/**
  * Modifies an element query targeting elements of this type.
  *
  * @param DbCommand            $query
  * @param ElementCriteriaModel $criteria
  *
  * @return mixed
  */
 public function modifyElementsQuery(DbCommand $query, ElementCriteriaModel $criteria)
 {
     // Default query
     $query->select('id, currentStep, totalSteps, status, type, description, settings, dateCreated')->from('tasks elements');
     // Reset default element type query parts
     $query->setJoin('');
     $query->setWhere('1=1');
     $query->setGroup('');
     unset($query->params[':locale']);
     unset($query->params[':elementsid1']);
     if ($criteria->type) {
         $query->andWhere(DbHelper::parseParam('type', $criteria->type, $query->params));
     }
     // Add search capabilities
     if ($criteria->search) {
         $query->andWhere(DbHelper::parseParam('description', '*' . $criteria->search . '*', $query->params));
         $criteria->search = null;
     }
 }
 /**
  * Modify the elements query.
  *
  * @param DbCommand            $query
  * @param ElementCriteriaModel $criteria
  */
 public function modifyElementsQuery(DbCommand $query, ElementCriteriaModel $criteria)
 {
     // Default query
     $query->select('auditlog.id, auditlog.type, auditlog.userId, auditlog.origin, auditlog.before, auditlog.after, auditlog.status, auditlog.dateCreated, auditlog.dateUpdated')->from('auditlog auditlog');
     // Reset default element type query parts
     $query->setJoin('');
     $query->setWhere('1=1');
     $query->setGroup('');
     unset($query->params[':locale']);
     unset($query->params[':elementsid1']);
     // Check for specific id
     if (!empty($criteria->id)) {
         $query->andWhere(DbHelper::parseParam('auditlog.id', $criteria->id, $query->params));
     }
     // Check type
     if (!empty($criteria->type)) {
         $query->andWhere(DbHelper::parseParam('auditlog.type', $criteria->type, $query->params));
     }
     // Check user id
     if (!empty($criteria->userId)) {
         $query->andWhere(DbHelper::parseParam('auditlog.userId', $criteria->userId, $query->params));
     }
     // Check origin
     if (!empty($criteria->origin)) {
         $query->andWhere(DbHelper::parseParam('auditlog.origin', $criteria->origin, $query->params));
     }
     // Check before
     if (!empty($criteria->before)) {
         $query->andWhere(DbHelper::parseParam('auditlog.before', $criteria->before, $query->params));
     }
     // Check after
     if (!empty($criteria->after)) {
         $query->andWhere(DbHelper::parseParam('auditlog.after', $criteria->after, $query->params));
     }
     // Check for status
     if (!empty($criteria->status)) {
         $query->andWhere(DbHelper::parseParam('auditlog.status', $criteria->status, $query->params));
     }
     // Dates
     $this->applyDateCriteria($criteria, $query);
     // Search
     $this->applySearchCriteria($criteria, $query);
 }
Пример #3
0
 /**
  * Cancel the elements query.
  *
  * @param DbCommand            $query
  * @param ElementCriteriaModel $criteria
  *
  * @return bool
  */
 public function modifyElementsQuery(DbCommand $query, ElementCriteriaModel $criteria)
 {
     // Default query
     $query->select('auditlog.id, auditlog.type, auditlog.userId, auditlog.origin, auditlog.before, auditlog.after, auditlog.status, auditlog.dateCreated, auditlog.dateUpdated')->from('auditlog auditlog');
     // Reset default element type query parts
     $query->setJoin('');
     $query->setWhere('1=1');
     $query->setGroup('');
     unset($query->params[':locale']);
     unset($query->params[':elementsid1']);
     // Check for specific id
     if (!empty($criteria->id)) {
         $query->andWhere(DbHelper::parseParam('auditlog.id', $criteria->id, $query->params));
     }
     // Check type
     if (!empty($criteria->type)) {
         $query->andWhere(DbHelper::parseParam('auditlog.type', $criteria->type, $query->params));
     }
     // Check user id
     if (!empty($criteria->userId)) {
         $query->andWhere(DbHelper::parseParam('auditlog.userId', $criteria->userId, $query->params));
     }
     // Check origin
     if (!empty($criteria->origin)) {
         $query->andWhere(DbHelper::parseParam('auditlog.origin', $criteria->origin, $query->params));
     }
     // Check for date modified
     if (!empty($criteria->modified)) {
         $query->andWhere(DbHelper::parseDateParam('auditlog.dateUpdated', $criteria->modified, $query->params));
     }
     // Check before
     if (!empty($criteria->before)) {
         $query->andWhere(DbHelper::parseParam('auditlog.before', $criteria->before, $query->params));
     }
     // Check after
     if (!empty($criteria->after)) {
         $query->andWhere(DbHelper::parseParam('auditlog.after', $criteria->after, $query->params));
     }
     // Check for date from
     if (!empty($criteria->from)) {
         $query->andWhere(DbHelper::parseDateParam('auditlog.dateUpdated', '>= ' . DateTimeHelper::formatTimeForDb($criteria->from), $query->params));
     }
     // Check for date to
     if (!empty($criteria->to)) {
         $criteria->to->add(new DateInterval('PT23H59M59S'));
         $query->andWhere(DbHelper::parseDateParam('auditlog.dateUpdated', '<= ' . DateTimeHelper::formatTimeForDb($criteria->to), $query->params));
     }
     // Check for type
     if (!empty($criteria->type)) {
         $query->andWhere(DbHelper::parseParam('auditlog.type', $criteria->type, $query->params));
     }
     // Check for status
     if (!empty($criteria->status)) {
         $query->andWhere(DbHelper::parseParam('auditlog.status', $criteria->status, $query->params));
     }
     // Search
     if (!empty($criteria->search)) {
         // Always perform a LIKE search
         $criteria->search = '*' . $criteria->search . '*';
         // Build conditions
         $conditions = array('or', DbHelper::parseParam('auditlog.origin', $criteria->search, $query->params), DbHelper::parseParam('auditlog.before', $criteria->search, $query->params), DbHelper::parseParam('auditlog.after', $criteria->search, $query->params));
         // Add to query
         $query->andWhere($conditions, $query->params);
         // Don't perform search logics after this
         $criteria->search = null;
     }
 }