mambax7 /
smartfaq
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * Module: SmartFAQ |
||
| 5 | * Author: The SmartFactory <www.smartfactory.ca> |
||
| 6 | * Licence: GNU |
||
| 7 | */ |
||
| 8 | |||
| 9 | include_once __DIR__ . '/header.php'; |
||
| 10 | include_once XOOPS_ROOT_PATH . '/header.php'; |
||
| 11 | |||
| 12 | global $xoopsUser, $xoopsConfig, $xoopsModuleConfig, $xoopsModule; |
||
| 13 | |||
| 14 | // Creating the category handler object |
||
| 15 | $categoryHandler = sf_gethandler('category'); |
||
| 16 | |||
| 17 | // Creating the FAQ handler object |
||
| 18 | $faqHandler = sf_gethandler('faq'); |
||
| 19 | |||
| 20 | // Get the total number of categories |
||
| 21 | $totalCategories = count($categoryHandler->getCategories()); |
||
| 22 | |||
| 23 | if ($totalCategories == 0) { |
||
| 24 | redirect_header('index.php', 1, _AM_SF_NOCOLEXISTS); |
||
| 25 | } |
||
| 26 | |||
| 27 | // Find if the user is admin of the module |
||
| 28 | $isAdmin = sf_userIsAdmin(); |
||
| 29 | // If the user is not admin AND we don't allow user submission, exit |
||
| 30 | View Code Duplication | if (!($isAdmin |
|
| 31 | || (isset($xoopsModuleConfig['allowrequest']) |
||
| 32 | && $xoopsModuleConfig['allowrequest'] == 1 |
||
| 33 | && (is_object($xoopsUser) || (isset($xoopsModuleConfig['anonpost']) && $xoopsModuleConfig['anonpost'] == 1)))) |
||
| 34 | ) { |
||
| 35 | redirect_header('index.php', 1, _NOPERM); |
||
| 36 | } |
||
| 37 | |||
| 38 | $op = ''; |
||
| 39 | |||
| 40 | if (isset($_GET['op'])) { |
||
| 41 | $op = $_GET['op']; |
||
| 42 | } |
||
| 43 | if (isset($_POST['op'])) { |
||
| 44 | $op = $_POST['op']; |
||
| 45 | } |
||
| 46 | |||
| 47 | switch ($op) { |
||
| 48 | case 'post': |
||
| 49 | |||
| 50 | global $xoopsUser, $xoopsConfig, $xoopsModule, $xoopsModuleConfig, $xoopsDB; |
||
| 51 | |||
| 52 | $newFaqObj = $faqHandler->create(); |
||
| 53 | |||
| 54 | View Code Duplication | if (!$xoopsUser) { |
|
| 55 | if ($xoopsModuleConfig['anonpost'] == 1) { |
||
| 56 | $uid = 0; |
||
| 57 | } else { |
||
| 58 | redirect_header('index.php', 3, _NOPERM); |
||
| 59 | } |
||
| 60 | } else { |
||
| 61 | $uid = $xoopsUser->uid(); |
||
| 62 | } |
||
| 63 | |||
| 64 | // Putting the values about the FAQ in the FAQ object |
||
| 65 | $newFaqObj->setVar('categoryid', $_POST['categoryid']); |
||
| 66 | $newFaqObj->setVar('uid', $uid); |
||
| 67 | $newFaqObj->setVar('question', $_POST['question']); |
||
| 68 | $notifypub = isset($_POST['notifypub']) ? $_POST['notifypub'] : 0; |
||
| 69 | $newFaqObj->setVar('notifypub', $notifypub); |
||
| 70 | |||
| 71 | // Setting the status of the FAQ |
||
| 72 | if ($xoopsModuleConfig['autoapprove_request'] == 1) { |
||
| 73 | $newFaqObj->setVar('status', _SF_STATUS_OPENED); |
||
| 74 | } else { |
||
| 75 | $newFaqObj->setVar('status', _SF_STATUS_ASKED); |
||
| 76 | } |
||
| 77 | |||
| 78 | // Storing the FAQ object in the database |
||
| 79 | if (!$newFaqObj->store()) { |
||
| 80 | redirect_header('javascript:history.go(-1)', 3, _MD_SF_REQUEST_ERROR . sf_formatErrors($newFaqObj->getErrors())); |
||
| 81 | } |
||
| 82 | |||
| 83 | // Get the cateopry object related to that FAQ |
||
| 84 | // If autoapprove_requested |
||
| 85 | if ($xoopsModuleConfig['autoapprove_request'] == 1) { |
||
| 86 | // We do not not subscribe user to notification on publish since we publish it right away |
||
| 87 | |||
| 88 | // Send notifications |
||
| 89 | $newFaqObj->sendNotifications(array(_SF_NOT_QUESTION_PUBLISHED)); |
||
| 90 | |||
| 91 | $redirect_msg = _MD_SF_REQUEST_RECEIVED_AND_PUBLISHED; |
||
| 92 | View Code Duplication | } else { |
|
| 93 | // Subscribe the user to On Published notification, if requested |
||
| 94 | if ($notifypub == 1) { |
||
| 95 | include_once XOOPS_ROOT_PATH . '/include/notification_constants.php'; |
||
| 96 | $notificationHandler = xoops_getHandler('notification'); |
||
| 97 | $notificationHandler->subscribe('question', $newFaqObj->faqid(), 'approved', XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE); |
||
| 98 | } |
||
| 99 | // Send notifications |
||
| 100 | $newFaqObj->sendNotifications(array(_SF_NOT_QUESTION_SUBMITTED)); |
||
| 101 | |||
| 102 | $redirect_msg = _MD_SF_REQUEST_RECEIVED_NEED_APPROVAL; |
||
| 103 | } |
||
| 104 | |||
| 105 | //redirect_header("javascript:history.go(-2)", 3, $redirect_msg); |
||
| 106 | redirect_header('index.php', 2, $redirect_msg); |
||
| 107 | break; |
||
| 108 | |||
| 109 | case 'form': |
||
| 110 | default: |
||
| 111 | |||
| 112 | global $xoopsUser, $myts; |
||
| 113 | |||
| 114 | $GLOBALS['xoopsOption']['template_main'] = 'smartfaq_submit.tpl'; |
||
| 115 | include_once XOOPS_ROOT_PATH . '/header.php'; |
||
| 116 | include_once __DIR__ . '/footer.php'; |
||
| 117 | |||
| 118 | $name = $xoopsUser ? ucwords($xoopsUser->getVar('uname')) : 'Anonymous'; |
||
|
0 ignored issues
–
show
|
|||
| 119 | |||
| 120 | $moduleName =& $myts->displayTarea($xoopsModule->getVar('name')); |
||
| 121 | $xoopsTpl->assign('whereInSection', $moduleName); |
||
| 122 | $xoopsTpl->assign('lang_submit', _MD_SF_REQUEST); |
||
| 123 | |||
| 124 | $xoopsTpl->assign('lang_intro_title', _MD_SF_REQUEST); |
||
| 125 | $xoopsTpl->assign('lang_intro_text', _MD_SF_GOODDAY . "<b>$name</b>, " . $myts->displayTarea($xoopsModuleConfig['requestintromsg'])); |
||
| 126 | |||
| 127 | include_once __DIR__ . '/include/request.inc.php'; |
||
| 128 | |||
| 129 | $name = $xoopsUser ? ucwords($xoopsUser->getVar('uname')) : 'Anonymous'; |
||
|
0 ignored issues
–
show
|
|||
| 130 | |||
| 131 | $sectionname = $myts->htmlSpecialChars($xoopsModule->getVar('name')); |
||
| 132 | |||
| 133 | include_once __DIR__ . '/include/request.inc.php'; |
||
| 134 | |||
| 135 | include_once XOOPS_ROOT_PATH . '/footer.php'; |
||
| 136 | |||
| 137 | break; |
||
| 138 | } |
||
| 139 |
Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.