/** * Create the criteria that will be used by getPictures and getPicturesCount * * @param int $start to which record to start * @param int $limit limit of pictures to return * @param int $uid_owner if specifid, only the pictures of this user will be returned * @param int $picture_id ID of a single picture to retrieve * @return icms_db_criteria_Compo $criteria */ private function getPicturesCriteria($start = 0, $limit = 0, $uid_owner = false, $picture_id = false) { $module = icms::handler("icms_module")->getByDirname(basename(dirname(dirname(__FILE__))), TRUE); $criteria = new icms_db_criteria_Compo(); if ($start) { $criteria->setStart((int) $start); } if ($limit) { $criteria->setLimit((int) $limit); } $criteria->setSort('creation_time'); if ($module->config['images_order']) { $criteria->setOrder('DESC'); } if (is_object(icms::$user)) { if (icms::$user->getVar('uid') != $uid_owner && !icms::$user->isAdmin()) { $criteria->add(new icms_db_criteria_Item('private', 0)); } } else { $criteria->add(new icms_db_criteria_Item('private', 0)); } if ($uid_owner) { $criteria->add(new icms_db_criteria_Item('uid_owner', (int) $uid_owner)); } if ($picture_id) { $criteria->add(new icms_db_criteria_Item('pictures_id', (int) $picture_id)); } return $criteria; }
/** * Return all categories in an array * * @param int $parentid * @param string $perm_name * @param string $sort * @param string $order * @return array */ public function getAllCategoriesArray($parentid = 0, $perm_name = false, $sort = 'parentid', $order = 'ASC') { if (!$this->allCategoriesObj) { $criteria = new icms_db_criteria_Compo(); $criteria->setSort($sort); $criteria->setOrder($order); $userIsAdmin = is_object(icms::$user) && icms::$user->isAdmin(); if ($perm_name && !$userIsAdmin) { if (!$this->setGrantedObjectsCriteria($criteria, $perm_name)) { return false; } } $this->allCategoriesObj =& $this->getObjects($criteria, 'parentid'); } $ret = array(); if (isset($this->allCategoriesObj[$parentid])) { foreach ($this->allCategoriesObj[$parentid] as $categoryid => $categoryObj) { $ret[$categoryid]['self'] =& $categoryObj->toArray(); if (isset($this->allCategoriesObj[$categoryid])) { $ret[$categoryid]['sub'] =& $this->getAllCategoriesArray($categoryid); $ret[$categoryid]['subcatscount'] = count($ret[$categoryid]['sub']); } } } return $ret; }
/** * * @param arr $item_ids_array * @param str $gperm_name */ public function getGrantedGroupsForIds($item_ids_array, $gperm_name = false) { static $groups; if ($gperm_name) { if (isset($groups[$gperm_name])) { return $groups[$gperm_name]; } } else { // if !$gperm_name then we will fetch all permissions in the module so we don't need them again return $groups; } $icmsModule =& $this->handler->getModuleInfo(); $criteria = new icms_db_criteria_Compo(); $criteria->add(new icms_db_criteria_Item('gperm_modid', $icmsModule->getVar('mid'))); if ($gperm_name) { $criteria->add(new icms_db_criteria_Item('gperm_name', $gperm_name)); } //Get group permissions handler $gperm_handler = icms::handler('icms_member_groupperm'); $permissionsObj = $gperm_handler->getObjects($criteria); foreach ($permissionsObj as $permissionObj) { $groups[$permissionObj->getVar('gperm_name')][$permissionObj->getVar('gperm_itemid')][] = $permissionObj->getVar('gperm_groupid'); } //Return the permission array if ($gperm_name) { return isset($groups[$gperm_name]) ? $groups[$gperm_name] : array(); } else { return isset($groups) ? $groups : array(); } }
/** * Function to be triggered at the end of the core boot process * * @return void */ function eventStartOutputInit() { global $xoopsTpl; if (is_object(icms::$user)) { foreach (icms::$user->vars as $key => $value) { $user[$key] = $value; } foreach ($user as $key => $value) { foreach ($user [$key] as $key1 => $value1) { if ($key1 == 'value') { if ($key == 'last_login') { $value1 = formatTimestamp( isset($_SESSION['xoopsUserLastLogin']) ? $_SESSION['xoopsUserLastLogin'] : time(), _DATESTRING ); } $user [$key] = $value1; } } } $pm_handler = icms::handler('icms_data_privmessage'); $criteria = new icms_db_criteria_Compo(new icms_db_criteria_Item('read_msg', 0)); $criteria->add(new icms_db_criteria_Item('to_userid', icms::$user->getVar('uid'))); $user['new_messages'] = $pm_handler->getCount($criteria); $xoopsTpl->assign('user', $user); } }
function b_profile_usermenu_show($options) { global $icmsConfigUser; if (!is_object(icms::$user)) { return; } icms_loadLanguageFile(basename(dirname(dirname(__FILE__))), 'modinfo'); $block = array(); $dirname = basename(dirname(dirname(__FILE__))); $config_handler = icms::handler('icms_config'); $privmessage_handler = icms::handler('icms_data_privmessage'); $module = icms::handler('icms_module')->getByDirname($dirname, TRUE); $criteria = new icms_db_criteria_Compo(); $criteria->add(new icms_db_criteria_Item('read_msg', 0)); $criteria->add(new icms_db_criteria_Item('to_userid', icms::$user->getVar('uid'))); $newmsg = $privmessage_handler->getCount($criteria); $i = 0; if (icms::$user->isAdmin()) { $block[++$i]['name'] = _MB_SYSTEM_ADMENU; $block[$i]['url'] = ICMS_URL . "/admin.php"; } $block[++$i]['name'] = _MB_SYSTEM_VACNT; $block[$i]['url'] = ICMS_URL . "/modules/" . $dirname . "/" . ($module->config['profile_social'] ? "index.php?uid=" . icms::$user->getVar('uid') : "userinfo.php?uid=" . icms::$user->getVar('uid')); $block[++$i]['name'] = _MB_SYSTEM_INBOX; $block[$i]['url'] = ICMS_URL . "/viewpmsg.php"; $block[$i]['extra'] = $newmsg; $block[++$i]['name'] = _MB_SYSTEM_NOTIF; $block[$i]['url'] = ICMS_URL . "/notifications.php"; if ($module->config['profile_social']) { $block[++$i]['name'] = _MI_PROFILE_SEARCH; $block[$i]['url'] = ICMS_URL . "/modules/" . $dirname . "/search.php"; } $block[++$i]['name'] = _MI_PROFILE_EDITACCOUNT; $block[$i]['url'] = ICMS_URL . "/modules/" . $dirname . "/edituser.php"; $block[++$i]['name'] = _MI_PROFILE_CHANGEPASS; $block[$i]['url'] = ICMS_URL . "/modules/" . $dirname . "/changepass.php"; if ($icmsConfigUser['allow_chgmail']) { $block[++$i]['name'] = _MI_PROFILE_CHANGEMAIL; $block[$i]['url'] = ICMS_URL . "/modules/" . $dirname . "/changemail.php"; } if ($icmsConfigUser['self_delete']) { $block[++$i]['name'] = _MI_PROFILE_DELETEACCOUNT; $block[$i]['url'] = ICMS_URL . "/modules/" . $dirname . "/edituser.php?op=delete"; } if ($module->config['profile_social']) { $block[++$i]['name'] = _MI_PROFILE_MYCONFIGS; $block[$i]['url'] = ICMS_URL . "/modules/" . $dirname . "/configs.php"; } $block[++$i]['name'] = _MB_SYSTEM_LOUT; $block[$i]['url'] = ICMS_URL . "/user.php?op=logout"; return $block; }
/** * Get fields visible to the $user_groups on a $profile_groups profile * * @param array $user_groups * @param array $profile_groups * @return array */ public function getVisibleFields($user_groups, $profile_groups) { $profile_groups[] = 0; $user_groups[] = 0; $rtn = array(); $criteria = new icms_db_criteria_Compo(); $criteria->add(new icms_db_criteria_Item('profile_group', '(' . implode(',', $profile_groups) . ')', 'IN')); $criteria->add(new icms_db_criteria_Item('user_group', '(' . implode(',', $user_groups) . ')', 'IN')); $visibilities = $this->getObjects($criteria); foreach ($visibilities as $visibility) { $rtn[] = $visibility->getVar('fieldid'); } return array_unique($rtn); }
/** * Get an array of plugins * @param string $path * @return multitype: */ public function getPluginsArray($path) { $module_handler = icms::handler('icms_module'); $criteria = new icms_db_criteria_Compo(); $criteria->add(new icms_db_criteria_Item('isactive', 1)); $tempModulesObj = $module_handler->getObjects($criteria); $modulesObj = array(); foreach ($tempModulesObj as $moduleObj) { $modulesObj[$moduleObj->getVar('dirname')] = $moduleObj; } $aFiles = str_replace('.php', '', icms_core_Filesystem::getFileList(ICMS_ROOT_PATH . '/plugins/' . $path . '/', '', array('php'))); $ret = array(); foreach ($aFiles as $pluginName) { $module_xoops_version_file = ICMS_ROOT_PATH . "/modules/{$pluginName}/xoops_version.php"; $module_icms_version_file = ICMS_ROOT_PATH . "/modules/{$pluginName}/icms_version.php"; if ((file_exists($module_xoops_version_file) || file_exists($module_icms_version_file)) && isset($modulesObj[$pluginName])) { $ret[$pluginName] = $modulesObj[$pluginName]->getVar('name'); } } return $ret; }
/** * Constructor * @param object $object reference to targetobject (@link icms_ipf_Object) * @param string $key the form name */ public function __construct($object, $key) { $category_title_field = $object->handler->identifierName; $addNoParent = isset($object->controls[$key]['addNoParent']) ? $object->controls[$key]['addNoParent'] : true; $criteria = new icms_db_criteria_Compo(); $criteria->setSort("weight, " . $category_title_field); $category_handler = icms_getModuleHandler('category', $object->handler->_moduleName); $categories = $category_handler->getObjects($criteria); $mytree = new icms_ipf_Tree($categories, "category_id", "category_pid"); parent::__construct($object->vars[$key]['form_caption'], $key, $object->getVar($key, 'e')); $ret = array(); $options = $this->getOptionArray($mytree, $category_title_field, 0, $ret, ""); if ($addNoParent) { $newOptions = array('0' => '----'); foreach ($options as $k => $v) { $newOptions[$k] = $v; } $options = $newOptions; } $this->addOptionArray($options); }
function smarty_function_xoInboxCount($params, &$smarty) { if (!isset(icms::$user) || !is_object(icms::$user)) { return; } $time = time(); if (isset($_SESSION['xoops_inbox_count']) && @$_SESSION['xoops_inbox_count_expire'] > $time) { $count = (int) $_SESSION['xoops_inbox_count']; } else { $pm_handler = icms::handler('icms_data_privmessage'); $criteria = new icms_db_criteria_Compo(new icms_db_criteria_Item('read_msg', 0)); $criteria->add(new icms_db_criteria_Item('to_userid', icms::$user->getVar('uid'))); $count = (int) $pm_handler->getCount($criteria); $_SESSION['xoops_inbox_count'] = $count; $_SESSION['xoops_inbox_count_expire'] = $time + 60; } if (!@empty($params['assign'])) { $smarty->assign($params['assign'], $count); } else { echo $count; } }
/** * Return search results and show images on userinfo page * * @param array $queryarray the terms to look * @param text $andor the conector between the terms to be looked * @param int $limit The number of maximum results * @param int $offset from wich register start * @param int $userid from which user to look * @return array $ret with all results */ function profile_search($queryarray, $andor, $limit, $offset, $userid) { global $icmsConfigUser; $ret = array(); $i = 0; $dirname = basename(dirname(dirname(__FILE__))); // check if anonymous users can access profiles if (!is_object(icms::$user) && !$icmsConfigUser['allow_annon_view_prof']) { return $ret; } // check if tribes are activated in module configuration $module = icms::handler('icms_module')->getByDirname($dirname, TRUE); if (!$module->config['enable_tribes']) { return $ret; } $profile_tribes_handler = icms_getModuleHandler('tribes', basename(dirname(dirname(__FILE__))), 'profile'); $criteria = new icms_db_criteria_Compo(); // if those two lines are uncommented, "all search results" isn't showing in the search results //if ($offset) $criteria->setStart($offset); //if ($limit) $criteria->setLimit((int)$limit); $criteria->setSort('title'); if ($userid) { $criteria->add(new icms_db_criteria_Item('uid_owner', $userid)); } if (is_array($queryarray) && count($queryarray) > 0) { foreach ($queryarray as $query) { $criteria_query = new icms_db_criteria_Compo(); $criteria_query->add(new icms_db_criteria_Item('title', '%' . $query . '%', 'LIKE')); $criteria_query->add(new icms_db_criteria_Item('tribe_desc', '%' . $query . '%', 'LIKE'), 'OR'); $criteria->add($criteria_query, $andor); unset($criteria_query); } } $tribes = $profile_tribes_handler->getObjects($criteria, false, false); foreach ($tribes as $tribe) { $ret[$i++] = array("image" => 'images/tribes.gif', "link" => $tribe['itemUrl'], "title" => $tribe['title'], "time" => strtotime($tribe['creation_time']), "uid" => $tribe['uid_owner']); } return $ret; }
/** * Create the criteria that will be used by getPosts * * @param int $start to which record to start * @param int $limit limit of posts to return * @param int $post_id id of the post * @param int $topic_id id of the topic the post belongs to * @param int $tribes_id id of the tribe the topic / post belongs to * @param string $order sort order for the result list * @return icms_db_criteria_Compo $criteria */ private function getPostCriteria($start = 0, $limit = 0, $post_id = false, $topic_id = false, $tribes_id = false, $order = 'ASC') { $criteria = new icms_db_criteria_Compo(); if ($start) { $criteria->setStart((int) $start); } if ($limit) { $criteria->setLimit((int) $limit); } $criteria->setSort('post_id'); $criteria->setOrder($order); if ($post_id) { $criteria->add(new icms_db_criteria_Item('post_id', (int) $post_id)); } if ($topic_id) { $criteria->add(new icms_db_criteria_Item('topic_id', (int) $topic_id)); } if ($tribes_id) { $criteria->add(new icms_db_criteria_Item('tribes_id', (int) $tribes_id)); } return $criteria; }
/** * Create the criteria that will be used by getVisitors * * @param int $start to which record to start * @param int $limit limit of tribes to return * @param int $uid_owner if specifid, only the tribes of this user will be returned * @param int $uid_visitor if specified, only the records with the specified user as a visitor will be returned * @param int $visit_time if specified, only records with a visit time greater than the specified on will be returned * @return icms_db_criteria_Compo $criteria */ private function getVisitorsCriteria($start = 0, $limit = 0, $uid_owner = false, $uid_visitor = false, $visit_time = false) { $criteria = new icms_db_criteria_Compo(); if ($start) { $criteria->setStart((int) $start); } if ($limit) { $criteria->setLimit((int) $limit); } $criteria->setSort('visit_time'); $criteria->setOrder('DESC'); if ($uid_owner) { $criteria->add(new icms_db_criteria_Item('uid_owner', (int) $uid_owner)); } if ($uid_visitor) { $criteria->add(new icms_db_criteria_Item('uid_visitor', (int) $uid_visitor)); } if ($visit_time) { $criteria->add(new icms_db_criteria_Item('visit_time', $visit_time, '>=')); } return $criteria; }
/** * Create the criteria that will be used by getTopics * * @param int $start to which record to start * @param int $limit limit of topics to return * @param int $topic_id id of the topic * @param int $tribes_id id of the tribe the topic belongs to * @return icms_db_criteria_Compo $criteria */ private function getTopicCriteria($start = 0, $limit = 0, $topic_id = false, $tribes_id = false) { $criteria = new icms_db_criteria_Compo(); if ($start) { $criteria->setStart((int) $start); } if ($limit) { $criteria->setLimit((int) $limit); } $criteria->setSort('last_post_time'); $criteria->setOrder('DESC'); if ($topic_id) { $criteria->add(new icms_db_criteria_Item('topic_id', (int) $topic_id)); } if ($tribes_id) { $criteria->add(new icms_db_criteria_Item('tribes_id', (int) $tribes_id)); } return $criteria; }
/** * Create the criteria that will be used by getAudios and getAudioCount * * @param int $start to which record to start * @param int $limit limit of audio to return * @param int $uid_owner if specifid, only the audio of this user will be returned * @param int $audio_id ID of a single audio to retrieve * @return icms_db_criteria_Compo $criteria */ private function getAudioCriteria($start = 0, $limit = 0, $uid_owner = false, $audio_id = false) { $criteria = new icms_db_criteria_Compo(); if ($start) { $criteria->setStart((int) $start); } if ($limit) { $criteria->setLimit((int) $limit); } if ($uid_owner) { $criteria->add(new icms_db_criteria_Item('uid_owner', (int) $uid_owner)); } if ($audio_id) { $criteria->add(new icms_db_criteria_Item('audio_id', (int) $audio_id)); } $criteria->setSort('creation_time'); $criteria->setOrder('DESC'); return $criteria; }
/** * Create the criteria that will be used by getConfigs and getConfigsCount * * @param int $start to which record to start * @param int $limit limit of configs to return * @param int $uid_owner if specifid, only the configs of this user will be returned * @param int $configs_id ID of a single config to retrieve * @return icms_db_criteria_Compo $criteria */ private function getConfigsCriteria($start = 0, $limit = 0, $uid_owner = false, $configs_id = false) { $criteria = new icms_db_criteria_Compo(); if ($start) { $criteria->setStart((int) $start); } if ($limit) { $criteria->setLimit((int) $limit); } if ($uid_owner) { $criteria->add(new icms_db_criteria_Item('config_uid', (int) $uid_owner)); } if ($configs_id) { $criteria->add(new icms_db_criteria_Item('configs_id', (int) $configs_id)); } return $criteria; }
/** * Constructor * * @param string $caption * @param string $name * @param mixed $value Pre-selected value (or array of them). * For an item with massive members, such as "Registered Users", "$value" should be used to store selected temporary users only instead of all members of that item * @param bool $include_anon Include user "anonymous"? * @param int $size Number or rows. "1" makes a drop-down-list. * @param bool $multiple Allow multiple selections? */ public function __construct($caption, $name, $include_anon = FALSE, $value = NULL, $size = 1, $multiple = FALSE, $showremovedusers = FALSE, $justremovedusers = FALSE) { $limit = 200; $select_element = new icms_form_elements_Select('', $name, $value, $size, $multiple); if ($include_anon) { $select_element->addOption(0, $GLOBALS['icmsConfig']['anonymous']); } $member_handler = icms::handler('icms_member'); $user_count = $member_handler->getUserCount(); $value = is_array($value) ? $value : (empty($value) ? array() : array($value)); if ($user_count > $limit && count($value) > 0) { $criteria = new icms_db_criteria_Compo(new icms_db_criteria_Item("uid", "(" . implode(",", $value) . ")", "IN")); } else { $criteria = new icms_db_criteria_Compo(); $criteria->setLimit($limit); } $criteria->setSort('uname'); if (!$showremovedusers) { $criteria->add(new icms_db_criteria_Item('level', '-1', '!=')); } elseif ($showremovedusers && $justremovedusers) { $criteria->add(new icms_db_criteria_Item('level', '-1')); } $criteria->setOrder('ASC'); $users = $member_handler->getUserList($criteria); $select_element->addOptionArray($users); if ($user_count <= $limit) { parent::__construct($caption, "", $name); $this->addElement($select_element); return; } icms_loadLanguageFile('core', 'findusers'); $js_addusers = "<script type=\"text/javascript\">\r\n\t\t\t\t\tfunction addusers(opts){\r\n\t\t\t\t\t\tvar num = opts.substring(0, opts.indexOf(\":\"));\r\n\t\t\t\t\t\topts = opts.substring(opts.indexOf(\":\")+1, opts.length);\r\n\t\t\t\t\t\tvar sel = xoopsGetElementById(\"" . $name . ($multiple ? "[]" : "") . "\");\r\n\t\t\t\t\t\tvar arr = new Array(num);\r\n\t\t\t\t\t\tfor (var n=0; n < num; n++) {\r\n\t\t\t\t\t\t\tvar nm = opts.substring(0, opts.indexOf(\":\"));\r\n\t\t\t\t\t\t\topts = opts.substring(opts.indexOf(\":\")+1, opts.length);\r\n\t\t\t\t\t\t\tvar val = opts.substring(0, opts.indexOf(\":\"));\r\n\t\t\t\t\t\t\topts = opts.substring(opts.indexOf(\":\")+1, opts.length);\r\n\t\t\t\t\t\t\tvar txt = opts.substring(0, nm - val.length);\r\n\t\t\t\t\t\t\topts = opts.substring(nm - val.length, opts.length);\r\n\t\t\t\t\t\t\tvar added = false;\r\n\t\t\t\t\t\t\tfor (var k = 0; k < sel.options.length; k++) {\r\n\t\t\t\t\t\t\t\tif (sel.options[k].value == val){\r\n\t\t\t\t\t\t\t\t\tadded = true;\r\n\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tif (added == false) {\r\n\t\t\t\t\t\t\t\tsel.options[k] = new Option(txt, val);\r\n\t\t\t\t\t\t\t\tsel.options[k].selected = true;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t}\r\n\t\t\t\t\t</script>"; $token = icms::$security->createToken(); $action_tray = new icms_form_elements_Tray("", " | "); $action_tray->addElement(new icms_form_elements_Label('', "<a href='#' onclick='var sel = xoopsGetElementById(\"" . $name . ($multiple ? "[]" : "") . "\");for (var i = sel.options.length-1; i >= 0; i--) {if (!sel.options[i].selected) {sel.options[i] = null;}}; return false;'>" . _MA_USER_REMOVE . "</a>")); $action_tray->addElement(new icms_form_elements_Label('', "<a href='#' onclick='openWithSelfMain(\"" . ICMS_URL . "/include/findusers.php?target={$name}&multiple={$multiple}&token={$token}\", \"userselect\", 800, 600, null); return false;' >" . _MA_USER_MORE . "</a>" . $js_addusers)); parent::__construct($caption, '<br /><br />', $name); $this->addElement($select_element); $this->addElement($action_tray); }
/** * Does the template exist in the database in the template set * * @param string $tplname template name * @param string $tplset_name template set name * @return bool true if exists, false if not **/ public function templateExists($tplname, $tplset_name) { $criteria = new icms_db_criteria_Compo(new icms_db_criteria_Item('tpl_file', trim($tplname))); $criteria->add(new icms_db_criteria_Item('tpl_tplset', trim($tplset_name))); if ($this->getCount($criteria) > 0) { return true; } return false; }
/** * generate the modid (combination of current module and page) and store it in a static var * isStart is only needed for this class (used in function retrieveBlocks()). * * @global array $icmsConfig ImpressCMS configuration array * @global icms_module_Object $icmsModule current module * @return void */ public static function getPage() { global $icmsConfig, $icmsModule; if (is_array(self::$modid)) { return self::$modid; } // getting the start module and page configured in the admin panel if (is_array($icmsConfig['startpage'])) { $member_handler = icms::handler('icms_member'); $group = $member_handler->getUserBestGroup(is_object(icms::$user) ? icms::$user->getVar('uid') : 0); $icmsConfig['startpage'] = $icmsConfig['startpage'][$group]; } $startMod = $icmsConfig['startpage'] == '--' ? 'system' : $icmsConfig['startpage']; // setting the full and relative url of the actual page $clean_request = filter_var($_SERVER['REQUEST_URI'], FILTER_SANITIZE_URL); $fullurl = icms::$urls['http'] . icms::$urls['httphost'] . $clean_request; $url = substr(str_replace(ICMS_URL, '', $fullurl), 1); $icms_page_handler = icms::handler('icms_data_page'); $criteria = new icms_db_criteria_Compo(new icms_db_criteria_Item('page_url', $fullurl)); if (!empty($url)) { $criteria->add(new icms_db_criteria_Item('page_url', $url), 'OR'); } $pages = $icms_page_handler->getCount($criteria); if ($pages > 0) { // we have a sym-link defined for this page $pages = $icms_page_handler->getObjects($criteria); $page = $pages[0]; $purl = filter_var($page->getVar('page_url'), FILTER_SANITIZE_URL); $mid = (int) $page->getVar('page_moduleid'); $pid = $page->getVar('page_id'); $module_handler = icms::handler('icms_module'); $module = $module_handler->get($mid); $dirname = $module->getVar('dirname'); $isStart = $startMod == $mid . '-' . $pid; } else { // we don't have a sym-link for this page if (is_object($icmsModule)) { $mid = (int) $icmsModule->getVar('mid'); $dirname = $icmsModule->getVar('dirname'); $isStart = substr($_SERVER['PHP_SELF'], -9) == 'index.php' && $startMod == $dirname; } else { $mid = 1; $dirname = 'system'; $isStart = !empty($GLOBALS['xoopsOption']['show_cblock']); } $pid = 0; } /* determine the visitor's start page and update the request based on that? */ if ($isStart) { self::$modid = array('module' => 0, 'page' => 1, 'isStart' => $isStart); } else { $criteria = new icms_db_criteria_Compo(new icms_db_criteria_Item('page_status', 1)); $pages = $icms_page_handler->getObjects($criteria); $pid = 0; foreach ($pages as $page) { $purl = filter_var($page->getVar('page_url'), FILTER_SANITIZE_URL); if (substr($purl, -1) == '*') { $purl = substr($purl, 0, -1); if (substr($url, 0, strlen($purl)) == $purl || substr($fullurl, 0, strlen($purl)) == $purl) { $pid = $page->getVar('page_id'); break; } } else { if ($purl == $url || $purl == $fullurl) { $pid = $page->getVar('page_id'); break; } } } self::$modid = array('module' => $mid, 'page' => $pid, 'isStart' => $isStart); } return self::$modid; }
/** * build options string * * @param mixed $value module-page combination * @return string html */ private function getPageSelOptions($value = NULL) { $icms_page_handler = icms::handler('icms_data_page'); if (!is_array($value)) { $value = array($value); } $module_handler = icms::handler('icms_module'); $criteria = new icms_db_criteria_Compo(new icms_db_criteria_Item('hasmain', 1)); $criteria->add(new icms_db_criteria_Item('isactive', 1)); $module_list = $module_handler->getObjects($criteria); $mods = ''; foreach ($module_list as $module) { $mods .= '<optgroup label="' . $module->getVar('name') . '">'; $criteria = new icms_db_criteria_Compo(new icms_db_criteria_Item('page_moduleid', $module->getVar('mid'))); $criteria->add(new icms_db_criteria_Item('page_status', 1)); $pages = $icms_page_handler->getObjects($criteria); $sel = ''; if (in_array($module->getVar('mid') . '-0', $value)) { $sel = ' selected=selected'; } $mods .= '<option value="' . $module->getVar('mid') . '-0"' . $sel . '>' . _AM_ALLPAGES . '</option>'; foreach ($pages as $page) { $sel = ''; if (in_array($module->getVar('mid') . '-' . $page->getVar('page_id'), $value)) { $sel = ' selected=selected'; } $mods .= '<option value="' . $module->getVar('mid') . '-' . $page->getVar('page_id') . '"' . $sel . '>'; $mods .= $page->getVar('page_title') . '</option>'; } $mods .= '</optgroup>'; } $module = $module_handler->get(1); $criteria = new icms_db_criteria_Compo(new icms_db_criteria_Item('page_moduleid', 1)); $criteria->add(new icms_db_criteria_Item('page_status', 1)); $pages = $icms_page_handler->getObjects($criteria); $cont = ''; if (count($pages) > 0) { $cont = '<optgroup label="' . $module->getVar('name') . '">'; $sel = ''; if (in_array($module->getVar('mid') . '-0', $value)) { $sel = ' selected=selected'; } $cont .= '<option value="' . $module->getVar('mid') . '-0"' . $sel . '>' . _AM_ALLPAGES . '</option>'; foreach ($pages as $page) { $sel = ''; if (in_array($module->getVar('mid') . '-' . $page->getVar('page_id'), $value)) { $sel = ' selected=selected'; } $cont .= '<option value="' . $module->getVar('mid') . '-' . $page->getVar('page_id') . '"' . $sel . '>'; $cont .= $page->getVar('page_title') . '</option>'; } $cont .= '</optgroup>'; } $sel = $sel1 = ''; if (in_array('0-1', $value)) { $sel = ' selected=selected'; } if (in_array('0-0', $value)) { $sel1 = ' selected=selected'; } $ret = '<option value="0-1"' . $sel . '>' . _AM_TOPPAGE . '</option>'; $ret .= '<option value="0-0"' . $sel1 . '>' . _AM_ALLPAGES . '</option>'; $ret .= $cont . $mods; return $ret; }
/** * * @param $fetchOnly * @param $debug */ public function render($fetchOnly = false, $debug = false) { global $impresscms; $this->_tpl = new icms_view_Tpl(); /** * We need access to the vars of the icms_ipf_Object for a few things in the table creation. * Since we may not have an icms_ipf_Object to look into now, let's create one for this purpose * and we will free it after */ $this->_tempObject =& $this->_objectHandler->create(); $this->_criteria->setStart(isset($_GET['start' . $this->_objectHandler->keyName]) ? (int) $_GET['start' . $this->_objectHandler->keyName] : 0); $this->setSortOrder(); if (!$this->_isTree) { $this->_limitsel = isset($_GET['limitsel']) ? $_GET['limitsel'] : icms_getCookieVar($_SERVER['SCRIPT_NAME'] . '_limitsel', '15'); } else { $this->_limitsel = 'all'; } $this->_limitsel = isset($_POST['limitsel']) ? $_POST['limitsel'] : $this->_limitsel; icms_setCookieVar($_SERVER['SCRIPT_NAME'] . '_limitsel', $this->_limitsel); $limitsArray = $this->getLimitsArray(); $this->_criteria->setLimit($this->_limitsel); $this->_filtersel = isset($_GET['filtersel']) ? $_GET['filtersel'] : $this->getDefaultFilter(); $this->_filtersel = isset($_POST['filtersel']) ? $_POST['filtersel'] : $this->_filtersel; icms_setCookieVar($_SERVER['SCRIPT_NAME'] . '_' . $this->_id . '_filtersel', $this->_filtersel); $filtersArray = $this->getFiltersArray(); if ($filtersArray) { $this->_tpl->assign('icms_optionssel_filtersArray', $filtersArray); } // Check if the selected filter is defined and if so, create the selfilter2 if (isset($this->_filterseloptions[$this->_filtersel])) { // check if method associate with this filter exists in the handler if (is_array($this->_filterseloptions[$this->_filtersel])) { $filter = $this->_filterseloptions[$this->_filtersel]; $this->_criteria->add($filter['criteria']); } else { if (method_exists($this->_objectHandler, $this->_filterseloptions[$this->_filtersel])) { // then we will create the selfilter2 options by calling this method $method = $this->_filterseloptions[$this->_filtersel]; $this->_filtersel2options = $this->_objectHandler->{$method}(); $this->_filtersel2 = isset($_GET['filtersel2']) ? $_GET['filtersel2'] : $this->getDefaultFilter2(); $this->_filtersel2 = isset($_POST['filtersel2']) ? $_POST['filtersel2'] : $this->_filtersel2; $filters2Array = $this->getFilters2Array(); $this->_tpl->assign('icms_optionssel_filters2Array', $filters2Array); icms_setCookieVar($_SERVER['SCRIPT_NAME'] . '_filtersel2', $this->_filtersel2); if ($this->_filtersel2 != 'default') { $this->_criteria->add(new icms_db_criteria_Item($this->_filtersel, $this->_filtersel2)); } } } } // Check if we have a quicksearch if (isset($_POST['quicksearch_' . $this->_id]) && $_POST['quicksearch_' . $this->_id] != '') { $quicksearch_criteria = new icms_db_criteria_Compo(); if (is_array($this->_quickSearch['fields'])) { foreach ($this->_quickSearch['fields'] as $v) { $quicksearch_criteria->add(new icms_db_criteria_Item($v, '%' . $_POST['quicksearch_' . $this->_id] . '%', 'LIKE'), 'OR'); } } else { $quicksearch_criteria->add(new icms_db_criteria_Item($this->_quickSearch['fields'], '%' . $_POST['quicksearch_' . $this->_id] . '%', 'LIKE')); } $this->_criteria->add($quicksearch_criteria); } $this->_objects = $this->fetchObjects($debug); /** * $params_of_the_options_sel is an array with all the parameters of the page * but without the pagenave parameters. This array will be used in the * OptionsSelection */ $params_of_the_options_sel = array(); if ($this->_criteria->getLimit() > 0) { /** * Geeting rid of the old params * $new_get_array is an array containing the new GET parameters */ $new_get_array = array(); $not_needed_params = array('sortsel', 'limitsel', 'ordersel', 'start' . $this->_objectHandler->keyName); foreach ($_GET as $k => $v) { if (!in_array($k, $not_needed_params)) { $new_get_array[] = "{$k}={$v}"; $params_of_the_options_sel[] = "{$k}={$v}"; } } /** * Adding the new params of the pagenav */ $new_get_array[] = "sortsel=" . $this->_sortsel; $new_get_array[] = "ordersel=" . $this->_ordersel; $new_get_array[] = "limitsel=" . $this->_limitsel; $otherParams = implode('&', $new_get_array); $pagenav = new icms_view_PageNav($this->_objectHandler->getCount($this->_criteria), $this->_criteria->getLimit(), $this->_criteria->getStart(), 'start' . $this->_objectHandler->keyName, $otherParams); $this->_tpl->assign('icms_pagenav', $pagenav->renderNav()); } $this->renderOptionSelection($limitsArray, $params_of_the_options_sel); // retreive the current url and the query string $current_url = $impresscms->urls['full_phpself']; $query_string = $impresscms->urls['querystring']; if ($query_string) { $query_string = str_replace('?', '', $query_string); } $query_stringArray = explode('&', $query_string); $new_query_stringArray = array(); foreach ($query_stringArray as $query_string) { if (strpos($query_string, 'sortsel') == FALSE && strpos($query_string, 'ordersel') == FALSE) { $new_query_stringArray[] = $query_string; } } $new_query_string = implode('&', $new_query_stringArray); $orderArray = array(); $orderArray['ASC']['image'] = 'desc.png'; $orderArray['ASC']['neworder'] = 'DESC'; $orderArray['DESC']['image'] = 'asc.png'; $orderArray['DESC']['neworder'] = 'ASC'; $aColumns = array(); foreach ($this->_columns as $column) { $aColumn = array(); $aColumn['width'] = $column->getWidth(); $aColumn['align'] = $column->getAlign(); $aColumn['key'] = $column->getKeyName(); if ($column->_keyname == 'checked') { $aColumn['caption'] = '<input type ="checkbox" id="checkall_icmspersistableobjects" name="checkall_icmspersistableobjects"' . ' value="checkall_icmspersistableobjects" onclick="icms_checkall(window.document.form_' . $this->_id . ', \'selected_icmspersistableobjects\');" />'; } elseif ($column->getCustomCaption()) { $aColumn['caption'] = $column->getCustomCaption(); } else { $aColumn['caption'] = isset($this->_tempObject->vars[$column->getKeyName()]['form_caption']) ? $this->_tempObject->vars[$column->getKeyName()]['form_caption'] : $column->getKeyName(); } // Are we doing a GET sort on this column ? $getSort = isset($_GET[$this->_objectHandler->_itemname . '_' . 'sortsel']) && $_GET[$this->_objectHandler->_itemname . '_' . 'sortsel'] == $column->getKeyName() || $this->_sortsel == $column->getKeyName(); $order = isset($_GET[$this->_objectHandler->_itemname . '_' . 'ordersel']) ? $_GET[$this->_objectHandler->_itemname . '_' . 'ordersel'] : 'DESC'; if (isset($_REQUEST['quicksearch_' . $this->_id]) && $_REQUEST['quicksearch_' . $this->_id] != '') { $filter = isset($_POST['quicksearch_' . $this->_id]) ? INPUT_POST : INPUT_GET; $qs_param = "&quicksearch_" . $this->_id . "=" . filter_input($filter, 'quicksearch_' . $this->_id, FILTER_SANITIZE_SPECIAL_CHARS); } else { $qs_param = ''; } if (!$this->_enableColumnsSorting || $column->_keyname == 'checked' || !$column->_sortable) { $aColumn['caption'] = $aColumn['caption']; } elseif ($getSort) { $aColumn['caption'] = '<a href="' . $current_url . '?' . $this->_objectHandler->_itemname . '_' . 'sortsel=' . $column->getKeyName() . '&' . $this->_objectHandler->_itemname . '_' . 'ordersel=' . $orderArray[$order]['neworder'] . $qs_param . '&' . $new_query_string . '">' . $aColumn['caption'] . ' <img src="' . ICMS_IMAGES_SET_URL . '/actions/' . $orderArray[$order]['image'] . '" alt="ASC" /></a>'; } else { $aColumn['caption'] = '<a href="' . $current_url . '?' . $this->_objectHandler->_itemname . '_' . 'sortsel=' . $column->getKeyName() . '&' . $this->_objectHandler->_itemname . '_' . 'ordersel=ASC' . $qs_param . '&' . $new_query_string . '">' . $aColumn['caption'] . '</a>'; } $aColumns[] = $aColumn; } $this->_tpl->assign('icms_columns', $aColumns); if ($this->_quickSearch) { $this->_tpl->assign('icms_quicksearch', $this->_quickSearch['caption']); } $this->createTableRows(); $this->_tpl->assign('icms_showFilterAndLimit', $this->_showFilterAndLimit); $this->_tpl->assign('icms_isTree', $this->_isTree); $this->_tpl->assign('icms_show_action_column_title', $this->_showActionsColumnTitle); $this->_tpl->assign('icms_table_header', $this->_tableHeader); $this->_tpl->assign('icms_table_footer', $this->_tableFooter); $this->_tpl->assign('icms_printer_friendly_page', $this->_printerFriendlyPage); $this->_tpl->assign('icms_user_side', $this->_userSide); $this->_tpl->assign('icms_has_actions', $this->_hasActions); $this->_tpl->assign('icms_head_css_class', $this->_head_css_class); $this->_tpl->assign('icms_actionButtons', $this->_actionButtons); $this->_tpl->assign('icms_introButtons', $this->_introButtons); $this->_tpl->assign('icms_id', $this->_id); if (!empty($this->_withSelectedActions)) { $this->_tpl->assign('icms_withSelectedActions', $this->_withSelectedActions); } $icms_table_template = $this->_customTemplate ? $this->_customTemplate : 'system_persistabletable_display.html'; if ($fetchOnly) { return $this->_tpl->fetch('db:' . $icms_table_template); } else { $this->_tpl->display('db:' . $icms_table_template); } }
*/ defined("ICMS_ROOT_PATH") or die("ImpressCMS root path not defined"); // create form $search_form = new icms_form_Theme(_SR_SEARCH, "search", "search.php", 'get'); // create form elements $search_form->addElement(new icms_form_elements_Text(_SR_KEYWORDS, "query", 30, 255, htmlspecialchars(stripslashes(implode(" ", $queries)), ENT_QUOTES)), true); $type_select = new icms_form_elements_Select(_SR_TYPE, "andor", $andor); $type_select->addOptionArray(array("AND" => _SR_ALL, "OR" => _SR_ANY, "exact" => _SR_EXACT)); $search_form->addElement($type_select); if (!empty($mids)) { $mods_checkbox = new icms_form_elements_Checkbox(_SR_SEARCHIN, "mids[]", $mids); } else { $mods_checkbox = new icms_form_elements_Checkbox(_SR_SEARCHIN, "mids[]", $mid); } if (empty($modules)) { $criteria = new icms_db_criteria_Compo(); $criteria->add(new icms_db_criteria_Item('hassearch', 1)); $criteria->add(new icms_db_criteria_Item('isactive', 1)); if (!empty($available_modules)) { $criteria->add(new icms_db_criteria_Item('mid', "(" . implode(',', $available_modules) . ")", 'IN')); } $module_handler = icms::handler('icms_module'); $mods_checkbox->addOptionArray($module_handler->getList($criteria)); } else { unset($module); foreach (array_keys($modules) as $mid) { $module_array[$mid] = $modules[$mid]->getVar('name'); } $mods_checkbox->addOptionArray($module_array); } $search_form->addElement($mods_checkbox);
$changed = true; } if ($obj->getVar('content_visibility', 'e') != $_POST['content_visibility'][$k]) { $obj->setVar('content_visibility', (int) $_POST['content_visibility'][$k]); $changed = true; } if ($changed) { $content_content_handler->insert($obj); } } redirect_header('content.php', 2, _AM_CONTENT_CONTENT_MODIFIED); break; default: icms_cp_header(); icms::$module->displayAdminMenu(0, _AM_CONTENT_CONTENTS); $criteria = new icms_db_criteria_Compo(); $criteria->add(new icms_db_criteria_Item('content_pid', $clean_content_pid)); $objectTable = new icms_ipf_view_Table($content_content_handler, $criteria); $objectTable->addColumn(new icms_ipf_view_Column('content_title', false, false, 'getPreviewItemLink')); $objectTable->addColumn(new icms_ipf_view_Column('content_subs', 'center', 100)); $objectTable->addColumn(new icms_ipf_view_Column('counter', 'center', 100)); $objectTable->addColumn(new icms_ipf_view_Column('content_status', 'center', 150, 'getContent_statusControl')); $objectTable->addColumn(new icms_ipf_view_Column('content_visibility', 'center', 150, 'getContent_visibleControl')); $objectTable->addColumn(new icms_ipf_view_Column('content_published_date', 'center', 150)); $objectTable->addActionButton('changedField', false, _SUBMIT); $objectTable->addCustomAction('getViewItemLink'); $objectTable->addCustomAction('getCloneItemLink'); $objectTable->addIntroButton('addcontent', 'content.php?op=mod' . ($clean_content_pid ? '&content_pid=' . $clean_content_pid : ''), _AM_CONTENT_CONTENT_CREATE); $objectTable->addQuickSearch(array('content_title', 'content_body')); $objectTable->addFilter('content_status', 'getContent_statusArray'); $objectTable->addFilter('content_uid', 'getPostersArray');
/** * Creates a multidimensional array with items of the dropdown menus of the admin panel. * This array will be saved, by the function xoops_module_write_admin_menu, in a cache file * to preserve resources of the server and to maintain compatibility with some modules Xoops. * * @author TheRplima * * @return array (content of admin panel dropdown menus) */ function impresscms_get_adminmenu() { $admin_menu = array(); $modules_menu = array(); $systemadm = false; ######################################################################### # Control Panel Home menu ######################################################################### $menu[0] = array('link' => ICMS_URL . '/admin.php', 'title' => _CPHOME, 'absolute' => 1, 'small' => ICMS_URL . '/modules/system/images/mini_cp.png'); $menu[] = array('link' => ICMS_URL, 'title' => _YOURHOME, 'absolute' => 1, 'small' => ICMS_URL . '/modules/system/images/home.png'); $menu[] = array('link' => ICMS_URL . '/user.php?op=logout', 'title' => _LOGOUT, 'absolute' => 1, 'small' => ICMS_URL . '/modules/system/images/logout.png'); $admin_menu[0] = array('id' => 'cphome', 'text' => _CPHOME, 'link' => '#', 'menu' => $menu); ######################################################################### # end ######################################################################### ######################################################################### # System Preferences menu ######################################################################### $module_handler = icms::handler('icms_module'); $mod =& $module_handler->getByDirname('system'); $menu = array(); foreach ($mod->getAdminMenu() as $lkn) { $lkn['dir'] = 'system'; $menu[] = $lkn; } $admin_menu[] = array('id' => 'opsystem', 'text' => _SYSTEM, 'link' => ICMS_URL . '/modules/system/admin.php', 'menu' => $menu); ######################################################################### # end ######################################################################### ######################################################################### # Modules menu ######################################################################### $module_handler = icms::handler('icms_module'); $criteria = new icms_db_criteria_Compo(); $criteria->add(new icms_db_criteria_Item('hasadmin', 1)); $criteria->add(new icms_db_criteria_Item('isactive', 1)); $modules = $module_handler->getObjects($criteria); usort($modules, 'impresscms_sort_adminmenu_modules'); foreach ($modules as $module) { $rtn = array(); $inf =& $module->getInfo(); $rtn['link'] = ICMS_URL . '/modules/' . $module->getVar('dirname') . '/' . (isset($inf['adminindex']) ? $inf['adminindex'] : ''); $rtn['title'] = $module->getVar('name'); $rtn['dir'] = $module->getVar('dirname'); if (isset($inf['iconsmall']) && $inf['iconsmall'] != '') { $rtn['small'] = ICMS_URL . '/modules/' . $module->getVar('dirname') . '/' . $inf['iconsmall']; } if (isset($inf['iconbig']) && $inf['iconbig'] != '') { $rtn['iconbig'] = ICMS_URL . '/modules/' . $module->getVar('dirname') . '/' . $inf['iconbig']; } $rtn['absolute'] = 1; $rtn['subs'] = array(); $module->loadAdminMenu(); if (is_array($module->adminmenu) && count($module->adminmenu) > 0) { foreach ($module->adminmenu as $item) { $item['link'] = ICMS_URL . '/modules/' . $module->getVar('dirname') . '/' . $item['link']; $rtn['subs'][] = $item; } } $hasconfig = $module->getVar('hasconfig'); $hascomments = $module->getVar('hascomments'); if (isset($hasconfig) && $hasconfig == 1 || isset($hascomments) && $hascomments == 1) { $subs = array('title' => _PREFERENCES, 'link' => ICMS_URL . '/modules/system/admin.php?fct=preferences&op=showmod&mod=' . $module->getVar('mid')); $rtn['subs'][] = $subs; } $rtn['hassubs'] = count($rtn['subs']) > 0 ? 1 : 0; if ($rtn['hassubs'] == 0) { unset($rtn['subs']); } if ($module->getVar('dirname') == 'system') { $systemadm = true; } $modules_menu[] = $rtn; } $admin_menu[] = array('id' => 'modules', 'text' => _MODULES, 'link' => ICMS_URL . '/modules/system/admin.php?fct=modulesadmin', 'menu' => $modules_menu); ######################################################################### # end ######################################################################### ######################################################################### # ImpressCMS News Feed menu ######################################################################### $menu = array(); $menu[] = array('link' => 'http://www.impresscms.org', 'title' => _IMPRESSCMS_HOME, 'absolute' => 1); if (_LANGCODE != 'en') { $menu[] = array('link' => _IMPRESSCMS_LOCAL_SUPPORT, 'title' => _IMPRESSCMS_LOCAL_SUPPORT_TITLE, 'absolute' => 1); } $menu[] = array('link' => 'http://community.impresscms.org', 'title' => _IMPRESSCMS_COMMUNITY, 'absolute' => 1); $menu[] = array('link' => 'http://addons.impresscms.org', 'title' => _IMPRESSCMS_ADDONS, 'absolute' => 1); $menu[] = array('link' => 'http://wiki.impresscms.org', 'title' => _IMPRESSCMS_WIKI, 'absolute' => 1); $menu[] = array('link' => 'http://blog.impresscms.org', 'title' => _IMPRESSCMS_BLOG, 'absolute' => 1); $menu[] = array('link' => 'https://impresscmsdev.assembla.com/spaces/impresscms/new_dashboard', 'title' => _IMPRESSCMS_PROJECT, 'absolute' => 1); /* $menu[] = array( 'link' => 'http://www.impresscms.org/donations/', 'title' => _IMPRESSCMS_DONATE, 'absolute' => 1, //'small' = ICMS_URL . '/images/impresscms.png', ); */ $menu[] = array('link' => ICMS_URL . '/admin.php?rssnews=1', 'title' => _IMPRESSCMS_NEWS, 'absolute' => 1); $admin_menu[] = array('id' => 'news', 'text' => _ABOUT, 'link' => '#', 'menu' => $menu); ######################################################################### # end ######################################################################### return $admin_menu; }
/** * Shows The latest comments * * @param array $options The block options * @return array $block the block array */ function b_system_comments_show($options) { $block = array(); include_once ICMS_ROOT_PATH . '/include/comment_constants.php'; $comment_handler = icms::handler('icms_data_comment'); $criteria = new icms_db_criteria_Compo(new icms_db_criteria_Item('com_status', XOOPS_COMMENT_ACTIVE)); $criteria->setLimit((int) $options[0]); $criteria->setSort('com_created'); $criteria->setOrder('DESC'); // Check modules permissions $moduleperm_handler = icms::handler('icms_member_groupperm'); $gperm_groupid = is_object(icms::$user) ? icms::$user->getGroups() : array(XOOPS_GROUP_ANONYMOUS); $criteria1 = new icms_db_criteria_Compo(new icms_db_criteria_Item('gperm_name', 'module_read', '=')); $criteria1->add(new icms_db_criteria_Item('gperm_groupid', '(' . implode(',', $gperm_groupid) . ')', 'IN')); $perms = $moduleperm_handler->getObjects($criteria1, TRUE); $modIds = array(); foreach ($perms as $item) { $modIds[] = $item->getVar('gperm_itemid'); } if (count($modIds) > 0) { $modIds = array_unique($modIds); $criteria->add(new icms_db_criteria_Item('com_modid', '(' . implode(',', $modIds) . ')', 'IN')); } // Check modules permissions $comments = $comment_handler->getObjects($criteria, TRUE); $member_handler = icms::handler('icms_member'); $module_handler = icms::handler('icms_module'); $modules = $module_handler->getObjects(new icms_db_criteria_Item('hascomments', 1), TRUE); $comment_config = array(); foreach (array_keys($comments) as $i) { $mid = $comments[$i]->getVar('com_modid'); $com['module'] = '<a href="' . ICMS_MODULES_URL . '/' . $modules[$mid]->getVar('dirname') . '/">' . $modules[$mid]->getVar('name') . '</a>'; if (!isset($comment_config[$mid])) { $comment_config[$mid] = $modules[$mid]->getInfo('comments'); } $com['id'] = $i; $com['title'] = '<a href="' . ICMS_MODULES_URL . '/' . $modules[$mid]->getVar('dirname') . '/' . $comment_config[$mid]['pageName'] . '?' . $comment_config[$mid]['itemName'] . '=' . $comments[$i]->getVar('com_itemid') . '&com_id=' . $i . '&com_rootid=' . $comments[$i]->getVar('com_rootid') . '&' . htmlspecialchars($comments[$i]->getVar('com_exparams')) . '#comment' . $i . '">' . $comments[$i]->getVar('com_title') . '</a>'; $com['icon'] = htmlspecialchars($comments[$i]->getVar('com_icon'), ENT_QUOTES); $com['icon'] = ($com['icon'] != '') ? $com['icon'] : 'icon1.gif'; $com['time'] = formatTimestamp($comments[$i]->getVar('com_created'), 'm'); if ($comments[$i]->getVar('com_uid') > 0) { $poster =& $member_handler->getUser($comments[$i]->getVar('com_uid')); if (is_object($poster)) { $com['poster'] = '<a href="' . ICMS_URL . '/userinfo.php?uid=' . $comments[$i]->getVar('com_uid') . '">' . $poster->getVar('uname') . '</a>'; } else { $com['poster'] = $GLOBALS['icmsConfig']['anonymous']; } } else { $com['poster'] = $GLOBALS['icmsConfig']['anonymous']; } $block['comments'][] =& $com; unset($com); } return $block; }
/** * The listing of the images for the image manager * @param int $imgcat_id The imageCatID to get the listing for * @param int $start The start offset to get the listing for * @return string the fetched and construced template */ function imanager_listimg($imgcat_id, $start = 0) { global $icmsTpl, $target, $type; if (!is_object(icms::$user)) { $groups = array(XOOPS_GROUP_ANONYMOUS); $admin = FALSE; } else { $groups =& icms::$user->getGroups(); $admin = (!icms::$user->isAdmin(1)) ? FALSE : TRUE; } $query = isset($_POST['query']) ? $_POST['query'] : NULL; if ($imgcat_id <= 0) { redirect_header($_SERVER['SCRIPT_NAME'] . '?op=list&target=' . $target . '&type=' . $type, 1, ''); } $imgcat_handler = icms::handler('icms_image_category'); $imagecategory =& $imgcat_handler->get($imgcat_id); $categ_path = $imgcat_handler->getCategFolder($imagecategory); $categ_url = $imgcat_handler->getCategFolder($imagecategory, 1, 'url'); if (!is_object($imagecategory)) { redirect_header($_SERVER['SCRIPT_NAME'] . '?op=list&target=' . $target . '&type=' . $type, 1); } $icmsTpl->assign('admnav', adminNav($imgcat_id, '/', 1)); $icmsTpl->assign('lang_imanager_title', _IMGMANAGER); $icmsTpl->assign('lang_imanager_catmsize', _MD_IMAGECATMSIZE); $icmsTpl->assign('lang_imanager_catmwidth', _MD_IMAGECATMWIDTH); $icmsTpl->assign('lang_imanager_catmheight', _MD_IMAGECATMHEIGHT); $icmsTpl->assign('lang_imanager_catstype', _MD_IMAGECATSTYPE); $icmsTpl->assign('lang_imanager_catdisp', _MD_IMAGECATDISP); $icmsTpl->assign('lang_imanager_catsubs', _MD_IMAGECATSUBS); $icmsTpl->assign('lang_imanager_catqtde', _MD_IMAGECATQTDE); $icmsTpl->assign('lang_imanager_catoptions', _MD_IMAGECATOPTIONS); $icmsTpl->assign('lang_imanager_cat_edit', _EDIT); $icmsTpl->assign('lang_imanager_cat_clone', _CLONE); $icmsTpl->assign('lang_imanager_cat_del', _DELETE); $icmsTpl->assign('lang_imanager_cat_listimg', _LIST); $icmsTpl->assign('lang_imanager_cat_submit', _SUBMIT); $icmsTpl->assign('lang_imanager_cat_back', _BACK); $icmsTpl->assign('lang_imanager_cat_addimg', _ADDIMAGE); $icmsTpl->assign('lang_imanager_cat_addnewcat', _MD_ADDIMGCATBTN); $icmsTpl->assign('lang_imanager_cat_addnewimg', _MD_ADDIMGBTN); $icmsTpl->assign('cat_maxsize', icms_convert_size($imagecategory->getVar('imgcat_maxsize'))); $icmsTpl->assign('cat_maxwidth', $imagecategory->getVar('imgcat_maxwidth')); $icmsTpl->assign('cat_maxheight', $imagecategory->getVar('imgcat_maxheight')); $icmsTpl->assign('cat_storetype', $imagecategory->getVar('imgcat_storetype')); $icmsTpl->assign('cat_display', $imagecategory->getVar('imgcat_display')); $icmsTpl->assign('cat_id', $imagecategory->getVar('imgcat_id')); $criteriaRead = new icms_db_criteria_Compo(); if (is_array($groups) && !empty($groups)) { $criteriaTray = new icms_db_criteria_Compo(); foreach ($groups as $gid) { $criteriaTray->add(new icms_db_criteria_Item('gperm_groupid', $gid), 'OR'); } $criteriaRead->add($criteriaTray); $criteriaRead->add(new icms_db_criteria_Item('gperm_name', 'imgcat_read')); $criteriaRead->add(new icms_db_criteria_Item('gperm_modid', 1)); } $criteriaRead->add(new icms_db_criteria_Item('imgcat_pid', $imagecategory->getVar('imgcat_id'))); $subcats = $imgcat_handler->getObjects($criteriaRead); $subs = count($subcats); $icmsTpl->assign('cat_subs', $subs); $image_handler = icms::handler('icms_image'); $criteriaRead = new icms_db_criteria_Compo(); if (is_array($groups) && !empty($groups)) { $criteriaTray = new icms_db_criteria_Compo(); foreach ($groups as $gid) { $criteriaTray->add(new icms_db_criteria_Item('gperm_groupid', $gid), 'OR'); } $criteriaRead->add($criteriaTray); $criteriaRead->add(new icms_db_criteria_Item('gperm_name', 'imgcat_read')); $criteriaRead->add(new icms_db_criteria_Item('gperm_modid', 1)); } $id = (!is_null($imgcat_id) ? $imgcat_id : 0); $criteriaRead->add(new icms_db_criteria_Item('imgcat_pid', $imagecategory->getVar('imgcat_id'))); $ssubs = $imgcat_handler->getObjects($criteriaRead); $sc = 0; foreach ($ssubs as $id=>$va) { $sc += $image_handler->getCount(new icms_db_criteria_Item('imgcat_id', $va->getVar('imgcat_id'))); } $scount = $sc; $icmsTpl->assign('simgcount', $scount); $icmsTpl->assign('lang_imanager_img_preview', _PREVIEW); $icmsTpl->assign('lang_image_name', _IMAGENAME); $icmsTpl->assign('lang_image_mimetype', _IMAGEMIME); $icmsTpl->assign('lang_image_cat', _IMAGECAT); $icmsTpl->assign('lang_image_weight', _IMGWEIGHT); $icmsTpl->assign('lang_image_disp', _IMGDISPLAY); $icmsTpl->assign('lang_submit', _SUBMIT); $icmsTpl->assign('lang_cancel', _CANCEL); $icmsTpl->assign('lang_yes', _YES); $icmsTpl->assign('lang_no', _NO); $icmsTpl->assign('lang_search', _SEARCH); $icmsTpl->assign('lang_select', _SELECT); $icmsTpl->assign('lang_search_title', _QSEARCH); $icmsTpl->assign('lang_imanager_img_editor', 'DHTML Image Editor'); $icmsTpl->assign('icms_root_path', ICMS_ROOT_PATH); $icmsTpl->assign('query', $query); $icmsTpl->assign('target', $target); $icmsTpl->assign('type', $type); $image_handler = icms::handler('icms_image'); $criteria = new icms_db_criteria_Compo(new icms_db_criteria_Item('imgcat_id', $imgcat_id)); if (!is_null($query)) { $criteria->add(new icms_db_criteria_Item('image_nicename', $query . '%', 'LIKE')); } $imgcount = $image_handler->getCount($criteria); $criteria->setStart($start); $criteria->setOrder('DESC'); $criteria->setSort('image_weight'); $criteria->setLimit(15); $images =& $image_handler->getObjects($criteria, TRUE, TRUE); $icmsTpl->assign('imgcount', $imgcount); $arrimg = array(); foreach (array_keys($images) as $i) { $arrimg[$i]['id'] = $images[$i]->getVar('image_id'); $arrimg[$i]['name'] = $images[$i]->getVar('image_name'); $arrimg[$i]['nicename'] = $images[$i]->getVar('image_nicename'); $arrimg[$i]['mimetype'] = $images[$i]->getVar('image_mimetype'); $arrimg[$i]['weight'] = $images[$i]->getVar('image_weight'); $arrimg[$i]['display'] = $images[$i]->getVar('image_display'); $arrimg[$i]['categ_id'] = $images[$i]->getVar('imgcat_id'); $arrimg[$i]['display_nicename'] = icms_core_DataFilter::icms_substr($images[$i]->getVar('image_nicename'), 0, 20); $uniq = icms_random_str(5); if ($imagecategory->getVar('imgcat_storetype') == 'db') { $src = ICMS_MODULES_URL . "/system/admin/images/preview.php?file=" . $images[$i]->getVar('image_name') . '&resize=0'; $img = WideImage::load($images[$i]->getVar('image_body'))->saveToFile(ICMS_IMANAGER_FOLDER_PATH . '/' . $images[$i]->getVar('image_name')); $arrimg[$i]['size'] = icms_convert_size(filesize(ICMS_IMANAGER_FOLDER_PATH . '/' . $images[$i]->getVar('image_name'))); $img_info = WideImage::load(ICMS_IMANAGER_FOLDER_PATH . '/' . $images[$i]->getVar('image_name')); $arrimg[$i]['width'] = $img_info->getWidth(); $arrimg[$i]['height'] = $img_info->getHeight(); @unlink(ICMS_IMANAGER_FOLDER_PATH . '/' . $images[$i]->getVar('image_name')); $path = ICMS_IMANAGER_FOLDER_PATH . '/'; $arrimg[$i]['lcode'] = '[img align=left id=' . $images[$i]->getVar('image_id') . ']' . $images[$i]->getVar('image_nicename') . '[/img]'; $arrimg[$i]['code'] = '[img align=center id=' . $images[$i]->getVar('image_id') . ']' . $images[$i]->getVar('image_nicename') . '[/img]'; $arrimg[$i]['rcode'] = '[img align=right id=' . $images[$i]->getVar('image_id') . ']' . $images[$i]->getVar('image_nicename') . '[/img]'; } else { $url = (substr($categ_url, -1) != '/') ? $categ_url . '/' : $categ_url; $path = (substr($categ_path, -1) != '/') ? $categ_path . '/' : $categ_path; $src = $url . $images[$i]->getVar('image_name'); $arrimg[$i]['size'] = icms_convert_size(filesize($path . $images[$i]->getVar('image_name'))); $img_info = WideImage::load($path . $images[$i]->getVar('image_name')); $arrimg[$i]['width'] = $img_info->getWidth(); $arrimg[$i]['height'] = $img_info->getHeight(); $arrimg[$i]['lcode'] = '[img align=left]' . $url . $images[$i]->getVar('image_name') . '[/img]'; $arrimg[$i]['code'] = '[img align=center]' . $url . $images[$i]->getVar('image_name') . '[/img]'; $arrimg[$i]['rcode'] = '[img align=right]' . $url . $images[$i]->getVar('image_name') . '[/img]'; } $arrimg[$i]['src'] = $src . '?' . time(); $arrimg[$i]['url_src'] = str_replace(ICMS_URL, '', $src); $src_lightbox = ICMS_MODULES_URL . "/system/admin/images/preview.php?file=" . $images[$i]->getVar('image_name'); $preview_url = '<a href="' . $src_lightbox . '" rel="lightbox[categ' . $images[$i]->getVar('imgcat_id') . ']" title="' . $images[$i]->getVar('image_nicename') . '"><img src="'. ICMS_IMAGES_SET_URL . '/actions/viewmag.png" alt="' . _PREVIEW . '" title="' . _PREVIEW . '" /></a>'; $arrimg[$i]['preview_link'] = $preview_url; $extra_perm = array("image/jpeg", "image/jpeg", "image/png", "image/gif"); if (in_array($images[$i]->getVar('image_mimetype'), $extra_perm)) { $arrimg[$i]['hasextra_link'] = 1; if (file_exists(ICMS_LIBRARIES_PATH . '/image-editor/image-edit.php')) { $arrimg[$i]['editor_link'] = 'window.open(\'' . ICMS_LIBRARIES_URL . '/image-editor/image-edit.php?image_id=' . $images[$i]->getVar('image_id') . '&uniq=' . $uniq . '&target=' . $target . '&type=' . $type . '\', \'icmsDHTMLImageEditor\',\'width=800,height=600,left=\'+parseInt(screen.availWidth/2-400)+\',top=\'+parseInt(screen.availHeight/2-350)+\',resizable=no,location=no,menubar=no,status=no,titlebar=no,scrollbars=no\'); return FALSE;'; } else { $arrimg[$i]['editor_link'] = ''; } } else { $arrimg[$i]['hasextra_link'] = 0; } $list =& $imgcat_handler->getList(array(), NULL, NULL, $imagecategory->getVar('imgcat_storetype')); $div = ''; foreach ($list as $value => $name) { $sel = ''; if ($value == $images[$i]->getVar('imgcat_id')) { $sel = ' selected="selected"'; } $div .= '<option value="' . $value . '"' . $sel . '>' . $name . '</option>'; } $arrimg[$i]['ed_selcat_options'] = $div; $arrimg[$i]['ed_token'] = icms::$security->getTokenHTML(); $arrimg[$i]['clone_token'] = icms::$security->getTokenHTML(); } $icmsTpl->assign('images', $arrimg); if ($imgcount > 0) { if ($imgcount > 15) { $nav = new icms_view_PageNav($imgcount, 15, $start, 'start', 'op=listimg&imgcat_id=' . $imgcat_id . '&type=' . $type . '&target=' . $target); $icmsTpl->assign('pag', '<div class="img_list_info_panel" align="center">' . $nav->renderNav() . '</div>'); } else { $icmsTpl->assign('pag', ''); } } else { $icmsTpl->assign('pag', ''); } $icmsTpl->assign('addimgform', showAddImgForm($imgcat_id)); return $icmsTpl->fetch(ICMS_MODULES_PATH . '/system/templates/admin/images/system_popup_imagemanager_imglist.html'); }
function icms_module_update($dirname) { $dirname = trim($dirname); $db =& icms_db_Factory::instance(); $module_handler = icms::handler('icms_module'); $module =& $module_handler->getByDirname($dirname); // Save current version for use in the update function $prev_version = $module->getVar('version'); $prev_dbversion = $module->getVar('dbversion'); xoops_template_clear_module_cache($module->getVar('mid')); // we dont want to change the module name set by admin $temp_name = $module->getVar('name'); $module->loadInfoAsVar($dirname); $module->setVar('name', $temp_name); if (!$module_handler->insert($module)) { echo '<p>Could not update ' . $module->getVar('name') . '</p>'; echo "<br /><a href='admin.php?fct=modulesadmin'>" . _MD_AM_BTOMADMIN . "</a>"; } else { $newmid = $module->getVar('mid'); $msgs = array(); $msgs[] = _MD_AM_MOD_DATA_UPDATED; $tplfile_handler =& icms::handler('icms_view_template_file'); $deltpl =& $tplfile_handler->find('default', 'module', $module->getVar('mid')); $delng = array(); if (is_array($deltpl)) { $xoopsDelTpl = new icms_view_Tpl(); // clear cache files $xoopsDelTpl->clear_cache(null, 'mod_' . $dirname); // delete template file entry in db $dcount = count($deltpl); for ($i = 0; $i < $dcount; $i++) { if (!$tplfile_handler->delete($deltpl[$i])) { $delng[] = $deltpl[$i]->getVar('tpl_file'); } } } $templates = $module->getInfo('templates'); if ($templates != false) { $msgs[] = _MD_AM_MOD_UP_TEM; foreach ($templates as $tpl) { $tpl['file'] = trim($tpl['file']); if (!in_array($tpl['file'], $delng)) { $tpldata =& xoops_module_gettemplate($dirname, $tpl['file']); $tplfile =& $tplfile_handler->create(); $tplfile->setVar('tpl_refid', $newmid); $tplfile->setVar('tpl_lastimported', 0); $tplfile->setVar('tpl_lastmodified', time()); if (preg_match("/\\.css\$/i", $tpl['file'])) { $tplfile->setVar('tpl_type', 'css'); } else { $tplfile->setVar('tpl_type', 'module'); } $tplfile->setVar('tpl_source', $tpldata, true); $tplfile->setVar('tpl_module', $dirname); $tplfile->setVar('tpl_tplset', 'default'); $tplfile->setVar('tpl_file', $tpl['file'], true); $tplfile->setVar('tpl_desc', $tpl['description'], true); if (!$tplfile_handler->insert($tplfile)) { $msgs[] = sprintf(' <span style="color:#ff0000;">' . _MD_AM_TEMPLATE_INSERT_FAIL . '</span>', '<strong>' . $tpl['file'] . '</strong>'); } else { $newid = $tplfile->getVar('tpl_id'); $msgs[] = sprintf(' <span>' . _MD_AM_TEMPLATE_INSERTED . '</span>', '<strong>' . $tpl['file'] . '</strong>', '<strong>' . $newid . '</strong>'); if ($icmsConfig['template_set'] == 'default') { if (!icms_view_Tpl::template_touch($newid)) { $msgs[] = sprintf(' <span style="color:#ff0000;">' . _MD_AM_TEMPLATE_RECOMPILE_FAIL . '</span>', '<strong>' . $tpl['file'] . '</strong>'); } else { $msgs[] = sprintf(' <span>' . _MD_AM_TEMPLATE_RECOMPILED . '</span>', '<strong>' . $tpl['file'] . '</strong>'); } } } unset($tpldata); } else { $msgs[] = sprintf(' <span style="color:#ff0000;">' . _MD_AM_TEMPLATE_DELETE_FAIL . '</span>', $tpl['file']); } } } $blocks = $module->getInfo('blocks'); $msgs[] = _MD_AM_MOD_REBUILD_BLOCKS; if ($blocks != false) { $count = count($blocks); $showfuncs = array(); $funcfiles = array(); for ($i = 1; $i <= $count; $i++) { if (isset($blocks[$i]['show_func']) && $blocks[$i]['show_func'] != '' && isset($blocks[$i]['file']) && $blocks[$i]['file'] != '') { $editfunc = isset($blocks[$i]['edit_func']) ? $blocks[$i]['edit_func'] : ''; $showfuncs[] = $blocks[$i]['show_func']; $funcfiles[] = $blocks[$i]['file']; $template = ''; if (isset($blocks[$i]['template']) && trim($blocks[$i]['template']) != '') { $content =& xoops_module_gettemplate($dirname, $blocks[$i]['template'], true); } if (!$content) { $content = ''; } else { $template = $blocks[$i]['template']; } $options = ''; if (!empty($blocks[$i]['options'])) { $options = $blocks[$i]['options']; } $sql = "SELECT bid, name FROM " . $db->prefix('newblocks') . " WHERE mid='" . (int) $module->getVar('mid') . "' AND func_num='" . (int) $i . "' AND show_func='" . addslashes($blocks[$i]['show_func']) . "' AND func_file='" . addslashes($blocks[$i]['file']) . "'"; $fresult = $db->query($sql); $fcount = 0; while ($fblock = $db->fetchArray($fresult)) { $fcount++; $sql = "UPDATE " . $db->prefix("newblocks") . " SET name='" . addslashes($blocks[$i]['name']) . "', edit_func='" . addslashes($editfunc) . "', content='', template='" . $template . "', last_modified=" . time() . " WHERE bid='" . (int) $fblock['bid'] . "'"; $result = $db->query($sql); if (!$result) { $msgs[] = sprintf(' ' . _MD_AM_UPDATE_FAIL, $fblock['name']); } else { $msgs[] = sprintf(' ' . _MD_AM_BLOCK_UPDATED, '<strong>' . $fblock['name'] . '</strong>', '<strong>' . icms_conv_nr2local($fblock['bid']) . '</strong>'); if ($template != '') { $tplfile =& $tplfile_handler->find('default', 'block', $fblock['bid']); if (count($tplfile) == 0) { $tplfile_new =& $tplfile_handler->create(); $tplfile_new->setVar('tpl_module', $dirname); $tplfile_new->setVar('tpl_refid', (int) $fblock['bid']); $tplfile_new->setVar('tpl_tplset', 'default'); $tplfile_new->setVar('tpl_file', $blocks[$i]['template'], true); $tplfile_new->setVar('tpl_type', 'block'); } else { $tplfile_new = $tplfile[0]; } $tplfile_new->setVar('tpl_source', $content, true); $tplfile_new->setVar('tpl_desc', $blocks[$i]['description'], true); $tplfile_new->setVar('tpl_lastmodified', time()); $tplfile_new->setVar('tpl_lastimported', 0); if (!$tplfile_handler->insert($tplfile_new)) { $msgs[] = sprintf(' <span style="color:#ff0000;">' . _MD_AM_TEMPLATE_UPDATE_FAIL . '</span>', '<strong>' . $blocks[$i]['template'] . '</strong>'); } else { $msgs[] = ' Template <b>' . $blocks[$i]['template'] . '</b> updated.'; if ($icmsConfig['template_set'] == 'default') { if (!icms_view_Tpl::template_touch($tplfile_new->getVar('tpl_id'))) { $msgs[] = sprintf(' <span style="color:#ff0000;">' . _MD_AM_TEMPLATE_RECOMPILE_FAIL . '</span>', '<strong>' . $blocks[$i]['template'] . '</strong>'); } else { $msgs[] = sprintf(' ' . _MD_AM_TEMPLATE_RECOMPILED, '<strong>' . $blocks[$i]['template'] . '</strong>'); } } } } } } if ($fcount == 0) { $newbid = $db->genId($db->prefix('newblocks') . '_bid_seq'); $block_name = addslashes($blocks[$i]['name']); $sql = "INSERT INTO " . $db->prefix("newblocks") . " (bid, mid, func_num, options, name, title, content, side, weight, visible, block_type, c_type, isactive, dirname, func_file, show_func, edit_func, template, bcachetime, last_modified) VALUES ('" . (int) $newbid . "', '" . (int) $module->getVar('mid') . "', '" . (int) $i . "','" . addslashes($options) . "','" . $block_name . "', '" . $block_name . "', '', '1', '0', '0', 'M', 'H', '1', '" . addslashes($dirname) . "', '" . addslashes($blocks[$i]['file']) . "', '" . addslashes($blocks[$i]['show_func']) . "', '" . addslashes($editfunc) . "', '" . $template . "', '0', '" . time() . "')"; $result = $db->query($sql); if (!$result) { $msgs[] = ' ERROR: Could not create ' . $blocks[$i]['name']; echo $sql; } else { if (empty($newbid)) { $newbid = $db->getInsertId(); } $groups =& icms::$user->getGroups(); $gperm_handler = icms::handler('icms_member_groupperm'); foreach ($groups as $mygroup) { $bperm =& $gperm_handler->create(); $bperm->setVar('gperm_groupid', (int) $mygroup); $bperm->setVar('gperm_itemid', (int) $newbid); $bperm->setVar('gperm_name', 'block_read'); $bperm->setVar('gperm_modid', 1); if (!$gperm_handler->insert($bperm)) { $msgs[] = ' <span style="color:#ff0000;">ERROR: Could not add block access right. Block ID: <b>' . $newbid . '</b> Group ID: <b>' . $mygroup . '</b></span>'; } else { $msgs[] = ' Added block access right. Block ID: <b>' . $newbid . '</b> Group ID: <b>' . $mygroup . '</b>'; } } if ($template != '') { $tplfile =& $tplfile_handler->create(); $tplfile->setVar('tpl_module', $dirname); $tplfile->setVar('tpl_refid', (int) $newbid); $tplfile->setVar('tpl_source', $content, true); $tplfile->setVar('tpl_tplset', 'default'); $tplfile->setVar('tpl_file', $blocks[$i]['template'], true); $tplfile->setVar('tpl_type', 'block'); $tplfile->setVar('tpl_lastimported', 0); $tplfile->setVar('tpl_lastmodified', time()); $tplfile->setVar('tpl_desc', $blocks[$i]['description'], true); if (!$tplfile_handler->insert($tplfile)) { $msgs[] = ' <span style="color:#ff0000;">ERROR: Could not insert template <b>' . $blocks[$i]['template'] . '</b> to the database.</span>'; } else { $newid = $tplfile->getVar('tpl_id'); $msgs[] = ' Template <b>' . $blocks[$i]['template'] . '</b> added to the database.'; if ($icmsConfig['template_set'] == 'default') { if (!icms_view_Tpl::template_touch($newid)) { $msgs[] = sprintf(' <span style="color:#ff0000;">' . _MD_AM_TEMPLATE_RECOMPILE_FAIL . '</span>', '<strong>' . $blocks[$i]['template'] . '</strong>'); } else { $msgs[] = sprintf(' ' . _MD_AM_TEMPLATE_RECOMPILED, '<strong>' . $blocks[$i]['template'] . '</strong>'); } } } } $msgs[] = ' Block <b>' . $blocks[$i]['name'] . '</b> created. Block ID: <b>' . $newbid . '</b>'; $sql = "INSERT INTO " . $db->prefix('block_module_link') . " (block_id, module_id, page_id) VALUES ('" . (int) $newbid . "', '0', '1')"; $db->query($sql); } } } } $icms_block_handler = icms::handler('icms_view_block'); $block_arr = $icms_block_handler->getByModule($module->getVar('mid')); foreach ($block_arr as $block) { if (!in_array($block->getVar('show_func'), $showfuncs) || !in_array($block->getVar('func_file'), $funcfiles)) { $sql = sprintf("DELETE FROM %s WHERE bid = '%u'", $db->prefix('newblocks'), (int) $block->getVar('bid')); if (!$db->query($sql)) { $msgs[] = ' <span style="color:#ff0000;">ERROR: Could not delete block <b>' . $block->getVar('name') . '</b>. Block ID: <b>' . $block->getVar('bid') . '</b></span>'; } else { $msgs[] = ' Block <b>' . $block->getVar('name') . ' deleted. Block ID: <b>' . $block->getVar('bid') . '</b>'; if ($block->getVar('template') != '') { $tplfiles =& $tplfile_handler->find(null, 'block', $block->getVar('bid')); if (is_array($tplfiles)) { $btcount = count($tplfiles); for ($k = 0; $k < $btcount; $k++) { if (!$tplfile_handler->delete($tplfiles[$k])) { $msgs[] = ' <span style="color:#ff0000;">ERROR: Could not remove deprecated block template. (ID: <b>' . $tplfiles[$k]->getVar('tpl_id') . '</b>)</span>'; } else { $msgs[] = ' Block template <b>' . $tplfiles[$k]->getVar('tpl_file') . '</b> deprecated.'; } } } } } } } } // first delete all config entries $config_handler = icms::handler('icms_config'); $configs =& $config_handler->getConfigs(new icms_db_criteria_Item('conf_modid', $module->getVar('mid'))); $confcount = count($configs); $config_delng = array(); if ($confcount > 0) { $msgs[] = 'Deleting module config options...'; for ($i = 0; $i < $confcount; $i++) { if (!$config_handler->deleteConfig($configs[$i])) { $msgs[] = ' <span style="color:#ff0000;">ERROR: Could not delete config data from the database. Config ID: <b>' . $configs[$i]->getvar('conf_id') . '</b></span>'; // save the name of config failed to delete for later use $config_delng[] = $configs[$i]->getvar('conf_name'); } else { $config_old[$configs[$i]->getvar('conf_name')]['value'] = $configs[$i]->getvar('conf_value', 'N'); $config_old[$configs[$i]->getvar('conf_name')]['formtype'] = $configs[$i]->getvar('conf_formtype'); $config_old[$configs[$i]->getvar('conf_name')]['valuetype'] = $configs[$i]->getvar('conf_valuetype'); $msgs[] = ' Config data deleted from the database. Config ID: <b>' . $configs[$i]->getVar('conf_id') . '</b>'; } } } // now reinsert them with the new settings $configs = $module->getInfo('config'); if ($configs != false) { if ($module->getVar('hascomments') != 0) { include_once ICMS_ROOT_PATH . '/include/comment_constants.php'; array_push($configs, array('name' => 'com_rule', 'title' => '_CM_COMRULES', 'description' => '', 'formtype' => 'select', 'valuetype' => 'int', 'default' => 1, 'options' => array('_CM_COMNOCOM' => XOOPS_COMMENT_APPROVENONE, '_CM_COMAPPROVEALL' => XOOPS_COMMENT_APPROVEALL, '_CM_COMAPPROVEUSER' => XOOPS_COMMENT_APPROVEUSER, '_CM_COMAPPROVEADMIN' => XOOPS_COMMENT_APPROVEADMIN))); array_push($configs, array('name' => 'com_anonpost', 'title' => '_CM_COMANONPOST', 'description' => '', 'formtype' => 'yesno', 'valuetype' => 'int', 'default' => 0)); } } else { if ($module->getVar('hascomments') != 0) { $configs = array(); include_once ICMS_ROOT_PATH . '/include/comment_constants.php'; $configs[] = array('name' => 'com_rule', 'title' => '_CM_COMRULES', 'description' => '', 'formtype' => 'select', 'valuetype' => 'int', 'default' => 1, 'options' => array('_CM_COMNOCOM' => XOOPS_COMMENT_APPROVENONE, '_CM_COMAPPROVEALL' => XOOPS_COMMENT_APPROVEALL, '_CM_COMAPPROVEUSER' => XOOPS_COMMENT_APPROVEUSER, '_CM_COMAPPROVEADMIN' => XOOPS_COMMENT_APPROVEADMIN)); $configs[] = array('name' => 'com_anonpost', 'title' => '_CM_COMANONPOST', 'description' => '', 'formtype' => 'yesno', 'valuetype' => 'int', 'default' => 0); } } // RMV-NOTIFY if ($module->getVar('hasnotification') != 0) { if (empty($configs)) { $configs = array(); } // Main notification options include_once ICMS_ROOT_PATH . '/include/notification_constants.php'; include_once ICMS_ROOT_PATH . '/include/notification_functions.php'; $options = array(); $options['_NOT_CONFIG_DISABLE'] = XOOPS_NOTIFICATION_DISABLE; $options['_NOT_CONFIG_ENABLEBLOCK'] = XOOPS_NOTIFICATION_ENABLEBLOCK; $options['_NOT_CONFIG_ENABLEINLINE'] = XOOPS_NOTIFICATION_ENABLEINLINE; $options['_NOT_CONFIG_ENABLEBOTH'] = XOOPS_NOTIFICATION_ENABLEBOTH; //$configs[] = array ('name' => 'notification_enabled', 'title' => '_NOT_CONFIG_ENABLED', 'description' => '_NOT_CONFIG_ENABLEDDSC', 'formtype' => 'yesno', 'valuetype' => 'int', 'default' => 1); $configs[] = array('name' => 'notification_enabled', 'title' => '_NOT_CONFIG_ENABLE', 'description' => '_NOT_CONFIG_ENABLEDSC', 'formtype' => 'select', 'valuetype' => 'int', 'default' => XOOPS_NOTIFICATION_ENABLEBOTH, 'options' => $options); // Event specific notification options // FIXME: for some reason the default doesn't come up properly // initially is ok, but not when 'update' module.. $options = array(); $categories =& icms_data_notification_Handler::categoryInfo('', $module->getVar('mid')); foreach ($categories as $category) { $events =& icms_data_notification_Handler::categoryEvents($category['name'], false, $module->getVar('mid')); foreach ($events as $event) { if (!empty($event['invisible'])) { continue; } $option_name = $category['title'] . ' : ' . $event['title']; $option_value = $category['name'] . '-' . $event['name']; $options[$option_name] = $option_value; //$configs[] = array ('name' => icms_data_notification_Handler::generateConfig($category,$event,'name'), 'title' => icms_data_notification_Handler::generateConfig($category,$event,'title_constant'), 'description' => icms_data_notification_Handler::generateConfig($category,$event,'description_constant'), 'formtype' => 'yesno', 'valuetype' => 'int', 'default' => 1); } } $configs[] = array('name' => 'notification_events', 'title' => '_NOT_CONFIG_EVENTS', 'description' => '_NOT_CONFIG_EVENTSDSC', 'formtype' => 'select_multi', 'valuetype' => 'array', 'default' => array_values($options), 'options' => $options); } if ($configs != false) { $msgs[] = 'Adding module config data...'; $config_handler = icms::handler('icms_config'); $order = 0; foreach ($configs as $config) { // only insert ones that have been deleted previously with success if (!in_array($config['name'], $config_delng)) { $confobj =& $config_handler->createConfig(); $confobj->setVar('conf_modid', (int) $newmid); $confobj->setVar('conf_catid', 0); $confobj->setVar('conf_name', $config['name']); $confobj->setVar('conf_title', $config['title'], true); $confobj->setVar('conf_desc', $config['description'], true); $confobj->setVar('conf_formtype', $config['formtype']); $confobj->setVar('conf_valuetype', $config['valuetype']); if (isset($config_old[$config['name']]['value']) && $config_old[$config['name']]['formtype'] == $config['formtype'] && $config_old[$config['name']]['valuetype'] == $config['valuetype']) { // preserver the old value if any // form type and value type must be the same $confobj->setVar('conf_value', $config_old[$config['name']]['value'], true); } else { $confobj->setConfValueForInput($config['default'], true); //$confobj->setVar('conf_value', $config['default'], true); } $confobj->setVar('conf_order', $order); $confop_msgs = ''; if (isset($config['options']) && is_array($config['options'])) { foreach ($config['options'] as $key => $value) { $confop =& $config_handler->createConfigOption(); $confop->setVar('confop_name', $key, true); $confop->setVar('confop_value', $value, true); $confobj->setConfOptions($confop); $confop_msgs .= '<br /> Config option added. Name: <b>' . $key . '</b> Value: <b>' . $value . '</b>'; unset($confop); } } $order++; if (false != $config_handler->insertConfig($confobj)) { $msgs[] = ' Config <b>' . $config['name'] . '</b> added to the database.' . $confop_msgs; } else { $msgs[] = ' <span style="color:#ff0000;">ERROR: Could not insert config <b>' . $config['name'] . '</b> to the database.</span>'; } unset($confobj); } } unset($configs); } // add module specific tasks to system autotasks list $atasks = $module->getInfo('autotasks'); $atasks_handler =& icms_getModuleHandler('autotasks', 'system'); if (count($atasks) > 0) { $msgs[] = 'Updating autotasks...'; $criteria = new icms_db_criteria_Compo(); $criteria->add(new icms_db_criteria_Item('sat_type', 'addon/' . $module->getInfo('dirname'))); $items_atasks = $atasks_handler->getObjects($criteria, false); foreach ($items_atasks as $task) { $taskID = (int) $task->getVar('sat_addon_id'); $atasks[$taskID]['enabled'] = $task->getVar('sat_enabled'); $atasks[$taskID]['repeat'] = $task->getVar('sat_repeat'); $atasks[$taskID]['interval'] = $task->getVar('sat_interval'); $atasks[$taskID]['name'] = $task->getVar('sat_name'); } $atasks_handler->deleteAll($criteria); foreach ($atasks as $taskID => $taskData) { if (!isset($taskData['code']) || trim($taskData['code']) == '') { continue; } $task =& $atasks_handler->create(); if (isset($taskData['enabled'])) { $task->setVar('sat_enabled', $taskData['enabled']); } if (isset($taskData['repeat'])) { $task->setVar('sat_repeat', $taskData['repeat']); } if (isset($taskData['interval'])) { $task->setVar('sat_interval', $taskData['interval']); } if (isset($taskData['onfinish'])) { $task->setVar('sat_onfinish', $taskData['onfinish']); } $task->setVar('sat_name', $taskData['name']); $task->setVar('sat_code', sprintf("require ICMS_ROOT_PATH . \"/modules/%s/%s\";", $module->getInfo('dirname'), addslashes($taskData['code']))); $task->setVar('sat_type', 'addon/' . $module->getInfo('dirname')); $task->setVar('sat_addon_id', (int) $taskID); if (!$atasks_handler->insert($task)) { $msgs[] = ' <span style="color:#ff0000;">ERROR: Could not insert autotask to db. Name: <b>' . $taskData['name'] . '</b></span>'; } else { $msgs[] = ' Updated task from autotasks list. Task Name: <b>' . $taskData['name'] . '</b>'; } } unset($atasks, $atasks_handler, $task, $taskData, $criteria, $items, $taskID); } // execute module specific update script if any $update_script = $module->getInfo('onUpdate'); $ModName = $module->getInfo('modname') != '' ? trim($module->getInfo('modname')) : $dirname; if (false != $update_script && trim($update_script) != '') { include_once ICMS_ROOT_PATH . '/modules/' . $dirname . '/' . trim($update_script); $is_IPF = $module->getInfo('object_items'); if (!empty($is_IPF)) { $icmsDatabaseUpdater = icms_db_legacy_Factory::getDatabaseUpdater(); $icmsDatabaseUpdater->moduleUpgrade($module, true); foreach ($icmsDatabaseUpdater->_messages as $msg) { $msgs[] = $msg; } } if (function_exists('xoops_module_update_' . $ModName)) { $func = 'xoops_module_update_' . $ModName; if (!$func($module, $prev_version, $prev_dbversion)) { $msgs[] = sprintf(_MD_AM_FAIL_EXEC, '<strong>' . $func . '</strong>'); } else { $msgs[] = sprintf(_MD_AM_FUNCT_EXEC, '<strong>' . $func . '</strong>'); } } elseif (function_exists('icms_module_update_' . $ModName)) { $func = 'icms_module_update_' . $ModName; if (!$func($module, $prev_version, $prev_dbversion)) { $msgs[] = sprintf(_MD_AM_FAIL_EXEC, '<strong>' . $func . '</strong>'); } else { $msgs[] = sprintf(_MD_AM_FUNCT_EXEC, '<strong>' . $func . '</strong>'); } } } $msgs[] = '</code><p>' . sprintf(_MD_AM_OKUPD, '<b>' . $module->getVar('name') . '</b>') . '</p>'; } $ret = '<code>'; foreach ($msgs as $msg) { $ret .= $msg . '<br />'; } return $ret; }
/** * Build criteria automatically from an array of key=>value * * @param array $criterias array of fieldname=>value criteria * @return object (@link icms_db_criteria_Compo) the icms_db_criteria_Compo object * @todo Move to a static class method - Criteria */ function icms_buildCriteria($criterias) { $criteria = new icms_db_criteria_Compo(); foreach ($criterias as $k => $v) { $criteria->add(new icms_db_criteria_Item($k, $v)); } return $criteria; }
/** * Get a list of avatars * @param string $avatar_type * @param integer $avatar_display * @return array */ public function getList($avatar_type = null, $avatar_display = null) { $criteria = new icms_db_criteria_Compo(); if (isset($avatar_type)) { $avatar_type = $avatar_type == 'C' ? 'C' : 'S'; $criteria->add(new icms_db_criteria_Item('avatar_type', $avatar_type)); } if (isset($avatar_display)) { $criteria->add(new icms_db_criteria_Item('avatar_display', (int) $avatar_display)); } $avatars =& $this->getObjects($criteria, true); $ret = array('blank.gif' => _NONE); foreach (array_keys($avatars) as $i) { $ret[$avatars[$i]->getVar('avatar_file')] = $avatars[$i]->getVar('avatar_name'); } return $ret; }
/** * Return an array of custom tags, indexed by name */ public function getCustomtagsByName() { if (!$this->_objects) { global $icmsConfig; $ret = array(); $criteria = new icms_db_criteria_Compo(); $criteria_language = new icms_db_criteria_Compo(); $criteria_language->add(new icms_db_criteria_Item('language', $icmsConfig['language'])); $criteria_language->add(new icms_db_criteria_Item('language', 'all'), 'OR'); $criteria->add($criteria_language); $icms_permissions_handler = new icms_ipf_permission_Handler($this); $granted_ids = $icms_permissions_handler->getGrantedItems('view_customtag'); if ($granted_ids && count($granted_ids) > 0) { $criteria->add(new icms_db_criteria_Item('customtagid', '(' . implode(', ', $granted_ids) . ')', 'IN')); $customtagsObj = $this->getObjects($criteria, TRUE); foreach ($customtagsObj as $customtagObj) { $ret[$customtagObj->getVar('name')] = $customtagObj; } } $this->_objects = $ret; } return $this->_objects; }
$time = mktime(0, 0, 0, substr($f_mail_regd_min, 5, 2), substr($f_mail_regd_min, 8, 2), substr($f_mail_regd_min, 0, 4)); if ($time > 0) { $criteria[] = "user_regdate > $time"; } } if (!empty($_POST['mail_regd_max'])) { $f_mail_regd_max = trim($_POST['mail_regd_max']); $time = mktime(0, 0, 0, substr($f_mail_regd_max, 5, 2), substr($f_mail_regd_max, 8, 2), substr($f_mail_regd_max, 0, 4)); if ($time > 0) { $criteria[] = "user_regdate < $time"; } } if (!empty($criteria) || !empty($_POST['mail_to_group'])) { $criteria_object = new icms_db_criteria_Compo(); $criteria_object->setStart(@$_POST['mail_start']); $criteria_object->setLimit($limit); foreach ($criteria as $c) { list ($field, $op, $value) = explode(' ', $c); $crit = new icms_db_criteria_Item($field, $value, $op); $crit->prefix = "u"; $criteria_object->add($crit, 'AND'); } $member_handler = icms::handler('icms_member'); $groups = empty($_POST['mail_to_group']) ? array() : array_map('intval', $_POST['mail_to_group']); $getusers = $member_handler->getUsersByGroupLink($groups, $criteria_object, TRUE); $count_criteria = $member_handler->getUserCountByGroupLink($groups, $criteria_object); foreach ($getusers as $getuser) { if (!in_array($getuser->getVar("uid"), $added_id)) { $added[] = $getuser;