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