- Timestamp:
- 09/20/10 18:23:03 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2/jabberit_messenger/inc/class.contacts_im.inc.php
r3102 r3266 74 74 $order = array(); 75 75 $ou_User = substr($this->ou_User, (strpos($this->ou_User,"=")+1)); 76 $return = '<empty/>';76 $return = ""; 77 77 $users = $this->getUsersIm($param['name']); 78 78 79 80 if (!is_array($users) && trim($users) === 'Many Results') 81 return "<error>Many Results</error>"; 82 79 if( count($users) == 0 ) 80 return "<empty></empty>"; 81 82 if( $users === "manyresults" ) 83 { 84 if( isset($_SESSION['phpgw_info']['jabberit_messenger']['photo']) ) 85 unset($_SESSION['phpgw_info']['jabberit_messenger']['photo']); 86 87 return "<manyresults></manyresults>"; 88 } 89 83 90 // Hosts Jabber 84 91 $hostsJabber = unserialize($_SESSION['phpgw_info']['jabberit_messenger']['map_org_realm_jabberit']); … … 130 137 131 138 private final function getUsersIm($pName) 132 { 139 { 133 140 $array_uids = array(); 141 $countUids = 0; 134 142 $members = array(); 135 143 $result = array(); 136 144 $uidType = "uid"; 137 $serversLdap = unserialize(trim($_SESSION['phpgw_info']['jabberit_messenger']['groups_search'])); 138 139 if( $serversLdap ) 140 { 141 if( array_key_exists($this->serverLdap, $serversLdap) ) 142 { 143 $groups = unserialize($serversLdap[$this->serverLdap]); 144 } 145 146 if( count($groups) > 0 ) 147 { 148 foreach($groups as $tmp) 149 { 150 $group = explode(":",$tmp); 151 $array_result = $this->ldap->getGroupsMemberUid($group[0], $this->serverLdap ); 152 @array_shift($array_result[0]['memberuid']); 153 $array_uids = @array_merge($array_uids, $array_result[0]['memberuid']); 154 unset($array_result); 155 } 156 } 157 } 158 159 if( count($array_uids) == 0 ) 160 { 161 $array_uids = $this->db->get_accounts_acl(); 162 $uidType = "uidnumber"; 163 } 164 165 for( $i = 0; $i < count($array_uids) ; $i+=50 ) 166 { 167 $partial_uids = array_slice($array_uids,$i,50); 168 $filter_uid = implode(")(".$uidType."=",$partial_uids); 169 $filter_uid = "(".$uidType."=". $filter_uid. ")"; 170 171 if( $this->groupsLocked() ) 172 { 173 $orgs[] = $this->ou_User; 174 $orgsGroupsLocked = explode(",", $_SESSION['phpgw_info']['jabberit_messenger']['organizationsGroupsLocked']); 175 176 foreach( $orgsGroupsLocked as $tmp ) 177 { 178 if( $tmp != "" ) 179 { 180 if( strpos($tmp, "/") !== false ) 181 { 182 $tt = explode("/", $tmp); 183 $newOU = implode(",OU=",array_reverse($tt)); 184 $orgs[] = "OU=". $newOU ; 185 } 186 else 187 $orgs[] = "OU=". $tmp; 188 } 189 } 190 191 $orgs = array_unique($orgs); 192 193 foreach( $orgs as $orgB ) 194 $result[] = $this->ldap->getUsersLdapRoot("cn=*".$pName."*", $filter_uid, $orgB ); 195 196 } 197 else 198 $result[] = $this->ldap->getUsersLdapRoot("cn=*".$pName."*", $filter_uid); 199 } 200 201 if( !$this->groupsLocked() ) 202 { 203 unset($serversLdap[$this->serverLdap]); 204 205 if( $serversLdap && count($serversLdap)) 206 { 207 foreach( $serversLdap as $key => $tmp ) 208 { 209 $array_uids_external = array( ); 210 $groupsExternal = unserialize($tmp); 211 212 if( count($groupsExternal) ) 213 { 214 foreach( $groupsExternal as $tmpExt ) 215 { 216 $group = explode(":",$tmpExt); 217 $array_result = $this->ldap->getGroupsMemberUid( $group[0], $key ); 218 219 if( $array_result[0]['memberuid']['count'] ) 220 unset($array_result[0]['memberuid']['count']); 221 222 $array_uids_external = @array_merge($array_uids_external, $array_result[0]['memberuid']); 223 } 224 225 226 if( is_array($array_uids_external) ) 227 { 228 for( $i = 0; $i < count( $array_uids_external ) ; $i+=50 ) 229 { 230 $partial_uids_external = array_slice($array_uids_external,$i,50); 231 $filter_uid_external = implode(")(uid=",$partial_uids_external); 232 $filter_uid_external = "(uid=". $filter_uid_external. ")"; 233 $result[] = $this->ldap->getUsersLdapCatalog("cn=*".$pName."*", $filter_uid_external, $key ); 234 } 235 } 236 } 237 } 238 } 239 240 if( count($this->hostsJabberLdap) ) 241 { 242 for($i = 0 ; $i < count($this->hostsJabberLdap); $i++) 243 { 244 if( !@array_key_exists($this->hostsJabberLdap[$i]['serverLdap'], $serversLdap) ) 245 { 246 $result[] = $this->ldap->getUsersLdapCatalog("cn=*".$pName."*", false, $this->hostsJabberLdap[$i]['serverLdap'] ); 247 } 248 } 249 } 250 } 251 252 if ( is_array($result) ) 253 { 254 for( $i = 0; $i < count($result); $i++ ) 255 if( is_array($result[$i]) ) 256 $members = @array_merge($members,$result[$i]); 257 } 258 259 if( count($members) > 150) 260 { 261 $ou = substr( $this->ou_User, strpos($this->ou_User, "=") + 1 ); 262 263 for($i = 0 ; $i < count($members); $i++ ) 264 { 265 if( $ou == $members[$i]['ou'] ) 266 { 267 $uids_org[] = $members[$i]; 145 $serversLdap = unserialize( trim($_SESSION['phpgw_info']['jabberit_messenger']['groups_search']) ); 146 147 if( $serversLdap ) 148 { 149 // Usa Grupos Ldap 150 $filters = array( ); 151 152 foreach( $serversLdap as $servers => $groups ) 153 { 154 $filter = ''; 155 foreach( unserialize($groups) as $group ) 156 $filter .= '(gidnumber' . strstr( $group, ':' ) . ')'; 157 158 $filters[ $servers ] = str_replace( ':', '=', $filter ); 159 } 160 161 foreach( $serversLdap as $key => $tmp ) 162 { 163 if( $key === $this->serverLdap ) 164 { 165 $result[$key] = $this->ldap->getUsersLdapRoot("cn=*".$pName."*"); 166 $countUids += count($result[$key]); 268 167 } 269 168 else 270 169 { 271 if(isset($_SESSION['phpgw_info']['jabberit_messenger']['photo'])) 272 unset($_SESSION['phpgw_info']['jabberit_messenger']['photo'][$members[$i]['ou']]); 273 } 274 } 275 276 return $uids_org; 277 } 278 279 return $members; 170 if( !$this->groupsLocked() ) 171 { 172 $result[$key] = $this->ldap->getUsersLdapCatalog("cn=*".$pName."*", $key ); 173 $countUids += count($result[$key]); 174 } 175 } 176 } 177 178 if( $countUids > $this->ldap->getMaxResults() ) 179 { 180 return "manyresults"; 181 } 182 183 $_RESULT = $this->ldap->getMembers($result, $filters); 184 185 foreach( $_RESULT as $key => $value ) 186 $array_uids = array_merge($array_uids, $_RESULT[$key]); 187 } 188 else 189 { 190 $result[] = $this->ldap->getUsersLdapRoot("cn=*".$pName."*"); 191 192 foreach( $result as $key => $value ) 193 { 194 $array_uids = array_merge($array_uids, $result[$key]); 195 } 196 197 if( count($array_uids) > $this->ldap->getMaxResults() ) 198 { 199 return "manyresults"; 200 } 201 } 202 203 if( $this->groupsLocked() ) 204 { 205 $orgs[] = substr($this->ou_User, ( strpos($this->ou_User, "ou=") + 3 ) ); 206 $orgsGroupsLocked = explode(",", $_SESSION['phpgw_info']['jabberit_messenger']['organizationsGroupsLocked']); 207 208 foreach( $orgsGroupsLocked as $tmp ) 209 { 210 if( $tmp != "") 211 $orgs[] = $tmp; 212 } 213 214 $orgs = array_unique($orgs); 215 216 $_restrict = array(); 217 218 for( $i = 0 ; $i < count($orgs) ; $i++ ) 219 { 220 for( $j = 0 ; $j < count($array_uids) ; $j++ ) 221 { 222 if( trim($array_uids[$j]['ou']) === trim($orgs[$i]) ) 223 { 224 $_restrict[] = $array_uids[$j]; 225 } 226 } 227 } 228 229 return $_restrict; 230 } 231 else 232 { 233 return $array_uids; 234 } 280 235 } 281 236
Note: See TracChangeset
for help on using the changeset viewer.