Passed
Branch master (565d4a)
by Michael
15:11 queued 01:11
created
class/IconHandler.php 2 patches
Indentation   +180 added lines, -180 removed lines patch added patch discarded remove patch
@@ -36,184 +36,184 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -94,23 +94,23 @@  discard block
 block discarded – undo
94 94
     public function getPath($type, $dirname = 'newbb', $default = '', $endDir = 'images')
95 95
     {
96 96
         static $paths;
97
-        if (isset($paths[$endDir . '/' . $type])) {
98
-            return $paths[$endDir . '/' . $type];
97
+        if (isset($paths[$endDir.'/'.$type])) {
98
+            return $paths[$endDir.'/'.$type];
99 99
         }
100 100
 
101 101
         $theme_path = $this->template->currentTheme->path;
102 102
         $rel_dir    = "modules/{$dirname}/{$endDir}";
103 103
         // START irmtfan add default for all pathes
104 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}"
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 107
                 : $GLOBALS['xoops']->path("modules/{$dirname}/templates/{$endDir}/{$type}"));
108 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
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 112
                  . "/default/{$rel_dir}/{$type}" : (
113
-                     is_dir(XOOPS_THEME_PATH . "/default/{$rel_dir}/{$default}/") ? XOOPS_THEME_PATH . "/default/{$rel_dir}/{$default}"
113
+                     is_dir(XOOPS_THEME_PATH."/default/{$rel_dir}/{$default}/") ? XOOPS_THEME_PATH . "/default/{$rel_dir}/{$default}"
114 114
                     : (is_dir($GLOBALS['xoops']->path("modules/{$dirname}/templates/{$endDir}/{$type}/")) ? $GLOBALS['xoops']->path("modules/{$dirname}/templates/{$endDir}/{$type}")
115 115
                     : $GLOBALS['xoops']->path("modules/{$dirname}/templates/{$endDir}/{$default}")) // XOOPS_ROOT_PATH
116 116
             ) // XOOPS_THEME_PATH {$default}
@@ -118,9 +118,9 @@  discard block
 block discarded – undo
118 118
             ); // $theme_path {$default}
119 119
         }
120 120
         // END irmtfan add default for all pathes
121
-        $paths[$endDir . '/' . $type] = str_replace(XOOPS_ROOT_PATH, '', str_replace('\\', '/', $path));
121
+        $paths[$endDir.'/'.$type] = str_replace(XOOPS_ROOT_PATH, '', str_replace('\\', '/', $path));
122 122
 
123
-        return $paths[$endDir . '/' . $type];
123
+        return $paths[$endDir.'/'.$type];
124 124
     }
125 125
 
126 126
     // END irmtfan - improve to get other "end dirnames" like "css" and "js" - change images with $endDir
@@ -135,8 +135,8 @@  discard block
 block discarded – undo
135 135
     ) {
136 136
         $this->forumImage = require_once $GLOBALS['xoops']->path("modules/{$dirname}/include/images.php");
137 137
 
138
-        $this->forumImage['icon']     = XOOPS_URL . $this->getPath('icon', $dirname) . '/';
139
-        $this->forumImage['language'] = XOOPS_URL . $this->getPath("language/{$language}", $dirname, 'language/english') . '/';
138
+        $this->forumImage['icon']     = XOOPS_URL.$this->getPath('icon', $dirname).'/';
139
+        $this->forumImage['language'] = XOOPS_URL.$this->getPath("language/{$language}", $dirname, 'language/english').'/';
140 140
     }
141 141
 
142 142
     /**
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
      */
161 161
     public function getImageSource($image)
162 162
     {
163
-        return $this->forumImage[$this->forumImage[$image]] . $this->prefix . $image . $this->postfix;
163
+        return $this->forumImage[$this->forumImage[$image]].$this->prefix.$image.$this->postfix;
164 164
     }
165 165
 
166 166
     /**
Please login to merge, or discard this patch.
class/Report.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -19,19 +19,19 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
votepolls.php 2 patches
Indentation   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -37,119 +37,119 @@
 block discarded – undo
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);
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 use Xmf\Request;
29 29
 use XoopsModules\Xoopspoll;
30 30
 
31
-require_once __DIR__ . '/header.php';
31
+require_once __DIR__.'/header.php';
32 32
 $poll_id  = Request::getInt('poll_id', Request::getInt('poll_id', 0, 'POST'), 'GET');
33 33
 $topic_id = Request::getInt('topic_id', Request::getInt('topic_id', 0, 'POST'), 'GET');
34 34
 $forum    = Request::getInt('forum', Request::getInt('forum', 0, 'POST'), 'GET');
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 
43 43
 if (!Request::getInt('option_id', 0, 'POST')) {
44 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);
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']);
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         $pollObject = $xpPollHandler->get($poll_id); // will create poll if poll_id = 0 exist
61 61
         // old xoopspoll or umfrage or any clone from them
62 62
     } else {
63
-        require_once $GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/include/constants.php');
63
+        require_once $GLOBALS['xoops']->path('modules/'.$GLOBALS['xoopsModuleConfig']['poll_module'].'/include/constants.php');
64 64
         $classPoll  = $topicObject->loadOldPoll();
65 65
         $pollObject = new $classPoll($poll_id); // will create poll if poll_id = 0 exist
66 66
     }
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
             $optionId = Request::getInt('option_id', 0, 'POST');
82 82
         }
83 83
         if (!$pollObject->hasExpired()) {
84
-            $msg = constant('_MD_' . strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']) . '_MUSTLOGIN');
84
+            $msg = constant('_MD_'.strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']).'_MUSTLOGIN');
85 85
             //@todo:: add $url to all redirects
86 86
             //            $url = $GLOBALS['xoops']->buildUrl("index.php", array('poll_id' => $poll_id));
87 87
             if ($pollObject->isAllowedToVote()) {
@@ -95,13 +95,13 @@  discard block
 block discarded – undo
95 95
                             echo $pollObject->getHtmlErrors();
96 96
                             exit();
97 97
                         }
98
-                        $msg = constant('_MD_' . strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']) . '_THANKSFORVOTE');
98
+                        $msg = constant('_MD_'.strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']).'_THANKSFORVOTE');
99 99
                     } else {
100 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'));
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 102
                     }
103 103
                 } else {
104
-                    $msg = constant('_MD_' . strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']) . '_ALREADYVOTED');
104
+                    $msg = constant('_MD_'.strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']).'_ALREADYVOTED');
105 105
                 }
106 106
                 /* set anon user vote (and the time they voted) */
107 107
                 if (!is_object($GLOBALS['xoopsUser'])) {
@@ -111,14 +111,14 @@  discard block
 block discarded – undo
111 111
                     $classPollUtility::setVoteCookie($poll_id, $voteTime, 0);
112 112
                 }
