/** * $Id: submit.php,v 1.2 2005/08/02 03:47:51 mauriciodelima Exp $ * Module: SmartSection * Author: The SmartFactory <www.smartfactory.ca> * Licence: GNU */ include_once "header.php"; global $smartsection_category_handler, $smartsection_item_handler, $xoopsUser, $xoopsConfig, $xoopsModuleConfig, $xoopsModule; // Get the total number of categories $totalCategories = count($smartsection_category_handler->getCategories()); if ($totalCategories == 0) { redirect_header("index.php", 1, _AM_SS_NOCOLEXISTS); exit; } // Find if the user is admin of the module $isAdmin = ss_userIsAdmin(); // If the user is not admin AND we don't allow user submission, exit if (!($isAdmin || isset($xoopsModuleConfig['allowsubmit']) && $xoopsModuleConfig['allowsubmit'] == 1 && (is_object($xoopsUser) || isset($xoopsModuleConfig['anonpost']) && $xoopsModuleConfig['anonpost'] == 1))) { redirect_header("index.php", 1, _NOPERM); exit; } $op = ''; if (isset($_POST['post'])) { $op = 'post'; } elseif (isset($_POST['preview'])) { $op = 'preview'; } else { $op = 'form'; } switch ($op) { case 'preview':
<?php /** * $Id: permissions.php,v 1.2 2005/08/02 03:47:51 mauriciodelima Exp $ * Module: SmartSection * Author: The SmartFactory <www.smartfactory.ca> * Licence: GNU */ include_once "admin_header.php"; include_once XOOPS_ROOT_PATH . '/class/xoopsform/grouppermform.php'; if (!ss_userIsAdmin()) { redirect_header("javascript:history.go(-1)", 1, _NOPERM); exit; } $op = ''; foreach ($_POST as $k => $v) { ${$k} = $v; } foreach ($_GET as $k => $v) { ${$k} = $v; } switch ($op) { case "default": default: global $xoopsDB, $xoopsModule; ss_xoops_cp_header(); ss_adminMenu(4, _AM_SS_PERMISSIONS); // View Categories permissions $item_list_view = array(); $block_view = array(); // echo "<h3 style='color: #2F5376; '>"._AM_SS_PERMISSIONSADMIN."</h3>\n" ;
<?php /** * $Id: footer.php,v 1.2 2005/08/02 03:47:51 mauriciodelima Exp $ * Module: SmartSection * Author: The SmartFactory <www.smartfactory.ca> * Licence: GNU */ global $xoopsModule, $xoopsModuleConfig; include_once XOOPS_ROOT_PATH . "/modules/smartsection/include/functions.php"; $uid = $xoopsUser ? $xoopsUser->getVar("uid") : 0; $isAdmin = ss_userIsAdmin() || ss_moderator(); $xoopsTpl->assign("smartsection_adminpage", "<a href='" . XOOPS_URL . "/modules/smartsection/admin/index.php'>" . _MD_SS_ADMIN_PAGE . "</a>"); $xoopsTpl->assign("isAdmin", $isAdmin); $xoopsTpl->assign('smartsection_url', SMARTSECTION_URL); $xoopsTpl->assign('smartsection_images_url', SMARTSECTION_IMAGES_URL); $xoopsTpl->assign("xoops_module_header", '<link rel="stylesheet" type="text/css" href="smartsection.css" />'); $xoopsTpl->assign('lang_total', _MD_SS_TOTAL_SMARTITEMS); $xoopsTpl->assign('lang_home', _MD_SS_HOME); $xoopsTpl->assign('lang_description', _MD_SS_DESCRIPTION); $xoopsTpl->assign('displayList', $xoopsModuleConfig['displaytype'] == 'list'); $xoopsTpl->assign('displayFull', $xoopsModuleConfig['displaytype'] == 'full'); $xoopsTpl->assign('modulename', $xoopsModule->dirname()); $xoopsTpl->assign('displaylastitem', $xoopsModuleConfig['displaylastitem']); $xoopsTpl->assign('displaysubcatdsc', $xoopsModuleConfig['displaysubcatdsc']); $xoopsTpl->assign('collapsable_heading', $xoopsModuleConfig['collapsable_heading']); $xoopsTpl->assign('display_comment_link', $xoopsModuleConfig['display_comment_link']); $xoopsTpl->assign('display_whowhen_link', $xoopsModuleConfig['display_whowhen_link']); $xoopsTpl->assign('display_date_col', $xoopsModuleConfig['display_date_col']); $xoopsTpl->assign('display_hits_col', $xoopsModuleConfig['display_hits_col']); $xoopsTpl->assign('lang_reads', _MD_SS_READS);
function ss_itemAccessGranted($itemid, $categoryid) { global $xoopsUser; if (ss_userIsAdmin()) { $result = true; } else { $result = false; $groups = $xoopsUser ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; $gperm_handler =& xoops_gethandler('groupperm'); $hModule =& xoops_gethandler('module'); $hModConfig =& xoops_gethandler('config'); $smartModule =& $hModule->getByDirname('smartsection'); $module_id = $smartModule->getVar('mid'); // Do we have access to the parent category if ($gperm_handler->checkRight('category_read', $categoryid, $groups, $module_id)) { // Do we have access to the item ? if ($gperm_handler->checkRight('item_read', $itemid, $groups, $module_id)) { $result = true; } else { // No we don't ! $result = false; } } else { // No we don't ! $result = false; } } return $result; }
function getCountsByCat($cat_id = 0, $status) { $ret = array(); $sql = 'SELECT categoryid, COUNT(*) AS count FROM ' . $this->db->prefix('smartsection_items'); if (intval($cat_id) > 0) { $sql .= ' WHERE categoryid = ' . intval($cat_id); $sql .= ' AND status IN (' . implode(',', $status) . ')'; } else { $sql .= ' WHERE status IN (' . implode(',', $status) . ')'; if (!ss_userIsAdmin()) { $smartsectionPermHandler =& xoops_getmodulehandler('permission', 'smartsection'); $items = $smartsectionPermHandler->getGrantedItems('item'); $sql .= ' AND itemid IN (' . implode(',', $items) . ')'; } } $sql .= ' GROUP BY categoryid'; $result = $this->db->query($sql); if (!$result) { return $ret; } while ($row = $this->db->fetchArray($result)) { $ret[$row['categoryid']] = intval($row['count']); } return $ret; }
function getSubCats(&$categories) { $criteria = new CriteriaCompo('parentid', "(" . implode(',', array_keys($categories)) . ")", 'IN'); $ret = array(); if (!ss_userIsAdmin()) { $smartsectionPermHandler =& xoops_getmodulehandler('permission', 'smartsection'); $categoriesGranted = $smartsectionPermHandler->getGrantedItems('category'); $criteria->add(new Criteria('categoryid', "(" . implode(',', $categoriesGranted) . ")", 'IN')); } $subcats = $this->getObjects($criteria, true); foreach ($subcats as $subcat_id => $subcat) { $ret[$subcat->getVar('parentid')][$subcat->getVar('categoryid')] = $subcat; } return $ret; }