Example #1
0
 /**
  * Generate the where clause.
  *
  * @return string The ready to use where clause.
  */
 function filter()
 {
     if (strlen($this->where_clause) > 0) {
         return $this->where_clause;
     }
     if (!is_null($this->forced_where) or strlen($this->search_string) > 0 && !empty($this->search_fields)) {
         $lastsql = new Pluf_SQL();
         $keywords = $lastsql->keywords($this->search_string);
         foreach ($keywords as $key) {
             $sql = new Pluf_SQL();
             foreach ($this->search_fields as $field) {
                 $sqlor = new Pluf_SQL();
                 $sqlor->Q($field . ' LIKE %s', '%' . $key . '%');
                 $sql->SOr($sqlor);
             }
             $lastsql->SAnd($sql);
         }
         if (!is_null($this->forced_where)) {
             $lastsql->SAnd($this->forced_where);
         }
         $this->where_clause = $lastsql->gen();
         if (strlen($this->where_clause) == 0) {
             $this->where_clause = null;
         }
     }
     return $this->where_clause;
 }
Example #2
0
 /**
  * Returns the number of open/closed issues.
  *
  * @param string Status ('open'), 'closed'
  * @param IDF_Tag Subfilter with a label (null)
  * @return int Count
  */
 public function getIssueCountByStatus($status = 'open', $label = null)
 {
     switch ($status) {
         case 'open':
             $key = 'labels_issue_open';
             $default = IDF_Form_IssueTrackingConf::init_open;
             break;
         case 'closed':
         default:
             $key = 'labels_issue_closed';
             $default = IDF_Form_IssueTrackingConf::init_closed;
             break;
     }
     $tags = array();
     foreach ($this->getTagsFromConfig($key, $default, 'Status') as $tag) {
         $tags[] = (int) $tag->id;
     }
     if (count($tags) == 0) {
         return array();
     }
     $sql = new Pluf_SQL(sprintf('project=%%s AND status IN (%s)', implode(', ', $tags)), array($this->id));
     if (!is_null($label)) {
         $sql2 = new Pluf_SQL('idf_tag_id=%s', array($label->id));
         $sql->SAnd($sql2);
     }
     $params = array('filter' => $sql->gen());
     if (!is_null($label)) {
         $params['view'] = 'join_tags';
     }
     $gissue = new IDF_Issue();
     return $gissue->getCount($params);
 }