113 113
             } else {
114
-                $msg = constant('_MD_' . strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']) . '_CANNOTVOTE');
114
+                $msg = constant('_MD_'.strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']).'_CANNOTVOTE');
115 115
             }
116 116
         } else {
117 117
             /* poll has expired so just show the results */
118
-            $msg = constant('_MD_' . strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']) . 'SORRYEXPIRED');
118
+            $msg = constant('_MD_'.strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']).'SORRYEXPIRED');
119 119
         }
120 120
     } else {
121
-        $msg = constant('_MD_' . strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']) . '_ERROR_INVALID_POLLID');
121
+        $msg = constant('_MD_'.strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']).'_ERROR_INVALID_POLLID');
122 122
     }
123 123
     if (null !== $url) {
124 124
         redirect_header($url, $classConstants::REDIRECT_DELAY_MEDIUM, $msg);
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
     }
128 128
     // old xoopspoll or umfrage or any clone from them
129 129
 } else {
130
-    $classLog = $classPoll . 'Log';
130
+    $classLog = $classPoll.'Log';
131 131
     if (is_object($GLOBALS['xoopsUser'])) {
132 132
         if ($classLog::hasVoted($poll_id, Request::getString('REMOTE_ADDR', '', 'SERVER'), $GLOBALS['xoopsUser']->getVar('uid'))) {
133 133
             $msg = _PL_ALREADYVOTED;
Please login to merge, or discard this patch.
viewforum.php 2 patches
Indentation   +125 added lines, -125 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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('&amp;', 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
 block discarded – undo
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
 block discarded – undo
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&amp;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&amp;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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
205 205
 $xoopsTpl->assign('h_poster_link', XOOPS_URL . "/modules/newbb/viewforum.php?{$page_query_sort}&amp;sort=t.topic_poster&amp;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}&amp;sort=t.topic_views&amp;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}&amp;sort=t.rating&amp;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}&amp;sort=t.topic_last_post_id&amp;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}&amp;sort=t.topic_id&amp;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
 block discarded – undo
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
 block discarded – undo
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}&amp;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}&amp;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
 block discarded – undo
276 276
 $xoopsTpl->assign('unreplied_link', XOOPS_URL . "/modules/newbb/viewforum.php?{$page_query_status}&amp;status=unreplied");
277 277
 $xoopsTpl->assign('unread_link', XOOPS_URL . "/modules/newbb/viewforum.php?{$page_query_status}&amp;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('&amp;', 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('&amp;', 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';
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -11,12 +11,12 @@  discard block
 block discarded – undo
11 11
 
12 12
 use Xmf\Request;
13 13
 
14
-require_once __DIR__ . '/header.php';
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
-require_once __DIR__ . '/include/functions.read.php';
19
+require_once __DIR__.'/include/functions.read.php';
20 20
 
21 21
 /*
22 22
  * Build the page query
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 $query_array = [];
26 26
 foreach ($query_vars as $var) {
27 27
     if (Request::getString($var, '', 'GET')) {
28
-        $query_array[$var] = "{$var}=" . Request::getString($var, '', 'GET');
28
+        $query_array[$var] = "{$var}=".Request::getString($var, '', 'GET');
29 29
     }
30 30
 }
31 31
 $page_query = implode('&amp;', array_values($query_array));
@@ -39,8 +39,8 @@  discard block
 block discarded – undo
39 39
         $markresult = _MD_NEWBB_MARK_UNREAD;
40 40
     }
41 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);
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');
@@ -67,25 +67,25 @@  discard block
 block discarded – undo
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
 
78
-$xoops_pagetitle = $forumObject->getVar('forum_name') . ' [' . $xoopsModule->getVar('name') . ']';
78
+$xoops_pagetitle = $forumObject->getVar('forum_name').' ['.$xoopsModule->getVar('name').']';
79 79
 
80 80
 $xoopsOption['template_main']   = 'newbb_viewforum.tpl';
81 81
 $xoopsOption['xoops_pagetitle'] = $xoops_pagetitle;
82 82
 
83 83
 require_once $GLOBALS['xoops']->path('header.php');
84
-require_once __DIR__ . '/include/functions.render.php';
84
+require_once __DIR__.'/include/functions.render.php';
85 85
 
86 86
 if (!empty($GLOBALS['xoopsModuleConfig']['rss_enable'])) {
87 87
     $xoopsTpl->assign('xoops_module_header', '
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 . '" />
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
 }
91 91
 $forumDescription = $forumObject->getVar('forum_desc');
@@ -119,16 +119,16 @@  discard block
 block discarded – undo
119 119
 
120 120
 if ($forumHandler->getPermission($forumObject, 'post')) {
121 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>');
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 123
     if ($pollmodules && $forumHandler->getPermission($forumObject, 'addpoll')) {
124 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&amp;forum={$forum_id}\">{$t_poll}</a>");
125
+        $xoopsTpl->assign('forum_addpoll', '<a href="'.XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname')."/polls.php?op=add&amp;forum={$forum_id}\">{$t_poll}</a>");
126 126
     }
127 127
 } else {
128 128
     $xoopsTpl->assign('viewer_level', 0);
129 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>');
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 132
         $xoopsTpl->assign('forum_addpoll', '');
133 133
     } else {
134 134
         $xoopsTpl->assign('forum_post_or_register', '');
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 $xoopsTpl->assign_by_ref('parentforum', $parentforum);
140 140
 
141 141
 $criteria = new \CriteriaCompo(new \Criteria('parent_forum', $forum_id));
142
-$criteria->add(new \Criteria('forum_id', '(' . implode(', ', $forumHandler->getIdsByPermission('access')) . ')', 'IN'));
142
+$criteria->add(new \Criteria('forum_id', '('.implode(', ', $forumHandler->getIdsByPermission('access')).')', 'IN'));
143 143
 $criteria->setSort('forum_order');
144 144
 
145 145
 if ($forums = $forumHandler->getAll($criteria, null, false)) {
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
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
 
@@ -184,14 +184,14 @@  discard block
 block discarded – undo
184 184
 $order                 = (!Request::getString('order', '', 'GET')
185 185
                           || 'ASC' !== Request::getString('order', '', 'GET')) ? 'DESC' : 'ASC';
186 186
 $forum_selection_order = '<select name="order">';
187
-$forum_selection_order .= '<option value="ASC"' . (('ASC' === $order) ? ' selected' : '') . '>' . _MD_NEWBB_ASCENDING . '</option>';
188
-$forum_selection_order .= '<option value="DESC"' . (('DESC' === $order) ? ' selected' : '') . '>' . _MD_NEWBB_DESCENDING . '</option>';
187
+$forum_selection_order .= '<option value="ASC"'.(('ASC' === $order) ? ' selected' : '').'>'._MD_NEWBB_ASCENDING.'</option>';
188
+$forum_selection_order .= '<option value="DESC"'.(('DESC' === $order) ? ' selected' : '').'>'._MD_NEWBB_DESCENDING.'</option>';
189 189
 $forum_selection_order .= '</select>';
190 190
 
191 191
 $xoopsTpl->assign_by_ref('forum_selection_order', $forum_selection_order);
192 192
 
193 193
 $since = Request::getInt('since', $GLOBALS['xoopsModuleConfig']['since_default'], 'GET');
194
-require_once __DIR__ . '/include/functions.time.php';
194
+require_once __DIR__.'/include/functions.time.php';
195 195
 $forum_selection_since = newbbSinceSelectBox($since);
196 196
 $xoopsTpl->assign_by_ref('forum_selection_since', $forum_selection_since);
197 197
 
@@ -200,14 +200,14 @@  discard block
 block discarded – undo
200 200
 $page_query_sort = implode('&amp;', array_values($query_sort));
201 201
 unset($query_sort);
202 202
 // irmtfan - edit: u.uname => t.topic_poster | t.topic_time => t.topic_id | p.post_time => t.topic_last_post_id
203
-$xoopsTpl->assign('h_topic_link', XOOPS_URL . "/modules/newbb/viewforum.php?{$page_query_sort}&amp;sort=t.topic_title&amp;order=" . (('t.topic_title' === $sort && 'DESC' === $order) ? 'ASC' : 'DESC'));
204
-$xoopsTpl->assign('h_reply_link', XOOPS_URL . "/modules/newbb/viewforum.php?{$page_query_sort}&amp;sort=t.topic_replies&amp;order=" . (('t.topic_replies' === $sort && 'DESC' === $order) ? 'ASC' : 'DESC'));
205
-$xoopsTpl->assign('h_poster_link', XOOPS_URL . "/modules/newbb/viewforum.php?{$page_query_sort}&amp;sort=t.topic_poster&amp;order=" . (('t.topic_poster' === $sort && 'DESC' === $order) ? 'ASC' : 'DESC'));
206
-$xoopsTpl->assign('h_views_link', XOOPS_URL . "/modules/newbb/viewforum.php?{$page_query_sort}&amp;sort=t.topic_views&amp;order=" . (('t.topic_views' === $sort && 'DESC' === $order) ? 'ASC' : 'DESC'));
207
-$xoopsTpl->assign('h_rating_link', XOOPS_URL . "/modules/newbb/viewforum.php?{$page_query_sort}&amp;sort=t.rating&amp;order=" . (('t.rating' === $sort
203
+$xoopsTpl->assign('h_topic_link', XOOPS_URL."/modules/newbb/viewforum.php?{$page_query_sort}&amp;sort=t.topic_title&amp;order=".(('t.topic_title' === $sort && 'DESC' === $order) ? 'ASC' : 'DESC'));
204
+$xoopsTpl->assign('h_reply_link', XOOPS_URL."/modules/newbb/viewforum.php?{$page_query_sort}&amp;sort=t.topic_replies&amp;order=".(('t.topic_replies' === $sort && 'DESC' === $order) ? 'ASC' : 'DESC'));
205
+$xoopsTpl->assign('h_poster_link', XOOPS_URL."/modules/newbb/viewforum.php?{$page_query_sort}&amp;sort=t.topic_poster&amp;order=".(('t.topic_poster' === $sort && 'DESC' === $order) ? 'ASC' : 'DESC'));
206
+$xoopsTpl->assign('h_views_link', XOOPS_URL."/modules/newbb/viewforum.php?{$page_query_sort}&amp;sort=t.topic_views&amp;order=".(('t.topic_views' === $sort && 'DESC' === $order) ? 'ASC' : 'DESC'));
207
+$xoopsTpl->assign('h_rating_link', XOOPS_URL."/modules/newbb/viewforum.php?{$page_query_sort}&amp;sort=t.rating&amp;order=".(('t.rating' === $sort
208 208
                                                                                                                                   && 'DESC' === $order) ? 'ASC' : 'DESC')); // irmtfan t.topic_ratings to t.rating
209
-$xoopsTpl->assign('h_date_link', XOOPS_URL . "/modules/newbb/viewforum.php?{$page_query_sort}&amp;sort=t.topic_last_post_id&amp;order=" . (('t.topic_last_post_id' === $sort && 'DESC' === $order) ? 'ASC' : 'DESC'));
210
-$xoopsTpl->assign('h_publish_link', XOOPS_URL . "/modules/newbb/viewforum.php?{$page_query_sort}&amp;sort=t.topic_id&amp;order=" . (('t.topic_id' === $sort
209
+$xoopsTpl->assign('h_date_link', XOOPS_URL."/modules/newbb/viewforum.php?{$page_query_sort}&amp;sort=t.topic_last_post_id&amp;order=".(('t.topic_last_post_id' === $sort && 'DESC' === $order) ? 'ASC' : 'DESC'));
210
+$xoopsTpl->assign('h_publish_link', XOOPS_URL."/modules/newbb/viewforum.php?{$page_query_sort}&amp;sort=t.topic_id&amp;order=".(('t.topic_id' === $sort
211 211
                                                                                                                                      && 'DESC' === $order) ? 'ASC' : 'DESC'));
212 212
 $xoopsTpl->assign('forum_since', $since); // For $since in search.php
213 213
 
@@ -237,11 +237,11 @@  discard block
 block discarded – undo
237 237
 $xoopsTpl->assign('img_digest', newbbDisplayImage('topic_digest', _MD_NEWBB_TOPICDIGEST));
238 238
 $xoopsTpl->assign('img_poll', newbbDisplayImage('poll', _MD_NEWBB_TOPICHASPOLL));
239 239
 
240
-$xoopsTpl->assign('mark_read', XOOPS_URL . "/modules/newbb/viewforum.php?mark=1&amp;{$page_query}");
241
-$xoopsTpl->assign('mark_unread', XOOPS_URL . "/modules/newbb/viewforum.php?mark=2&amp;{$page_query}");
240
+$xoopsTpl->assign('mark_read', XOOPS_URL."/modules/newbb/viewforum.php?mark=1&amp;{$page_query}");
241
+$xoopsTpl->assign('mark_unread', XOOPS_URL."/modules/newbb/viewforum.php?mark=2&amp;{$page_query}");
242 242
 
243
-$xoopsTpl->assign('post_link', XOOPS_URL . '/modules/newbb/viewpost.php?forum=' . $forum_id);
244
-$xoopsTpl->assign('newpost_link', XOOPS_URL . '/modules/newbb/viewpost.php?status=new&amp;forum=' . $forum_id);
243
+$xoopsTpl->assign('post_link', XOOPS_URL.'/modules/newbb/viewpost.php?forum='.$forum_id);
244
+$xoopsTpl->assign('newpost_link', XOOPS_URL.'/modules/newbb/viewpost.php?status=new&amp;forum='.$forum_id);
245 245
 
246 246
 $query_type = $query_array;
247 247
 unset($query_type['type']);
@@ -252,16 +252,16 @@  discard block
 block discarded – undo
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}"];
255
+    $typeOptions[] = ['title' => _ALL, 'link' => XOOPS_URL."/modules/newbb/viewforum.php?{$page_query_type}"];
256 256
     foreach ($types as $key => $item) {
257 257
         $typeOptions[] = [
258 258
             'title' => $item['type_name'],
259
-            'link'  => XOOPS_URL . "/modules/newbb/viewforum.php?{$page_query_type}&amp;type={$key}"
259
+            'link'  => XOOPS_URL."/modules/newbb/viewforum.php?{$page_query_type}&amp;type={$key}"
260 260
         ];
261 261
     }
262 262
 }
263 263
 if ($type > 0) {
264
-    require_once __DIR__ . '/include/functions.topic.php';
264
+    require_once __DIR__.'/include/functions.topic.php';
265 265
     $xoopsTpl->assign('forum_topictype', getTopicTitle('', $types[$type]['type_name'], $types[$type]['type_color']));
266 266
 }
267 267
 $xoopsTpl->assign_by_ref('typeOptions', $typeOptions);
@@ -270,11 +270,11 @@  discard block
 block discarded – undo
270 270
 unset($query_status['status']);
271 271
 $page_query_status = implode('&amp;', array_values($query_status));
272 272
 unset($query_status);
273
-$xoopsTpl->assign('newpost_link', XOOPS_URL . '/modules/newbb/viewpost.php?status=new&amp;forum=' . $forumObject->getVar('forum_id'));
274
-$xoopsTpl->assign('all_link', XOOPS_URL . "/modules/newbb/viewforum.php?{$page_query_status}");
275
-$xoopsTpl->assign('digest_link', XOOPS_URL . "/modules/newbb/viewforum.php?{$page_query_status}&amp;status=digest");
276
-$xoopsTpl->assign('unreplied_link', XOOPS_URL . "/modules/newbb/viewforum.php?{$page_query_status}&amp;status=unreplied");
277
-$xoopsTpl->assign('unread_link', XOOPS_URL . "/modules/newbb/viewforum.php?{$page_query_status}&amp;status=unread");
273
+$xoopsTpl->assign('newpost_link', XOOPS_URL.'/modules/newbb/viewpost.php?status=new&amp;forum='.$forumObject->getVar('forum_id'));
274
+$xoopsTpl->assign('all_link', XOOPS_URL."/modules/newbb/viewforum.php?{$page_query_status}");
275
+$xoopsTpl->assign('digest_link', XOOPS_URL."/modules/newbb/viewforum.php?{$page_query_status}&amp;status=digest");
276
+$xoopsTpl->assign('unreplied_link', XOOPS_URL."/modules/newbb/viewforum.php?{$page_query_status}&amp;status=unreplied");
277
+$xoopsTpl->assign('unread_link', XOOPS_URL."/modules/newbb/viewforum.php?{$page_query_status}&amp;status=unread");
278 278
 switch ($status) {
279 279
     case 'digest':
280 280
         $current_status = _MD_NEWBB_DIGEST;
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 }
323 323
 
324 324
 if (!empty($GLOBALS['xoopsModuleConfig']['show_jump'])) {
325
-    require_once __DIR__ . '/include/functions.forum.php';
325
+    require_once __DIR__.'/include/functions.forum.php';
326 326
     $xoopsTpl->assign('forum_jumpbox', newbbMakeJumpbox($forum_id));
327 327
 }
328 328
 
@@ -335,8 +335,8 @@  discard block
 block discarded – undo
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
-require_once __DIR__ . '/footer.php';
341
+require_once __DIR__.'/footer.php';
342 342
 require_once $GLOBALS['xoops']->path('footer.php');
Please login to merge, or discard this patch.
view.tag.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,5 +8,5 @@
 block discarded – undo
8 8
  * @since          4.00
9 9
  * @package        module::newbb
10 10
  */
11
-require_once __DIR__ . '/header.php';
11
+require_once __DIR__.'/header.php';
12 12
 require_once $GLOBALS['xoops']->path('modules/tag/view.tag.php');
Please login to merge, or discard this patch.
delete.php 2 patches
Indentation   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -16,17 +16,17 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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&amp;pid=$pid&amp;forum=$forum", 2, _MD_NEWBB_DELNOTALLOWED);
65
+	redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id=$topic_id&amp;pid=$pid&amp;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&amp;topic_id=$topic_id&amp;post_id=$post_id&amp;pid=$pid", 2, _MD_NEWBB_TIMEISUPDEL);
69
+	redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?forum=$forum&amp;topic_id=$topic_id&amp;post_id=$post_id&amp;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&amp;pid=$pid&amp;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&amp;pid=$pid&amp;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&amp;order=$order&amp;viewmode=$viewmode&amp;pid=$pid&amp;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&amp;order=$order&amp;viewmode=$viewmode&amp;pid=$pid&amp;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
 }
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 
12 12
 use Xmf\Request;
13 13
 
14
-require_once __DIR__ . '/header.php';
14
+require_once __DIR__.'/header.php';
15 15
 
16 16
 $ok = Request::getInt('ok', 0, 'POST');
17 17
 
@@ -43,15 +43,15 @@  discard block
 block discarded – undo
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;
46
+    $redirect = empty($forum) ? 'index.php' : 'viewforum.php?forum='.$forum;
47
+    $redirect = XOOPS_URL.'/modules/newbb/'.$redirect;
48 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,11 +62,11 @@  discard block
 block discarded – undo
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&amp;pid=$pid&amp;forum=$forum", 2, _MD_NEWBB_DELNOTALLOWED);
65
+    redirect_header(XOOPS_URL."/modules/newbb/viewtopic.php?topic_id=$topic_id&amp;pid=$pid&amp;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&amp;topic_id=$topic_id&amp;post_id=$post_id&amp;pid=$pid", 2, _MD_NEWBB_TIMEISUPDEL);
69
+    redirect_header(XOOPS_URL."/modules/newbb/viewtopic.php?forum=$forum&amp;topic_id=$topic_id&amp;post_id=$post_id&amp;pid=$pid", 2, _MD_NEWBB_TIMEISUPDEL);
70 70
 }
71 71
 
72 72
 if ($GLOBALS['xoopsModuleConfig']['wol_enabled']) {
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
     }
83 83
     if ($isDeleteOne && $postObject->isTopic() && $topic->getVar('topic_replies') > 0) {
84 84
         //$postHandler->emptyTopic($postObject);
85
-        redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id=$topic_id&amp;pid=$pid&amp;forum=$forum", 2, _MD_NEWBB_POSTFIRSTWITHREPLYNODELETED);
85
+        redirect_header(XOOPS_URL."/modules/newbb/viewtopic.php?topic_id=$topic_id&amp;pid=$pid&amp;forum=$forum", 2, _MD_NEWBB_POSTFIRSTWITHREPLYNODELETED);
86 86
     } else {
87 87
         if (Request::getString('post_text', '', 'POST')) {
88 88
             //send a message
@@ -101,11 +101,11 @@  discard block
 block discarded – undo
101 101
                 $xoopsMailer->setToUsers($senduser);
102 102
                 $xoopsMailer->setFromName($GLOBALS['xoopsUser']->getVar('uname'));
103 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>';
104
+                $forenurl = '<a href="'.XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname').'/viewtopic.php?topic_id='.$postObject->getVar('topic_id').'">'.$postObject->getVar('subject').'</a>';
105 105
                 if (!empty($GLOBALS['xoopsModuleConfig']['do_rewrite'])) {
106 106
                     $forenurl = seo_urls($forenurl);
107 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 . '/');
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 109
                 $body = $myts->nl2Br($body);
110 110
                 $xoopsMailer->setBody($body);
111 111
                 $xoopsMailer->send();
@@ -121,25 +121,25 @@  discard block
 block discarded – undo
121 121
 
122 122
     //$postObject->loadFilters('delete');
123 123
     if ($isDeleteOne) {
124
-        redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id=$topic_id&amp;order=$order&amp;viewmode=$viewmode&amp;pid=$pid&amp;forum=$forum", 2, _MD_NEWBB_POSTDELETED);
124
+        redirect_header(XOOPS_URL."/modules/newbb/viewtopic.php?topic_id=$topic_id&amp;order=$order&amp;viewmode=$viewmode&amp;pid=$pid&amp;forum=$forum", 2, _MD_NEWBB_POSTDELETED);
125 125
     } else {
126
-        redirect_header(XOOPS_URL . "/modules/newbb/viewforum.php?forum=$forum", 2, _MD_NEWBB_POSTSDELETED);
126
+        redirect_header(XOOPS_URL."/modules/newbb/viewforum.php?forum=$forum", 2, _MD_NEWBB_POSTSDELETED);
127 127
     }
128 128
 } else {
129 129
     require_once $GLOBALS['xoops']->path('header.php');
130 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
-          <form method="post" action="' . XOOPS_URL . '/modules/newbb/delete.php">';
133
-    echo _MD_NEWBB_DELEDEDMSG . '<br>';
131
+    echo '<div class="confirmMsg">'._MD_NEWBB_DEL_ONE.'<br>
132
+          <form method="post" action="' . XOOPS_URL.'/modules/newbb/delete.php">';
133
+    echo _MD_NEWBB_DELEDEDMSG.'<br>';
134 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) . '" />';
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 139
     echo '<input type="hidden" name="ok" value="1" />';
140 140
     echo $GLOBALS['xoopsSecurity']->getTokenHTML();
141
-    echo '<input type="submit" name="confirm_submit" value="' . _SUBMIT . '" title="' . _SUBMIT . '"/>
142
-          <input type="button" name="confirm_back" value="' . _CANCEL . '" onclick="history.go(-1);" title="' . _CANCEL . '" />
141
+    echo '<input type="submit" name="confirm_submit" value="'._SUBMIT.'" title="'._SUBMIT.'"/>
142
+          <input type="button" name="confirm_back" value="' . _CANCEL.'" onclick="history.go(-1);" title="'._CANCEL.'" />
143 143
           </form>
144 144
           </div>';
145 145
     if ($isAdmin) {
Please login to merge, or discard this patch.
polls.php 3 patches
Indentation   +685 added lines, -685 removed lines patch added patch discarded remove patch
@@ -30,17 +30,17 @@  discard block
 block discarded – undo
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
 block discarded – undo
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&amp;poll_id={$poll_id}&amp;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&amp;poll_id={$poll_id}&amp;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&amp;poll_id={$poll_id}&amp;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&amp;poll_id={$poll_id}&amp;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&amp;poll_id={$poll_id}&amp;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&amp;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&amp;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&amp;poll_id={$poll_id}&amp;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&amp;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&amp;poll_id={$poll_id}"), 2, _MD_NEWBB_POLL_VIEWLOG);
754
+		}
755
+		break;
756 756
 } // switch
757 757
 
758 758
 // irmtfan move to footer.php
Please login to merge, or discard this patch.
Switch Indentation   +640 added lines, -640 removed lines patch added patch discarded remove patch
@@ -111,648 +111,648 @@
 block discarded – undo
111 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&amp;poll_id={$poll_id}&amp;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&amp;poll_id={$poll_id}&amp;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&amp;poll_id={$poll_id}&amp;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&amp;poll_id={$poll_id}&amp;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&amp;poll_id={$poll_id}&amp;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&amp;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&amp;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&amp;poll_id={$poll_id}&amp;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&amp;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&amp;poll_id={$poll_id}"), 2, _MD_NEWBB_POLL_VIEWLOG);
754
+        	}
755
+        	break;
756 756
 } // switch
757 757
 
758 758
 // irmtfan move to footer.php
Please login to merge, or discard this patch.
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 
24 24
 // rewrite by irmtfan and zyspec to accept xoopspoll 1.4 and all old xoopspoll and umfrage versions and all clones
25 25
 
26
-require_once __DIR__ . '/header.php';
26
+require_once __DIR__.'/header.php';
27 27
 require_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
28 28
 require_once $GLOBALS['xoops']->path('class/xoopslists.php');
29 29
 require_once $GLOBALS['xoops']->path('class/xoopsblock.php');
@@ -56,18 +56,18 @@  discard block
 block discarded – undo
56 56
 if (is_object($topicObject)) {
57 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']);
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
         $pollObject = $xpPollHandler->get($poll_id); // will create poll if poll_id = 0 exist
85 85
         // old xoopspoll or umfrage or any clone from them
86 86
     } else {
87
-        require_once $GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/include/constants.php');
87
+        require_once $GLOBALS['xoops']->path('modules/'.$GLOBALS['xoopsModuleConfig']['poll_module'].'/include/constants.php');
88 88
         $classPoll  = $topicObject->loadOldPoll();
89 89
         $pollObject = new $classPoll($poll_id); // will create poll if poll_id = 0 exist
90 90
     }
@@ -114,11 +114,11 @@  discard block
 block discarded – undo
114 114
     case 'add':
115 115
         // new xoopspoll module
116 116
         if ($pollModuleHandler->getVar('version') >= 140) {
117
-            echo '<h4>' . _MD_NEWBB_POLL_CREATNEWPOLL . "</h4>\n";
117
+            echo '<h4>'._MD_NEWBB_POLL_CREATNEWPOLL."</h4>\n";
118 118
             $pollObject->renderForm(Request::getString('PHP_SELF', '', 'SERVER'), 'post', ['topic_id' => $topic_id]);
119 119
         // old xoopspoll or umfrage or any clone from them
120 120
         } else {
121
-            $classOption  = $classPoll . 'Option';
121
+            $classOption  = $classPoll.'Option';
122 122
             $poll_form    = new \XoopsThemeForm(_MD_NEWBB_POLL_CREATNEWPOLL, 'poll_form', 'polls.php', 'post', true);
123 123
             $author_label = new \XoopsFormLabel(_MD_NEWBB_POLL_AUTHOR, is_object($GLOBALS['xoopsUser']) ? ("<a href='"
124 124
                                                                                                           . XOOPS_URL
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
             $poll_form->addElement($desc_tarea);
135 135
             $currenttime = formatTimestamp(time(), 'Y-m-d H:i:s');
136 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);
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 138
             $poll_form->addElement($expire_text);
139 139
 
140 140
             $weight_text = new \XoopsFormText(_MD_NEWBB_POLL_DISPLAYORDER, 'weight', 6, 5, 0);
@@ -147,14 +147,14 @@  discard block
 block discarded – undo
147 147
             $poll_form->addElement($notify_yn);
148 148
 
149 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/'));
150
+            $barcolor_array = \XoopsLists::getImgListAsArray($GLOBALS['xoops']->path('modules/'.$GLOBALS['xoopsModuleConfig']['poll_module'].'/assets/images/colorbars/'));
151 151
             for ($i = 0; $i < 10; ++$i) {
152 152
                 $current_bar = ('blank.gif' !== current($barcolor_array)) ? current($barcolor_array) : next($barcolor_array);
153 153
                 $option_text = new \XoopsFormText('', 'option_text[]', 50, 255);
154 154
                 $option_tray->addElement($option_text);
155 155
                 $color_select = new \XoopsFormSelect('', "option_color[{$i}]", $current_bar);
156 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 . "\")'");
157
+                $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[{$i}]\", \"modules/".$GLOBALS['xoopsModuleConfig']['poll_module'].'/assets/images/colorbars", "", "'.XOOPS_URL."\")'");
158 158
                 $color_label = new \XoopsFormLabel('', "<img src='"
159 159
                                                       . XOOPS_URL
160 160
                                                       . '/modules/'
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
             $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id));
177 177
             $poll_form->addElement(new \XoopsFormHidden('user_id', is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0));
178 178
             $poll_form->addElement(new \XoopsFormButtonTray('poll_submit', _SUBMIT, 'submit'));
179
-            echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . '</h4>';
179
+            echo '<h4>'._MD_NEWBB_POLL_POLLCONF.'</h4>';
180 180
             $poll_form->display();
181 181
         }
182 182
         break; // op: add
@@ -184,13 +184,13 @@  discard block
 block discarded – undo
184 184
     case 'edit':
185 185
         // new xoopspoll module
186 186
         if ($pollModuleHandler->getVar('version') >= 140) {
187
-            echo '<h4>' . _MD_NEWBB_POLL_EDITPOLL . "</h4>\n";
187
+            echo '<h4>'._MD_NEWBB_POLL_EDITPOLL."</h4>\n";
188 188
             $pollObject->renderForm(Request::getString('PHP_SELF', '', 'SERVER'), 'post', ['topic_id' => $topic_id]);
189 189
         // old xoopspoll or umfrage or any clone from them
190 190
         } else {
191
-            $classOption  = $classPoll . 'Option';
191
+            $classOption  = $classPoll.'Option';
192 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>');
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 194
             $poll_form->addElement($author_label);
195 195
             $question_text = new \XoopsFormText(_MD_NEWBB_POLL_POLLQUESTION, 'question', 50, 255, $pollObject->getVar('question', 'E'));
196 196
             $poll_form->addElement($question_text);
@@ -198,13 +198,13 @@  discard block
 block discarded – undo
198 198
             $poll_form->addElement($desc_tarea);
199 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 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);
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 202
                 $poll_form->addElement($expire_text);
203 203
             } else {
204 204
                 // irmtfan full URL - add topic_id
205 205
                 $restart_label = new \XoopsFormLabel(
206 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&amp;poll_id={$poll_id}&amp;topic_id={$topic_id}'>" . _MD_NEWBB_POLL_RESTART . '</a>'
207
+                                                    sprintf(_MD_NEWBB_POLL_EXPIREDAT, $date)."<br><a href='".XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname')."/polls.php?op=restart&amp;poll_id={$poll_id}&amp;topic_id={$topic_id}'>"._MD_NEWBB_POLL_RESTART.'</a>'
208 208
                 );
209 209
                 $poll_form->addElement($restart_label);
210 210
             }
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
             $poll_form->addElement($weight_text);
213 213
             $multi_yn = new \XoopsFormRadioYN(_MD_NEWBB_POLL_ALLOWMULTI, 'multiple', $pollObject->getVar('multiple'));
214 214
             $poll_form->addElement($multi_yn);
215
-            $options_arr  =& $classOption::getAllByPollId($poll_id);
215
+            $options_arr  = & $classOption::getAllByPollId($poll_id);
216 216
             $notify_value = 1;
217 217
             if (0 !== $pollObject->getVar('mail_status')) {
218 218
                 $notify_value = 0;
@@ -228,9 +228,9 @@  discard block
 block discarded – undo
228 228
                 $option_tray->addElement(new \XoopsFormHidden('option_id[]', $option->getVar('option_id')));
229 229
                 $color_select = new \XoopsFormSelect('', 'option_color[{$i}]', $option->getVar('option_color'));
230 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 . "\")'");
231
+                $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[".$i."]\", \"modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars\", \"\", \"".XOOPS_URL."\")'");
232 232
                 $color_label = new \XoopsFormLabel('', "<img src='"
233
-                                                      . $GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/" . $option->getVar('option_color', 'E'))
233
+                                                      . $GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/".$option->getVar('option_color', 'E'))
234 234
                                                       . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt='' /><br>");
235 235
                 $option_tray->addElement($color_select);
236 236
                 $option_tray->addElement($color_label);
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
                 ++$i;
239 239
             }
