function answer() { $answer_handler = new sfAnswerHandler($this->db); switch ($this->status()) { case _SF_STATUS_SUBMITTED: $theAnswers =& $answer_handler->getAllAnswers($this->faqid(), _SF_AN_STATUS_APPROVED, 1, 0); //echo "test"; //exit; $this->_answer =& $theAnswers[0]; break; case _SF_STATUS_ANSWERED: $theAnswers =& $answer_handler->getAllAnswers($this->faqid(), _SF_AN_STATUS_PROPOSED, 1, 0); //echo "test"; //exit; $this->_answer =& $theAnswers[0]; break; case _SF_STATUS_PUBLISHED: case _SF_STATUS_NEW_ANSWER: case _SF_STATUS_OFFLINE: $this->_answer =& $answer_handler->getOfficialAnswer($this->faqid()); break; case _SF_STATUS_ASKED: $this->_answer =& $answer_handler->create(); case _SF_STATUS_OPENED: $this->_answer =& $answer_handler->create(); break; } if ($this->_answer) { $this->_answer->setVar('dohtml', $this->getVar('html')); $this->_answer->setVar('doxcode', $this->getVar('xcodes')); $this->_answer->setVar('dosmiley', $this->getVar('smiley')); $this->_answer->setVar('doimage', $this->getVar('image')); $this->_answer->setVar('dobr', $this->getVar('linebreak')); } return $this->_answer; }
// Send answer notifications if (!empty($notifToDo_answer)) { $answerObj->sendNotifications($notifToDo_answer); } redirect_header("index.php", 2, $redirect_msg); exit; break; case "del": global $xoopsUser, $xoopsUser, $xoopsConfig, $xoopsDB; $faqid = isset($_POST['faqid']) ? intval($_POST['faqid']) : 0; $faqid = isset($_GET['faqid']) ? intval($_GET['faqid']) : $faqid; $answerid = isset($_POST['answerid']) ? intval($_POST['answerid']) : 0; $answerid = isset($_GET['answerid']) ? intval($_GET['answerid']) : $answerid; $confirm = isset($_POST['confirm']) ? intval($_POST['confirm']) : 0; $faqObj = new sfFaq($faqid); $answerObj = new sfAnswer($answerid); if ($confirm) { $answerObj->setVar('status', _SF_AN_STATUS_REJECTED); $answerObj->store(); switch ($faqObj->status()) { // Open Question for which we are rejecting an answer case _SF_STATUS_ANSWERED: $redirect_page = "index.php"; $redirect_msg = _AM_SF_ANSWER_REJECTED_OPEN_QUESTION; $faqObj->setVar('status', _SF_STATUS_OPENED); break; case _SF_STATUS_NEW_ANSWER: $proposed_answers = $answer_handler->getAllAnswers($faqid, _SF_AN_STATUS_PROPOSED); if (count($proposed_answers) > 0) { // This question has other proposed answer $redirect_page = "answer.php?op=mod&faqid=" . $faqid;
function getLastPublishedByFaq($faqids) { $ret = array(); $sql = "SELECT faqid, answer, uid, datesub FROM " . $this->db->prefix("smartfaq_answers") . "\r\n\t WHERE faqid IN (" . implode(',', $faqids) . ") AND status = " . _SF_AN_STATUS_APPROVED . " GROUP BY faqid"; $result = $this->db->query($sql); if (!$result) { return $ret; } while ($row = $this->db->fetchArray($result)) { $answer = new sfAnswer(); $answer->assignVars($row); $ret[$row['faqid']] =& $answer; unset($answer); } return $ret; }
function editfaq($showmenu = false, $faqid = -1, $answerid = -1, $merge = false) { global $answer_handler, $faq_handler, $category_handler, $xoopsUser, $xoopsUser, $xoopsConfig, $xoopsDB, $modify, $xoopsModuleConfig, $xoopsModule, $XOOPS_URL, $myts; include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; // If there is a parameter, and the id exists, retrieve data: we're editing a faq if ($faqid != -1) { // Creating the FAQ object $faqObj = new sfFaq($faqid); if ($faqObj->notLoaded()) { redirect_header("faq.php", 1, _AM_SF_NOFAQSELECTED); exit; } if ($answerid == -1) { // Creating the object for the official answer $answerObj =& $faqObj->answer(); if (!$answerObj) { $answerObj = $answer_handler->create(); } } else { $answerObj = new sfAnswer($answerid); $originalAnswerObj =& $faqObj->answer(); } switch ($faqObj->status()) { case _SF_STATUS_ASKED: $breadcrumb_action1 = _AM_SF_ASKED; $breadcrumb_action2 = _AM_SF_APPROVING; $collapsableBar_title = _AM_SF_ASKED_TITLE; $collapsableBar_info = _AM_SF_ASKED_TITLE_INFO; $button_caption = _AM_SF_PUBLISHED; $an_status = _SF_AN_STATUS_APPROVED; $answerObj->setVar('uid', $xoopsUser->getVar('uid')); break; case _SF_STATUS_ANSWERED: $breadcrumb_action1 = _AM_SF_ANSWERED; $breadcrumb_action2 = _AM_SF_APPROVING; $collapsableBar_title = _AM_SF_ANSWERED_TITLE; $collapsableBar_info = _AM_SF_ANSWERED_TITLE_INFO; $button_caption = _AM_SF_APPROVE; $an_status = _SF_AN_STATUS_PROPOSED; break; case _SF_STATUS_SUBMITTED: $breadcrumb_action1 = _AM_SF_SUBMITTED; $breadcrumb_action2 = _AM_SF_APPROVING; $collapsableBar_title = _AM_SF_SUBMITTED_TITLE; $collapsableBar_info = _AM_SF_SUBMITTED_INFO; $button_caption = _AM_SF_APPROVE; $an_status = _SF_AN_STATUS_PROPOSED; break; case _SF_STATUS_PUBLISHED: $breadcrumb_action1 = _AM_SF_PUBLISHED; $breadcrumb_action2 = _AM_SF_EDITING; $collapsableBar_title = _AM_SF_PUBLISHEDEDITING; $collapsableBar_info = _AM_SF_PUBLISHEDEDITING_INFO; $button_caption = _AM_SF_MODIFY; $an_status = _SF_AN_STATUS_APPROVED; break; case _SF_STATUS_OFFLINE: $breadcrumb_action1 = _AM_SF_OFFLINE; $breadcrumb_action2 = _AM_SF_EDITING; $collapsableBar_title = _AM_SF_OFFLINEEDITING; $collapsableBar_info = _AM_SF_OFFLINEEDITING_INFO; $button_caption = _AM_SF_MODIFY; $an_status = _SF_AN_STATUS_APPROVED; break; case _SF_STATUS_OPENED: $breadcrumb_action1 = _AM_SF_OPEN_QUESTIONS; $breadcrumb_action2 = _AM_SF_ANSWERING; $collapsableBar_title = _AM_SF_OPEN_QUESTION_ANSWERING; $collapsableBar_info = _AM_SF_OPEN_QUESTION_ANSWERING_INFO; $button_caption = _AM_SF_PUBLISH; $an_status = _SF_AN_STATUS_NOTSET; $answerObj->setVar('uid', $xoopsUser->getVar('uid')); break; case _SF_STATUS_NEW_ANSWER: $breadcrumb_action1 = _AM_SF_PUBLISHED; $breadcrumb_action2 = _AM_SF_EDITING; $collapsableBar_title = _AM_SF_NEW_ANSWER_EDITING; $collapsableBar_info = _AM_SF_NEW_ANSWER_EDITING_INFO; $button_caption = _AM_SF_PUBLISH; $an_status = _SF_AN_STATUS_NOTSET; break; case "default": default: break; } /* if (!$answerObj) { redirect_header("faq.php", 2, _AM_SF_ANSWERNOTFOUND); exit(); } */ // Creating the category of this FAQ $categoryObj =& $faqObj->category(); if ($showmenu) { sf_adminMenu(2, $breadcrumb_action1 . " > " . $breadcrumb_action2); } echo "<br />\n"; sf_collapsableBar('bottomtable', 'bottomtableicon'); echo "<img id='bottomtableicon' src=" . XOOPS_URL . "/modules/" . $xoopsModule->dirname() . "/images/icon/close12.gif alt='' /></a> " . $collapsableBar_title . "</h3>"; echo "<div id='bottomtable'>"; echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . $collapsableBar_info . "</span>"; } else { // there's no parameter, so we're adding a faq $faqObj =& $faq_handler->create(); $faqObj->setVar('uid', $xoopsUser->getVar('uid')); $categoryObj =& $category_handler->create(); $answerObj =& $answer_handler->create(); $answerObj->setVar('uid', $xoopsUser->getVar('uid')); $breadcrumb_action1 = _AM_SF_SMARTFAQS; $breadcrumb_action2 = _AM_SF_CREATINGNEW; $button_caption = _AM_SF_CREATE; if ($showmenu) { sf_adminMenu(2, $breadcrumb_action1 . " > " . $breadcrumb_action2); } sf_collapsableBar('bottomtable', 'bottomtableicon'); echo "<img id='bottomtableicon' src=" . XOOPS_URL . "/modules/" . $xoopsModule->dirname() . "/images/icon/close12.gif alt='' /></a> " . _AM_SF_CREATESMARTFAQ . "</h3>"; echo "<div id='bottomtable'>"; } $sform = new XoopsThemeForm(_AM_SF_SMARTFAQ, "op", xoops_getenv('PHP_SELF')); $sform->setExtra('enctype="multipart/form-data"'); // faq requester $sform->addElement(new XoopsFormLabel(_AM_SF_REQUESTED_BY, sf_getLinkedUnameFromId($faqObj->uid(), $xoopsModuleConfig['userealname']))); // faq answered by $sform->addElement(new XoopsFormLabel(_AM_SF_ANSWERED_BY, sf_getLinkedUnameFromId($answerObj->uid(), $xoopsModuleConfig['userealname']))); // CATEGORY /* * Get information for pulldown menu using XoopsTree. * First var is the database table * Second var is the unique field ID for the categories * Last one is not set as we do not have sub menus in Smartfaq */ $mytree = new XoopsTree($xoopsDB->prefix("smartfaq_categories"), "categoryid", "parentid"); ob_start(); $mytree->makeMySelBox("name", "weight", $categoryObj->categoryid()); $sform->addElement(new XoopsFormLabel(_AM_SF_CATEGORY_FAQ, ob_get_contents())); ob_end_clean(); // faq QUESTION $sform->addElement(new XoopsFormTextArea(_AM_SF_QUESTION, 'question', $faqObj->question(0, 'e'), 7, 60)); // ANSWER if ($merge) { $theanswer = $originalAnswerObj->answer('e') . "\n\n" . sprintf(_AM_SF_NEW_CONTRIBUTION, sf_getLinkedUnameFromId($answerObj->uid(), $xoopsModuleConfig['userealname']), $answerObj->datesub(), $answerObj->answer('e')); } else { $theanswer = $answerObj->answer('e'); } $sform->addElement(new XoopsFormDhtmlTextArea(_AM_SF_ANSWER_FAQ, 'answer', $theanswer, 15, 60), true); // HOW DO I $sform->addElement(new XoopsFormText(_AM_SF_HOWDOI_FAQ, 'howdoi', 50, 255, $faqObj->howdoi('e')), false); // DIDUNO $sform->addElement(new XoopsFormTextArea(_AM_SF_DIDUNO_FAQ, 'diduno', $faqObj->diduno('e'), 3, 60)); // CONTEXT MODULE LINK // Retreive the list of module currently installed. The key value is the dirname $module_handler =& xoops_gethandler('module'); $modules_array = $module_handler->getList(null, true); $modulelink_select_array = array("url" => _AM_SF_SPECIFIC_URL_SELECT); $modulelink_select_array = array_merge($modules_array, $modulelink_select_array); $modulelink_select_array = array_merge(array("None" => _AM_SF_NONE, "All" => _AM_SF_ALL), $modulelink_select_array); $modulelink_select = new XoopsFormSelect('', 'modulelink', $faqObj->modulelink()); $modulelink_select->addOptionArray($modulelink_select_array); $modulelink_tray = new XoopsFormElementTray(_AM_SF_CONTEXTMODULELINK_FAQ, ' '); $modulelink_tray->addElement($modulelink_select); $sform->addElement($modulelink_tray); // SPECIFICURL $sform->addElement(new XoopsFormText(_AM_SF_SPECIFIC_URL, 'contextpage', 50, 60, $faqObj->contextpage()), false); // EXACT URL? $excaturl_radio = new XoopsFormRadioYN(_AM_SF_EXACTURL, 'exacturl', $faqObj->exacturl(), ' ' . _AM_SF_YES . '', ' ' . _AM_SF_NO . ''); $sform->addElement($excaturl_radio); // WEIGHT $sform->addElement(new XoopsFormText(_AM_SF_WEIGHT, 'weight', 5, 5, $faqObj->weight()), true); // COMMENTS // Code to allow comments $addcomments_radio = new XoopsFormRadioYN(_AM_SF_ALLOWCOMMENTS, 'cancomment', $faqObj->cancomment(), ' ' . _AM_SF_YES . '', ' ' . _AM_SF_NO . ''); $sform->addElement($addcomments_radio); // PER ITEM PERMISSIONS $member_handler =& xoops_gethandler('member'); $group_list =& $member_handler->getGroupList(); $groups_checkbox = new XoopsFormCheckBox(_AM_SF_PERMISSIONS_FAQ, 'groups[]', $faqObj->getGroups_read()); foreach ($group_list as $group_id => $group_name) { if ($group_id != XOOPS_GROUP_ADMIN) { $groups_checkbox->addOption($group_id, $group_name); } } $sform->addElement($groups_checkbox); $partial_view = new XoopsFormRadioYN(_AM_SF_PARTIALVIEW, 'partialview', $faqObj->partialview(), ' ' . _AM_SF_YES . '', ' ' . _AM_SF_NO . ''); $sform->addElement($partial_view); // VARIOUS OPTIONS $options_tray = new XoopsFormElementTray(_AM_SF_OPTIONS, '<br />'); $html_checkbox = new XoopsFormCheckBox('', 'html', $faqObj->html()); $html_checkbox->addOption(1, _AM_SF_DOHTML); $options_tray->addElement($html_checkbox); $smiley_checkbox = new XoopsFormCheckBox('', 'smiley', $faqObj->smiley()); $smiley_checkbox->addOption(1, _AM_SF_DOSMILEY); $options_tray->addElement($smiley_checkbox); $xcodes_checkbox = new XoopsFormCheckBox('', 'xcodes', $faqObj->xcodes()); $xcodes_checkbox->addOption(1, _AM_SF_DOXCODE); $options_tray->addElement($xcodes_checkbox); $sform->addElement($options_tray); // OFFLINE if ($faqObj->status() == _SF_STATUS_OFFLINE) { // Back OnLine $offline_radio = new XoopsFormRadioYN(_AM_SF_OFFLINE_FIELD, 'offline', 1, ' ' . _AM_SF_YES . '', ' ' . _AM_SF_NO . ''); $sform->addElement($offline_radio); } // faq ID $sform->addElement(new XoopsFormHidden('faqid', $faqObj->faqid())); // requester id $sform->addElement(new XoopsFormHidden('requester_uid', $faqObj->uid())); // answerer id $sform->addElement(new XoopsFormHidden('answerer_uid', $answerObj->uid())); // ANSWER ID $sform->addElement(new XoopsFormHidden('answerid', $answerObj->answerid())); $button_tray = new XoopsFormElementTray('', ''); $hidden = new XoopsFormHidden('op', 'addfaq'); $button_tray->addElement($hidden); $sform->addElement(new XoopsFormHidden('status', $faqObj->status())); // Setting the FAQ Status /* $status_select = new XoopsFormSelect('', 'status', $status); $status_select->addOptionArray(sf_getStatusArray()); $status_tray = new XoopsFormElementTray(_AM_SF_STATUS_EXP , ' '); $status_tray->addElement($status_select); $sform->addElement($status_tray); */ if (!$faqid) { // there's no faqid? Then it's a new faq // $button_tray -> addElement( new XoopsFormButton( '', 'mod', _AM_SF_CREATE, 'submit' ) ); $butt_create = new XoopsFormButton('', '', _AM_SF_CREATE, 'submit'); $butt_create->setExtra('onclick="this.form.elements.op.value=\'addfaq\'"'); $button_tray->addElement($butt_create); $butt_clear = new XoopsFormButton('', '', _AM_SF_CLEAR, 'reset'); $button_tray->addElement($butt_clear); $butt_cancel = new XoopsFormButton('', '', _AM_SF_CANCEL, 'button'); $butt_cancel->setExtra('onclick="history.go(-1)"'); $button_tray->addElement($butt_cancel); } else { // else, we're editing an existing faq // $button_tray -> addElement( new XoopsFormButton( '', 'mod', _AM_SF_MODIFY, 'submit' ) ); $butt_create = new XoopsFormButton('', '', $button_caption, 'submit'); $butt_create->setExtra('onclick="this.form.elements.op.value=\'addfaq\'"'); $button_tray->addElement($butt_create); $butt_cancel = new XoopsFormButton('', '', _AM_SF_CANCEL, 'button'); $butt_cancel->setExtra('onclick="history.go(-1)"'); $button_tray->addElement($butt_cancel); } $sform->addElement($button_tray); $sform->display(); echo "</div>"; unset($hidden); }