/** * Event: new_faq * Triggered after FAQ addition * @param xhelpTicket $ticket Ticket used as base for FAQ * @param xhelpFaq $faq FAQ that was added */ function new_faq($ticket, $faq) { global $xoopsUser; //Create a new solution from the supplied ticket / faq $hTicketSol =& xhelpGetHandler('ticketSolution'); $sol =& $hTicketSol->create(); $sol->setVar('ticketid', $ticket->getVar('id')); $sol->setVar('url', $faq->getVar('url')); $sol->setVar('title', $faq->getVar('subject')); $sol->setVar('uid', $xoopsUser->getVar('uid')); return $hTicketSol->addSolution($ticket, $sol); }
/** * storeFaq: store the FAQ in the application's specific database (required) * @param xhelpFaq $faq The faq to add * @return bool true (success) / false (failure) * @access public */ function storeFaq(&$faq) { global $xoopsUser; $uid = $xoopsUser->getVar('uid'); // Take xhelpFaq and create faq for smartfaq $hFaq =& sf_gethandler('faq'); $hAnswer =& sf_gethandler('answer'); $myFaq =& $hFaq->create(); $myAnswer =& $hAnswer->create(); // Creating the answer object //$faq->getVar('categories') is an array. If your application //only supports single categories use the first element //in the array $categories = $faq->getVar('categories'); $categories = intval($categories[0]); // Change array of categories to 1 category $myFaq->setVar('uid', $uid); $myFaq->setVar('question', $faq->getVar('problem')); $myFaq->setVar('datesub', time()); $myFaq->setVar('categoryid', $categories); $myFaq->setVar('status', _SF_STATUS_PUBLISHED); $ret = $hFaq->insert($myFaq); $faq->setVar('id', $myFaq->getVar('faqid')); if ($ret) { // If faq was stored, store answer // Trigger event for question being stored $myAnswer->setVar('status', _SF_AN_STATUS_APPROVED); $myAnswer->setVar('faqid', $myFaq->faqid()); $myAnswer->setVar('answer', $faq->getVar('solution')); $myAnswer->setVar('uid', $uid); $ret = $hAnswer->insert($myAnswer); } if ($ret) { // Set the new url for the saved FAQ $faq->setVar('url', $this->makeFaqUrl($faq)); // Trigger any module events $myFaq->sendNotifications(array(_SF_NOT_FAQ_PUBLISHED)); } return $ret; }
/** * Event: new_faq * Triggered after FAQ addition * @param xhelpTicket $ticket Ticket used as base for FAQ * @param xhelpFaq $faq FAQ that was added */ function new_faq($ticket, $faq) { global $xoopsUser; $logMessage =& $this->_hLog->create(); $logMessage->setVar('uid', $xoopsUser->getVar('uid')); $logMessage->setVar('ticketid', $ticket->getVar('id')); $logMessage->setVar('action', sprintf(_XHELP_LOG_NEWFAQ, $faq->getVar('subject'))); return $this->_hLog->insert($logMessage, true); }
/** * storeFaq: store the FAQ in the application's specific database (required) * @param xhelpFaq $faq The faq to add * @return bool true (success) / false (failure) * @access public */ function storeFaq(&$faq) { global $xoopsUser, $smartsection_item_handler; $uid = $xoopsUser->getVar('uid'); //fix for smartsectionItem::store assuming that smartsection handlers are globalized $GLOBALS['smartsection_item_handler'] =& smartsection_gethandler('item'); $GLOBALS['smartsection_category_handler'] =& smartsection_gethandler('category'); $ssConfig =& smartsection_getModuleConfig(); // Create page in smartsection from xhelpFAQ object $hSSItem =& smartsection_gethandler('item'); $itemObj =& $hSSItem->create(); //$faq->getVar('categories') is an array. If your application //only supports single categories use the first element //in the array $categories = $faq->getVar('categories'); $categories = intval($categories[0]); // Change array of categories to 1 category // Putting the values about the ITEM in the ITEM object $itemObj->setVar('categoryid', $categories); $itemObj->setVar('title', $faq->getVar('subject', 'e')); $itemObj->setVar('summary', '[b]' . ucfirst(_XHELP_TEXT_PROBLEM) . "[/b]\r\n" . $faq->getVar('problem', 'e')); $itemObj->setVar('body', '[b]' . ucfirst(_XHELP_TEXT_SOLUTION) . "[/b]\r\n" . $faq->getVar('solution', 'e')); $itemObj->setVar('dohtml', XHELP_SSECTION_DOHTML); $itemObj->setVar('dosmiley', XHELP_SSECTION_DOSMILEY); $itemObj->setVar('doxcode', XHELP_SSECTION_DOBBCODE); $itemObj->setVar('doimage', XHELP_SSECTION_DOIMAGE); $itemObj->setVar('dobr', XHELP_SSECTION_DOBR); $itemObj->setVar('notifypub', XHELP_SSECTION_NOTIFYPUB); $itemObj->setVar('uid', $uid); $itemObj->setVar('datesub', time()); // Setting the status of the item if ($this->_articleNeedsApproval()) { $itemObj->setVar('status', _SSECTION_STATUS_SUBMITTED); } else { $itemObj->setVar('status', _SSECTION_STATUS_PUBLISHED); } // Storing the item object in the database if ($ret = $itemObj->store()) { $faq->setVar('id', $itemObj->getVar('itemid')); $faq->setVar('url', $this->makeFaqUrl($faq)); if (!$this->_articleNeedsApproval()) { // Send notifications $itemObj->sendNotifications(array(_SSECTION_NOT_ITEM_PUBLISHED)); } else { if (XHELP_SSECTION_NOTIFYPUB) { include_once XOOPS_ROOT_PATH . '/include/notification_constants.php'; $notification_handler =& xoops_gethandler('notification'); $notification_handler->subscribe('item', $itemObj->itemid(), 'approved', XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE); } // Send notifications $itemObj->sendNotifications(array(_SSECTION_NOT_ITEM_SUBMITTED)); } } return $ret; }