240 240
             // irmtfan full URL
241
-            $more_label = new \XoopsFormLabel('', "<br><a href='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/polls.php?op=addmore&amp;poll_id={$poll_id}&amp;topic_id={$topic_id}'>" . _MD_NEWBB_POLL_ADDMORE . '</a>');
241
+            $more_label = new \XoopsFormLabel('', "<br><a href='".XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname')."/polls.php?op=addmore&amp;poll_id={$poll_id}&amp;topic_id={$topic_id}'>"._MD_NEWBB_POLL_ADDMORE.'</a>');
242 242
             $option_tray->addElement($more_label);
243 243
             $poll_form->addElement($option_tray);
244 244
             $poll_form->addElement(new \XoopsFormHidden('op', 'update'));
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
             $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id));
247 247
             $poll_form->addElement(new \XoopsFormButtonTray('poll_submit', _SUBMIT, 'submit'));
248 248
 
249
-            echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n";
249
+            echo '<h4>'._MD_NEWBB_POLL_POLLCONF."</h4>\n";
250 250
             $poll_form->display();
251 251
         }
252 252
         break; // op: edit
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
             $option_empty = true;
265 265
             if (!Request::getString('option_text', '', 'POST')) {
266 266
                 // irmtfan - issue with javascript:history.go(-1)
267
-                redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !');
267
+                redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED.': '._MD_NEWBB_POLL_POLLOPTIONS.' !');
268 268
             }
