예제 #1
0
 function getCategoryName()
 {
     if (!isset($this->_category)) {
         $this->_category = new sfCategory($this->getVar('categoryid'));
     }
     return $this->_category->name();
 }
예제 #2
0
 function &getCategoriesWithOpenQuestion($limit = 0, $start = 0, $parentid = 0, $sort = 'weight', $order = 'ASC')
 {
     include_once XOOPS_ROOT_PATH . '/modules/smartfaq/include/functions.php';
     $criteria = new CriteriaCompo();
     $criteria->setSort($sort);
     $criteria->setOrder($order);
     if ($parentid != -1) {
         $criteria->add(new Criteria('c.parentid', $parentid));
     }
     if (!sf_userIsAdmin()) {
         $smartPermHandler =& xoops_getmodulehandler('permission', 'smartfaq');
         $categoriesGranted = $smartPermHandler->getPermissions('category');
         $criteria->add(new Criteria('categoryid', "(" . implode(',', $categoriesGranted) . ")", 'IN'));
     }
     $criteria->add(new Criteria('f.status', _SF_STATUS_OPENED));
     $criteria->setStart($start);
     $criteria->setLimit($limit);
     $ret = array();
     $limit = $start = 0;
     $sql = 'SELECT DISTINCT c.categoryid, c.parentid, c.name, c.description, c.total, c.weight, c.created FROM ' . $this->db->prefix('smartfaq_categories') . ' AS c INNER JOIN ' . $this->db->prefix('smartfaq_faq') . ' AS f ON c.categoryid = f.categoryid';
     if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
         $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) {
         return $ret;
     }
     while ($myrow = $this->db->fetchArray($result)) {
         $category = new sfCategory();
         $category->assignVars($myrow);
         $ret[] =& $category;
         unset($category);
     }
     return $ret;
 }
