Beispiel #1
0
function editfaq($faqid = '')
{
    global $answer_handler, $xoopsUser, $xoopsUser, $xoopsConfig, $xoopsDB, $modify, $xoopsModuleConfig, $xoopsModule, $XOOPS_URL, $myts;
    include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
    // Creating the FAQ object
    $faqObj = new sfFaq($faqid);
    // Creating the category object
    $categoryObj =& $faqObj->category();
    if ($faqObj->notLoaded()) {
        redirect_header("index.php", 1, _AM_SF_NOFAQSELECTED);
        exit;
    }
    switch ($faqObj->status()) {
        case _SF_STATUS_ANSWERED:
            $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;
    }
    $module_id = $xoopsModule->getVar('mid');
    $gperm_handler =& xoops_gethandler('groupperm');
    $groups = $xoopsUser ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;
    if (!sf_userIsAdmin() && !$gperm_handler->checkRight('category_admin', $faqObj->categoryid(), $groups, $module_id)) {
        redirect_header("javascript:history.go(-1)", 1, _NOPERM);
        exit;
    }
    // Retreiving the official answer
    $official_answer = $faqObj->answer();
    sf_adminMenu(-1, _AM_SF_SMARTFAQ . " > " . _AM_SF_ANSWER);
    sf_collapsableBar('bottomtable', 'bottomtableicon');
    echo "<img id='bottomtableicon' src=" . XOOPS_URL . "/modules/" . $xoopsModule->dirname() . "/images/icon/close12.gif alt='' /></a>&nbsp;" . _AM_SF_SUBMITTED_ANSWER . "</h3>";
    echo "<div id='bottomtable'>";
    echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . _AM_SF_SUBMITTED_ANSWER_INFO . "</span>";
    $proposed_answers = $answer_handler->getAllAnswers($faqid, _SF_AN_STATUS_PROPOSED);
    if (count($proposed_answers) == 0) {
        redirect_header("index.php", 1, _AM_SF_NOANSWERS);
        exit;
    }
    echo "<table width='100%' cellspacing=1 cellpadding=3 border=0 class = outer>\r\n\t        <tr>\r\n\t          <td class='head' width='100px'>" . _AM_SF_CATEGORY . "</td>\r\n\t          <td class='even'>" . $categoryObj->name() . "</td>\r\n\t        </tr>\r\n\t        <tr>\r\n\t          <td class='head' width='100px'>" . _AM_SF_QUESTION . "</td>\r\n\t          <td class='even'>" . $faqObj->question() . "</td>\r\n\t        </tr>";
    if ($official_answer) {
        echo "\r\n\t        <tr>\r\n\t          <td class='head' width='100px'>" . _AM_SF_ANSWER_OFFICIAL . "</td>\r\n\t          <td class='even'>" . $official_answer->answer() . "</td>\r\n\t        </tr>";
    }
    echo "</table><br />\n";
    echo "<table width='100%' cellspacing=1 cellpadding=3 border=0 class = outer>";
    echo "<tr>";
    echo "<td width='40' class='bg3' align='center'><b>" . _AM_SF_ARTID . "</b></td>";
    echo "<td class='bg3' class='bg3' align='center'><b>" . _AM_SF_ANSWER . "</b></td>";
    echo "<td width='180' class='bg3' align='center'><b>" . _AM_SF_CREATED . "</b></td>";
    echo "<td width='120' class='bg3' align='center'><b>" . _AM_SF_ACTION . "</b></td>";
    echo "</tr>";
    $merge = '';
    $modify = '';
    $approve = '';
    foreach ($proposed_answers as $proposed_answer) {
        if ($faqObj->status() == _SF_STATUS_NEW_ANSWER) {
            $merge = "<a href='faq.php?op=merge&amp;faqid=" . $faqObj->faqid() . "&amp;answerid=" . $proposed_answer->answerid() . "'><img src='" . XOOPS_URL . "/modules/" . $xoopsModule->dirname() . "/images/icon/merge.gif' title='" . _AM_SF_FAQ_MERGE . "' alt='" . _AM_SF_FAQ_MERGE . "' /></a>&nbsp;";
            $approve = "<a href='answer.php?op=selectanswer&amp;faqid=" . $faqid . "&amp;answerid=" . $proposed_answer->answerid() . "'><img src='" . XOOPS_URL . "/modules/" . $xoopsModule->dirname() . "/images/icon/approve.gif' title='" . _AM_SF_FAQ_APPROVE_NEW_ANSWER . "' alt='" . _AM_SF_APPROVESUB . "' /></a>";
        }
        $modify = "<a href='faq.php?op=mod&amp;faqid=" . $faqObj->faqid() . "&amp;answerid=" . $proposed_answer->answerid() . "'><img src='" . XOOPS_URL . "/modules/" . $xoopsModule->dirname() . "/images/icon/edit.gif' title='" . _AM_SF_FAQ_REVIEW . "' alt='" . _AM_SF_FAQ_REVIEW . "' /></a>&nbsp;";
        $delete = "<a href='answer.php?op=del&amp;faqid=" . $faqObj->faqid() . "&amp;answerid=" . $proposed_answer->answerid() . "'><img src='" . XOOPS_URL . "/modules/" . $xoopsModule->dirname() . "/images/icon/delete.gif' title='" . _AM_SF_DELETESUBM . "' alt='" . _AM_SF_DELETESUBM . "' /></a>";
        echo "<tr>";
        echo "<td class='head' align='center'>" . $proposed_answer->answerid() . "</td>";
        echo "<td class='even' align='left'>" . $proposed_answer->answer() . "</td>";
        echo "<td class='even' align='center'>" . $proposed_answer->datesub() . "</td>";
        echo "<td class='even' align='center'> {$merge} {$modify} {$approve} {$delete} </td>";
        echo "</tr>";
    }
    echo "</table>\n<br />";
}
Beispiel #2
0
function editfaq($showmenu = false, $faqid = -1)
{
    global $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_NOARTTOEDIT);
            exit;
        }
        switch ($faqObj->status()) {
            case _SF_STATUS_ASKED:
                $breadcrumb_action = _AM_SF_APPROVING;
                $collapsableBar_title = _AM_SF_QUESTION_APPROVING;
                $collapsableBar_info = _AM_SF_QUESTION_APPROVING_INFO;
                $button_caption = _AM_SF_QUEUE;
                break;
            case "default":
            default:
                $breadcrumb_action = _AM_SF_EDITING;
                $collapsableBar_title = _AM_SF_EDITQUES;
                $collapsableBar_info = _AM_SF_EDITING_INFO;
                $button_caption = _AM_SF_MODIFY;
                break;
        }
        // Creating the category of this FAQ
        $categoryObj =& $category_handler->get($faqObj->categoryid());
        if ($showmenu) {
            sf_adminMenu(3, _AM_SF_OPEN_QUESTIONS . " > " . $breadcrumb_action);
        }
        echo "<br />\n";
        sf_collapsableBar('bottomtable', 'bottomtableicon');
        echo "<img id='bottomtableicon' src=" . XOOPS_URL . "/modules/" . $xoopsModule->dirname() . "/images/icon/close12.gif alt='' /></a>&nbsp;" . $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();
        $breadcrumb_action = _AM_SF_CREATINGNEW;
        $button_caption = _AM_SF_CREATE;
        if ($showmenu) {
            sf_adminMenu(3, _AM_SF_OPEN_QUESTIONS . " > " . $breadcrumb_action);
        }
        sf_collapsableBar('bottomtable', 'bottomtableicon');
        echo "<img id='bottomtableicon' src=" . XOOPS_URL . "/modules/" . $xoopsModule->dirname() . "/images/icon/close12.gif alt='' /></a>&nbsp;" . _AM_SF_CREATEQUESTION . "</h3>";
        echo "<div id='bottomtable'>";
    }
    $sform = new XoopsThemeForm(_AM_SF_OPEN_QUESTION, "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'])));
    // 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_QUESTION, ob_get_contents()));
    ob_end_clean();
    // faq QUESTION
    $sform->addElement(new XoopsFormTextArea(_AM_SF_QUESTION, 'question', $faqObj->question(), 7, 60));
    // PER ITEM PERMISSIONS
    $member_handler =& xoops_gethandler('member');
    $group_list =& $member_handler->getGroupList();
    $groups_checkbox = new XoopsFormCheckBox(_AM_SF_PERMISSIONS_QUESTION, '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);
    // faq ID
    $sform->addElement(new XoopsFormHidden('faqid', $faqObj->faqid()));
    $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 , '&nbsp;');
    	$status_tray->addElement($status_select);
    	$sform->addElement($status_tray);
    	*/
    if ($faqid == -1) {
        // 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_edit = new XoopsFormButton('', '', _AM_SF_OPEN_QUESTION_EDIT, 'button');
        $butt_edit->setExtra("onclick=\"location='faq.php?op=mod&amp;faqid=" . $faqid . "'\"");
        $button_tray->addElement($butt_edit);
        $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);
}
Beispiel #3
0
 function sendNotifications($notifications = array())
 {
     $smartModule =& sf_getModuleInfo();
     $myts =& MyTextSanitizer::getInstance();
     $notification_handler =& xoops_gethandler('notification');
     $faqObj = new sfFaq($this->faqid());
     $tags = array();
     $tags['MODULE_NAME'] = $myts->displayTarea($smartModule->getVar('name'));
     $tags['FAQ_NAME'] = $faqObj->question();
     $tags['FAQ_URL'] = XOOPS_URL . '/modules/' . $smartModule->getVar('dirname') . '/faq.php?faqid=' . $faqObj->faqid();
     $tags['CATEGORY_NAME'] = $faqObj->getCategoryName();
     $tags['CATEGORY_URL'] = XOOPS_URL . '/modules/' . $smartModule->getVar('dirname') . '/category.php?categoryid=' . $faqObj->categoryid();
     $tags['FAQ_QUESTION'] = $faqObj->question();
     // TODO : Not sure about the 'formpreview' ...
     $tags['FAQ_ANSWER'] = $this->answer('formpreview');
     $tags['DATESUB'] = $this->datesub();
     foreach ($notifications as $notification) {
         switch ($notification) {
             case _SF_NOT_ANSWER_APPROVED:
                 // This notification is not working for PM, but is for email... and I don't understand why???
                 $notification_handler->triggerEvent('faq', $this->answerid(), 'answer_approved', $tags);
                 break;
             case -1:
             default:
                 break;
         }
     }
 }