@@ -44,12 +44,12 @@ |
||
| 44 | 44 | */ |
| 45 | 45 | class Readtopic extends Newbb\Read |
| 46 | 46 | { |
| 47 | - /** |
|
| 48 | - * |
|
| 49 | - */ |
|
| 50 | - public function __construct() |
|
| 51 | - { |
|
| 52 | - parent::__construct(); |
|
| 53 | - //$this->initVar('forum_id', XOBJ_DTYPE_INT); |
|
| 54 | - } |
|
| 47 | + /** |
|
| 48 | + * |
|
| 49 | + */ |
|
| 50 | + public function __construct() |
|
| 51 | + { |
|
| 52 | + parent::__construct(); |
|
| 53 | + //$this->initVar('forum_id', XOBJ_DTYPE_INT); |
|
| 54 | + } |
|
| 55 | 55 | } |
@@ -22,186 +22,186 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | class Topic extends \XoopsObject |
| 24 | 24 | { |
| 25 | - /** |
|
| 26 | - * |
|
| 27 | - */ |
|
| 28 | - public function __construct() |
|
| 29 | - { |
|
| 30 | - parent::__construct(); |
|
| 31 | - $this->initVar('topic_id', XOBJ_DTYPE_INT); |
|
| 32 | - $this->initVar('topic_title', XOBJ_DTYPE_TXTBOX); |
|
| 33 | - $this->initVar('topic_poster', XOBJ_DTYPE_INT); |
|
| 34 | - $this->initVar('topic_time', XOBJ_DTYPE_INT); |
|
| 35 | - $this->initVar('topic_views', XOBJ_DTYPE_INT); |
|
| 36 | - $this->initVar('topic_replies', XOBJ_DTYPE_INT); |
|
| 37 | - $this->initVar('topic_last_post_id', XOBJ_DTYPE_INT); |
|
| 38 | - $this->initVar('forum_id', XOBJ_DTYPE_INT); |
|
| 39 | - $this->initVar('topic_status', XOBJ_DTYPE_INT); |
|
| 40 | - $this->initVar('type_id', XOBJ_DTYPE_INT); |
|
| 41 | - $this->initVar('topic_sticky', XOBJ_DTYPE_INT); |
|
| 42 | - $this->initVar('topic_digest', XOBJ_DTYPE_INT); |
|
| 43 | - $this->initVar('digest_time', XOBJ_DTYPE_INT); |
|
| 44 | - $this->initVar('approved', XOBJ_DTYPE_INT); |
|
| 45 | - $this->initVar('poster_name', XOBJ_DTYPE_TXTBOX); |
|
| 46 | - $this->initVar('rating', XOBJ_DTYPE_OTHER); |
|
| 47 | - $this->initVar('votes', XOBJ_DTYPE_INT); |
|
| 48 | - $this->initVar('topic_haspoll', XOBJ_DTYPE_INT); |
|
| 49 | - $this->initVar('poll_id', XOBJ_DTYPE_INT); |
|
| 50 | - $this->initVar('topic_tags', XOBJ_DTYPE_SOURCE); |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - // irmtfan add LAST_INSERT_ID to enhance the mysql performances |
|
| 54 | - public function incrementCounter() |
|
| 55 | - { |
|
| 56 | - $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('newbb_topics') . ' SET topic_views = LAST_INSERT_ID(topic_views + 1) WHERE topic_id =' . $this->getVar('topic_id'); |
|
| 57 | - $GLOBALS['xoopsDB']->queryF($sql); |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * Create full title of the topic |
|
| 62 | - * |
|
| 63 | - * the title is composed of [type_name] if type_id is greater than 0 plus topic_title |
|
| 64 | - * |
|
| 65 | - */ |
|
| 66 | - public function getFullTitle() |
|
| 67 | - { |
|
| 68 | - $topic_title = $this->getVar('topic_title'); |
|
| 69 | - if (!$this->getVar('type_id')) { |
|
| 70 | - return $topic_title; |
|
| 71 | - } |
|
| 72 | - $typeHandler = Newbb\Helper::getInstance()->getHandler('Type'); |
|
| 73 | - if (!$typeObject = $typeHandler->get($this->getVar('type_id'))) { |
|
| 74 | - return $topic_title; |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - require_once dirname(__DIR__) . '/include/functions.topic.php'; |
|
| 78 | - |
|
| 79 | - return getTopicTitle($topic_title, $typeObject->getVar('type_name'), $typeObject->getVar('type_color')); |
|
| 80 | - } |
|
| 81 | - // START irmtfan loadOldPoll function |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * Load functions needed for old xoopspoll (older than version 1.4 by zyspec) and umfrage modules |
|
| 85 | - * |
|
| 86 | - * @access public |
|
| 87 | - * @param string $pollModule dirname of the poll module |
|
| 88 | - * @return string|false $classPoll = the name of the old poll class eg: "XoopsPoll" | "Umfrage" |
|
| 89 | - */ |
|
| 90 | - |
|
| 91 | - public function loadOldPoll($pollModule = null) |
|
| 92 | - { |
|
| 93 | - static $classPoll = false; |
|
| 94 | - if ($classPoll && empty($pollModule)) { |
|
| 95 | - return $classPoll; |
|
| 96 | - } |
|
| 97 | - $newbbConfig = newbbLoadConfig(); |
|
| 98 | - if (!empty($pollModule)) { |
|
| 99 | - $newbbConfig['poll_module'] = $pollModule; |
|
| 100 | - } |
|
| 25 | + /** |
|
| 26 | + * |
|
| 27 | + */ |
|
| 28 | + public function __construct() |
|
| 29 | + { |
|
| 30 | + parent::__construct(); |
|
| 31 | + $this->initVar('topic_id', XOBJ_DTYPE_INT); |
|
| 32 | + $this->initVar('topic_title', XOBJ_DTYPE_TXTBOX); |
|
| 33 | + $this->initVar('topic_poster', XOBJ_DTYPE_INT); |
|
| 34 | + $this->initVar('topic_time', XOBJ_DTYPE_INT); |
|
| 35 | + $this->initVar('topic_views', XOBJ_DTYPE_INT); |
|
| 36 | + $this->initVar('topic_replies', XOBJ_DTYPE_INT); |
|
| 37 | + $this->initVar('topic_last_post_id', XOBJ_DTYPE_INT); |
|
| 38 | + $this->initVar('forum_id', XOBJ_DTYPE_INT); |
|
| 39 | + $this->initVar('topic_status', XOBJ_DTYPE_INT); |
|
| 40 | + $this->initVar('type_id', XOBJ_DTYPE_INT); |
|
| 41 | + $this->initVar('topic_sticky', XOBJ_DTYPE_INT); |
|
| 42 | + $this->initVar('topic_digest', XOBJ_DTYPE_INT); |
|
| 43 | + $this->initVar('digest_time', XOBJ_DTYPE_INT); |
|
| 44 | + $this->initVar('approved', XOBJ_DTYPE_INT); |
|
| 45 | + $this->initVar('poster_name', XOBJ_DTYPE_TXTBOX); |
|
| 46 | + $this->initVar('rating', XOBJ_DTYPE_OTHER); |
|
| 47 | + $this->initVar('votes', XOBJ_DTYPE_INT); |
|
| 48 | + $this->initVar('topic_haspoll', XOBJ_DTYPE_INT); |
|
| 49 | + $this->initVar('poll_id', XOBJ_DTYPE_INT); |
|
| 50 | + $this->initVar('topic_tags', XOBJ_DTYPE_SOURCE); |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + // irmtfan add LAST_INSERT_ID to enhance the mysql performances |
|
| 54 | + public function incrementCounter() |
|
| 55 | + { |
|
| 56 | + $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('newbb_topics') . ' SET topic_views = LAST_INSERT_ID(topic_views + 1) WHERE topic_id =' . $this->getVar('topic_id'); |
|
| 57 | + $GLOBALS['xoopsDB']->queryF($sql); |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * Create full title of the topic |
|
| 62 | + * |
|
| 63 | + * the title is composed of [type_name] if type_id is greater than 0 plus topic_title |
|
| 64 | + * |
|
| 65 | + */ |
|
| 66 | + public function getFullTitle() |
|
| 67 | + { |
|
| 68 | + $topic_title = $this->getVar('topic_title'); |
|
| 69 | + if (!$this->getVar('type_id')) { |
|
| 70 | + return $topic_title; |
|
| 71 | + } |
|
| 72 | + $typeHandler = Newbb\Helper::getInstance()->getHandler('Type'); |
|
| 73 | + if (!$typeObject = $typeHandler->get($this->getVar('type_id'))) { |
|
| 74 | + return $topic_title; |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + require_once dirname(__DIR__) . '/include/functions.topic.php'; |
|
| 78 | + |
|
| 79 | + return getTopicTitle($topic_title, $typeObject->getVar('type_name'), $typeObject->getVar('type_color')); |
|
| 80 | + } |
|
| 81 | + // START irmtfan loadOldPoll function |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * Load functions needed for old xoopspoll (older than version 1.4 by zyspec) and umfrage modules |
|
| 85 | + * |
|
| 86 | + * @access public |
|
| 87 | + * @param string $pollModule dirname of the poll module |
|
| 88 | + * @return string|false $classPoll = the name of the old poll class eg: "XoopsPoll" | "Umfrage" |
|
| 89 | + */ |
|
| 90 | + |
|
| 91 | + public function loadOldPoll($pollModule = null) |
|
| 92 | + { |
|
| 93 | + static $classPoll = false; |
|
| 94 | + if ($classPoll && empty($pollModule)) { |
|
| 95 | + return $classPoll; |
|
| 96 | + } |
|
| 97 | + $newbbConfig = newbbLoadConfig(); |
|
| 98 | + if (!empty($pollModule)) { |
|
| 99 | + $newbbConfig['poll_module'] = $pollModule; |
|
| 100 | + } |
|
| 101 | 101 | // $relPath = $GLOBALS['xoops']->path('modules/' . $newbbConfig['poll_module'] . '/class/' . $newbbConfig['poll_module']); |
| 102 | 102 | // require_once $relPath . '.php'; |
| 103 | 103 | // require_once $relPath . 'option.php'; |
| 104 | 104 | // require_once $relPath . 'log.php'; |
| 105 | 105 | // require_once $relPath . 'renderer.php'; |
| 106 | - $classes = get_declared_classes(); |
|
| 107 | - foreach (array_reverse($classes) as $class) { |
|
| 108 | - if (strtolower($class) == $newbbConfig['poll_module']) { |
|
| 109 | - $classPoll = $class; |
|
| 110 | - |
|
| 111 | - return $classPoll; |
|
| 112 | - } |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - return false; |
|
| 116 | - } |
|
| 117 | - // END irmtfan loadOldPoll function |
|
| 118 | - // START irmtfan add deletePoll function |
|
| 119 | - /** |
|
| 120 | - * delete a poll in database |
|
| 121 | - * |
|
| 122 | - * @access public |
|
| 123 | - * @param int $poll_id |
|
| 124 | - * @return bool |
|
| 125 | - */ |
|
| 126 | - public function deletePoll($poll_id) |
|
| 127 | - { |
|
| 128 | - if (empty($poll_id)) { |
|
| 129 | - return false; |
|
| 130 | - } |
|
| 131 | - /** @var \XoopsModuleHandler $moduleHandler */ |
|
| 132 | - $moduleHandler = xoops_getHandler('module'); |
|
| 133 | - $newbbConfig = newbbLoadConfig(); |
|
| 134 | - $pollModuleHandler = $moduleHandler->getByDirname($newbbConfig['poll_module']); |
|
| 135 | - if (!is_object($pollModuleHandler) || !$pollModuleHandler->getVar('isactive')) { |
|
| 136 | - return false; |
|
| 137 | - } |
|
| 138 | - // new xoopspoll module |
|
| 139 | - if ($pollModuleHandler->getVar('version') >= 140) { |
|
| 140 | - /** @var \XoopsPollHandler $pollHandler */ |
|
| 141 | - $pollHandler = Xoopspoll\Helper::getInstance()->getHandler('Poll'); |
|
| 142 | - if (false !== $pollHandler->deleteAll(new \Criteria('poll_id', $poll_id, '='))) { |
|
| 143 | - /** @var XoopsPoll\OptionHandler $optionHandler */ |
|
| 144 | - $optionHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); |
|
| 145 | - $optionHandler->deleteAll(new \Criteria('poll_id', $poll_id, '=')); |
|
| 146 | - /** @var XoopsPoll\LogHandler $logHandler */ |
|
| 147 | - $logHandler = Xoopspoll\Helper::getInstance()->getHandler('Log'); |
|
| 148 | - $logHandler->deleteAll(new \Criteria('poll_id', $poll_id, '=')); |
|
| 149 | - xoops_comment_delete($GLOBALS['xoopsModule']->getVar('mid'), $poll_id); |
|
| 150 | - } |
|
| 151 | - // old Xoopspoll or Umfrage or any clone from them |
|
| 152 | - } else { |
|
| 153 | - $classPoll = $this->loadOldPoll(); |
|
| 154 | - /** @var \XoopsPoll $poll */ |
|
| 155 | - $poll = new $classPoll($poll_id); |
|
| 156 | - if (false !== $poll->delete()) { |
|
| 157 | - $classOption = $classPoll . 'Option'; |
|
| 158 | - $classOption::deleteByPollId($poll->getVar('poll_id')); |
|
| 159 | - $classLog = $classPoll . 'Log'; |
|
| 160 | - $classLog::deleteByPollId($poll->getVar('poll_id')); |
|
| 161 | - xoops_comment_delete($GLOBALS['xoopsModule']->getVar('mid'), $poll->getVar('poll_id')); |
|
| 162 | - } |
|
| 163 | - } // end poll_module new or old |
|
| 164 | - |
|
| 165 | - return true; |
|
| 166 | - } |
|
| 167 | - // END irmtfan add deletePoll function |
|
| 168 | - |
|
| 169 | - // START irmtfan add getPoll function |
|
| 170 | - /** |
|
| 171 | - * get a poll object from a poll module. |
|
| 172 | - * note: can be used to find if a poll exist in a module |
|
| 173 | - * @access public |
|
| 174 | - * @param int $poll_id |
|
| 175 | - * @param string $pollModule dirname of the poll module |
|
| 176 | - * @return bool|\XoopsObject poll |
|
| 177 | - */ |
|
| 178 | - public function getPoll($poll_id, $pollModule = null) |
|
| 179 | - { |
|
| 180 | - if (empty($poll_id)) { |
|
| 181 | - return false; |
|
| 182 | - } |
|
| 183 | - /** @var \XoopsModuleHandler $moduleHandler */ |
|
| 184 | - $moduleHandler = xoops_getHandler('module'); |
|
| 185 | - $newbbConfig = newbbLoadConfig(); |
|
| 186 | - if (!empty($pollModule)) { |
|
| 187 | - $newbbConfig['poll_module'] = $pollModule; |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - $pollModuleHandler = $moduleHandler->getByDirname($newbbConfig['poll_module']); |
|
| 191 | - if (!is_object($pollModuleHandler) || !$pollModuleHandler->getVar('isactive')) { |
|
| 192 | - return false; |
|
| 193 | - } |
|
| 194 | - // new xoopspoll module |
|
| 195 | - if ($pollModuleHandler->getVar('version') >= 140) { |
|
| 196 | - $pollHandler = Xoopspoll\Helper::getInstance()->getHandler('Poll'); |
|
| 197 | - $pollObject = $pollHandler->get($poll_id); |
|
| 198 | - // old xoopspoll or umfrage or any clone from them |
|
| 199 | - } else { |
|
| 200 | - $classPoll = $this->loadOldPoll($newbbConfig['poll_module']); |
|
| 201 | - $pollObject = new $classPoll($poll_id); |
|
| 202 | - } // end poll_module new or old |
|
| 203 | - |
|
| 204 | - return $pollObject; |
|
| 205 | - } |
|
| 206 | - // END irmtfan add getPoll function |
|
| 106 | + $classes = get_declared_classes(); |
|
| 107 | + foreach (array_reverse($classes) as $class) { |
|
| 108 | + if (strtolower($class) == $newbbConfig['poll_module']) { |
|
| 109 | + $classPoll = $class; |
|
| 110 | + |
|
| 111 | + return $classPoll; |
|
| 112 | + } |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + return false; |
|
| 116 | + } |
|
| 117 | + // END irmtfan loadOldPoll function |
|
| 118 | + // START irmtfan add deletePoll function |
|
| 119 | + /** |
|
| 120 | + * delete a poll in database |
|
| 121 | + * |
|
| 122 | + * @access public |
|
| 123 | + * @param int $poll_id |
|
| 124 | + * @return bool |
|
| 125 | + */ |
|
| 126 | + public function deletePoll($poll_id) |
|
| 127 | + { |
|
| 128 | + if (empty($poll_id)) { |
|
| 129 | + return false; |
|
| 130 | + } |
|
| 131 | + /** @var \XoopsModuleHandler $moduleHandler */ |
|
| 132 | + $moduleHandler = xoops_getHandler('module'); |
|
| 133 | + $newbbConfig = newbbLoadConfig(); |
|
| 134 | + $pollModuleHandler = $moduleHandler->getByDirname($newbbConfig['poll_module']); |
|
| 135 | + if (!is_object($pollModuleHandler) || !$pollModuleHandler->getVar('isactive')) { |
|
| 136 | + return false; |
|
| 137 | + } |
|
| 138 | + // new xoopspoll module |
|
| 139 | + if ($pollModuleHandler->getVar('version') >= 140) { |
|
| 140 | + /** @var \XoopsPollHandler $pollHandler */ |
|
| 141 | + $pollHandler = Xoopspoll\Helper::getInstance()->getHandler('Poll'); |
|
| 142 | + if (false !== $pollHandler->deleteAll(new \Criteria('poll_id', $poll_id, '='))) { |
|
| 143 | + /** @var XoopsPoll\OptionHandler $optionHandler */ |
|
| 144 | + $optionHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); |
|
| 145 | + $optionHandler->deleteAll(new \Criteria('poll_id', $poll_id, '=')); |
|
| 146 | + /** @var XoopsPoll\LogHandler $logHandler */ |
|
| 147 | + $logHandler = Xoopspoll\Helper::getInstance()->getHandler('Log'); |
|
| 148 | + $logHandler->deleteAll(new \Criteria('poll_id', $poll_id, '=')); |
|
| 149 | + xoops_comment_delete($GLOBALS['xoopsModule']->getVar('mid'), $poll_id); |
|
| 150 | + } |
|
| 151 | + // old Xoopspoll or Umfrage or any clone from them |
|
| 152 | + } else { |
|
| 153 | + $classPoll = $this->loadOldPoll(); |
|
| 154 | + /** @var \XoopsPoll $poll */ |
|
| 155 | + $poll = new $classPoll($poll_id); |
|
| 156 | + if (false !== $poll->delete()) { |
|
| 157 | + $classOption = $classPoll . 'Option'; |
|
| 158 | + $classOption::deleteByPollId($poll->getVar('poll_id')); |
|
| 159 | + $classLog = $classPoll . 'Log'; |
|
| 160 | + $classLog::deleteByPollId($poll->getVar('poll_id')); |
|
| 161 | + xoops_comment_delete($GLOBALS['xoopsModule']->getVar('mid'), $poll->getVar('poll_id')); |
|
| 162 | + } |
|
| 163 | + } // end poll_module new or old |
|
| 164 | + |
|
| 165 | + return true; |
|
| 166 | + } |
|
| 167 | + // END irmtfan add deletePoll function |
|
| 168 | + |
|
| 169 | + // START irmtfan add getPoll function |
|
| 170 | + /** |
|
| 171 | + * get a poll object from a poll module. |
|
| 172 | + * note: can be used to find if a poll exist in a module |
|
| 173 | + * @access public |
|
| 174 | + * @param int $poll_id |
|
| 175 | + * @param string $pollModule dirname of the poll module |
|
| 176 | + * @return bool|\XoopsObject poll |
|
| 177 | + */ |
|
| 178 | + public function getPoll($poll_id, $pollModule = null) |
|
| 179 | + { |
|
| 180 | + if (empty($poll_id)) { |
|
| 181 | + return false; |
|
| 182 | + } |
|
| 183 | + /** @var \XoopsModuleHandler $moduleHandler */ |
|
| 184 | + $moduleHandler = xoops_getHandler('module'); |
|
| 185 | + $newbbConfig = newbbLoadConfig(); |
|
| 186 | + if (!empty($pollModule)) { |
|
| 187 | + $newbbConfig['poll_module'] = $pollModule; |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + $pollModuleHandler = $moduleHandler->getByDirname($newbbConfig['poll_module']); |
|
| 191 | + if (!is_object($pollModuleHandler) || !$pollModuleHandler->getVar('isactive')) { |
|
| 192 | + return false; |
|
| 193 | + } |
|
| 194 | + // new xoopspoll module |
|
| 195 | + if ($pollModuleHandler->getVar('version') >= 140) { |
|
| 196 | + $pollHandler = Xoopspoll\Helper::getInstance()->getHandler('Poll'); |
|
| 197 | + $pollObject = $pollHandler->get($poll_id); |
|
| 198 | + // old xoopspoll or umfrage or any clone from them |
|
| 199 | + } else { |
|
| 200 | + $classPoll = $this->loadOldPoll($newbbConfig['poll_module']); |
|
| 201 | + $pollObject = new $classPoll($poll_id); |
|
| 202 | + } // end poll_module new or old |
|
| 203 | + |
|
| 204 | + return $pollObject; |
|
| 205 | + } |
|
| 206 | + // END irmtfan add getPoll function |
|
| 207 | 207 | } |
@@ -36,184 +36,184 @@ |
||
| 36 | 36 | */ |
| 37 | 37 | class IconHandler |
| 38 | 38 | { |
| 39 | - /** |
|
| 40 | - * reference to XOOPS template |
|
| 41 | - */ |
|
| 42 | - public $template; |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * image set |
|
| 46 | - */ |
|
| 47 | - private $forumImage = []; |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * prefix |
|
| 51 | - */ |
|
| 52 | - private $prefix = ''; |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * postfix, including extension |
|
| 56 | - */ |
|
| 57 | - private $postfix = '.png'; |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * images to be assigned to template |
|
| 61 | - */ |
|
| 62 | - private $images = []; |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * Constructor |
|
| 66 | - */ |
|
| 67 | - public function __construct() |
|
| 68 | - { |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * Access the only instance of this class |
|
| 73 | - * @return IconHandler |
|
| 74 | - */ |
|
| 75 | - public static function getInstance() |
|
| 76 | - { |
|
| 77 | - static $instance; |
|
| 78 | - if (null === $instance) { |
|
| 79 | - $instance = new static(); |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - return $instance; |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * TODO: get compatible with new theme engine |
|
| 87 | - * @param $type |
|
| 88 | - * @param string $dirname |
|
| 89 | - * @param string $default |
|
| 90 | - * @param string $endDir |
|
| 91 | - * @return mixed |
|
| 92 | - */ |
|
| 93 | - // START irmtfan - improve to get other "end dirnames" like "css" and "js" - change images with $endDir |
|
| 94 | - public function getPath($type, $dirname = 'newbb', $default = '', $endDir = 'images') |
|
| 95 | - { |
|
| 96 | - static $paths; |
|
| 97 | - if (isset($paths[$endDir . '/' . $type])) { |
|
| 98 | - return $paths[$endDir . '/' . $type]; |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - $theme_path = $this->template->currentTheme->path; |
|
| 102 | - $rel_dir = "modules/{$dirname}/{$endDir}"; |
|
| 103 | - // START irmtfan add default for all pathes |
|
| 104 | - if (empty($default)) { |
|
| 105 | - $path = is_dir($theme_path . "/{$rel_dir}/{$type}/") ? $theme_path . "/{$rel_dir}/{$type}" |
|
| 106 | - : (is_dir(XOOPS_THEME_PATH . "/default/{$rel_dir}/{$type}/") ? XOOPS_THEME_PATH . "/default/{$rel_dir}/{$type}" |
|
| 107 | - : $GLOBALS['xoops']->path("modules/{$dirname}/templates/{$endDir}/{$type}")); |
|
| 108 | - } else { |
|
| 109 | - $path = is_dir($theme_path . "/{$rel_dir}/{$type}/") ? $theme_path . "/{$rel_dir}/{$type}" : ( |
|
| 110 | - is_dir($theme_path . "/{$rel_dir}/{$default}/") ? $theme_path . "/{$rel_dir}/{$default}" : ( |
|
| 111 | - is_dir(XOOPS_THEME_PATH . "/default/{$rel_dir}/{$type}/") ? XOOPS_THEME_PATH |
|
| 112 | - . "/default/{$rel_dir}/{$type}" : ( |
|
| 113 | - is_dir(XOOPS_THEME_PATH . "/default/{$rel_dir}/{$default}/") ? XOOPS_THEME_PATH . "/default/{$rel_dir}/{$default}" |
|
| 114 | - : (is_dir($GLOBALS['xoops']->path("modules/{$dirname}/templates/{$endDir}/{$type}/")) ? $GLOBALS['xoops']->path("modules/{$dirname}/templates/{$endDir}/{$type}") |
|
| 115 | - : $GLOBALS['xoops']->path("modules/{$dirname}/templates/{$endDir}/{$default}")) // XOOPS_ROOT_PATH |
|
| 116 | - ) // XOOPS_THEME_PATH {$default} |
|
| 117 | - ) // XOOPS_THEME_PATH |
|
| 118 | - ); // $theme_path {$default} |
|
| 119 | - } |
|
| 120 | - // END irmtfan add default for all pathes |
|
| 121 | - $paths[$endDir . '/' . $type] = str_replace(XOOPS_ROOT_PATH, '', str_replace('\\', '/', $path)); |
|
| 122 | - |
|
| 123 | - return $paths[$endDir . '/' . $type]; |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - // END irmtfan - improve to get other "end dirnames" like "css" and "js" - change images with $endDir |
|
| 127 | - |
|
| 128 | - /** |
|
| 129 | - * @param string $language |
|
| 130 | - * @param string $dirname |
|
| 131 | - */ |
|
| 132 | - public function init(/*$set = "default", */ |
|
| 133 | - $language = 'english', |
|
| 134 | - $dirname = 'newbb' |
|
| 135 | - ) { |
|
| 136 | - $this->forumImage = require_once $GLOBALS['xoops']->path("modules/{$dirname}/include/images.php"); |
|
| 137 | - |
|
| 138 | - $this->forumImage['icon'] = XOOPS_URL . $this->getPath('icon', $dirname) . '/'; |
|
| 139 | - $this->forumImage['language'] = XOOPS_URL . $this->getPath("language/{$language}", $dirname, 'language/english') . '/'; |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - /** |
|
| 143 | - * @param $image |
|
| 144 | - * @param string $alt |
|
| 145 | - * @param string $extra |
|
| 146 | - */ |
|
| 147 | - public function setImage($image, $alt = '', $extra = '') |
|
| 148 | - { |
|
| 149 | - if (!isset($this->images[$image])) { |
|
| 150 | - $imageSource = $this->getImageSource($image); |
|
| 151 | - // irmtfan add id={$image} |
|
| 152 | - $this->images[$image] = "<img src=\"{$imageSource}\" alt=\"{$alt}\" title=\"{$alt}\" align=\"middle\" {$extra} id={$image} />"; |
|
| 153 | - } |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - /** |
|
| 157 | - * TODO: How about image not exist? |
|
| 158 | - * @param $image |
|
| 159 | - * @return string |
|
| 160 | - */ |
|
| 161 | - public function getImageSource($image) |
|
| 162 | - { |
|
| 163 | - return $this->forumImage[$this->forumImage[$image]] . $this->prefix . $image . $this->postfix; |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - /** |
|
| 167 | - * @param $image |
|
| 168 | - * @param string $alt |
|
| 169 | - * @param string $extra |
|
| 170 | - * @return mixed |
|
| 171 | - */ |
|
| 172 | - public function getImage($image, $alt = '', $extra = '') |
|
| 173 | - { |
|
| 174 | - $this->setImage($image, $alt, $extra); |
|
| 175 | - |
|
| 176 | - return $this->images[$image]; |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - /** |
|
| 180 | - * @param $image |
|
| 181 | - * @param string $alt |
|
| 182 | - * @param string $extra |
|
| 183 | - * @return string |
|
| 184 | - */ |
|
| 185 | - public function assignImage($image, $alt = '', $extra = '') |
|
| 186 | - { |
|
| 187 | - $this->setImage($image, $alt, $extra); |
|
| 188 | - // START hacked by irmtfan - improve function to CSS3 buttons - add alt and title attributes - use span instead of button to support IE7&8 |
|
| 189 | - $tag = 'span'; |
|
| 190 | - if ("class='forum_icon'" === $extra && in_array(substr($image, 0, 2), ['t_', 'p_', 'up'])) { |
|
| 191 | - $extra = "class='forum_icon forum_button'"; |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - return "<{$tag} alt=\"{$alt}\" title=\"{$alt}\" align=\"middle\" {$extra} id={$image}>$alt</{$tag}>"; |
|
| 195 | - // END hacked by irmtfan - improve function to CSS3 buttons |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - /** |
|
| 199 | - * @param $images |
|
| 200 | - */ |
|
| 201 | - public function assignImages($images) |
|
| 202 | - { |
|
| 203 | - foreach ($images as $myImage) { |
|
| 204 | - list($image, $alt, $extra) = $myImage; |
|
| 205 | - $this->assignImage($image, $alt, $extra); |
|
| 206 | - } |
|
| 207 | - } |
|
| 208 | - |
|
| 209 | - /** |
|
| 210 | - * @return int|void |
|
| 211 | - */ |
|
| 212 | - public function render() |
|
| 213 | - { |
|
| 214 | - //$this->template->assign_by_ref("image", $this->images); |
|
| 215 | - $this->template->assign($this->images); |
|
| 216 | - |
|
| 217 | - return count($this->images); |
|
| 218 | - } |
|
| 39 | + /** |
|
| 40 | + * reference to XOOPS template |
|
| 41 | + */ |
|
| 42 | + public $template; |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * image set |
|
| 46 | + */ |
|
| 47 | + private $forumImage = []; |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * prefix |
|
| 51 | + */ |
|
| 52 | + private $prefix = ''; |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * postfix, including extension |
|
| 56 | + */ |
|
| 57 | + private $postfix = '.png'; |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * images to be assigned to template |
|
| 61 | + */ |
|
| 62 | + private $images = []; |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * Constructor |
|
| 66 | + */ |
|
| 67 | + public function __construct() |
|
| 68 | + { |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * Access the only instance of this class |
|
| 73 | + * @return IconHandler |
|
| 74 | + */ |
|
| 75 | + public static function getInstance() |
|
| 76 | + { |
|
| 77 | + static $instance; |
|
| 78 | + if (null === $instance) { |
|
| 79 | + $instance = new static(); |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + return $instance; |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * TODO: get compatible with new theme engine |
|
| 87 | + * @param $type |
|
| 88 | + * @param string $dirname |
|
| 89 | + * @param string $default |
|
| 90 | + * @param string $endDir |
|
| 91 | + * @return mixed |
|
| 92 | + */ |
|
| 93 | + // START irmtfan - improve to get other "end dirnames" like "css" and "js" - change images with $endDir |
|
| 94 | + public function getPath($type, $dirname = 'newbb', $default = '', $endDir = 'images') |
|
| 95 | + { |
|
| 96 | + static $paths; |
|
| 97 | + if (isset($paths[$endDir . '/' . $type])) { |
|
| 98 | + return $paths[$endDir . '/' . $type]; |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + $theme_path = $this->template->currentTheme->path; |
|
| 102 | + $rel_dir = "modules/{$dirname}/{$endDir}"; |
|
| 103 | + // START irmtfan add default for all pathes |
|
| 104 | + if (empty($default)) { |
|
| 105 | + $path = is_dir($theme_path . "/{$rel_dir}/{$type}/") ? $theme_path . "/{$rel_dir}/{$type}" |
|
| 106 | + : (is_dir(XOOPS_THEME_PATH . "/default/{$rel_dir}/{$type}/") ? XOOPS_THEME_PATH . "/default/{$rel_dir}/{$type}" |
|
| 107 | + : $GLOBALS['xoops']->path("modules/{$dirname}/templates/{$endDir}/{$type}")); |
|
| 108 | + } else { |
|
| 109 | + $path = is_dir($theme_path . "/{$rel_dir}/{$type}/") ? $theme_path . "/{$rel_dir}/{$type}" : ( |
|
| 110 | + is_dir($theme_path . "/{$rel_dir}/{$default}/") ? $theme_path . "/{$rel_dir}/{$default}" : ( |
|
| 111 | + is_dir(XOOPS_THEME_PATH . "/default/{$rel_dir}/{$type}/") ? XOOPS_THEME_PATH |
|
| 112 | + . "/default/{$rel_dir}/{$type}" : ( |
|
| 113 | + is_dir(XOOPS_THEME_PATH . "/default/{$rel_dir}/{$default}/") ? XOOPS_THEME_PATH . "/default/{$rel_dir}/{$default}" |
|
| 114 | + : (is_dir($GLOBALS['xoops']->path("modules/{$dirname}/templates/{$endDir}/{$type}/")) ? $GLOBALS['xoops']->path("modules/{$dirname}/templates/{$endDir}/{$type}") |
|
| 115 | + : $GLOBALS['xoops']->path("modules/{$dirname}/templates/{$endDir}/{$default}")) // XOOPS_ROOT_PATH |
|
| 116 | + ) // XOOPS_THEME_PATH {$default} |
|
| 117 | + ) // XOOPS_THEME_PATH |
|
| 118 | + ); // $theme_path {$default} |
|
| 119 | + } |
|
| 120 | + // END irmtfan add default for all pathes |
|
| 121 | + $paths[$endDir . '/' . $type] = str_replace(XOOPS_ROOT_PATH, '', str_replace('\\', '/', $path)); |
|
| 122 | + |
|
| 123 | + return $paths[$endDir . '/' . $type]; |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + // END irmtfan - improve to get other "end dirnames" like "css" and "js" - change images with $endDir |
|
| 127 | + |
|
| 128 | + /** |
|
| 129 | + * @param string $language |
|
| 130 | + * @param string $dirname |
|
| 131 | + */ |
|
| 132 | + public function init(/*$set = "default", */ |
|
| 133 | + $language = 'english', |
|
| 134 | + $dirname = 'newbb' |
|
| 135 | + ) { |
|
| 136 | + $this->forumImage = require_once $GLOBALS['xoops']->path("modules/{$dirname}/include/images.php"); |
|
| 137 | + |
|
| 138 | + $this->forumImage['icon'] = XOOPS_URL . $this->getPath('icon', $dirname) . '/'; |
|
| 139 | + $this->forumImage['language'] = XOOPS_URL . $this->getPath("language/{$language}", $dirname, 'language/english') . '/'; |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + /** |
|
| 143 | + * @param $image |
|
| 144 | + * @param string $alt |
|
| 145 | + * @param string $extra |
|
| 146 | + */ |
|
| 147 | + public function setImage($image, $alt = '', $extra = '') |
|
| 148 | + { |
|
| 149 | + if (!isset($this->images[$image])) { |
|
| 150 | + $imageSource = $this->getImageSource($image); |
|
| 151 | + // irmtfan add id={$image} |
|
| 152 | + $this->images[$image] = "<img src=\"{$imageSource}\" alt=\"{$alt}\" title=\"{$alt}\" align=\"middle\" {$extra} id={$image} />"; |
|
| 153 | + } |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + /** |
|
| 157 | + * TODO: How about image not exist? |
|
| 158 | + * @param $image |
|
| 159 | + * @return string |
|
| 160 | + */ |
|
| 161 | + public function getImageSource($image) |
|
| 162 | + { |
|
| 163 | + return $this->forumImage[$this->forumImage[$image]] . $this->prefix . $image . $this->postfix; |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + /** |
|
| 167 | + * @param $image |
|
| 168 | + * @param string $alt |
|
| 169 | + * @param string $extra |
|
| 170 | + * @return mixed |
|
| 171 | + */ |
|
| 172 | + public function getImage($image, $alt = '', $extra = '') |
|
| 173 | + { |
|
| 174 | + $this->setImage($image, $alt, $extra); |
|
| 175 | + |
|
| 176 | + return $this->images[$image]; |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + /** |
|
| 180 | + * @param $image |
|
| 181 | + * @param string $alt |
|
| 182 | + * @param string $extra |
|
| 183 | + * @return string |
|
| 184 | + */ |
|
| 185 | + public function assignImage($image, $alt = '', $extra = '') |
|
| 186 | + { |
|
| 187 | + $this->setImage($image, $alt, $extra); |
|
| 188 | + // START hacked by irmtfan - improve function to CSS3 buttons - add alt and title attributes - use span instead of button to support IE7&8 |
|
| 189 | + $tag = 'span'; |
|
| 190 | + if ("class='forum_icon'" === $extra && in_array(substr($image, 0, 2), ['t_', 'p_', 'up'])) { |
|
| 191 | + $extra = "class='forum_icon forum_button'"; |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + return "<{$tag} alt=\"{$alt}\" title=\"{$alt}\" align=\"middle\" {$extra} id={$image}>$alt</{$tag}>"; |
|
| 195 | + // END hacked by irmtfan - improve function to CSS3 buttons |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + /** |
|
| 199 | + * @param $images |
|
| 200 | + */ |
|
| 201 | + public function assignImages($images) |
|
| 202 | + { |
|
| 203 | + foreach ($images as $myImage) { |
|
| 204 | + list($image, $alt, $extra) = $myImage; |
|
| 205 | + $this->assignImage($image, $alt, $extra); |
|
| 206 | + } |
|
| 207 | + } |
|
| 208 | + |
|
| 209 | + /** |
|
| 210 | + * @return int|void |
|
| 211 | + */ |
|
| 212 | + public function render() |
|
| 213 | + { |
|
| 214 | + //$this->template->assign_by_ref("image", $this->images); |
|
| 215 | + $this->template->assign($this->images); |
|
| 216 | + |
|
| 217 | + return count($this->images); |
|
| 218 | + } |
|
| 219 | 219 | } |
@@ -19,19 +19,19 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | class Report extends \XoopsObject |
| 21 | 21 | { |
| 22 | - /** |
|
| 23 | - * |
|
| 24 | - */ |
|
| 25 | - public function __construct() |
|
| 26 | - { |
|
| 27 | - parent::__construct(); |
|
| 28 | - $this->initVar('report_id', XOBJ_DTYPE_INT); |
|
| 29 | - $this->initVar('post_id', XOBJ_DTYPE_INT); |
|
| 30 | - $this->initVar('reporter_uid', XOBJ_DTYPE_INT); |
|
| 31 | - $this->initVar('reporter_ip', XOBJ_DTYPE_TXTBOX); |
|
| 32 | - $this->initVar('report_time', XOBJ_DTYPE_INT); |
|
| 33 | - $this->initVar('report_text', XOBJ_DTYPE_TXTBOX); |
|
| 34 | - $this->initVar('report_result', XOBJ_DTYPE_INT); |
|
| 35 | - $this->initVar('report_memo', XOBJ_DTYPE_TXTBOX); |
|
| 36 | - } |
|
| 22 | + /** |
|
| 23 | + * |
|
| 24 | + */ |
|
| 25 | + public function __construct() |
|
| 26 | + { |
|
| 27 | + parent::__construct(); |
|
| 28 | + $this->initVar('report_id', XOBJ_DTYPE_INT); |
|
| 29 | + $this->initVar('post_id', XOBJ_DTYPE_INT); |
|
| 30 | + $this->initVar('reporter_uid', XOBJ_DTYPE_INT); |
|
| 31 | + $this->initVar('reporter_ip', XOBJ_DTYPE_TXTBOX); |
|
| 32 | + $this->initVar('report_time', XOBJ_DTYPE_INT); |
|
| 33 | + $this->initVar('report_text', XOBJ_DTYPE_TXTBOX); |
|
| 34 | + $this->initVar('report_result', XOBJ_DTYPE_INT); |
|
| 35 | + $this->initVar('report_memo', XOBJ_DTYPE_TXTBOX); |
|
| 36 | + } |
|
| 37 | 37 | } |
@@ -37,119 +37,119 @@ |
||
| 37 | 37 | //$topicHandler = Newbb\Helper::getInstance()->getHandler('Topic'); |
| 38 | 38 | $topicObject = $topicHandler->get($topic_id); |
| 39 | 39 | if (!$topicHandler->getPermission($topicObject->getVar('forum_id'), $topicObject->getVar('topic_status'), 'vote')) { |
| 40 | - redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _NOPERM); |
|
| 40 | + redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _NOPERM); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | if (!Request::getInt('option_id', 0, 'POST')) { |
| 44 | - // irmtfan - add error message - simple url |
|
| 45 | - redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id={$topic_id}", 1, _MD_NEWBB_POLL_NOOPTION); |
|
| 44 | + // irmtfan - add error message - simple url |
|
| 45 | + redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id={$topic_id}", 1, _MD_NEWBB_POLL_NOOPTION); |
|
| 46 | 46 | } |
| 47 | 47 | // poll module |
| 48 | 48 | $pollModuleHandler = $moduleHandler->getByDirname($GLOBALS['xoopsModuleConfig']['poll_module']); |
| 49 | 49 | if (is_object($pollModuleHandler) && $pollModuleHandler->getVar('isactive')) { |
| 50 | - // new xoopspoll module |
|
| 51 | - if ($pollModuleHandler->getVar('version') >= 140) { |
|
| 52 | - xoops_load('constants', $GLOBALS['xoopsModuleConfig']['poll_module']); |
|
| 53 | - xoops_loadLanguage('main', $GLOBALS['xoopsModuleConfig']['poll_module']); |
|
| 50 | + // new xoopspoll module |
|
| 51 | + if ($pollModuleHandler->getVar('version') >= 140) { |
|
| 52 | + xoops_load('constants', $GLOBALS['xoopsModuleConfig']['poll_module']); |
|
| 53 | + xoops_loadLanguage('main', $GLOBALS['xoopsModuleConfig']['poll_module']); |
|
| 54 | 54 | |
| 55 | - /** @var Xoopspoll\PollHandler $xpPollHandler */ |
|
| 56 | - $xpPollHandler = Xoopspoll\Helper::getInstance()->getHandler('Poll'); |
|
| 57 | - /** @var Xoopspoll\LogHandler $xpLogHandler */ |
|
| 58 | - $xpLogHandler = Xoopspoll\Helper::getInstance()->getHandler('Log'); |
|
| 59 | - /** @var Xoopspoll\Poll $pollObject */ |
|
| 60 | - $pollObject = $xpPollHandler->get($poll_id); // will create poll if poll_id = 0 exist |
|
| 61 | - // old xoopspoll or umfrage or any clone from them |
|
| 62 | - } else { |
|
| 63 | - require_once $GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/include/constants.php'); |
|
| 64 | - $classPoll = $topicObject->loadOldPoll(); |
|
| 65 | - $pollObject = new $classPoll($poll_id); // will create poll if poll_id = 0 exist |
|
| 66 | - } |
|
| 55 | + /** @var Xoopspoll\PollHandler $xpPollHandler */ |
|
| 56 | + $xpPollHandler = Xoopspoll\Helper::getInstance()->getHandler('Poll'); |
|
| 57 | + /** @var Xoopspoll\LogHandler $xpLogHandler */ |
|
| 58 | + $xpLogHandler = Xoopspoll\Helper::getInstance()->getHandler('Log'); |
|
| 59 | + /** @var Xoopspoll\Poll $pollObject */ |
|
| 60 | + $pollObject = $xpPollHandler->get($poll_id); // will create poll if poll_id = 0 exist |
|
| 61 | + // old xoopspoll or umfrage or any clone from them |
|
| 62 | + } else { |
|
| 63 | + require_once $GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/include/constants.php'); |
|
| 64 | + $classPoll = $topicObject->loadOldPoll(); |
|
| 65 | + $pollObject = new $classPoll($poll_id); // will create poll if poll_id = 0 exist |
|
| 66 | + } |
|
| 67 | 67 | } else { |
| 68 | - redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_POLLMODULE_ERROR); |
|
| 68 | + redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_POLLMODULE_ERROR); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | $mail_author = false; |
| 72 | 72 | // new xoopspoll module |
| 73 | 73 | if ($pollModuleHandler->getVar('version') >= 140) { |
| 74 | - $classConstants = Xoopspoll\Constants(); |
|
| 75 | - if (is_object($pollObject)) { |
|
| 76 | - if ($pollObject->getVar('multiple')) { |
|
| 77 | - $optionId = Request::getInt('option_id', 0, 'POST'); |
|
| 78 | - $optionId = (array)$optionId; // type cast to make sure it's an array |
|
| 79 | - $optionId = array_map('intval', $optionId); // make sure values are integers |
|
| 80 | - } else { |
|
| 81 | - $optionId = Request::getInt('option_id', 0, 'POST'); |
|
| 82 | - } |
|
| 83 | - if (!$pollObject->hasExpired()) { |
|
| 84 | - $msg = constant('_MD_' . strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']) . '_MUSTLOGIN'); |
|
| 85 | - //@todo:: add $url to all redirects |
|
| 86 | - // $url = $GLOBALS['xoops']->buildUrl("index.php", array('poll_id' => $poll_id)); |
|
| 87 | - if ($pollObject->isAllowedToVote()) { |
|
| 88 | - $thisVoter = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : null; |
|
| 89 | - $votedThisPoll = $xpLogHandler->hasVoted($poll_id, xoops_getenv('REMOTE_ADDR'), $thisVoter); |
|
| 90 | - if (!$votedThisPoll) { |
|
| 91 | - /* user that hasn't voted before in this poll or module preferences allow it */ |
|
| 92 | - $voteTime = time(); |
|
| 93 | - if ($pollObject->vote($optionId, xoops_getenv('REMOTE_ADDR'), $voteTime)) { |
|
| 94 | - if (!$xpPollHandler->updateCount($pollObject)) { // update the count and save in db |
|
| 95 | - echo $pollObject->getHtmlErrors(); |
|
| 96 | - exit(); |
|
| 97 | - } |
|
| 98 | - $msg = constant('_MD_' . strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']) . '_THANKSFORVOTE'); |
|
| 99 | - } else { |
|
| 100 | - /* there was a problem registering the vote */ |
|
| 101 | - redirect_header($GLOBALS['xoops']->buildUrl('index.php', ['poll_id' => $poll_id]), $classConstants::REDIRECT_DELAY_MEDIUM, constant('_MD_' . strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']) . '_VOTE_ERROR')); |
|
| 102 | - } |
|
| 103 | - } else { |
|
| 104 | - $msg = constant('_MD_' . strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']) . '_ALREADYVOTED'); |
|
| 105 | - } |
|
| 106 | - /* set anon user vote (and the time they voted) */ |
|
| 107 | - if (!is_object($GLOBALS['xoopsUser'])) { |
|
| 108 | - xoops_load('pollUtility', $GLOBALS['xoopsModuleConfig']['poll_module']); |
|
| 109 | - /** @var Xoopspoll\Utility $classPollUtility */ |
|
| 110 | - $classPollUtility = new Xoopspoll\Utility(); |
|
| 111 | - $classPollUtility::setVoteCookie($poll_id, $voteTime, 0); |
|
| 112 | - } |
|
| 113 | - } else { |
|
| 114 | - $msg = constant('_MD_' . strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']) . '_CANNOTVOTE'); |
|
| 115 | - } |
|
| 116 | - } else { |
|
| 117 | - /* poll has expired so just show the results */ |
|
| 118 | - $msg = constant('_MD_' . strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']) . 'SORRYEXPIRED'); |
|
| 119 | - } |
|
| 120 | - } else { |
|
| 121 | - $msg = constant('_MD_' . strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']) . '_ERROR_INVALID_POLLID'); |
|
| 122 | - } |
|
| 123 | - if (null !== $url) { |
|
| 124 | - redirect_header($url, $classConstants::REDIRECT_DELAY_MEDIUM, $msg); |
|
| 125 | - } else { |
|
| 126 | - redirect_header($GLOBALS['xoops']->buildUrl('viewtopic.php', ['topic_id' => $topic_id]), $classConstants::REDIRECT_DELAY_MEDIUM, $msg); |
|
| 127 | - } |
|
| 128 | - // old xoopspoll or umfrage or any clone from them |
|
| 74 | + $classConstants = Xoopspoll\Constants(); |
|
| 75 | + if (is_object($pollObject)) { |
|
| 76 | + if ($pollObject->getVar('multiple')) { |
|
| 77 | + $optionId = Request::getInt('option_id', 0, 'POST'); |
|
| 78 | + $optionId = (array)$optionId; // type cast to make sure it's an array |
|
| 79 | + $optionId = array_map('intval', $optionId); // make sure values are integers |
|
| 80 | + } else { |
|
| 81 | + $optionId = Request::getInt('option_id', 0, 'POST'); |
|
| 82 | + } |
|
| 83 | + if (!$pollObject->hasExpired()) { |
|
| 84 | + $msg = constant('_MD_' . strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']) . '_MUSTLOGIN'); |
|
| 85 | + //@todo:: add $url to all redirects |
|
| 86 | + // $url = $GLOBALS['xoops']->buildUrl("index.php", array('poll_id' => $poll_id)); |
|
| 87 | + if ($pollObject->isAllowedToVote()) { |
|
| 88 | + $thisVoter = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : null; |
|
| 89 | + $votedThisPoll = $xpLogHandler->hasVoted($poll_id, xoops_getenv('REMOTE_ADDR'), $thisVoter); |
|
| 90 | + if (!$votedThisPoll) { |
|
| 91 | + /* user that hasn't voted before in this poll or module preferences allow it */ |
|
| 92 | + $voteTime = time(); |
|
| 93 | + if ($pollObject->vote($optionId, xoops_getenv('REMOTE_ADDR'), $voteTime)) { |
|
| 94 | + if (!$xpPollHandler->updateCount($pollObject)) { // update the count and save in db |
|
| 95 | + echo $pollObject->getHtmlErrors(); |
|
| 96 | + exit(); |
|
| 97 | + } |
|
| 98 | + $msg = constant('_MD_' . strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']) . '_THANKSFORVOTE'); |
|
| 99 | + } else { |
|
| 100 | + /* there was a problem registering the vote */ |
|
| 101 | + redirect_header($GLOBALS['xoops']->buildUrl('index.php', ['poll_id' => $poll_id]), $classConstants::REDIRECT_DELAY_MEDIUM, constant('_MD_' . strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']) . '_VOTE_ERROR')); |
|
| 102 | + } |
|
| 103 | + } else { |
|
| 104 | + $msg = constant('_MD_' . strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']) . '_ALREADYVOTED'); |
|
| 105 | + } |
|
| 106 | + /* set anon user vote (and the time they voted) */ |
|
| 107 | + if (!is_object($GLOBALS['xoopsUser'])) { |
|
| 108 | + xoops_load('pollUtility', $GLOBALS['xoopsModuleConfig']['poll_module']); |
|
| 109 | + /** @var Xoopspoll\Utility $classPollUtility */ |
|
| 110 | + $classPollUtility = new Xoopspoll\Utility(); |
|
| 111 | + $classPollUtility::setVoteCookie($poll_id, $voteTime, 0); |
|
| 112 | + } |
|
| 113 | + } else { |
|
| 114 | + $msg = constant('_MD_' . strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']) . '_CANNOTVOTE'); |
|
| 115 | + } |
|
| 116 | + } else { |
|
| 117 | + /* poll has expired so just show the results */ |
|
| 118 | + $msg = constant('_MD_' . strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']) . 'SORRYEXPIRED'); |
|
| 119 | + } |
|
| 120 | + } else { |
|
| 121 | + $msg = constant('_MD_' . strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']) . '_ERROR_INVALID_POLLID'); |
|
| 122 | + } |
|
| 123 | + if (null !== $url) { |
|
| 124 | + redirect_header($url, $classConstants::REDIRECT_DELAY_MEDIUM, $msg); |
|
| 125 | + } else { |
|
| 126 | + redirect_header($GLOBALS['xoops']->buildUrl('viewtopic.php', ['topic_id' => $topic_id]), $classConstants::REDIRECT_DELAY_MEDIUM, $msg); |
|
| 127 | + } |
|
| 128 | + // old xoopspoll or umfrage or any clone from them |
|
| 129 | 129 | } else { |
| 130 | - $classLog = $classPoll . 'Log'; |
|
| 131 | - if (is_object($GLOBALS['xoopsUser'])) { |
|
| 132 | - if ($classLog::hasVoted($poll_id, Request::getString('REMOTE_ADDR', '', 'SERVER'), $GLOBALS['xoopsUser']->getVar('uid'))) { |
|
| 133 | - $msg = _PL_ALREADYVOTED; |
|
| 134 | - setcookie("newbb_polls[{$poll_id}]", 1); |
|
| 135 | - } else { |
|
| 136 | - // irmtfan save ip to db |
|
| 137 | - $pollObject->vote(Request::getInt('option_id', 0, 'POST'), Request::getString('REMOTE_ADDR', '', 'SERVER'), $GLOBALS['xoopsUser']->getVar('uid')); |
|
| 138 | - $pollObject->updateCount(); |
|
| 139 | - $msg = _PL_THANKSFORVOTE; |
|
| 140 | - setcookie("newbb_polls[{$poll_id}]", 1); |
|
| 141 | - } |
|
| 142 | - } else { |
|
| 143 | - if ($classLog::hasVoted($poll_id, Request::getString('REMOTE_ADDR', '', 'SERVER'))) { |
|
| 144 | - $msg = _PL_ALREADYVOTED; |
|
| 145 | - setcookie("newbb_polls[{$poll_id}]", 1); |
|
| 146 | - } else { |
|
| 147 | - $pollObject->vote(Request::getInt('option_id', 0, 'POST'), Request::getString('REMOTE_ADDR', '', 'SERVER')); |
|
| 148 | - $pollObject->updateCount(); |
|
| 149 | - $msg = _PL_THANKSFORVOTE; |
|
| 150 | - setcookie("newbb_polls[{$poll_id}]", 1); |
|
| 151 | - } |
|
| 152 | - } |
|
| 130 | + $classLog = $classPoll . 'Log'; |
|
| 131 | + if (is_object($GLOBALS['xoopsUser'])) { |
|
| 132 | + if ($classLog::hasVoted($poll_id, Request::getString('REMOTE_ADDR', '', 'SERVER'), $GLOBALS['xoopsUser']->getVar('uid'))) { |
|
| 133 | + $msg = _PL_ALREADYVOTED; |
|
| 134 | + setcookie("newbb_polls[{$poll_id}]", 1); |
|
| 135 | + } else { |
|
| 136 | + // irmtfan save ip to db |
|
| 137 | + $pollObject->vote(Request::getInt('option_id', 0, 'POST'), Request::getString('REMOTE_ADDR', '', 'SERVER'), $GLOBALS['xoopsUser']->getVar('uid')); |
|
| 138 | + $pollObject->updateCount(); |
|
| 139 | + $msg = _PL_THANKSFORVOTE; |
|
| 140 | + setcookie("newbb_polls[{$poll_id}]", 1); |
|
| 141 | + } |
|
| 142 | + } else { |
|
| 143 | + if ($classLog::hasVoted($poll_id, Request::getString('REMOTE_ADDR', '', 'SERVER'))) { |
|
| 144 | + $msg = _PL_ALREADYVOTED; |
|
| 145 | + setcookie("newbb_polls[{$poll_id}]", 1); |
|
| 146 | + } else { |
|
| 147 | + $pollObject->vote(Request::getInt('option_id', 0, 'POST'), Request::getString('REMOTE_ADDR', '', 'SERVER')); |
|
| 148 | + $pollObject->updateCount(); |
|
| 149 | + $msg = _PL_THANKSFORVOTE; |
|
| 150 | + setcookie("newbb_polls[{$poll_id}]", 1); |
|
| 151 | + } |
|
| 152 | + } |
|
| 153 | 153 | } |
| 154 | 154 | // irmtfan - simple url |
| 155 | 155 | redirect_header("viewtopic.php?topic_id={$topic_id}", 1, $msg); |
@@ -46,93 +46,93 @@ |
||
| 46 | 46 | $xoopsLogger->activated = false; |
| 47 | 47 | |
| 48 | 48 | if (!Request::getString('post_data', '', 'POST')) { |
| 49 | - $forum = Request::getInt('forum', 0, 'GET'); |
|
| 50 | - $topic_id = Request::getInt('topic_id', 0, 'GET'); |
|
| 51 | - $post_id = Request::getInt('post_id', 0, 'GET'); |
|
| 49 | + $forum = Request::getInt('forum', 0, 'GET'); |
|
| 50 | + $topic_id = Request::getInt('topic_id', 0, 'GET'); |
|
| 51 | + $post_id = Request::getInt('post_id', 0, 'GET'); |
|
| 52 | 52 | |
| 53 | - if (0 === $post_id && 0 === $topic_id) { |
|
| 54 | - exit(_MD_NEWBB_ERRORTOPIC); |
|
| 55 | - } |
|
| 53 | + if (0 === $post_id && 0 === $topic_id) { |
|
| 54 | + exit(_MD_NEWBB_ERRORTOPIC); |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - if (0 !== $post_id) { |
|
| 58 | - // /** @var Newbb\PostHandler $postHandler */ |
|
| 59 | - // $postHandler = Newbb\Helper::getInstance()->getHandler('Post'); |
|
| 60 | - /** @var Newbb\Post $post */ |
|
| 61 | - $post = $postHandler->get($post_id); |
|
| 62 | - if (!$approved = $post->getVar('approved')) { |
|
| 63 | - exit(_MD_NEWBB_NORIGHTTOVIEW); |
|
| 64 | - } |
|
| 65 | - $topic_id = $post->getVar('topic_id'); |
|
| 66 | - $post_data = $postHandler->getPostForPrint($post); |
|
| 67 | - $isPost = 1; |
|
| 68 | - $post_data['url'] = XOOPS_URL . '/modules/newbb/viewtopic.php?post_id=' . $post_id; |
|
| 69 | - if (!empty($GLOBALS['xoopsModuleConfig']['do_rewrite'])) { |
|
| 70 | - $post_data['url'] = seo_urls('<a href="' . $post_data['url'] . '"></a>'); |
|
| 71 | - $post_data['url'] = str_replace('<a href="', '', $post_data['url']); |
|
| 72 | - $post_data['url'] = str_replace('"></a>', '', $post_data['url']); |
|
| 73 | - } |
|
| 74 | - } |
|
| 57 | + if (0 !== $post_id) { |
|
| 58 | + // /** @var Newbb\PostHandler $postHandler */ |
|
| 59 | + // $postHandler = Newbb\Helper::getInstance()->getHandler('Post'); |
|
| 60 | + /** @var Newbb\Post $post */ |
|
| 61 | + $post = $postHandler->get($post_id); |
|
| 62 | + if (!$approved = $post->getVar('approved')) { |
|
| 63 | + exit(_MD_NEWBB_NORIGHTTOVIEW); |
|
| 64 | + } |
|
| 65 | + $topic_id = $post->getVar('topic_id'); |
|
| 66 | + $post_data = $postHandler->getPostForPrint($post); |
|
| 67 | + $isPost = 1; |
|
| 68 | + $post_data['url'] = XOOPS_URL . '/modules/newbb/viewtopic.php?post_id=' . $post_id; |
|
| 69 | + if (!empty($GLOBALS['xoopsModuleConfig']['do_rewrite'])) { |
|
| 70 | + $post_data['url'] = seo_urls('<a href="' . $post_data['url'] . '"></a>'); |
|
| 71 | + $post_data['url'] = str_replace('<a href="', '', $post_data['url']); |
|
| 72 | + $post_data['url'] = str_replace('"></a>', '', $post_data['url']); |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - // /** @var Newbb\TopicHandler $topicHandler */ |
|
| 77 | - // $topicHandler = Newbb\Helper::getInstance()->getHandler('Topic'); |
|
| 78 | - $topicObject = $topicHandler->get($topic_id); |
|
| 79 | - $topic_id = $topicObject->getVar('topic_id'); |
|
| 80 | - $forum = $topicObject->getVar('forum_id'); |
|
| 81 | - if (!$approved = $topicObject->getVar('approved')) { |
|
| 82 | - exit(_MD_NEWBB_NORIGHTTOVIEW); |
|
| 83 | - } |
|
| 76 | + // /** @var Newbb\TopicHandler $topicHandler */ |
|
| 77 | + // $topicHandler = Newbb\Helper::getInstance()->getHandler('Topic'); |
|
| 78 | + $topicObject = $topicHandler->get($topic_id); |
|
| 79 | + $topic_id = $topicObject->getVar('topic_id'); |
|
| 80 | + $forum = $topicObject->getVar('forum_id'); |
|
| 81 | + if (!$approved = $topicObject->getVar('approved')) { |
|
| 82 | + exit(_MD_NEWBB_NORIGHTTOVIEW); |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - $isAdmin = newbbIsAdmin($forumObject); |
|
| 86 | - if (!$isAdmin && $topicObject->getVar('approved') < 0) { |
|
| 87 | - exit(_MD_NEWBB_NORIGHTTOVIEW); |
|
| 88 | - } |
|
| 85 | + $isAdmin = newbbIsAdmin($forumObject); |
|
| 86 | + if (!$isAdmin && $topicObject->getVar('approved') < 0) { |
|
| 87 | + exit(_MD_NEWBB_NORIGHTTOVIEW); |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - // /** @var Newbb\ForumHandler $forumHandler */ |
|
| 91 | - // $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum'); |
|
| 92 | - $forum = $topicObject->getVar('forum_id'); |
|
| 93 | - $forumObject = $forumHandler->get($forum); |
|
| 94 | - if (!$forumHandler->getPermission($forumObject)) { |
|
| 95 | - exit(_MD_NEWBB_NORIGHTTOVIEW); |
|
| 96 | - } |
|
| 90 | + // /** @var Newbb\ForumHandler $forumHandler */ |
|
| 91 | + // $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum'); |
|
| 92 | + $forum = $topicObject->getVar('forum_id'); |
|
| 93 | + $forumObject = $forumHandler->get($forum); |
|
| 94 | + if (!$forumHandler->getPermission($forumObject)) { |
|
| 95 | + exit(_MD_NEWBB_NORIGHTTOVIEW); |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - if (!$topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'view')) { |
|
| 99 | - exit(_MD_NEWBB_NORIGHTTOVIEW); |
|
| 100 | - } |
|
| 101 | - // irmtfan add print permission |
|
| 102 | - if (!$topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'print')) { |
|
| 103 | - exit(_MD_NEWBB_NORIGHTTOPRINT); |
|
| 104 | - } |
|
| 98 | + if (!$topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'view')) { |
|
| 99 | + exit(_MD_NEWBB_NORIGHTTOVIEW); |
|
| 100 | + } |
|
| 101 | + // irmtfan add print permission |
|
| 102 | + if (!$topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'print')) { |
|
| 103 | + exit(_MD_NEWBB_NORIGHTTOPRINT); |
|
| 104 | + } |
|
| 105 | 105 | } else { |
| 106 | - $post_data = unserialize(base64_decode(Request::getString('post_data', '', 'POST'))); |
|
| 107 | - $isPost = 1; |
|
| 106 | + $post_data = unserialize(base64_decode(Request::getString('post_data', '', 'POST'))); |
|
| 107 | + $isPost = 1; |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | xoops_header(false); |
| 111 | 111 | |
| 112 | 112 | if (empty($isPost)) { |
| 113 | - echo "</head><body style='background-color:#ffffff; color:#000000;' onload='window.print()'> |
|
| 113 | + echo "</head><body style='background-color:#ffffff; color:#000000;' onload='window.print()'> |
|
| 114 | 114 | <div style='width: 750px; border: 1px solid #000; padding: 20px;'> |
| 115 | 115 | <div style='text-align: center; display: block; margin: 0 0 6px 0;'> |
| 116 | 116 | <img src='" . XOOPS_URL . "/modules/newbb/assets/images/xoopsbb_slogo.png' border='0' alt='' /> |
| 117 | 117 | <br><br> "; |
| 118 | 118 | |
| 119 | - $postsArray = $topicHandler->getAllPosts($topicObject); |
|
| 120 | - foreach ($postsArray as $post) { |
|
| 121 | - if (!$post->getVar('approved')) { |
|
| 122 | - continue; |
|
| 123 | - } |
|
| 124 | - $post_data = $postHandler->getPostForPrint($post); |
|
| 125 | - echo "<h2 style='margin: 0;'>" . $post_data['subject'] . "</h2> |
|
| 119 | + $postsArray = $topicHandler->getAllPosts($topicObject); |
|
| 120 | + foreach ($postsArray as $post) { |
|
| 121 | + if (!$post->getVar('approved')) { |
|
| 122 | + continue; |
|
| 123 | + } |
|
| 124 | + $post_data = $postHandler->getPostForPrint($post); |
|
| 125 | + echo "<h2 style='margin: 0;'>" . $post_data['subject'] . "</h2> |
|
| 126 | 126 | <div align='center'>" . _POSTEDBY . ' ' . $post_data['author'] . ' ' . _ON . ' ' . formatTimestamp($post_data['date']) . "</div> |
| 127 | 127 | <div style='text-align: center; display: block; padding-bottom: 12px; margin: 0 0 6px 0; border-bottom: 2px solid #ccc;'></div> |
| 128 | 128 | <div>" . $post_data['text'] . "</div> |
| 129 | 129 | <div style='padding-top: 12px; border-top: 2px solid #ccc;'></div><br>"; |
| 130 | - } |
|
| 131 | - echo '<p>' . _MD_NEWBB_COMEFROM . ' ' . XOOPS_URL . '/newbb/viewtopic.php?forum=' . $forum_id . '&topic_id=' . $topic_id . '</p>'; |
|
| 132 | - echo '</div></div>'; |
|
| 133 | - echo '</body></html>'; |
|
| 130 | + } |
|
| 131 | + echo '<p>' . _MD_NEWBB_COMEFROM . ' ' . XOOPS_URL . '/newbb/viewtopic.php?forum=' . $forum_id . '&topic_id=' . $topic_id . '</p>'; |
|
| 132 | + echo '</div></div>'; |
|
| 133 | + echo '</body></html>'; |
|
| 134 | 134 | } else { |
| 135 | - echo "</head><body style='background-color:#ffffff; color:#000000;' onload='window.print()'> |
|
| 135 | + echo "</head><body style='background-color:#ffffff; color:#000000;' onload='window.print()'> |
|
| 136 | 136 | <div style='width: 750px; border: 1px solid #000; padding: 20px;'> |
| 137 | 137 | <div style='text-align: center; display: block; margin: 0 0 6px 0;'> |
| 138 | 138 | <h2 style='margin: 0;'>" . $post_data['subject'] . "</h2></div> |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | require_once __DIR__ . '/header.php'; |
| 15 | 15 | |
| 16 | 16 | if (!Request::getInt('forum', 0, 'GET')) { |
| 17 | - redirect_header(XOOPS_URL . '/index.php', 2, _MD_NEWBB_ERRORFORUM); |
|
| 17 | + redirect_header(XOOPS_URL . '/index.php', 2, _MD_NEWBB_ERRORFORUM); |
|
| 18 | 18 | } |
| 19 | 19 | require_once __DIR__ . '/include/functions.read.php'; |
| 20 | 20 | |
@@ -24,54 +24,54 @@ discard block |
||
| 24 | 24 | $query_vars = ['forum', 'type', 'status', 'sort', 'order', 'start', 'since']; |
| 25 | 25 | $query_array = []; |
| 26 | 26 | foreach ($query_vars as $var) { |
| 27 | - if (Request::getString($var, '', 'GET')) { |
|
| 28 | - $query_array[$var] = "{$var}=" . Request::getString($var, '', 'GET'); |
|
| 29 | - } |
|
| 27 | + if (Request::getString($var, '', 'GET')) { |
|
| 28 | + $query_array[$var] = "{$var}=" . Request::getString($var, '', 'GET'); |
|
| 29 | + } |
|
| 30 | 30 | } |
| 31 | 31 | $page_query = implode('&', array_values($query_array)); |
| 32 | 32 | |
| 33 | 33 | if (Request::getInt('mark', 0, 'GET')) { |
| 34 | - if (1 === Request::getInt('mark', 0, 'GET')) { // marked as read |
|
| 35 | - $markvalue = 1; |
|
| 36 | - $markresult = _MD_NEWBB_MARK_READ; |
|
| 37 | - } else { // marked as unread |
|
| 38 | - $markvalue = 0; |
|
| 39 | - $markresult = _MD_NEWBB_MARK_UNREAD; |
|
| 40 | - } |
|
| 41 | - newbbSetReadTopic($markvalue, Request::getInt('forum', 0, 'GET')); |
|
| 42 | - $url = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewforum.php?' . $page_query; |
|
| 43 | - redirect_header($url, 2, _MD_NEWBB_ALL_TOPIC_MARKED . ' ' . $markresult); |
|
| 34 | + if (1 === Request::getInt('mark', 0, 'GET')) { // marked as read |
|
| 35 | + $markvalue = 1; |
|
| 36 | + $markresult = _MD_NEWBB_MARK_READ; |
|
| 37 | + } else { // marked as unread |
|
| 38 | + $markvalue = 0; |
|
| 39 | + $markresult = _MD_NEWBB_MARK_UNREAD; |
|
| 40 | + } |
|
| 41 | + newbbSetReadTopic($markvalue, Request::getInt('forum', 0, 'GET')); |
|
| 42 | + $url = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewforum.php?' . $page_query; |
|
| 43 | + redirect_header($url, 2, _MD_NEWBB_ALL_TOPIC_MARKED . ' ' . $markresult); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | $forum_id = Request::getInt('forum', 0, 'GET'); |
| 47 | 47 | $type = Request::getInt('type', 0, 'GET'); |
| 48 | 48 | $status = (Request::getString('status', '', 'GET') |
| 49 | - && in_array(Request::getString('status', '', 'GET'), [ |
|
| 50 | - 'active', |
|
| 51 | - 'pending', |
|
| 52 | - 'deleted', |
|
| 53 | - 'digest', |
|
| 54 | - 'unreplied', |
|
| 55 | - 'unread' |
|
| 56 | - ], true)) ? Request::getString('status', '', 'GET') : ''; |
|
| 49 | + && in_array(Request::getString('status', '', 'GET'), [ |
|
| 50 | + 'active', |
|
| 51 | + 'pending', |
|
| 52 | + 'deleted', |
|
| 53 | + 'digest', |
|
| 54 | + 'unreplied', |
|
| 55 | + 'unread' |
|
| 56 | + ], true)) ? Request::getString('status', '', 'GET') : ''; |
|
| 57 | 57 | |
| 58 | 58 | $mode = (Request::getString('status', '', 'GET') |
| 59 | - && in_array(Request::getString('status', '', 'GET'), [ |
|
| 60 | - 'active', |
|
| 61 | - 'pending', |
|
| 62 | - 'deleted' |
|
| 63 | - ], true)) ? 2 : Request::getInt('mode', 0, 'GET'); |
|
| 59 | + && in_array(Request::getString('status', '', 'GET'), [ |
|
| 60 | + 'active', |
|
| 61 | + 'pending', |
|
| 62 | + 'deleted' |
|
| 63 | + ], true)) ? 2 : Request::getInt('mode', 0, 'GET'); |
|
| 64 | 64 | |
| 65 | 65 | ///** @var Newbb\ForumHandler $forumHandler */ |
| 66 | 66 | //$forumHandler = Newbb\Helper::getInstance()->getHandler('Forum'); |
| 67 | 67 | $forumObject = $forumHandler->get($forum_id); |
| 68 | 68 | |
| 69 | 69 | if (!$forumObject) { |
| 70 | - redirect_header(XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/index.php', 2, _MD_NEWBB_ERRORFORUM); |
|
| 70 | + redirect_header(XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/index.php', 2, _MD_NEWBB_ERRORFORUM); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | if (!$forumHandler->getPermission($forumObject)) { |
| 74 | - redirect_header(XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/index.php', 2, _NOPERM); |
|
| 74 | + redirect_header(XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/index.php', 2, _NOPERM); |
|
| 75 | 75 | } |
| 76 | 76 | newbbSetRead('forum', $forum_id, $forumObject->getVar('forum_last_post_id')); |
| 77 | 77 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | require_once __DIR__ . '/include/functions.render.php'; |
| 85 | 85 | |
| 86 | 86 | if (!empty($GLOBALS['xoopsModuleConfig']['rss_enable'])) { |
| 87 | - $xoopsTpl->assign('xoops_module_header', ' |
|
| 87 | + $xoopsTpl->assign('xoops_module_header', ' |
|
| 88 | 88 | <link rel="alternate" type="application/xml+rss" title="' . $xoopsModule->getVar('name') . '-' . $forumObject->getVar('forum_name') . '" href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/rss.php?f=' . $forum_id . '" /> |
| 89 | 89 | ' . @$xoopsTpl->get_template_vars('xoops_module_header')); |
| 90 | 90 | } |
@@ -99,41 +99,41 @@ discard block |
||
| 99 | 99 | $xoopsTpl->assign('viewer_level', $isAdmin ? 2 : 0); |
| 100 | 100 | /* Only admin has access to admin mode */ |
| 101 | 101 | if (!$isAdmin) { |
| 102 | - $status = (!empty($status) && in_array($status, ['active', 'pending', 'deleted'], true)) ? '' : $status; |
|
| 103 | - // irmtfan add mode |
|
| 104 | - $mode = 0; |
|
| 102 | + $status = (!empty($status) && in_array($status, ['active', 'pending', 'deleted'], true)) ? '' : $status; |
|
| 103 | + // irmtfan add mode |
|
| 104 | + $mode = 0; |
|
| 105 | 105 | } |
| 106 | 106 | // irmtfan add mode |
| 107 | 107 | $xoopsTpl->assign('mode', $mode); |
| 108 | 108 | $xoopsTpl->assign('status', $status); |
| 109 | 109 | if ($isAdmin) { |
| 110 | - $xoopsTpl->assign('forum_index_cpanel', ['link' => 'admin/index.php', 'name' => _MD_NEWBB_ADMINCP]); |
|
| 110 | + $xoopsTpl->assign('forum_index_cpanel', ['link' => 'admin/index.php', 'name' => _MD_NEWBB_ADMINCP]); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | if ($GLOBALS['xoopsModuleConfig']['wol_enabled']) { |
| 114 | - // /** @var Newbb\OnlineHandler $onlineHandler */ |
|
| 115 | - // $onlineHandler = Newbb\Helper::getInstance()->getHandler('Online'); |
|
| 116 | - $onlineHandler->init($forumObject); |
|
| 117 | - $xoopsTpl->assign('online', $onlineHandler->showOnline()); |
|
| 114 | + // /** @var Newbb\OnlineHandler $onlineHandler */ |
|
| 115 | + // $onlineHandler = Newbb\Helper::getInstance()->getHandler('Online'); |
|
| 116 | + $onlineHandler->init($forumObject); |
|
| 117 | + $xoopsTpl->assign('online', $onlineHandler->showOnline()); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | if ($forumHandler->getPermission($forumObject, 'post')) { |
| 121 | - $xoopsTpl->assign('viewer_level', $isAdmin ? 2 : 1); |
|
| 122 | - $xoopsTpl->assign('forum_post_or_register', '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/newtopic.php?forum={$forum_id}\">" . newbbDisplayImage('t_new', _MD_NEWBB_POSTNEW) . '</a>'); |
|
| 123 | - if ($pollmodules && $forumHandler->getPermission($forumObject, 'addpoll')) { |
|
| 124 | - $t_poll = newbbDisplayImage('t_poll', _MD_NEWBB_ADDPOLL); |
|
| 125 | - $xoopsTpl->assign('forum_addpoll', '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/polls.php?op=add&forum={$forum_id}\">{$t_poll}</a>"); |
|
| 126 | - } |
|
| 121 | + $xoopsTpl->assign('viewer_level', $isAdmin ? 2 : 1); |
|
| 122 | + $xoopsTpl->assign('forum_post_or_register', '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/newtopic.php?forum={$forum_id}\">" . newbbDisplayImage('t_new', _MD_NEWBB_POSTNEW) . '</a>'); |
|
| 123 | + if ($pollmodules && $forumHandler->getPermission($forumObject, 'addpoll')) { |
|
| 124 | + $t_poll = newbbDisplayImage('t_poll', _MD_NEWBB_ADDPOLL); |
|
| 125 | + $xoopsTpl->assign('forum_addpoll', '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/polls.php?op=add&forum={$forum_id}\">{$t_poll}</a>"); |
|
| 126 | + } |
|
| 127 | 127 | } else { |
| 128 | - $xoopsTpl->assign('viewer_level', 0); |
|
| 129 | - if (!is_object($GLOBALS['xoopsUser']) && !empty($GLOBALS['xoopsModuleConfig']['show_reg'])) { |
|
| 130 | - $redirect = preg_replace("|(.*)\/modules\/Newbb\/(.*)|", "\\1/modules/newbb/newtopic.php?forum=" . $forum_id, htmlspecialchars($xoopsRequestUri, ENT_QUOTES | ENT_HTML5)); |
|
| 131 | - $xoopsTpl->assign('forum_post_or_register', "<a href='" . XOOPS_URL . "/user.php?xoops_redirect={$redirect}'>" . _MD_NEWBB_REGTOPOST . '</a>'); |
|
| 132 | - $xoopsTpl->assign('forum_addpoll', ''); |
|
| 133 | - } else { |
|
| 134 | - $xoopsTpl->assign('forum_post_or_register', ''); |
|
| 135 | - $xoopsTpl->assign('forum_addpoll', ''); |
|
| 136 | - } |
|
| 128 | + $xoopsTpl->assign('viewer_level', 0); |
|
| 129 | + if (!is_object($GLOBALS['xoopsUser']) && !empty($GLOBALS['xoopsModuleConfig']['show_reg'])) { |
|
| 130 | + $redirect = preg_replace("|(.*)\/modules\/Newbb\/(.*)|", "\\1/modules/newbb/newtopic.php?forum=" . $forum_id, htmlspecialchars($xoopsRequestUri, ENT_QUOTES | ENT_HTML5)); |
|
| 131 | + $xoopsTpl->assign('forum_post_or_register', "<a href='" . XOOPS_URL . "/user.php?xoops_redirect={$redirect}'>" . _MD_NEWBB_REGTOPOST . '</a>'); |
|
| 132 | + $xoopsTpl->assign('forum_addpoll', ''); |
|
| 133 | + } else { |
|
| 134 | + $xoopsTpl->assign('forum_post_or_register', ''); |
|
| 135 | + $xoopsTpl->assign('forum_addpoll', ''); |
|
| 136 | + } |
|
| 137 | 137 | } |
| 138 | 138 | $parentforum = $forumHandler->getParents($forumObject); |
| 139 | 139 | $xoopsTpl->assign_by_ref('parentforum', $parentforum); |
@@ -143,10 +143,10 @@ discard block |
||
| 143 | 143 | $criteria->setSort('forum_order'); |
| 144 | 144 | |
| 145 | 145 | if ($forums = $forumHandler->getAll($criteria, null, false)) { |
| 146 | - $subforum_array = $forumHandler->display($forums, $GLOBALS['xoopsModuleConfig']['length_title_index'], $GLOBALS['xoopsModuleConfig']['count_subforum']); |
|
| 147 | - $subforum = array_values($subforum_array[$forum_id]); |
|
| 148 | - unset($subforum_array); |
|
| 149 | - $xoopsTpl->assign_by_ref('subforum', $subforum); |
|
| 146 | + $subforum_array = $forumHandler->display($forums, $GLOBALS['xoopsModuleConfig']['length_title_index'], $GLOBALS['xoopsModuleConfig']['count_subforum']); |
|
| 147 | + $subforum = array_values($subforum_array[$forum_id]); |
|
| 148 | + unset($subforum_array); |
|
| 149 | + $xoopsTpl->assign_by_ref('subforum', $subforum); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | //$categoryHandler = Newbb\Helper::getInstance()->getHandler('Category'); |
@@ -159,30 +159,30 @@ discard block |
||
| 159 | 159 | |
| 160 | 160 | // irmtfan - add and edit: u.uname => t.topic_poster | t.topic_time => t.topic_id | "t.rating"=>_MD_NEWBB_RATINGS, | p.post_time => t.topic_last_post_id |
| 161 | 161 | $sel_sort_array = [ |
| 162 | - 't.topic_title' => _MD_NEWBB_TOPICTITLE, |
|
| 163 | - 't.topic_poster' => _MD_NEWBB_TOPICPOSTER, |
|
| 164 | - 't.topic_id' => _MD_NEWBB_TOPICTIME, |
|
| 165 | - 't.topic_replies' => _MD_NEWBB_NUMBERREPLIES, |
|
| 166 | - 't.topic_views' => _MD_NEWBB_VIEWS, |
|
| 167 | - 't.rating' => _MD_NEWBB_RATINGS, |
|
| 168 | - 't.topic_last_post_id' => _MD_NEWBB_LASTPOSTTIME |
|
| 162 | + 't.topic_title' => _MD_NEWBB_TOPICTITLE, |
|
| 163 | + 't.topic_poster' => _MD_NEWBB_TOPICPOSTER, |
|
| 164 | + 't.topic_id' => _MD_NEWBB_TOPICTIME, |
|
| 165 | + 't.topic_replies' => _MD_NEWBB_NUMBERREPLIES, |
|
| 166 | + 't.topic_views' => _MD_NEWBB_VIEWS, |
|
| 167 | + 't.rating' => _MD_NEWBB_RATINGS, |
|
| 168 | + 't.topic_last_post_id' => _MD_NEWBB_LASTPOSTTIME |
|
| 169 | 169 | ]; |
| 170 | 170 | if (!Request::getString('sort', '', 'GET') || !array_key_exists(Request::getString('sort', '', 'GET'), $sel_sort_array)) { |
| 171 | - $sort = 't.topic_last_post_id'; |
|
| 171 | + $sort = 't.topic_last_post_id'; |
|
| 172 | 172 | } else { |
| 173 | - $sort = Request::getString('sort', '', 'GET'); |
|
| 173 | + $sort = Request::getString('sort', '', 'GET'); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | $forum_selection_sort = '<select name="sort">'; |
| 177 | 177 | foreach ($sel_sort_array as $sort_k => $sort_v) { |
| 178 | - $forum_selection_sort .= '<option value="' . $sort_k . '"' . (($sort == $sort_k) ? ' selected="selected"' : '') . '>' . $sort_v . '</option>'; |
|
| 178 | + $forum_selection_sort .= '<option value="' . $sort_k . '"' . (($sort == $sort_k) ? ' selected="selected"' : '') . '>' . $sort_v . '</option>'; |
|
| 179 | 179 | } |
| 180 | 180 | $forum_selection_sort .= '</select>'; |
| 181 | 181 | |
| 182 | 182 | $xoopsTpl->assign_by_ref('forum_selection_sort', $forum_selection_sort); |
| 183 | 183 | |
| 184 | 184 | $order = (!Request::getString('order', '', 'GET') |
| 185 | - || 'ASC' !== Request::getString('order', '', 'GET')) ? 'DESC' : 'ASC'; |
|
| 185 | + || 'ASC' !== Request::getString('order', '', 'GET')) ? 'DESC' : 'ASC'; |
|
| 186 | 186 | $forum_selection_order = '<select name="order">'; |
| 187 | 187 | $forum_selection_order .= '<option value="ASC"' . (('ASC' === $order) ? ' selected' : '') . '>' . _MD_NEWBB_ASCENDING . '</option>'; |
| 188 | 188 | $forum_selection_order .= '<option value="DESC"' . (('DESC' === $order) ? ' selected' : '') . '>' . _MD_NEWBB_DESCENDING . '</option>'; |
@@ -205,10 +205,10 @@ discard block |
||
| 205 | 205 | $xoopsTpl->assign('h_poster_link', XOOPS_URL . "/modules/newbb/viewforum.php?{$page_query_sort}&sort=t.topic_poster&order=" . (('t.topic_poster' === $sort && 'DESC' === $order) ? 'ASC' : 'DESC')); |
| 206 | 206 | $xoopsTpl->assign('h_views_link', XOOPS_URL . "/modules/newbb/viewforum.php?{$page_query_sort}&sort=t.topic_views&order=" . (('t.topic_views' === $sort && 'DESC' === $order) ? 'ASC' : 'DESC')); |
| 207 | 207 | $xoopsTpl->assign('h_rating_link', XOOPS_URL . "/modules/newbb/viewforum.php?{$page_query_sort}&sort=t.rating&order=" . (('t.rating' === $sort |
| 208 | - && 'DESC' === $order) ? 'ASC' : 'DESC')); // irmtfan t.topic_ratings to t.rating |
|
| 208 | + && 'DESC' === $order) ? 'ASC' : 'DESC')); // irmtfan t.topic_ratings to t.rating |
|
| 209 | 209 | $xoopsTpl->assign('h_date_link', XOOPS_URL . "/modules/newbb/viewforum.php?{$page_query_sort}&sort=t.topic_last_post_id&order=" . (('t.topic_last_post_id' === $sort && 'DESC' === $order) ? 'ASC' : 'DESC')); |
| 210 | 210 | $xoopsTpl->assign('h_publish_link', XOOPS_URL . "/modules/newbb/viewforum.php?{$page_query_sort}&sort=t.topic_id&order=" . (('t.topic_id' === $sort |
| 211 | - && 'DESC' === $order) ? 'ASC' : 'DESC')); |
|
| 211 | + && 'DESC' === $order) ? 'ASC' : 'DESC')); |
|
| 212 | 212 | $xoopsTpl->assign('forum_since', $since); // For $since in search.php |
| 213 | 213 | |
| 214 | 214 | // irmtfan - if no since it should be 0 |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | |
| 219 | 219 | $criteria_vars = ['startdate', 'start', 'sort', 'order', 'type', 'status', 'excerpt']; |
| 220 | 220 | foreach ($criteria_vars as $var) { |
| 221 | - $criteria_topic[$var] = @${$var}; |
|
| 221 | + $criteria_topic[$var] = @${$var}; |
|
| 222 | 222 | } |
| 223 | 223 | $criteria_topic['excerpt'] = $GLOBALS['xoopsModuleConfig']['post_excerpt']; |
| 224 | 224 | |
@@ -252,17 +252,17 @@ discard block |
||
| 252 | 252 | $typeOptions = null; |
| 253 | 253 | $types = []; |
| 254 | 254 | if ($types = $typeHandler->getByForum($forum_id)) { |
| 255 | - $typeOptions[] = ['title' => _ALL, 'link' => XOOPS_URL . "/modules/newbb/viewforum.php?{$page_query_type}"]; |
|
| 256 | - foreach ($types as $key => $item) { |
|
| 257 | - $typeOptions[] = [ |
|
| 258 | - 'title' => $item['type_name'], |
|
| 259 | - 'link' => XOOPS_URL . "/modules/newbb/viewforum.php?{$page_query_type}&type={$key}" |
|
| 260 | - ]; |
|
| 261 | - } |
|
| 255 | + $typeOptions[] = ['title' => _ALL, 'link' => XOOPS_URL . "/modules/newbb/viewforum.php?{$page_query_type}"]; |
|
| 256 | + foreach ($types as $key => $item) { |
|
| 257 | + $typeOptions[] = [ |
|
| 258 | + 'title' => $item['type_name'], |
|
| 259 | + 'link' => XOOPS_URL . "/modules/newbb/viewforum.php?{$page_query_type}&type={$key}" |
|
| 260 | + ]; |
|
| 261 | + } |
|
| 262 | 262 | } |
| 263 | 263 | if ($type > 0) { |
| 264 | - require_once __DIR__ . '/include/functions.topic.php'; |
|
| 265 | - $xoopsTpl->assign('forum_topictype', getTopicTitle('', $types[$type]['type_name'], $types[$type]['type_color'])); |
|
| 264 | + require_once __DIR__ . '/include/functions.topic.php'; |
|
| 265 | + $xoopsTpl->assign('forum_topictype', getTopicTitle('', $types[$type]['type_name'], $types[$type]['type_color'])); |
|
| 266 | 266 | } |
| 267 | 267 | $xoopsTpl->assign_by_ref('typeOptions', $typeOptions); |
| 268 | 268 | |
@@ -276,66 +276,66 @@ discard block |
||
| 276 | 276 | $xoopsTpl->assign('unreplied_link', XOOPS_URL . "/modules/newbb/viewforum.php?{$page_query_status}&status=unreplied"); |
| 277 | 277 | $xoopsTpl->assign('unread_link', XOOPS_URL . "/modules/newbb/viewforum.php?{$page_query_status}&status=unread"); |
| 278 | 278 | switch ($status) { |
| 279 | - case 'digest': |
|
| 280 | - $current_status = _MD_NEWBB_DIGEST; |
|
| 281 | - break; |
|
| 282 | - case 'unreplied': |
|
| 283 | - $current_status = _MD_NEWBB_UNREPLIED; |
|
| 284 | - break; |
|
| 285 | - case 'unread': |
|
| 286 | - $current_status = _MD_NEWBB_UNREAD; |
|
| 287 | - break; |
|
| 288 | - case 'active': |
|
| 289 | - $current_status = _MD_NEWBB_TYPE_ADMIN; |
|
| 290 | - break; |
|
| 291 | - case 'pending': |
|
| 292 | - $current_status = _MD_NEWBB_TYPE_PENDING; |
|
| 293 | - break; |
|
| 294 | - case 'deleted': |
|
| 295 | - $current_status = _MD_NEWBB_TYPE_DELETED; |
|
| 296 | - break; |
|
| 297 | - default: |
|
| 298 | - $current_status = ''; |
|
| 299 | - break; |
|
| 279 | + case 'digest': |
|
| 280 | + $current_status = _MD_NEWBB_DIGEST; |
|
| 281 | + break; |
|
| 282 | + case 'unreplied': |
|
| 283 | + $current_status = _MD_NEWBB_UNREPLIED; |
|
| 284 | + break; |
|
| 285 | + case 'unread': |
|
| 286 | + $current_status = _MD_NEWBB_UNREAD; |
|
| 287 | + break; |
|
| 288 | + case 'active': |
|
| 289 | + $current_status = _MD_NEWBB_TYPE_ADMIN; |
|
| 290 | + break; |
|
| 291 | + case 'pending': |
|
| 292 | + $current_status = _MD_NEWBB_TYPE_PENDING; |
|
| 293 | + break; |
|
| 294 | + case 'deleted': |
|
| 295 | + $current_status = _MD_NEWBB_TYPE_DELETED; |
|
| 296 | + break; |
|
| 297 | + default: |
|
| 298 | + $current_status = ''; |
|
| 299 | + break; |
|
| 300 | 300 | } |
| 301 | 301 | $xoopsTpl->assign('forum_topicstatus', $current_status); |
| 302 | 302 | |
| 303 | 303 | $all_topics = $forumHandler->getTopicCount($forumObject, $startdate, $status); |
| 304 | 304 | if ($all_topics > $GLOBALS['xoopsModuleConfig']['topics_per_page']) { |
| 305 | - require_once $GLOBALS['xoops']->path('class/pagenav.php'); |
|
| 306 | - $query_nav = $query_array; |
|
| 307 | - unset($query_nav['start']); |
|
| 308 | - $page_query_nav = implode('&', array_values($query_nav)); |
|
| 309 | - unset($query_nav); |
|
| 310 | - $nav = new \XoopsPageNav($all_topics, $GLOBALS['xoopsModuleConfig']['topics_per_page'], $start, 'start', $page_query_nav); |
|
| 311 | - if ('select' === $GLOBALS['xoopsModuleConfig']['pagenav_display']) { |
|
| 312 | - $navi = $nav->renderSelect(); |
|
| 313 | - } elseif ('image' === $GLOBALS['xoopsModuleConfig']['pagenav_display']) { |
|
| 314 | - $navi = $nav->renderImageNav(4); |
|
| 315 | - } else { |
|
| 316 | - $navi = $nav->renderNav(4); |
|
| 317 | - } |
|
| 318 | - |
|
| 319 | - $xoopsTpl->assign('forum_pagenav', $navi); |
|
| 305 | + require_once $GLOBALS['xoops']->path('class/pagenav.php'); |
|
| 306 | + $query_nav = $query_array; |
|
| 307 | + unset($query_nav['start']); |
|
| 308 | + $page_query_nav = implode('&', array_values($query_nav)); |
|
| 309 | + unset($query_nav); |
|
| 310 | + $nav = new \XoopsPageNav($all_topics, $GLOBALS['xoopsModuleConfig']['topics_per_page'], $start, 'start', $page_query_nav); |
|
| 311 | + if ('select' === $GLOBALS['xoopsModuleConfig']['pagenav_display']) { |
|
| 312 | + $navi = $nav->renderSelect(); |
|
| 313 | + } elseif ('image' === $GLOBALS['xoopsModuleConfig']['pagenav_display']) { |
|
| 314 | + $navi = $nav->renderImageNav(4); |
|
| 315 | + } else { |
|
| 316 | + $navi = $nav->renderNav(4); |
|
| 317 | + } |
|
| 318 | + |
|
| 319 | + $xoopsTpl->assign('forum_pagenav', $navi); |
|
| 320 | 320 | } else { |
| 321 | - $xoopsTpl->assign('forum_pagenav', ''); |
|
| 321 | + $xoopsTpl->assign('forum_pagenav', ''); |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | if (!empty($GLOBALS['xoopsModuleConfig']['show_jump'])) { |
| 325 | - require_once __DIR__ . '/include/functions.forum.php'; |
|
| 326 | - $xoopsTpl->assign('forum_jumpbox', newbbMakeJumpbox($forum_id)); |
|
| 325 | + require_once __DIR__ . '/include/functions.forum.php'; |
|
| 326 | + $xoopsTpl->assign('forum_jumpbox', newbbMakeJumpbox($forum_id)); |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | if ($GLOBALS['xoopsModuleConfig']['show_permissiontable']) { |
| 330 | - // /** var Newbb\PermissionHandler $permHandler */ |
|
| 331 | - // $permHandler = Newbb\Helper::getInstance()->getHandler('Permission'); |
|
| 332 | - $permission_table = $permHandler->getPermissionTable($forum_id, false, $isAdmin); |
|
| 333 | - $xoopsTpl->assign_by_ref('permission_table', $permission_table); |
|
| 334 | - unset($permission_table); |
|
| 330 | + // /** var Newbb\PermissionHandler $permHandler */ |
|
| 331 | + // $permHandler = Newbb\Helper::getInstance()->getHandler('Permission'); |
|
| 332 | + $permission_table = $permHandler->getPermissionTable($forum_id, false, $isAdmin); |
|
| 333 | + $xoopsTpl->assign_by_ref('permission_table', $permission_table); |
|
| 334 | + unset($permission_table); |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | if (1 == $GLOBALS['xoopsModuleConfig']['rss_enable']) { |
| 338 | - $xoopsTpl->assign('rss_button', "<div align='right'><a href='" . XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/rss.php?f=' . $forum_id . "' title='RSS feed' target='_blank'>" . newbbDisplayImage('rss', 'RSS feed') . '</a></div>'); |
|
| 338 | + $xoopsTpl->assign('rss_button', "<div align='right'><a href='" . XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/rss.php?f=' . $forum_id . "' title='RSS feed' target='_blank'>" . newbbDisplayImage('rss', 'RSS feed') . '</a></div>'); |
|
| 339 | 339 | } |
| 340 | 340 | // irmtfan move to footer.php |
| 341 | 341 | require_once __DIR__ . '/footer.php'; |
@@ -16,17 +16,17 @@ discard block |
||
| 16 | 16 | $ok = Request::getInt('ok', 0, 'POST'); |
| 17 | 17 | |
| 18 | 18 | foreach (['forum', 'topic_id', 'post_id', 'order', 'pid', 'act'] as $getint) { |
| 19 | - ${$getint} = Request::getInt($getint, 0, 'POST'); |
|
| 19 | + ${$getint} = Request::getInt($getint, 0, 'POST'); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | foreach (['forum', 'topic_id', 'post_id', 'order', 'pid', 'act'] as $getint) { |
| 23 | - ${$getint} = !empty(${$getint}) ? ${$getint} : Request::getInt($getint, 0, 'GET'); |
|
| 23 | + ${$getint} = !empty(${$getint}) ? ${$getint} : Request::getInt($getint, 0, 'GET'); |
|
| 24 | 24 | } |
| 25 | 25 | //$viewmode = (isset($_GET['viewmode']) && $_GET['viewmode'] !== 'flat') ? 'thread' : 'flat'; |
| 26 | 26 | //$viewmode = ($viewmode) ? $viewmode: (isset($_POST['viewmode'])?$_POST['viewmode'] : 'flat'); |
| 27 | 27 | |
| 28 | 28 | $viewmode = (Request::getString('viewmode', '', 'GET') |
| 29 | - && 'flat' !== Request::getString('viewmode', '', 'GET')) ? 'thread' : 'flat'; |
|
| 29 | + && 'flat' !== Request::getString('viewmode', '', 'GET')) ? 'thread' : 'flat'; |
|
| 30 | 30 | $viewmode = $viewmode ?: (Request::getString('viewmode', '', 'POST') ?: 'flat'); |
| 31 | 31 | |
| 32 | 32 | ///** @var Newbb\ForumHandler $forumHandler */ |
@@ -37,21 +37,21 @@ discard block |
||
| 37 | 37 | //$postHandler = Newbb\Helper::getInstance()->getHandler('Post'); |
| 38 | 38 | |
| 39 | 39 | if (!empty($post_id)) { |
| 40 | - $topic = $topicHandler->getByPost($post_id); |
|
| 40 | + $topic = $topicHandler->getByPost($post_id); |
|
| 41 | 41 | } else { |
| 42 | - $topic = $topicHandler->get($topic_id); |
|
| 42 | + $topic = $topicHandler->get($topic_id); |
|
| 43 | 43 | } |
| 44 | 44 | $topic_id = $topic->getVar('topic_id'); |
| 45 | 45 | if (!$topic_id) { |
| 46 | - $redirect = empty($forum) ? 'index.php' : 'viewforum.php?forum=' . $forum; |
|
| 47 | - $redirect = XOOPS_URL . '/modules/newbb/' . $redirect; |
|
| 48 | - redirect_header($redirect, 2, _MD_NEWBB_ERRORTOPIC); |
|
| 46 | + $redirect = empty($forum) ? 'index.php' : 'viewforum.php?forum=' . $forum; |
|
| 47 | + $redirect = XOOPS_URL . '/modules/newbb/' . $redirect; |
|
| 48 | + redirect_header($redirect, 2, _MD_NEWBB_ERRORTOPIC); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | $forum = $topic->getVar('forum_id'); |
| 52 | 52 | $forumObject = $forumHandler->get($forum); |
| 53 | 53 | if (!$forumHandler->getPermission($forumObject)) { |
| 54 | - redirect_header(XOOPS_URL . '/index.php', 2, _MD_NEWBB_NORIGHTTOACCESS); |
|
| 54 | + redirect_header(XOOPS_URL . '/index.php', 2, _MD_NEWBB_NORIGHTTOACCESS); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | $isAdmin = newbbIsAdmin($forumObject); |
@@ -62,95 +62,95 @@ discard block |
||
| 62 | 62 | $topic_status = $topic->getVar('topic_status'); |
| 63 | 63 | if (($postObject->checkIdentity() || $isAdmin) && $topicHandler->getPermission($topic->getVar('forum_id'), $topic_status, 'delete')) { |
| 64 | 64 | } else { |
| 65 | - redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id=$topic_id&pid=$pid&forum=$forum", 2, _MD_NEWBB_DELNOTALLOWED); |
|
| 65 | + redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id=$topic_id&pid=$pid&forum=$forum", 2, _MD_NEWBB_DELNOTALLOWED); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | if (!$isAdmin && !$postObject->checkTimelimit('delete_timelimit')) { |
| 69 | - redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?forum=$forum&topic_id=$topic_id&post_id=$post_id&pid=$pid", 2, _MD_NEWBB_TIMEISUPDEL); |
|
| 69 | + redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?forum=$forum&topic_id=$topic_id&post_id=$post_id&pid=$pid", 2, _MD_NEWBB_TIMEISUPDEL); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | if ($GLOBALS['xoopsModuleConfig']['wol_enabled']) { |
| 73 | - // /** @var Newbb\OnlineHandler $onlineHandler */ |
|
| 74 | - // $onlineHandler = Newbb\Helper::getInstance()->getHandler('Online'); |
|
| 75 | - $onlineHandler->init($forumObject); |
|
| 73 | + // /** @var Newbb\OnlineHandler $onlineHandler */ |
|
| 74 | + // $onlineHandler = Newbb\Helper::getInstance()->getHandler('Online'); |
|
| 75 | + $onlineHandler->init($forumObject); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | if ($ok) { |
| 79 | - $isDeleteOne = (1 === $ok); |
|
| 80 | - if ($postObject->isTopic() && 0 == $topic->getVar('topic_replies')) { |
|
| 81 | - $isDeleteOne = false; |
|
| 82 | - } |
|
| 83 | - if ($isDeleteOne && $postObject->isTopic() && $topic->getVar('topic_replies') > 0) { |
|
| 84 | - //$postHandler->emptyTopic($postObject); |
|
| 85 | - redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id=$topic_id&pid=$pid&forum=$forum", 2, _MD_NEWBB_POSTFIRSTWITHREPLYNODELETED); |
|
| 86 | - } else { |
|
| 87 | - if (Request::getString('post_text', '', 'POST')) { |
|
| 88 | - //send a message |
|
| 89 | - /** @var \XoopsMemberHandler $memberHandler */ |
|
| 90 | - $memberHandler = xoops_getHandler('member'); |
|
| 91 | - $senduser = $memberHandler->getUser($postObject->getVar('uid')); |
|
| 92 | - if ($senduser->getVar('notify_method') > 0) { |
|
| 93 | - $xoopsMailer = xoops_getMailer(); |
|
| 94 | - $xoopsMailer->reset(); |
|
| 95 | - if (1 == $senduser->getVar('notify_method')) { |
|
| 96 | - $xoopsMailer->usePM(); |
|
| 97 | - } else { |
|
| 98 | - $xoopsMailer->useMail(); |
|
| 99 | - } |
|
| 100 | - $xoopsMailer->setHTML(true); |
|
| 101 | - $xoopsMailer->setToUsers($senduser); |
|
| 102 | - $xoopsMailer->setFromName($GLOBALS['xoopsUser']->getVar('uname')); |
|
| 103 | - $xoopsMailer->setSubject(_MD_NEWBB_DELEDEDMSG_SUBJECT); |
|
| 104 | - $forenurl = '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewtopic.php?topic_id=' . $postObject->getVar('topic_id') . '">' . $postObject->getVar('subject') . '</a>'; |
|
| 105 | - if (!empty($GLOBALS['xoopsModuleConfig']['do_rewrite'])) { |
|
| 106 | - $forenurl = seo_urls($forenurl); |
|
| 107 | - } |
|
| 108 | - $body = sprintf(_MD_NEWBB_DELEDEDMSG_BODY, $senduser->getVar('uname'), $forenurl, Request::getString('post_text', '', 'POST'), $GLOBALS['xoopsUser']->getVar('uname'), $GLOBALS['xoopsConfig']['sitename'], XOOPS_URL . '/'); |
|
| 109 | - $body = $myts->nl2Br($body); |
|
| 110 | - $xoopsMailer->setBody($body); |
|
| 111 | - $xoopsMailer->send(); |
|
| 112 | - } |
|
| 113 | - } |
|
| 114 | - $postHandler->delete($postObject, $isDeleteOne); |
|
| 115 | - $forumHandler->synchronization($forum); |
|
| 116 | - $topicHandler->synchronization($topic_id); |
|
| 117 | - // /** @var Newbb\StatsHandler $statsHandler */ |
|
| 118 | - // $statsHandler = Newbb\Helper::getInstance()->getHandler('Stats'); |
|
| 119 | - $statsHandler->reset(); |
|
| 120 | - } |
|
| 79 | + $isDeleteOne = (1 === $ok); |
|
| 80 | + if ($postObject->isTopic() && 0 == $topic->getVar('topic_replies')) { |
|
| 81 | + $isDeleteOne = false; |
|
| 82 | + } |
|
| 83 | + if ($isDeleteOne && $postObject->isTopic() && $topic->getVar('topic_replies') > 0) { |
|
| 84 | + //$postHandler->emptyTopic($postObject); |
|
| 85 | + redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id=$topic_id&pid=$pid&forum=$forum", 2, _MD_NEWBB_POSTFIRSTWITHREPLYNODELETED); |
|
| 86 | + } else { |
|
| 87 | + if (Request::getString('post_text', '', 'POST')) { |
|
| 88 | + //send a message |
|
| 89 | + /** @var \XoopsMemberHandler $memberHandler */ |
|
| 90 | + $memberHandler = xoops_getHandler('member'); |
|
| 91 | + $senduser = $memberHandler->getUser($postObject->getVar('uid')); |
|
| 92 | + if ($senduser->getVar('notify_method') > 0) { |
|
| 93 | + $xoopsMailer = xoops_getMailer(); |
|
| 94 | + $xoopsMailer->reset(); |
|
| 95 | + if (1 == $senduser->getVar('notify_method')) { |
|
| 96 | + $xoopsMailer->usePM(); |
|
| 97 | + } else { |
|
| 98 | + $xoopsMailer->useMail(); |
|
| 99 | + } |
|
| 100 | + $xoopsMailer->setHTML(true); |
|
| 101 | + $xoopsMailer->setToUsers($senduser); |
|
| 102 | + $xoopsMailer->setFromName($GLOBALS['xoopsUser']->getVar('uname')); |
|
| 103 | + $xoopsMailer->setSubject(_MD_NEWBB_DELEDEDMSG_SUBJECT); |
|
| 104 | + $forenurl = '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewtopic.php?topic_id=' . $postObject->getVar('topic_id') . '">' . $postObject->getVar('subject') . '</a>'; |
|
| 105 | + if (!empty($GLOBALS['xoopsModuleConfig']['do_rewrite'])) { |
|
| 106 | + $forenurl = seo_urls($forenurl); |
|
| 107 | + } |
|
| 108 | + $body = sprintf(_MD_NEWBB_DELEDEDMSG_BODY, $senduser->getVar('uname'), $forenurl, Request::getString('post_text', '', 'POST'), $GLOBALS['xoopsUser']->getVar('uname'), $GLOBALS['xoopsConfig']['sitename'], XOOPS_URL . '/'); |
|
| 109 | + $body = $myts->nl2Br($body); |
|
| 110 | + $xoopsMailer->setBody($body); |
|
| 111 | + $xoopsMailer->send(); |
|
| 112 | + } |
|
| 113 | + } |
|
| 114 | + $postHandler->delete($postObject, $isDeleteOne); |
|
| 115 | + $forumHandler->synchronization($forum); |
|
| 116 | + $topicHandler->synchronization($topic_id); |
|
| 117 | + // /** @var Newbb\StatsHandler $statsHandler */ |
|
| 118 | + // $statsHandler = Newbb\Helper::getInstance()->getHandler('Stats'); |
|
| 119 | + $statsHandler->reset(); |
|
| 120 | + } |
|
| 121 | 121 | |
| 122 | - //$postObject->loadFilters('delete'); |
|
| 123 | - if ($isDeleteOne) { |
|
| 124 | - redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id=$topic_id&order=$order&viewmode=$viewmode&pid=$pid&forum=$forum", 2, _MD_NEWBB_POSTDELETED); |
|
| 125 | - } else { |
|
| 126 | - redirect_header(XOOPS_URL . "/modules/newbb/viewforum.php?forum=$forum", 2, _MD_NEWBB_POSTSDELETED); |
|
| 127 | - } |
|
| 122 | + //$postObject->loadFilters('delete'); |
|
| 123 | + if ($isDeleteOne) { |
|
| 124 | + redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id=$topic_id&order=$order&viewmode=$viewmode&pid=$pid&forum=$forum", 2, _MD_NEWBB_POSTDELETED); |
|
| 125 | + } else { |
|
| 126 | + redirect_header(XOOPS_URL . "/modules/newbb/viewforum.php?forum=$forum", 2, _MD_NEWBB_POSTSDELETED); |
|
| 127 | + } |
|
| 128 | 128 | } else { |
| 129 | - require_once $GLOBALS['xoops']->path('header.php'); |
|
| 130 | - //xoops_confirm(array('post_id' => $post_id, 'viewmode' => $viewmode, 'order' => $order, 'forum' => $forum, 'topic_id' => $topic_id, 'ok' => 1), 'delete.php', _MD_NEWBB_DEL_ONE); |
|
| 131 | - echo '<div class="confirmMsg">' . _MD_NEWBB_DEL_ONE . '<br> |
|
| 129 | + require_once $GLOBALS['xoops']->path('header.php'); |
|
| 130 | + //xoops_confirm(array('post_id' => $post_id, 'viewmode' => $viewmode, 'order' => $order, 'forum' => $forum, 'topic_id' => $topic_id, 'ok' => 1), 'delete.php', _MD_NEWBB_DEL_ONE); |
|
| 131 | + echo '<div class="confirmMsg">' . _MD_NEWBB_DEL_ONE . '<br> |
|
| 132 | 132 | <form method="post" action="' . XOOPS_URL . '/modules/newbb/delete.php">'; |
| 133 | - echo _MD_NEWBB_DELEDEDMSG . '<br>'; |
|
| 134 | - echo '<textarea name="post_text" cols="50" rows="5"></textarea><br>'; |
|
| 135 | - echo '<input type="hidden" name="post_id" value="' . htmlspecialchars($post_id, ENT_QUOTES | ENT_HTML5) . '" />'; |
|
| 136 | - echo '<input type="hidden" name="order" value="' . htmlspecialchars($order, ENT_QUOTES | ENT_HTML5) . '" />'; |
|
| 137 | - echo '<input type="hidden" name="forum" value="' . htmlspecialchars($forum, ENT_QUOTES | ENT_HTML5) . '" />'; |
|
| 138 | - echo '<input type="hidden" name="topic_id" value="' . htmlspecialchars($topic_id, ENT_QUOTES | ENT_HTML5) . '" />'; |
|
| 139 | - echo '<input type="hidden" name="ok" value="1" />'; |
|
| 140 | - echo $GLOBALS['xoopsSecurity']->getTokenHTML(); |
|
| 141 | - echo '<input type="submit" name="confirm_submit" value="' . _SUBMIT . '" title="' . _SUBMIT . '"/> |
|
| 133 | + echo _MD_NEWBB_DELEDEDMSG . '<br>'; |
|
| 134 | + echo '<textarea name="post_text" cols="50" rows="5"></textarea><br>'; |
|
| 135 | + echo '<input type="hidden" name="post_id" value="' . htmlspecialchars($post_id, ENT_QUOTES | ENT_HTML5) . '" />'; |
|
| 136 | + echo '<input type="hidden" name="order" value="' . htmlspecialchars($order, ENT_QUOTES | ENT_HTML5) . '" />'; |
|
| 137 | + echo '<input type="hidden" name="forum" value="' . htmlspecialchars($forum, ENT_QUOTES | ENT_HTML5) . '" />'; |
|
| 138 | + echo '<input type="hidden" name="topic_id" value="' . htmlspecialchars($topic_id, ENT_QUOTES | ENT_HTML5) . '" />'; |
|
| 139 | + echo '<input type="hidden" name="ok" value="1" />'; |
|
| 140 | + echo $GLOBALS['xoopsSecurity']->getTokenHTML(); |
|
| 141 | + echo '<input type="submit" name="confirm_submit" value="' . _SUBMIT . '" title="' . _SUBMIT . '"/> |
|
| 142 | 142 | <input type="button" name="confirm_back" value="' . _CANCEL . '" onclick="history.go(-1);" title="' . _CANCEL . '" /> |
| 143 | 143 | </form> |
| 144 | 144 | </div>'; |
| 145 | - if ($isAdmin) { |
|
| 146 | - xoops_confirm([ |
|
| 147 | - 'post_id' => $post_id, |
|
| 148 | - 'viewmode' => $viewmode, |
|
| 149 | - 'order' => $order, |
|
| 150 | - 'forum' => $forum, |
|
| 151 | - 'topic_id' => $topic_id, |
|
| 152 | - 'ok' => 99 |
|
| 153 | - ], 'delete.php', _MD_NEWBB_DEL_RELATED); |
|
| 154 | - } |
|
| 155 | - require_once $GLOBALS['xoops']->path('footer.php'); |
|
| 145 | + if ($isAdmin) { |
|
| 146 | + xoops_confirm([ |
|
| 147 | + 'post_id' => $post_id, |
|
| 148 | + 'viewmode' => $viewmode, |
|
| 149 | + 'order' => $order, |
|
| 150 | + 'forum' => $forum, |
|
| 151 | + 'topic_id' => $topic_id, |
|
| 152 | + 'ok' => 99 |
|
| 153 | + ], 'delete.php', _MD_NEWBB_DEL_RELATED); |
|
| 154 | + } |
|
| 155 | + require_once $GLOBALS['xoops']->path('footer.php'); |
|
| 156 | 156 | } |
@@ -30,17 +30,17 @@ discard block |
||
| 30 | 30 | xoops_load('XoopsLocal'); |
| 31 | 31 | $op = 'add'; |
| 32 | 32 | $goodOps = [ |
| 33 | - 'add', |
|
| 34 | - 'save', |
|
| 35 | - 'edit', |
|
| 36 | - 'update', |
|
| 37 | - 'addmore', |
|
| 38 | - 'savemore', |
|
| 39 | - 'delete', |
|
| 40 | - 'delete_ok', |
|
| 41 | - 'restart', |
|
| 42 | - 'restart_ok', |
|
| 43 | - 'log' |
|
| 33 | + 'add', |
|
| 34 | + 'save', |
|
| 35 | + 'edit', |
|
| 36 | + 'update', |
|
| 37 | + 'addmore', |
|
| 38 | + 'savemore', |
|
| 39 | + 'delete', |
|
| 40 | + 'delete_ok', |
|
| 41 | + 'restart', |
|
| 42 | + 'restart_ok', |
|
| 43 | + 'log' |
|
| 44 | 44 | ]; |
| 45 | 45 | $op = isset($_REQUEST['op']) ? $_REQUEST['op'] : 'add'; |
| 46 | 46 | $op = (!in_array($op, $goodOps)) ? 'add' : $op; |
@@ -54,705 +54,705 @@ discard block |
||
| 54 | 54 | $topicObject = $topicHandler->get($topic_id); |
| 55 | 55 | // topic exist |
| 56 | 56 | if (is_object($topicObject)) { |
| 57 | - $forum_id = $topicObject->getVar('forum_id'); |
|
| 57 | + $forum_id = $topicObject->getVar('forum_id'); |
|
| 58 | 58 | } else { |
| 59 | - redirect_header(XOOPS_URL . '/index.php', 2, _MD_NEWBB_POLLMODULE_ERROR . ': ' . _MD_NEWBB_FORUMNOEXIST); |
|
| 59 | + redirect_header(XOOPS_URL . '/index.php', 2, _MD_NEWBB_POLLMODULE_ERROR . ': ' . _MD_NEWBB_FORUMNOEXIST); |
|
| 60 | 60 | } |
| 61 | 61 | // forum access permission |
| 62 | 62 | /** @var Newbb\ForumHandler $forumHandler */ |
| 63 | 63 | $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum'); |
| 64 | 64 | $forumObject = $forumHandler->get($forum_id); |
| 65 | 65 | if (!$forumHandler->getPermission($forumObject)) { |
| 66 | - redirect_header(XOOPS_URL . '/index.php', 2, _MD_NEWBB_NORIGHTTOACCESS); |
|
| 66 | + redirect_header(XOOPS_URL . '/index.php', 2, _MD_NEWBB_NORIGHTTOACCESS); |
|
| 67 | 67 | } |
| 68 | 68 | // topic view permission |
| 69 | 69 | if (!$topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'view')) { |
| 70 | - redirect_header('viewforum.php?forum=' . $forum_id, 2, _MD_NEWBB_NORIGHTTOVIEW); |
|
| 70 | + redirect_header('viewforum.php?forum=' . $forum_id, 2, _MD_NEWBB_NORIGHTTOVIEW); |
|
| 71 | 71 | } |
| 72 | 72 | // poll module |
| 73 | 73 | $pollModuleHandler = $moduleHandler->getByDirname($GLOBALS['xoopsModuleConfig']['poll_module']); |
| 74 | 74 | if (is_object($pollModuleHandler) && $pollModuleHandler->getVar('isactive')) { |
| 75 | - // new xoopspoll module |
|
| 76 | - if ($pollModuleHandler->getVar('version') >= 140) { |
|
| 77 | - xoops_load('constants', $GLOBALS['xoopsModuleConfig']['poll_module']); |
|
| 78 | - xoops_load('pollUtility', $GLOBALS['xoopsModuleConfig']['poll_module']); |
|
| 79 | - xoops_load('request', $GLOBALS['xoopsModuleConfig']['poll_module']); |
|
| 80 | - xoops_loadLanguage('admin', $GLOBALS['xoopsModuleConfig']['poll_module']); |
|
| 81 | - /** @var Xoopspoll\PollHandler $xpPollHandler */ |
|
| 82 | - $xpPollHandler = Xoopspoll\Helper::getInstance()->getHandler('Poll'); |
|
| 83 | - /** @var \XoopsPoll $pollObject */ |
|
| 84 | - $pollObject = $xpPollHandler->get($poll_id); // will create poll if poll_id = 0 exist |
|
| 85 | - // old xoopspoll or umfrage or any clone from them |
|
| 86 | - } else { |
|
| 87 | - require_once $GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/include/constants.php'); |
|
| 88 | - $classPoll = $topicObject->loadOldPoll(); |
|
| 89 | - $pollObject = new $classPoll($poll_id); // will create poll if poll_id = 0 exist |
|
| 90 | - } |
|
| 75 | + // new xoopspoll module |
|
| 76 | + if ($pollModuleHandler->getVar('version') >= 140) { |
|
| 77 | + xoops_load('constants', $GLOBALS['xoopsModuleConfig']['poll_module']); |
|
| 78 | + xoops_load('pollUtility', $GLOBALS['xoopsModuleConfig']['poll_module']); |
|
| 79 | + xoops_load('request', $GLOBALS['xoopsModuleConfig']['poll_module']); |
|
| 80 | + xoops_loadLanguage('admin', $GLOBALS['xoopsModuleConfig']['poll_module']); |
|
| 81 | + /** @var Xoopspoll\PollHandler $xpPollHandler */ |
|
| 82 | + $xpPollHandler = Xoopspoll\Helper::getInstance()->getHandler('Poll'); |
|
| 83 | + /** @var \XoopsPoll $pollObject */ |
|
| 84 | + $pollObject = $xpPollHandler->get($poll_id); // will create poll if poll_id = 0 exist |
|
| 85 | + // old xoopspoll or umfrage or any clone from them |
|
| 86 | + } else { |
|
| 87 | + require_once $GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/include/constants.php'); |
|
| 88 | + $classPoll = $topicObject->loadOldPoll(); |
|
| 89 | + $pollObject = new $classPoll($poll_id); // will create poll if poll_id = 0 exist |
|
| 90 | + } |
|
| 91 | 91 | } else { |
| 92 | - // irmtfan - issue with javascript:history.go(-1) |
|
| 93 | - redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_POLLMODULE_ERROR); |
|
| 92 | + // irmtfan - issue with javascript:history.go(-1) |
|
| 93 | + redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_POLLMODULE_ERROR); |
|
| 94 | 94 | } |
| 95 | 95 | // include header |
| 96 | 96 | require_once $GLOBALS['xoops']->path('header.php'); |
| 97 | 97 | |
| 98 | 98 | // no admin user permission |
| 99 | 99 | if (is_object($GLOBALS['xoopsUser']) && !newbbIsAdmin($forumObject)) { |
| 100 | - $perm = false; |
|
| 101 | - if ($topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'addpoll')) { |
|
| 102 | - if (('add' === $op || 'save' === $op || 'update' === $op) && !$topicObject->getVar('topic_haspoll') |
|
| 103 | - && ($GLOBALS['xoopsUser']->getVar('uid') == $topicObject->getVar('topic_poster'))) { |
|
| 104 | - $perm = true; |
|
| 105 | - } elseif (!empty($poll_id) && ($GLOBALS['xoopsUser']->getVar('uid') == $pollObject->getVar('user_id'))) { |
|
| 106 | - $perm = true; |
|
| 107 | - } |
|
| 108 | - } |
|
| 109 | - if (!$perm) { |
|
| 110 | - redirect_header("viewtopic.php?topic_id={$topic_id}", 2, _NOPERM); |
|
| 111 | - } |
|
| 100 | + $perm = false; |
|
| 101 | + if ($topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'addpoll')) { |
|
| 102 | + if (('add' === $op || 'save' === $op || 'update' === $op) && !$topicObject->getVar('topic_haspoll') |
|
| 103 | + && ($GLOBALS['xoopsUser']->getVar('uid') == $topicObject->getVar('topic_poster'))) { |
|
| 104 | + $perm = true; |
|
| 105 | + } elseif (!empty($poll_id) && ($GLOBALS['xoopsUser']->getVar('uid') == $pollObject->getVar('user_id'))) { |
|
| 106 | + $perm = true; |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | + if (!$perm) { |
|
| 110 | + redirect_header("viewtopic.php?topic_id={$topic_id}", 2, _NOPERM); |
|
| 111 | + } |
|
| 112 | 112 | } |
| 113 | 113 | switch ($op) { |
| 114 | - case 'add': |
|
| 115 | - // new xoopspoll module |
|
| 116 | - if ($pollModuleHandler->getVar('version') >= 140) { |
|
| 117 | - echo '<h4>' . _MD_NEWBB_POLL_CREATNEWPOLL . "</h4>\n"; |
|
| 118 | - $pollObject->renderForm(Request::getString('PHP_SELF', '', 'SERVER'), 'post', ['topic_id' => $topic_id]); |
|
| 119 | - // old xoopspoll or umfrage or any clone from them |
|
| 120 | - } else { |
|
| 121 | - $classOption = $classPoll . 'Option'; |
|
| 122 | - $poll_form = new \XoopsThemeForm(_MD_NEWBB_POLL_CREATNEWPOLL, 'poll_form', 'polls.php', 'post', true); |
|
| 123 | - $author_label = new \XoopsFormLabel(_MD_NEWBB_POLL_AUTHOR, is_object($GLOBALS['xoopsUser']) ? ("<a href='" |
|
| 124 | - . XOOPS_URL |
|
| 125 | - . '/userinfo.php?uid=' |
|
| 126 | - . $GLOBALS['xoopsUser']->getVar('uid') |
|
| 127 | - . "'>" |
|
| 128 | - . newbbGetUnameFromId($GLOBALS['xoopsUser']->getVar('uid'), $GLOBALS['xoopsModuleConfig']['show_realname']) |
|
| 129 | - . '</a>') : $GLOBALS['xoopsConfig']['anonymous']); |
|
| 130 | - $poll_form->addElement($author_label); |
|
| 131 | - $question_text = new \XoopsFormText(_MD_NEWBB_POLL_POLLQUESTION, 'question', 50, 255); |
|
| 132 | - $poll_form->addElement($question_text); |
|
| 133 | - $desc_tarea = new \XoopsFormTextarea(_MD_NEWBB_POLL_POLLDESC, 'description'); |
|
| 134 | - $poll_form->addElement($desc_tarea); |
|
| 135 | - $currenttime = formatTimestamp(time(), 'Y-m-d H:i:s'); |
|
| 136 | - $endtime = formatTimestamp(time() + 604800, 'Y-m-d H:i:s'); |
|
| 137 | - $expire_text = new \XoopsFormText(_MD_NEWBB_POLL_EXPIRATION . '<br><small>' . _MD_NEWBB_POLL_FORMAT . '<br>' . sprintf(_MD_NEWBB_POLL_CURRENTTIME, $currenttime) . '</small>', 'end_time', 30, 19, $endtime); |
|
| 138 | - $poll_form->addElement($expire_text); |
|
| 139 | - |
|
| 140 | - $weight_text = new \XoopsFormText(_MD_NEWBB_POLL_DISPLAYORDER, 'weight', 6, 5, 0); |
|
| 141 | - $poll_form->addElement($weight_text); |
|
| 142 | - |
|
| 143 | - $multi_yn = new \XoopsFormRadioYN(_MD_NEWBB_POLL_ALLOWMULTI, 'multiple', 0); |
|
| 144 | - $poll_form->addElement($multi_yn); |
|
| 145 | - |
|
| 146 | - $notify_yn = new \XoopsFormRadioYN(_MD_NEWBB_POLL_NOTIFY, 'notify', 1); |
|
| 147 | - $poll_form->addElement($notify_yn); |
|
| 148 | - |
|
| 149 | - $option_tray = new \XoopsFormElementTray(_MD_NEWBB_POLL_POLLOPTIONS, ''); |
|
| 150 | - $barcolor_array = \XoopsLists::getImgListAsArray($GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/assets/images/colorbars/')); |
|
| 151 | - for ($i = 0; $i < 10; ++$i) { |
|
| 152 | - $current_bar = ('blank.gif' !== current($barcolor_array)) ? current($barcolor_array) : next($barcolor_array); |
|
| 153 | - $option_text = new \XoopsFormText('', 'option_text[]', 50, 255); |
|
| 154 | - $option_tray->addElement($option_text); |
|
| 155 | - $color_select = new \XoopsFormSelect('', "option_color[{$i}]", $current_bar); |
|
| 156 | - $color_select->addOptionArray($barcolor_array); |
|
| 157 | - $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[{$i}]\", \"modules/" . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/assets/images/colorbars", "", "' . XOOPS_URL . "\")'"); |
|
| 158 | - $color_label = new \XoopsFormLabel('', "<img src='" |
|
| 159 | - . XOOPS_URL |
|
| 160 | - . '/modules/' |
|
| 161 | - . $GLOBALS['xoopsModuleConfig']['poll_module'] |
|
| 162 | - . '/assets/images/colorbars/' |
|
| 163 | - . $current_bar |
|
| 164 | - . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' width='30' align='bottom' height='15' alt='' /><br>"); |
|
| 165 | - $option_tray->addElement($color_select); |
|
| 166 | - $option_tray->addElement($color_label); |
|
| 167 | - if (!next($barcolor_array)) { |
|
| 168 | - reset($barcolor_array); |
|
| 169 | - } |
|
| 170 | - unset($color_select, $color_label); |
|
| 171 | - } |
|
| 172 | - $poll_form->addElement($option_tray); |
|
| 173 | - |
|
| 174 | - $poll_form->addElement(new \XoopsFormHidden('op', 'save')); |
|
| 175 | - $poll_form->addElement(new \XoopsFormHidden('topic_id', $topic_id)); |
|
| 176 | - $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id)); |
|
| 177 | - $poll_form->addElement(new \XoopsFormHidden('user_id', is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0)); |
|
| 178 | - $poll_form->addElement(new \XoopsFormButtonTray('poll_submit', _SUBMIT, 'submit')); |
|
| 179 | - echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . '</h4>'; |
|
| 180 | - $poll_form->display(); |
|
| 181 | - } |
|
| 182 | - break; // op: add |
|
| 183 | - |
|
| 184 | - case 'edit': |
|
| 185 | - // new xoopspoll module |
|
| 186 | - if ($pollModuleHandler->getVar('version') >= 140) { |
|
| 187 | - echo '<h4>' . _MD_NEWBB_POLL_EDITPOLL . "</h4>\n"; |
|
| 188 | - $pollObject->renderForm(Request::getString('PHP_SELF', '', 'SERVER'), 'post', ['topic_id' => $topic_id]); |
|
| 189 | - // old xoopspoll or umfrage or any clone from them |
|
| 190 | - } else { |
|
| 191 | - $classOption = $classPoll . 'Option'; |
|
| 192 | - $poll_form = new \XoopsThemeForm(_MD_NEWBB_POLL_EDITPOLL, 'poll_form', 'polls.php', 'post', true); |
|
| 193 | - $author_label = new \XoopsFormLabel(_MD_NEWBB_POLL_AUTHOR, "<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $pollObject->getVar('user_id') . "'>" . newbbGetUnameFromId($pollObject->getVar('user_id'), $GLOBALS['xoopsModuleConfig']['show_realname']) . '</a>'); |
|
| 194 | - $poll_form->addElement($author_label); |
|
| 195 | - $question_text = new \XoopsFormText(_MD_NEWBB_POLL_POLLQUESTION, 'question', 50, 255, $pollObject->getVar('question', 'E')); |
|
| 196 | - $poll_form->addElement($question_text); |
|
| 197 | - $desc_tarea = new \XoopsFormTextarea(_MD_NEWBB_POLL_POLLDESC, 'description', $pollObject->getVar('description', 'E')); |
|
| 198 | - $poll_form->addElement($desc_tarea); |
|
| 199 | - $date = formatTimestamp($pollObject->getVar('end_time'), 'Y-m-d H:i:s'); // important "Y-m-d H:i:s" use in jdf function |
|
| 200 | - if (!$pollObject->hasExpired()) { |
|
| 201 | - $expire_text = new \XoopsFormText(_MD_NEWBB_POLL_EXPIRATION . '<br><small>' . _MD_NEWBB_POLL_FORMAT . '<br>' . sprintf(_MD_NEWBB_POLL_CURRENTTIME, formatTimestamp(time(), 'Y-m-d H:i:s')) . '</small>', 'end_time', 20, 19, $date); |
|
| 202 | - $poll_form->addElement($expire_text); |
|
| 203 | - } else { |
|
| 204 | - // irmtfan full URL - add topic_id |
|
| 205 | - $restart_label = new \XoopsFormLabel( |
|
| 206 | - _MD_NEWBB_POLL_EXPIRATION, |
|
| 207 | - sprintf(_MD_NEWBB_POLL_EXPIREDAT, $date) . "<br><a href='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/polls.php?op=restart&poll_id={$poll_id}&topic_id={$topic_id}'>" . _MD_NEWBB_POLL_RESTART . '</a>' |
|
| 208 | - ); |
|
| 209 | - $poll_form->addElement($restart_label); |
|
| 210 | - } |
|
| 211 | - $weight_text = new \XoopsFormText(_MD_NEWBB_POLL_DISPLAYORDER, 'weight', 6, 5, $pollObject->getVar('weight')); |
|
| 212 | - $poll_form->addElement($weight_text); |
|
| 213 | - $multi_yn = new \XoopsFormRadioYN(_MD_NEWBB_POLL_ALLOWMULTI, 'multiple', $pollObject->getVar('multiple')); |
|
| 214 | - $poll_form->addElement($multi_yn); |
|
| 215 | - $options_arr =& $classOption::getAllByPollId($poll_id); |
|
| 216 | - $notify_value = 1; |
|
| 217 | - if (0 !== $pollObject->getVar('mail_status')) { |
|
| 218 | - $notify_value = 0; |
|
| 219 | - } |
|
| 220 | - $notify_yn = new \XoopsFormRadioYN(_MD_NEWBB_POLL_NOTIFY, 'notify', $notify_value); |
|
| 221 | - $poll_form->addElement($notify_yn); |
|
| 222 | - $option_tray = new \XoopsFormElementTray(_MD_NEWBB_POLL_POLLOPTIONS, ''); |
|
| 223 | - $barcolor_array = \XoopsLists::getImgListAsArray($GLOBALS['xoops']->path("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/")); |
|
| 224 | - $i = 0; |
|
| 225 | - foreach ($options_arr as $option) { |
|
| 226 | - /** @var \XoopsPoll $option */ |
|
| 227 | - $option_tray->addElement(new \XoopsFormText('', 'option_text[]', 50, 255, $option->getVar('option_text'))); |
|
| 228 | - $option_tray->addElement(new \XoopsFormHidden('option_id[]', $option->getVar('option_id'))); |
|
| 229 | - $color_select = new \XoopsFormSelect('', 'option_color[{$i}]', $option->getVar('option_color')); |
|
| 230 | - $color_select->addOptionArray($barcolor_array); |
|
| 231 | - $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[" . $i . "]\", \"modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars\", \"\", \"" . XOOPS_URL . "\")'"); |
|
| 232 | - $color_label = new \XoopsFormLabel('', "<img src='" |
|
| 233 | - . $GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/" . $option->getVar('option_color', 'E')) |
|
| 234 | - . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt='' /><br>"); |
|
| 235 | - $option_tray->addElement($color_select); |
|
| 236 | - $option_tray->addElement($color_label); |
|
| 237 | - unset($color_select, $color_label); |
|
| 238 | - ++$i; |
|
| 239 | - } |
|
| 240 | - // irmtfan full URL |
|
| 241 | - $more_label = new \XoopsFormLabel('', "<br><a href='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/polls.php?op=addmore&poll_id={$poll_id}&topic_id={$topic_id}'>" . _MD_NEWBB_POLL_ADDMORE . '</a>'); |
|
| 242 | - $option_tray->addElement($more_label); |
|
| 243 | - $poll_form->addElement($option_tray); |
|
| 244 | - $poll_form->addElement(new \XoopsFormHidden('op', 'update')); |
|
| 245 | - $poll_form->addElement(new \XoopsFormHidden('topic_id', $topic_id)); |
|
| 246 | - $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id)); |
|
| 247 | - $poll_form->addElement(new \XoopsFormButtonTray('poll_submit', _SUBMIT, 'submit')); |
|
| 248 | - |
|
| 249 | - echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n"; |
|
| 250 | - $poll_form->display(); |
|
| 251 | - } |
|
| 252 | - break; // op: edit |
|
| 253 | - |
|
| 254 | - case 'save': |
|
| 255 | - // old xoopspoll or umfrage or any clone from them |
|
| 256 | - if ($pollModuleHandler->getVar('version') < 140) { |
|
| 257 | - // check security token |
|
| 258 | - if (!$GLOBALS['xoopsSecurity']->check()) { |
|
| 259 | - redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())); |
|
| 260 | - } |
|
| 261 | - /* |
|
| 114 | + case 'add': |
|
| 115 | + // new xoopspoll module |
|
| 116 | + if ($pollModuleHandler->getVar('version') >= 140) { |
|
| 117 | + echo '<h4>' . _MD_NEWBB_POLL_CREATNEWPOLL . "</h4>\n"; |
|
| 118 | + $pollObject->renderForm(Request::getString('PHP_SELF', '', 'SERVER'), 'post', ['topic_id' => $topic_id]); |
|
| 119 | + // old xoopspoll or umfrage or any clone from them |
|
| 120 | + } else { |
|
| 121 | + $classOption = $classPoll . 'Option'; |
|
| 122 | + $poll_form = new \XoopsThemeForm(_MD_NEWBB_POLL_CREATNEWPOLL, 'poll_form', 'polls.php', 'post', true); |
|
| 123 | + $author_label = new \XoopsFormLabel(_MD_NEWBB_POLL_AUTHOR, is_object($GLOBALS['xoopsUser']) ? ("<a href='" |
|
| 124 | + . XOOPS_URL |
|
| 125 | + . '/userinfo.php?uid=' |
|
| 126 | + . $GLOBALS['xoopsUser']->getVar('uid') |
|
| 127 | + . "'>" |
|
| 128 | + . newbbGetUnameFromId($GLOBALS['xoopsUser']->getVar('uid'), $GLOBALS['xoopsModuleConfig']['show_realname']) |
|
| 129 | + . '</a>') : $GLOBALS['xoopsConfig']['anonymous']); |
|
| 130 | + $poll_form->addElement($author_label); |
|
| 131 | + $question_text = new \XoopsFormText(_MD_NEWBB_POLL_POLLQUESTION, 'question', 50, 255); |
|
| 132 | + $poll_form->addElement($question_text); |
|
| 133 | + $desc_tarea = new \XoopsFormTextarea(_MD_NEWBB_POLL_POLLDESC, 'description'); |
|
| 134 | + $poll_form->addElement($desc_tarea); |
|
| 135 | + $currenttime = formatTimestamp(time(), 'Y-m-d H:i:s'); |
|
| 136 | + $endtime = formatTimestamp(time() + 604800, 'Y-m-d H:i:s'); |
|
| 137 | + $expire_text = new \XoopsFormText(_MD_NEWBB_POLL_EXPIRATION . '<br><small>' . _MD_NEWBB_POLL_FORMAT . '<br>' . sprintf(_MD_NEWBB_POLL_CURRENTTIME, $currenttime) . '</small>', 'end_time', 30, 19, $endtime); |
|
| 138 | + $poll_form->addElement($expire_text); |
|
| 139 | + |
|
| 140 | + $weight_text = new \XoopsFormText(_MD_NEWBB_POLL_DISPLAYORDER, 'weight', 6, 5, 0); |
|
| 141 | + $poll_form->addElement($weight_text); |
|
| 142 | + |
|
| 143 | + $multi_yn = new \XoopsFormRadioYN(_MD_NEWBB_POLL_ALLOWMULTI, 'multiple', 0); |
|
| 144 | + $poll_form->addElement($multi_yn); |
|
| 145 | + |
|
| 146 | + $notify_yn = new \XoopsFormRadioYN(_MD_NEWBB_POLL_NOTIFY, 'notify', 1); |
|
| 147 | + $poll_form->addElement($notify_yn); |
|
| 148 | + |
|
| 149 | + $option_tray = new \XoopsFormElementTray(_MD_NEWBB_POLL_POLLOPTIONS, ''); |
|
| 150 | + $barcolor_array = \XoopsLists::getImgListAsArray($GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/assets/images/colorbars/')); |
|
| 151 | + for ($i = 0; $i < 10; ++$i) { |
|
| 152 | + $current_bar = ('blank.gif' !== current($barcolor_array)) ? current($barcolor_array) : next($barcolor_array); |
|
| 153 | + $option_text = new \XoopsFormText('', 'option_text[]', 50, 255); |
|
| 154 | + $option_tray->addElement($option_text); |
|
| 155 | + $color_select = new \XoopsFormSelect('', "option_color[{$i}]", $current_bar); |
|
| 156 | + $color_select->addOptionArray($barcolor_array); |
|
| 157 | + $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[{$i}]\", \"modules/" . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/assets/images/colorbars", "", "' . XOOPS_URL . "\")'"); |
|
| 158 | + $color_label = new \XoopsFormLabel('', "<img src='" |
|
| 159 | + . XOOPS_URL |
|
| 160 | + . '/modules/' |
|
| 161 | + . $GLOBALS['xoopsModuleConfig']['poll_module'] |
|
| 162 | + . '/assets/images/colorbars/' |
|
| 163 | + . $current_bar |
|
| 164 | + . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' width='30' align='bottom' height='15' alt='' /><br>"); |
|
| 165 | + $option_tray->addElement($color_select); |
|
| 166 | + $option_tray->addElement($color_label); |
|
| 167 | + if (!next($barcolor_array)) { |
|
| 168 | + reset($barcolor_array); |
|
| 169 | + } |
|
| 170 | + unset($color_select, $color_label); |
|
| 171 | + } |
|
| 172 | + $poll_form->addElement($option_tray); |
|
| 173 | + |
|
| 174 | + $poll_form->addElement(new \XoopsFormHidden('op', 'save')); |
|
| 175 | + $poll_form->addElement(new \XoopsFormHidden('topic_id', $topic_id)); |
|
| 176 | + $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id)); |
|
| 177 | + $poll_form->addElement(new \XoopsFormHidden('user_id', is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0)); |
|
| 178 | + $poll_form->addElement(new \XoopsFormButtonTray('poll_submit', _SUBMIT, 'submit')); |
|
| 179 | + echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . '</h4>'; |
|
| 180 | + $poll_form->display(); |
|
| 181 | + } |
|
| 182 | + break; // op: add |
|
| 183 | + |
|
| 184 | + case 'edit': |
|
| 185 | + // new xoopspoll module |
|
| 186 | + if ($pollModuleHandler->getVar('version') >= 140) { |
|
| 187 | + echo '<h4>' . _MD_NEWBB_POLL_EDITPOLL . "</h4>\n"; |
|
| 188 | + $pollObject->renderForm(Request::getString('PHP_SELF', '', 'SERVER'), 'post', ['topic_id' => $topic_id]); |
|
| 189 | + // old xoopspoll or umfrage or any clone from them |
|
| 190 | + } else { |
|
| 191 | + $classOption = $classPoll . 'Option'; |
|
| 192 | + $poll_form = new \XoopsThemeForm(_MD_NEWBB_POLL_EDITPOLL, 'poll_form', 'polls.php', 'post', true); |
|
| 193 | + $author_label = new \XoopsFormLabel(_MD_NEWBB_POLL_AUTHOR, "<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $pollObject->getVar('user_id') . "'>" . newbbGetUnameFromId($pollObject->getVar('user_id'), $GLOBALS['xoopsModuleConfig']['show_realname']) . '</a>'); |
|
| 194 | + $poll_form->addElement($author_label); |
|
| 195 | + $question_text = new \XoopsFormText(_MD_NEWBB_POLL_POLLQUESTION, 'question', 50, 255, $pollObject->getVar('question', 'E')); |
|
| 196 | + $poll_form->addElement($question_text); |
|
| 197 | + $desc_tarea = new \XoopsFormTextarea(_MD_NEWBB_POLL_POLLDESC, 'description', $pollObject->getVar('description', 'E')); |
|
| 198 | + $poll_form->addElement($desc_tarea); |
|
| 199 | + $date = formatTimestamp($pollObject->getVar('end_time'), 'Y-m-d H:i:s'); // important "Y-m-d H:i:s" use in jdf function |
|
| 200 | + if (!$pollObject->hasExpired()) { |
|
| 201 | + $expire_text = new \XoopsFormText(_MD_NEWBB_POLL_EXPIRATION . '<br><small>' . _MD_NEWBB_POLL_FORMAT . '<br>' . sprintf(_MD_NEWBB_POLL_CURRENTTIME, formatTimestamp(time(), 'Y-m-d H:i:s')) . '</small>', 'end_time', 20, 19, $date); |
|
| 202 | + $poll_form->addElement($expire_text); |
|
| 203 | + } else { |
|
| 204 | + // irmtfan full URL - add topic_id |
|
| 205 | + $restart_label = new \XoopsFormLabel( |
|
| 206 | + _MD_NEWBB_POLL_EXPIRATION, |
|
| 207 | + sprintf(_MD_NEWBB_POLL_EXPIREDAT, $date) . "<br><a href='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/polls.php?op=restart&poll_id={$poll_id}&topic_id={$topic_id}'>" . _MD_NEWBB_POLL_RESTART . '</a>' |
|
| 208 | + ); |
|
| 209 | + $poll_form->addElement($restart_label); |
|
| 210 | + } |
|
| 211 | + $weight_text = new \XoopsFormText(_MD_NEWBB_POLL_DISPLAYORDER, 'weight', 6, 5, $pollObject->getVar('weight')); |
|
| 212 | + $poll_form->addElement($weight_text); |
|
| 213 | + $multi_yn = new \XoopsFormRadioYN(_MD_NEWBB_POLL_ALLOWMULTI, 'multiple', $pollObject->getVar('multiple')); |
|
| 214 | + $poll_form->addElement($multi_yn); |
|
| 215 | + $options_arr =& $classOption::getAllByPollId($poll_id); |
|
| 216 | + $notify_value = 1; |
|
| 217 | + if (0 !== $pollObject->getVar('mail_status')) { |
|
| 218 | + $notify_value = 0; |
|
| 219 | + } |
|
| 220 | + $notify_yn = new \XoopsFormRadioYN(_MD_NEWBB_POLL_NOTIFY, 'notify', $notify_value); |
|
| 221 | + $poll_form->addElement($notify_yn); |
|
| 222 | + $option_tray = new \XoopsFormElementTray(_MD_NEWBB_POLL_POLLOPTIONS, ''); |
|
| 223 | + $barcolor_array = \XoopsLists::getImgListAsArray($GLOBALS['xoops']->path("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/")); |
|
| 224 | + $i = 0; |
|
| 225 | + foreach ($options_arr as $option) { |
|
| 226 | + /** @var \XoopsPoll $option */ |
|
| 227 | + $option_tray->addElement(new \XoopsFormText('', 'option_text[]', 50, 255, $option->getVar('option_text'))); |
|
| 228 | + $option_tray->addElement(new \XoopsFormHidden('option_id[]', $option->getVar('option_id'))); |
|
| 229 | + $color_select = new \XoopsFormSelect('', 'option_color[{$i}]', $option->getVar('option_color')); |
|
| 230 | + $color_select->addOptionArray($barcolor_array); |
|
| 231 | + $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[" . $i . "]\", \"modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars\", \"\", \"" . XOOPS_URL . "\")'"); |
|
| 232 | + $color_label = new \XoopsFormLabel('', "<img src='" |
|
| 233 | + . $GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/" . $option->getVar('option_color', 'E')) |
|
| 234 | + . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt='' /><br>"); |
|
| 235 | + $option_tray->addElement($color_select); |
|
| 236 | + $option_tray->addElement($color_label); |
|
| 237 | + unset($color_select, $color_label); |
|
| 238 | + ++$i; |
|
| 239 | + } |
|
| 240 | + // irmtfan full URL |
|
| 241 | + $more_label = new \XoopsFormLabel('', "<br><a href='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/polls.php?op=addmore&poll_id={$poll_id}&topic_id={$topic_id}'>" . _MD_NEWBB_POLL_ADDMORE . '</a>'); |
|
| 242 | + $option_tray->addElement($more_label); |
|
| 243 | + $poll_form->addElement($option_tray); |
|
| 244 | + $poll_form->addElement(new \XoopsFormHidden('op', 'update')); |
|
| 245 | + $poll_form->addElement(new \XoopsFormHidden('topic_id', $topic_id)); |
|
| 246 | + $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id)); |
|
| 247 | + $poll_form->addElement(new \XoopsFormButtonTray('poll_submit', _SUBMIT, 'submit')); |
|
| 248 | + |
|
| 249 | + echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n"; |
|
| 250 | + $poll_form->display(); |
|
| 251 | + } |
|
| 252 | + break; // op: edit |
|
| 253 | + |
|
| 254 | + case 'save': |
|
| 255 | + // old xoopspoll or umfrage or any clone from them |
|
| 256 | + if ($pollModuleHandler->getVar('version') < 140) { |
|
| 257 | + // check security token |
|
| 258 | + if (!$GLOBALS['xoopsSecurity']->check()) { |
|
| 259 | + redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())); |
|
| 260 | + } |
|
| 261 | + /* |
|
| 262 | 262 | * The option check should be done before submitting |
| 263 | 263 | */ |
| 264 | - $option_empty = true; |
|
| 265 | - if (!Request::getString('option_text', '', 'POST')) { |
|
| 266 | - // irmtfan - issue with javascript:history.go(-1) |
|
| 267 | - redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !'); |
|
| 268 | - } |
|
| 269 | - $option_text = Request::getArray('option_text', '', 'POST'); |
|
| 270 | - foreach ($option_text as $optxt) { |
|
| 271 | - if ('' !== trim($optxt)) { |
|
| 272 | - $option_empty = false; |
|
| 273 | - break; |
|
| 274 | - } |
|
| 275 | - } |
|
| 276 | - if ($option_empty) { |
|
| 277 | - // irmtfan - issue with javascript:history.go(-1) |
|
| 278 | - redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !'); |
|
| 279 | - } |
|
| 280 | - $pollObject->setVar('question', Request::getString('question', '', 'POST')); |
|
| 281 | - $pollObject->setVar('description', Request::getString('description', '', 'POST')); |
|
| 282 | - $end_time = Request::getString('end_time', '', 'POST'); // (empty($_POST['end_time'])) ? "" : $_POST['end_time']; |
|
| 283 | - if ('' !== $end_time) { |
|
| 284 | - $timezone = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('timezone') : null; |
|
| 285 | - $pollObject->setVar('end_time', userTimeToServerTime(method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime($end_time) : strtotime($end_time), $timezone)); |
|
| 286 | - } else { |
|
| 287 | - // if expiration date is not set, set it to 10 days from now |
|
| 288 | - $pollObject->setVar('end_time', time() + (86400 * 10)); |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - $pollObject->setVar('display', 0); |
|
| 292 | - $pollObject->setVar('weight', Request::getInt('weight', 0, 'POST')); |
|
| 293 | - $pollObject->setVar('multiple', Request::getInt('multiple', 0, 'POST')); |
|
| 294 | - $pollObject->setVar('user_id', Request::getInt('user_id', 0, 'POST')); |
|
| 295 | - if (Request::getInt('notify', 0, 'POST') && $end_time > time()) { |
|
| 296 | - // if notify, set mail status to "not mailed" |
|
| 297 | - $pollObject->setVar('mail_status', Xoopspoll\Constants::POLL_NOT_MAILED); |
|
| 298 | - } else { |
|
| 299 | - // if not notify, set mail status to already "mailed" |
|
| 300 | - $pollObject->setVar('mail_status', Xoopspoll\Constants::POLL_MAILED); |
|
| 301 | - } |
|
| 302 | - $new_poll_id = $pollObject->store(); |
|
| 303 | - if (empty($new_poll_id)) { |
|
| 304 | - xoops_error($pollObject->getHtmlErrors); |
|
| 305 | - break; |
|
| 306 | - } |
|
| 307 | - $i = 0; |
|
| 308 | - $option_color = Request::getArray('option_color', null, 'POST'); |
|
| 309 | - $classOption = $classPoll . 'Option'; |
|
| 310 | - foreach ($option_text as $optxt) { |
|
| 311 | - $optxt = trim($optxt); |
|
| 312 | - /** @var Xoopspoll\Option $optionObject */ |
|
| 313 | - $optionObject = new $classOption(); |
|
| 314 | - if ('' !== $optxt) { |
|
| 315 | - $optionObject->setVar('option_text', $optxt); |
|
| 316 | - $optionObject->setVar('option_color', $option_color[$i]); |
|
| 317 | - $optionObject->setVar('poll_id', $new_poll_id); |
|
| 318 | - $optionObject->store(); |
|
| 319 | - } |
|
| 320 | - ++$i; |
|
| 321 | - } |
|
| 322 | - // clear the template cache so changes take effect immediately |
|
| 323 | - require_once $GLOBALS['xoops']->path('class/template.php'); |
|
| 324 | - xoops_template_clear_module_cache($GLOBALS['xoopsModule']->getVar('mid')); |
|
| 325 | - xoops_template_clear_module_cache($pollModuleHandler->getVar('mid')); |
|
| 326 | - |
|
| 327 | - // update topic to indicate it has a poll |
|
| 328 | - $topicObject->setVar('topic_haspoll', 1); |
|
| 329 | - $topicObject->setVar('poll_id', $new_poll_id); |
|
| 330 | - $success = $topicHandler->insert($topicObject); |
|
| 331 | - if (!$success) { |
|
| 332 | - xoops_error($topicHandler->getHtmlErrors()); |
|
| 333 | - } else { |
|
| 334 | - redirect_header("viewtopic.php?topic_id={$topic_id}", 2, _MD_NEWBB_POLL_DBUPDATED); |
|
| 335 | - } |
|
| 336 | - break;// op: save |
|
| 337 | - } |
|
| 338 | - // no break |
|
| 339 | - case 'update': |
|
| 340 | - // check security token |
|
| 341 | - if (!$GLOBALS['xoopsSecurity']->check()) { |
|
| 342 | - redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())); |
|
| 343 | - } |
|
| 344 | - /* make sure there's at least one option */ |
|
| 345 | - $option_text = Request::getString('option_text', '', 'POST'); |
|
| 346 | - $option_string = is_array($option_text) ? implode('', $option_text) : $option_text; |
|
| 347 | - $option_string = trim($option_string); |
|
| 348 | - if ('' === $option_string) { |
|
| 349 | - redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !'); |
|
| 350 | - } |
|
| 351 | - |
|
| 352 | - // new xoopspoll module |
|
| 353 | - if ($pollModuleHandler->getVar('version') >= 140) { |
|
| 354 | - /** @var Xoopspoll\OptionHandler $xpOptHandler */ |
|
| 355 | - $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); |
|
| 356 | - /** @var Xoopspoll\LogHandler $xpLogHandler */ |
|
| 357 | - $xpLogHandler = Xoopspoll\Helper::getInstance()->getHandler('Log'); |
|
| 358 | - // $classRequest = ucfirst($GLOBALS['xoopsModuleConfig']["poll_module"]) . "Request"; |
|
| 359 | - $classConstants = new XoopsModules\Xoopspoll\Constants(); |
|
| 360 | - $notify = Request::getInt('notify', $classConstants::NOTIFICATION_ENABLED, 'POST'); |
|
| 361 | - $currentTimestamp = time(); |
|
| 362 | - //$xuEndTimestamp = method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime(Request::getString('xu_end_time', null, 'POST')) |
|
| 363 | - // : strtotime(Request::getString('xu_end_time', null, 'POST')); |
|
| 364 | - $xuEndTimestamp = strtotime(Request::getString('xu_end_time', null, 'POST')); |
|
| 365 | - $endTimestamp = (!Request::getString('xu_end_time', null, 'POST')) ? ($currentTimestamp + $classConstants::DEFAULT_POLL_DURATION) : userTimeToServerTime($xuEndTimestamp); |
|
| 366 | - //$xuStartTimestamp = method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime(Request::getString('xu_start_time', null, 'POST')) |
|
| 367 | - // : strtotime(Request::getString('xu_start_time', null, 'POST')); |
|
| 368 | - $xuStartTimestamp = strtotime(Request::getString('xu_start_time', null, 'POST')); |
|
| 369 | - $startTimestamp = (!Request::getString('xu_start_time', null, 'POST')) ? ($endTimestamp - $classConstants::DEFAULT_POLL_DURATION) : userTimeToServerTime($xuStartTimestamp); |
|
| 370 | - |
|
| 371 | - // don't allow changing start time if there are votes in the log |
|
| 372 | - if (($startTimestamp < $pollObject->getVar('start_time')) |
|
| 373 | - && ($xpLogHandler->getTotalVotesByPollId($poll_id) > 0)) { |
|
| 374 | - $startTimestamp = $pollObject->getVar('start_time'); //don't change start time |
|
| 375 | - } |
|
| 376 | - |
|
| 377 | - $poll_vars = [ |
|
| 378 | - 'user_id' => Request::getInt('user_id', $GLOBALS['xoopsUser']->uid(), 'POST'), |
|
| 379 | - 'question' => Request::getString('question', null, 'POST'), |
|
| 380 | - 'description' => Request::getText('description', null, 'POST'), |
|
| 381 | - 'mail_status' => ($classConstants::NOTIFICATION_ENABLED == $notify) ? $classConstants::POLL_NOT_MAILED : $classConstants::POLL_MAILED, |
|
| 382 | - 'mail_voter' => Request::getInt('mail_voter', $classConstants::NOT_MAIL_POLL_TO_VOTER, 'POST'), |
|
| 383 | - 'start_time' => $startTimestamp, |
|
| 384 | - 'end_time' => $endTimestamp, |
|
| 385 | - 'display' => Request::getInt('display', $classConstants::DO_NOT_DISPLAY_POLL_IN_BLOCK, 'POST'), |
|
| 386 | - 'visibility' => Request::getInt('visibility', $classConstants::HIDE_NEVER, 'POST'), |
|
| 387 | - 'weight' => Request::getInt('weight', $classConstants::DEFAULT_WEIGHT, 'POST'), |
|
| 388 | - 'multiple' => Request::getInt('multiple', $classConstants::NOT_MULTIPLE_SELECT_POLL, 'POST'), |
|
| 389 | - 'multilimit' => Request::getInt('multilimit', $classConstants::MULTIPLE_SELECT_LIMITLESS, 'POST'), |
|
| 390 | - 'anonymous' => Request::getInt('anonymous', $classConstants::ANONYMOUS_VOTING_DISALLOWED, 'POST') |
|
| 391 | - ]; |
|
| 392 | - $pollObject->setVars($poll_vars); |
|
| 393 | - $poll_id = $xpPollHandler->insert($pollObject); |
|
| 394 | - if (!$poll_id) { |
|
| 395 | - $err = $pollObject->getHtmlErrors(); |
|
| 396 | - exit($err); |
|
| 397 | - } |
|
| 398 | - |
|
| 399 | - // now get the options |
|
| 400 | - $optionIdArray = Request::getArray('option_id', [], 'POST'); |
|
| 401 | - $optionIdArray = array_map('intval', $optionIdArray); |
|
| 402 | - $optionTextArray = Request::getArray('option_text', [], 'POST'); |
|
| 403 | - $optionColorArray = Request::getArray('option_color', [], 'POST'); |
|
| 404 | - |
|
| 405 | - foreach ($optionIdArray as $key => $oId) { |
|
| 406 | - if (!empty($oId) && ($optionObject = $xpOptHandler->get($oId))) { |
|
| 407 | - // existing option object so need to update it |
|
| 408 | - $optionTextArray[$key] = trim($optionTextArray[$key]); |
|
| 409 | - if ('' === $optionTextArray[$key]) { |
|
| 410 | - // want to delete this option |
|
| 411 | - if (false !== $xpOptHandler->delete($optionObject)) { |
|
| 412 | - // now remove it from the log |
|
| 413 | - $xpLogHandler->deleteByOptionId($optionObject->getVar('option_id')); |
|
| 414 | - //update vote count in poll |
|
| 415 | - $xpPollHandler->updateCount($pollObject); |
|
| 416 | - } else { |
|
| 417 | - xoops_error($xpLogHandler->getHtmlErrors()); |
|
| 418 | - break; |
|
| 419 | - } |
|
| 420 | - } else { |
|
| 421 | - $optionObject->setVar('option_text', $optionTextArray[$key]); |
|
| 422 | - $optionObject->setVar('option_color', $optionColorArray[$key]); |
|
| 423 | - $optionObject->setVar('poll_id', $poll_id); |
|
| 424 | - $xpOptHandler->insert($optionObject); |
|
| 425 | - } |
|
| 426 | - } else { |
|
| 427 | - // new option object |
|
| 428 | - $optionObject = $xpOptHandler->create(); |
|
| 429 | - $optionTextArray[$key] = trim($optionTextArray[$key]); |
|
| 430 | - if ('' !== $optionTextArray[$key]) { // ignore if text is empty |
|
| 431 | - $optionObject->setVar('option_text', $optionTextArray[$key]); |
|
| 432 | - $optionObject->setVar('option_color', $optionColorArray[$key]); |
|
| 433 | - $optionObject->setVar('poll_id', $poll_id); |
|
| 434 | - $xpOptHandler->insert($optionObject); |
|
| 435 | - } |
|
| 436 | - unset($optionObject); |
|
| 437 | - } |
|
| 438 | - } |
|
| 439 | - // old xoopspoll or umfrage or any clone from them |
|
| 440 | - } else { |
|
| 441 | - $pollObject->setVar('question', Request::getString('question', '', 'POST')); |
|
| 442 | - $pollObject->setVar('description', Request::getString('description', '', 'POST')); |
|
| 443 | - |
|
| 444 | - $end_time = Request::getString('end_time', '', 'POST'); |
|
| 445 | - if ('' !== $end_time) { |
|
| 446 | - $timezone = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('timezone') : null; |
|
| 447 | - $pollObject->setVar('end_time', userTimeToServerTime(method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime($end_time) : strtotime($end_time), $timezone)); |
|
| 448 | - } |
|
| 449 | - $pollObject->setVar('display', 0); |
|
| 450 | - $pollObject->setVar('weight', Request::getInt('weight', 0, 'POST')); |
|
| 451 | - $pollObject->setVar('multiple', Request::getInt('multiple', 0, 'POST')); |
|
| 452 | - $pollObject->setVar('user_id', Request::getInt('user_id', 0, 'POST')); |
|
| 453 | - if (Request::getInt('notify', 0, 'POST') && $end_time > time()) { |
|
| 454 | - // if notify, set mail status to "not mailed" |
|
| 455 | - $pollObject->setVar('mail_status', $classConstants::POLL_NOT_MAILED); |
|
| 456 | - } else { |
|
| 457 | - // if not notify, set mail status to already "mailed" |
|
| 458 | - $pollObject->setVar('mail_status', $classConstants::POLL_MAILED); |
|
| 459 | - } |
|
| 460 | - |
|
| 461 | - if (!$pollObject->store()) { |
|
| 462 | - xoops_error($pollObject->getHtmlErrors); |
|
| 463 | - break; |
|
| 464 | - } |
|
| 465 | - $i = 0; |
|
| 466 | - $option_id = Request::getArray('option_id', null, 'POST'); |
|
| 467 | - $option_color = Request::getArray('option_color', null, 'POST'); |
|
| 468 | - $classOption = $classPoll . 'Option'; |
|
| 469 | - $classLog = $classPoll . 'Log'; |
|
| 470 | - foreach ($option_id as $opid) { |
|
| 471 | - $optionObject = new $classOption($opid); |
|
| 472 | - $option_text[$i] = trim($option_text[$i]); |
|
| 473 | - if ('' !== $option_text[$i]) { |
|
| 474 | - $optionObject->setVar('option_text', $option_text[$i]); |
|
| 475 | - $optionObject->setVar('option_color', $option_color[$i]); |
|
| 476 | - $optionObject->store(); |
|
| 477 | - } else { |
|
| 478 | - if (false !== $optionObject->delete()) { |
|
| 479 | - $classLog::deleteByOptionId($option->getVar('option_id')); |
|
| 480 | - } |
|
| 481 | - } |
|
| 482 | - ++$i; |
|
| 483 | - } |
|
| 484 | - $pollObject->updateCount(); |
|
| 485 | - } |
|
| 486 | - // clear the template cache so changes take effect immediately |
|
| 487 | - require_once $GLOBALS['xoops']->path('class/template.php'); |
|
| 488 | - xoops_template_clear_module_cache($GLOBALS['xoopsModule']->getVar('mid')); |
|
| 489 | - xoops_template_clear_module_cache($pollModuleHandler->getVar('mid')); |
|
| 490 | - |
|
| 491 | - // update topic to indicate it has a poll |
|
| 492 | - $topicObject->setVar('topic_haspoll', 1); |
|
| 493 | - $topicObject->setVar('poll_id', $pollObject->getVar('poll_id')); |
|
| 494 | - $success = $topicHandler->insert($topicObject); |
|
| 495 | - if (!$success) { |
|
| 496 | - xoops_error($topicHandler->getHtmlErrors()); |
|
| 497 | - } else { |
|
| 498 | - redirect_header("viewtopic.php?topic_id={$topic_id}", 2, _MD_NEWBB_POLL_DBUPDATED); |
|
| 499 | - } |
|
| 500 | - break;// op: save | update |
|
| 501 | - |
|
| 502 | - case 'addmore': |
|
| 503 | - $question = $pollObject->getVar('question'); |
|
| 504 | - unset($pollObject); |
|
| 505 | - $poll_form = new \XoopsThemeForm(_MD_NEWBB_POLL_ADDMORE, 'poll_form', 'polls.php', 'post', true); |
|
| 506 | - $poll_form->addElement(new \XoopsFormLabel(_MD_NEWBB_POLL_POLLQUESTION, $question)); |
|
| 507 | - // new xoopspoll module |
|
| 508 | - if ($pollModuleHandler->getVar('version') >= 140) { |
|
| 509 | - $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); |
|
| 510 | - $option_tray = $xpOptHandler->renderOptionFormTray($poll_id); |
|
| 511 | - // old xoopspoll or umfrage or any clone from them |
|
| 512 | - } else { |
|
| 513 | - $option_tray = new \XoopsFormElementTray(_MD_NEWBB_POLL_POLLOPTIONS, ''); |
|
| 514 | - $barcolor_array = \XoopsLists::getImgListAsArray($GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/assets/images/colorbars/')); |
|
| 515 | - for ($i = 0; $i < 10; ++$i) { |
|
| 516 | - $current_bar = ('blank.gif' !== current($barcolor_array)) ? current($barcolor_array) : next($barcolor_array); |
|
| 517 | - $option_text = new \XoopsFormText('', 'option_text[]', 50, 255); |
|
| 518 | - $option_tray->addElement($option_text); |
|
| 519 | - $color_select = new \XoopsFormSelect('', "option_color[{$i}]", $current_bar); |
|
| 520 | - $color_select->addOptionArray($barcolor_array); |
|
| 521 | - $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[{$i}]\", \"modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars\", \"\", \"" . XOOPS_URL . "\")'"); |
|
| 522 | - $color_label = new \XoopsFormLabel('', "<img src='" |
|
| 523 | - . $GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/{$current_bar}") |
|
| 524 | - . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt='' /><br>"); |
|
| 525 | - $option_tray->addElement($color_select); |
|
| 526 | - $option_tray->addElement($color_label); |
|
| 527 | - unset($color_select, $color_label, $option_text); |
|
| 528 | - if (!next($barcolor_array)) { |
|
| 529 | - reset($barcolor_array); |
|
| 530 | - } |
|
| 531 | - } |
|
| 532 | - } |
|
| 533 | - $poll_form->addElement($option_tray); |
|
| 534 | - $poll_form->addElement(new \XoopsFormButtonTray('poll_submit', _SUBMIT, 'submit')); |
|
| 535 | - $poll_form->addElement(new \XoopsFormHidden('op', 'savemore')); |
|
| 536 | - $poll_form->addElement(new \XoopsFormHidden('topic_id', $topic_id)); |
|
| 537 | - $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id)); |
|
| 538 | - |
|
| 539 | - echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n"; |
|
| 540 | - $poll_form->display(); |
|
| 541 | - break; |
|
| 542 | - |
|
| 543 | - case 'savemore': |
|
| 544 | - // check security token |
|
| 545 | - if (!$GLOBALS['xoopsSecurity']->check()) { |
|
| 546 | - redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())); |
|
| 547 | - } |
|
| 548 | - |
|
| 549 | - $option_text = Request::getString('option_text', '', 'POST'); |
|
| 550 | - $option_string = is_array($option_text) ? implode('', $option_text) : $option_text; |
|
| 551 | - $option_string = trim($option_string); |
|
| 552 | - if ('' === $option_string) { |
|
| 553 | - // irmtfan - issue with javascript:history.go(-1) |
|
| 554 | - redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !'); |
|
| 555 | - } |
|
| 556 | - $i = 0; |
|
| 557 | - $option_color = Request::getArray('option_color', null, 'POST'); |
|
| 558 | - foreach ($option_text as $optxt) { |
|
| 559 | - $optxt = trim($optxt); |
|
| 560 | - if ('' !== $optxt) { |
|
| 561 | - // new xoopspoll module |
|
| 562 | - if ($pollModuleHandler->getVar('version') >= 140) { |
|
| 563 | - $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); |
|
| 564 | - $optionObject = $xpOptHandler->create(); |
|
| 565 | - $optionObject->setVar('option_text', $optxt); |
|
| 566 | - $optionObject->setVar('poll_id', $poll_id); |
|
| 567 | - $optionObject->setVar('option_color', $option_color[$i]); |
|
| 568 | - $xpOptHandler->insert($optionObject); |
|
| 569 | - // old xoopspoll or umfrage or any clone from them |
|
| 570 | - } else { |
|
| 571 | - $classOption = $classPoll . 'Option'; |
|
| 572 | - $optionObject = new $classOption(); |
|
| 573 | - $optionObject->setVar('option_text', $optxt); |
|
| 574 | - $optionObject->setVar('poll_id', $poll_id); |
|
| 575 | - $optionObject->setVar('option_color', $option_color[$i]); |
|
| 576 | - $optionObject->store(); |
|
| 577 | - } |
|
| 578 | - unset($optionObject); |
|
| 579 | - } |
|
| 580 | - ++$i; |
|
| 581 | - } |
|
| 582 | - require_once $GLOBALS['xoops']->path('class/template.php'); |
|
| 583 | - xoops_template_clear_module_cache($GLOBALS['xoopsModule']->getVar('mid')); |
|
| 584 | - xoops_template_clear_module_cache($pollModuleHandler->getVar('mid')); |
|
| 585 | - redirect_header("polls.php?op=edit&poll_id={$poll_id}&topic_id={$topic_id}", 2, _MD_NEWBB_POLL_DBUPDATED); |
|
| 586 | - break; |
|
| 587 | - |
|
| 588 | - case 'delete': |
|
| 589 | - echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n"; |
|
| 590 | - xoops_confirm(['op' => 'delete_ok', 'topic_id' => $topic_id, 'poll_id' => $poll_id], 'polls.php', sprintf(_MD_NEWBB_POLL_RUSUREDEL, $pollObject->getVar('question'))); |
|
| 591 | - break; |
|
| 592 | - |
|
| 593 | - case 'delete_ok': |
|
| 594 | - // check security token |
|
| 595 | - if (!$GLOBALS['xoopsSecurity']->check()) { |
|
| 596 | - redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())); |
|
| 597 | - } |
|
| 598 | - //try and delete the poll |
|
| 599 | - // new xoopspoll module |
|
| 600 | - if ($pollModuleHandler->getVar('version') >= 140) { |
|
| 601 | - $status = $xpPollHandler->delete($pollObject); |
|
| 602 | - if (false !== $status) { |
|
| 603 | - $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); |
|
| 604 | - $xpLogHandler = Xoopspoll\Helper::getInstance()->getHandler('Log'); |
|
| 605 | - $xpOptHandler->deleteByPollId($poll_id); |
|
| 606 | - $xpLogHandler->deleteByPollId($poll_id); |
|
| 607 | - } else { |
|
| 608 | - $msg = $xpPollHandler->getHtmlErrors(); |
|
| 609 | - } |
|
| 610 | - // old xoopspoll or umfrage or any clone from them |
|
| 611 | - } else { |
|
| 612 | - $status = $pollObject->delete(); |
|
| 613 | - $classOption = $classPoll . 'Option'; |
|
| 614 | - $classLog = $classPoll . 'Log'; |
|
| 615 | - if (false !== $status) { |
|
| 616 | - $classOption::deleteByPollId($poll_id); |
|
| 617 | - $classLog::deleteByPollId($poll_id); |
|
| 618 | - } else { |
|
| 619 | - $msg = $pollObject->getHtmlErrors(); |
|
| 620 | - } |
|
| 621 | - } |
|
| 622 | - if (false !== $status) { |
|
| 623 | - require_once $GLOBALS['xoops']->path('class/template.php'); |
|
| 624 | - xoops_template_clear_module_cache($xoopsModule->getVar('mid')); |
|
| 625 | - xoops_template_clear_module_cache($pollModuleHandler->getVar('mid')); |
|
| 626 | - // delete comments for this poll |
|
| 627 | - xoops_comment_delete($xoopsModule->getVar('mid'), $poll_id); |
|
| 628 | - |
|
| 629 | - $topicObject->setVar('votes', 0); // not sure why we want to clear votes too... but I left it alone |
|
| 630 | - $topicObject->setVar('topic_haspoll', 0); |
|
| 631 | - $topicObject->setVar('poll_id', 0); |
|
| 632 | - $success = $topicHandler->insert($topicObject); |
|
| 633 | - if (!$success) { |
|
| 634 | - xoops_error($topicHandler->getHtmlErrors()); |
|
| 635 | - break; |
|
| 636 | - } |
|
| 637 | - } else { |
|
| 638 | - xoops_error($msg); |
|
| 639 | - break; |
|
| 640 | - } |
|
| 641 | - redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id={$topic_id}", 1, _MD_NEWBB_POLL_DBUPDATED); |
|
| 642 | - break; |
|
| 643 | - |
|
| 644 | - case 'restart': |
|
| 645 | - // new xoopspoll module |
|
| 646 | - if ($pollModuleHandler->getVar('version') >= 140) { |
|
| 647 | - $classConstants = new XoopsModules\Xoopspoll\Constants(); |
|
| 648 | - $default_poll_duration = $classConstants::DEFAULT_POLL_DURATION; |
|
| 649 | - // old xoopspoll or umfrage or any clone from them |
|
| 650 | - } else { |
|
| 651 | - $default_poll_duration = (86400 * 10); |
|
| 652 | - } |
|
| 653 | - $poll_form = new \XoopsThemeForm(_MD_NEWBB_POLL_RESTARTPOLL, 'poll_form', 'polls.php', 'post', true); |
|
| 654 | - $expire_text = new \XoopsFormText( |
|
| 655 | - _MD_NEWBB_POLL_EXPIRATION . '<br><small>' . _MD_NEWBB_POLL_FORMAT . '<br>' . sprintf(_MD_NEWBB_POLL_CURRENTTIME, formatTimestamp(time(), 'Y-m-d H:i:s')) . '<br>' . sprintf( |
|
| 656 | - _MD_NEWBB_POLL_EXPIREDAT, |
|
| 657 | - formatTimestamp($pollObject->getVar('end_time'), 'Y-m-d H:i:s') |
|
| 658 | - ) . '</small>', |
|
| 659 | - 'end_time', |
|
| 660 | - 20, |
|
| 661 | - 19, |
|
| 662 | - formatTimestamp(time() + $default_poll_duration, 'Y-m-d H:i:s') |
|
| 663 | - ); |
|
| 664 | - $poll_form->addElement($expire_text); |
|
| 665 | - $poll_form->addElement(new \XoopsFormRadioYN(_MD_NEWBB_POLL_NOTIFY, 'notify', 1)); |
|
| 666 | - $poll_form->addElement(new \XoopsFormRadioYN(_MD_NEWBB_POLL_RESET, 'reset', 0)); |
|
| 667 | - $poll_form->addElement(new \XoopsFormHidden('op', 'restart_ok')); |
|
| 668 | - $poll_form->addElement(new \XoopsFormHidden('topic_id', $topic_id)); |
|
| 669 | - $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id)); |
|
| 670 | - $poll_form->addElement(new \XoopsFormButton('', 'poll_submit', _MD_NEWBB_POLL_RESTART, 'submit')); |
|
| 671 | - |
|
| 672 | - echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n"; |
|
| 673 | - $poll_form->display(); |
|
| 674 | - break; |
|
| 675 | - |
|
| 676 | - case 'restart_ok': |
|
| 677 | - // check security token |
|
| 678 | - if (!$GLOBALS['xoopsSecurity']->check()) { |
|
| 679 | - redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())); |
|
| 680 | - } |
|
| 681 | - |
|
| 682 | - // new xoopspoll module |
|
| 683 | - if ($pollModuleHandler->getVar('version') >= 140) { |
|
| 684 | - $classConstants = new XoopsModules\Xoopspoll\Constants(); |
|
| 685 | - $default_poll_duration = $classConstants::DEFAULT_POLL_DURATION; |
|
| 686 | - $poll_not_mailed = $classConstants::POLL_NOT_MAILED; |
|
| 687 | - $poll_mailed = $classConstants::POLL_MAILED; |
|
| 688 | - // old xoopspoll or umfrage or any clone from them |
|
| 689 | - } else { |
|
| 690 | - $default_poll_duration = (86400 * 10); |
|
| 691 | - $poll_not_mailed = Xoopspoll\Constants::POLL_NOT_MAILED; |
|
| 692 | - $poll_mailed = Xoopspoll\Constants::POLL_MAILED; |
|
| 693 | - } |
|
| 694 | - |
|
| 695 | - $end_time = !Request::getInt('end_time', 0, 'POST'); |
|
| 696 | - if (0 !== $end_time) { |
|
| 697 | - $timezone = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('timezone') : null; |
|
| 698 | - $pollObject->setVar('end_time', userTimeToServerTime(method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime($end_time) : strtotime($end_time), $timezone)); |
|
| 699 | - } else { |
|
| 700 | - $pollObject->setVar('end_time', time() + $default_poll_duration); |
|
| 701 | - } |
|
| 702 | - |
|
| 703 | - $isNotify = Request::getInt('notify', 0, 'POST'); |
|
| 704 | - if (!empty($isNotify) && ($end_time > time())) { |
|
| 705 | - // if notify, set mail status to "not mailed" |
|
| 706 | - $pollObject->setVar('mail_status', $poll_not_mailed); |
|
| 707 | - } else { |
|
| 708 | - // if not notify, set mail status to already "mailed" |
|
| 709 | - $pollObject->setVar('mail_status', $poll_mailed); |
|
| 710 | - } |
|
| 711 | - |
|
| 712 | - // new xoopspoll module |
|
| 713 | - if ($pollModuleHandler->getVar('version') >= 140) { |
|
| 714 | - if (!$xpPollHandler->insert($pollObject)) { // update the poll |
|
| 715 | - xoops_error($pollObject->getHtmlErrors()); |
|
| 716 | - exit(); |
|
| 717 | - } |
|
| 718 | - if (Request::getInt('reset', 0, 'POST')) { // reset all vote/voter counters |
|
| 719 | - /** @var Xoopspoll\OptionHandler $xpOptHandler */ |
|
| 720 | - $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); |
|
| 721 | - /** @var Xoopspoll\LogHandler $xpLogHandler */ |
|
| 722 | - $xpLogHandler = Xoopspoll\Helper::getInstance()->getHandler('Log'); |
|
| 723 | - $xpLogHandler->deleteByPollId($poll_id); |
|
| 724 | - $xpOptHandler->resetCountByPollId($poll_id); |
|
| 725 | - $xpPollHandler->updateCount($pollObject); |
|
| 726 | - } |
|
| 727 | - // old xoopspoll or umfrage or any clone from them |
|
| 728 | - } else { |
|
| 729 | - if (!$pollObject->store()) { // update the poll |
|
| 730 | - xoops_error($pollObject->getHtmlErrors()); |
|
| 731 | - exit(); |
|
| 732 | - } |
|
| 733 | - if (Request::getInt('reset', 0, 'POST')) { // reset all logs |
|
| 734 | - $classOption = $classPoll . 'Option'; |
|
| 735 | - $classLog = $classPoll . 'Log'; |
|
| 736 | - $classLog::deleteByPollId($poll_id); |
|
| 737 | - $classOption::resetCountByPollId($poll_id); |
|
| 738 | - $pollObject->updateCount(); |
|
| 739 | - } |
|
| 740 | - } |
|
| 741 | - require_once $GLOBALS['xoops']->path('class/template.php'); |
|
| 742 | - xoops_template_clear_module_cache($xoopsModule->getVar('mid')); |
|
| 743 | - xoops_template_clear_module_cache($pollModuleHandler->getVar('mid')); |
|
| 744 | - redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id={$topic_id}", 1, _MD_NEWBB_POLL_DBUPDATED); |
|
| 745 | - break; |
|
| 746 | - |
|
| 747 | - case 'log': |
|
| 748 | - // new xoopspoll module |
|
| 749 | - if ($pollModuleHandler->getVar('version') >= 140) { |
|
| 750 | - redirect_header($GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/admin/main.php?op=log&poll_id={$poll_id}"), 2, _MD_NEWBB_POLL_VIEWLOG); |
|
| 751 | - // old xoopspoll or umfrage or any clone from them |
|
| 752 | - } else { |
|
| 753 | - redirect_header($GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/admin/index.php?op=log&poll_id={$poll_id}"), 2, _MD_NEWBB_POLL_VIEWLOG); |
|
| 754 | - } |
|
| 755 | - break; |
|
| 264 | + $option_empty = true; |
|
| 265 | + if (!Request::getString('option_text', '', 'POST')) { |
|
| 266 | + // irmtfan - issue with javascript:history.go(-1) |
|
| 267 | + redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !'); |
|
| 268 | + } |
|
| 269 | + $option_text = Request::getArray('option_text', '', 'POST'); |
|
| 270 | + foreach ($option_text as $optxt) { |
|
| 271 | + if ('' !== trim($optxt)) { |
|
| 272 | + $option_empty = false; |
|
| 273 | + break; |
|
| 274 | + } |
|
| 275 | + } |
|
| 276 | + if ($option_empty) { |
|
| 277 | + // irmtfan - issue with javascript:history.go(-1) |
|
| 278 | + redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !'); |
|
| 279 | + } |
|
| 280 | + $pollObject->setVar('question', Request::getString('question', '', 'POST')); |
|
| 281 | + $pollObject->setVar('description', Request::getString('description', '', 'POST')); |
|
| 282 | + $end_time = Request::getString('end_time', '', 'POST'); // (empty($_POST['end_time'])) ? "" : $_POST['end_time']; |
|
| 283 | + if ('' !== $end_time) { |
|
| 284 | + $timezone = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('timezone') : null; |
|
| 285 | + $pollObject->setVar('end_time', userTimeToServerTime(method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime($end_time) : strtotime($end_time), $timezone)); |
|
| 286 | + } else { |
|
| 287 | + // if expiration date is not set, set it to 10 days from now |
|
| 288 | + $pollObject->setVar('end_time', time() + (86400 * 10)); |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + $pollObject->setVar('display', 0); |
|
| 292 | + $pollObject->setVar('weight', Request::getInt('weight', 0, 'POST')); |
|
| 293 | + $pollObject->setVar('multiple', Request::getInt('multiple', 0, 'POST')); |
|
| 294 | + $pollObject->setVar('user_id', Request::getInt('user_id', 0, 'POST')); |
|
| 295 | + if (Request::getInt('notify', 0, 'POST') && $end_time > time()) { |
|
| 296 | + // if notify, set mail status to "not mailed" |
|
| 297 | + $pollObject->setVar('mail_status', Xoopspoll\Constants::POLL_NOT_MAILED); |
|
| 298 | + } else { |
|
| 299 | + // if not notify, set mail status to already "mailed" |
|
| 300 | + $pollObject->setVar('mail_status', Xoopspoll\Constants::POLL_MAILED); |
|
| 301 | + } |
|
| 302 | + $new_poll_id = $pollObject->store(); |
|
| 303 | + if (empty($new_poll_id)) { |
|
| 304 | + xoops_error($pollObject->getHtmlErrors); |
|
| 305 | + break; |
|
| 306 | + } |
|
| 307 | + $i = 0; |
|
| 308 | + $option_color = Request::getArray('option_color', null, 'POST'); |
|
| 309 | + $classOption = $classPoll . 'Option'; |
|
| 310 | + foreach ($option_text as $optxt) { |
|
| 311 | + $optxt = trim($optxt); |
|
| 312 | + /** @var Xoopspoll\Option $optionObject */ |
|
| 313 | + $optionObject = new $classOption(); |
|
| 314 | + if ('' !== $optxt) { |
|
| 315 | + $optionObject->setVar('option_text', $optxt); |
|
| 316 | + $optionObject->setVar('option_color', $option_color[$i]); |
|
| 317 | + $optionObject->setVar('poll_id', $new_poll_id); |
|
| 318 | + $optionObject->store(); |
|
| 319 | + } |
|
| 320 | + ++$i; |
|
| 321 | + } |
|
| 322 | + // clear the template cache so changes take effect immediately |
|
| 323 | + require_once $GLOBALS['xoops']->path('class/template.php'); |
|
| 324 | + xoops_template_clear_module_cache($GLOBALS['xoopsModule']->getVar('mid')); |
|
| 325 | + xoops_template_clear_module_cache($pollModuleHandler->getVar('mid')); |
|
| 326 | + |
|
| 327 | + // update topic to indicate it has a poll |
|
| 328 | + $topicObject->setVar('topic_haspoll', 1); |
|
| 329 | + $topicObject->setVar('poll_id', $new_poll_id); |
|
| 330 | + $success = $topicHandler->insert($topicObject); |
|
| 331 | + if (!$success) { |
|
| 332 | + xoops_error($topicHandler->getHtmlErrors()); |
|
| 333 | + } else { |
|
| 334 | + redirect_header("viewtopic.php?topic_id={$topic_id}", 2, _MD_NEWBB_POLL_DBUPDATED); |
|
| 335 | + } |
|
| 336 | + break;// op: save |
|
| 337 | + } |
|
| 338 | + // no break |
|
| 339 | + case 'update': |
|
| 340 | + // check security token |
|
| 341 | + if (!$GLOBALS['xoopsSecurity']->check()) { |
|
| 342 | + redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())); |
|
| 343 | + } |
|
| 344 | + /* make sure there's at least one option */ |
|
| 345 | + $option_text = Request::getString('option_text', '', 'POST'); |
|
| 346 | + $option_string = is_array($option_text) ? implode('', $option_text) : $option_text; |
|
| 347 | + $option_string = trim($option_string); |
|
| 348 | + if ('' === $option_string) { |
|
| 349 | + redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !'); |
|
| 350 | + } |
|
| 351 | + |
|
| 352 | + // new xoopspoll module |
|
| 353 | + if ($pollModuleHandler->getVar('version') >= 140) { |
|
| 354 | + /** @var Xoopspoll\OptionHandler $xpOptHandler */ |
|
| 355 | + $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); |
|
| 356 | + /** @var Xoopspoll\LogHandler $xpLogHandler */ |
|
| 357 | + $xpLogHandler = Xoopspoll\Helper::getInstance()->getHandler('Log'); |
|
| 358 | + // $classRequest = ucfirst($GLOBALS['xoopsModuleConfig']["poll_module"]) . "Request"; |
|
| 359 | + $classConstants = new XoopsModules\Xoopspoll\Constants(); |
|
| 360 | + $notify = Request::getInt('notify', $classConstants::NOTIFICATION_ENABLED, 'POST'); |
|
| 361 | + $currentTimestamp = time(); |
|
| 362 | + //$xuEndTimestamp = method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime(Request::getString('xu_end_time', null, 'POST')) |
|
| 363 | + // : strtotime(Request::getString('xu_end_time', null, 'POST')); |
|
| 364 | + $xuEndTimestamp = strtotime(Request::getString('xu_end_time', null, 'POST')); |
|
| 365 | + $endTimestamp = (!Request::getString('xu_end_time', null, 'POST')) ? ($currentTimestamp + $classConstants::DEFAULT_POLL_DURATION) : userTimeToServerTime($xuEndTimestamp); |
|
| 366 | + //$xuStartTimestamp = method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime(Request::getString('xu_start_time', null, 'POST')) |
|
| 367 | + // : strtotime(Request::getString('xu_start_time', null, 'POST')); |
|
| 368 | + $xuStartTimestamp = strtotime(Request::getString('xu_start_time', null, 'POST')); |
|
| 369 | + $startTimestamp = (!Request::getString('xu_start_time', null, 'POST')) ? ($endTimestamp - $classConstants::DEFAULT_POLL_DURATION) : userTimeToServerTime($xuStartTimestamp); |
|
| 370 | + |
|
| 371 | + // don't allow changing start time if there are votes in the log |
|
| 372 | + if (($startTimestamp < $pollObject->getVar('start_time')) |
|
| 373 | + && ($xpLogHandler->getTotalVotesByPollId($poll_id) > 0)) { |
|
| 374 | + $startTimestamp = $pollObject->getVar('start_time'); //don't change start time |
|
| 375 | + } |
|
| 376 | + |
|
| 377 | + $poll_vars = [ |
|
| 378 | + 'user_id' => Request::getInt('user_id', $GLOBALS['xoopsUser']->uid(), 'POST'), |
|
| 379 | + 'question' => Request::getString('question', null, 'POST'), |
|
| 380 | + 'description' => Request::getText('description', null, 'POST'), |
|
| 381 | + 'mail_status' => ($classConstants::NOTIFICATION_ENABLED == $notify) ? $classConstants::POLL_NOT_MAILED : $classConstants::POLL_MAILED, |
|
| 382 | + 'mail_voter' => Request::getInt('mail_voter', $classConstants::NOT_MAIL_POLL_TO_VOTER, 'POST'), |
|
| 383 | + 'start_time' => $startTimestamp, |
|
| 384 | + 'end_time' => $endTimestamp, |
|
| 385 | + 'display' => Request::getInt('display', $classConstants::DO_NOT_DISPLAY_POLL_IN_BLOCK, 'POST'), |
|
| 386 | + 'visibility' => Request::getInt('visibility', $classConstants::HIDE_NEVER, 'POST'), |
|
| 387 | + 'weight' => Request::getInt('weight', $classConstants::DEFAULT_WEIGHT, 'POST'), |
|
| 388 | + 'multiple' => Request::getInt('multiple', $classConstants::NOT_MULTIPLE_SELECT_POLL, 'POST'), |
|
| 389 | + 'multilimit' => Request::getInt('multilimit', $classConstants::MULTIPLE_SELECT_LIMITLESS, 'POST'), |
|
| 390 | + 'anonymous' => Request::getInt('anonymous', $classConstants::ANONYMOUS_VOTING_DISALLOWED, 'POST') |
|
| 391 | + ]; |
|
| 392 | + $pollObject->setVars($poll_vars); |
|
| 393 | + $poll_id = $xpPollHandler->insert($pollObject); |
|
| 394 | + if (!$poll_id) { |
|
| 395 | + $err = $pollObject->getHtmlErrors(); |
|
| 396 | + exit($err); |
|
| 397 | + } |
|
| 398 | + |
|
| 399 | + // now get the options |
|
| 400 | + $optionIdArray = Request::getArray('option_id', [], 'POST'); |
|
| 401 | + $optionIdArray = array_map('intval', $optionIdArray); |
|
| 402 | + $optionTextArray = Request::getArray('option_text', [], 'POST'); |
|
| 403 | + $optionColorArray = Request::getArray('option_color', [], 'POST'); |
|
| 404 | + |
|
| 405 | + foreach ($optionIdArray as $key => $oId) { |
|
| 406 | + if (!empty($oId) && ($optionObject = $xpOptHandler->get($oId))) { |
|
| 407 | + // existing option object so need to update it |
|
| 408 | + $optionTextArray[$key] = trim($optionTextArray[$key]); |
|
| 409 | + if ('' === $optionTextArray[$key]) { |
|
| 410 | + // want to delete this option |
|
| 411 | + if (false !== $xpOptHandler->delete($optionObject)) { |
|
| 412 | + // now remove it from the log |
|
| 413 | + $xpLogHandler->deleteByOptionId($optionObject->getVar('option_id')); |
|
| 414 | + //update vote count in poll |
|
| 415 | + $xpPollHandler->updateCount($pollObject); |
|
| 416 | + } else { |
|
| 417 | + xoops_error($xpLogHandler->getHtmlErrors()); |
|
| 418 | + break; |
|
| 419 | + } |
|
| 420 | + } else { |
|
| 421 | + $optionObject->setVar('option_text', $optionTextArray[$key]); |
|
| 422 | + $optionObject->setVar('option_color', $optionColorArray[$key]); |
|
| 423 | + $optionObject->setVar('poll_id', $poll_id); |
|
| 424 | + $xpOptHandler->insert($optionObject); |
|
| 425 | + } |
|
| 426 | + } else { |
|
| 427 | + // new option object |
|
| 428 | + $optionObject = $xpOptHandler->create(); |
|
| 429 | + $optionTextArray[$key] = trim($optionTextArray[$key]); |
|
| 430 | + if ('' !== $optionTextArray[$key]) { // ignore if text is empty |
|
| 431 | + $optionObject->setVar('option_text', $optionTextArray[$key]); |
|
| 432 | + $optionObject->setVar('option_color', $optionColorArray[$key]); |
|
| 433 | + $optionObject->setVar('poll_id', $poll_id); |
|
| 434 | + $xpOptHandler->insert($optionObject); |
|
| 435 | + } |
|
| 436 | + unset($optionObject); |
|
| 437 | + } |
|
| 438 | + } |
|
| 439 | + // old xoopspoll or umfrage or any clone from them |
|
| 440 | + } else { |
|
| 441 | + $pollObject->setVar('question', Request::getString('question', '', 'POST')); |
|
| 442 | + $pollObject->setVar('description', Request::getString('description', '', 'POST')); |
|
| 443 | + |
|
| 444 | + $end_time = Request::getString('end_time', '', 'POST'); |
|
| 445 | + if ('' !== $end_time) { |
|
| 446 | + $timezone = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('timezone') : null; |
|
| 447 | + $pollObject->setVar('end_time', userTimeToServerTime(method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime($end_time) : strtotime($end_time), $timezone)); |
|
| 448 | + } |
|
| 449 | + $pollObject->setVar('display', 0); |
|
| 450 | + $pollObject->setVar('weight', Request::getInt('weight', 0, 'POST')); |
|
| 451 | + $pollObject->setVar('multiple', Request::getInt('multiple', 0, 'POST')); |
|
| 452 | + $pollObject->setVar('user_id', Request::getInt('user_id', 0, 'POST')); |
|
| 453 | + if (Request::getInt('notify', 0, 'POST') && $end_time > time()) { |
|
| 454 | + // if notify, set mail status to "not mailed" |
|
| 455 | + $pollObject->setVar('mail_status', $classConstants::POLL_NOT_MAILED); |
|
| 456 | + } else { |
|
| 457 | + // if not notify, set mail status to already "mailed" |
|
| 458 | + $pollObject->setVar('mail_status', $classConstants::POLL_MAILED); |
|
| 459 | + } |
|
| 460 | + |
|
| 461 | + if (!$pollObject->store()) { |
|
| 462 | + xoops_error($pollObject->getHtmlErrors); |
|
| 463 | + break; |
|
| 464 | + } |
|
| 465 | + $i = 0; |
|
| 466 | + $option_id = Request::getArray('option_id', null, 'POST'); |
|
| 467 | + $option_color = Request::getArray('option_color', null, 'POST'); |
|
| 468 | + $classOption = $classPoll . 'Option'; |
|
| 469 | + $classLog = $classPoll . 'Log'; |
|
| 470 | + foreach ($option_id as $opid) { |
|
| 471 | + $optionObject = new $classOption($opid); |
|
| 472 | + $option_text[$i] = trim($option_text[$i]); |
|
| 473 | + if ('' !== $option_text[$i]) { |
|
| 474 | + $optionObject->setVar('option_text', $option_text[$i]); |
|
| 475 | + $optionObject->setVar('option_color', $option_color[$i]); |
|
| 476 | + $optionObject->store(); |
|
| 477 | + } else { |
|
| 478 | + if (false !== $optionObject->delete()) { |
|
| 479 | + $classLog::deleteByOptionId($option->getVar('option_id')); |
|
| 480 | + } |
|
| 481 | + } |
|
| 482 | + ++$i; |
|
| 483 | + } |
|
| 484 | + $pollObject->updateCount(); |
|
| 485 | + } |
|
| 486 | + // clear the template cache so changes take effect immediately |
|
| 487 | + require_once $GLOBALS['xoops']->path('class/template.php'); |
|
| 488 | + xoops_template_clear_module_cache($GLOBALS['xoopsModule']->getVar('mid')); |
|
| 489 | + xoops_template_clear_module_cache($pollModuleHandler->getVar('mid')); |
|
| 490 | + |
|
| 491 | + // update topic to indicate it has a poll |
|
| 492 | + $topicObject->setVar('topic_haspoll', 1); |
|
| 493 | + $topicObject->setVar('poll_id', $pollObject->getVar('poll_id')); |
|
| 494 | + $success = $topicHandler->insert($topicObject); |
|
| 495 | + if (!$success) { |
|
| 496 | + xoops_error($topicHandler->getHtmlErrors()); |
|
| 497 | + } else { |
|
| 498 | + redirect_header("viewtopic.php?topic_id={$topic_id}", 2, _MD_NEWBB_POLL_DBUPDATED); |
|
| 499 | + } |
|
| 500 | + break;// op: save | update |
|
| 501 | + |
|
| 502 | + case 'addmore': |
|
| 503 | + $question = $pollObject->getVar('question'); |
|
| 504 | + unset($pollObject); |
|
| 505 | + $poll_form = new \XoopsThemeForm(_MD_NEWBB_POLL_ADDMORE, 'poll_form', 'polls.php', 'post', true); |
|
| 506 | + $poll_form->addElement(new \XoopsFormLabel(_MD_NEWBB_POLL_POLLQUESTION, $question)); |
|
| 507 | + // new xoopspoll module |
|
| 508 | + if ($pollModuleHandler->getVar('version') >= 140) { |
|
| 509 | + $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); |
|
| 510 | + $option_tray = $xpOptHandler->renderOptionFormTray($poll_id); |
|
| 511 | + // old xoopspoll or umfrage or any clone from them |
|
| 512 | + } else { |
|
| 513 | + $option_tray = new \XoopsFormElementTray(_MD_NEWBB_POLL_POLLOPTIONS, ''); |
|
| 514 | + $barcolor_array = \XoopsLists::getImgListAsArray($GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/assets/images/colorbars/')); |
|
| 515 | + for ($i = 0; $i < 10; ++$i) { |
|
| 516 | + $current_bar = ('blank.gif' !== current($barcolor_array)) ? current($barcolor_array) : next($barcolor_array); |
|
| 517 | + $option_text = new \XoopsFormText('', 'option_text[]', 50, 255); |
|
| 518 | + $option_tray->addElement($option_text); |
|
| 519 | + $color_select = new \XoopsFormSelect('', "option_color[{$i}]", $current_bar); |
|
| 520 | + $color_select->addOptionArray($barcolor_array); |
|
| 521 | + $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[{$i}]\", \"modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars\", \"\", \"" . XOOPS_URL . "\")'"); |
|
| 522 | + $color_label = new \XoopsFormLabel('', "<img src='" |
|
| 523 | + . $GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/{$current_bar}") |
|
| 524 | + . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt='' /><br>"); |
|
| 525 | + $option_tray->addElement($color_select); |
|
| 526 | + $option_tray->addElement($color_label); |
|
| 527 | + unset($color_select, $color_label, $option_text); |
|
| 528 | + if (!next($barcolor_array)) { |
|
| 529 | + reset($barcolor_array); |
|
| 530 | + } |
|
| 531 | + } |
|
| 532 | + } |
|
| 533 | + $poll_form->addElement($option_tray); |
|
| 534 | + $poll_form->addElement(new \XoopsFormButtonTray('poll_submit', _SUBMIT, 'submit')); |
|
| 535 | + $poll_form->addElement(new \XoopsFormHidden('op', 'savemore')); |
|
| 536 | + $poll_form->addElement(new \XoopsFormHidden('topic_id', $topic_id)); |
|
| 537 | + $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id)); |
|
| 538 | + |
|
| 539 | + echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n"; |
|
| 540 | + $poll_form->display(); |
|
| 541 | + break; |
|
| 542 | + |
|
| 543 | + case 'savemore': |
|
| 544 | + // check security token |
|
| 545 | + if (!$GLOBALS['xoopsSecurity']->check()) { |
|
| 546 | + redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())); |
|
| 547 | + } |
|
| 548 | + |
|
| 549 | + $option_text = Request::getString('option_text', '', 'POST'); |
|
| 550 | + $option_string = is_array($option_text) ? implode('', $option_text) : $option_text; |
|
| 551 | + $option_string = trim($option_string); |
|
| 552 | + if ('' === $option_string) { |
|
| 553 | + // irmtfan - issue with javascript:history.go(-1) |
|
| 554 | + redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !'); |
|
| 555 | + } |
|
| 556 | + $i = 0; |
|
| 557 | + $option_color = Request::getArray('option_color', null, 'POST'); |
|
| 558 | + foreach ($option_text as $optxt) { |
|
| 559 | + $optxt = trim($optxt); |
|
| 560 | + if ('' !== $optxt) { |
|
| 561 | + // new xoopspoll module |
|
| 562 | + if ($pollModuleHandler->getVar('version') >= 140) { |
|
| 563 | + $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); |
|
| 564 | + $optionObject = $xpOptHandler->create(); |
|
| 565 | + $optionObject->setVar('option_text', $optxt); |
|
| 566 | + $optionObject->setVar('poll_id', $poll_id); |
|
| 567 | + $optionObject->setVar('option_color', $option_color[$i]); |
|
| 568 | + $xpOptHandler->insert($optionObject); |
|
| 569 | + // old xoopspoll or umfrage or any clone from them |
|
| 570 | + } else { |
|
| 571 | + $classOption = $classPoll . 'Option'; |
|
| 572 | + $optionObject = new $classOption(); |
|
| 573 | + $optionObject->setVar('option_text', $optxt); |
|
| 574 | + $optionObject->setVar('poll_id', $poll_id); |
|
| 575 | + $optionObject->setVar('option_color', $option_color[$i]); |
|
| 576 | + $optionObject->store(); |
|
| 577 | + } |
|
| 578 | + unset($optionObject); |
|
| 579 | + } |
|
| 580 | + ++$i; |
|
| 581 | + } |
|
| 582 | + require_once $GLOBALS['xoops']->path('class/template.php'); |
|
| 583 | + xoops_template_clear_module_cache($GLOBALS['xoopsModule']->getVar('mid')); |
|
| 584 | + xoops_template_clear_module_cache($pollModuleHandler->getVar('mid')); |
|
| 585 | + redirect_header("polls.php?op=edit&poll_id={$poll_id}&topic_id={$topic_id}", 2, _MD_NEWBB_POLL_DBUPDATED); |
|
| 586 | + break; |
|
| 587 | + |
|
| 588 | + case 'delete': |
|
| 589 | + echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n"; |
|
| 590 | + xoops_confirm(['op' => 'delete_ok', 'topic_id' => $topic_id, 'poll_id' => $poll_id], 'polls.php', sprintf(_MD_NEWBB_POLL_RUSUREDEL, $pollObject->getVar('question'))); |
|
| 591 | + break; |
|
| 592 | + |
|
| 593 | + case 'delete_ok': |
|
| 594 | + // check security token |
|
| 595 | + if (!$GLOBALS['xoopsSecurity']->check()) { |
|
| 596 | + redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())); |
|
| 597 | + } |
|
| 598 | + //try and delete the poll |
|
| 599 | + // new xoopspoll module |
|
| 600 | + if ($pollModuleHandler->getVar('version') >= 140) { |
|
| 601 | + $status = $xpPollHandler->delete($pollObject); |
|
| 602 | + if (false !== $status) { |
|
| 603 | + $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); |
|
| 604 | + $xpLogHandler = Xoopspoll\Helper::getInstance()->getHandler('Log'); |
|
| 605 | + $xpOptHandler->deleteByPollId($poll_id); |
|
| 606 | + $xpLogHandler->deleteByPollId($poll_id); |
|
| 607 | + } else { |
|
| 608 | + $msg = $xpPollHandler->getHtmlErrors(); |
|
| 609 | + } |
|
| 610 | + // old xoopspoll or umfrage or any clone from them |
|
| 611 | + } else { |
|
| 612 | + $status = $pollObject->delete(); |
|
| 613 | + $classOption = $classPoll . 'Option'; |
|
| 614 | + $classLog = $classPoll . 'Log'; |
|
| 615 | + if (false !== $status) { |
|
| 616 | + $classOption::deleteByPollId($poll_id); |
|
| 617 | + $classLog::deleteByPollId($poll_id); |
|
| 618 | + } else { |
|
| 619 | + $msg = $pollObject->getHtmlErrors(); |
|
| 620 | + } |
|
| 621 | + } |
|
| 622 | + if (false !== $status) { |
|
| 623 | + require_once $GLOBALS['xoops']->path('class/template.php'); |
|
| 624 | + xoops_template_clear_module_cache($xoopsModule->getVar('mid')); |
|
| 625 | + xoops_template_clear_module_cache($pollModuleHandler->getVar('mid')); |
|
| 626 | + // delete comments for this poll |
|
| 627 | + xoops_comment_delete($xoopsModule->getVar('mid'), $poll_id); |
|
| 628 | + |
|
| 629 | + $topicObject->setVar('votes', 0); // not sure why we want to clear votes too... but I left it alone |
|
| 630 | + $topicObject->setVar('topic_haspoll', 0); |
|
| 631 | + $topicObject->setVar('poll_id', 0); |
|
| 632 | + $success = $topicHandler->insert($topicObject); |
|
| 633 | + if (!$success) { |
|
| 634 | + xoops_error($topicHandler->getHtmlErrors()); |
|
| 635 | + break; |
|
| 636 | + } |
|
| 637 | + } else { |
|
| 638 | + xoops_error($msg); |
|
| 639 | + break; |
|
| 640 | + } |
|
| 641 | + redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id={$topic_id}", 1, _MD_NEWBB_POLL_DBUPDATED); |
|
| 642 | + break; |
|
| 643 | + |
|
| 644 | + case 'restart': |
|
| 645 | + // new xoopspoll module |
|
| 646 | + if ($pollModuleHandler->getVar('version') >= 140) { |
|
| 647 | + $classConstants = new XoopsModules\Xoopspoll\Constants(); |
|
| 648 | + $default_poll_duration = $classConstants::DEFAULT_POLL_DURATION; |
|
| 649 | + // old xoopspoll or umfrage or any clone from them |
|
| 650 | + } else { |
|
| 651 | + $default_poll_duration = (86400 * 10); |
|
| 652 | + } |
|
| 653 | + $poll_form = new \XoopsThemeForm(_MD_NEWBB_POLL_RESTARTPOLL, 'poll_form', 'polls.php', 'post', true); |
|
| 654 | + $expire_text = new \XoopsFormText( |
|
| 655 | + _MD_NEWBB_POLL_EXPIRATION . '<br><small>' . _MD_NEWBB_POLL_FORMAT . '<br>' . sprintf(_MD_NEWBB_POLL_CURRENTTIME, formatTimestamp(time(), 'Y-m-d H:i:s')) . '<br>' . sprintf( |
|
| 656 | + _MD_NEWBB_POLL_EXPIREDAT, |
|
| 657 | + formatTimestamp($pollObject->getVar('end_time'), 'Y-m-d H:i:s') |
|
| 658 | + ) . '</small>', |
|
| 659 | + 'end_time', |
|
| 660 | + 20, |
|
| 661 | + 19, |
|
| 662 | + formatTimestamp(time() + $default_poll_duration, 'Y-m-d H:i:s') |
|
| 663 | + ); |
|
| 664 | + $poll_form->addElement($expire_text); |
|
| 665 | + $poll_form->addElement(new \XoopsFormRadioYN(_MD_NEWBB_POLL_NOTIFY, 'notify', 1)); |
|
| 666 | + $poll_form->addElement(new \XoopsFormRadioYN(_MD_NEWBB_POLL_RESET, 'reset', 0)); |
|
| 667 | + $poll_form->addElement(new \XoopsFormHidden('op', 'restart_ok')); |
|
| 668 | + $poll_form->addElement(new \XoopsFormHidden('topic_id', $topic_id)); |
|
| 669 | + $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id)); |
|
| 670 | + $poll_form->addElement(new \XoopsFormButton('', 'poll_submit', _MD_NEWBB_POLL_RESTART, 'submit')); |
|
| 671 | + |
|
| 672 | + echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n"; |
|
| 673 | + $poll_form->display(); |
|
| 674 | + break; |
|
| 675 | + |
|
| 676 | + case 'restart_ok': |
|
| 677 | + // check security token |
|
| 678 | + if (!$GLOBALS['xoopsSecurity']->check()) { |
|
| 679 | + redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())); |
|
| 680 | + } |
|
| 681 | + |
|
| 682 | + // new xoopspoll module |
|
| 683 | + if ($pollModuleHandler->getVar('version') >= 140) { |
|
| 684 | + $classConstants = new XoopsModules\Xoopspoll\Constants(); |
|
| 685 | + $default_poll_duration = $classConstants::DEFAULT_POLL_DURATION; |
|
| 686 | + $poll_not_mailed = $classConstants::POLL_NOT_MAILED; |
|
| 687 | + $poll_mailed = $classConstants::POLL_MAILED; |
|
| 688 | + // old xoopspoll or umfrage or any clone from them |
|
| 689 | + } else { |
|
| 690 | + $default_poll_duration = (86400 * 10); |
|
| 691 | + $poll_not_mailed = Xoopspoll\Constants::POLL_NOT_MAILED; |
|
| 692 | + $poll_mailed = Xoopspoll\Constants::POLL_MAILED; |
|
| 693 | + } |
|
| 694 | + |
|
| 695 | + $end_time = !Request::getInt('end_time', 0, 'POST'); |
|
| 696 | + if (0 !== $end_time) { |
|
| 697 | + $timezone = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('timezone') : null; |
|
| 698 | + $pollObject->setVar('end_time', userTimeToServerTime(method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime($end_time) : strtotime($end_time), $timezone)); |
|
| 699 | + } else { |
|
| 700 | + $pollObject->setVar('end_time', time() + $default_poll_duration); |
|
| 701 | + } |
|
| 702 | + |
|
| 703 | + $isNotify = Request::getInt('notify', 0, 'POST'); |
|
| 704 | + if (!empty($isNotify) && ($end_time > time())) { |
|
| 705 | + // if notify, set mail status to "not mailed" |
|
| 706 | + $pollObject->setVar('mail_status', $poll_not_mailed); |
|
| 707 | + } else { |
|
| 708 | + // if not notify, set mail status to already "mailed" |
|
| 709 | + $pollObject->setVar('mail_status', $poll_mailed); |
|
| 710 | + } |
|
| 711 | + |
|
| 712 | + // new xoopspoll module |
|
| 713 | + if ($pollModuleHandler->getVar('version') >= 140) { |
|
| 714 | + if (!$xpPollHandler->insert($pollObject)) { // update the poll |
|
| 715 | + xoops_error($pollObject->getHtmlErrors()); |
|
| 716 | + exit(); |
|
| 717 | + } |
|
| 718 | + if (Request::getInt('reset', 0, 'POST')) { // reset all vote/voter counters |
|
| 719 | + /** @var Xoopspoll\OptionHandler $xpOptHandler */ |
|
| 720 | + $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); |
|
| 721 | + /** @var Xoopspoll\LogHandler $xpLogHandler */ |
|
| 722 | + $xpLogHandler = Xoopspoll\Helper::getInstance()->getHandler('Log'); |
|
| 723 | + $xpLogHandler->deleteByPollId($poll_id); |
|
| 724 | + $xpOptHandler->resetCountByPollId($poll_id); |
|
| 725 | + $xpPollHandler->updateCount($pollObject); |
|
| 726 | + } |
|
| 727 | + // old xoopspoll or umfrage or any clone from them |
|
| 728 | + } else { |
|
| 729 | + if (!$pollObject->store()) { // update the poll |
|
| 730 | + xoops_error($pollObject->getHtmlErrors()); |
|
| 731 | + exit(); |
|
| 732 | + } |
|
| 733 | + if (Request::getInt('reset', 0, 'POST')) { // reset all logs |
|
| 734 | + $classOption = $classPoll . 'Option'; |
|
| 735 | + $classLog = $classPoll . 'Log'; |
|
| 736 | + $classLog::deleteByPollId($poll_id); |
|
| 737 | + $classOption::resetCountByPollId($poll_id); |
|
| 738 | + $pollObject->updateCount(); |
|
| 739 | + } |
|
| 740 | + } |
|
| 741 | + require_once $GLOBALS['xoops']->path('class/template.php'); |
|
| 742 | + xoops_template_clear_module_cache($xoopsModule->getVar('mid')); |
|
| 743 | + xoops_template_clear_module_cache($pollModuleHandler->getVar('mid')); |
|
| 744 | + redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id={$topic_id}", 1, _MD_NEWBB_POLL_DBUPDATED); |
|
| 745 | + break; |
|
| 746 | + |
|
| 747 | + case 'log': |
|
| 748 | + // new xoopspoll module |
|
| 749 | + if ($pollModuleHandler->getVar('version') >= 140) { |
|
| 750 | + redirect_header($GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/admin/main.php?op=log&poll_id={$poll_id}"), 2, _MD_NEWBB_POLL_VIEWLOG); |
|
| 751 | + // old xoopspoll or umfrage or any clone from them |
|
| 752 | + } else { |
|
| 753 | + redirect_header($GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/admin/index.php?op=log&poll_id={$poll_id}"), 2, _MD_NEWBB_POLL_VIEWLOG); |
|
| 754 | + } |
|
| 755 | + break; |
|
| 756 | 756 | } // switch |
| 757 | 757 | |
| 758 | 758 | // irmtfan move to footer.php |