Example #1
0
 protected function _buildQueryWhere(KDatabaseQuery $query)
 {
     if ($this->_state->source instanceof KDatabaseRowInterface) {
         $source = $this->_state->source;
         $query->where('tbl.files_container_id', '=', $source->container->id)->where('tbl.folder', '=', '/' . $source->relative_folder)->where('tbl.filename', '=', $source->name);
     } else {
         if ($this->_state->folder) {
             $query->where('tbl.folder', '=', $this->_state->folder);
         } else {
             if ($this->_state->files) {
                 $query->where('tbl.filename', 'IN', $this->_state->files);
             }
         }
     }
     $states = $this->_state->getData(true);
     /*
      * This is here so that parent method won't try to use the source row object when creating the query
      */
     if (!empty($states)) {
         $states = $this->getTable()->mapColumns($states);
         foreach ($states as $key => $value) {
             if ($key != 'source' && isset($value)) {
                 $query->where('tbl.' . $key, 'IN', $value);
             }
         }
     }
 }
Example #2
0
	protected function _buildQueryWhere(KDatabaseQuery $query)
    {
		if ($this->_state->source instanceof KDatabaseRowInterface) {
			$source = $this->_state->source;

			$query->where('tbl.files_container_id', '=', $source->container->id)
				->where('tbl.folder', '=', '/'.$source->relative_folder)
				->where('tbl.filename', '=', $source->name)
				;

			/*
			 * This is here so that parent method won't try to use the source row object when creating the query
			 */
			$this->_source = $source;
			$this->_state->source = null;
		}
		else if ($this->_state->folder) {
			$query->where('tbl.folder', '=', $this->_state->folder);
		}
		else if ($this->_state->files) {
			$query->where('tbl.filename', 'IN', $this->_state->files);
		}

		parent::_buildQueryWhere($query);

	}
 public function _buildQueryWhere(KDatabaseQuery $query)
 {
     if ($this->_parent_column) {
         $parent = $this->_parent ? $this->_parent : $this->{$this->_parent_column};
         $query->where($this->_table->mapColumns($this->_parent_column), '=', $parent);
     }
 }
Example #4
0
 protected function _buildQueryWhere(KDatabaseQuery $query)
 {
     $state = $this->getState();
     if ($state->search) {
         $search = '%' . $state->search . '%';
         $query->where('tbl.target_type', 'LIKE', $search);
         $query->where('tbl.text', 'LIKE', $search, 'OR');
     }
     if ($state->controller) {
         $query->where('tbl.controller', '=', $state->controller);
     }
     if ($state->browse) {
         $query->where('tbl.browse', '=', 1);
     }
     if ($state->read) {
         $query->where('tbl.read', '=', 1);
     }
     if ($state->edit) {
         $query->where('tbl.edit', '=', 1);
     }
     if ($state->add) {
         $query->where('tbl.add', '=', 1);
     }
     if ($state->delete) {
         $query->where('tbl.delete', '=', 1);
     }
     parent::_buildQueryWhere($query);
 }
Example #5
0
 public function _buildQueryWhere(KDatabaseQuery $query)
 {
     if($this->getMixer()->getIdentifier()->name == 'article' && !isset($this->featured_order))
     {
         $query->where('catid', '=', $this->category_id)
               ->where('state', '>=', 0);
     }
 }
Example #6
0
 protected function _buildQueryOrder(KDatabaseQuery $query)
 {
     if ($this->_state->distinct && !empty($this->_state->column)) {
         $query->order('package', 'asc');
     } else {
         parent::_buildQueryOrder($query);
     }
 }
Example #7
0
 protected function _buildQueryWhere(KDatabaseQuery $query)
 {
     if ($this->_state->task) {
         $query->where('tbl.jedi_task_id', '=', (int) $this->_state->task);
     }
     if ($this->_state->member) {
         $query->where('tbl.jedi_member_id', '=', (int) $this->_state->member);
     }
     parent::_buildQueryWhere($query);
 }
Example #8
0
	/**
     * Builds LEFT JOINS clauses for the query.
     *
     * @param   KDatabaseQuery  A query object.
     * @return  void
     */
	protected function _buildQueryJoins(KDatabaseQuery $query)
	{
	    $state = $this->_state;
	    
	    if($state->loggedin) {
			$query->join('RIGHT', 'session AS session', 'tbl.id = session.userid');
        } else {
            $query->join('LEFT', 'session AS session', 'tbl.id = session.userid');
        }
	}
