Esempio n. 1
0
             // Send notifications
             if (isset($_POST['notifypub']) && $_POST['notifypub'] == 1) {
                 include_once XOOPS_ROOT_PATH . '/include/notification_constants.php';
                 $notification_handler->subscribe('faq', $newAnswerObj->answerid(), 'answer_approved', XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE);
             }
             $faqObj->sendNotifications(array(_SF_NOT_NEW_ANSWER_PROPOSED));
             break;
     }
     redirect_header("javascript:history.go(-2)", 3, $redirect_msg);
     exit;
     break;
 case 'form':
 default:
     global $xoopsUser, $xoopsModule, $HTTP_SERVER_VARS;
     // Creating the FAQ object for the selected FAQ
     $faqObj = new sfFaq($faqid);
     // If the selected FAQ was not found, exit
     if ($faqObj->notLoaded()) {
         redirect_header("javascript:history.go(-1)", 1, _MD_SF_NOFAQSELECTED);
         exit;
     }
     // Creating the category object that holds the selected FAQ
     $categoryObj =& $faqObj->category();
     // Creating the answer object
     $answerObj =& $faqObj->answer();
     // Check user permissions to access that category of the selected FAQ
     if (faqAccessGranted($faqObj) < 0) {
         redirect_header("javascript:history.go(-1)", 1, _NOPERM);
         exit;
     }
     $xoopsOption['template_main'] = 'smartfaq_submit.html';
Esempio n. 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);
}
Esempio n. 3
0
/**
* $Id: faq.php,v 1.31 2006/09/29 18:49:10 malanciault Exp $
* Module: SmartFAQ
* Author: The SmartFactory <www.smartfactory.ca>
* Licence: GNU
*/
include_once "header.php";
$faqid = isset($_GET['faqid']) ? intval($_GET['faqid']) : 0;
if ($faqid == 0) {
    redirect_header("javascript:history.go(-1)", 1, _MD_SF_NOFAQSELECTED);
    exit;
}
// Creating the FAQ handler object
$faq_handler =& sf_gethandler('faq');
// Creating the FAQ object for the selected FAQ
$faqObj = new sfFaq($faqid);
// If the selected FAQ was not found, exit
if ($faqObj->notLoaded()) {
    redirect_header("javascript:history.go(-1)", 1, _MD_SF_NOFAQSELECTED);
    exit;
}
// Creating the category object that holds the selected FAQ
$categoryObj = $faqObj->category();
// Creating the answer object
$answerObj = $faqObj->answer();
// Check user permissions to access that category of the selected FAQ
$faqAccessGrantedResult = faqAccessGranted($faqObj);
if ($faqAccessGrantedResult < 0) {
    redirect_header("javascript:history.go(-1)", 1, _NOPERM);
    exit;
}
Esempio n. 4
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 />";
}
Esempio n. 5
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;
         }
     }
 }
Esempio n. 6
0
 function getFaqsFromSearch($queryarray = array(), $andor = 'AND', $limit = 0, $offset = 0, $userid = 0)
 {
     global $xoopsUser;
     $ret = array();
     $userIsAdmin = sf_userIsAdmin();
     if ($userid != 0) {
         $criteriaUser = new CriteriaCompo();
         $criteriaUser->add(new Criteria('faq.uid', $userid), 'OR');
         $criteriaUser->add(new Criteria('answer.uid', $userid), 'OR');
     }
     if ($queryarray) {
         $criteriaKeywords = new CriteriaCompo();
         for ($i = 0; $i < count($queryarray); $i++) {
             $criteriaKeyword = new CriteriaCompo();
             $criteriaKeyword->add(new Criteria('faq.question', '%' . $queryarray[$i] . '%', 'LIKE'), 'OR');
             $criteriaKeyword->add(new Criteria('answer.answer', '%' . $queryarray[$i] . '%', 'LIKE'), 'OR');
             $criteriaKeywords->add($criteriaKeyword, $andor);
             unset($criteriaKeyword);
         }
     }
     // Categories for which user has access
     if (!$userIsAdmin) {
         $smartPermHandler =& xoops_getmodulehandler('permission', 'smartfaq');
         $categoriesGranted = $smartPermHandler->getPermissions('category');
         $faqsGranted = $smartPermHandler->getPermissions('item');
         if (!$categoriesGranted) {
             return $ret;
         }
         if (!$faqsGranted) {
             return $ret;
         }
         $grantedCategories = new Criteria('faq.categoryid', "(" . implode(',', $categoriesGranted) . ")", 'IN');
         $grantedFaq = new CriteriaCompo();
         $grantedFaq->add(new Criteria('faq.faqid', "(" . implode(',', $faqsGranted) . ")", 'IN'), 'OR');
         // If user is anonymous, check if the FAQ allow partialview
         if (!is_object($xoopsUser)) {
             $grantedFaq->add(new Criteria('partialview', '1'), 'OR');
         }
     }
     $criteriaPermissions = new CriteriaCompo();
     if (!$userIsAdmin) {
         $criteriaPermissions->add($grantedCategories, 'AND');
         $criteriaPermissions->add($grantedFaq, 'AND');
     }
     $criteriaAnswersStatus = new CriteriaCompo();
     $criteriaAnswersStatus->add(new Criteria('answer.status', _SF_AN_STATUS_APPROVED));
     $criteriaFasStatus = new CriteriaCompo();
     $criteriaFasStatus->add(new Criteria('faq.status', _SF_STATUS_OPENED), 'OR');
     $criteriaFasStatus->add(new Criteria('faq.status', _SF_STATUS_PUBLISHED), 'OR');
     $criteria = new CriteriaCompo();
     if (!empty($criteriaUser)) {
         $criteria->add($criteriaUser, 'AND');
     }
     if (!empty($criteriaKeywords)) {
         $criteria->add($criteriaKeywords, 'AND');
     }
     if (!empty($criteriaPermissions) && !$userIsAdmin) {
         $criteria->add($criteriaPermissions);
     }
     if (!empty($criteriaAnswersStatus)) {
         $criteria->add($criteriaAnswersStatus, 'AND');
     }
     if (!empty($criteriaFasStatus)) {
         $criteria->add($criteriaFasStatus, 'AND');
     }
     $criteria->setLimit($limit);
     $criteria->setStart($offset);
     $criteria->setSort('faq.datesub');
     $criteria->setOrder('DESC');
     $sql = 'SELECT faq.faqid, faq.question, faq.datesub, faq.uid FROM ' . $this->db->prefix('smartfaq_faq') . ' as faq INNER JOIN ' . $this->db->prefix('smartfaq_answers') . ' as answer ON faq.faqid = answer.faqid';
     if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
         $whereClause = $criteria->renderWhere();
         if ($whereClause != 'WHERE ()') {
             $sql .= ' ' . $criteria->renderWhere();
             if ($criteria->getSort() != '') {
                 $sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder();
             }
             $limit = $criteria->getLimit();
             $start = $criteria->getStart();
         }
     }
     //echo "<br />" . $sql . "<br />";
     $result = $this->db->query($sql, $limit, $start);
     if (!$result) {
         trigger_error("Query did not work in smartfaq", E_USER_WARNING);
         return $ret;
     }
     if (count($result) == 0) {
         return $ret;
     }
     while ($myrow = $this->db->fetchArray($result)) {
         $faq = new sfFaq();
         $faq->assignVars($myrow);
         $ret[] =& $faq;
         unset($faq);
     }
     return $ret;
 }
Esempio n. 7
0
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>&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();
        $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>&nbsp;" . _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, '&nbsp;');
    $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 , '&nbsp;');
    	$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);
}