/** * Filter by status * * @access public * @param integer $is_active * @return TaskFilter */ public function filterByStatus($is_active) { if ($is_active >= 0) { $this->query->eq('is_active', $is_active); } return $this; }
/** * 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; }
/** * Filter by project id * * @access public * @param integer $project_id * @return ProjectUserRoleFilter */ public function filterByProjectId($project_id) { $this->query->eq(ProjectGroupRole::TABLE . '.project_id', $project_id); 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; }