269 269
             $option_text = Request::getArray('option_text', '', 'POST');
270 270
             foreach ($option_text as $optxt) {
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
             }
276 276
             if ($option_empty) {
277 277
                 // irmtfan - issue with javascript:history.go(-1)
278
-                redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !');
278
+                redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED.': '._MD_NEWBB_POLL_POLLOPTIONS.' !');
279 279
             }
280 280
             $pollObject->setVar('question', Request::getString('question', '', 'POST'));
281 281
             $pollObject->setVar('description', Request::getString('description', '', 'POST'));
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
             }
307 307
             $i            = 0;
308 308
             $option_color = Request::getArray('option_color', null, 'POST');
309
-            $classOption  = $classPoll . 'Option';
309
+            $classOption  = $classPoll.'Option';
310 310
             foreach ($option_text as $optxt) {
311 311
                 $optxt = trim($optxt);
312 312
                 /** @var Xoopspoll\Option $optionObject */
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
             } else {
334 334
                 redirect_header("viewtopic.php?topic_id={$topic_id}", 2, _MD_NEWBB_POLL_DBUPDATED);
335 335
             }
336
-            break;// op: save
336
+            break; // op: save
337 337
         }
338 338
     // no break
339 339
     case 'update':
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
         $option_string = is_array($option_text) ? implode('', $option_text) : $option_text;
