proper access rights $rows[$i] = $row; $i ++; } $this->_data[$state] = $rows; } return true; } function _buildQuery($state = 1) { global $mainframe; // Get the page/component configuration $params = &$mainframe->getParams(); // If voting is turned on, get voting data as well for the content items $voting = ContentHelperQuery::buildVotingQuery($params); // Get the WHERE and ORDER BY clauses for the query $where = $this->_buildContentWhere($state); $orderby = $this->_buildContentOrderBy($state); $query = 'SELECT cc.title AS category, a.id, a.title, a.alias, a.title_alias, a.introtext, a.fulltext, a.sectionid, a.state, a.catid, a.created, a.created_by, a.created_by_alias, a.modified, a.modified_by,' . ' a.checked_out, a.checked_out_time, a.publish_up, a.publish_down, a.attribs, a.hits, a.images, a.urls, a.ordering, a.metakey, a.metadesc, a.access,' . ' 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,'. ' CHAR_LENGTH( a.`fulltext` ) AS readmore, u.name AS author, u.usertype, g.name AS groups, u.email as author_email'.$voting['select'] . ' FROM #__content AS a' . ' LEFT JOIN #__categories AS cc ON a.catid = cc.id' . ' LEFT JOIN #__users AS u ON u.id = a.created_by' . ' LEFT JOIN #__groups AS g ON a.access = g.id'. $voting['join']. $where. $orderby; return $query; } function _buildContentOrderBy($state = 1) { global $mainframe; // Get the page/component configuration $params = &$mainframe->getParams(); $itemid = JRequest::getInt('id', 0) . ':' . JRequest::getInt('Itemid', 0); $filter_order = $mainframe->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order', 'filter_order', '', 'cmd'); $filter_order_Dir = $mainframe->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order_Dir', 'filter_order_Dir', '', 'cmd'); $orderby = ' ORDER BY '; if ($filter_order && $filter_order_Dir) { $orderby .= $filter_order .' '. $filter_order_Dir.', '; } if ($filter_order == 'author') { $orderby .= 'created_by_alias '. $filter_order_Dir.', '; } switch ($state) { case -1: // Special ordering for archive articles $orderby_sec = $params->def('orderby', 'rdate'); $secondary = ContentHelperQuery::orderbySecondary($orderby_sec).', '; $primary = ''; break; case 1: default: $orderby_sec = $params->def('orderby_sec', 'rdate'); $orderby_sec = ($orderby_sec == 'front') ? '' : $orderby_sec; $orderby_pri = $params->def('orderby_pri', ''); $secondary = ContentHelperQuery::orderbySecondary($orderby_sec).', '; $primary = ContentHelperQuery::orderbyPrimary($orderby_pri); break; } $orderby .= $primary .' '. $secondary .' a.created DESC'; return $orderby; } function _buildContentWhere($state = 1) { global $mainframe; $user =& JFactory::getUser(); $gid = $user->get('aid', 0); $jnow =& JFactory::getDate(); $now = $jnow->toMySQL(); // Get the page/component configuration $params = &$mainframe->getParams(); $noauth = !$params->get('show_noauth'); $nullDate = $this->_db->getNullDate(); $where = ' WHERE 1'; // Does the user have access to view the items? if ($noauth) { $where .= ' AND a.access <= '.(int) $gid; } // First thing we need to do is assert that the articles are in the current category if ($this->_id) { $where .= ' AND a.catid = '.(int) $this->_id; } // Regular Published Content switch ($state) { case 1: if ($user->authorize('com_content', 'edit', 'content', 'all')) { $where .= ' AND a.state >= 0'; } else { $where .= ' AND a.state = 1' . ' AND ( publish_up = '.$this->_db->Quote($nullDate).' OR publish_up <= '.$this->_db->Quote($now).' )' . ' AND ( publish_down = '.$this->_db->Quote($nullDate).' OR publish_down >= '.$this->_db->Quote($now).' )'; } break; // Archive Content case -1: // Get some request vars specific to this state $year = JRequest::getInt( 'year', date('Y') ); $month = JRequest::getInt( 'month', date('m') ); $where .= ' AND a.state = -1'; $where .= ' AND YEAR( a.created ) = '.(int) $year; $where .= ' AND MONTH( a.created ) = '.(int) $month; break; default: $where .= ' AND a.state = '.(int) $state; break; } /* * If we have a filter, and this is enabled... lets tack the AND clause * for the filter onto the WHERE clause of the content item query. */ if ($params->get('filter')) { $filter = JRequest::getString('filter', '', 'request'); if ($filter) { // clean filter variable $filter = JString::strtolower($filter); $hitsFilter = intval($filter); $filter = $this->_db->Quote( '%'.$this->_db->getEscaped( $filter, true ).'%', false ); switch ($params->get('filter_type')) { case 'author' : $where .= ' AND ( ( LOWER( u.name ) LIKE '.$filter.' ) OR ( LOWER( a.created_by_alias ) LIKE '.$filter.' ) )'; break; case 'hits' : $where .= ' AND a.hits >= '.$hitsFilter. ' '; break; case 'title' : default : // default to 'title' if parameter is not valid $where .= ' AND LOWER( a.title ) LIKE '.$filter; break; } } } return $where; } }