function execute($request) { // Ticket Check if (!$GLOBALS['xoopsGTicket']->check(true, 'pico')) { redirect_header(XOOPS_URL . '/', 3, $GLOBALS['xoopsGTicket']->getErrors()); } parent::execute($request); // $categoryObj (not parent) $picoPermission =& PicoPermission::getInstance(); $categoryObj = new PicoCategory($this->mydirname, $request['cat_id'], $picoPermission->getPermissions($this->mydirname)); // check existence if ($categoryObj->isError()) { redirect_header(XOOPS_URL . "/modules/{$this->mydirname}/index.php", 2, _MD_PICO_ERR_READCONTENT); exit; } $cat_data = $categoryObj->getData(); // permission check if (empty($cat_data['isadminormod'])) { redirect_header(XOOPS_URL . '/', 2, _MD_PICO_ERR_CATEGORYMANAGER); } // cat_id != 0 check if ($cat_data['id'] == 0) { // LANGTD redirect_header(XOOPS_URL . '/', 2, 'top category cannot be deleted'); } // children check if (count($cat_data['redundants']['subcattree_raw']) > 0) { // LANGTD redirect_header(XOOPS_URL . '/', 2, 'child categories exist'); } // delete transaction pico_delete_category($this->mydirname, $request['cat_id']); // view $this->is_need_header_footer = false; }
function execute($request) { // Ticket Check if (!$GLOBALS['xoopsGTicket']->check(true, 'pico')) { redirect_header(XOOPS_URL . '/', 3, $GLOBALS['xoopsGTicket']->getErrors()); } parent::execute($request); // initialize $this->cat_id = $request['cat_id']; // $categoryObj (not parent) $picoPermission =& PicoPermission::getInstance(); $categoryObj = new PicoCategory($this->mydirname, $request['cat_id'], $picoPermission->getPermissions($this->mydirname)); // check existence if ($categoryObj->isError()) { redirect_header(XOOPS_URL . "/modules/{$this->mydirname}/index.php", 2, _MD_PICO_ERR_READCONTENT); exit; } $cat_data = $categoryObj->getData(); // permission check if (empty($cat_data['isadminormod'])) { redirect_header(XOOPS_URL . '/', 2, _MD_PICO_ERR_CATEGORYMANAGER); } // insert a category pico_updatecategory($this->mydirname, $this->cat_id); // view $this->is_need_header_footer = false; }
function pico_common_get_objects_from_content_id($mydirname, $content_id) { $picoPermission =& PicoPermission::getInstance(); $permissions = $picoPermission->getPermissions($mydirname); $cat_id = pico_common_get_cat_id_from_content_id($mydirname, $content_id); $categoryObj = new PicoCategory($mydirname, intval($cat_id), $permissions); $contentObj = new PicoContent($mydirname, $content_id, $categoryObj); return array($categoryObj, $contentObj); }
function execute($request) { // Ticket Check if (!$GLOBALS['xoopsGTicket']->check(true, 'pico')) { redirect_header(XOOPS_URL . '/', 3, $GLOBALS['xoopsGTicket']->getErrors()); } parent::execute($request); // initialize $cat_data = $this->currentCategoryObj->getData(); $picoPermission =& PicoPermission::getInstance(); // permission check if (empty($cat_data['can_post'])) { redirect_header(XOOPS_URL . '/', 2, _MD_PICO_ERR_MAKECONTENT); } // insert a content $content_id = pico_makecontent($this->mydirname); $content_uri4html = XOOPS_URL . "/modules/{$this->mydirname}/" . pico_common_make_content_link4html($this->mod_config, $content_id, $this->mydirname); // get contentObj $this->contentObj =& new PicoContent($this->mydirname, $content_id, $this->currentCategoryObj); $content_data = $this->contentObj->getData(); // return uri if (!empty($_GET['ret']) && ($ret_uri = pico_main_parse_ret2uri($this->mydirname, $_GET['ret']))) { $ret_uri4html = htmlspecialchars($ret_uri, ENT_QUOTES); } else { $ret_uri4html = $content_uri4html; } // calling a delegate if (class_exists('XCube_DelegateUtils')) { XCube_DelegateUtils::raiseEvent('ModuleClass.Pico.Contentman.InsertSuccess', $this->mydirname, $content_id, $cat_data, $ret_uri4html); } // create extra_tags for notifications $extra_tags = array('CONTENT_URL' => pico_common_unhtmlspecialchars($content_uri4html), 'APPROVAL_URL' => XOOPS_URL . "/modules/{$this->mydirname}/index.php?page=contentmanager&content_id={$content_id}", 'CAT_TITLE' => $cat_data['cat_title'], 'CONTENT_SUBJECT' => $content_data['subject_raw']); // users2notify (can_readfull only) $users2notify = $picoPermission->getUidsFromCatid($this->mydirname, $cat_data['id'], 'can_readfull'); if ($cat_data['post_auto_approved']) { // Notify for new content 'global' pico_main_trigger_event($this->mydirname, 'global', 0, 'newcontent', $extra_tags, $users2notify, 0); // Notify for new content 'category' of all parental categories foreach (array_keys($cat_data['paths_raw']) as $cat_id) { pico_main_trigger_event($this->mydirname, 'category', $cat_id, 'newcontent', $extra_tags, $users2notify, 0); } // message "registered" redirect_header($ret_uri4html, 2, _MD_PICO_MSG_CONTENTMADE); } else { // Notify for new waiting content (only for admin or mod) $users2notify = pico_main_get_moderators($this->mydirname, $cat_data['id']); if (empty($users2notify)) { $users2notify = array(0); } pico_main_trigger_event($this->mydirname, 'global', 0, 'waitingcontent', $extra_tags, $users2notify); // message "waiting approval" redirect_header($ret_uri4html, 2, _MD_PICO_MSG_CONTENTWAITINGREGISTER); } // view $this->is_need_header_footer = false; }
function PicoCategoryHandler($mydirname, $permissions = null) { $this->mydirname = $mydirname; if ($permissions) { $this->permissions = $permissions; } else { $picoPermission =& PicoPermission::getInstance(); $this->permissions = $picoPermission->getPermissions($mydirname); } }
function PicoControllerAbstract(&$currentCategoryObj) { global $xoopsUser; $this->currentCategoryObj =& $currentCategoryObj; $this->mydirname = $currentCategoryObj->mydirname; $this->mod_config = $currentCategoryObj->getOverriddenModConfig(); $this->uid = is_object($xoopsUser) ? $xoopsUser->getVar('uid') : 0; $picoPermission =& PicoPermission::getInstance(); $this->permissions = $picoPermission->getPermissions($this->mydirname); $this->assign = array('mymodname' => htmlspecialchars($currentCategoryObj->mod_name, ENT_QUOTES), 'mydirname' => $this->mydirname, 'mytrustdirname' => $this->mytrustdirname, 'mod_url' => XOOPS_URL . '/modules/' . $this->mydirname, 'mod_imageurl' => XOOPS_URL . '/modules/' . $this->mydirname . '/' . $this->mod_config['images_dir'], 'xoops_config' => $GLOBALS['xoopsConfig'], 'mod_config' => $this->mod_config, 'uid' => $this->uid); $this->template_name = $this->mydirname . '_index.html'; }
function pico_notify_base($mydirname, $category, $item_id) { include_once dirname(__FILE__) . '/include/common_functions.php'; $db =& Database::getInstance(); $module_handler =& xoops_gethandler('module'); $module =& $module_handler->getByDirname($mydirname); $picoPermission =& PicoPermission::getInstance(); $permissions = $picoPermission->getPermissions($mydirname); // global if ($category == 'global') { $item['name'] = ''; $item['url'] = ''; } // category if ($category == 'category') { // Assume we have a valid cat_id $cat_id = intval($item_id); $currentCategoryObj =& new PicoCategory($mydirname, intval($cat_id), $permissions); $cat_data = $currentCategoryObj->getData(); if (!$cat_data['can_read']) { return false; } $category4assign = $currentCategoryObj->getData4html(); // $item should be assigned HTML escaped data $item['name'] = $category4assign['cat_title']; $item['url'] = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/' . $category4assign['link']; } // content if ($category == 'content') { // Assume we have a valid content_id $content_id = intval($item_id); $cat_id = pico_common_get_cat_id_from_content_id($mydirname, $content_id); $currentCategoryObj =& new PicoCategory($mydirname, intval($cat_id), $permissions); $cat_data = $currentCategoryObj->getData(); if (!$cat_data['can_read']) { return false; } $contentObj =& new PicoContent($mydirname, $content_id, $currentCategoryObj); $content4assign = $contentObj->getData4html(); if (!$content4assign['can_read']) { return false; } // $item should be assigned HTML escaped data $item['name'] = $content4assign['subject']; $item['url'] = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/' . $content4assign['link']; } return $item; }
<?php require_once dirname(dirname(__FILE__)) . '/include/main_functions.php'; require_once dirname(dirname(__FILE__)) . '/include/common_functions.php'; require_once dirname(dirname(__FILE__)) . '/class/pico.textsanitizer.php'; require_once dirname(dirname(__FILE__)) . '/class/PicoUriMapper.class.php'; require_once dirname(dirname(__FILE__)) . '/class/PicoPermission.class.php'; require_once dirname(dirname(__FILE__)) . '/class/PicoModelCategory.class.php'; require_once dirname(dirname(__FILE__)) . '/class/PicoModelContent.class.php'; require_once XOOPS_TRUST_PATH . '/libs/altsys/class/AltsysBreadcrumbs.class.php'; // breadcrumbs $breadcrumbsObj =& AltsysBreadcrumbs::getInstance(); $breadcrumbsObj->appendPath(XOOPS_URL . '/modules/' . $mydirname . '/index.php', $xoopsModule->getVar('name')); // permissions $picoPermission =& PicoPermission::getInstance(); $permissions = $picoPermission->getPermissions($mydirname); // current category object (this "current" means "parent" $currentCategoryObj = new PicoCategory($mydirname, intval(@$_REQUEST['pid']), $permissions); if ($currentCategoryObj->isError()) { redirect_header(XOOPS_URL . "/modules/{$mydirname}/index.php", 2, _MD_PICO_ERR_READCATEGORY); exit; } // override $xoopsModuleConfig $xoopsModuleConfig = $currentCategoryObj->getOverriddenModConfig(); // append paths from each categories into breadcrumbs $breadcrumbsObj->appendPath($currentCategoryObj->getBreadcrumbs()); // request $picoRequest = array(); $picoRequest['makecategory'] = true; $picoRequest['cat_id'] = -1; if (!empty($_POST['categoryman_post'])) {
function PicoContent($mydirname, $content_id, $categoryObj = null, $allow_makenew = false) { $db =& Database::getInstance(); $this->id = $content_id; $this->mydirname = $mydirname; // get this "content" from given $content_id $sql = "SELECT * FROM " . $db->prefix($mydirname . "_contents") . " WHERE content_id={$content_id}"; if (!($ors = $db->query($sql))) { die(_MD_PICO_ERR_SQL . __LINE__); } if ($db->getRowsNum($ors) <= 0) { if ($allow_makenew && is_object($categoryObj)) { $content_row = $this->getBlankContentRow($categoryObj); } else { $this->errorno = 1; // the content does not exist return; } } else { $content_row = $db->fetchArray($ors); } // categoryObj $this->categoryObj =& $categoryObj; if (empty($this->categoryObj)) { $picoPermission =& PicoPermission::getInstance(); $permissions = $picoPermission->getPermissions($mydirname); $this->categoryObj = new PicoCategory($mydirname, $content_row['cat_id'], $permissions); } $cat_data = $this->categoryObj->getData(); $is_public = $content_row['visible'] && $content_row['created_time'] <= time() && $content_row['expiring_time'] > time(); $this->data = array('id' => intval($content_row['content_id']), 'created_time_formatted' => formatTimestamp($content_row['created_time']), 'modified_time_formatted' => formatTimestamp($content_row['modified_time']), 'expiring_time_formatted' => formatTimestamp($content_row['expiring_time']), 'subject_raw' => $content_row['subject'], 'body_raw' => $content_row['body'], 'isadminormod' => $cat_data['isadminormod'], 'public' => $is_public, 'can_read' => $cat_data['isadminormod'] || $cat_data['can_read'] && $is_public, 'can_readfull' => $cat_data['isadminormod'] || $cat_data['can_readfull'] && $is_public, 'can_edit' => $cat_data['isadminormod'] || $cat_data['can_edit'] && !$content_row['locked'] && $is_public, 'can_delete' => $cat_data['isadminormod'] || $cat_data['can_delete'] && !$content_row['locked'] && $is_public, 'ef' => pico_common_unserialize($content_row['extra_fields'])) + $content_row; }
function pico_get_requests4content($mydirname, &$errors, &$auto_approval, &$isadminormod, $content_id = 0) { global $xoopsUser; $myts =& MyTextSanitizer::getInstance(); $db =& Database::getInstance(); $picoPermission =& PicoPermission::getInstance(); $permissions = $picoPermission->getPermissions($mydirname); // First, fetch $cat_id $cat_id = intval(@$_POST['cat_id']); // requested category object $newCategoryObj =& new PicoCategory($mydirname, $cat_id, $permissions); if ($newCategoryObj->isError()) { redirect_header(XOOPS_URL . "/modules/{$mydirname}/index.php", 2, _MD_PICO_ERR_READCATEGORY); exit; } // recheck permissions and reload $config $mod_config = $newCategoryObj->getOverriddenModConfig(); $cat_data = $newCategoryObj->getData(); $auto_approval = $auto_approval && $cat_data['post_auto_approved']; $isadminormod = $isadminormod && $cat_data['isadminormod']; // build filters $filters = array(); foreach ($_POST as $key => $val) { if (substr($key, 0, 15) == 'filter_enabled_' && $val) { $name = str_replace('..', '', substr($key, 15)); $constpref = '_MD_PICO_FILTERS_' . strtoupper($name); $filter_file = dirname(dirname(__FILE__)) . '/filters/pico_' . $name . '.php'; if (!file_exists($filter_file)) { continue; } require_once $filter_file; if (!$isadminormod && defined($constpref . 'ISINSECURE')) { continue; } $filters[$name] = intval(@$_POST['filter_weight_' . $name]); } } asort($filters); // forced filters $filters_forced = array_map('trim', explode(',', $mod_config['filters_forced'])); foreach ($filters_forced as $filter_forced) { $regs = explode(':', $filter_forced); if (stristr($filter_forced, ':LAST')) { $filters[$regs[0]] = 0; } else { $filters = array($regs[0] => 0) + $filters; } } // prohibited filters $filters_prohibited = array_map('trim', explode(',', $mod_config['filters_prohibited'])); foreach ($filters_prohibited as $filter_prohibited) { unset($filters[$filter_prohibited]); } $ret = array('cat_id' => $cat_id, 'vpath' => trim($myts->stripSlashesGPC(@$_POST['vpath'])), 'subject' => $myts->stripSlashesGPC(@$_POST['subject']), 'htmlheader' => $myts->stripSlashesGPC(@$_POST['htmlheader']), 'body' => $myts->stripSlashesGPC(@$_POST['body']), 'filters' => implode('|', array_keys($filters)), 'tags' => trim($myts->stripSlashesGPC(@$_POST['tags'])), 'weight' => intval(@$_POST['weight']), 'use_cache' => empty($_POST['use_cache']) ? 0 : 1, 'show_in_navi' => empty($_POST['show_in_navi']) ? 0 : 1, 'show_in_menu' => empty($_POST['show_in_menu']) ? 0 : 1, 'allow_comment' => empty($_POST['allow_comment']) ? 0 : 1, 'categoryObj' => $newCategoryObj); // tags (finding a custom tag filter for each languages) $custom_tag_filter_file = dirname(dirname(__FILE__)) . '/language/' . $GLOBALS['xoopsConfig']['language'] . '/tag_filter.phtml'; if (file_exists($custom_tag_filter_file)) { require_once $custom_tag_filter_file; $tags_array = pico_custom_tag_filter($ret['tags']); } else { $tags_array = preg_split('/\\s+/', preg_replace('/[\\x00-\\x2f:-@\\x5b-\\x60\\x7b-\\x7f]/', ' ', $ret['tags'])); } $ret['tags'] = trim(implode(' ', array_unique($tags_array))); // vpath duplication check if ($ret['vpath']) { while (1) { list($count) = $db->fetchRow($db->query("SELECT COUNT(*) FROM " . $db->prefix($mydirname . "_contents") . " WHERE vpath='" . mysql_real_escape_string($ret['vpath']) . "' AND content_id<>" . intval($content_id))); if (empty($count)) { break; } $ext = strrchr($ret['vpath'], '.'); if ($ext) { $ret['vpath'] = str_replace($ext, '.1' . $ext, $ret['vpath']); } else { $ret['vpath'] .= '.1'; } $errors[] = _MD_PICO_ERR_DUPLICATEDVPATH; } } // approval if ($auto_approval) { $ret += array('subject_waiting' => '', 'htmlheader_waiting' => '', 'body_waiting' => '', 'visible' => empty($_POST['visible']) ? 0 : 1, 'approval' => 1); } else { $ret += array('subject_waiting' => $myts->stripSlashesGPC(@$_POST['subject']), 'htmlheader_waiting' => $myts->stripSlashesGPC(@$_POST['htmlheader']), 'body_waiting' => $myts->stripSlashesGPC(@$_POST['body']), 'visible' => 0, 'approval' => 0); } // created_time,modified_time,poster_uid,modifier_uid,locked if ($isadminormod) { $ret['specify_created_time'] = empty($_POST['specify_created_time']) ? 0 : 1; $ret['specify_modified_time'] = empty($_POST['specify_modified_time']) ? 0 : 1; $ret['specify_expiring_time'] = empty($_POST['specify_expiring_time']) ? 0 : 1; if ($ret['specify_created_time'] && strtotime(@$_POST['created_time']) != -1) { $created_time_safe = preg_replace('#[^\\s0-9a-zA-Z:+/-]#', '', $_POST['created_time']); $ret['created_time_formatted'] = $created_time_safe; $ret['created_time'] = pico_common_get_server_timestamp(strtotime($_POST['created_time'])); } if ($ret['specify_modified_time'] && strtotime(@$_POST['modified_time']) != -1) { $modified_time_safe = preg_replace('#[^\\s0-9a-zA-Z:+/-]#', '', $_POST['modified_time']); $ret['modified_time_formatted'] = $modified_time_safe; $ret['modified_time'] = pico_common_get_server_timestamp(strtotime($_POST['modified_time'])); } if ($ret['specify_expiring_time'] && strtotime(@$_POST['expiring_time']) != -1) { $expiring_time_safe = preg_replace('#[^\\s0-9a-zA-Z:+/-]#', '', $_POST['expiring_time']); $ret['expiring_time_formatted'] = $expiring_time_safe; $ret['expiring_time'] = pico_common_get_server_timestamp(strtotime($_POST['expiring_time'])); } $ret['locked'] = empty($_POST['locked']) ? 0 : 1; if (isset($_POST['poster_uid'])) { $ret['poster_uid'] = pico_main_get_uid($_POST['poster_uid']); } if (isset($_POST['modifier_uid'])) { $ret['modifier_uid'] = pico_main_get_uid($_POST['modifier_uid']); } } // HTML Purifier in Protector (only for PHP5) //'htmlpurify_except' , if (substr(PHP_VERSION, 0, 1) != 4 && file_exists(XOOPS_TRUST_PATH . '/modules/protector/library/HTMLPurifier.auto.php')) { if (is_object($xoopsUser)) { $purifier_enable = sizeof(array_intersect($xoopsUser->getGroups(), @$mod_config['htmlpurify_except'])) == 0; } else { $purifier_enable = true; } $purifier_enable = $purifier_enable && !isset($filters['htmlspecialchars']); if ($purifier_enable) { require_once XOOPS_TRUST_PATH . '/modules/protector/library/HTMLPurifier.auto.php'; $config = HTMLPurifier_Config::createDefault(); $config->set('Cache', 'SerializerPath', XOOPS_TRUST_PATH . '/modules/protector/configs'); $config->set('Core', 'Encoding', _CHARSET); //$config->set('HTML', 'Doctype', 'HTML 4.01 Transitional'); $purifier = new HTMLPurifier($config); $ret['body'] = $purifier->purify($ret['body']); } } // extra_fields (read ef class and create the object) $ef_class = empty($mod_config['extra_fields_class']) ? 'PicoExtraFields' : $mod_config['extra_fields_class']; require_once dirname(dirname(__FILE__)) . '/extra_fields/' . $ef_class . '.class.php'; $ef_obj =& new $ef_class($mydirname, $newCategoryObj, $content_id); $ret['extra_fields'] = $ef_obj->getSerializedRequestsFromPost(); $ret['ef_obj'] = $ef_obj; return $ret; }
function b_pico_list_show($options) { // options $mytrustdirname = basename(dirname(dirname(__FILE__))); $mydirname = empty($options[0]) ? $mytrustdirname : $options[0]; $categories = trim(@$options[1]) === '' ? array() : array_map('intval', explode(',', $options[1])); $selected_order = empty($options[2]) ? 'o.created_time DESC' : $options[2]; $limit_offset = empty($options[3]) ? '10' : preg_replace('/[^0-9,]/', '', $options[3]); if (strstr($limit_offset, ',')) { list($offset, $limit) = array_map('intval', explode(',', $limit_offset)); } else { $offset = 0; $limit = intval($limit_offset); } $this_template = empty($options[4]) ? 'db:' . $mydirname . '_block_list.html' : trim($options[4]); $display_body = empty($options[5]) ? false : true; $tags = empty($options[6]) ? '' : trim($options[6]); // mydirname check if (preg_match('/[^0-9a-zA-Z_-]/', $mydirname)) { die('Invalid mydirname'); } // module config (not overridden yet) $module_handler =& xoops_gethandler('module'); $module =& $module_handler->getByDirname($mydirname); $config_handler =& xoops_gethandler('config'); $mod_config = $config_handler->getConfigList($module->mid()); // content handler $content_handler =& new PicoContentHandler($mydirname); // contentObjects $picoPermission =& PicoPermission::getInstance(); $permissions = $picoPermission->getPermissions($mydirname); if (sizeof($categories) == 0) { // no category specified $mod_config_overridden = $mod_config; $contents4assign = $content_handler->getContents4assign('1', $selected_order, $offset, $limit, false, $tags); } else { if (sizeof($categories) == 1 && $categories[0] > 0) { // single category (not hierarchical) eg) cat_id=1 $cat_id = abs($categories[0]); $currentCategoryObj =& new PicoCategory($mydirname, $cat_id, $permissions); $mod_config_overridden = $currentCategoryObj->getOverriddenModConfig(); $contents4assign = $content_handler->getContents4assign('o.cat_id=' . $cat_id, $selected_order, $offset, $limit, false, $tags); } else { if (sizeof($categories) == 1 && $categories[0] < 0) { // single category (hierarchical) eg) cat_id=-1 $cat_id = abs($categories[0]); $currentCategoryObj =& new PicoCategory($mydirname, $cat_id, $permissions); $mod_config_overridden = $currentCategoryObj->getOverriddenModConfig(); $child_ids = $currentCategoryObj->getChildIds(); $contents4assign = $content_handler->getContents4assign('o.cat_id IN (' . $cat_id . ',' . implode(',', $child_ids) . ')', $selected_order, $offset, $limit, false, $tags); } else { // multi category eg) cat_id=1,2,3 $mod_config_overridden = $mod_config; $contents4assign = $content_handler->getContents4assign('o.cat_id IN (' . implode(',', $categories) . ')', $selected_order, $offset, $limit, false, $tags); } } } // compatibility for 1.5/1.6 foreach (array_keys($contents4assign) as $i) { $contents4assign[$i]['body'] = $display_body ? $contents4assign[$i]['body_cached'] : ''; } // constpref $constpref = '_MB_' . strtoupper($mydirname); // make an array named 'block' $block = array('mytrustdirname' => $mytrustdirname, 'mydirname' => $mydirname, 'mod_url' => XOOPS_URL . '/modules/' . $mydirname, 'mod_imageurl' => XOOPS_URL . '/modules/' . $mydirname . '/' . $mod_config_overridden['images_dir'], 'mod_config_overridden' => $mod_config_overridden, 'mod_config' => $mod_config, 'contents' => $contents4assign, 'display_body' => $display_body, 'lang_category' => constant($constpref . '_CATEGORY'), 'lang_topcategory' => constant($constpref . '_TOPCATEGORY')); if (empty($options['disable_renderer'])) { // render it require_once XOOPS_ROOT_PATH . '/class/template.php'; $tpl =& new XoopsTpl(); $tpl->assign('block', $block); $ret['content'] = $tpl->fetch($this_template); return $ret; } else { // just assign it return $block; } }
function execute($request) { parent::execute($request); // makecategory/categorymanager $page = empty($request['makecategory']) ? 'categorymanager' : 'makecategory'; // $categoryObj (not parent) $picoPermission =& PicoPermission::getInstance(); $categoryObj = new PicoCategory($this->mydirname, $request['cat_id'], $picoPermission->getPermissions($this->mydirname), $page == 'makecategory', $this->currentCategoryObj); // check existence if ($categoryObj->isError()) { redirect_header(XOOPS_URL . "/modules/{$this->mydirname}/index.php", 2, _MD_PICO_ERR_READCONTENT); exit; } // fetch data from DB $cat_data = $categoryObj->getData(); $this->assign['category_base'] = $categoryObj->getData4html(true); $this->categoryObjs['category_base'] =& $categoryObj; $this->assign['category'] = $categoryObj->getData4edit(); // permission check if ($page == 'makecategory') { $pcat_data = $this->currentCategoryObj->getData(); if (empty($pcat_data['can_makesubcategory'])) { redirect_header(XOOPS_URL . '/', 2, _MD_PICO_ERR_CREATECATEGORY); } } else { if (empty($cat_data['isadminormod'])) { redirect_header(XOOPS_URL . '/', 2, _MD_PICO_ERR_CATEGORYMANAGEMENT); } } // category list can be read for category jumpbox etc. $categoryHandler = new PicoCategoryHandler($this->mydirname, $this->permissions); $categories = $categoryHandler->getAllCategories(); $this->assign['categories_can_post'] = array(); foreach ($categories as $tmpObj) { $tmp_data = $tmpObj->getData(); if (empty($tmp_data['can_makesubcategory'])) { continue; } $this->assign['categories_can_makesubcategory'][$tmp_data['id']] = str_repeat('--', $tmp_data['cat_depth_in_tree']) . $tmp_data['cat_title']; } // breadcrumbs $breadcrumbsObj =& AltsysBreadcrumbs::getInstance(); if ($page == 'makecategory') { $breadcrumbsObj->appendPath('', _MD_PICO_LINK_MAKECATEGORY); $this->assign['xoops_pagetitle'] = _MD_PICO_LINK_MAKECATEGORY; } else { // $breadcrumbsObj->appendPath( XOOPS_URL.'/modules/'.$this->mydirname.'/'.$this->assign['category']['link'] , $this->assign['category']['title'] ) ; $breadcrumbsObj->appendPath('', _MD_PICO_CATEGORYMANAGER); $this->assign['xoops_pagetitle'] = _MD_PICO_CATEGORYMANAGER; } $this->assign['xoops_breadcrumbs'] = $breadcrumbsObj->getXoopsbreadcrumbs(); // misc assigns $this->assign['page'] = $page; $this->assign['formtitle'] = $page == 'makecategory' ? _MD_PICO_LINK_MAKECATEGORY : _MD_PICO_CATEGORYMANAGER; $this->assign['gticket_hidden'] = $GLOBALS['xoopsGTicket']->getTicketHtml(__LINE__, 1800, 'pico'); $this->assign['category']['option_desc'] = $this->getCategoryOptions4edit(); $this->assign['category']['wraps_directories'] = array('' => '---') + pico_main_get_wraps_directories_recursively($this->mydirname, '/'); // views $this->template_name = $this->mydirname . '_main_category_form.html'; $this->is_need_header_footer = true; }