347 347
         $option_string = trim($option_string);
348 348
         if ('' === $option_string) {
349
-            redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !');
349
+            redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED.': '._MD_NEWBB_POLL_POLLOPTIONS.' !');
350 350
         }
351 351
 
352 352
         // new xoopspoll module
@@ -465,8 +465,8 @@  discard block
 block discarded – undo
465 465
             $i            = 0;
466 466
             $option_id    = Request::getArray('option_id', null, 'POST');
467 467
             $option_color = Request::getArray('option_color', null, 'POST');
468
-            $classOption  = $classPoll . 'Option';
469
-            $classLog     = $classPoll . 'Log';
468
+            $classOption  = $classPoll.'Option';
469
+            $classLog     = $classPoll.'Log';
470 470
             foreach ($option_id as $opid) {
471 471
                 $optionObject    = new $classOption($opid);
472 472
                 $option_text[$i] = trim($option_text[$i]);
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
         } else {
498 498
             redirect_header("viewtopic.php?topic_id={$topic_id}", 2, _MD_NEWBB_POLL_DBUPDATED);
499 499
         }
500
-        break;// op: save | update
500
+        break; // op: save | update
501 501
 
502 502
     case 'addmore':
503 503
         $question = $pollObject->getVar('question');
@@ -511,14 +511,14 @@  discard block
 block discarded – undo
511 511
         // old xoopspoll or umfrage or any clone from them
512 512
         } else {
513 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/'));
514
+            $barcolor_array = \XoopsLists::getImgListAsArray($GLOBALS['xoops']->path('modules/'.$GLOBALS['xoopsModuleConfig']['poll_module'].'/assets/images/colorbars/'));
515 515
             for ($i = 0; $i < 10; ++$i) {
516 516
                 $current_bar = ('blank.gif' !== current($barcolor_array)) ? current($barcolor_array) : next($barcolor_array);
517 517
                 $option_text = new \XoopsFormText('', 'option_text[]', 50, 255);
518 518
                 $option_tray->addElement($option_text);
519 519
                 $color_select = new \XoopsFormSelect('', "option_color[{$i}]", $current_bar);
520 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 . "\")'");
521
+                $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[{$i}]\", \"modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars\", \"\", \"".XOOPS_URL."\")'");
522 522
                 $color_label = new \XoopsFormLabel('', "<img src='"
523 523
                                                       . $GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/{$current_bar}")
524 524
                                                       . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt='' /><br>");
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
         $poll_form->addElement(new \XoopsFormHidden('topic_id', $topic_id));
537 537
         $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id));
538 538
 
539
-        echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n";
539
+        echo '<h4>'._MD_NEWBB_POLL_POLLCONF."</h4>\n";
540 540
         $poll_form->display();
541 541
         break;
542 542
 
@@ -551,7 +551,7 @@  discard block
 block discarded – undo
551 551
         $option_string = trim($option_string);
552 552
         if ('' === $option_string) {
553 553
             // irmtfan - issue with javascript:history.go(-1)
554
-            redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !');
554
+            redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED.': '._MD_NEWBB_POLL_POLLOPTIONS.' !');
555 555
         }
556 556
         $i            = 0;
557 557
         $option_color = Request::getArray('option_color', null, 'POST');
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
                     $xpOptHandler->insert($optionObject);
569 569
                 // old xoopspoll or umfrage or any clone from them
570 570
                 } else {
571
-                    $classOption  = $classPoll . 'Option';
571
+                    $classOption  = $classPoll.'Option';
572 572
                     $optionObject = new $classOption();
573 573
                     $optionObject->setVar('option_text', $optxt);
574 574
                     $optionObject->setVar('poll_id', $poll_id);
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
         break;
587 587
 
588 588
     case 'delete':
589
-        echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n";
589
+        echo '<h4>'._MD_NEWBB_POLL_POLLCONF."</h4>\n";
590 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 591
         break;
592 592
 
@@ -610,8 +610,8 @@  discard block
 block discarded – undo
610 610
             // old xoopspoll or umfrage or any clone from them
611 611
         } else {
612 612
             $status      = $pollObject->delete();
613
-            $classOption = $classPoll . 'Option';
614
-            $classLog    = $classPoll . 'Log';
613
+            $classOption = $classPoll.'Option';
614
+            $classLog    = $classPoll.'Log';
615 615
             if (false !== $status) {
616 616
                 $classOption::deleteByPollId($poll_id);
617 617
                 $classLog::deleteByPollId($poll_id);
@@ -638,13 +638,13 @@  discard block
 block discarded – undo
638 638
             xoops_error($msg);
639 639
             break;
640 640
         }
641
-        redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id={$topic_id}", 1, _MD_NEWBB_POLL_DBUPDATED);
641
+        redirect_header(XOOPS_URL."/modules/newbb/viewtopic.php?topic_id={$topic_id}", 1, _MD_NEWBB_POLL_DBUPDATED);
642 642
         break;
643 643
 
644 644
     case 'restart':
645 645
         // new xoopspoll module
646 646
         if ($pollModuleHandler->getVar('version') >= 140) {
647
-            $classConstants   = new XoopsModules\Xoopspoll\Constants();
647
+            $classConstants = new XoopsModules\Xoopspoll\Constants();
648 648
             $default_poll_duration = $classConstants::DEFAULT_POLL_DURATION;
649 649
         // old xoopspoll or umfrage or any clone from them
650 650
         } else {
@@ -652,10 +652,10 @@  discard block
 block discarded – undo
652 652
         }
653 653
         $poll_form   = new \XoopsThemeForm(_MD_NEWBB_POLL_RESTARTPOLL, 'poll_form', 'polls.php', 'post', true);
654 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(
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 656
             _MD_NEWBB_POLL_EXPIREDAT,
657 657
                                                                                                                                                                                                                      formatTimestamp($pollObject->getVar('end_time'), 'Y-m-d H:i:s')
658
-        ) . '</small>',
658
+        ).'</small>',
659 659
                                          'end_time',
660 660
             20,
661 661
             19,
@@ -669,7 +669,7 @@  discard block
 block discarded – undo
669 669
         $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id));
670 670
         $poll_form->addElement(new \XoopsFormButton('', 'poll_submit', _MD_NEWBB_POLL_RESTART, 'submit'));
671 671
 
672
-        echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n";
672
+        echo '<h4>'._MD_NEWBB_POLL_POLLCONF."</h4>\n";
673 673
         $poll_form->display();
674 674
         break;
675 675
 
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
 
682 682
         // new xoopspoll module
683 683
         if ($pollModuleHandler->getVar('version') >= 140) {
684
-            $classConstants   = new XoopsModules\Xoopspoll\Constants();
684
+            $classConstants = new XoopsModules\Xoopspoll\Constants();
685 685
             $default_poll_duration = $classConstants::DEFAULT_POLL_DURATION;
686 686
             $poll_not_mailed       = $classConstants::POLL_NOT_MAILED;
687 687
             $poll_mailed           = $classConstants::POLL_MAILED;
@@ -731,8 +731,8 @@  discard block
 block discarded – undo
731 731
                 exit();
732 732
             }
733 733
             if (Request::getInt('reset', 0, 'POST')) { // reset all logs
734
-                $classOption = $classPoll . 'Option';
735
-                $classLog    = $classPoll . 'Log';
734
+                $classOption = $classPoll.'Option';
735
+                $classLog    = $classPoll.'Log';
736 736
                 $classLog::deleteByPollId($poll_id);
737 737
                 $classOption::resetCountByPollId($poll_id);
738 738
                 $pollObject->updateCount();
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
         require_once $GLOBALS['xoops']->path('class/template.php');
742 742
         xoops_template_clear_module_cache($xoopsModule->getVar('mid'));
743 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);
744
+        redirect_header(XOOPS_URL."/modules/newbb/viewtopic.php?topic_id={$topic_id}", 1, _MD_NEWBB_POLL_DBUPDATED);
745 745
         break;
746 746
 
747 747
     case 'log':
@@ -756,5 +756,5 @@  discard block
 block discarded – undo
756 756
 } // switch
757 757
 