Example #9
0
 protected function _buildQueryOrder(KDatabaseQuery $query)
 {
     $state = $this->_state;
     $direction = strtoupper($this->_state->direction);
     $element = $this->getService('com://admin/cck.model.elements')->slug(str_replace('_', '-', $state->sort))->getItem();
     if ($state->sort) {
         $query->order('cck.cck_element_id = ' . $element->id, null);
         $query->order('cck.value', $direction);
     }
 }
Example #10
0
 protected function _buildQueryWhere(KDatabaseQuery $query)
 {
     $state = $this->getState();
     if ($state->search) {
         $search = '%' . $state->search . '%';
         $query->where('tbl.title', 'LIKE', $search);
         $query->where('tbl.text', 'LIKE', $search, 'OR');
     }
     parent::_buildQueryWhere($query);
 }
 protected function _buildQueryWhere(KDatabaseQuery $query)
 {
     $state = $this->_state;
     if ($state->extman_extension_id) {
         $query->where('tbl.extman_extension_id', '=', $state->extman_extension_id);
     }
     if ($state->dependent_id) {
         $query->where('tbl.dependent_id', '=', $state->dependent_id);
     }
 }
Example #12
0
 protected function _buildQueryWhere(KDatabaseQuery $query)
 {
     if ($this->_state->search) {
         $query->where('tbl.title', 'LIKE', '%' . $this->_state->search . '%');
     }
     if (is_numeric($this->_state->enabled)) {
         $query->where('tbl.enabled', '=', $this->_state->enabled);
     }
     parent::_buildQueryWhere($query);
 }
Example #13
0
 protected function _buildQueryOrder(KDatabaseQuery $query)
 {
     $sort = $this->_state->sort;
     $direction = strtoupper($this->_state->direction);
     if ($sort) {
         $query->order($this->getTable()->mapColumns($sort), $direction);
     }
     if (array_key_exists('ordering', $this->getTable()->getColumns())) {
         $query->order('category.title, tbl.ordering', 'ASC');
     }
 }
Example #14
0
 protected function _buildQueryWhere(KDatabaseQuery $query)
 {
     $state = $this->_state;
     if (!$state->isUnique()) {
         if ($state->search) {
             $query->where('title', 'LIKE', '%' . $state->search . '%');
             $query->where('description', 'LIKE', '%' . $state->search . '%', 'OR');
         }
     }
     parent::_buildQueryWhere($query);
 }
Example #15
0
 protected function _buildQueryOrder(KDatabaseQuery $query)
 {
     //We need to write a proper sort function first.
     //$query->order('tbl.lft', 'ASC');
     $query->order('path_ordering', 'ASC');
     $order = $this->_state->order;
     $direction = strtoupper($this->_state->direction);
     if ($order) {
         $query->order($order, $direction);
     }
 }
 protected function _buildQueryWhere(KDatabaseQuery $query)
 {
     $state = $this->_state;
     if ($state->business) {
         $query->where('tbl.businesses_business_id', '=', $state->business);
     }
     if ($state->tag) {
         $query->where('tbl.businesses_tag_id', '=', $state->tag);
     }
     parent::_buildQueryWhere($query);
 }
 protected function _buildQueryWhere(KDatabaseQuery $query)
 {
     if (!$this->_state->isUnique()) {
         if ($this->_state->table) {
             $query->where('relations.table', '=', $this->_state->table);
         }
         if ($this->_state->row) {
             $query->where('relations.row', 'IN', $this->_state->row);
         }
     }
     parent::_buildQueryWhere($query);
 }
Example #18
0
 public function _buildQueryWhere(KDatabaseQuery $query)
 {
     if (is_array($this->_state->group_id)) {
         foreach ($this->_state->group_id as $group) {
             $query->where('FIND_IN_SET(' . $group . ', REPLACE(SUBSTRING_INDEX(SUBSTR(ANCESTORS,LOCATE(\'"GROUPS":[\',ANCESTORS)+CHAR_LENGTH(\'"GROUPS":[\')),\']\', 1),\'\', \'\'))', null, null, 'OR');
         }
     } else {
         if (is_int($this->_state->group_id)) {
             $query->where('FIND_IN_SET(' . $this->_state->group_id . ', REPLACE(SUBSTRING_INDEX(SUBSTR(ANCESTORS,LOCATE(\'"GROUPS":[\',ANCESTORS)+CHAR_LENGTH(\'"GROUPS":[\')),\']\', 1),\'\', \'\'))', null, null);
         }
     }
 }
 protected function _buildQueryWhere(KDatabaseQuery $query)
 {
     $state = $this->_state;
     if (!$state->isUnique()) {
         if ($state->subscribed) {
             $user = JFactory::getUser();
             $query->where('subscription.user_id', '=', $user->id);
         }
         if ($state->category) {
             $query->where('tbl.news_category_id', '=', $state->category);
         }
     }
     parent::_buildQueryWhere($query);
 }
