/** * Create the criteria that will be used by getFriendships * * @param int $start to which record to start * @param int $limit max friendships to display * @param int $friend1_uid only the friendship of this user will be returned * @param int $friend2_uid if specifid, the friendship of these two users will be returned. * @param int $status only get friendships with the specified status * @return icms_db_criteria_Compo $criteria */ private function getFriendshipsCriteria($start = 0, $limit = 0, $friend1_uid = 0, $friend2_uid = 0, $status = 0) { $criteria = new icms_db_criteria_Compo(); if ($start) { $criteria->setStart((int) $start); } if ($limit) { $criteria->setLimit((int) $limit); } $criteria->setSort('creation_time'); $criteria->setOrder('DESC'); if ($status == PROFILE_FRIENDSHIP_STATUS_PENDING && $friend2_uid) { $criteria->add(new icms_db_criteria_Item('status', (int) $status)); $criteria->add(new icms_db_criteria_Item('friend2_uid', (int) $friend2_uid)); } else { if ($status) { $criteria->add(new icms_db_criteria_Item('status', (int) $status)); } if ($friend2_uid > 0) { $criteria->add(new icms_db_criteria_Item('friend1_uid', (int) $friend1_uid)); $criteria->add(new icms_db_criteria_Item('friend2_uid', (int) $friend2_uid)); $criteria->add(new icms_db_criteria_Item('friend1_uid', (int) $friend2_uid), 'OR'); $criteria->add(new icms_db_criteria_Item('friend2_uid', (int) $friend1_uid)); } elseif ($friend1_uid > 0) { $criteria->add(new icms_db_criteria_Item('friend1_uid', (int) $friend1_uid)); $criteria->add(new icms_db_criteria_Item('friend2_uid', (int) $friend1_uid), 'OR'); } if ($status) { $criteria->add(new icms_db_criteria_Item('status', (int) $status)); } } 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; }
/** * 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; }
/** * 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; }
/** * 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); }
/** * 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); }
/** * 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; }
/** * 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; }
/** * 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; }
/** * Gets selected type current events for current user * * @param int $ type * @return Object */ public function getTasks() { $criteria = new icms_db_criteria_Compo(); $criteria->setSort('sat_lastruntime'); $criteria->setOrder('ASC'); $criteria->add( new icms_db_criteria_Item('(sat_lastruntime + sat_interval)', time(), '<=', NULL, "%s" )); $criteria->add( new icms_db_criteria_Item('sat_repeat', 0, '>=', NULL, "'%s'")); $criteria->add( new icms_db_criteria_Item('sat_enabled', 1)); $rez = $this->getObjects($criteria, FALSE); return $rez; }
/** * Gets the content pages * * @param bool $showsubs Show subitems related to this item (recursive!) * @param string $sort Order the pages by weight * @param string $order The sort direction * @param int $content_id The content ID * @param int $relateds Show related items * @return array $pages The array with pages in a certain weight, order and with related id's */ function getPages($showsubs = true, $sort = 'content_weight', $order = 'ASC', $content_id = 0, $relateds = 0) { $groups = is_object(icms::$user) ? icms::$user->getGroups() : array(ICMS_GROUP_ANONYMOUS); $uid = is_object(icms::$user) ? icms::$user->getVar('uid') : 0; $content_handler =& icms_getModuleHandler('content', basename(dirname(dirname(__FILE__))), 'content'); $module = icms::handler('icms_module')->getByDirname(basename(dirname(dirname(__FILE__)))); $criteria = new icms_db_criteria_Compo(new icms_db_criteria_Item('content_status', 1)); if (!$relateds) { $criteria->add(new icms_db_criteria_Item('content_pid', $content_id)); } else { $criteria->add(new icms_db_criteria_Item('short_url', $content_id, 'LIKE')); $criteria->add(new icms_db_criteria_Item('content_id', $content_id), 'OR'); } $crit = new icms_db_criteria_Compo(new icms_db_criteria_Item('content_visibility', 1)); $crit->add(new icms_db_criteria_Item('content_visibility', 3), 'OR'); $criteria->add($crit); $criteria->setSort($sort); $criteria->setOrder($order); $impress_content = $content_handler->getObjects($criteria); $i = 0; $pages = array(); foreach ($impress_content as $content) { if (icms::handler('icms_member_groupperm')->checkRight('content_read', $content->getVar('content_id'), $groups, $module->getVar('mid'))) { $pages[$i]['title'] = $content->getVar('content_title'); $pages[$i]['menu'] = $content_handler->makeLink($content); if ($showsubs) { $subs = getPages($showsubs, $sort, $order, $content->getVar('content_id')); if (count($subs) > 0) { $pages[$i]['hassubs'] = 1; $pages[$i]['subs'] = $subs; } else { $pages[$i]['hassubs'] = 0; } } $i++; } } return $pages; }
/** * Retrieve a list of objects as arrays - DON'T USE WITH JOINT KEYS * * @param object $criteria {@link icms_db_criteria_Element} conditions to be met * @param int $limit Max number of objects to fetch * @param int $start Which record to start at * * @return array */ public function getList($criteria = null, $limit = 0, $start = 0, $debug = false) { $ret = array(); if ($criteria == null) { $criteria = new icms_db_criteria_Compo(); } if ($criteria->getSort() == '') { $criteria->setSort($this->getIdentifierName()); } $sql = 'SELECT ' . (is_array($this->keyName) ? implode(', ', $this->keyName) : $this->keyName); if (!empty($this->identifierName)) { $sql .= ', ' . $this->getIdentifierName(); } $sql .= ' FROM ' . $this->table . " AS " . $this->_itemname; if (isset($criteria) && is_subclass_of($criteria, 'icms_db_criteria_Element')) { $sql .= ' ' . $criteria->renderWhere(); if ($criteria->getSort() != '') { $sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder(); } $limit = $criteria->getLimit(); $start = $criteria->getStart(); } if ($debug) { icms_core_Debug::message($sql); } $result = $this->db->query($sql, $limit, $start); if (!$result) { return $ret; } while ($myrow = $this->db->fetchArray($result)) { //identifiers should be textboxes, so sanitize them like that $ret[$myrow[$this->keyName]] = empty($this->identifierName) ? 1 : icms_core_DataFilter::checkVar($myrow[$this->identifierName], 'text', 'output'); } return $ret; }
public function downWeight($bid) { $blockObj = $this->get($bid); $criteria = new icms_db_criteria_Compo(); $criteria->setLimit(1); $criteria->setSort('weight'); $criteria->setOrder('ASC'); $criteria->add(new icms_db_criteria_Item('side', $blockObj->vars['side']['value'])); $criteria->add(new icms_db_criteria_Item('weight', $blockObj->getVar('weight'), '>')); $sideBlocks = $this->getObjects($criteria); $weight = (is_array($sideBlocks) && count($sideBlocks) == 1) ? $sideBlocks[0]->getVar('weight') + 1 : $blockObj->getVar('weight') + 1; $blockObj->setVar('weight', $weight); $this->insert($blockObj, TRUE); }
/** * Search tribes by title and description * * @param str search string * @return array of mod_profile_Tribes objects */ public function searchTribes($title) { $criteria = new icms_db_criteria_Compo(); $criteria->setSort('title'); $criteria->add(new icms_db_criteria_Item('title', '%' . $title . '%', 'LIKE')); $criteria->add(new icms_db_criteria_Item('tribe_desc', '%' . $title . '%', 'LIKE'), 'OR'); $ret = $this->getObjects($criteria, true, false); return $ret; }
/** * Get block data for multiple block ids * * @param array $blockids * * @todo can be removed together with getAllByGroupModule and getNonGroupedBlocks. (used in theme_blocks) */ private function &getMultiple($blockids) { $criteria = new icms_db_criteria_Compo(); $criteria->add(new icms_db_criteria_Item('bid', '(' . implode(',', $blockids) . ')', 'IN')); $criteria->setSort('weight'); $ret = $this->getObjects($criteria, true, true); $sql = "SELECT block_id, module_id, page_id FROM " . $this->db->prefix('block_module_link') . " WHERE block_id IN (" . implode(',', array_keys($ret)) . ") ORDER BY block_id"; $result = $this->db->query($sql); $modules = array(); $last_block_id = 0; while ($row = $this->db->fetchArray($result)) { $modules[] = (int) $row['module_id'] . '-' . (int) $row['page_id']; $ret[$row['block_id']]->setVar('visiblein', $modules); if ($row['block_id'] != $last_block_id) { $modules = array(); } $last_block_id = $row['block_id']; } return $ret; }
} $member_handler = icms::handler('icms_member'); if (count($_POST) == 0) { unset($_SESSION['profile']); } $template_dir = ICMS_ROOT_PATH . '/language/' . $icmsConfig['language'] . '/mail_template'; if (!file_exists($template_dir)) { $template_dir = ICMS_ROOT_PATH . '/language/english/mail_template'; } $newuser = isset($_SESSION['profile']['uid']) ? $member_handler->getUser($_SESSION['profile']['uid']) : $member_handler->createUser(); $profile_handler = icms_getmodulehandler('profile', basename(dirname(__FILE__)), 'profile'); $profile = $profile_handler->get($newuser->getVar('uid')); $op = !isset($_POST['op']) ? 'register' : $_POST['op']; $current_step = isset($_POST['step']) ? $_POST['step'] : 0; $criteria = new icms_db_criteria_Compo(); $criteria->setSort('step_order'); $regstep_handler = icms_getmodulehandler('regstep', basename(dirname(__FILE__)), 'profile'); $steps = $regstep_handler->getObjects($criteria); if (count($steps) == 0) { redirect_header(ICMS_URL . '/', 6, _MD_PROFILE_NOSTEPSAVAILABLE); } switch ($op) { case 'step': // Get dynamic fields $fields = $profile_handler->loadFields(); if (count($fields) > 0) { foreach (array_keys($fields) as $i) { $fieldname = $fields[$i]->getVar('field_name'); if (isset($_POST[$fieldname])) { if ($fields[$i]->getVar('field_type') == 'date' || $fields[$i]->getVar('field_type') == 'longdate') { $_SESSION['profile'][$fieldname] = trim(strtotime($_POST[$fieldname]));
/** * Displays user information form * */ function displayUsers() { global $icmsConfig, $icmsModule, $icmsConfigUser; $userstart = isset($_GET['userstart']) ? (int) $_GET['userstart'] : 0; icms_cp_header(); echo '<div class="CPbigTitle" style="background-image: url(' . ICMS_MODULES_URL . '/system/admin/users/images/users_big.png)">' . _MD_AM_USER . '</div><br />'; $member_handler = icms::handler('icms_member'); $usercount = $member_handler->getUserCount(new icms_db_criteria_Item('level', '-1', '!=')); $nav = new icms_view_PageNav($usercount, 200, $userstart, 'userstart', 'fct=users'); $editform = new icms_form_Theme(_AM_EDEUSER, 'edituser', 'admin.php'); $user_select = new icms_form_elements_Select('', 'uid'); $criteria = new icms_db_criteria_Compo(); $criteria->add(new icms_db_criteria_Item('level', '-1', '!=')); $criteria->setSort('uname'); $criteria->setOrder('ASC'); $criteria->setLimit(200); $criteria->setStart($userstart); $user_select->addOptionArray($member_handler->getUserList($criteria)); $user_select_tray = new icms_form_elements_Tray(_AM_NICKNAME, '<br />'); $user_select_tray->addElement($user_select); $user_select_nav = new icms_form_elements_Label('', $nav->renderNav(4)); $user_select_tray->addElement($user_select_nav); $op_select = new icms_form_elements_Select('', 'op'); $op_select->addOptionArray(array('modifyUser'=>_AM_MODIFYUSER, 'delUser'=>_AM_DELUSER)); $submit_button = new icms_form_elements_Button('', 'submit', _AM_GO, 'submit'); $fct_hidden = new icms_form_elements_Hidden('fct', 'users'); $editform->addElement($user_select_tray); $editform->addElement($op_select); $editform->addElement($submit_button); $editform->addElement($fct_hidden); $editform->display(); echo "<br />\n"; $usercount = $member_handler->getUserCount(new icms_db_criteria_Item('level', '-1')); $nav = new icms_view_PageNav($usercount, 200, $userstart, 'userstart', 'fct=users'); $editform = new icms_form_Theme(_AM_REMOVED_USERS, 'edituser', 'admin.php'); $user_select = new icms_form_elements_Select('', 'uid'); $criteria = new icms_db_criteria_Compo(); $criteria->add(new icms_db_criteria_Item('level', '-1')); $criteria->setSort('uname'); $criteria->setOrder('ASC'); $criteria->setLimit(200); $criteria->setStart($userstart); $user_select->addOptionArray($member_handler->getUserList($criteria)); $user_select_tray = new icms_form_elements_Tray(_AM_NICKNAME, '<br />'); $user_select_tray->addElement($user_select); $user_select_nav = new icms_form_elements_Label('', $nav->renderNav(4)); $user_select_tray->addElement($user_select_nav); $op_select = new icms_form_elements_Select('', 'op'); $op_select->addOptionArray(array('modifyUser'=>_AM_MODIFYUSER)); $submit_button = new icms_form_elements_Button('', 'submit', _AM_GO, 'submit'); $fct_hidden = new icms_form_elements_Hidden('fct', 'users'); $editform->addElement($user_select_tray); $editform->addElement($op_select); $editform->addElement($submit_button); $editform->addElement($fct_hidden); $editform->display(); echo "<br />\n"; $uid_value = ''; $uname_value = ''; $login_name_value = ''; $name_value = ''; $email_value = ''; $email_cbox_value = 0; $openid_value = ''; $openid_cbox_value = 0; $url_value = ''; $timezone_value = $icmsConfig['default_TZ']; $icq_value = ''; $aim_value = ''; $yim_value = ''; $msnm_value = ''; $location_value = ''; $occ_value = ''; $interest_value = ''; $sig_value = ''; $sig_cbox_value = 0; $umode_value = $icmsConfig['com_mode']; $uorder_value = $icmsConfig['com_order']; include_once ICMS_INCLUDE_PATH .'/notification_constants.php'; $notify_method_value = XOOPS_NOTIFICATION_METHOD_PM; $notify_mode_value = XOOPS_NOTIFICATION_MODE_SENDALWAYS; $bio_value = ''; $rank_value = 0; $mailok_value = 0; $pass_expired_value = 0; $op_value = 'addUser'; $form_title = _AM_ADDUSER; $form_isedit = FALSE; $language_value = $icmsConfig['language']; $groups = array(XOOPS_GROUP_USERS); include ICMS_MODULES_PATH . '/system/admin/users/userform.php'; icms_cp_footer(); }
/** * Create the criteria that will be used by getContents and getContentsCount * * @param int $start to which record to start * @param int $limit limit of contents to return * @param int $content_uid if specifid, only the content of this user will be returned * @param int $cid if specifid, only the content related to this category will be returned * @param int $year of contents to display * @param int $month of contents to display * @param int $content_id ID of a single content to retrieve * @return icms_db_criteria_Compo $criteria */ public function getContentsCriteria($start = 0, $limit = 0, $content_uid = false, $content_tags = false, $content_id = false, $content_pid = false, $order = 'content_published_date', $sort = 'DESC') { $criteria = new icms_db_criteria_Compo(); if ($start) { $criteria->setStart($start); } if ($limit) { $criteria->setLimit((int) $limit); } $criteria->setSort($order); $criteria->setOrder($sort); $criteria->add(new icms_db_criteria_Item('content_status', CONTENT_CONTENT_STATUS_PUBLISHED)); if ($content_uid) { $criteria->add(new icms_db_criteria_Item('content_uid', $content_uid)); } if ($content_tags) { $criteria->add(new icms_db_criteria_Item('content_tags', '%' . $content_tags . '%', 'LIKE')); } if ($content_id) { $crit = new icms_db_criteria_Compo(new icms_db_criteria_Item('short_url', $content_id, 'LIKE')); $alt_content_id = str_replace('-', ' ', $content_id); //Added for backward compatiblity in case short_url contains spaces instead of dashes. $crit->add(new icms_db_criteria_Item('short_url', $alt_content_id), 'OR'); $crit->add(new icms_db_criteria_Item('content_id', $content_id), 'OR'); $criteria->add($crit); } if ($content_pid !== false) { $criteria->add(new icms_db_criteria_Item('content_pid', $content_pid)); } return $criteria; }
/** * System Admin Modules Block Show Fuction * * @return array * @todo Maybe it can be improved a little, is just a copy of the generate menu function. */ function b_system_admin_modules_show() { $block['mods'] = array(); $module_handler = icms::handler('icms_module'); $moduleperm_handler = icms::handler('icms_member_groupperm'); $criteria = new icms_db_criteria_Compo(); $criteria->add(new icms_db_criteria_Item('hasadmin', 1)); $criteria->add(new icms_db_criteria_Item('isactive', 1)); $criteria->setSort('mid'); $modules = $module_handler->getObjects($criteria); foreach ($modules as $module) { $rtn = array(); $inf =& $module->getInfo(); $rtn['link'] = ICMS_MODULES_URL . '/' . $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_MODULES_URL . '/' . $module->getVar('dirname') . '/' . $inf['iconsmall']; } if (isset($inf['iconbig']) && $inf['iconbig'] != '') { $rtn['iconbig'] = ICMS_MODULES_URL . '/' . $module->getVar('dirname') . '/' . $inf['iconbig']; } $rtn['absolute'] = 1; $module->loadAdminMenu(); if (is_array($module->adminmenu) && count($module->adminmenu) > 0) { $rtn['hassubs'] = 1; $rtn['subs'] = array(); foreach ($module->adminmenu as $item) { $item['link'] = ICMS_MODULES_URL . '/' . $module->getVar('dirname') . '/' . $item['link']; $rtn['subs'][] = $item; } } else { $rtn['hassubs'] = 0; unset($rtn['subs']); } $hasconfig = $module->getVar('hasconfig'); $hascomments = $module->getVar('hascomments'); if (isset($hasconfig) && $hasconfig == 1 || isset($hascomments) && $hascomments == 1) { $rtn['hassubs'] = 1; if (!isset($rtn['subs'])) { $rtn['subs'] = array(); } $subs = array('title' => _PREFERENCES, 'link' => ICMS_MODULES_URL . '/system/admin.php?fct=preferences&op=showmod&mod=' . $module->getVar('mid')); $rtn['subs'][] = $subs; } else { $rtn['hassubs'] = 0; unset($rtn['subs']); } if ($module->getVar('dirname') == 'system') { $systemadm = TRUE; } if (is_object(icms::$user)) { $admin_perm = $moduleperm_handler->checkRight('module_admin', $module->getVar('mid'), icms::$user->getGroups()); } if ($admin_perm) { if ($rtn['dir'] != 'system') { $block['mods'][] = $rtn; } } } // If there is any module listed, then show the block. if (count($block['mods'] > 0)) { return $block; } }
/** * create list of categories for table filter * * @return array list of categories */ public function getCategoriesArray() { if (!$this->_categoriesArray) { $profile_category_handler = icms_getModuleHandler('category', basename(dirname(dirname(__FILE__))), 'profile'); $criteria = new icms_db_criteria_Compo(); $criteria->setSort('cat_title'); $criteria->setOrder('ASC'); $categories = $profile_category_handler->getObjects($criteria); foreach ($categories as $category) { $this->_categoriesArray[$category->getVar('catid')] = $category->getVar('cat_title'); } } return $this->_categoriesArray; }