758 758
 // irmtfan move to footer.php
759
-require_once __DIR__ . '/footer.php';
759
+require_once __DIR__.'/footer.php';
760 760
 require_once $GLOBALS['xoops']->path('footer.php');
Please login to merge, or discard this patch.
footer.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -36,9 +36,9 @@
 block discarded – undo
36 36
 xoops_load('XoopsLists');
37 37
 $allfiles = \XoopsLists::getFileListAsArray($GLOBALS['xoops']->path($js_rel_path));
38 38
 foreach ($allfiles as $jsfile) {
39
-    if ('js' === strtolower(pathinfo($jsfile, PATHINFO_EXTENSION))) {
40
-        $xoTheme->addScript($js_rel_path . '/' . $jsfile);
41
-    }
39
+	if ('js' === strtolower(pathinfo($jsfile, PATHINFO_EXTENSION))) {
40
+		$xoTheme->addScript($js_rel_path . '/' . $jsfile);
41
+	}
42 42
 }
43 43
 global $forumCookie;  // for $forumCookie["prefix"] revert last change - use global instead of include
44 44
 // add toggle script
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -25,23 +25,23 @@
 block discarded – undo
25 25
 require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.render.php');
26 26
 $iconHandler = newbbGetIconHandler();
27 27
 //  get css rel path from setted language
28
-$css_rel_path = $iconHandler->getPath('language/' . $GLOBALS['xoopsConfig']['language'], 'newbb', 'language/english', 'css');
28
+$css_rel_path = $iconHandler->getPath('language/'.$GLOBALS['xoopsConfig']['language'], 'newbb', 'language/english', 'css');
29 29
 // add local stylesheet
30 30
 /** @var xos_opal_Theme $xoTheme */
31
-$xoTheme->addStylesheet($css_rel_path . '/style.css');
31
+$xoTheme->addStylesheet($css_rel_path.'/style.css');
32 32
 
33 33
 //  get js rel path from setted language
34
-$js_rel_path = $iconHandler->getPath('language/' . $GLOBALS['xoopsConfig']['language'], 'newbb', 'language/english', 'js');
34
+$js_rel_path = $iconHandler->getPath('language/'.$GLOBALS['xoopsConfig']['language'], 'newbb', 'language/english', 'js');
35 35
 // add all local js files inside js directory
36 36
 xoops_load('XoopsLists');
37 37
 $allfiles = \XoopsLists::getFileListAsArray($GLOBALS['xoops']->path($js_rel_path));
38 38
 foreach ($allfiles as $jsfile) {
39 39
     if ('js' === strtolower(pathinfo($jsfile, PATHINFO_EXTENSION))) {
40
-        $xoTheme->addScript($js_rel_path . '/' . $jsfile);
40
+        $xoTheme->addScript($js_rel_path.'/'.$jsfile);
41 41
     }
42 42
 }
43
-global $forumCookie;  // for $forumCookie["prefix"] revert last change - use global instead of include
43
+global $forumCookie; // for $forumCookie["prefix"] revert last change - use global instead of include
44 44
 // add toggle script
45 45
 //$toggle_script = "var toggle_cookie=\"" . $forumCookie['prefix'] . 'G' . '\';';
46
-$toggle_script = 'var toggle_cookie="' . $forumCookie['prefix'] . 'G";';
46
+$toggle_script = 'var toggle_cookie="'.$forumCookie['prefix'].'G";';
47 47
 $xoTheme->addScript(null, ['type' => 'text/javascript'], $toggle_script);
Please login to merge, or discard this patch.
moderate.php 2 patches
Indentation   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -21,75 +21,75 @@  discard block
 block discarded – undo
21 21
 $forum_id     = Request::getInt('forum', 0);
22 22
 $isAdmin      = newbbIsAdmin($forum_id);
23 23
 if (!$isAdmin) {
24
-    redirect_header(XOOPS_URL . '/index.php', 2, _MD_NEWBB_NORIGHTTOACCESS);
24
+	redirect_header(XOOPS_URL . '/index.php', 2, _MD_NEWBB_NORIGHTTOACCESS);
25 25
 }
26 26
 $is_administrator = $GLOBALS['xoopsUserIsAdmin'];
27 27
 ///** @var Newbb\ModerateHandler $moderateHandler */
28 28
 //$moderateHandler = Newbb\Helper::getInstance()->getHandler('Moderate');
29 29
 
30 30
 if (Request::hasVar('submit', 'POST') && Request::getInt('expire', 0, 'POST')) {
31
-    $ipWithMask = '';
32
-    if (0 == $forum_userid) {
33
-        $ipWithMask = Request::getString('ip', null, 'POST');
34
-        $mask       = '';
35
-        $ipParts    = explode('/', $ipWithMask);
36
-        $ip         = new \Xmf\IPAddress($ipParts[0]);
37
-        if (false === $ip->asReadable()) {
38
-            $ipWithMask = '';
39
-        } else {
40
-            $ipWithMask = $ip->asReadable();
41
-            $mask       = empty($ipParts[1]) ? 0 : (int)$ipParts[1];
42
-            $mask       = ($mask > ((4 === $ip->ipVersion()) ? 32 : 128) || $mask < 8) ? '' : $mask;
43
-            $ipWithMask .= empty($mask) ? '' : '/' . $mask;
44
-        }
45
-    }
46
-
47
-    $mod_end  = time() + Request::getInt('expire', 0, 'POST') * 3600 * 24;
48
-    $mod_desc = Request::getString('desc', '', 'POST');
49
-
50
-    $moderateObject = $moderateHandler->create();
51
-    $moderateObject->setVar('uid', $forum_userid);
52
-    $moderateObject->setVar('ip', $ipWithMask);
53
-    $moderateObject->setVar('forum_id', $forum_id);
54
-    $moderateObject->setVar('mod_start', time());
55
-    $moderateObject->setVar('mod_end', $mod_end);
56
-    $moderateObject->setVar('mod_desc', $mod_desc);
57
-    $res = $moderateHandler->insert($moderateObject);
58
-
59
-    redirect_header("moderate.php?forum={$forum_id}", 2, _MD_NEWBB_DBUPDATED);
31
+	$ipWithMask = '';
32
+	if (0 == $forum_userid) {
33
+		$ipWithMask = Request::getString('ip', null, 'POST');
34
+		$mask       = '';
35
+		$ipParts    = explode('/', $ipWithMask);
36
+		$ip         = new \Xmf\IPAddress($ipParts[0]);
37
+		if (false === $ip->asReadable()) {
38
+			$ipWithMask = '';
39
+		} else {
40
+			$ipWithMask = $ip->asReadable();
41
+			$mask       = empty($ipParts[1]) ? 0 : (int)$ipParts[1];
42
+			$mask       = ($mask > ((4 === $ip->ipVersion()) ? 32 : 128) || $mask < 8) ? '' : $mask;
43
+			$ipWithMask .= empty($mask) ? '' : '/' . $mask;
44
+		}
45
+	}
46
+
47
+	$mod_end  = time() + Request::getInt('expire', 0, 'POST') * 3600 * 24;
48
+	$mod_desc = Request::getString('desc', '', 'POST');
49
+
50
+	$moderateObject = $moderateHandler->create();
51
+	$moderateObject->setVar('uid', $forum_userid);
52
+	$moderateObject->setVar('ip', $ipWithMask);
53
+	$moderateObject->setVar('forum_id', $forum_id);
54
+	$moderateObject->setVar('mod_start', time());
55
+	$moderateObject->setVar('mod_end', $mod_end);
56
+	$moderateObject->setVar('mod_desc', $mod_desc);
57
+	$res = $moderateHandler->insert($moderateObject);
58
+
59
+	redirect_header("moderate.php?forum={$forum_id}", 2, _MD_NEWBB_DBUPDATED);
60 60
 } elseif (Request::hasVar('del')) {
61
-    $moderateObject = $moderateHandler->get(Request::getInt('del', 0, 'GET'));
62
-    if ($is_administrator || $moderateObject->getVar('forum_id') == $forum_id) {
63
-        $moderateHandler->delete($moderateObject, true);
64
-        redirect_header("moderate.php?forum={$forum_id}", 2, _MD_NEWBB_DBUPDATED);
65
-    }
61
+	$moderateObject = $moderateHandler->get(Request::getInt('del', 0, 'GET'));
62
+	if ($is_administrator || $moderateObject->getVar('forum_id') == $forum_id) {
63
+		$moderateHandler->delete($moderateObject, true);
64
+		redirect_header("moderate.php?forum={$forum_id}", 2, _MD_NEWBB_DBUPDATED);
65
+	}
66 66
 }
67 67
 
68 68
 $start    = Request::getInt('start', 0, 'GET');
69 69
 $sortname = Request::getString('sort', '', 'GET');
70 70
 
71 71
 switch ($sortname) {
72
-    case 'uid':
73
-        $sort  = 'uid ASC, ip';
74
-        $order = 'ASC';
75
-        break;
76
-    case 'start':
77
-        $sort  = 'mod_start';
78
-        $order = 'ASC';
79
-        break;
80
-    case 'expire':
81
-        $sort  = 'mod_end';
82
-        $order = 'DESC';
83
-        break;
84
-    default:
85
-        $sort  = 'forum_id ASC, uid ASC, ip';
86
-        $order = 'ASC';
87
-        break;
72
+	case 'uid':
73
+		$sort  = 'uid ASC, ip';
74
+		$order = 'ASC';
75
+		break;
76
+	case 'start':
77
+		$sort  = 'mod_start';
78
+		$order = 'ASC';
79
+		break;
80
+	case 'expire':
81
+		$sort  = 'mod_end';
82
+		$order = 'DESC';
83
+		break;
84
+	default:
85
+		$sort  = 'forum_id ASC, uid ASC, ip';
86
+		$order = 'ASC';
87
+		break;
88 88
 }
89 89
 // show all bans for module admin - for moderator just show its forum_id bans
90 90
 $criteria = new \CriteriaCompo();
91 91
 if (!$is_administrator) {
92
-    $criteria->add(new \Criteria('forum_id', $forum_id, '='));
92
+	$criteria->add(new \Criteria('forum_id', $forum_id, '='));
93 93
 }
