Ejemplo n.º 1
0
 function _searchResults()
 {
     global $AppUI, $locale_char_set;
     $q = new DBQuery();
     $dPObj = new CDpObject($this->table, $this->table_key);
     $q->addTable($this->table, $this->table_alias);
     foreach ($this->table_joins as $join) {
         $q->addJoin($join['table'], $join['alias'], $join['join']);
     }
     $q->addQuery($this->table_key);
     if (isset($this->table_key2)) {
         $q->addQuery($this->table_key2);
     }
     foreach ($this->display_fields as $fld) {
         $q->addQuery($fld);
     }
     $q->addOrder($this->table_orderby);
     $dPObj->setAllowedSQL($AppUI->user_id, $q, null, null, $this->table_module);
     if ($this->table_extra) {
         $q->addWhere($this->table_extra);
     }
     $keys = '';
     $keys2 = '';
     foreach (array_keys($this->keywords) as $keyword) {
         if ($keys2) {
             $keys .= $this->search_options['all_words'] == 'on' ? ' AND ' : ' OR ';
             $keys2 = '';
         }
         foreach ($this->search_fields as $field) {
             // OR treatment to each keyword
             // Search for semi-colons, commas or spaces and allow any to be separators
             $or_keywords = preg_split('/[\\s,;]+/', $keyword);
             foreach ($or_keywords as $or_keyword) {
                 $search_pattern = $this->search_options['ignore_specchar'] == 'on' ? recode2regexp_utf8($or_keyword) : '(' . $or_keyword . ')';
                 $keys2 .= $keys2 ? ' OR ' : '';
                 $keys2 .= '(' . $field . ' REGEXP ' . ($this->search_options['ignore_case'] == 'on' ? '' : ' BINARY ') . "'.*" . $search_pattern . ".*'" . ($this->search_options['ignore_specchar'] == 'on' ? ' COLLATE utf8_general_ci' : '') . ')';
             }
         }
         $keys .= $keys2 ? '(' . $keys2 . ')' : '';
     }
     if ($keys) {
         $q->addWhere($keys);
     }
     $results = $q->loadList();
     return $results;
 }
Ejemplo n.º 2
0
 function setAllowedSQL($uid, &$query, $index = null, $key = null)
 {
     $oCpy = new CCompany();
     parent::setAllowedSQL($uid, $query, $index, $key);
     $oCpy->setAllowedSQL($uid, $query, ($key ? $key . '.' : '') . 'project_company');
 }
 function setAllowedSQL($uid, &$query, $index = null)
 {
     $oCpy = new CCompany();
     parent::setAllowedSQL($uid, $query, $index);
     $oCpy->setAllowedSQL($uid, $query, "project_company");
 }