@zyspec :
As you can see i used (copy/paste) many of your codes for xoopspoll 1.4 functionality in newbb located in xoopspoll/extras/newbb_4x/irmtfan (so you can remove that extra in your next versions)
Therefore thanks to your codes, I didnt have to put time to learn your xoopspoll 1.4 functionality.
Of course there were some bugs which i solved. so it was a good team work.
After that I decided to make newbb work with any poll module regardless of version or dirname so i did that too.
Quote:
That's no longer true (could be a clone of xoopspoll or umfrage). I'll have to create a function to determine if the polls are associated with 'this' copy of xoopspoll and then take the appropriate actions.
Yes previously it was hardcoded to "xoopspoll"
Today i add a function to find poll module that is in used in the current newbb installation.
This function is totally reliable and you can use it. so you dont need to put time on it.
// START irmtfan findPollModule
/**
* find poll module that is in used in the current newbb installtion.
* @access public
* @param array $pollDirs dirnames of all active poll modules
* @return string $dir_def | true | false
* $dir_def: dirname of poll module that is in used in the current newbb installtion.
* true: no poll module is installed | newbb has no topic with poll | newbb has no topic
* false: errors (see below xoops_errors)
*/
public function findPollModule($pollDirs = array()) {
if(empty($pollDirs)) $pollDirs = $this->getActivePolls();
if(empty($pollDirs)) return true;
// if only one active poll module still we need to check!!!
//if(count($pollDirs) == 1) return end($pollDirs);
$topicPollObjs = $this->getAll(new Criteria("topic_haspoll", 1));
if(empty($topicPollObjs)) return true; // no poll or no topic!!!
foreach($topicPollObjs as $tObj) {
$poll_idInMod = 0;
foreach($pollDirs as $dirname) {
$pollObj = $tObj->getPoll($tObj->getVar("poll_id"), $dirname);
if(is_object($pollObj) && ($pollObj->getVar("poll_id") == $tObj->getVar("poll_id"))) {
$poll_idInMod++;
$dir_def = $dirname;
}
}
// Only one poll module should has this poll_id
// if 0 there is an error
if($poll_idInMod == 0) {
xoops_error("Error: Cannot find poll module for poll_id='{$tObj->getVar('poll_id')}'");
return false;
}
// if 1 => $dir_def is correct
if($poll_idInMod == 1) {
return $dir_def;
}
// if more than 1 continue
}
// if there is some topics but no module or more than one module have polls
xoops_error("Error: Cannot find poll module that is in used in newbb!!! <br><br>You should select the correct poll module yourself in newbb > preferences > poll module setting.");
return false;
}
// END irmtfan findPollModule
so the usage is as simple as this:
$topic_handler = xoops_getmodulehandler('topic', 'newbb');
$poll_module_in_use = $topic_handler->findPollModule();
as you can see the output is informative:
Quote:
* $dir_def: dirname of poll module that is in used in the current newbb installation.
* true: no poll module is installed | newbb has no topic with poll | newbb has no topic
* false: errors (see below xoops_errors)
I used that in 'OnUpdate' and 'preferences saving' processes to make sure the "poll_module" config will be saved correctly.
I changed the version to newbb 4.33 and RC7:
http://svn.code.sf.net/p/xoops/svn/Xo ... b/branches/irmtfan/newbb/Quote:
the 'hard coded date() functoin' usage - I thought I'd removed those where applicable.
yes.
eg: in xoopspoll/class/renderer.php line 173 should be replaced by this
$xuEndFormatted = formatTimeStamp($xuEndTimestamp);
I think it would be the best solution for you to write a helper class and be free from any dirname, config, handler, date format, ... in next version of xoopspoll
helper really reduce my coding time in userlog.
irmtfan
Module Developer

Joined:
2003/12/7 14:14
From In the middle of nowhere
Group:
Registered Users
Community Coordinator (temporary)
(Show More)
(Show Less)