Example #20
0
 protected function _buildQueryWhere(KDatabaseQuery $query)
 {
     global $mainframe, $option;
     $filter_state = $this->getState('filter_state');
     if ($filter_state) {
         if ($filter_state == 'P') {
             $query->where('enabled', '=', 1);
         } else {
             if ($filter_state == 'U') {
                 $query->where('enabled', '=', 0);
             }
         }
     }
 }
Example #21
0
 protected function _buildQueryWhere(KDatabaseQuery $query)
 {
     $state = $this->_state;
     if ($state->search) {
         $query->where('tbl.name', 'LIKE', '%' . $state->search . '%');
     }
     if (is_numeric($state->enabled)) {
         $query->where('tbl.enabled', '=', $state->enabled);
     }
     if (is_numeric($state->jedi_rank_id)) {
         $query->where('tbl.jedi_rank_id', '=', (int) $state->jedi_rank_id);
     }
     parent::_buildQueryWhere($query);
 }
 protected function _buildQueryWhere(KDatabaseQuery $query)
 {
     $state = $this->_state;
     if (!$state->isUnique()) {
         if ($state->subscribed) {
             $user = JFactory::getUser();
             $query->where('subscription.user_id', '=', $user->id);
         }
         if ($state->enabled) {
             $query->where('tbl.enabled', '=', (int) $state->enabled);
         }
         if ($state->category) {
             $query->where('tbl.news_category_id', '=', $state->category);
         }
         if ($state->search) {
             $query->where('(', null, null, 'AND')->where('tbl.title', 'LIKE', '%' . $state->search . '%', '')->where('tbl.text', 'LIKE', '%' . $state->search . '%', 'OR')->where(')', null, null, '');
         }
         if ($this->_state->start_date && $this->_state->start_date != '0000-00-00') {
             $start_date = $this->getService('koowa:date', array('date' => $this->_state->start_date));
             $end_date = $this->getService('koowa:date', array('date' => $this->_state->end_date));
             $start = $start_date->addDays(1)->addSeconds(-1)->getDate();
             $end = $end_date->addDays(1)->addSeconds(-1)->getDate();
             $query->where('tbl.created_on', '>', $start);
             $query->where('tbl.created_on', '<', $end);
         }
     }
     parent::_buildQueryWhere($query);
 }
 protected function _buildQueryWhere(KDatabaseQuery $query)
 {
     $state = $this->_state;
     if (is_bool($state->enabled)) {
         $query->where('tbl.published', '=', (int) $state->enabled);
     }
     if (is_numeric($state->category) && !empty($state->category)) {
         $query->where('tbl.catid', '=', $state->category);
     }
     if ($state->search) {
         $query->where('tbl.name', 'LIKE', '%' . $state->search . '%');
     }
     parent::_buildQueryWhere($query);
 }
Example #24
0
	protected function _buildQueryWhere(KDatabaseQuery $query)
	{
		$state = $this->_state;

		if($state->search) {
			$query->where('tbl.title', 'LIKE', '%'.$state->search.'%');
		}

		if($state->position) {
			$query->where('tbl.position', '=', $state->position);
		}
		
		if($state->type) {
			$query->where('tbl.module', '=', $state->type);
		}

		if($state->enabled !== '' && $state->enabled !== null) {
			$query->where('tbl.published', '=', $state->enabled);
		}
		
		if($state->application !== false)
		{
		    $client	= JApplicationHelper::getClientInfo($state->application, true);
	    	$query->where('tbl.client_id', '=', $client->id);
	    }

		parent::_buildQueryWhere($query);
	}
 protected function _buildQueryWhere(KDatabaseQuery $query)
 {
     $state = $this->_state;
     if ($state->source instanceof KDatabaseRowInterface) {
         $source = $state->source;
         $query->where('tbl.files_container_id', '=', $source->container->id)->where('tbl.filename', '=', $source->name);
         if ($source->folder) {
             $query->where('tbl.folder', '=', $source->folder);
         }
     } else {
         if ($state->container) {
             $query->where('tbl.files_container_id', '=', $state->container->id);
         }
         if ($state->folder !== false) {
             $query->where('tbl.folder', '=', ltrim($state->folder, '/'));
         }
         // Need this for BC
         if (!empty($state->files)) {
             $query->where('tbl.filename', 'IN', $state->files);
         }
         if ($state->filename) {
             $query->where('tbl.filename', '=', $state->filename);
         }
     }
 }
 protected function _buildQueryOrder(KDatabaseQuery $query)
 {
     $state = $this->_state;
     $direction = strtoupper($state->direction);
     if (is_bool($state->featured) && $state->featured == true) {
         if ($this->_state->sort == 'ordering') {
             $query->order('featured_ordering', $direction);
         } else {
             $query->order($this->_state->sort, $direction)->order('featured_ordering', 'ASC');
         }
     } else {
         if ($this->_state->sort == 'ordering') {
             $query->order('section_title', 'ASC')->order('category_title', 'ASC')->order('ordering', $direction);
         } else {
             $query->order($this->_state->sort, $direction)->order('section_title', 'ASC')->order('category_title', 'ASC')->order('ordering', 'ASC');
         }
     }
 }
