예제 #1
0
 /**
  * Apply condition
  *
  * @access public
  * @return CriteriaInterface
  */
 public function apply()
 {
     $this->query->beginOr();
     foreach ($this->filters as $filter) {
         $filter->withQuery($this->query)->apply();
     }
     $this->query->closeOr();
     return $this;
 }
예제 #2
0
 /**
  * Execute a PicoDb query
  *
  * @access public
  * @return array
  */
 public function executeQuery()
 {
     if ($this->query !== null) {
         return $this->query->offset($this->offset)->limit($this->limit)->orderBy($this->order, $this->direction)->findAll();
     }
     return array();
 }
예제 #3
0
 /**
  * Use the board_highlight_period for the "recently" keyword
  *
  * @access private
  * @param  string    $field
  * @return TaskFilter
  */
 private function filterRecentlyDate($field)
 {
     $duration = $this->config->get('board_highlight_period', 0);
     if ($duration > 0) {
         $this->query->gte($field, time() - $duration);
     }
     return $this;
 }
예제 #4
0
 /**
  * Filter with an operator
  *
  * @access public
  * @param  string    $field
  * @param  string    $value
  * @param  boolean   $is_date
  * @return TaskFilter
  */
 private function filterWithOperator($field, $value, $is_date)
 {
     $operators = array('<=' => 'lte', '>=' => 'gte', '<' => 'lt', '>' => 'gt');
     foreach ($operators as $operator => $method) {
         if (strpos($value, $operator) === 0) {
             $value = substr($value, strlen($operator));
             $this->query->{$method}($field, $is_date ? $this->dateParser->getTimestampFromIsoFormat($value) : $value);
             return $this;
         }
     }
     $this->query->eq($field, $is_date ? $this->dateParser->getTimestampFromIsoFormat($value) : $value);
     return $this;
 }
예제 #5
0
 /**
  * Transform results to all day ical events
  *
  * @access public
  * @param  string                             $column        Column name for the date
  * @param  Eluceo\iCal\Component\Calendar     $vCalendar     Calendar object
  * @return Eluceo\iCal\Component\Calendar
  */
 public function addAllDayIcalEvents($column = 'date_due', Calendar $vCalendar = null)
 {
     if ($vCalendar === null) {
         $vCalendar = new Calendar('Kanboard');
     }
     foreach ($this->query->findAll() as $task) {
         $date = new DateTime();
         $date->setTimestamp($task[$column]);
         $vEvent = $this->getTaskIcalEvent($task, 'task-#' . $task['id'] . '-' . $column);
         $vEvent->setDtStart($date);
         $vEvent->setDtEnd($date);
         $vEvent->setNoTime(true);
         $vCalendar->addComponent($vEvent);
     }
     return $vCalendar;
 }
예제 #6
0
 /**
  * Common function to return events
  *
  * @access public
  * @param  \PicoDb\Table   $query           PicoDb Query
  * @param  integer         $start           Timestamp of earliest activity
  * @param  integer         $end             Timestamp of latest activity
  * @return array
  */
 private function getEvents(\PicoDb\Table $query, $start, $end)
 {
     if (!is_null($start)) {
         $query->gte('date_creation', $start);
     }
     if (!is_null($end)) {
         $query->lte('date_creation', $end);
     }
     $events = $query->findAll();
     foreach ($events as &$event) {
         $event += $this->decode($event['data']);
         unset($event['data']);
         $event['author'] = $event['author_name'] ?: $event['author_username'];
         $event['event_title'] = $this->getTitle($event);
         $event['event_content'] = $this->getContent($event);
     }
     return $events;
 }
 /**
  * Filter by username
  *
  * @access public
  * @param  string $input
  * @return ProjectUserRoleFilter
  */
 public function startWithUsername($input)
 {
     $this->query->join(GroupMember::TABLE, 'group_id', 'group_id', ProjectGroupRole::TABLE)->join(User::TABLE, 'id', 'user_id', GroupMember::TABLE)->ilike(User::TABLE . '.username', $input . '%');
     return $this;
 }
예제 #8
0
 /**
  * Get the query result as array
  *
  * @access public
  * @return array
  */
 public function toArray()
 {
     return $this->query->findAll();
 }
 /**
  * Filter by username
  *
  * @access public
  * @param  string $input
  * @return ProjectUserRoleFilter
  */
 public function startWithUsername($input)
 {
     $this->query->join(User::TABLE, 'id', 'user_id')->ilike(User::TABLE . '.username', $input . '%');
     return $this;
 }
 /**
  * Apply subquery filter
  *
  * @access protected
  * @param  Table $subquery
  * @return Table
  */
 protected function applySubQueryFilter(Table $subquery)
 {
     if (is_int($this->value) || ctype_digit($this->value)) {
         $subquery->eq(Subtask::TABLE . '.user_id', $this->value);
     } else {
         switch ($this->value) {
             case 'me':
                 $subquery->eq(Subtask::TABLE . '.user_id', $this->currentUserId);
                 break;
             case 'nobody':
                 $subquery->eq(Subtask::TABLE . '.user_id', 0);
                 break;
             default:
                 $subquery->beginOr();
                 $subquery->ilike(User::TABLE . '.username', $this->value . '%');
                 $subquery->ilike(User::TABLE . '.name', '%' . $this->value . '%');
                 $subquery->closeOr();
         }
     }
     return $subquery;
 }
예제 #11
0
 /**
  * Lower than or equal condition with subquery
  *
  * @access public
  * @param  string   $column
  * @param  Table    $subquery
  */
 public function lteSubquery($column, Table $subquery)
 {
     $this->addCondition($this->db->escapeIdentifier($column) . ' <= (' . $subquery->buildSelectQuery() . ')');
     $this->values = array_merge($this->values, $subquery->getConditionBuilder()->getValues());
 }