Changeset 1438
- Timestamp:
- 09/21/09 15:56:22 (15 years ago)
- Location:
- trunk/jabberit_messenger/inc
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/jabberit_messenger/inc/class.contacts_im.inc.php
r1160 r1438 19 19 private $ldap; 20 20 private $db; 21 private $dn_User; 21 22 private $ou_User; 22 23 private $serverJabber; … … 27 28 $this->db = new db_im(); 28 29 30 // (DN) User 31 $this->dn_User = $_SESSION['phpgw_info']['jabberit_messenger']['account_dn']; 32 29 33 // (OU) User 30 $this->ou_User = $ _SESSION['phpgw_info']['jabberit_messenger']['account_dn'];34 $this->ou_User = $this->dn_User; 31 35 $this->ou_User = substr($this->ou_User,strpos($this->ou_User, "ou=")); 32 36 $this->ou_User = strtoupper(substr($this->ou_User, 0, strpos($this->ou_User, ",dc="))); … … 131 135 { 132 136 if( $tmp != "" ) 133 $orgs[] = "OU=". $tmp; 134 } 135 137 { 138 if( strpos($tmp, "/") !== false ) 139 { 140 $tt = explode("/", $tmp); 141 $newOU = implode(",OU=",array_reverse($tt)); 142 $orgs[] = "OU=". $newOU ; 143 } 144 else 145 $orgs[] = "OU=". $tmp; 146 } 147 } 148 136 149 $orgs = array_unique($orgs); 137 150 138 151 foreach( $orgs as $orgB ) 139 152 $result[] = $this->ldap->getUsersLdapRoot("cn=*".$pName."*", $filter_uid, $orgB ); … … 170 183 } 171 184 185 private final function strallpos($haystack, $needle, $offset = 0) 186 { 187 $result = array(); 188 for($i = $offset; $i< strlen($haystack); $i++ ) 189 { 190 $pos = strpos($haystack,$needle,$i); 191 if($pos !== FALSE) 192 { 193 $offset = $pos; 194 if($offset >= $i) 195 $result[] = $i = $offset; 196 } 197 } 198 199 return $result; 200 } 201 172 202 public final function verifyAddNewContact($pUid) 173 203 { … … 175 205 $gidNumbers = array(); 176 206 $uid = $pUid['uid']; 207 $uid_User = substr($this->dn_User, 0, strpos($this->dn_User, ",")); 208 $uid_User = substr($uid_User, 4); 177 209 178 210 foreach($groupsLocked as $tmp) … … 186 218 187 219 $result = $this->ldap->getGroupsMemberUid($filter_gid); 188 220 189 221 if( $result && is_array($result) ) 190 222 { … … 205 237 $search = array(); 206 238 $search_Gid = array(); 207 239 208 240 // Verifica Uid em Grupo Bloqueado 209 241 foreach($Groups as $value) … … 212 244 { 213 245 $ou = substr($value['dn'],strpos($value['dn'], "ou=")); 214 $search[] = strtoupper(substr($ou, 0, strpos($ou, ",dc="))); 215 $search_Gid[] = $value['gidnumber']; 216 } 217 } 218 } 219 246 if( array_search($uid_User, $value['memberuid']) === false ) 247 { 248 $search[] = strtoupper(substr($ou, 0, strpos($ou, ",dc="))); 249 $search_Gid[] = $value['gidnumber']; 250 } 251 } 252 } 253 } 254 255 220 256 if( $this->groupsLocked() ) 221 257 { … … 229 265 { 230 266 $ousTp = explode(",",$tpGroups[2]); 231 $ou_User = s ubstr($this->ou_User,3);267 $ou_User = strtoupper(trim($this->dn_User)); 232 268 269 $posAll = $this->strallpos($ou_User, "OU=" ); 270 $orgs = array(); 271 272 for( $i = 0 ; $i < count($posAll); $i++ ) 273 { 274 $pos = strpos($ou_User, ","); 275 $tmpString = substr($ou_User, $posAll[$i] + 3); 276 $orgs[] = substr($tmpString, 0, strpos($tmpString, ",")); 277 } 278 279 $ou_User = implode("/", array_reverse($orgs)); 280 233 281 if( array_search( $ou_User, $ousTp) !== false ) 234 282 return "true"; … … 251 299 { 252 300 $tpGroups = explode(":",$value); 301 253 302 if( $tpGroups[1] == $search_Gid[0] ) 254 303 { 255 304 $ousTp = explode(",",$tpGroups[2]); 256 $ou_User = substr($this->ou_User,3); 257 305 $ou_User = strtoupper(trim($this->dn_User)); 306 307 $posAll = $this->strallpos($ou_User, "OU=" ); 308 $orgs = array(); 309 310 for( $i = 0 ; $i < count($posAll); $i++ ) 311 { 312 $pos = strpos($ou_User, ","); 313 $tmpString = substr($ou_User, $posAll[$i] + 3); 314 $orgs[] = substr($tmpString, 0, strpos($tmpString, ",")); 315 } 316 317 $ou_User = implode("/", array_reverse($orgs)); 318 258 319 if( array_search( $ou_User, $ousTp) !== false ) 259 320 return "true"; -
trunk/jabberit_messenger/inc/class.db_im.inc.php
r988 r1438 426 426 public final function setOuGroupsLocked($pGroup) 427 427 { 428 429 function strallpos($haystack, $needle, $offset = 0) 430 { 431 $result = array(); 432 for($i = $offset; $i< strlen($haystack); $i++ ) 433 { 434 $pos = strpos($haystack,$needle,$i); 435 if($pos !== FALSE) 436 { 437 $offset = $pos; 438 if($offset >= $i) 439 $result[] = $i = $offset; 440 } 441 } 442 443 return $result; 444 } 445 428 446 $group = $pGroup['group']; 429 447 $gidnumber = $pGroup['gidnumber']; 430 $organization = strtoupper($pGroup['ou']); 448 $organization = strtoupper(trim($pGroup['ou'])); 449 450 $posAll = strallpos($organization, "OU=" ); 451 $orgs = array(); 452 453 for( $i = 0 ; $i < count($posAll); $i++ ) 454 { 455 $pos = strpos($organization, ","); 456 $tmpString = substr($organization, $posAll[$i] + 3); 457 $orgs[] = substr($tmpString, 0, strpos($tmpString, ",")); 458 } 459 460 $organization = implode("/", array_reverse($orgs)); 431 461 432 462 if( $this->db ) -
trunk/jabberit_messenger/inc/class.ldap_im.inc.php
r1160 r1438 51 51 52 52 $GLOBALS['phpgw_info']['server']['ldap_version3'] = true; 53 54 $this->ldap = $this->common->ldapConnect( $this->ldap_host, $this->ldap_user . "," . $this->ldap_context , $this->ldap_pass, false ); 53 54 if( $this->ldap_user && $this->ldap_pass ) 55 $this->ldap = $this->common->ldapConnect( $this->ldap_host, $this->ldap_user . "," . $this->ldap_context , $this->ldap_pass, false ); 56 else 57 $this->ldap = $this->common->ldapConnect( $this->ldap_host, $this->ldap_context , "", false ); 55 58 } 56 59 57 60 private final function ldapRoot() 58 61 { 59 $this->ldap_host = (isset($_SESSION['phpgw_info']['jabberit_messenger']['server_ldap_jabberit'])) ? $_SESSION['phpgw_info']['jabberit_messenger']['server_ldap_jabberit'] : $GLOBALS['phpgw_info']['server']['ldap_host'];60 $this->ldap_context = (isset($_SESSION['phpgw_info']['jabberit_messenger']['context_ldap_jabberit'])) ? $_SESSION['phpgw_info']['jabberit_messenger']['context_ldap_jabberit'] : $GLOBALS['phpgw_info']['server']['ldap_context'];61 $this->ldap_user = (isset($_SESSION['phpgw_info']['jabberit_messenger']['user_ldap_jabberit'])) ? $_SESSION['phpgw_info']['jabberit_messenger']['user_ldap_jabberit'] : $GLOBALS['phpgw_info']['server']['ldap_root_dn'];62 $this->ldap_pass = (isset($_SESSION['phpgw_info']['jabberit_messenger']['password_ldap_jabberit'])) ? $_SESSION['phpgw_info']['jabberit_messenger']['password_ldap_jabberit'] : $GLOBALS['phpgw_info']['server']['ldap_root_pw'];62 $this->ldap_host = $_SESSION['phpgw_info']['jabberit_messenger']['server_ldap_jabberit']; 63 $this->ldap_context = $_SESSION['phpgw_info']['jabberit_messenger']['context_ldap_jabberit']; 64 $this->ldap_user = $_SESSION['phpgw_info']['jabberit_messenger']['user_ldap_jabberit']; 65 $this->ldap_pass = $_SESSION['phpgw_info']['jabberit_messenger']['password_ldap_jabberit']; 63 66 64 67 $this->ldapConn(); … … 146 149 if( $this->ldap ) 147 150 { 148 $filter="ou=*"; 149 $justthese = array("ou"); 150 $search = ldap_search($this->ldap,$this->ldap_context,$filter,$justthese); 151 $entry = ldap_get_entries($this->ldap, $search); 152 } 153 154 foreach($entry as $tmp) 155 if($tmp['ou'][0] != "") 156 $result_org[] = $tmp['ou'][0]; 157 158 return $result_org; 159 } 160 151 $filter = "(ou=*)"; 152 $justthese = array("dn"); 153 $search = ldap_search($this->ldap, $this->ldap_context, $filter, $justthese); 154 $info = ldap_get_entries($this->ldap, $search); 155 156 for ($i=0; $i<$info["count"]; $i++) 157 $a_sectors[] = $info[$i]['dn']; 158 } 159 160 // Retiro o count do array info e inverto o array para ordenação. 161 foreach ($a_sectors as $context) 162 { 163 $array_dn = ldap_explode_dn ( $context, 1 ); 164 $array_dn_reverse = array_reverse ( $array_dn, true ); 165 array_pop ( $array_dn_reverse ); 166 $inverted_dn[$context] = implode ( "#", $array_dn_reverse ); 167 } 168 169 // Ordenação 170 natcasesort($inverted_dn); 171 172 foreach ( $inverted_dn as $dn=>$invert_ufn ) 173 { 174 $display = ''; 175 176 $array_dn_reverse = explode ( "#", $invert_ufn ); 177 $array_dn = array_reverse ( $array_dn_reverse, true ); 178 179 $level = count( $array_dn ) - (int)(count(explode(",", $this->ldap_context)) + 1); 180 181 if ($level == 0) 182 $display .= '+'; 183 else 184 { 185 for( $i = 0; $i < $level; $i++) 186 $display .= '---'; 187 } 188 189 reset ( $array_dn ); 190 $display .= ' ' . (current ( $array_dn ) ); 191 192 $dn = trim(strtolower($dn)); 193 $options[$dn] = $display; 194 } 195 196 return $options; 197 198 } 161 199 162 200 public final function getUsersLdapCatalog( $search ) -
trunk/jabberit_messenger/inc/class.uienabledgroups.inc.php
r946 r1438 58 58 if( ($LdapOus = $ldap->getOrganizationsLdap()) ) 59 59 { 60 foreach($LdapOus as $ tmp)61 $ous .= "<option value='".$ tmp."'>".$tmp."</option>";60 foreach($LdapOus as $key => $val ) 61 $ous .= "<option value='".$key."'>".$val."</option>"; 62 62 } 63 63 -
trunk/jabberit_messenger/inc/class.uigroupslocked.inc.php
r946 r1438 70 70 71 71 $ous = "<option value='-1'>-- ".lang('Select Organization')." --</option>"; 72 72 73 if( ($LdapOus = $ldap->getOrganizationsLdap()) ) 73 74 { 74 foreach($LdapOus as $ tmp)75 $ous .= "<option value='".$ tmp."'>".$tmp."</option>";75 foreach($LdapOus as $key=>$val ) 76 $ous .= "<option value='".$val."'>".$val."</option>"; 76 77 } 77 78 78 79 $groupsRestricts = ""; 79 80 … … 82 83 $glocked = explode(';',$GLOBALS['phpgw_info']['server']['groups_locked_jabberit']); 83 84 natcasesort($glocked); 84 85 85 86 foreach( $glocked as $tmp ){ 86 87 $option = explode(":",$tmp);
Note: See TracChangeset
for help on using the changeset viewer.