original_string: protected function prepareQuery($query, $topics = false)
      {
          $field = $topics
                  ? Thread::tableName() . '.created_at'
                  : Post::tableName() . '.updated_at';
          if (!empty($this->author)) {
              $query->andWhere(['like', 'username', $this->author])->joinWith(['author']);
          }
          if (!empty($this->dateFromStamp) && empty($this->dateToStamp)) {
              $query->andWhere(['>=', $field, $this->dateFromStamp]);
          } elseif (!empty($this->dateToStamp) && empty($this->dateFromStamp)) {
              $this->dateToStamp += 23 * 3600 + 59 * 60 + 59; // 23:59:59
              $query->andWhere(['<=', $field, $this->dateToStamp]);
          } elseif (!empty($this->dateToStamp) && !empty($this->dateFromStamp)) {
              if ($this->dateFromStamp > $this->dateToStamp) {
                  $tmp = $this->dateToStamp;
                  $this->dateToStamp = $this->dateFromStamp;
                  $this->dateFromStamp = $tmp;
              }
              $this->dateToStamp += 23 * 3600 + 59 * 60 + 59; // 23:59:59
              $query->andWhere(['<=', $field, $this->dateToStamp]);
              $query->andWhere(['>=', $field, $this->dateFromStamp]);
          }
          if (!empty($this->forums)) {
              if (is_array($this->forums)) {
                  $forums = [];
                  foreach ($this->forums as $f) {
                      if (is_numeric($f)) {
                          $forums[] = (int)$f;
                      }
                  }
                  if (!empty($forums)) {
                      $query->andWhere(['forum_id' => $forums]);
                  }
              }
          }
      }
code: protected function prepareQuery($query, $topics = false)
      {
          $field = $topics
                  ? Thread::tableName() . '.created_at'
                  : Post::tableName() . '.updated_at';
          if (!empty($this->author)) {
              $query->andWhere(['like', 'username', $this->author])->joinWith(['author']);
          }
          if (!empty($this->dateFromStamp) && empty($this->dateToStamp)) {
              $query->andWhere(['>=', $field, $this->dateFromStamp]);
          } elseif (!empty($this->dateToStamp) && empty($this->dateFromStamp)) {
              $this->dateToStamp += 23 * 3600 + 59 * 60 + 59; // 23:59:59
              $query->andWhere(['<=', $field, $this->dateToStamp]);
          } elseif (!empty($this->dateToStamp) && !empty($this->dateFromStamp)) {
              if ($this->dateFromStamp > $this->dateToStamp) {
                  $tmp = $this->dateToStamp;
                  $this->dateToStamp = $this->dateFromStamp;
                  $this->dateFromStamp = $tmp;
              }
              $this->dateToStamp += 23 * 3600 + 59 * 60 + 59; // 23:59:59
              $query->andWhere(['<=', $field, $this->dateToStamp]);
              $query->andWhere(['>=', $field, $this->dateFromStamp]);
          }
          if (!empty($this->forums)) {
              if (is_array($this->forums)) {
                  $forums = [];
                  foreach ($this->forums as $f) {
                      if (is_numeric($f)) {
                          $forums[] = (int)$f;
                      }
                  }
                  if (!empty($forums)) {
                      $query->andWhere(['forum_id' => $forums]);
                  }
              }
          }
      }
code_tokens: protected function prepareQuery ( $ query , $ topics = false ) { $ field = $ topics ? Thread :: tableName ( ) . '.created_at' : Post :: tableName ( ) . '.updated_at' ; if ( ! empty ( $ this -> author ) ) { $ query -> andWhere ( [ 'like' , 'username' , $ this -> author ] ) -> joinWith ( [ 'author' ] ) ; } if ( ! empty ( $ this -> dateFromStamp ) && empty ( $ this -> dateToStamp ) ) { $ query -> andWhere ( [ '>=' , $ field , $ this -> dateFromStamp ] ) ; } elseif ( ! empty ( $ this -> dateToStamp ) && empty ( $ this -> dateFromStamp ) ) { $ this -> dateToStamp += 23 * 3600 + 59 * 60 + 59 ; // 23:59:59 $ query -> andWhere ( [ '<=' , $ field , $ this -> dateToStamp ] ) ; } elseif ( ! empty ( $ this -> dateToStamp ) && ! empty ( $ this -> dateFromStamp ) ) { if ( $ this -> dateFromStamp > $ this -> dateToStamp ) { $ tmp = $ this -> dateToStamp ; $ this -> dateToStamp = $ this -> dateFromStamp ; $ this -> dateFromStamp = $ tmp ; } $ this -> dateToStamp += 23 * 3600 + 59 * 60 + 59 ; // 23:59:59 $ query -> andWhere ( [ '<=' , $ field , $ this -> dateToStamp ] ) ; $ query -> andWhere ( [ '>=' , $ field , $ this -> dateFromStamp ] ) ; } if ( ! empty ( $ this -> forums ) ) { if ( is_array ( $ this -> forums ) ) { $ forums = [ ] ; foreach ( $ this -> forums as $ f ) { if ( is_numeric ( $ f ) ) { $ forums [ ] = ( int ) $ f ; } } if ( ! empty ( $ forums ) ) { $ query -> andWhere ( [ 'forum_id' => $ forums ] ) ; } } } }
docstring: Prepares query conditions.
  @param ActiveQuery $query
  @param bool $topics
  @since 0.6
docstring_tokens: Prepares query conditions .