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 | * @param $options |
||
| 8 | * @return array |
||
| 9 | */ |
||
| 10 | // defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); |
||
|
0 ignored issues
–
show
|
|||
| 11 | |||
| 12 | function b_faqs_recent_show($options) |
||
| 13 | { |
||
| 14 | include_once(XOOPS_ROOT_PATH . '/modules/smartfaq/include/functions.php'); |
||
| 15 | $myts = MyTextSanitizer::getInstance(); |
||
| 16 | |||
| 17 | $smartModule = sf_getModuleInfo(); |
||
| 18 | $smartModuleConfig = sf_getModuleConfig(); |
||
| 19 | |||
| 20 | $block = array(); |
||
| 21 | |||
| 22 | View Code Duplication | if ($options[0] == 0) { |
|
| 23 | $categoryid = -1; |
||
| 24 | } else { |
||
| 25 | $categoryid = $options[0]; |
||
| 26 | } |
||
| 27 | |||
| 28 | $sort = $options[1]; |
||
| 29 | $limit = $options[2]; |
||
| 30 | $maxQuestionLength = $options[3]; |
||
| 31 | |||
| 32 | // Creating the faq handler object |
||
| 33 | $faqHandler = sf_gethandler('faq'); |
||
| 34 | |||
| 35 | // Creating the category handler object |
||
| 36 | $categoryHandler = sf_gethandler('category'); |
||
| 37 | |||
| 38 | // Creating the last FAQs |
||
| 39 | $faqsObj = $faqHandler->getAllPublished($limit, 0, $categoryid, $sort); |
||
| 40 | $allcategories = $categoryHandler->getObjects(null, true); |
||
| 41 | if ($faqsObj) { |
||
| 42 | $userids = array(); |
||
| 43 | foreach ($faqsObj as $key => $thisfaq) { |
||
| 44 | $faqids[] = $thisfaq->getVar('faqid'); |
||
| 45 | $userids[$thisfaq->uid()] = 1; |
||
| 46 | } |
||
| 47 | $answerHandler = sf_gethandler('answer'); |
||
| 48 | $allanswers = $answerHandler->getLastPublishedByFaq($faqids); |
||
| 49 | |||
| 50 | foreach ($allanswers as $key => $thisanswer) { |
||
| 51 | $userids[$thisanswer->uid()] = 1; |
||
| 52 | } |
||
| 53 | |||
| 54 | $memberHandler = xoops_getHandler('member'); |
||
| 55 | $users = $memberHandler->getUsers(new Criteria('uid', '(' . implode(',', array_keys($userids)) . ')', 'IN'), true); |
||
| 56 | for ($i = 0, $iMax = count($faqsObj); $i < $iMax; ++$i) { |
||
| 57 | $faqs['categoryid'] = $faqsObj[$i]->categoryid(); |
||
| 58 | $faqs['question'] = $faqsObj[$i]->question($maxQuestionLength); |
||
| 59 | $faqs['faqid'] = $faqsObj[$i]->faqid(); |
||
| 60 | $faqs['categoryname'] = $allcategories[$faqsObj[$i]->categoryid()]->getVar('name'); |
||
| 61 | |||
| 62 | // Creating the answer object |
||
| 63 | $answerObj =& $allanswers[$faqsObj[$i]->faqid()]; |
||
| 64 | |||
| 65 | $faqs['date'] = $faqsObj[$i]->datesub(); |
||
| 66 | |||
| 67 | $faqs['poster'] = sf_getLinkedUnameFromId($answerObj->uid(), $smartModuleConfig['userealname'], $users); |
||
| 68 | |||
| 69 | $block['faqs'][] = $faqs; |
||
| 70 | } |
||
| 71 | |||
| 72 | $block['lang_question'] = _MB_SF_FAQS; |
||
| 73 | $block['lang_category'] = _MB_SF_CATEGORY; |
||
| 74 | $block['lang_poster'] = _MB_SF_ANSWEREDBY; |
||
| 75 | $block['lang_date'] = _MB_SF_DATE; |
||
| 76 | $modulename = $myts->htmlSpecialChars($smartModule->getVar('name')); |
||
| 77 | $block['lang_visitfaq'] = _MB_SF_VISITFAQ . ' ' . $modulename; |
||
| 78 | } |
||
| 79 | |||
| 80 | return $block; |
||
| 81 | } |
||
| 82 | |||
| 83 | /** |
||
| 84 | * @param $options |
||
| 85 | * @return string |
||
| 86 | */ |
||
| 87 | function b_faqs_recent_edit($options) |
||
| 88 | { |
||
| 89 | include_once(XOOPS_ROOT_PATH . '/modules/smartfaq/include/functions.php'); |
||
| 90 | |||
| 91 | $form = sf_createCategorySelect($options[0]); |
||
| 92 | |||
| 93 | $form .= ' <br>' . _MB_SF_ORDER . " <select name='options[]'>"; |
||
| 94 | |||
| 95 | $form .= "<option value='datesub'"; |
||
| 96 | if ($options[1] === 'datesub') { |
||
| 97 | $form .= " selected='selected'"; |
||
| 98 | } |
||
| 99 | $form .= '>' . _MB_SF_DATE . "</option>\n"; |
||
| 100 | |||
| 101 | $form .= "<option value='counter'"; |
||
| 102 | if ($options[1] === 'counter') { |
||
| 103 | $form .= " selected='selected'"; |
||
| 104 | } |
||
| 105 | $form .= '>' . _MB_SF_HITS . "</option>\n"; |
||
| 106 | |||
| 107 | $form .= "<option value='weight'"; |
||
| 108 | if ($options[1] === 'weight') { |
||
| 109 | $form .= " selected='selected'"; |
||
| 110 | } |
||
| 111 | $form .= '>' . _MB_SF_WEIGHT . "</option>\n"; |
||
| 112 | |||
| 113 | $form .= "</select>\n"; |
||
| 114 | |||
| 115 | $form .= ' ' . _MB_SF_DISP . " <input type='text' name='options[]' value='" . $options[2] . "' /> " . _MB_SF_FAQS . ''; |
||
| 116 | $form .= ' <br>' . _MB_SF_CHARS . " <input type='text' name='options[]' value='" . $options[3] . "' /> " . _MB_SF_LENGTH . ''; |
||
| 117 | |||
| 118 | return $form; |
||
| 119 | } |
||
| 120 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.