Example #1
0
 protected function _buildQueryJoins(KDatabaseQueryInterface $query)
 {
     parent::_buildQueryJoins($query);
     if ($this->getState()->container) {
         $query->join(array('c' => 'files_containers'), 'c.files_container_id = tbl.files_container_id');
     }
 }
Example #2
0
 protected function _buildQueryWhere(KDatabaseQueryInterface $query)
 {
     $state = $this->getState();
     parent::_buildQueryWhere($query);
     if (!$state->isUnique()) {
         $query->where('tbl.start <= :date AND (tbl.end >= :date OR tbl.end = :default)')->bind(array('date' => date('Y-m-d H:i:s'), 'default' => '0000-00-00 00:00:00'));
         if ($state->code) {
             $query->where('(tbl.global = :global AND tbl.code = :code)')->bind(array('global' => 1, 'code' => $state->code));
         }
         $query->where('(tbl.global = :global AND tbl.code = :empty)', $state->code ? 'OR' : 'AND')->bind(array('global' => 1, 'empty' => ''));
         $query->where('CASE WHEN tbl.usage_limit > 0 THEN tbl.usage_limit > tbl.times_used END');
         if (is_array($state->conditions)) {
             foreach ($state->conditions as $key => $values) {
                 foreach ($values as $value) {
                     $query->where('(FIND_IN_SET(' . $value . ', REPLACE(SUBSTRING_INDEX(SUBSTR(CONDITIONS,LOCATE(\'"' . strtoupper($key) . '":[\',CONDITIONS)+CHAR_LENGTH(\'"' . strtoupper($key) . '":[\')),\']\', 1),\'\', \'\'))', 'OR');
                 }
             }
             $query->where('CASE WHEN tbl.usage_limit > 0 THEN tbl.usage_limit > tbl.times_used END');
             if ($state->code) {
                 $query->where('(tbl.code = :empty OR tbl.code = :code))')->bind(array('empty' => '', 'code' => $state->code));
             } else {
                 $query->where('tbl.code = :empty)')->bind(array('empty' => ''));
             }
         }
     }
 }
Example #3
0
 protected function _buildQueryWhere(KDatabaseQueryInterface $query)
 {
     parent::_buildQueryWhere($query);
     $state = $this->getState();
     if ($state->search) {
         $query->where('tbl.title LIKE :search')->bind(array('search' => '%' . $state->search . '%'));
     }
 }
Example #4
0
 protected function _buildQueryWhere(KDatabaseQueryInterface $query)
 {
     parent::_buildQueryWhere($query);
     $state = $this->getState();
     if (!is_null($state->status) && $state->status != 'all') {
         $query->where('(tbl.status IN :status)')->bind(array('status' => (array) $state->status));
     }
 }
Example #5
0
 protected function _buildQueryWhere(KDatabaseQueryInterface $query)
 {
     parent::_buildQueryWhere($query);
     $state = $this->getState();
     if (!is_null($state->enabled)) {
         $query->where('(tbl.enabled IN :enabled)')->bind(array('enabled' => (array) $state->enabled));
     }
 }
Example #6
0
 protected function _buildQueryJoins(KDatabaseQueryInterface $query)
 {
     $state = $this->getState();
     parent::_buildQueryJoins($query);
     if ($state->table) {
         $identity_column = KStringInflector::singularize($state->table) . '_id';
         $table = KStringInflector::singularize($state->table) . '_translations';
         $query->columns('IFNULL(' . $identity_column . ', 0) AS translated')->columns('IFNULL(r.original, 0) AS original')->join(array('r' => $table), 'r.locale = tbl.lang_code AND r.' . $identity_column . ' = :id', 'left')->bind(array('id' => $state->row));
     }
 }
Example #7
0
 protected function _buildQueryWhere(KDatabaseQueryInterface $query)
 {
     parent::_buildQueryWhere($query);
     $state = $this->getState();
     if ($state->top_level) {
         $query->where('tbl.parent_id = 0');
     }
     if ($state->parent_id) {
         $query->where('tbl.parent_id = :parent_id')->bind(array('parent_id' => $state->parent_id));
     }
 }
Example #8
0
 protected function _buildQueryWhere(KDatabaseQueryInterface $query)
 {
     parent::_buildQueryWhere($query);
     $state = $this->getState();
     if ($state->mimetype) {
         $query->where('mimetype IN :mimetype')->bind(array('mimetype' => (array) $state->mimetype));
     }
     if ($state->extension) {
         $query->where('extension IN :extension')->bind(array('extension' => (array) $state->extension));
     }
 }
