/** * Build an SQL query to load the list data. * * @return JQuery */ protected function _getListQuery() { // Create a new query object. $query = new JQuery(); $user = JFactory::getUser(); // Select the required fields from the table. $query->select($this->getState('list.select', 'a.*, ' . 'u.name AS user_from')); $query->from('#__messages AS a'); // Join over the users for message owner. $query->join('INNER', '#__users AS u ON u.id = a.user_id_from'); $query->where('a.user_id_to = ' . (int) $user->get('id')); // Filter by published state. $state = $this->getState('filter.state'); if (is_numeric($state)) { $query->where('a.state = ' . (int) $state); } else { if ($state === '') { $query->where('(a.state IN (0, 1))'); } } // Filter by search in subject or message. $search = $this->getState('filter.search'); if (!empty($search)) { $search = $this->_db->Quote('%' . $this->_db->getEscaped($search, true) . '%', false); $query->where('a.subject LIKE ' . $search . ' OR a.message LIKE ' . $search . ')'); } // Add the list ordering clause. $query->order($this->_db->getEscaped($this->getState('list.ordering', 'a.date_time')) . ' ' . $this->_db->getEscaped($this->getState('list.direction', 'DESC'))); //echo nl2br(str_replace('#__','jos_',$query)); return $query; }
/** * Build an SQL query to load the list data. * * @return JQuery */ protected function _getListQuery() { // Create a new query object. $query = new JQuery(); // Select the required fields from the table. $query->select($this->getState('list.select', 'a.extension_id, a.name, a.element, a.client_id')); $query->from('`#__extensions` AS a'); // Filter by extension type. $query->where('`type` = ' . $this->_db->quote('template')); // Filter by client. $clientId = $this->getState('filter.client_id'); if (is_numeric($clientId)) { $query->where('a.client_id = ' . (int) $clientId); } // Filter by search in title $search = $this->getState('filter.search'); if (!empty($search)) { if (stripos($search, 'id:') === 0) { $query->where('a.id = ' . (int) substr($search, 3)); } else { $search = $this->_db->Quote('%' . $this->_db->getEscaped($search, true) . '%'); $query->where('a.element LIKE ' . $search . ' OR a.name LIKE ' . $search); } } // Add the list ordering clause. $query->order($this->_db->getEscaped($this->getState('list.ordering', 'a.folder')) . ' ' . $this->_db->getEscaped($this->getState('list.direction', 'ASC'))); //echo nl2br(str_replace('#__','jos_',$query)); return $query; }
/** * Method to get a list of options for a list input. * * @return array An array of JHtml options. */ protected function _getOptions() { $db =& JFactory::getDbo(); $query = new JQuery(); $query->select('a.id AS value, a.title AS text, a.level'); $query->from('#__categories AS a'); $query->join('LEFT', '`#__categories` AS b ON a.lft > b.lft AND a.rgt < b.rgt'); // Filter by the type if ($extension = $this->_form->getValue('extension')) { $query->where('(a.extension = ' . $db->quote($extension) . ' OR a.parent_id = 0)'); } // Prevent parenting to children of this item. if ($id = $this->_form->getValue('id')) { $query->join('LEFT', '`#__categories` AS p ON p.id = ' . (int) $id); $query->where('NOT(a.lft >= p.lft AND a.rgt <= p.rgt)'); } $query->group('a.id'); $query->order('a.lft ASC'); // Get the options. $db->setQuery($query); $options = $db->loadObjectList(); // Check for a database error. if ($db->getErrorNum()) { JError::raiseWarning(500, $db->getErrorMsg()); } // Pad the option text with spaces using depth level as a multiplier. for ($i = 0, $n = count($options); $i < $n; $i++) { $options[$i]->text = str_repeat('- ', $options[$i]->level) . $options[$i]->text; } $options = array_merge(parent::_getOptions(), $options); return $options; }
/** * Build an SQL query to load the list data. * * @return JQuery */ protected function _getListQuery() { // Create a new query object. $query = new JQuery(); // Select the required fields from the table. $query->select($this->getState('list.select', 'a.*')); $query->from('`#__redirect_links` AS a'); // Filter by published state $state = $this->getState('filter.state'); if (is_numeric($state)) { $query->where('a.published = ' . (int) $state); } else { if ($state === '') { $query->where('(a.published IN (0,1,2))'); } } // Filter the items over the search string if set. $search = $this->getState('filter.search'); if (!empty($search)) { if (stripos($search, 'id:') === 0) { $query->where('a.id = ' . (int) substr($search, 3)); } else { $search = $this->_db->Quote('%' . $this->_db->getEscaped($search, true) . '%'); $query->where('(`old_url` LIKE ' . $search . ' OR `new_url` LIKE ' . $search . ' OR `comment` LIKE ' . $search . ' OR `referer` LIKE ' . $search . ')'); } } // Add the list ordering clause. $query->order($this->_db->getEscaped($this->getState('list.ordering', 'a.old_url')) . ' ' . $this->_db->getEscaped($this->getState('list.direction', 'ASC'))); //echo nl2br(str_replace('#__','jos_',$query)); return $query; }
/** * Build an SQL query to load the list data. * * @return JQuery */ protected function _getListQuery() { // Create a new query object. $query = new JQuery(); // Select the required fields from the table. $query->select($this->getState('list.select', 'a.*')); $query->from('`#__viewlevels` AS a'); // Add the level in the tree. $query->group('a.id'); // Filter the items over the search string if set. $search = $this->getState('filter.search'); if (!empty($search)) { if (stripos($search, 'id:') === 0) { $query->where('a.id = ' . (int) substr($search, 3)); } else { $search = $this->_db->Quote('%' . $this->_db->getEscaped($search, true) . '%'); $query->where('a.title LIKE ' . $search); } } $query->group('a.id'); // Add the list ordering clause. $query->order($this->_db->getEscaped($this->getState('list.ordering', 'a.lft')) . ' ' . $this->_db->getEscaped($this->getState('list.direction', 'ASC'))); //echo nl2br(str_replace('#__','jos_',$query)); return $query; }
function fetchElement($name, $value, &$node, $control_name) { $access = JFactory::getACL(); // Include user in groups that have access to edit their articles, other articles, or manage content. $action = array('com_content.article.edit_own', 'com_content.article.edit_article', 'com_content.manage'); $groups = $access->getAuthorisedUsergroups($action, true); // Check the results of the access check. if (!$groups) { return false; } // Clean up and serialize. JArrayHelper::toInteger($groups); $groups = implode(',', $groups); // Build the query to get the users. $query = new JQuery(); $query->select('u.id AS value'); $query->select('u.name AS text'); $query->from('#__users AS u'); $query->join('INNER', '#__user_usergroup_map AS m ON m.user_id = u.id'); $query->where('u.block = 0'); $query->where('m.group_id IN (' . $groups . ')'); // Get the users. $db = JFactory::getDbo(); $db->setQuery((string) $query); $users = $db->loadObjectList(); // Check for a database error. if ($db->getErrorNum()) { JError::raiseNotice(500, $db->getErrorMsg()); return false; } return JHtml::_('select.genericlist', $users, $name, 'class="inputbox" size="1"', 'value', 'text', $value); }
/** * Method to build an SQL query to load the list data. * * @return string An SQL query * @since 1.6 */ protected function _getListQuery() { $user =& JFactory::getUser(); $groups = implode(',', $user->authorisedLevels()); // Create a new query object. $query = new JQuery(); // Select required fields from the categories. $query->select($this->getState('list.select', 'a.*')); $query->from('`#__weblinks` AS a'); $query->where('a.access IN (' . $groups . ')'); // Filter by category. if ($categoryId = $this->getState('category.id')) { $query->where('a.catid = ' . (int) $categoryId); $query->join('LEFT', '#__categories AS c ON c.id = a.catid'); $query->where('c.access IN (' . $groups . ')'); } // Filter by state $state = $this->getState('filter.state'); if (is_numeric($state)) { $query->where('a.state = ' . (int) $state); } // Add the list ordering clause. $query->order($this->_db->getEscaped($this->getState('list.ordering', 'a.ordering')) . ' ' . $this->_db->getEscaped($this->getState('list.direction', 'ASC'))); return $query; }
/** * @param boolean True to join selected foreign information * * @return string */ function _getListQuery($resolveFKs = true) { // Create a new query object. $query = new JQuery(); // Select the required fields from the table. $query->select($this->getState('list.select', 'a.id, a.title, a.alias, a.checked_out, a.checked_out_time, a.catid, a.state, a.access, a.created, a.hits')); $query->from('#__content AS a'); // Join over the content table. $query->select('fp.ordering'); $query->join('INNER', '#__content_frontpage AS fp ON fp.content_id = a.id'); // Join over the users for the checked out user. $query->select('uc.name AS editor'); $query->join('LEFT', '#__users AS uc ON uc.id=a.checked_out'); // Join over the asset groups. $query->select('ag.title AS access_level'); $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); // Join over the categories. $query->select('c.title AS category_title'); $query->join('LEFT', '#__categories AS c ON c.id = a.catid'); // Join over the users for the author. $query->select('ua.name AS author_name'); $query->join('LEFT', '#__users AS ua ON ua.id = a.created_by'); // Filter by access level. if ($access = $this->getState('filter.access')) { $query->where('a.access = ' . (int) $access); } // Filter by published state $published = $this->getState('filter.published'); if (is_numeric($published)) { $query->where('a.state = ' . (int) $published); } else { if ($published === '') { $query->where('(a.state = 0 OR a.state = 1)'); } } // Filter by search in title $search = $this->getState('filter.search'); if (!empty($search)) { if (stripos($search, 'id:') === 0) { $query->where('a.id = ' . (int) substr($search, 3)); } else { $search = $this->_db->Quote('%' . $this->_db->getEscaped($search, true) . '%'); $query->where('a.title LIKE ' . $search . ' OR a.alias LIKE ' . $search); } } // Add the list ordering clause. $query->order($this->_db->getEscaped($this->getState('list.ordering', 'a.title')) . ' ' . $this->_db->getEscaped($this->getState('list.direction', 'ASC'))); //echo nl2br(str_replace('#__','jos_',$query->toString())); return $query; }
function getList(&$params) { //get database $db =& JFactory::getDbo(); $query = new JQuery(); $query->select('MONTH(created) AS created_month, created, id, title, YEAR(created) AS created_year'); $query->from('#__content'); $query->where('state = -1 AND checked_out = 0'); $query->group('created_year DESC, created_month DESC'); // $query = 'SELECT MONTH(created) AS created_month, created, id, title, YEAR(created) AS created_year' . // ' FROM #__content' . // ' WHERE (state = -1 AND checked_out = 0)' . // ' GROUP BY created_year DESC, created_month DESC'; $db->setQuery($query, 0, intval($params->get('count'))); $rows = $db->loadObjectList(); $menu =& JSite::getMenu(); $item = $menu->getItems('link', 'index.php?option=com_content&view=archive', true); $itemid = isset($item) ? '&Itemid=' . $item->id : ''; $i = 0; $lists = array(); foreach ($rows as $row) { $date =& JFactory::getDate($row->created); $created_month = $date->toFormat("%m"); $month_name = $date->toFormat("%B"); $created_year = $date->toFormat("%Y"); $lists[$i]->link = JRoute::_('index.php?option=com_content&view=archive&year=' . $created_year . '&month=' . $created_month . $itemid); $lists[$i]->text = $month_name . ', ' . $created_year; $i++; } return $lists; }
/** * Method to build an SQL query to load the list data. * * @return string An SQL query * @since 1.6 */ protected function _getListQuery() { // Create a new query object. $query = new JQuery(); // Select all fields from the users table. $query->select($this->getState('list.select', 'a.*')); $query->from('`#__languages` AS a'); // Filter on the published state. $published = $this->getState('filter.published'); if (is_numeric($published)) { $query->where('a.published = ' . (int) $published); } else { if ($published === '') { $query->where('(a.published IN (0, 1))'); } } // Filter by search in title $search = $this->getState('filter.search'); if (!empty($search)) { $search = $this->_db->Quote('%' . $this->_db->getEscaped($search, true) . '%', false); $query->where('(a.title LIKE ' . $search . ')'); } // Add the list ordering clause. $query->order($this->_db->getEscaped($this->getState('list.ordering', 'a.ordering')) . ' ' . $this->_db->getEscaped($this->getState('list.direction', 'ASC'))); return $query; }
/** * Method to build an SQL query to load the list data. * * @access protected * @return string An SQL query * @since 1.0 */ function _getListQuery() { $query = new JQuery(); // Select the required fields from the table. $query->select($this->getState('list.select', 'a.*')); $query->from('`#__social_threads` AS a'); // Join on the comments table. $query->select('COUNT(c.id) AS comment_count'); $query->leftJoin('#__social_comments AS c ON c.thread_id = a.id'); // Join on the ratings table. $query->select('pscore_count'); $query->leftJoin('#__social_ratings AS r ON r.thread_id = a.id'); $query->group('a.id'); // Filter the items over the context if set. if ($context = $this->getState('filter.context')) { $query->where('a.context = ' . $this->_db->Quote($context)); } // Filter by search string. if ($search = $this->getState('filter.search')) { if (stripos($search, 'id:') === 0) { $query->where('a.id = ' . (int) substr($search, 3)); } else { $search = $this->_db->Quote('%' . $this->_db->getEscaped($search, true) . '%'); $query->where('a.page_title LIKE ' . $search); } } // Add the list ordering clause. $query->order($this->_db->getEscaped($this->getState('list.ordering', 'a.id') . ' ' . $this->getState('list.direction', 'asc'))); //echo nl2br(str_replace('#__','jos_',$query)); return $query; }
/** * Build an SQL query to load the list data. * * @return JQuery */ protected function _getListQuery() { // Create a new query object. $query = new JQuery(); // Select the required fields from the table. $query->select($this->getState('list.select', 'a.*')); $query->from('`#__usergroups` AS a'); // Add the level in the tree. $query->select('COUNT(DISTINCT c2.id) AS level'); $query->join('LEFT OUTER', '`#__usergroups` AS c2 ON a.lft > c2.lft AND a.rgt < c2.rgt'); $query->group('a.id'); // Count the objects in the user group. $query->select('COUNT(DISTINCT map.user_id) AS user_count'); $query->join('LEFT', '`#__user_usergroup_map` AS map ON map.group_id = a.id'); $query->group('a.id'); // Filter the comments over the search string if set. $search = $this->getState('filter.search'); if (!empty($search)) { if (stripos($search, 'id:') === 0) { $query->where('a.id = ' . (int) substr($search, 3)); } else { $search = $this->_db->Quote('%' . $this->_db->getEscaped($search, true) . '%'); $query->where('a.title LIKE ' . $search); } } // Add the list ordering clause. $query->order($this->_db->getEscaped($this->getState('list.ordering', 'a.lft')) . ' ' . $this->_db->getEscaped($this->getState('list.direction', 'ASC'))); //echo nl2br(str_replace('#__','jos_',$query)); return $query; }
/** * Build an SQL query to load the list data. * * @return JQuery */ protected function _getListQuery() { // Create a new query object. $query = new JQuery(); // Select the required fields from the table. $query->select($this->getState('list.select', 'a.id, a.template, a.title, a.home, a.client_id')); $query->from('`#__template_styles` AS a'); // Join on menus. $query->select('COUNT(m.template_style_id) AS assigned'); $query->leftjoin('#__menu AS m ON m.template_style_id = a.id'); $query->group('a.id'); // Filter by template. if ($template = $this->getState('filter.template')) { $query->where('a.template = ' . $this->_db->quote($template)); } // Filter by client. $clientId = $this->getState('filter.client_id'); if (is_numeric($clientId)) { $query->where('a.client_id = ' . (int) $clientId); } // Filter by search in title $search = $this->getState('filter.search'); if (!empty($search)) { if (stripos($search, 'id:') === 0) { $query->where('a.id = ' . (int) substr($search, 3)); } else { $search = $this->_db->Quote('%' . $this->_db->getEscaped($search, true) . '%'); $query->where('a.template LIKE ' . $search . ' OR a.title LIKE ' . $search); } } // Add the list ordering clause. $query->order($this->_db->getEscaped($this->getState('list.ordering', 'a.name')) . ' ' . $this->_db->getEscaped($this->getState('list.direction', 'ASC'))); //echo nl2br(str_replace('#__','jos_',$query)); return $query; }
/** * Method to get the field input. * * @return string The field input. */ protected function _getGroups() { $client = $this->_element->attributes('client'); $client_id = $client == 'administrator' ? 1 : 0; $db = JFactory::getDBO(); $query = new JQuery(); $query->select($db->nameQuote('id')); $query->select($db->nameQuote('title')); $query->select($db->nameQuote('template')); $query->from($db->nameQuote('#__template_styles')); $query->where($db->nameQuote('client_id') . '=' . (int) $client_id); $query->order($db->nameQuote('template')); $query->order($db->nameQuote('title')); $db->setQuery($query); $styles = $db->loadObjectList(); // Pre-process into groups. $last = null; $groups = array(); foreach ($styles as $style) { if ($style->template != $last) { $last = $style->template; $groups[$last] = array(); } $groups[$last][] = JHtml::_('select.option', $style->id, $style->title); } // Merge any additional options in the XML definition. $groups = array_merge(parent::_getGroups(), $groups); return $groups; }
/** * Get the parent asset id for the record * * @return int */ protected function _getAssetParentId() { // Initialise variables. $assetId = null; // This is a category under a category. if ($this->parent_id > 1) { // Build the query to get the asset id for the parent category. $query = new JQuery(); $query->select('asset_id'); $query->from('#__categories'); $query->where('id = ' . (int) $this->parent_id); // Get the asset id from the database. $this->_db->setQuery($query); if ($result = $this->_db->loadResult()) { $assetId = (int) $result; } } elseif ($assetId === null) { // Build the query to get the asset id for the parent category. $query = new JQuery(); $query->select('id'); $query->from('#__assets'); $query->where('name = ' . $this->_db->quote($this->extension)); // Get the asset id from the database. $this->_db->setQuery($query); if ($result = $this->_db->loadResult()) { $assetId = (int) $result; } } // Return the asset id. if ($assetId) { return $assetId; } else { return parent::_getAssetParentId(); } }
/** * Build an SQL query to load the list data. * * @return JQuery */ protected function _getListQuery() { // Create a new query object. $query = new JQuery(); // Select the required fields from the table. $query->select($this->getState('list.select', 'a.extension_id, a.name, a.element AS module')); $query->from('`#__extensions` AS a'); // Filter by module $query->where('a.type = ' . $this->_db->Quote('module')); // Filter by client. $clientId = $this->getState('filter.client_id'); $query->where('a.client_id = ' . (int) $clientId); // Add the list ordering clause. $query->order($this->_db->getEscaped($this->getState('list.ordering', 'a.ordering')) . ' ' . $this->_db->getEscaped($this->getState('list.direction', 'ASC'))); //echo nl2br(str_replace('#__','jos_',$query)); return $query; }
/** * Loads the entire menu table into memory. * * @return array */ public function load() { $cache =& JFactory::getCache('_system', 'output'); if (!($data = $cache->get('menu_items'))) { jimport('joomla.database.query'); // Initialise some variables. $db =& JFactory::getDbo(); $query = new JQuery(); $query->select('m.id, m.menutype, m.title, m.alias, m.path AS route, m.link, m.type, m.level'); $query->select('m.browserNav, m.access, m.params, m.home, m.img, m.template_style_id, m.component_id, m.parent_id'); $query->select('e.element as component'); $query->from('#__menu AS m'); $query->leftJoin('#__extensions AS e ON m.component_id = e.extension_id'); $query->where('m.published = 1'); $query->where('m.parent_id > 0'); $query->order('m.lft'); $db->setQuery($query); if (!($menus = $db->loadObjectList('id'))) { JError::raiseWarning(500, "Error loading Menus: " . $db->getErrorMsg()); return false; } foreach ($menus as &$menu) { // Get parent information. $parent_tree = array(); if (($parent = $menu->parent_id) && isset($menus[$parent]) && is_object($menus[$parent]) && isset($menus[$parent]->route) && isset($menus[$parent]->tree)) { $parent_tree = $menus[$parent]->tree; } // Create tree. array_push($parent_tree, $menu->id); $menu->tree = $parent_tree; // Create the query array. $url = str_replace('index.php?', '', $menu->link); if (strpos($url, '&') !== false) { $url = str_replace('&', '&', $url); } parse_str($url, $menu->query); } $cache->store(serialize($menus), 'menu_items'); $this->_items = $menus; } else { $this->_items = unserialize($data); } }
/** * Builds the query to select contact items * @param array * @return string * @access protected */ function _getContactQuery($pk = null) { // TODO: Cache on the fingerprint of the arguments $db =& JFactory::getDbo(); $user =& JFactory::getUser(); $pk = !empty($pk) ? $pk : (int) $this->getState('contact.id'); $query = new JQuery(); if ($pk) { $query->select('a.*, cc.access as category_access, cc.title as category_name, ' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug, ' . ' CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(\':\', cc.id, cc.alias) ELSE cc.id END AS catslug '); $query->from('#__contact_details AS a'); $query->join('INNER', '#__categories AS cc on cc.id = a.catid'); $query->where('a.id = ' . (int) $pk); $query->where('a.published = 1'); $query->where('cc.published = 1'); $groups = implode(',', $user->authorisedLevels()); $query->where('a.access IN (' . implode(',', $user->authorisedLevels()) . ')'); } return $query; }
/** * Get the options for the list. */ protected function _getOptions(&$node) { jimport('joomla.database.query'); $clientId = ($v = $node->attributes('client_id')) ? $v : 0; $options = array(); $path1 = null; $path2 = null; // Load template entries for each menuid $db =& JFactory::getDBO(); $query = new JQuery(); $query->select('template'); $query->from('#__template_styles'); $query->where('client_id = ' . (int) $clientId); $query->where('home = 1'); $db->setQuery($query); $template = $db->loadResult(); if ($module = $node->attributes('module')) { $base = $clientId == 1 ? JPATH_ADMINISTRATOR : JPATH_SITE; $module = preg_replace('#\\W#', '', $module); $path1 = $base . DS . 'modules' . DS . $module . DS . 'tmpl'; $path2 = $base . DS . 'templates' . DS . $template . DS . 'html' . DS . $module; $options[] = JHTML::_('select.option', '', ''); } if ($path1 && $path2) { jimport('joomla.filesystem.file'); $path1 = JPath::clean($path1); $path2 = JPath::clean($path2); $files = JFolder::files($path1, '^[^_]*\\.php$'); foreach ($files as $file) { $options[] = JHTML::_('select.option', JFile::stripExt($file)); } if (is_dir($path2) && ($files = JFolder::files($path2, '^[^_]*\\.php$'))) { $options[] = JHTML::_('select.optgroup', JText::_('JOption_From_Default')); foreach ($files as $file) { $options[] = JHTML::_('select.option', JFile::stripExt($file)); } } } // Merge any additional options in the XML definition. $options = array_merge(parent::_getOptions($node), $options); return $options; }
/** * Returns an array of menu items groups by menu. * * @param array An array of configuration options. * * @return array */ public static function menuitems($config = array()) { if (empty(self::$items)) { $db =& JFactory::getDbo(); $db->setQuery('SELECT menutype As value, title As text' . ' FROM #__menu_types' . ' ORDER BY title'); $menus = $db->loadObjectList(); $query = new JQuery(); $query->select('a.id AS value, a.title As text, a.level, a.menutype'); $query->from('#__menu AS a'); $query->where('a.parent_id > 0'); $query->where('a.type <> ' . $db->quote('url')); // Filter on the published state if (isset($config['published'])) { $query->where('a.published = ' . (int) $config['published']); } $query->order('a.lft'); $db->setQuery($query); $items = $db->loadObjectList(); // Collate menu items based on menutype $lookup = array(); foreach ($items as &$item) { if (!isset($lookup[$item->menutype])) { $lookup[$item->menutype] = array(); } $lookup[$item->menutype][] =& $item; $item->text = str_repeat('- ', $item->level) . $item->text; } self::$items = array(); foreach ($menus as &$menu) { self::$items[] = JHtml::_('select.optgroup', $menu->text); self::$items[] = JHtml::_('select.option', $menu->value . '.0', JText::_('Menus_Add_to_this_menu')); if (isset($lookup[$menu->value])) { foreach ($lookup[$menu->value] as &$item) { self::$items[] = JHtml::_('select.option', $menu->value . '.' . $item->value, $item->text); } } } } return self::$items; }
/** * Build an SQL query to load the list data. * * @return JQuery */ protected function _getListQuery() { // Create a new query object. $query = new JQuery(); // Select the required fields from the table. $query->select($this->getState('list.select', 'a.*')); $query->from('`#__core_log_searches` AS a'); // Filter by access level. if ($access = $this->getState('filter.access')) { $query->where('a.access = ' . (int) $access); } // Filter by search in title $search = $this->getState('filter.search'); if (!empty($search)) { $search = $this->_db->Quote('%' . $this->_db->getEscaped($search, true) . '%'); $query->where('a.search_term LIKE ' . $search); } // Add the list ordering clause. $query->order($this->_db->getEscaped($this->getState('list.ordering', 'a.hits')) . ' ' . $this->_db->getEscaped($this->getState('list.direction', 'ASC'))); //echo nl2br(str_replace('#__','jos_',$query)); return $query; }
/** * Method to get a list of options for a list input. * * @return array An array of JHtml options. */ protected function _getOptions() { $db = JFactory::getDbo(); $query = new JQuery(); $clientId = (int) $this->_form->getValue('client_id'); $client = JApplicationHelper::getClientInfo($clientId); jimport('joomla.filesystem.folder'); // template assignment filter $query = new JQuery(); $query->select('DISTINCT(template)'); $query->from('#__template_styles'); $query->where('client_id = ' . (int) $clientId); $db->setQuery($query); $templates = $db->loadResultArray(); if ($error = $db->getErrorMsg()) { JError::raiseWarning(500, $error); return false; } $query = new JQuery(); $query->select('DISTINCT(position)'); $query->from('#__modules'); $query->where('`client_id` = ' . (int) $clientId); $db->setQuery($query); $positions = $db->loadResultArray(); if ($error = $db->getErrorMsg()) { JError::raiseWarning(500, $error); return false; } // Load the positions from the installed templates. foreach ($templates as $template) { $path = JPath::clean($client->path . '/templates/' . $template . '/templateDetails.xml'); if (file_exists($path)) { $xml = simplexml_load_file($path); if (isset($xml->positions[0])) { foreach ($xml->positions[0] as $position) { $positions[] = (string) $position; } } } } $positions = array_unique($positions); sort($positions); $options = array(); foreach ($positions as $position) { $options[] = JHtml::_('select.option', $position, $position); } // Merge any additional options in the XML definition. $options = array_merge(parent::_getOptions(), $options); return $options; }
/** * Returns an array of categories for the given extension. * * @param string The extension option. * @param array An array of configuration options. By default, only published and unpulbished categories are returned. * * @return array */ public static function options($extension, $config = array('filter.published' => array(0, 1))) { $hash = md5($extension . '.' . serialize($config)); if (!isset(self::$items[$hash])) { $config = (array) $config; $db =& JFactory::getDbo(); jimport('joomla.database.query'); $query = new JQuery(); $query->select('a.id, a.title, a.level'); $query->from('#__categories AS a'); $query->where('a.parent_id > 0'); // Filter on extension. $query->where('extension = ' . $db->quote($extension)); // Filter on the published state if (isset($config['filter.published'])) { if (is_numeric($config['filter.published'])) { $query->where('a.published = ' . (int) $config['filter.published']); } else { if (is_array($config['filter.published'])) { JArrayHelper::toInteger($config['filter.published']); $query->where('a.published IN (' . implode(',', $config['filter.published']) . ')'); } } } $query->order('a.lft'); $db->setQuery($query); $items = $db->loadObjectList(); // Assemble the list options. self::$items[$hash] = array(); foreach ($items as &$item) { $item->title = str_repeat('- ', $item->level - 1) . $item->title; self::$items[$hash][] = JHtml::_('select.option', $item->id, $item->title); } } return self::$items[$hash]; }
function getOnlineUserNames() { $db =& JFactory::getDbo(); $result = null; $query = new JQuery(); $query->select('a.username, a.time, a.userid, a.usertype, a.client_id'); $query->from('#__session AS a'); $query->where('a.userid != 0'); $query->group('a.userid'); $db->setQuery($query); $result = $db->loadObjectList(); if ($db->getErrorNum()) { JError::raiseWarning(500, $db->stderr()); } return $result; }
/** * Returns an array of standard published state filter options. * * @return string The HTML code for the select tag */ public static function folderOptions() { jimport('joomla.database.query'); $db = JFactory::getDbo(); $query = new JQuery(); $query->select('DISTINCT(folder) AS value, folder AS text'); $query->from('#__extensions'); $query->where('`type` = ' . $db->quote('plugin')); $query->order('name'); $db->setQuery($query); $options = $db->loadObjectList(); if ($error = $db->getErrorMsg()) { JError::raiseWarning(500, $error); } return $options; }
/** * Build an SQL query to load the list data. * * @return JQuery */ protected function _getListQuery() { // Create a new query object. $query = new JQuery(); // Select the required fields from the table. $query->select($this->getState('list.select', 'a.extension_id, a.name, a.element, a.folder, a.checked_out, a.checked_out_time,' . ' a.enabled, a.access, a.ordering')); $query->from('`#__extensions` AS a'); $query->where('`type` = ' . $this->_db->quote('plugin')); // Join over the users for the checked out user. $query->select('uc.name AS editor'); $query->join('LEFT', '#__users AS uc ON uc.id=a.checked_out'); // Join over the asset groups. $query->select('ag.title AS access_level'); $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); // Filter by access level. if ($access = $this->getState('filter.access')) { $query->where('a.access = ' . (int) $access); } // Filter by published state $published = $this->getState('filter.state'); if (is_numeric($published)) { $query->where('a.enabled = ' . (int) $published); } else { if ($published === '') { $query->where('(a.enabled IN (0, 1))'); } } // Filter by folder. if ($folder = $this->getState('filter.folder')) { $query->where('a.folder = ' . $this->_db->quote($folder)); } // Filter by search in title $search = $this->getState('filter.search'); if (!empty($search)) { if (stripos($search, 'id:') === 0) { $query->where('a.id = ' . (int) substr($search, 3)); } else { $search = $this->_db->Quote('%' . $this->_db->getEscaped($search, true) . '%'); $query->where('a.name LIKE ' . $search); } } // Add the list ordering clause. $query->order($this->_db->getEscaped($this->getState('list.ordering', 'a.name')) . ' ' . $this->_db->getEscaped($this->getState('list.direction', 'ASC'))); //echo nl2br(str_replace('#__','jos_',$query)); return $query; }
/** * Method to get a single record. * * @param integer The id of the primary key. * * @return mixed Object on success, false on failure. */ public function &getItem($pk = null) { // Initialise variables. $pk = !empty($pk) ? $pk : (int) $this->getState('message.id'); $false = false; // Get a row instance. $table = $this->getTable(); // Attempt to load the row. $return = $table->load($pk); // Check for a table object error. if ($return === false && $table->getError()) { $this->setError($table->getError()); return $false; } // Convert to the JObject before adding other data. $value = JArrayHelper::toObject($table->getProperties(1), 'JObject'); // Prime required properties. if (empty($table->id)) { // Prepare data for a new record. if ($replyId = $this->getState('reply.id')) { // If replying to a message, preload some data. $db = $this->getDbo(); $query = new JQuery(); $query->select('subject, user_id_from'); $query->from('#__messages'); $query->where('message_id = ' . (int) $replyId); $message = $db->setQuery($query)->loadObject(); if ($error = $db->getErrorMsg()) { $this->setError($error); return false; } $value->set('user_id_to', $message->user_id_from); $re = JText::_('Messages_Re'); if (stripos($message->subject, $re) !== 0) { $value->set('subject', $re . $message->subject); } } } else { // Get the user name for an existing messasge. if ($table->user_id_from && ($fromUser = new JUser($table->user_id_from))) { $value->set('from_user_name', $fromUser->name); } } return $value; }
/** * Count the number of users online. * * @return mixed The number of users online, or false on error. */ public static function getOnlineCount() { jimport('joomla.database.query'); $db = JFactory::getDbo(); $session = JFactory::getSession(); $sessionId = $session->getId(); $query = new JQuery(); $query->select('COUNT(a.session_id)'); $query->from('#__session AS a'); $query->where('a.session_id <> ' . $db->Quote($sessionId)); $db->setQuery($query); $result = (int) $db->loadResult(); if ($error = $db->getErrorMsg()) { JError::raiseWarning(500, $error); return false; } return $result; }
/** * Count the number of unread messages. * * @return mixed The number of unread messages, or false on error. */ public static function getCount() { jimport('joomla.database.query'); // Initialise variables. $db = JFactory::getDbo(); $user = JFactory::getUser(); // Get the number of unread messages in your inbox. $query = new JQuery(); $query->select('COUNT(*)'); $query->from('#__messages'); $query->where('state = 0 AND user_id_to = ' . (int) $user->get('id')); $result = (int) $db->setQuery($query)->loadResult(); if ($error = $db->getErrorMsg()) { JError::raiseWarning(500, $error); return false; } return $result; }
/** * Get the options for the element * * @param object $node * @return array */ protected function _getOptions(&$node) { $db =& JFactory::getDbo(); $query = new JQuery(); $query->select('a.lang_code AS value, a.title AS text, a.title_native'); $query->from('#__languages AS a'); $query->where('a.published >= 0'); $query->order('a.title'); // Get the options. $db->setQuery($query); $options = $db->loadObjectList(); // Check for a database error. if ($db->getErrorNum()) { JError::raiseWarning(500, $db->getErrorMsg()); } // Merge any additional options in the XML definition. $options = array_merge(parent::_getOptions($node), $options); return $options; }