Example #27
0
	protected function _buildQueryWhere(KDatabaseQuery $query)
	{
		$state = $this->_state;

		if($state->search) {
			$query->where('tbl.name', 'LIKE', '%'.$state->search.'%');
		}
		
		if($state->type) {
			$query->where('tbl.folder', '=', $state->type);
		}

		if($state->enabled !== '' && $state->enabled !== null) {
			$query->where('tbl.published', '=', $state->enabled);
		}

		parent::_buildQueryWhere($query);
	}
Example #28
0
 /**
  * Filter list based on search keyword
  *
  * @author Stian Didriksen <*****@*****.**>
  * @param KDatabaseQuery $query
  * @return $this
  */
 protected function _buildQueryWhere(KDatabaseQuery $query)
 {
     if ($search = trim($this->_state->search)) {
         $parts = explode(' ', $search);
         $states = array();
         foreach ($parts as $i => $part) {
             if (strpos($part, ':') === false) {
                 continue;
             }
             $keys = explode(':', $part);
             $states[$keys[0]] = $keys[1];
             unset($parts[$i]);
         }
         if ($states) {
             $conditions = array();
             foreach (array('username', 'email') as $key) {
                 if (isset($states[$key])) {
                     $query->where('tbl.' . $key, 'LIKE', '%' . $states[$key] . '%');
                 }
             }
             if ($parts) {
                 $query->where('tbl.name', 'LIKE', '%' . implode($parts) . '%');
             }
         } else {
             //To avoid auto quoting, and also trim trailing whitespace
             $search = $this->getTable()->getDatabase()->quoteValue('%' . strtoupper($search) . '%');
             $query->where("(tbl.name LIKE {$search} OR tbl.username LIKE {$search} OR tbl.email LIKE {$search} OR person.alias LIKE {$search})");
         }
     }
     $group = $this->_state->usergroup;
     if ($group) {
         $query->where('tbl.gid', '=', (int) $group);
     }
     if (!$this->_state->me) {
         $me = KFactory::get('admin::com.ninjaboard.model.people')->getMe();
         $query->where('tbl.id', '!=', $me->id);
     }
     //Don't show blocked users
     $query->where('tbl.block', '=', 0);
     parent::_buildQueryWhere($query);
 }
Example #29
0
 protected function _buildQueryOrder(KDatabaseQuery $query)
 {
     $sort = $this->_state->sort;
     $direction = strtoupper($this->_state->direction);
     if (!$sort) {
         //@TODO we no longer need this CONCAT part
         //$query->select("CONCAT(tbl.path, tbl.ninjaboard_forum_id, '/') AS path_ordering");
         $query->order('path_sort', 'asc');
     } elseif ($sort) {
         //Our model don't support DESC yet
         //$query->order($sort, $direction);
         $query->order($sort, 'asc');
     }
 }
Example #30
0
 protected function _buildQueryOrder(KDatabaseQuery $query)
 {
     $sort = $this->_state->sort ? $this->_state->sort : 'category';
     $direction = strtoupper($this->_state->direction);
     switch ($sort) {
         case 'random':
             $query->order('RAND()', 'ASC');
             break;
         case '0':
             $query->order('tbl.sticky', 'DESC');
             $query->order('tbl.ordering', 'ASC');
             break;
         case 'category':
             $query->order('category', $direction);
             $query->order('tbl.ordering', 'ASC');
             break;
         default:
             $query->order($this->getTable()->mapColumns($sort), $direction);
     }
 }