コード例 #1
0
ファイル: forums.php プロジェクト: ravenlife/Ninjaboard
 protected function _buildQueryColumns(KDatabaseQuery $query)
 {
     parent::_buildQueryColumns($query);
     /* TODO finish this function and remove the placeholder */
     $query->select('first_post.subject')->select('last_post.created_user_id');
     $query->select('tbl.last_post_id')->select('last_post.created_time AS last_post_date')->select('last_post.ninjaboard_topic_id AS last_topic_id');
     //Build query for the screen names
     KFactory::get('admin::com.ninjaboard.model.people')->buildScreenNameQuery($query, 'person', 'usr', 'last_post_username', 'IFNULL(last_post.guest_name, \'' . JText::_('Anonymous') . '\')');
     if (KFactory::get('lib.joomla.user')->guest) {
         $query->select(array('0 AS new', '1 AS unread'));
     } else {
         $me = KFactory::get('admin::com.ninjaboard.model.people')->getMe();
         $table = KFactory::get('admin::com.ninjaboard.database.table.logtopicreads');
         $select = KFactory::tmp('lib.koowa.database.query')->select('UNIX_TIMESTAMP(IFNULL(MIN(created_on), NOW()))')->where('created_by', '=', $me->id);
         $start = $table->select($select, KDatabase::FETCH_FIELD);
         //The conversion to unix timestamp and back is because koowa will quote raw datetime strings in select queries
         $query->select('IF(UNIX_TIMESTAMP(topic.last_post_on) > ' . (int) $start . ', 1, 0) AS new');
         //Count all the read topics by this user
         $reads = KFactory::tmp('lib.koowa.database.query')->select('COUNT(*)')->where('reads.ninjaboard_forum_id = tbl.ninjaboard_forum_id')->where('reads.created_by = ' . $me->id)->where('reads.created_on >= tmp.last_post_on')->join('left', 'ninjaboard_topics AS tmp', 'tmp.ninjaboard_topic_id = reads.ninjaboard_topic_id')->from('ninjaboard_log_topic_reads AS reads');
         //Count all the topics directly nesting in this forum, not counting down the tree
         $topics = KFactory::tmp('lib.koowa.database.query')->select('COUNT(*)')->where('topics.forum_id = tbl.ninjaboard_forum_id')->from('ninjaboard_topics AS topics');
         $query->select('IF(tbl.topics = 0, 0, (' . $topics . ') - (' . $reads . ')) AS unread');
         //$query->select('('.$topics.') AS total_topics');
         //$query->select('('.$reads.') AS total_reads');
     }
 }
コード例 #2
0
ファイル: assets.php プロジェクト: ravenlife/Ninjaboard
 protected function _buildQueryColumns(KDatabaseQuery $query)
 {
     parent::_buildQueryColumns($query);
 }