Changeset 3260 for branches/2.2/jabberit_messenger/jmessenger/inc
- Timestamp:
- 09/17/10 11:11:28 (14 years ago)
- Location:
- branches/2.2/jabberit_messenger/jmessenger/inc
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2/jabberit_messenger/jmessenger/inc/class.ContactsIm.inc.php
r3102 r3260 25 25 // (OU) User 26 26 $this->ou_User = $this->dn_User; 27 $this->ou_User = substr($this->ou_User, strpos($this->ou_User, "ou="));27 $this->ou_User = substr($this->ou_User, strpos($this->ou_User, "ou=") ); 28 28 $this->ou_User = strtoupper(substr($this->ou_User, 0, strpos($this->ou_User, ",dc="))); 29 29 … … 49 49 public final function getListContacts($param) 50 50 { 51 52 51 $order = array(); 53 52 $ou_User = substr($this->ou_User, (strpos($this->ou_User,"=")+1)); 54 $return = '<empty/>';53 $return = "<empty></empty>"; 55 54 $users = $this->getUsersIm($param['name']); 56 57 58 if (!is_array($users) && trim($users) === 'Many Results') 59 return "<error>Many Results</error>"; 60 55 56 if ( !is_array($users) ) 57 return "<error></error>"; 58 59 if( count($users) == 0 ) 60 return "<empty></empty>"; 61 62 if( count($users) > $this->ldap->getMaxResults() ) 63 { 64 if( isset($_SESSION['phpgw_info']['jabberit_messenger']['photo']) ) 65 unset($_SESSION['phpgw_info']['jabberit_messenger']['photo']); 66 67 return "<manyresults></manyresults>"; 68 } 69 61 70 // Hosts Jabber 62 71 $hostsJabber = unserialize($_SESSION['phpgw_info']['jabberit_messenger']['map_org_realm_jabberit']); … … 113 122 $result = array(); 114 123 $uidType = "uid"; 115 $serversLdap = unserialize(trim($_SESSION['phpgw_info']['jabberit_messenger']['groups_search'])); 116 117 if( $serversLdap ) 118 { 119 if( array_key_exists($this->serverLdap, $serversLdap) ) 120 { 121 $groups = unserialize($serversLdap[$this->serverLdap]); 122 } 123 124 if( count($groups) > 0 ) 125 { 126 foreach($groups as $tmp) 127 { 128 $group = explode(":",$tmp); 129 $array_result = $this->ldap->getGroupsMemberUid($group[0], $this->serverLdap ); 130 @array_shift($array_result[0]['memberuid']); 131 $array_uids = @array_merge($array_uids, $array_result[0]['memberuid']); 132 unset($array_result); 133 } 134 } 135 } 136 137 if( count($array_uids) == 0 ) 138 { 124 $serversLdap = unserialize( trim($_SESSION['phpgw_info']['jabberit_messenger']['groups_search']) ); 125 126 if( $serversLdap ) 127 { 128 // Usa Grupos Ldap 129 130 $filters = array( ); 131 132 foreach( $serversLdap as $servers => $groups ) 133 { 134 $filter = ''; 135 foreach( unserialize($groups) as $group ) 136 $filter .= '(gidnumber' . strstr( $group, ':' ) . ')'; 137 138 $filters[ $servers ] = str_replace( ':', '=', $filter ); 139 } 140 141 foreach( $serversLdap as $key => $tmp ) 142 { 143 if( $key === $this->serverLdap ) 144 { 145 $result[$key] = $this->ldap->getUsersLdapRoot("cn=*".$pName."*"); 146 } 147 else 148 { 149 if( !$this->groupsLocked() ) 150 $result[$key] = $this->ldap->getUsersLdapCatalog("cn=*".$pName."*", $key ); 151 } 152 } 153 154 $_RESULT = $this->ldap->getMembers($result, $filters); 155 156 foreach( $_RESULT as $key => $value ) 157 $array_uids = array_merge($array_uids, $_RESULT[$key]); 158 } 159 else 160 { 161 // Consulta Banco 139 162 $array_uids = $this->db->get_accounts_acl(); 140 $uidType = "uidnumber"; 141 } 142 143 for( $i = 0; $i < count($array_uids) ; $i+=50 ) 144 { 145 $partial_uids = array_slice($array_uids,$i,50); 146 $filter_uid = implode(")(".$uidType."=",$partial_uids); 147 $filter_uid = "(".$uidType."=". $filter_uid. ")"; 148 149 if( $this->groupsLocked() ) 150 { 151 $orgs[] = $this->ou_User; 152 $orgsGroupsLocked = explode(",", $_SESSION['phpgw_info']['jabberit_messenger']['organizationsGroupsLocked']); 153 154 foreach( $orgsGroupsLocked as $tmp ) 155 { 156 if( $tmp != "" ) 163 $uidType = "uidnumber"; 164 } 165 166 if( $this->groupsLocked() ) 167 { 168 $orgs[] = substr($this->ou_User, ( strpos($this->ou_User, "ou=") + 3 ) ); 169 $orgsGroupsLocked = explode(",", $_SESSION['phpgw_info']['jabberit_messenger']['organizationsGroupsLocked']); 170 171 foreach( $orgsGroupsLocked as $tmp ) 172 { 173 if( $tmp != "") 174 $orgs[] = $tmp; 175 } 176 177 $orgs = array_unique($orgs); 178 179 $_restrict = array(); 180 181 for( $i = 0 ; $i < count($orgs) ; $i++ ) 182 { 183 for( $j = 0 ; $j < count($array_uids) ; $j++ ) 184 { 185 if( trim($array_uids[$j]['ou']) === trim($orgs[$i]) ) 157 186 { 158 if( strpos($tmp, "/") !== false ) 159 { 160 $tt = explode("/", $tmp); 161 $newOU = implode(",OU=",array_reverse($tt)); 162 $orgs[] = "OU=". $newOU ; 163 } 164 else 165 $orgs[] = "OU=". $tmp; 166 } 167 } 168 169 $orgs = array_unique($orgs); 170 171 foreach( $orgs as $orgB ) 172 $result[] = $this->ldap->getUsersLdapRoot("cn=*".$pName."*", $filter_uid, $orgB ); 173 174 } 175 else 176 $result[] = $this->ldap->getUsersLdapRoot("cn=*".$pName."*", $filter_uid); 177 } 178 179 if( !$this->groupsLocked() ) 180 { 181 unset($serversLdap[$this->serverLdap]); 182 183 if( $serversLdap && count($serversLdap)) 184 { 185 foreach( $serversLdap as $key => $tmp ) 186 { 187 $array_uids_external = array( ); 188 $groupsExternal = unserialize($tmp); 189 190 if( count($groupsExternal) ) 191 { 192 foreach( $groupsExternal as $tmpExt ) 193 { 194 $group = explode(":",$tmpExt); 195 $array_result = $this->ldap->getGroupsMemberUid( $group[0], $key ); 196 197 if( $array_result[0]['memberuid']['count'] ) 198 unset($array_result[0]['memberuid']['count']); 199 200 $array_uids_external = @array_merge($array_uids_external, $array_result[0]['memberuid']); 201 } 202 203 204 if( is_array($array_uids_external) ) 205 { 206 for( $i = 0; $i < count( $array_uids_external ) ; $i+=50 ) 207 { 208 $partial_uids_external = array_slice($array_uids_external,$i,50); 209 $filter_uid_external = implode(")(".$this->attribute."=",$partial_uids_external); 210 $filter_uid_external = "(".$this->attribute."=". $filter_uid_external. ")"; 211 $result[] = $this->ldap->getUsersLdapCatalog("cn=*".$pName."*", $filter_uid_external, $key ); 212 } 213 } 214 } 215 } 216 } 217 218 if( count($this->hostsJabberLdap) ) 219 { 220 for($i = 0 ; $i < count($this->hostsJabberLdap); $i++) 221 { 222 if( !@array_key_exists($this->hostsJabberLdap[$i]['serverLdap'], $serversLdap) ) 223 { 224 $result[] = $this->ldap->getUsersLdapCatalog("cn=*".$pName."*", false, $this->hostsJabberLdap[$i]['serverLdap'] ); 225 } 226 } 227 } 228 } 229 230 if ( is_array($result) ) 231 { 232 for( $i = 0; $i < count($result); $i++ ) 233 if( is_array($result[$i]) ) 234 $members = @array_merge($members,$result[$i]); 235 } 236 237 if( count($members) > 150) 238 { 239 $ou = substr( $this->ou_User, strpos($this->ou_User, "=") + 1 ); 240 241 for($i = 0 ; $i < count($members); $i++ ) 242 { 243 if( $ou == $members[$i]['ou'] ) 244 { 245 $uids_org[] = $members[$i]; 246 } 247 else 248 { 249 if(isset($_SESSION['phpgw_info']['jabberit_messenger']['photo'])) 250 unset($_SESSION['phpgw_info']['jabberit_messenger']['photo'][$members[$i]['ou']]); 251 } 252 } 253 254 return $uids_org; 255 } 256 257 return $members; 187 $_restrict[] = $array_uids[$j]; 188 } 189 } 190 } 191 192 return $_restrict; 193 } 194 else 195 { 196 return $array_uids; 197 } 258 198 } 259 199 … … 355 295 if( count($search) > 0 ) 356 296 { 357 // Verifica permiss ões do grupo297 // Verifica permissões do grupo 358 298 foreach($groupsLocked as $value) 359 299 { … … 392 332 if( array_search($this->ou_User, $search) === false ) 393 333 { 394 // Verifica permiss ões do grupo334 // Verifica permissões do grupo 395 335 foreach($groupsLocked as $value) 396 336 { -
branches/2.2/jabberit_messenger/jmessenger/inc/class.LdapIM.inc.php
r3102 r3260 42 42 43 43 // Result Ldap 44 $this->max_result = 20;44 $this->max_result = 15; 45 45 46 46 if ( file_exists('inc/attributeLdap.php') ) … … 73 73 private final function ldapRoot() 74 74 { 75 $this->ldap_host = $_SESSION['phpgw_info']['jabberit_messenger']['server_ldap_jabberit']; 76 $this->ldap_context = $_SESSION['phpgw_info']['jabberit_messenger']['context_ldap_jabberit']; 77 $this->ldap_user = $_SESSION['phpgw_info']['jabberit_messenger']['user_ldap_jabberit']; 78 $this->ldap_pass = $_SESSION['phpgw_info']['jabberit_messenger']['password_ldap_jabberit']; 79 75 80 $this->ldapConn(); 76 81 } … … 102 107 103 108 return $conn; 109 } 110 111 private function getLdapHost() 112 { 113 return $_SESSION['phpgw_info']['jabberit_messenger']['server_ldap_jabberit']; 104 114 } 105 115 … … 169 179 170 180 return $result_groups; 181 } 182 183 public final function getMaxResults() 184 { 185 return $this->max_result; 186 } 187 188 public final function getMembers( $pMembers, $pServers ) 189 { 190 $members = $pMembers; 191 192 foreach( $pServers as $servers => $groups ) 193 { 194 if( $servers == $this->getLdapHost() || $servers == 'localhost') 195 { 196 $this->ldapRoot(); 197 198 $count = count($members[$servers]); 199 200 for( $i = 0; $i < $count; $i++ ) 201 { 202 if ( ! $this->getMemberUid($groups, $members[$servers][$i]['uid'] ) ) 203 unset( $members[$servers][$i] ); 204 } 205 206 if( $this->ldap ) 207 @ldap_close($this->ldap); 208 } 209 else 210 { 211 $confHosts = $this->hostsJabber; 212 213 for($i = 0; $i < count($confHosts); $i++ ) 214 { 215 if( $this->ldap ) 216 @ldap_close($this->ldap); 217 218 if( trim($servers) === trim($confHosts[$i]['serverLdap']) ) 219 { 220 $this->ldap_host = $confHosts[$i]['serverLdap']; 221 $this->ldap_context = $confHosts[$i]['contextLdap']; 222 $this->ldap_user = $confHosts[$i]['user']; 223 $this->ldap_org = $confHosts[$i]['org']; 224 $this->ldap_pass = $confHosts[$i]['password']; 225 $this->ldap = $this->ldapCatalog(); 226 227 $count = count($members[$servers]); 228 229 for( $i = 0; $i < $count; $i++ ) 230 { 231 if ( ! $this->getMemberUid($groups, $members[$servers][$i]['uid'] ) ) 232 unset( $members[$servers][$i] ); 233 } 234 235 if( $this->ldap ) 236 @ldap_close($this->ldap); 237 } 238 } 239 } 240 } 241 242 return $members; 243 } 244 245 private function getMemberUid( $pGidNumber, $pMemberUid ) 246 { 247 $filter = "(&(phpgwAccountType=g)(|{$pGidNumber})(memberuid={$pMemberUid}))"; 248 $justthese = array("memberuid"); 249 250 if( $this->ldap ) 251 { 252 $search = ldap_search($this->ldap, $this->ldap_context, $filter, $justthese ); 253 $result = ldap_get_entries($this->ldap,$search); 254 if( $result["count"] ) 255 return true; 256 } 257 258 return false; 171 259 } 172 260 … … 360 448 } 361 449 362 public final function getUsersLdapCatalog( $search, $ uid = false, $pLdap= false )450 public final function getUsersLdapCatalog( $search, $pLdap = false, $uid = false ) 363 451 { 364 452 $confHosts = $this->hostsJabber; … … 390 478 $return = array_merge($return, $result); 391 479 else 392 $return = $result; 480 $return = $result; 393 481 } 394 482 … … 401 489 } 402 490 403 public final function getUsersLdapRoot( $search, $uidnumber, $ous = false ) 404 { 491 public final function getUsersLdapRoot( $search, $uidnumber = false, $ous = false ) 492 { 493 405 494 $result = array(); 406 495 $this->ldapRoot(); … … 409 498 { 410 499 $searchRoot = ( $ous ) ? $ous.",".$this->ldap_context : $this->ldap_context ; 411 $filter = "(&(phpgwaccounttype=u)(|".$uidnumber.")(".$search ."))";500 $filter = ($uidnumber) ? "(&(phpgwaccounttype=u)(|".$uidnumber.")(".$search ."))" : "(&(phpgwaccounttype=u)(".$search ."))"; 412 501 $justthese = array( $this->attribute, "uidNumber", "cn", "mail", "phpgwAccountVisible", "dn", "jpegPhoto" ); 413 502 $search = @ldap_search( $this->ldap, $searchRoot, $filter, $justthese, 0, $this->max_result + 1);
Note: See TracChangeset
for help on using the changeset viewer.