+
+ public function getIDs($text, $mode, $subid = null)
+ {
+ if ($mode == XDB::WILDCARD_EXACT) {
+ $options = $this->getOptions($subid);
+ return array_keys($options, $text);
+ } else {
+ if ($this->where == null) {
+ $where = 'WHERE ';
+ } else {
+ $where = $this->where . ' AND ';
+ }
+ if ($subid != null && array_key_exists($subid, $this->suboptions)) {
+ $where .= XDB::format($this->optfield . ' = {?} AND ', $subid);
+ }
+
+ $conds = array();
+ $conds[] = $this->valfield . XDB::formatWildcards($mode, $text);
+ if ($this->valfield2 != null) {
+ $conds[] = $this->valfield2 . XDB::formatWildcards($mode, $text);
+ }
+ $where .= '(' . implode(' OR ', $conds) . ')';
+
+ return XDB::fetchColumn('SELECT ' . $this->idfield . '
+ FROM ' . $this->from . '
+ ' . $this->join . '
+ ' . $where . '
+ GROUP BY ' . $this->idfield);
+ }
+ }
+
+ public function getAutoComplete($text, $subid = null)
+ {
+ $text = str_replace(array('%', '_'), '', $text);
+
+ if (is_null($this->ac_where) || $this->ac_where == '') {
+ $where = '';
+ } else {
+ $where = $this->ac_where . ' AND ';
+ }
+
+ if ($subid != null && array_key_exists($subid, $this->suboptions)) {
+ $where .= XDB::format($this->optfield . ' = {?} AND ', $subid);
+ }
+
+ $tests = $this->mkTests($this->valfield, $text);
+ if (!is_null($this->valfield2)) {
+ $tests = array_merge($tests, $this->mkTests($this->valfield2, $text));
+ }
+
+ $where .= '(' . implode(' OR ', $tests) . ')';
+
+ return XDB::iterator('SELECT ' . $this->valfield . ' AS field'
+ . ($this->ac_distinct ? (', COUNT(DISTINCT ' . $this->ac_unique . ') AS nb') : '')
+ . ($this->ac_withid ? (', ' . $this->idfield . ' AS id') : '') . '
+ FROM ' . $this->from . '
+ ' . $this->ac_join . '
+ WHERE ' . $where . '
+ GROUP BY ' . $this->valfield . '
+ ORDER BY ' . ($this->ac_distinct ? 'nb DESC' : $this->valfield) . '
+ LIMIT ' . self::AUTOCOMPLETE_LIMIT);
+ }
+}
+// }}}
+
+// {{{ class DE_NameTypes
+// returns 'system' names ('lastname', 'lastname_marital', ...)
+class DE_NameTypes extends DirEnumeration
+{
+ public $capabilities = self::HAS_OPTIONS;
+
+ protected $from = 'profile_name_enum';
+ protected $valfield = 'type';