Passed
Push — master ( 2744eb...81ba93 )
by Michael
02:46
created
submit.php 1 patch
Switch Indentation   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -54,153 +54,153 @@  discard block
 block discarded – undo
54 54
 }
55 55
 
56 56
 switch ($op) {
57
-    case 'preview':
57
+        case 'preview':
58 58
 
59
-        global $xoopsUser, $xoopsConfig, $xoopsModule,  $xoopsDB;
59
+            global $xoopsUser, $xoopsConfig, $xoopsModule,  $xoopsDB;
60 60
 
61
-        $faqObj      = $faqHandler->create();
62
-        $answerObj   = $answerHandler->create();
63
-        $categoryObj = $categoryHandler->get($_POST['categoryid']);
61
+            $faqObj      = $faqHandler->create();
62
+            $answerObj   = $answerHandler->create();
63
+            $categoryObj = $categoryHandler->get($_POST['categoryid']);
64 64
 
65
-        if (!$xoopsUser) {
66
-            if (1 == $helper->getConfig('anonpost')) {
67
-                $uid = 0;
65
+            if (!$xoopsUser) {
66
+                if (1 == $helper->getConfig('anonpost')) {
67
+                    $uid = 0;
68
+                } else {
69
+                    redirect_header('index.php', 3, _NOPERM);
70
+                }
68 71
             } else {
69
-                redirect_header('index.php', 3, _NOPERM);
72
+                $uid = $xoopsUser->uid();
70 73
             }
71
-        } else {
72
-            $uid = $xoopsUser->uid();
73
-        }
74 74
 
75
-        $notifypub = \Xmf\Request::getInt('notifypub', 0, POST);
75
+            $notifypub = \Xmf\Request::getInt('notifypub', 0, POST);
76 76
 
77
-        // Putting the values about the FAQ in the FAQ object
78
-        $faqObj->setVar('categoryid', $_POST['categoryid']);
79
-        $faqObj->setVar('uid', $uid);
80
-        $faqObj->setVar('question', $_POST['question']);
81
-        $faqObj->setVar('howdoi', $_POST['howdoi']);
82
-        $faqObj->setVar('diduno', $_POST['diduno']);
83
-        $faqObj->setVar('datesub', time());
77
+            // Putting the values about the FAQ in the FAQ object
78
+            $faqObj->setVar('categoryid', $_POST['categoryid']);
79
+            $faqObj->setVar('uid', $uid);
80
+            $faqObj->setVar('question', $_POST['question']);
81
+            $faqObj->setVar('howdoi', $_POST['howdoi']);
82
+            $faqObj->setVar('diduno', $_POST['diduno']);
83
+            $faqObj->setVar('datesub', time());
84 84
 
85
-        // Putting the values in the answer object
86
-        $answerObj->setVar('status', Constants::SF_AN_STATUS_APPROVED);
87
-        $answerObj->setVar('faqid', $faqObj->faqid());
88
-        $answerObj->setVar('answer', $_POST['answer']);
89
-        $answerObj->setVar('uid', $uid);
85
+            // Putting the values in the answer object
86
+            $answerObj->setVar('status', Constants::SF_AN_STATUS_APPROVED);
87
+            $answerObj->setVar('faqid', $faqObj->faqid());
88
+            $answerObj->setVar('answer', $_POST['answer']);
89
+            $answerObj->setVar('uid', $uid);
90 90
 
91
-        global $xoopsUser, $myts;
91
+            global $xoopsUser, $myts;
92 92
 
93
-        $GLOBALS['xoopsOption']['template_main'] = 'smartfaq_submit.tpl';
94
-        require_once XOOPS_ROOT_PATH . '/header.php';
95
-        require_once __DIR__ . '/footer.php';
93
+            $GLOBALS['xoopsOption']['template_main'] = 'smartfaq_submit.tpl';
94
+            require_once XOOPS_ROOT_PATH . '/header.php';
95
+            require_once __DIR__ . '/footer.php';
96 96
 
97
-        $name = $xoopsUser ? ucwords($xoopsUser->getVar('uname')) : 'Anonymous';
97
+            $name = $xoopsUser ? ucwords($xoopsUser->getVar('uname')) : 'Anonymous';
98 98
 
99
-        $moduleName          =& $myts->displayTarea($xoopsModule->getVar('name'));
100
-        $faq                 = $faqObj->toArray(null, $categoryObj, false);
101
-        $faq['categoryPath'] = $categoryObj->getCategoryPath(true);
102
-        $faq['answer']       = $answerObj->answer();
103
-        $faq['who_when']     = $faqObj->getWhoAndWhen();
99
+            $moduleName          =& $myts->displayTarea($xoopsModule->getVar('name'));
100
+            $faq                 = $faqObj->toArray(null, $categoryObj, false);
101
+            $faq['categoryPath'] = $categoryObj->getCategoryPath(true);
102
+            $faq['answer']       = $answerObj->answer();
103
+            $faq['who_when']     = $faqObj->getWhoAndWhen();
104 104
 
105
-        $faq['comments'] = -1;
106
-        $xoopsTpl->assign('faq', $faq);
107
-        $xoopsTpl->assign('op', 'preview');
108
-        $xoopsTpl->assign('whereInSection', $moduleName);
109
-        $xoopsTpl->assign('lang_submit', _MD_SF_SUB_SNEWNAME);
105
+            $faq['comments'] = -1;
106
+            $xoopsTpl->assign('faq', $faq);
107
+            $xoopsTpl->assign('op', 'preview');
108
+            $xoopsTpl->assign('whereInSection', $moduleName);
109
+            $xoopsTpl->assign('lang_submit', _MD_SF_SUB_SNEWNAME);
110 110
 
111
-        $xoopsTpl->assign('lang_intro_title', sprintf(_MD_SF_SUB_SNEWNAME, ucwords($xoopsModule->name())));
112
-        $xoopsTpl->assign('lang_intro_text', _MD_SF_GOODDAY . "<b>$name</b>, " . _MD_SF_SUB_INTRO);
111
+            $xoopsTpl->assign('lang_intro_title', sprintf(_MD_SF_SUB_SNEWNAME, ucwords($xoopsModule->name())));
112
+            $xoopsTpl->assign('lang_intro_text', _MD_SF_GOODDAY . "<b>$name</b>, " . _MD_SF_SUB_INTRO);
113 113
 
114
-        require_once __DIR__ . '/include/submit.inc.php';
114
+            require_once __DIR__ . '/include/submit.inc.php';
115 115
 
116
-        require_once XOOPS_ROOT_PATH . '/footer.php';
116
+            require_once XOOPS_ROOT_PATH . '/footer.php';
117 117
 
118
-        exit();
119
-        break;
118
+            exit();
119
+            break;
120 120
 
121
-    case 'post':
121
+        case 'post':
122 122
 
123
-        global $xoopsUser, $xoopsConfig, $xoopsModule,  $xoopsDB;
123
+            global $xoopsUser, $xoopsConfig, $xoopsModule,  $xoopsDB;
124 124
 
125
-        $newFaqObj    = $faqHandler->create();
126
-        $newAnswerObj = $answerHandler->create();
125
+            $newFaqObj    = $faqHandler->create();
126
+            $newAnswerObj = $answerHandler->create();
127 127
 
128
-        if (!$xoopsUser) {
129
-            if (1 == $helper->getConfig('anonpost')) {
130
-                $uid = 0;
128
+            if (!$xoopsUser) {
129
+                if (1 == $helper->getConfig('anonpost')) {
130
+                    $uid = 0;
131
+                } else {
132
+                    redirect_header('index.php', 3, _NOPERM);
133
+                }
131 134
             } else {
132
-                redirect_header('index.php', 3, _NOPERM);
135
+                $uid = $xoopsUser->uid();
133 136
             }
134
-        } else {
135
-            $uid = $xoopsUser->uid();
136
-        }
137
-
138
-        $notifypub = \Xmf\Request::getInt('notifypub', 0, POST);
139
-
140
-        // Putting the values about the FAQ in the FAQ object
141
-        $newFaqObj->setVar('categoryid', $_POST['categoryid']);
142
-        $newFaqObj->setVar('uid', $uid);
143
-        $newFaqObj->setVar('question', $_POST['question']);
144
-        $newFaqObj->setVar('howdoi', $_POST['howdoi']);
145
-        $newFaqObj->setVar('diduno', $_POST['diduno']);
146
-        $newFaqObj->setVar('notifypub', $notifypub);
147
-        //$newFaqObj->setVar('modulelink', $_POST['modulelink']);
148
-        //$newFaqObj->setVar('contextpage', $_POST['contextpage']);
149 137
 
150
-        // Setting the status of the FAQ
151
-
152
-        // if user is admin, FAQ are automatically published
153
-        $isAdmin = Smartfaq\Utility::userIsAdmin();
154
-        if ($isAdmin) {
155
-            $newFaqObj->setVar('status', Constants::SF_STATUS_PUBLISHED);
156
-        } elseif (1 == $helper->getConfig('autoapprove_submitted_faq')) {
157
-            $newFaqObj->setVar('status', Constants::SF_STATUS_PUBLISHED);
158
-        } else {
159
-            $newFaqObj->setVar('status', Constants::SF_STATUS_SUBMITTED);
160
-        }
138
+            $notifypub = \Xmf\Request::getInt('notifypub', 0, POST);
139
+
140
+            // Putting the values about the FAQ in the FAQ object
141
+            $newFaqObj->setVar('categoryid', $_POST['categoryid']);
142
+            $newFaqObj->setVar('uid', $uid);
143
+            $newFaqObj->setVar('question', $_POST['question']);
144
+            $newFaqObj->setVar('howdoi', $_POST['howdoi']);
145
+            $newFaqObj->setVar('diduno', $_POST['diduno']);
146
+            $newFaqObj->setVar('notifypub', $notifypub);
147
+            //$newFaqObj->setVar('modulelink', $_POST['modulelink']);
148
+            //$newFaqObj->setVar('contextpage', $_POST['contextpage']);
149
+
150
+            // Setting the status of the FAQ
151
+
152
+            // if user is admin, FAQ are automatically published
153
+            $isAdmin = Smartfaq\Utility::userIsAdmin();
154
+            if ($isAdmin) {
155
+                $newFaqObj->setVar('status', Constants::SF_STATUS_PUBLISHED);
156
+            } elseif (1 == $helper->getConfig('autoapprove_submitted_faq')) {
157
+                $newFaqObj->setVar('status', Constants::SF_STATUS_PUBLISHED);
158
+            } else {
159
+                $newFaqObj->setVar('status', Constants::SF_STATUS_SUBMITTED);
160
+            }
161 161
 
162
-        // Storing the FAQ object in the database
163
-        if (!$newFaqObj->store()) {
164
-            redirect_header('javascript:history.go(-1)', 2, _MD_SF_SUBMIT_ERROR);
165
-        }
162
+            // Storing the FAQ object in the database
163
+            if (!$newFaqObj->store()) {
164
+                redirect_header('javascript:history.go(-1)', 2, _MD_SF_SUBMIT_ERROR);
165
+            }
166 166
 
167
-        // Putting the values in the answer object
168
-        $newAnswerObj->setVar('status', Constants::SF_AN_STATUS_APPROVED);
169
-        $newAnswerObj->setVar('faqid', $newFaqObj->faqid());
170
-        $newAnswerObj->setVar('answer', $_POST['answer']);
171
-        $newAnswerObj->setVar('uid', $uid);
172
-
173
-        //====================================================================================
174
-        //TODO post Attachment
175
-        $attachments_tmp = [];
176
-        if (!empty($_POST['attachments_tmp'])) {
177
-            $attachments_tmp = unserialize(base64_decode($_POST['attachments_tmp']));
178
-            if (isset($_POST['delete_tmp']) && count($_POST['delete_tmp'])) {
179
-                foreach ($_POST['delete_tmp'] as $key) {
180
-                    unlink(XOOPS_ROOT_PATH . '/' . $helper->getConfig('dir_attachments') . '/' . $attachments_tmp[$key][0]);
181
-                    unset($attachments_tmp[$key]);
167
+            // Putting the values in the answer object
168
+            $newAnswerObj->setVar('status', Constants::SF_AN_STATUS_APPROVED);
169
+            $newAnswerObj->setVar('faqid', $newFaqObj->faqid());
170
+            $newAnswerObj->setVar('answer', $_POST['answer']);
171
+            $newAnswerObj->setVar('uid', $uid);
172
+
173
+            //====================================================================================
174
+            //TODO post Attachment
175
+            $attachments_tmp = [];
176
+            if (!empty($_POST['attachments_tmp'])) {
177
+                $attachments_tmp = unserialize(base64_decode($_POST['attachments_tmp']));
178
+                if (isset($_POST['delete_tmp']) && count($_POST['delete_tmp'])) {
179
+                    foreach ($_POST['delete_tmp'] as $key) {
180
+                        unlink(XOOPS_ROOT_PATH . '/' . $helper->getConfig('dir_attachments') . '/' . $attachments_tmp[$key][0]);
181
+                        unset($attachments_tmp[$key]);
182
+                    }
182 183
                 }
183 184
             }
184
-        }
185
-        if (count($attachments_tmp)) {
186
-            foreach ($attachments_tmp as $key => $attach) {
187
-                if (rename(XOOPS_CACHE_PATH . '/' . $attachments_tmp[$key][0], XOOPS_ROOT_PATH . '/' . $helper->getConfig('dir_attachments') . '/' . $attachments_tmp[$key][0])) {
188
-                    $post_obj->setAttachment($attach[0], $attach[1], $attach[2]);
185
+            if (count($attachments_tmp)) {
186
+                foreach ($attachments_tmp as $key => $attach) {
187
+                    if (rename(XOOPS_CACHE_PATH . '/' . $attachments_tmp[$key][0], XOOPS_ROOT_PATH . '/' . $helper->getConfig('dir_attachments') . '/' . $attachments_tmp[$key][0])) {
188
+                        $post_obj->setAttachment($attach[0], $attach[1], $attach[2]);
189
+                    }
189 190
                 }
190 191
             }
191
-        }
192
-        $error_upload = '';
192
+            $error_upload = '';
193 193
 
194
-        if (isset($_FILES['userfile']['name']) && '' != $_FILES['userfile']['name']
195
-            && $topicHandler->getPermission($forum_obj, $topic_status, 'attach')) {
196
-            require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/class/uploader.php';
197
-            $maxfilesize = $forum_obj->getVar('attach_maxkb') * 1024;
198
-            $uploaddir   = XOOPS_CACHE_PATH;
194
+            if (isset($_FILES['userfile']['name']) && '' != $_FILES['userfile']['name']
195
+                && $topicHandler->getPermission($forum_obj, $topic_status, 'attach')) {
196
+                require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/class/uploader.php';
197
+                $maxfilesize = $forum_obj->getVar('attach_maxkb') * 1024;
198
+                $uploaddir   = XOOPS_CACHE_PATH;
199 199
 
200
-            $uploader = new Smartfaq\Uploader($uploaddir, $newAnswerObj->getVar('attach_ext'), (int)$maxfilesize, (int)$helper->getConfig('max_img_width'), (int)$helper->getConfig('max_img_height'));
200
+                $uploader = new Smartfaq\Uploader($uploaddir, $newAnswerObj->getVar('attach_ext'), (int)$maxfilesize, (int)$helper->getConfig('max_img_width'), (int)$helper->getConfig('max_img_height'));
201 201
 
202
-            if ($_FILES['userfile']['error'] > 0) {
203
-                switch ($_FILES['userfile']['error']) {
202
+                if ($_FILES['userfile']['error'] > 0) {
203
+                    switch ($_FILES['userfile']['error']) {
204 204
                     case 1:
205 205
                         $error_message[] = _MD_NEWBB_MAXUPLOADFILEINI;
206 206
                         break;
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
                     default:
211 211
                         $error_message[] = _MD_NEWBB_UPLOAD_ERRNODEF;
212 212
                         break;
213
-                }
213
+                    }
214 214
             } else {
215 215
                 $uploader->setCheckMediaTypeByExt();
216 216
 
@@ -273,30 +273,30 @@  discard block
 block discarded – undo
273 273
         redirect_header('index.php', 2, $redirect_msg);
274 274
         break;
275 275
 
276
-    case 'form':
277
-    default:
276
+        case 'form':
277
+        default:
278 278
 
279
-        global $xoopsUser, $myts;
279
+            global $xoopsUser, $myts;
280 280
 
281
-        $faqObj      = $faqHandler->create();
282
-        $answerObj   = $answerHandler->create();
283
-        $categoryObj = $categoryHandler->create();
281
+            $faqObj      = $faqHandler->create();
282
+            $answerObj   = $answerHandler->create();
283
+            $categoryObj = $categoryHandler->create();
284 284
 
285
-        $GLOBALS['xoopsOption']['template_main'] = 'smartfaq_submit.tpl';
286
-        require_once XOOPS_ROOT_PATH . '/header.php';
287
-        require_once __DIR__ . '/footer.php';
285
+            $GLOBALS['xoopsOption']['template_main'] = 'smartfaq_submit.tpl';
286
+            require_once XOOPS_ROOT_PATH . '/header.php';
287
+            require_once __DIR__ . '/footer.php';
288 288
 
289
-        $name       = $xoopsUser ? ucwords($xoopsUser->getVar('uname')) : 'Anonymous';
290
-        $notifypub  = 1;
291
-        $moduleName =& $myts->displayTarea($xoopsModule->getVar('name'));
292
-        $xoopsTpl->assign('whereInSection', $moduleName);
293
-        $xoopsTpl->assign('lang_submit', _MD_SF_SUB_SNEWNAME);
289
+            $name       = $xoopsUser ? ucwords($xoopsUser->getVar('uname')) : 'Anonymous';
290
+            $notifypub  = 1;
291
+            $moduleName =& $myts->displayTarea($xoopsModule->getVar('name'));
292
+            $xoopsTpl->assign('whereInSection', $moduleName);
293
+            $xoopsTpl->assign('lang_submit', _MD_SF_SUB_SNEWNAME);
294 294
 
295
-        $xoopsTpl->assign('lang_intro_title', sprintf(_MD_SF_SUB_SNEWNAME, ucwords($xoopsModule->name())));
296
-        $xoopsTpl->assign('lang_intro_text', _MD_SF_GOODDAY . "<b>$name</b>, " . _MD_SF_SUB_INTRO);
295
+            $xoopsTpl->assign('lang_intro_title', sprintf(_MD_SF_SUB_SNEWNAME, ucwords($xoopsModule->name())));
296
+            $xoopsTpl->assign('lang_intro_text', _MD_SF_GOODDAY . "<b>$name</b>, " . _MD_SF_SUB_INTRO);
297 297
 
298
-        require_once __DIR__ . '/include/submit.inc.php';
298
+            require_once __DIR__ . '/include/submit.inc.php';
299 299
 
300
-        require_once XOOPS_ROOT_PATH . '/footer.php';
301
-        break;
300
+            require_once XOOPS_ROOT_PATH . '/footer.php';
301
+            break;
302 302
 }
Please login to merge, or discard this patch.
admin/category.php 1 patch
Switch Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -236,149 +236,149 @@
 block discarded – undo
236 236
 }
237 237
 
238 238
 switch ($op) {
239
-    case 'mod':
240
-        $categoryid  = \Xmf\Request::getInt('categoryid', 0, 'GET');
241
-        $destList    = \Xmf\Request::getString('destList', '', 'POST');
242
-        $adminObject = \Xmf\Module\Admin::getInstance();
243
-        xoops_cp_header();
239
+        case 'mod':
240
+            $categoryid  = \Xmf\Request::getInt('categoryid', 0, 'GET');
241
+            $destList    = \Xmf\Request::getString('destList', '', 'POST');
242
+            $adminObject = \Xmf\Module\Admin::getInstance();
243
+            xoops_cp_header();
244 244
 
245
-        $adminObject->displayNavigation(basename(__FILE__));
246
-        editcat(true, $categoryid);
247
-        break;
245
+            $adminObject->displayNavigation(basename(__FILE__));
246
+            editcat(true, $categoryid);
247
+            break;
248 248
 
249
-    case 'addcategory':
250
-        global $_POST, $xoopsUser, $xoopsUser, $xoopsConfig, $xoopsDB, $xoopsModule,  $modify, $myts, $categoryid;
249
+        case 'addcategory':
250
+            global $_POST, $xoopsUser, $xoopsUser, $xoopsConfig, $xoopsDB, $xoopsModule,  $modify, $myts, $categoryid;
251 251
 
252
-        $categoryid = \Xmf\Request::getInt('categoryid', 0, 'POST');
252
+            $categoryid = \Xmf\Request::getInt('categoryid', 0, 'POST');
253 253
 
254
-        if (0 != $categoryid) {
255
-            $categoryObj = new Smartfaq\Category($categoryid);
256
-        } else {
257
-            $categoryObj = $categoryHandler->create();
258
-        }
254
+            if (0 != $categoryid) {
255
+                $categoryObj = new Smartfaq\Category($categoryid);
256
+            } else {
257
+                $categoryObj = $categoryHandler->create();
258
+            }
259 259
 
260
-        //if (isset($_POST['allmods'])) $allmods = $_POST['allmods'];
261
-        //if (isset($_POST['moderators'])) $moderators = $_POST['moderators'];
260
+            //if (isset($_POST['allmods'])) $allmods = $_POST['allmods'];
261
+            //if (isset($_POST['moderators'])) $moderators = $_POST['moderators'];
262 262
 
263
-        $categoryObj->setVar('parentid', isset($_POST['parentid']) ? (int)$_POST['parentid'] : 0);
264
-        $applyall = \Xmf\Request::getInt('applyall', 0, 'POST');
265
-        $categoryObj->setVar('weight', isset($_POST['weight']) ? (int)$_POST['weight'] : 1);
263
+            $categoryObj->setVar('parentid', isset($_POST['parentid']) ? (int)$_POST['parentid'] : 0);
264
+            $applyall = \Xmf\Request::getInt('applyall', 0, 'POST');
265
+            $categoryObj->setVar('weight', isset($_POST['weight']) ? (int)$_POST['weight'] : 1);
266 266
 
267
-        // Groups and permissions
268
-        if (isset($_POST['groups_read'])) {
269
-            $categoryObj->setGroups_read($_POST['groups_read']);
270
-        } else {
271
-            $categoryObj->setGroups_read();
272
-        }
273
-        //  $groups_admin = isset($_POST['groups_admin'])? $_POST['groups_admin'] : array();
274
-        //  $mod_perms = isset($_POST['mod_perms'])? $_POST['mod_perms'] : array();
275
-
276
-        $categoryObj->setVar('name', $_POST['name']);
277
-
278
-        $categoryObj->setVar('description', $_POST['description']);
279
-        if ($categoryObj->isNew()) {
280
-            $redirect_msg = _AM_SF_CATCREATED;
281
-            $redirect_to  = 'category.php?op=mod';
282
-        } else {
283
-            $redirect_msg = _AM_SF_COLMODIFIED;
284
-            $redirect_to  = 'category.php';
285
-        }
286
-
287
-        if (!$categoryObj->store()) {
288
-            redirect_header('javascript:history.go(-1)', 3, _AM_SF_CATEGORY_SAVE_ERROR . Smartfaq\Utility::formatErrors($categoryObj->getErrors()));
289
-        }
290
-        // TODO : put this function in the category class
291
-        Smartfaq\Utility::saveCategoryPermissions($categoryObj->getGroups_read(), $categoryObj->categoryid(), 'category_read');
292
-        //Smartfaq\Utility::saveCategoryPermissions($groups_admin, $categoriesObj->categoryid(), 'category_admin');
267
+            // Groups and permissions
268
+            if (isset($_POST['groups_read'])) {
269
+                $categoryObj->setGroups_read($_POST['groups_read']);
270
+            } else {
271
+                $categoryObj->setGroups_read();
272
+            }
273
+            //  $groups_admin = isset($_POST['groups_admin'])? $_POST['groups_admin'] : array();
274
+            //  $mod_perms = isset($_POST['mod_perms'])? $_POST['mod_perms'] : array();
275
+
276
+            $categoryObj->setVar('name', $_POST['name']);
277
+
278
+            $categoryObj->setVar('description', $_POST['description']);
279
+            if ($categoryObj->isNew()) {
280
+                $redirect_msg = _AM_SF_CATCREATED;
281
+                $redirect_to  = 'category.php?op=mod';
282
+            } else {
283
+                $redirect_msg = _AM_SF_COLMODIFIED;
284
+                $redirect_to  = 'category.php';
285
+            }
293 286
 
294
-        if ($applyall) {
287
+            if (!$categoryObj->store()) {
288
+                redirect_header('javascript:history.go(-1)', 3, _AM_SF_CATEGORY_SAVE_ERROR . Smartfaq\Utility::formatErrors($categoryObj->getErrors()));
289
+            }
295 290
             // TODO : put this function in the category class
296
-            Smartfaq\Utility::overrideFaqsPermissions($categoryObj->getGroups_read(), $categoryObj->categoryid());
297
-        }
291
+            Smartfaq\Utility::saveCategoryPermissions($categoryObj->getGroups_read(), $categoryObj->categoryid(), 'category_read');
292
+            //Smartfaq\Utility::saveCategoryPermissions($groups_admin, $categoriesObj->categoryid(), 'category_admin');
298 293
 
299
-        redirect_header($redirect_to, 2, $redirect_msg);
300
-        break;
294
+            if ($applyall) {
295
+                // TODO : put this function in the category class
296
+                Smartfaq\Utility::overrideFaqsPermissions($categoryObj->getGroups_read(), $categoryObj->categoryid());
297
+            }
301 298
 
302
-    case 'del':
303
-        global $xoopsUser, $xoopsUser, $xoopsConfig, $xoopsDB, $_GET;
299
+            redirect_header($redirect_to, 2, $redirect_msg);
300
+            break;
304 301
 
305
-        $module_id    = $xoopsModule->getVar('mid');
306
-        $gpermHandler = xoops_getHandler('groupperm');
302
+        case 'del':
303
+            global $xoopsUser, $xoopsUser, $xoopsConfig, $xoopsDB, $_GET;
307 304
 
308
-        $categoryid = \Xmf\Request::getInt('categoryid', 0, 'POST');
309
-        $categoryid = \Xmf\Request::getInt('categoryid', $categoryid, 'GET');
305
+            $module_id    = $xoopsModule->getVar('mid');
306
+            $gpermHandler = xoops_getHandler('groupperm');
310 307
 
311
-        $categoryObj = new Smartfaq\Category($categoryid);
308
+            $categoryid = \Xmf\Request::getInt('categoryid', 0, 'POST');
309
+            $categoryid = \Xmf\Request::getInt('categoryid', $categoryid, 'GET');
312 310
 
313
-        $confirm = \Xmf\Request::getInt('confirm', 0, POST);
314
-        $name    = \Xmf\Request::getString('name', '', 'POST');
311
+            $categoryObj = new Smartfaq\Category($categoryid);
315 312
 
316
-        if ($confirm) {
317
-            if (!$categoryHandler->delete($categoryObj)) {
318
-                redirect_header('category.php', 1, _AM_SF_DELETE_CAT_ERROR);
313
+            $confirm = \Xmf\Request::getInt('confirm', 0, POST);
314
+            $name    = \Xmf\Request::getString('name', '', 'POST');
315
+
316
+            if ($confirm) {
317
+                if (!$categoryHandler->delete($categoryObj)) {
318
+                    redirect_header('category.php', 1, _AM_SF_DELETE_CAT_ERROR);
319
+                }
320
+                redirect_header('category.php', 1, sprintf(_AM_SF_COLISDELETED, $name));
321
+            } else {
322
+                // no confirm: show deletion condition
323
+                $categoryid = \Xmf\Request::getInt('categoryid', 0, 'GET');
324
+                xoops_cp_header();
325
+                xoops_confirm([
326
+                                  'op'         => 'del',
327
+                                  'categoryid' => $categoryObj->categoryid(),
328
+                                  'confirm'    => 1,
329
+                                  'name'       => $categoryObj->name()
330
+                              ], 'category.php', _AM_SF_DELETECOL . " '" . $categoryObj->name() . "'. <br> <br>" . _AM_SF_DELETE_CAT_CONFIRM, _AM_SF_DELETE);
331
+                xoops_cp_footer();
319 332
             }
320
-            redirect_header('category.php', 1, sprintf(_AM_SF_COLISDELETED, $name));
321
-        } else {
322
-            // no confirm: show deletion condition
323
-            $categoryid = \Xmf\Request::getInt('categoryid', 0, 'GET');
333
+            exit();
334
+            break;
335
+
336
+        case 'cancel':
337
+            redirect_header('category.php', 1, sprintf(_AM_SF_BACK2IDX, ''));
338
+            break;
339
+        case 'default':
340
+        default:
341
+            $adminObject = \Xmf\Module\Admin::getInstance();
324 342
             xoops_cp_header();
325
-            xoops_confirm([
326
-                              'op'         => 'del',
327
-                              'categoryid' => $categoryObj->categoryid(),
328
-                              'confirm'    => 1,
329
-                              'name'       => $categoryObj->name()
330
-                          ], 'category.php', _AM_SF_DELETECOL . " '" . $categoryObj->name() . "'. <br> <br>" . _AM_SF_DELETE_CAT_CONFIRM, _AM_SF_DELETE);
331
-            xoops_cp_footer();
332
-        }
333
-        exit();
334
-        break;
335
-
336
-    case 'cancel':
337
-        redirect_header('category.php', 1, sprintf(_AM_SF_BACK2IDX, ''));
338
-        break;
339
-    case 'default':
340
-    default:
341
-        $adminObject = \Xmf\Module\Admin::getInstance();
342
-        xoops_cp_header();
343
-
344
-        $adminObject->displayNavigation(basename(__FILE__));
345
-        echo "<br>\n";
346 343
 
347
-        // Creating the objects for top categories
348
-        $categoriesObj =& $categoryHandler->getCategories($helper->getConfig('perpage'), $startcategory, 0);
349
-
350
-        Smartfaq\Utility::collapsableBar('toptable', 'toptableicon');
351
-        echo "<img id='toptableicon' src=" . XOOPS_URL . '/modules/' . $xoopsModule->dirname() . "/assets/images/icon/close12.gif alt=''></a>&nbsp;" . _AM_SF_CATEGORIES_TITLE . '</h3>';
352
-        echo "<div id='toptable'>";
353
-        echo '<span style="color: #567; margin: 3px 0 12px 0; font-size: small; display: block; ">' . _AM_SF_CATEGORIES_DSC . '</span>';
354
-
355
-        echo "<table width='100%' cellspacing=1 cellpadding=3 border=0 class = outer>";
356
-        echo '<tr>';
357
-        echo "<th width='35%' class='bg3' align='left'><b>" . _AM_SF_ARTCOLNAME . '</b></td>';
358
-        echo "<th class='bg3' align='left'><b>" . _AM_SF_DESCRIP . '</b></td>';
359
-        echo "<th class='bg3' width='65' align='center'><b>" . _AM_SF_WEIGHT . '</b></td>';
360
-        echo "<th width='60' class='bg3' align='center'><b>" . _AM_SF_ACTION . '</b></td>';
361
-        echo '</tr>';
362
-        $totalCategories = $categoryHandler->getCategoriesCount(0);
363
-        if (count($categoriesObj) > 0) {
364
-            foreach ($categoriesObj as $key => $thiscat) {
365
-                displayCategory($thiscat);
366
-            }
367
-        } else {
344
+            $adminObject->displayNavigation(basename(__FILE__));
345
+            echo "<br>\n";
346
+
347
+            // Creating the objects for top categories
348
+            $categoriesObj =& $categoryHandler->getCategories($helper->getConfig('perpage'), $startcategory, 0);
349
+
350
+            Smartfaq\Utility::collapsableBar('toptable', 'toptableicon');
351
+            echo "<img id='toptableicon' src=" . XOOPS_URL . '/modules/' . $xoopsModule->dirname() . "/assets/images/icon/close12.gif alt=''></a>&nbsp;" . _AM_SF_CATEGORIES_TITLE . '</h3>';
352
+            echo "<div id='toptable'>";
353
+            echo '<span style="color: #567; margin: 3px 0 12px 0; font-size: small; display: block; ">' . _AM_SF_CATEGORIES_DSC . '</span>';
354
+
355
+            echo "<table width='100%' cellspacing=1 cellpadding=3 border=0 class = outer>";
368 356
             echo '<tr>';
369
-            echo "<td class='head' align='center' colspan= '7'>" . _AM_SF_NOCAT . '</td>';
357
+            echo "<th width='35%' class='bg3' align='left'><b>" . _AM_SF_ARTCOLNAME . '</b></td>';
358
+            echo "<th class='bg3' align='left'><b>" . _AM_SF_DESCRIP . '</b></td>';
359
+            echo "<th class='bg3' width='65' align='center'><b>" . _AM_SF_WEIGHT . '</b></td>';
360
+            echo "<th width='60' class='bg3' align='center'><b>" . _AM_SF_ACTION . '</b></td>';
370 361
             echo '</tr>';
371
-            $categoryid = '0';
372
-        }
373
-        echo "</table>\n";
374
-        require_once XOOPS_ROOT_PATH . '/class/pagenav.php';
375
-        $pagenav = new \XoopsPageNav($totalCategories, $helper->getConfig('perpage'), $startcategory, 'startcategory');
376
-        echo '<div style="text-align:right;">' . $pagenav->renderNav() . '</div>';
377
-        echo '</div>';
362
+            $totalCategories = $categoryHandler->getCategoriesCount(0);
363
+            if (count($categoriesObj) > 0) {
364
+                foreach ($categoriesObj as $key => $thiscat) {
365
+                    displayCategory($thiscat);
366
+                }
367
+            } else {
368
+                echo '<tr>';
369
+                echo "<td class='head' align='center' colspan= '7'>" . _AM_SF_NOCAT . '</td>';
370
+                echo '</tr>';
371
+                $categoryid = '0';
372
+            }
373
+            echo "</table>\n";
374
+            require_once XOOPS_ROOT_PATH . '/class/pagenav.php';
375
+            $pagenav = new \XoopsPageNav($totalCategories, $helper->getConfig('perpage'), $startcategory, 'startcategory');
376
+            echo '<div style="text-align:right;">' . $pagenav->renderNav() . '</div>';
377
+            echo '</div>';
378 378
 
379
-        editcat(false);
379
+            editcat(false);
380 380
 
381
-        break;
381
+            break;
382 382
 }
383 383
 
384 384
 require_once __DIR__ . '/admin_footer.php';
Please login to merge, or discard this patch.
request.php 1 patch
Switch Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -51,94 +51,94 @@
 block discarded – undo
51 51
 }
52 52
 
53 53
 switch ($op) {
54
-    case 'post':
54
+        case 'post':
55 55
 
56
-        global $xoopsUser, $xoopsConfig, $xoopsModule, $xoopsDB;
56
+            global $xoopsUser, $xoopsConfig, $xoopsModule, $xoopsDB;
57 57
 
58
-        $newFaqObj = $faqHandler->create();
58
+            $newFaqObj = $faqHandler->create();
59 59
 
60
-        if (!$xoopsUser) {
61
-            if (1 == $helper->getConfig('anonpost')) {
62
-                $uid = 0;
60
+            if (!$xoopsUser) {
61
+                if (1 == $helper->getConfig('anonpost')) {
62
+                    $uid = 0;
63
+                } else {
64
+                    redirect_header('index.php', 3, _NOPERM);
65
+                }
63 66
             } else {
64
-                redirect_header('index.php', 3, _NOPERM);
67
+                $uid = $xoopsUser->uid();
65 68
             }
66
-        } else {
67
-            $uid = $xoopsUser->uid();
68
-        }
69
-
70
-        // Putting the values about the FAQ in the FAQ object
71
-        $newFaqObj->setVar('categoryid', $_POST['categoryid']);
72
-        $newFaqObj->setVar('uid', $uid);
73
-        $newFaqObj->setVar('question', $_POST['question']);
74
-        $notifypub = \Xmf\Request::getInt('notifypub', 0, POST);
75
-        $newFaqObj->setVar('notifypub', $notifypub);
76
-
77
-        // Setting the status of the FAQ
78
-        if (1 == $helper->getConfig('autoapprove_request')) {
79
-            $newFaqObj->setVar('status', Constants::SF_STATUS_OPENED);
80
-        } else {
81
-            $newFaqObj->setVar('status', Constants::SF_STATUS_ASKED);
82
-        }
83
-
84
-        // Storing the FAQ object in the database
85
-        if (!$newFaqObj->store()) {
86
-            redirect_header('javascript:history.go(-1)', 3, _MD_SF_REQUEST_ERROR . Smartfaq\Utility::formatErrors($newFaqObj->getErrors()));
87
-        }
88
-
89
-        // Get the cateopry object related to that FAQ
90
-        // If autoapprove_requested
91
-        if (1 == $helper->getConfig('autoapprove_request')) {
92
-            // We do not not subscribe user to notification on publish since we publish it right away
93
-
94
-            // Send notifications
95
-            $newFaqObj->sendNotifications([Constants::SF_NOT_QUESTION_PUBLISHED]);
96
-
97
-            $redirect_msg = _MD_SF_REQUEST_RECEIVED_AND_PUBLISHED;
98
-        } else {
99
-            // Subscribe the user to On Published notification, if requested
100
-            if (1 == $notifypub) {
101
-                require_once XOOPS_ROOT_PATH . '/include/notification_constants.php';
102
-                $notificationHandler = xoops_getHandler('notification');
103
-                $notificationHandler->subscribe('question', $newFaqObj->faqid(), 'approved', XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE);
69
+
70
+            // Putting the values about the FAQ in the FAQ object
71
+            $newFaqObj->setVar('categoryid', $_POST['categoryid']);
72
+            $newFaqObj->setVar('uid', $uid);
73
+            $newFaqObj->setVar('question', $_POST['question']);
74
+            $notifypub = \Xmf\Request::getInt('notifypub', 0, POST);
75
+            $newFaqObj->setVar('notifypub', $notifypub);
76
+
77
+            // Setting the status of the FAQ
78
+            if (1 == $helper->getConfig('autoapprove_request')) {
79
+                $newFaqObj->setVar('status', Constants::SF_STATUS_OPENED);
80
+            } else {
81
+                $newFaqObj->setVar('status', Constants::SF_STATUS_ASKED);
82
+            }
83
+
84
+            // Storing the FAQ object in the database
85
+            if (!$newFaqObj->store()) {
86
+                redirect_header('javascript:history.go(-1)', 3, _MD_SF_REQUEST_ERROR . Smartfaq\Utility::formatErrors($newFaqObj->getErrors()));
104 87
             }
105
-            // Send notifications
106
-            $newFaqObj->sendNotifications([Constants::SF_NOT_QUESTION_SUBMITTED]);
107 88
 
108
-            $redirect_msg = _MD_SF_REQUEST_RECEIVED_NEED_APPROVAL;
109
-        }
89
+            // Get the cateopry object related to that FAQ
90
+            // If autoapprove_requested
91
+            if (1 == $helper->getConfig('autoapprove_request')) {
92
+                // We do not not subscribe user to notification on publish since we publish it right away
93
+
94
+                // Send notifications
95
+                $newFaqObj->sendNotifications([Constants::SF_NOT_QUESTION_PUBLISHED]);
96
+
97
+                $redirect_msg = _MD_SF_REQUEST_RECEIVED_AND_PUBLISHED;
98
+            } else {
99
+                // Subscribe the user to On Published notification, if requested
100
+                if (1 == $notifypub) {
101
+                    require_once XOOPS_ROOT_PATH . '/include/notification_constants.php';
102
+                    $notificationHandler = xoops_getHandler('notification');
103
+                    $notificationHandler->subscribe('question', $newFaqObj->faqid(), 'approved', XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE);
104
+                }
105
+                // Send notifications
106
+                $newFaqObj->sendNotifications([Constants::SF_NOT_QUESTION_SUBMITTED]);
107
+
108
+                $redirect_msg = _MD_SF_REQUEST_RECEIVED_NEED_APPROVAL;
109
+            }
110 110
 
111
-        //redirect_header("javascript:history.go(-2)", 3, $redirect_msg);
112
-        redirect_header('index.php', 2, $redirect_msg);
113
-        break;
111
+            //redirect_header("javascript:history.go(-2)", 3, $redirect_msg);
112
+            redirect_header('index.php', 2, $redirect_msg);
113
+            break;
114 114
 
115
-    case 'form':
116
-    default:
115
+        case 'form':
116
+        default:
117 117
 
118
-        global $xoopsUser, $myts;
118
+            global $xoopsUser, $myts;
119 119
 
120
-        $GLOBALS['xoopsOption']['template_main'] = 'smartfaq_submit.tpl';
121
-        require_once XOOPS_ROOT_PATH . '/header.php';
122
-        require_once __DIR__ . '/footer.php';
120
+            $GLOBALS['xoopsOption']['template_main'] = 'smartfaq_submit.tpl';
121
+            require_once XOOPS_ROOT_PATH . '/header.php';
122
+            require_once __DIR__ . '/footer.php';
123 123
 
124
-        $name = $xoopsUser ? ucwords($xoopsUser->getVar('uname')) : 'Anonymous';
124
+            $name = $xoopsUser ? ucwords($xoopsUser->getVar('uname')) : 'Anonymous';
125 125
 
126
-        $moduleName =& $myts->displayTarea($xoopsModule->getVar('name'));
127
-        $xoopsTpl->assign('whereInSection', $moduleName);
128
-        $xoopsTpl->assign('lang_submit', _MD_SF_REQUEST);
126
+            $moduleName =& $myts->displayTarea($xoopsModule->getVar('name'));
127
+            $xoopsTpl->assign('whereInSection', $moduleName);
128
+            $xoopsTpl->assign('lang_submit', _MD_SF_REQUEST);
129 129
 
130
-        $xoopsTpl->assign('lang_intro_title', _MD_SF_REQUEST);
131
-        $xoopsTpl->assign('lang_intro_text', _MD_SF_GOODDAY . "<b>$name</b>, " . $myts->displayTarea($helper->getConfig('requestintromsg')));
130
+            $xoopsTpl->assign('lang_intro_title', _MD_SF_REQUEST);
131
+            $xoopsTpl->assign('lang_intro_text', _MD_SF_GOODDAY . "<b>$name</b>, " . $myts->displayTarea($helper->getConfig('requestintromsg')));
132 132
 
133
-        require_once __DIR__ . '/include/request.inc.php';
133
+            require_once __DIR__ . '/include/request.inc.php';
134 134
 
135
-        $name = $xoopsUser ? ucwords($xoopsUser->getVar('uname')) : 'Anonymous';
135
+            $name = $xoopsUser ? ucwords($xoopsUser->getVar('uname')) : 'Anonymous';
136 136
 
137
-        $sectionname = $myts->htmlSpecialChars($xoopsModule->getVar('name'));
137
+            $sectionname = $myts->htmlSpecialChars($xoopsModule->getVar('name'));
138 138
 
139
-        require_once __DIR__ . '/include/request.inc.php';
139
+            require_once __DIR__ . '/include/request.inc.php';
140 140
 
141
-        require_once XOOPS_ROOT_PATH . '/footer.php';
141
+            require_once XOOPS_ROOT_PATH . '/footer.php';
142 142
 
143
-        break;
143
+            break;
144 144
 }
Please login to merge, or discard this patch.