@@ -86,6 +86,9 @@ public function list_records($cols=null, $subset=0) {
8686
8787 while ($ ret = $ db ->fetch_assoc ()) {
8888 $ ret ['email ' ] = explode (', ' , $ ret ['email ' ]);
89+ //$names = explode(' ', $ret['name']);
90+ //$ret['surname'] = array_push($names);
91+ //$ret['firsname']= implode(' ', $names);
8992 $ this ->result ->add ($ ret );
9093 }
9194 return $ this ->result ;
@@ -101,13 +104,13 @@ function list_groups($search = null, $mode=0) {
101104 if ($ search ) {
102105 switch (intval ($ mode )) {
103106 case 1 :
104- $ x = $ rc ->db ->ilike ('name ' , $ search );
107+ $ x = $ rc ->db ->ilike ('domain ' , $ search );
105108 break ;
106109 case 2 :
107- $ x = $ rc ->db ->ilike ('name ' , $ search . '% ' );
110+ $ x = $ rc ->db ->ilike ('domain ' , $ search . '% ' );
108111 break ;
109112 default :
110- $ x = $ rc ->db ->ilike ('name ' , '% ' . $ search . '% ' );
113+ $ x = $ rc ->db ->ilike ('domain ' , '% ' . $ search . '% ' );
111114 }
112115 $ x = ' WHERE ' . $ x . ' ' ;
113116 } else { $ x = ' ' ; }
@@ -138,7 +141,7 @@ public function search($fields, $value, $strict=false, $select=true, $nocount=fa
138141 foreach ($ fields as $ idx => $ col ) {
139142
140143 if ($ col == 'ID ' || $ col == $ this ->primary_key ) {
141- $ ids = !is_array ($ value ) ? explode (self :: SEPARATOR , $ value ) : $ value ;
144+ $ ids = !is_array ($ value ) ? explode (' , ' , $ value ) : $ value ;
142145 $ ids = $ db ->array2list ($ ids , 'integer ' );
143146 $ where [] = 'c. ' . $ this ->primary_key .' IN ( ' .$ ids .') ' ;
144147 continue ;
@@ -147,23 +150,30 @@ public function search($fields, $value, $strict=false, $select=true, $nocount=fa
147150 foreach (explode ($ WS , rcube_utils::normalize_string ($ value )) as $ word ) {
148151 switch ($ mode ) {
149152 case 1 : // Strict
150- $ words [] = '( ' . $ db ->ilike ('words ' , $ word . '% ' )
151- . ' OR ' . $ db ->ilike ('words ' , '% ' . $ WS . $ word . $ WS . '% ' )
152- . ' OR ' . $ db ->ilike ('words ' , '% ' . $ WS . $ word ) . ') ' ;
153+ $ words []='( ' . $ db ->ilike ('name ' , $ word . '% ' )
154+ . ' OR ' . $ db ->ilike ('email ' ,$ word . '% ' )
155+ . ' OR ' . $ db ->ilike ('name ' , '% ' . $ WS . $ word . $ WS . '% ' )
156+ . ' OR ' . $ db ->ilike ('email ' ,'% ' . $ WS . $ word . $ WS . '% ' )
157+ . ' OR ' . $ db ->ilike ('name ' , '% ' . $ WS . $ word )
158+ . ' OR ' . $ db ->ilike ('email ' ,'% ' . $ WS . $ word ). ') ' ;
153159 break ;
154160
155161 case 2 : // Prefix
156- $ words [] = '( ' . $ db ->ilike ('words ' , $ word . '% ' )
157- . ' OR ' . $ db ->ilike ('words ' , '% ' . $ WS . $ word . '% ' ) . ') ' ;
162+ $ words []='( ' . $ db ->ilike ('name ' , $ word . '% ' )
163+ . ' OR ' . $ db ->ilike ('email ' ,$ word . '% ' )
164+ . ' OR ' . $ db ->ilike ('name ' , '% ' . $ WS . $ word . '% ' )
165+ . ' OR ' . $ db ->ilike ('email ' ,'% ' . $ WS . $ word . '% ' ) . ') ' ;
158166 break ;
159167
160168 default : // Partial
161- $ words [] = $ db ->ilike ('words ' , '% ' . $ word . '% ' );
169+ $ words []='( ' . $ db ->ilike ('name ' , '% ' . $ word . '% ' )
170+ . ' OR ' . $ db ->ilike ('email ' ,'% ' . $ word . '% ' ) . ') ' ;
162171 break ;
163172 }
164173 }
165174 $ where [] = '( ' . join (' AND ' , $ words ) . ') ' ;
166- } else {
175+ //} else {
176+ } elseif ($ col !== 'firstname ' && $ col !== 'surname ' ) {
167177 $ val = is_array ($ value ) ? $ value [$ idx ] : $ value ;
168178
169179 switch ($ mode ) {
0 commit comments