94 94
 $criteria->setLimit($GLOBALS['xoopsModuleConfig']['topics_per_page']);
95 95
 $criteria->setStart($start);
@@ -100,75 +100,75 @@  discard block
 block discarded – undo
100 100
 
101 101
 $url = 'moderate.php';
102 102
 if ($forum_id) {
103
-    $url .= '?forum=' . $forum_id;
103
+	$url .= '?forum=' . $forum_id;
104 104
 }
105 105
 $xoopsTpl->assign('moderate_url', $url);
106 106
 
107 107
 if (!empty($moderate_count)) {
108
-    $_users = [];
109
-    foreach (array_keys($moderateObjects) as $id) {
110
-        $_users[$moderateObjects[$id]->getVar('uid')] = 1;
111
-    }
112
-    $users = newbbGetUnameFromIds(array_keys($_users), $GLOBALS['xoopsModuleConfig']['show_realname'], true);
113
-
114
-    $columnHeaders ['uid']    = [
115
-        'url'    => 'moderate.php?forum=' . $forum_id . '&amp;start=' . $start . '&amp;sort=uid',
116
-        'header' => _MD_NEWBB_SUSPEND_UID,
117
-        'title'  => _MD_NEWBB_SUSPEND_UID,
118
-    ];
119
-    $columnHeaders ['start']  = [
120
-        'url'    => 'moderate.php?forum=' . $forum_id . '&amp;start=' . $start . '&amp;sort=start',
121
-        'header' => _MD_NEWBB_SUSPEND_START,
122
-        'title'  => _MD_NEWBB_SUSPEND_START,
123
-    ];
124
-    $columnHeaders['expire']  = [
125
-        'url'    => 'moderate.php?forum=' . $forum_id . '&amp;start=' . $start . '&amp;sort=expire',
126
-        'header' => _MD_NEWBB_SUSPEND_EXPIRE,
127
-        'title'  => _MD_NEWBB_SUSPEND_EXPIRE,
128
-    ];
129
-    $columnHeaders['forum']   = [
130
-        'url'    => 'moderate.php?forum=' . $forum_id . '&amp;start=' . $start . '&amp;sort=forum',
131
-        'header' => _MD_NEWBB_SUSPEND_SCOPE,
132
-        'title'  => _MD_NEWBB_SUSPEND_SCOPE,
133
-    ];
134
-    $columnHeaders['desc']    = [
135
-        'url'    => false,
136
-        'header' => _MD_NEWBB_SUSPEND_DESC,
137
-        'title'  => _MD_NEWBB_SUSPEND_DESC,
138
-    ];
139
-    $columnHeaders['options'] = [
140
-        'url'    => false,
141
-        'header' => _DELETE,
142
-        'title'  => _DELETE,
143
-    ];
144
-    $xoopsTpl->assign('columnHeaders', $columnHeaders);
145
-
146
-    //    /** @var Newbb\ForumHandler $forumHandler */
147
-    //    $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum');
148
-    $forum_list = $forumHandler->getAll(null, ['forum_name'], false);
149
-
150
-    $columnRows = [];
151
-    foreach (array_keys($moderateObjects) as $id) {
152
-        // for anon, show ip instead
153
-        $row['uid']     = ($moderateObjects[$id]->getVar('uid') ? (isset($users[$moderateObjects[$id]->getVar('uid')]) ? $users[$moderateObjects[$id]->getVar('uid')] : $moderateObjects[$id]->getVar('uid')) : $moderateObjects[$id]->getVar('ip'));
154
-        $row['start']   = formatTimestamp($moderateObjects[$id]->getVar('mod_start'));
155
-        $row['expire']  = formatTimestamp($moderateObjects[$id]->getVar('mod_end'));
156
-        $row['forum']   = ($moderateObjects[$id]->getVar('forum_id') ? $forum_list[$moderateObjects[$id]->getVar('forum_id')]['forum_name'] : _ALL);
157
-        $row['desc']    = ($moderateObjects[$id]->getVar('mod_desc') ?: _NONE);
158
-        $row['options'] = (($is_administrator
159
-                            || $moderateObjects[$id]->getVar('forum_id') == $forum_id) ? '<a href="moderate.php?forum=' . $forum_id . '&amp;del=' . $moderateObjects[$id]->getVar('mod_id') . '">' . _DELETE . '</a>' : '');
160
-        $columnRows[]   = $row;
161
-    }
162
-    $xoopsTpl->assign('columnRows', $columnRows);
163
-
164
-    if ($moderate_count > $GLOBALS['xoopsModuleConfig']['topics_per_page']) {
165
-        require_once $GLOBALS['xoops']->path('class/pagenav.php');
166
-        $nav = new \XoopsPageNav($moderate_count, $GLOBALS['xoopsModuleConfig']['topics_per_page'], $start, 'start', 'forum=' . $forum_id . '&amp;sort=' . $sortname);
167
-        //if (isset($GLOBALS['xoopsModuleConfig']['do_rewrite'])) {
168
-        //    $nav->url = formatURL(Request::getString('SERVER_NAME', '', 'SERVER')) . ' /' . $nav->url;
169
-        //}
170
-        $xoopsTpl->assign('moderate_page_nav', $nav->renderNav());
171
-    }
108
+	$_users = [];
109
+	foreach (array_keys($moderateObjects) as $id) {
110
+		$_users[$moderateObjects[$id]->getVar('uid')] = 1;
111
+	}
112
+	$users = newbbGetUnameFromIds(array_keys($_users), $GLOBALS['xoopsModuleConfig']['show_realname'], true);
113
+
114
+	$columnHeaders ['uid']    = [
115
+		'url'    => 'moderate.php?forum=' . $forum_id . '&amp;start=' . $start . '&amp;sort=uid',
116
+		'header' => _MD_NEWBB_SUSPEND_UID,
117
+		'title'  => _MD_NEWBB_SUSPEND_UID,
118
+	];
119
+	$columnHeaders ['start']  = [
120
+		'url'    => 'moderate.php?forum=' . $forum_id . '&amp;start=' . $start . '&amp;sort=start',
121
+		'header' => _MD_NEWBB_SUSPEND_START,
122
+		'title'  => _MD_NEWBB_SUSPEND_START,
123
+	];
124
+	$columnHeaders['expire']  = [
125
+		'url'    => 'moderate.php?forum=' . $forum_id . '&amp;start=' . $start . '&amp;sort=expire',
126
+		'header' => _MD_NEWBB_SUSPEND_EXPIRE,
127
+		'title'  => _MD_NEWBB_SUSPEND_EXPIRE,
128
+	];
129
+	$columnHeaders['forum']   = [
130
+		'url'    => 'moderate.php?forum=' . $forum_id . '&amp;start=' . $start . '&amp;sort=forum',
131
+		'header' => _MD_NEWBB_SUSPEND_SCOPE,
132
+		'title'  => _MD_NEWBB_SUSPEND_SCOPE,
133
+	];
134
+	$columnHeaders['desc']    = [
135
+		'url'    => false,
136
+		'header' => _MD_NEWBB_SUSPEND_DESC,
137
+		'title'  => _MD_NEWBB_SUSPEND_DESC,
138
+	];
139
+	$columnHeaders['options'] = [
140
+		'url'    => false,
141
+		'header' => _DELETE,
142
+		'title'  => _DELETE,
143
+	];
144
+	$xoopsTpl->assign('columnHeaders', $columnHeaders);
145
+
146
+	//    /** @var Newbb\ForumHandler $forumHandler */
147
+	//    $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum');
148
+	$forum_list = $forumHandler->getAll(null, ['forum_name'], false);
149
+
150
+	$columnRows = [];
151
+	foreach (array_keys($moderateObjects) as $id) {
152
+		// for anon, show ip instead
153
+		$row['uid']     = ($moderateObjects[$id]->getVar('uid') ? (isset($users[$moderateObjects[$id]->getVar('uid')]) ? $users[$moderateObjects[$id]->getVar('uid')] : $moderateObjects[$id]->getVar('uid')) : $moderateObjects[$id]->getVar('ip'));
154
+		$row['start']   = formatTimestamp($moderateObjects[$id]->getVar('mod_start'));
155
+		$row['expire']  = formatTimestamp($moderateObjects[$id]->getVar('mod_end'));
156
+		$row['forum']   = ($moderateObjects[$id]->getVar('forum_id') ? $forum_list[$moderateObjects[$id]->getVar('forum_id')]['forum_name'] : _ALL);
157
+		$row['desc']    = ($moderateObjects[$id]->getVar('mod_desc') ?: _NONE);
158
+		$row['options'] = (($is_administrator
159
+							|| $moderateObjects[$id]->getVar('forum_id') == $forum_id) ? '<a href="moderate.php?forum=' . $forum_id . '&amp;del=' . $moderateObjects[$id]->getVar('mod_id') . '">' . _DELETE . '</a>' : '');
160
+		$columnRows[]   = $row;
161
+	}
162
+	$xoopsTpl->assign('columnRows', $columnRows);
163
+
164
+	if ($moderate_count > $GLOBALS['xoopsModuleConfig']['topics_per_page']) {
165
+		require_once $GLOBALS['xoops']->path('class/pagenav.php');
166
+		$nav = new \XoopsPageNav($moderate_count, $GLOBALS['xoopsModuleConfig']['topics_per_page'], $start, 'start', 'forum=' . $forum_id . '&amp;sort=' . $sortname);
167
+		//if (isset($GLOBALS['xoopsModuleConfig']['do_rewrite'])) {
168
+		//    $nav->url = formatURL(Request::getString('SERVER_NAME', '', 'SERVER')) . ' /' . $nav->url;
169
+		//}
170
+		$xoopsTpl->assign('moderate_page_nav', $nav->renderNav());
171
+	}
172 172
 }
173 173
 
174 174
 require_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
@@ -179,19 +179,19 @@  discard block
 block discarded – undo
179 179
 $forum_form->addElement(new \XoopsFormText(_MD_NEWBB_SUSPEND_DESC, 'desc', 50, 255));
180 180
 require_once __DIR__ . '/include/functions.forum.php';
