$redirect_msg = _AM_SF_QUESTIONPUBLISHED; // Setting the new status $status = _SF_STATUS_OPENED; $notifToDo = array(_SF_NOT_QUESTION_PUBLISHED); break; case "default": default: $redirect_msg = _AM_SF_QUESTIONMODIFIED; // Setting the new status $status = $faqObj->status(); break; } $faqObj->setVar('status', $status); // Storing the FAQ if (!$faqObj->store()) { redirect_header("javascript:history.go(-1)", 3, _AM_SF_ERROR . sf_formatErrors($faqObj->getErrors())); exit; } // Send notifications if (!empty($notifToDo)) { $faqObj->sendNotifications($notifToDo); } redirect_header("question.php", 2, $redirect_msg); exit; break; case "del": global $xoopsUser, $xoopsUser, $xoopsConfig, $xoopsDB, $_GET; $module_id = $xoopsModule->getVar('mid'); $gperm_handler =& xoops_gethandler('groupperm'); $faqid = isset($_POST['faqid']) ? intval($_POST['faqid']) : 0; $faqid = isset($_GET['faqid']) ? intval($_GET['faqid']) : $faqid;
// New submitted answer need approbation $redirect_msg = _MD_SF_FAQ_NEW_ANSWER_NEED_APPROBATION; $faqObj->setVar('status', _SF_STATUS_NEW_ANSWER); $newAnswerObj->setVar('status', _SF_AN_STATUS_PROPOSED); $notifCase = 5; } break; } // Storing the FAQ object in the database if (!$faqObj->store()) { redirect_header("javascript:history.go(-1)", 3, _MD_SF_SUBMIT_ERROR . sf_formatErrors($faqObj->getErrors())); exit; } // Storing the answer object in the database if (!$newAnswerObj->store()) { redirect_header("javascript:history.go(-1)", 3, _MD_SF_SUBMIT_ERROR . sf_formatErrors($newAnswerObj->getErrors())); exit; } $notification_handler =& xoops_gethandler('notification'); switch ($notifCase) { case 1: // Question submitted, auto-approved; became Q&A, auto-approved // We do not not subscribe user to notification on publish since we publish it right away // Send notifications $faqObj->sendNotifications(array(_SF_NOT_FAQ_PUBLISHED)); break; case 2: // Answer for an open question submitted, auto-approved; became Q&A, need approbation if (isset($_POST['notifypub']) && $_POST['notifypub'] == 1) { include_once XOOPS_ROOT_PATH . '/include/notification_constants.php'; $notification_handler->subscribe('faq', $faqObj->faqid(), 'approved', XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE);
} // Putting the values about the FAQ in the FAQ object $newFaqObj->setVar('categoryid', $_POST['categoryid']); $newFaqObj->setVar('uid', $uid); $newFaqObj->setVar('question', $_POST['question']); $notifypub = isset($_POST['notifypub']) ? $_POST['notifypub'] : 0; $newFaqObj->setVar('notifypub', $notifypub); // Setting the status of the FAQ if ($xoopsModuleConfig['autoapprove_request'] == 1) { $newFaqObj->setVar('status', _SF_STATUS_OPENED); } else { $newFaqObj->setVar('status', _SF_STATUS_ASKED); } // Storing the FAQ object in the database if (!$newFaqObj->store()) { redirect_header("javascript:history.go(-1)", 3, _MD_SF_REQUEST_ERROR . sf_formatErrors($newFaqObj->getErrors())); exit; } // Get the cateopry object related to that FAQ // If autoapprove_requested if ($xoopsModuleConfig['autoapprove_request'] == 1) { // We do not not subscribe user to notification on publish since we publish it right away // Send notifications $newFaqObj->sendNotifications(array(_SF_NOT_QUESTION_PUBLISHED)); $redirect_msg = _MD_SF_REQUEST_RECEIVED_AND_PUBLISHED; } else { // Subscribe the user to On Published notification, if requested if ($notifypub == 1) { include_once XOOPS_ROOT_PATH . '/include/notification_constants.php'; $notification_handler =& xoops_gethandler('notification'); $notification_handler->subscribe('question', $newFaqObj->faqid(), 'approved', XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE);
} redirect_header("faq.php", 2, $redirect_msg); exit; break; case "del": global $xoopsUser, $xoopsUser, $xoopsConfig, $xoopsDB, $_GET; $module_id = $xoopsModule->getVar('mid'); $gperm_handler =& xoops_gethandler('groupperm'); $faqid = isset($_POST['faqid']) ? intval($_POST['faqid']) : 0; $faqid = isset($_GET['faqid']) ? intval($_GET['faqid']) : $faqid; $faqObj = new sfFaq($faqid); $confirm = isset($_POST['confirm']) ? $_POST['confirm'] : 0; $question = isset($_POST['question']) ? $_POST['question'] : ''; if ($confirm) { if (!$faq_handler->delete($faqObj)) { redirect_header("faq.php", 2, _AM_SF_FAQ_DELETE_ERROR . sf_formatErrors($faqObj->getErrors())); exit; } redirect_header("faq.php", 2, sprintf(_AM_SF_ARTISDELETED, $faqObj->question())); exit; } else { // no confirm: show deletion condition $faqid = isset($_GET['faqid']) ? intval($_GET['faqid']) : 0; xoops_cp_header(); xoops_confirm(array('op' => 'del', 'faqid' => $faqObj->faqid(), 'confirm' => 1, 'name' => $faqObj->question()), 'faq.php', _AM_SF_DELETETHISARTICLE . " <br />'" . $faqObj->question() . "'. <br /> <br />", _AM_SF_DELETE); xoops_cp_footer(); } exit; break; case "default": default:
} else { $categoryObj->setGroups_read(); } // $groups_admin = isset($_POST['groups_admin'])? $_POST['groups_admin'] : array(); // $mod_perms = isset($_POST['mod_perms'])? $_POST['mod_perms'] : array(); $categoryObj->setVar('name', $_POST['name']); $categoryObj->setVar('description', $_POST['description']); if ($categoryObj->isNew()) { $redirect_msg = _AM_SF_CATCREATED; $redirect_to = 'category.php?op=mod'; } else { $redirect_msg = _AM_SF_COLMODIFIED; $redirect_to = 'category.php'; } if (!$categoryObj->store()) { redirect_header("javascript:history.go(-1)", 3, _AM_SF_CATEGORY_SAVE_ERROR . sf_formatErrors($categoryObj->getErrors())); exit; } // TODO : put this function in the category class sf_saveCategory_Permissions($categoryObj->getGroups_read(), $categoryObj->categoryid(), 'category_read'); //sf_saveCategory_Permissions($groups_admin, $categoriesObj->categoryid(), 'category_admin'); if ($applyall) { // TODO : put this function in the category class sf_overrideFaqsPermissions($categoryObj->getGroups_read(), $categoryObj->categoryid()); } redirect_header($redirect_to, 2, $redirect_msg); exit; break; case "del": global $xoopsUser, $xoopsUser, $xoopsConfig, $xoopsDB, $_GET; $module_id = $xoopsModule->getVar('mid');