Changeset 4538 for sandbox/2.2.0.2/contactcenter/inc
- Timestamp:
- 05/27/11 15:02:52 (13 years ago)
- Location:
- sandbox/2.2.0.2/contactcenter/inc
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/2.2.0.2/contactcenter/inc/class.abo_catalog.inc.php
r2 r4538 685 685 case 'LIKE': 686 686 case 'iLIKE': 687 case 'LIKE and ~=': 687 688 case 'NOT NULL': 688 689 case 'NOT IN': … … 726 727 $return_t[] = 'UPPER( '.$associative_tree[$restrict_data['field']]['table'].'.'. 727 728 $associative_tree[$restrict_data['field']]['field'].') LIKE UPPER(\''.$restrict_data['value'].'\')'; 729 break; 730 731 case 'LIKE and ~=': 732 $return_t[] = 'UPPER( '.$associative_tree[$restrict_data['field']]['table'].'.'. 733 $associative_tree[$restrict_data['field']]['field'].') LIKE UPPER(\''."%".$restrict_data['value']."%".'\')'; 728 734 break; 729 735 -
sandbox/2.2.0.2/contactcenter/inc/class.bo_global_ldap_catalog.inc.php
r4353 r4538 115 115 function find($what, $rules=false, $other=false, $area=false, $recursive=false) 116 116 { 117 $restric_fields = $this->get_restrictions_without_branch($rules); 118 119 $trans_f = $this->translate_fields($what, $restric_fields); 120 121 foreach($trans_f as $orig => $field_a) 122 { 123 foreach($field_a as $field) 124 { 125 $fields[] = $field; 126 } 127 } 128 129 $fields = array_unique($fields); 130 131 //Testa se a busca foi realizada com aspas 132 $rules_search = $rules[3]['value']; 133 $rules_len = (strlen($rules_search)) -1; 134 135 if((($rules_search{1}) == "\"") && (($rules_search{$rules_len -1}) == "\"")){ 136 $rules_search = substr($rules_search,2,$rules_len-3); 137 $filter = "(&(|(objectClass=phpgwAccount))(&(!(phpgwAccountVisible=-1)))(|(cn=* $rules_search *)(cn=$rules_search *)(cn=* $rules_search)))"; 138 } 139 else{ 140 $filter = $this->process_restrictions($rules, $trans_f); 141 } 142 143 if ($area) 144 { 145 $obj = CreateObject('phpgwapi.config','contactcenter'); 146 $opts = $obj->read_repository(); 147 $filter = substr($filter,0,-1) .'(' . $opts['cc_ldap_atrib'] . '=*' . $area . '*))'; 148 $opts = null; 149 $obj = null; 150 } 151 // Find objects where 'mail' attribute is not null. 152 $filter = "(&".$filter."(mail=*))"; 153 117 $find = ''; 118 if($rules) 119 { 120 foreach ($rules as $rule) 121 { 122 if($rule['field'] == 'contact.names_ordered' && $find === '') 123 $find .= $rule['value']; 124 else if($rule['field'] == 'contact.names_ordered') 125 $find .= ' '.$rule['value']; 126 } 127 } 128 129 if(!((strlen($find) == 2 && substr($find, -1) == '%') || $find == '%' )) 130 return $this->findAddress($find,$other); 131 132 $restric_fields = $this->get_restrictions_without_branch($rules); 133 134 $trans_f = $this->translate_fields($what, $restric_fields); 135 136 foreach($trans_f as $orig => $field_a) 137 { 138 foreach($field_a as $field) 139 { 140 $fields[] = $field; 141 } 142 } 143 144 $fields = array_unique($fields); 145 146 //Testa se a busca foi realizada com aspas 147 $rules_search = $rules[3]['value']; 148 $rules_len = (strlen($rules_search)) -1; 149 150 if((($rules_search{1}) == "\"") && (($rules_search{$rules_len -1}) == "\"")){ 151 $rules_search = substr($rules_search,2,$rules_len-3); 152 $filter = "(&(|(objectClass=phpgwAccount))(&(!(phpgwAccountVisible=-1)))(|(cn=* $rules_search *)(cn=$rules_search *)(cn=* $rules_search)))"; 153 } 154 else{ 155 $filter = $this->process_restrictions($rules, $trans_f); 156 } 157 158 // Find objects where 'mail' attribute is not null. 159 $filter = "(&".$filter."(mail=*))"; 154 160 $ldap = $GLOBALS['phpgw']->common->ldapConnect($this->src_info['host'], $this->src_info['acc'], $this->src_info['pw'], true); 155 161 $result_r = $recursive ? ldap_search($ldap , $this->src_info['context'], $filter, $fields, 0, $this->src_info['max_results']) : 156 157 158 if (!$result_r)162 ldap_list($ldap , $this->src_info['context'], $filter, $fields, 0, $this->src_info['max_results']); 163 164 if (!$result_r) 159 165 { 160 166 return false; 161 167 } 162 163 164 165 166 167 } 168 169 170 168 169 if ($other['order']) 170 { 171 $sort_f = array($other['order']); 172 $ldap_sort_by = $this->translate_fields($sort_f, $restric_fields); 173 } 174 175 if ($ldap_sort_by) 176 { 171 177 if (!ldap_sort($ldap, $result_r, $ldap_sort_by[$other['order']][0])) 172 178 { 173 return false; 174 } 175 } 176 177 $result_u = ldap_get_entries($ldap, $result_r); 178 // No entries found. 179 if(!$result_u) 180 return true; 181 182 $i = 0; 183 foreach ($result_u as $index => $result_p) 184 { 185 if ($index === 'count' or $index === 'dn' or (!$this->external and $result_p['phpgwaccountvisible'][0] == '-1')) 186 { 187 continue; 188 } 189 190 foreach ($trans_f as $orig => $trans) 191 { 192 $orig = substr($orig, strrpos($orig, '.')+1, strlen($orig)); 193 foreach ($trans as $f) 194 { 195 if ($f === 'dn') 196 { 197 $return[$i][$orig] = $result_p['dn']; 198 } 199 else if ($result_p[$f][0]) 200 { 201 $return[$i][$orig] = $result_p[$f][0]; 202 } 203 } 204 } 205 $i++; 206 } 207 if($return) 208 usort($return, array($this, "compareObjects")); 209 return $return; 210 } 179 return false; 180 } 181 } 182 183 $iTotalEntries = ldap_count_entries( $ldap, $result_r ); 184 185 if($iTotalEntries < 1 ) 186 return true; 187 188 $iEnd = $iTotalEntries; 189 190 $return = array(); 191 192 $rEntry = ldap_first_entry( $ldap, $result_r ); 193 for ( $iCurrent = 0; $iCurrent < $iEnd ;$iCurrent++) 194 { 195 196 $result_p = ldap_get_attributes($ldap, $rEntry ); 197 198 if(!$this->external and $result_p['phpgwaccountvisible'][0] == '-1'){ 199 continue; 200 } 201 202 $returnTemp = array(); 203 $returnTemp['id_contact'] = ldap_get_dn($ldap, $rEntry); 204 $returnTemp['names_ordered'] = $result_p['cn']['0']; 205 206 array_push( $return, $returnTemp ); 207 $rEntry = ldap_next_entry( $ldap, $rEntry ); 208 209 } 210 211 212 usort($return, array($this, "compareObjects")); 213 return $return; 214 } 215 216 function findAddress($find, $other=false) 217 { 218 219 require_once $_SESSION['rootPath'].'/API/class.servicelocator.php'; 220 $ldapService = ServiceLocator::getService('ldap'); 221 $filter = $ldapService->getSearchFilter($find); 222 $fields = array('cn','dn'); 223 $ldap = $GLOBALS['phpgw']->common->ldapConnect($this->src_info['host'], $this->src_info['acc'], $this->src_info['pw'], true); 224 $result_r = ldap_search($ldap , $this->src_info['context'], $filter, $fields); 225 226 227 if (!$result_r) 228 { 229 return false; 230 } 231 232 if ($other['order']) 233 { 234 $sort_f = array($other['order']); 235 $ldap_sort_by = $this->translate_fields($sort_f, $restric_fields); 236 } 237 238 if ($ldap_sort_by) 239 { 240 if (!ldap_sort($ldap, $result_r, $ldap_sort_by[$other['order']][0])) 241 { 242 return false; 243 } 244 } 245 246 $iTotalEntries = ldap_count_entries( $ldap, $result_r ); 247 248 if($iTotalEntries < 1 ) 249 return true; 250 251 $iEnd = $iTotalEntries; 252 253 $return = array(); 254 255 $rEntry = ldap_first_entry( $ldap, $result_r ); 256 for ( $iCurrent = 0; $iCurrent < $iEnd ;$iCurrent++) 257 { 258 259 $result_p = ldap_get_attributes($ldap, $rEntry ); 260 261 $returnTemp = array(); 262 $returnTemp['id_contact'] = ldap_get_dn($ldap, $rEntry); 263 $returnTemp['names_ordered'] = $result_p['cn']['0']; 264 265 array_push( $return, $returnTemp ); 266 $rEntry = ldap_next_entry( $ldap, $rEntry ); 267 268 } 269 270 271 usort($return, array($this, "compareObjects")); 272 return $return; 273 } 274 211 275 // Compare function for usort. 212 276 function compareObjects($a, $b) { -
sandbox/2.2.0.2/contactcenter/inc/class.bo_ldap_manager.inc.php
r4500 r4538 57 57 'branch' => $ou, //strtolower('ou'), 58 58 'montaDN'=> $subLevels, //$data['cc_ldap_subLevels'], 59 'visible'=> $data['cc_ldap_query_automatic'] 59 'visible'=> $data['cc_ldap_query_automatic'], 60 'max_results' => $data['cc_ldap_max_results'] 60 61 ) 61 62 ); … … 93 94 /* 94 95 * @function get_external_ldap_sources 95 * @author M ï¿œrio Cï¿œsar Kolling <mario.kolling@serpro.gov.br>96 * @author Mário César Kolling <mario.kolling@serpro.gov.br> 96 97 * @abstract returns an array with the external sources 97 98 * @return (array) the external sources -
sandbox/2.2.0.2/contactcenter/inc/class.ui_data.inc.php
r4513 r4538 3172 3172 if (!is_array($data) || (!$data['search_for'] && !$full_search) || !is_array($data['fields'])) 3173 3173 { 3174 3175 3176 3177 3178 3179 3174 echo serialize(array( 3175 'msg' => lang('Invalid parameters'), 3176 'status' => 'abort' 3177 )); 3178 3179 return array('error' => lang('Invalid parameters')); 3180 3180 } 3181 3181 … … 3211 3211 else 3212 3212 { 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3213 $names = explode(' ', $data['search_for']); 3214 3215 if (!is_array($names)) 3216 { 3217 if(!$full_search) { 3218 echo serialize(array( 3219 'msg' => lang('Invalid Search Parameter'), 3220 'status' => 'abort' 3221 )); 3222 exit; 3223 } 3224 else 3225 $names = array(); 3226 3227 } 3228 3228 3229 3229 if (!$external && $this->page_info['actual_catalog']['class'] != 'bo_people_catalog' && … … 3287 3287 array_push($rules,array( 3288 3288 'field' => $this->aux_full_search($field,false), 3289 'type' => 'iLIKE',3290 'value' => '%'.$value.'%'3289 'type' => 'LIKE and ~=', 3290 'value' => $name 3291 3291 )); 3292 }3292 } 3293 3293 3294 3294 } … … 3300 3300 array_push($rules, array( 3301 3301 'field' => $data['fields']['search'], 3302 'type' => ' iLIKE',3303 'value' => '%'.$name.'%'3302 'type' => 'LIKE and ~=', 3303 'value' => $name 3304 3304 )); 3305 3305 }
Note: See TracChangeset
for help on using the changeset viewer.