Example #9
0
 protected function _buildQueryWhere(KDatabaseQueryInterface $query)
 {
     $state = $this->getState();
     parent::_buildQueryWhere($query);
     if (is_numeric($state->default)) {
         $query->where('default = :default')->bind(array('default' => $state->default));
     }
     if (is_numeric($state->enabled)) {
         $query->where('enabled = :enabled')->bind(array('enabled' => $state->enabled));
     }
 }
 protected function _buildQueryWhere(KDatabaseQueryInterface $query)
 {
     parent::_buildQueryWhere($query);
     $state = $this->getState();
     if (!$state->isUnique()) {
         if ($table = $state->table) {
             $query->where('table = :table');
         }
         if ($row = $state->row) {
             $query->where('row = :row');
         }
         $column = $this->getConfig()->relation_column;
         if ($id = $state->{$column}) {
             $query->where("{$column} = :id");
         }
         $query->bind(array('table' => $table, 'row' => $row, 'id' => $id));
     }
 }
 /**
  * Builds WHERE clause for the query.
  *
  * @param KDatabaseQueryInterface $query
  */
 protected function _buildQueryWhere(KDatabaseQueryInterface $query)
 {
     parent::_buildQueryWhere($query);
     $state = $this->getState();
     if ($state->application) {
         $query->where('tbl.application = :application')->bind(array('application' => $state->application));
     }
     if ($state->type) {
         $query->where('tbl.type = :type')->bind(array('type' => $state->type));
     }
     if ($state->package) {
         $query->where('tbl.package IN :package')->bind(array('package' => (array) $state->package));
     }
     if ($state->name) {
         $query->where('tbl.name = :name')->bind(array('name' => $state->name));
     }
     if ($state->action) {
         $query->where('tbl.action IN (:action)')->bind(array('action' => $state->action));
     }
     if (is_numeric($state->row)) {
         $query->where('tbl.row IN (:row)')->bind(array('row' => $state->row));
     }
     if ($state->start_date && $state->start_date != '0000-00-00') {
         $start_date = $this->getObject('lib:date', array('date' => $state->start_date));
         $query->where('DATE(tbl.created_on) >= :start')->bind(array('start' => $start_date->format('Y-m-d')));
         if (is_numeric($state->day_range)) {
             $query->where('DATE(tbl.created_on) <= :range_start')->bind(array('range_start' => $start_date->modify(sprintf('+%d days', $state->day_range))->format('Y-m-d')));
         }
     }
     if ($state->end_date && $state->end_date != '0000-00-00') {
         $end_date = $this->getObject('lib:date', array('date' => $state->end_date));
         $query->where('DATE(tbl.created_on) <= :end')->bind(array('end' => $end_date->format('Y-m-d')));
         if (is_numeric($state->day_range)) {
             $query->where('DATE(tbl.created_on) >= :range_end')->bind(array('range_end' => $end_date->modify(sprintf('-%d days', $state->day_range))->format('Y-m-d')));
         }
     }
     if (is_numeric($state->user)) {
         $query->where('tbl.created_by = :created_by')->bind(array('created_by' => $state->user));
     }
     if ($ip = $state->ip) {
         $query->where('tbl.ip IN (:ip)')->bind(array('ip' => $state->ip));
     }
 }
Example #12
0
 protected function _buildQueryWhere(KDatabaseQueryInterface $query)
 {
     parent::_buildQueryWhere($query);
     $state = $this->getState();
     if ($uuid = $state->uuid) {
         $query->where('tbl.uuid = :uuid')->bind(array('uuid' => $uuid));
     }
     if ($package = $state->package) {
         $query->where('tbl.package = :package')->bind(array('package' => $package));
     }
     if ($name = $state->name) {
         $query->where('tbl.name = :name')->bind(array('name' => $name));
     }
     if ($resource_id = $state->resource_id) {
         $query->where('tbl.resource_id = :resource_id')->bind(array('resource_id' => $resource_id));
     }
     if ($title = $state->title) {
         $query->where('tbl.title LIKE :title')->bind(array('title' => '%' . $title . '%'));
     }
 }
Example #13
0
    /**
     * Get a list of items which represents a table rowset
     *
     * Overridden to add itemid to the returned results
     */
    protected function _actionFetch(KModelContext $context)
    {
        $result = parent::_actionFetch($context);

        if ($result && $this->getState()->page)
        {
            foreach ($result as $item) {
                $item->itemid = $this->findPage($item);
            }
        }

        return $result;
    }
Example #14
0
 protected function _initialize(KObjectConfig $config)
 {
     $config->append(array('behaviors' => array('searchable')));
     parent::_initialize($config);
 }
Example #15
0
 /**
  * Overridden for pushing the container value.
  */
 protected function _actionCreate(KModelContext $context)
 {
     $context->entity->append(array('container' => $context->state->container));
     return parent::_actionCreate($context);
 }
 public function __construct(KObjectConfig $config)
 {
     parent::__construct($config);
     $this->getState()->insert('stale', 'boolean', false)->insert('status', 'int')->insert('queue', 'int');
 }
Example #17
0
 protected function _initialize(KObjectConfig $config)
 {
     $config->append(array('table' => $this->getIdentifier()->name, 'behaviors' => array('searchable' => array('columns' => array('name', 'username', 'email')))));
     parent::_initialize($config);
 }