181 181
 if (newbbIsAdmin()) {
182
-    $forumSel = '<select name="forum">';// if user doesn't select, default is "0" all forums
183
-    $forumSel .= '<option value="0"';
184
-    if (0 == $forum_id) {
185
-        $forumSel .= ' selected';
186
-    }
187
-    $forumSel                         .= '>' . _ALL . '</option>';
188
-    $forumSel                         .= newbbForumSelectBox($forum_id, 'access', false); //$accessForums, $permission = "access", $delimitorCategory = true
189
-    $forumSel                         .= '</select>';
190
-    $forumEle                         = new \XoopsFormLabel(_MD_NEWBB_SELFORUM, $forumSel);
191
-    $forumEle->customValidationCode[] = 'if (document.suspend.forum.value < 0) {return false;} ';
192
-    $forum_form->addElement($forumEle);
182
+	$forumSel = '<select name="forum">';// if user doesn't select, default is "0" all forums
183
+	$forumSel .= '<option value="0"';
184
+	if (0 == $forum_id) {
185
+		$forumSel .= ' selected';
186
+	}
187
+	$forumSel                         .= '>' . _ALL . '</option>';
188
+	$forumSel                         .= newbbForumSelectBox($forum_id, 'access', false); //$accessForums, $permission = "access", $delimitorCategory = true
189
+	$forumSel                         .= '</select>';
190
+	$forumEle                         = new \XoopsFormLabel(_MD_NEWBB_SELFORUM, $forumSel);
191
+	$forumEle->customValidationCode[] = 'if (document.suspend.forum.value < 0) {return false;} ';
192
+	$forum_form->addElement($forumEle);
193 193
 } else {
194
-    $forum_form->addElement(new \XoopsFormHidden('forum', $forum_id));
194
+	$forum_form->addElement(new \XoopsFormHidden('forum', $forum_id));
195 195
 }
196 196
 $forum_form->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
197 197
 $forum_form->assign($xoopsTpl);
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 
12 12
 use Xmf\Request;
13 13
 
14
-require_once __DIR__ . '/header.php';
14
+require_once __DIR__.'/header.php';
15 15
 
16 16
 global $xoTheme, $xoopsTpl;
17 17
 $GLOBALS['xoopsOption']['template_main'] = 'newbb_moderate.tpl';
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 $forum_id     = Request::getInt('forum', 0);
22 22
 $isAdmin      = newbbIsAdmin($forum_id);
23 23
 if (!$isAdmin) {
24
-    redirect_header(XOOPS_URL . '/index.php', 2, _MD_NEWBB_NORIGHTTOACCESS);
24
+    redirect_header(XOOPS_URL.'/index.php', 2, _MD_NEWBB_NORIGHTTOACCESS);
25 25
 }
26 26
 $is_administrator = $GLOBALS['xoopsUserIsAdmin'];
27 27
 ///** @var Newbb\ModerateHandler $moderateHandler */
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
             $ipWithMask = $ip->asReadable();
41 41
             $mask       = empty($ipParts[1]) ? 0 : (int)$ipParts[1];
42 42
             $mask       = ($mask > ((4 === $ip->ipVersion()) ? 32 : 128) || $mask < 8) ? '' : $mask;
43
-            $ipWithMask .= empty($mask) ? '' : '/' . $mask;
43
+            $ipWithMask .= empty($mask) ? '' : '/'.$mask;
44 44
         }
45 45
     }
46 46
 
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 
101 101
 $url = 'moderate.php';
102 102
 if ($forum_id) {
103
-    $url .= '?forum=' . $forum_id;
103
+    $url .= '?forum='.$forum_id;
104 104
 }
105 105
 $xoopsTpl->assign('moderate_url', $url);
106 106
 
@@ -111,27 +111,27 @@  discard block
 block discarded – undo
111 111
     }
112 112
     $users = newbbGetUnameFromIds(array_keys($_users), $GLOBALS['xoopsModuleConfig']['show_realname'], true);
113 113
 
114
-    $columnHeaders ['uid']    = [
115
-        'url'    => 'moderate.php?forum=' . $forum_id . '&amp;start=' . $start . '&amp;sort=uid',
114
+    $columnHeaders ['uid'] = [
115
+        'url'    => 'moderate.php?forum='.$forum_id.'&amp;start='.$start.'&amp;sort=uid',
116 116
         'header' => _MD_NEWBB_SUSPEND_UID,
117 117
         'title'  => _MD_NEWBB_SUSPEND_UID,
118 118
     ];
119
-    $columnHeaders ['start']  = [
120
-        'url'    => 'moderate.php?forum=' . $forum_id . '&amp;start=' . $start . '&amp;sort=start',
119
+    $columnHeaders ['start'] = [
120
+        'url'    => 'moderate.php?forum='.$forum_id.'&amp;start='.$start.'&amp;sort=start',
121 121
         'header' => _MD_NEWBB_SUSPEND_START,
122 122
         'title'  => _MD_NEWBB_SUSPEND_START,
123 123
     ];
124
-    $columnHeaders['expire']  = [
125
-        'url'    => 'moderate.php?forum=' . $forum_id . '&amp;start=' . $start . '&amp;sort=expire',
124
+    $columnHeaders['expire'] = [
125
+        'url'    => 'moderate.php?forum='.$forum_id.'&amp;start='.$start.'&amp;sort=expire',
126 126
         'header' => _MD_NEWBB_SUSPEND_EXPIRE,
127 127
         'title'  => _MD_NEWBB_SUSPEND_EXPIRE,
128 128
     ];
129
-    $columnHeaders['forum']   = [
130
-        'url'    => 'moderate.php?forum=' . $forum_id . '&amp;start=' . $start . '&amp;sort=forum',
129
+    $columnHeaders['forum'] = [
130
+        'url'    => 'moderate.php?forum='.$forum_id.'&amp;start='.$start.'&amp;sort=forum',
131 131
         'header' => _MD_NEWBB_SUSPEND_SCOPE,
132 132
         'title'  => _MD_NEWBB_SUSPEND_SCOPE,
133 133
     ];
134
-    $columnHeaders['desc']    = [
134
+    $columnHeaders['desc'] = [
135 135
         'url'    => false,
136 136
         'header' => _MD_NEWBB_SUSPEND_DESC,
137 137
         'title'  => _MD_NEWBB_SUSPEND_DESC,
@@ -156,14 +156,14 @@  discard block
 block discarded – undo
156 156
         $row['forum']   = ($moderateObjects[$id]->getVar('forum_id') ? $forum_list[$moderateObjects[$id]->getVar('forum_id')]['forum_name'] : _ALL);
157 157
         $row['desc']    = ($moderateObjects[$id]->getVar('mod_desc') ?: _NONE);
158 158
         $row['options'] = (($is_administrator
159
-                            || $moderateObjects[$id]->getVar('forum_id') == $forum_id) ? '<a href="moderate.php?forum=' . $forum_id . '&amp;del=' . $moderateObjects[$id]->getVar('mod_id') . '">' . _DELETE . '</a>' : '');
159
+                            || $moderateObjects[$id]->getVar('forum_id') == $forum_id) ? '<a href="moderate.php?forum='.$forum_id.'&amp;del='.$moderateObjects[$id]->getVar('mod_id').'">'._DELETE.'</a>' : '');
160 160
         $columnRows[]   = $row;
161 161
     }
162 162
     $xoopsTpl->assign('columnRows', $columnRows);
163 163
 
164 164
     if ($moderate_count > $GLOBALS['xoopsModuleConfig']['topics_per_page']) {
165 165
         require_once $GLOBALS['xoops']->path('class/pagenav.php');
166
-        $nav = new \XoopsPageNav($moderate_count, $GLOBALS['xoopsModuleConfig']['topics_per_page'], $start, 'start', 'forum=' . $forum_id . '&amp;sort=' . $sortname);
166
+        $nav = new \XoopsPageNav($moderate_count, $GLOBALS['xoopsModuleConfig']['topics_per_page'], $start, 'start', 'forum='.$forum_id.'&amp;sort='.$sortname);
167 167
         //if (isset($GLOBALS['xoopsModuleConfig']['do_rewrite'])) {
168 168
         //    $nav->url = formatURL(Request::getString('SERVER_NAME', '', 'SERVER')) . ' /' . $nav->url;
169 169
         //}
@@ -177,14 +177,14 @@  discard block
 block discarded – undo
177 177
 $forum_form->addElement(new \XoopsFormText(_MD_NEWBB_SUSPEND_IP, 'ip', 50, 50));
178 178
 $forum_form->addElement(new \XoopsFormText(_MD_NEWBB_SUSPEND_DURATION, 'expire', 20, 25, '5'), true);
179 179
 $forum_form->addElement(new \XoopsFormText(_MD_NEWBB_SUSPEND_DESC, 'desc', 50, 255));
180
-require_once __DIR__ . '/include/functions.forum.php';
180
+require_once __DIR__.'/include/functions.forum.php';
181 181
 if (newbbIsAdmin()) {
182
-    $forumSel = '<select name="forum">';// if user doesn't select, default is "0" all forums
182
+    $forumSel = '<select name="forum">'; // if user doesn't select, default is "0" all forums
183 183
     $forumSel .= '<option value="0"';
184 184
     if (0 == $forum_id) {
185 185
         $forumSel .= ' selected';
186 186
     }
187
-    $forumSel                         .= '>' . _ALL . '</option>';
187
+    $forumSel                         .= '>'._ALL.'</option>';
188 188
     $forumSel                         .= newbbForumSelectBox($forum_id, 'access', false); //$accessForums, $permission = "access", $delimitorCategory = true
189 189
     $forumSel                         .= '</select>';
190 190
     $forumEle                         = new \XoopsFormLabel(_MD_NEWBB_SELFORUM, $forumSel);
@@ -196,5 +196,5 @@  discard block
 block discarded – undo
196 196
 $forum_form->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
197 197
 $forum_form->assign($xoopsTpl);
198 198
 
199
-require_once __DIR__ . '/footer.php';
199
+require_once __DIR__.'/footer.php';
200 200
 require_once $GLOBALS['xoops']->path('footer.php');
Please login to merge, or discard this patch.