예제 #3
0
function editcat($showmenu = false, $categoryid = 0)
{
    //$moderators = array(); // just to define the variable
    //$allmods = array();
    $startfaq = isset($_GET['startfaq']) ? intval($_GET['startfaq']) : 0;
    global $category_handler, $xoopsUser, $xoopsUser, $myts, $xoopsConfig, $xoopsDB, $modify, $xoopsModuleConfig, $xoopsModule, $_GET;
    include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
    // Creating the faq handler object
    $faq_handler =& sf_gethandler('faq');
    echo "<script type=\"text/javascript\" src=\"funcs.js\"></script>";
    echo "<style>";
    echo "<!-- ";
    echo "select { width: 130px; }";
    echo "-->";
    echo "</style>";
    // If there is a parameter, and the id exists, retrieve data: we're editing a category
    if ($categoryid != 0) {
        // Creating the category object for the selected category
        $categoryObj = new sfCategory($categoryid);
        if ($showmenu) {
            sf_adminMenu(1, _AM_SF_CATEGORIES . " > " . _AM_SF_EDITING);
        }
        echo "<br />\n";
        if ($categoryObj->notLoaded()) {
            redirect_header("category.php", 1, _AM_SF_NOCOLTOEDIT);
            exit;
        }
        sf_collapsableBar('bottomtable', 'bottomtableicon');
        echo "<img id='bottomtableicon' src=" . XOOPS_URL . "/modules/" . $xoopsModule->dirname() . "/images/icon/close12.gif alt='' /></a>&nbsp;" . _AM_SF_EDITCOL . "</h3>";
        echo "<div id='bottomtable'>";
    } else {
        $categoryObj = $category_handler->create();
        if ($showmenu) {
            sf_adminMenu(1, _AM_SF_CATEGORIES . " > " . _AM_SF_CREATINGNEW);
        }
        echo "<br />\n";
        sf_collapsableBar('bottomtable', 'bottomtableicon');
        echo "<img id='bottomtableicon' src=" . XOOPS_URL . "/modules/" . $xoopsModule->dirname() . "/images/icon/close12.gif alt='' /></a>&nbsp;" . _AM_SF_CATEGORY_CREATE . "</h3>";
        echo "<div id='bottomtable'>";
    }
    // Start category form
    $sform = new XoopsThemeForm(_AM_SF_CATEGORY, "op", xoops_getenv('PHP_SELF'));
    $sform->setExtra('enctype="multipart/form-data"');
    // Name
    $sform->addElement(new XoopsFormText(_AM_SF_CATEGORY, 'name', 50, 255, $categoryObj->name('e')), true);
    // Parent Category
    $mytree = new XoopsTree($xoopsDB->prefix("smartfaq_categories"), "categoryid", "parentid");
    ob_start();
    $mytree->makeMySelBox("name", "weight", $categoryObj->parentid(), 1, 'parentid');
    //makeMySelBox($title,$order="",$preset_id=0, $none=0, $sel_name="", $onchange="")
    $sform->addElement(new XoopsFormLabel(_AM_SF_PARENT_CATEGORY_EXP, ob_get_contents()));
    ob_end_clean();
    /*	$mytree = new XoopsTree($xoopsDB->prefix("smartfaq_categories"), "categoryid" , "parentid");
    	ob_start();
    	$sform->addElement(new XoopsFormHidden('categoryid', $categoryObj->categoryid()));
    	$mytree->makeMySelBox("name", "weight", $categoryObj->categoryid());
    	$sform->addElement(new XoopsFormLabel(_AM_SF_CATEGORY_FAQ, ob_get_contents()));
    	ob_end_clean();
    	*/
    // Decsription
    $sform->addElement(new XoopsFormTextArea(_AM_SF_COLDESCRIPT, 'description', $categoryObj->description('e'), 7, 60));
    // Weight
    $sform->addElement(new XoopsFormText(_AM_SF_COLPOSIT, 'weight', 4, 4, $categoryObj->weight()));
    // READ PERMISSIONS
    $member_handler =& xoops_gethandler('member');
    $group_list =& $member_handler->getGroupList();
    $groups_read_checkbox = new XoopsFormCheckBox(_AM_SF_PERMISSIONS_CAT_READ, 'groups_read[]', $categoryObj->getGroups_read());
    foreach ($group_list as $group_id => $group_name) {
        if ($group_id != XOOPS_GROUP_ADMIN) {
            $groups_read_checkbox->addOption($group_id, $group_name);
        }
    }
    $sform->addElement($groups_read_checkbox);
    // Apply permissions on all faqs
    $addapplyall_radio = new XoopsFormRadioYN(_AM_SF_PERMISSIONS_APPLY_ON_FAQS, 'applyall', 0, ' ' . _AM_SF_YES . '', ' ' . _AM_SF_NO . '');
    $sform->addElement($addapplyall_radio);
    // MODERATORS
    //$moderators_tray = new XoopsFormElementTray(_AM_SF_MODERATORS_DEF, '');
    $module_id = $xoopsModule->getVar('mid');
    /*$gperm_handler = &xoops_gethandler('groupperm');
    	$mod_perms = $gperm_handler->getGroupIds('category_moderation', $categoryid, $module_id);
    
    	$moderators_select = new XoopsFormSelect('', 'moderators', $moderators, 5, true);
    	$moderators_tray->addElement($moderators_select);
    
    	$butt_mngmods = new XoopsFormButton('', '', 'Manage mods', 'button');
    	$butt_mngmods->setExtra('onclick="javascript:small_window(\'pop.php\', 370, 350);"');
    	$moderators_tray->addElement($butt_mngmods);
    
    	$butt_delmod = new XoopsFormButton('', '', 'Delete mod', 'button');
    	$butt_delmod->setExtra('onclick="javascript:deleteSelectedItemsFromList(this.form.elements[\'moderators[]\']);"');
    	$moderators_tray->addElement($butt_delmod);
    
    	$sform->addElement($moderators_tray);
    	*/
    $sform->addElement(new XoopsFormHidden('categoryid', $categoryid));
    // Action buttons tray
    $button_tray = new XoopsFormElementTray('', '');
    /*for ($i = 0; $i < sizeof($moderators); $i++) {
    	$allmods[] = $moderators[$i];
    	}
    
    	$hiddenmods = new XoopsFormHidden('allmods', $allmods);
    	$button_tray->addElement($hiddenmods);
    	*/
    $hidden = new XoopsFormHidden('op', 'addcategory');
    $button_tray->addElement($hidden);
    // No ID for category -- then it's new category, button says 'Create'
    if (!$categoryid) {
        $butt_create = new XoopsFormButton('', '', _AM_SF_CREATE, 'submit');
        $butt_create->setExtra('onclick="this.form.elements.op.value=\'addcategory\'"');
        $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 {
        // button says 'Update'
        $butt_create = new XoopsFormButton('', '', _AM_SF_MODIFY, 'submit');
        $butt_create->setExtra('onclick="this.form.elements.op.value=\'addcategory\'"');
        $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>";
    if ($categoryid) {
        include_once XOOPS_ROOT_PATH . "/modules/smartfaq/include/displayfaqs.php";
    }
    unset($hidden);
}
예제 #4
0
<?php

/**
* $Id: open_category.php,v 1.19 2005/08/15 16:51:58 fx2024 Exp $
* Module: SmartFAQ
* Author: The SmartFactory <www.smartfactory.ca>
* Licence: GNU
*/
include_once "header.php";
global $xoopsConfig, $xoopsModuleConfig, $xoopsModule;
$xoopsOption['template_main'] = 'smartfaq_category.html';
include_once XOOPS_ROOT_PATH . "/header.php";
include_once "footer.php";
$categoryid = isset($_GET['categoryid']) ? intval($_GET['categoryid']) : 0;
// Creating the category object for the selected category
$categoryObj = new sfCategory($categoryid);
// If the selected category was not found, exit
if ($categoryObj->notLoaded()) {
    redirect_header("javascript:history.go(-1)", 1, _MD_SF_NOCATEGORYSELECTED);
    exit;
}
// Check user permissions to access this category
if (!$categoryObj->checkPermission()) {
    redirect_header("javascript:history.go(-1)", 1, _NOPERM);
    exit;
}
// Creating the category handler object
$category_handler =& sf_gethandler('category');
// At which record shall we start
$start = isset($_GET['start']) ? intval($_GET['start']) : 0;
// Creating the faq handler object
예제 #5
0
<?php

/**
* $Id: category.php,v 1.37 2005/08/26 18:31:04 fx2024 Exp $
* Module: SmartFAQ
* Author: The SmartFactory <www.smartfactory.ca>
* Licence: GNU
*/
include_once "header.php";
$categoryid = isset($_GET['categoryid']) ? intval($_GET['categoryid']) : 0;
// Creating the category handler object
$category_handler =& sf_gethandler('category');
// Creating the category object for the selected category
$categoryObj = new sfCategory($categoryid);
// If the selected category was not found, exit
if ($categoryObj->notLoaded()) {
    redirect_header("javascript:history.go(-1)", 1, _MD_SF_NOCATEGORYSELECTED);
    exit;
}
// Check user permissions to access this category
if (!$categoryObj->checkPermission()) {
    redirect_header("javascript:history.go(-1)", 1, _NOPERM);
    exit;
}
$totalQnas = $category_handler->publishedFaqsCount($categoryid);
// If there is no FAQ under this categories or the sub-categories, exit
if (!isset($totalQnas[$categoryid]) || $totalQnas[$categoryid] == 0) {
    //redirect_header("index.php", 1, _MD_SF_MAINNOFAQS);
    //exit;
}
$xoopsOption['template_main'] = 'smartfaq_category.html';