Changeset 697 for trunk/jabberit_messenger/inc/class.contacts_im.inc.php
- Timestamp:
- 03/12/09 11:32:55 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/jabberit_messenger/inc/class.contacts_im.inc.php
r598 r697 19 19 private $ldap; 20 20 private $db; 21 21 private $ou_User; 22 22 23 public final function __construct() 23 24 { 24 25 $this->ldap = new ldap_im(); 25 $this->db = new db_im(); 26 $this->db = new db_im(); 27 28 $ou_User = $_SESSION['phpgw_info']['jabberit_messenger']['account_dn']; 29 $ou_User = substr($this->ou_User,strpos($this->ou_User, "ou=")); 30 $ou_User = strtoupper(substr($this->ou_User, 0, strpos($this->ou_User, ",dc="))); 31 32 // (OU) User 33 $this->ou_User = $_SESSION['phpgw_info']['jabberit_messenger']['account_dn']; 34 $this->ou_User = substr($this->ou_User,strpos($this->ou_User, "ou=")); 35 $this->ou_User = strtoupper(substr($this->ou_User, 0, strpos($this->ou_User, ",dc="))); 26 36 } 27 37 … … 45 55 { 46 56 $groups = explode(":", $tmp); 47 if( array_search($groups[1], $memberShip) !== False) 57 if( array_search($groups[1], $memberShip) !== False ) 58 { 59 $_SESSION['phpgw_info']['jabberit_messenger']['organizationsGroupsLocked'] = $groups[2]; 48 60 return true; 61 } 49 62 } 50 63 … … 82 95 return $return; 83 96 } 84 97 85 98 private final function users_auth_im($pName) 86 99 { … … 88 101 $count = count($array_uids); 89 102 $uids_members = array(); 103 $result = array(); 90 104 91 105 for($i = 0; $i < $count ;$i+=50) … … 94 108 $filter_uid = implode(")(uidnumber=",$partial_uids); 95 109 $filter_uid = "(uidnumber=". $filter_uid. ")"; 96 $result = $this->ldap->list_users_ldap("cn=*".$pName."*", $filter_uid, $this->groupsLocked()); 97 if ( is_array($result) ) 98 $uids_members = array_merge($uids_members,$result); 110 111 if( $this->groupsLocked() ) 112 { 113 $orgs[] = $this->ou_User; 114 $orgsGroupsLocked = explode(",", $_SESSION['phpgw_info']['jabberit_messenger']['organizationsGroupsLocked']); 115 116 foreach( $orgsGroupsLocked as $tmp ) 117 { 118 if( $tmp != "" ) 119 $orgs[] = "OU=". $tmp; 120 } 121 122 $orgs = array_unique($orgs); 123 124 foreach( $orgs as $tmp ) 125 $result[] = $this->ldap->list_users_ldap("cn=*".$pName."*", $filter_uid, $tmp); 126 } 127 else 128 $result[] = $this->ldap->list_users_ldap("cn=*".$pName."*", $filter_uid); 129 } 130 131 if ( is_array($result) ) 132 { 133 for($i = 0; $i < count($result); $i++) 134 if(is_array($result[$i])) 135 $uids_members = array_merge($uids_members,$result[$i]); 136 } 99 137 100 if(count($uids_members) > 50){ 101 unset($_SESSION['phpgw_info']['jabberit_messenger']['photo']); 102 return 'Many Results'; 103 } 104 } 105 if(count($uids_members) > 0) 138 if( count($uids_members) > 50 ) 139 { 140 unset($_SESSION['phpgw_info']['jabberit_messenger']['photo']); 141 return 'Many Results'; 142 } 143 144 if( count($uids_members) > 0 ) 106 145 return $uids_members; 107 146 else 108 return 0; 147 return 0; 148 } 149 150 public final function verifyAddNewContact($pUid) 151 { 152 $groupsLocked = explode(";",$_SESSION['phpgw_info']['jabberit_messenger']['groups_locked']); 153 $gidNumbers = array(); 154 $uid = $pUid['uid']; 155 156 foreach($groupsLocked as $tmp) 157 { 158 $groups = explode(":", $tmp); 159 $gidNumbers[] = $groups[1]; 160 } 161 162 $filter_gid = implode(")(gidnumber=",$gidNumbers); 163 $filter_gid = "(gidnumber=". $filter_gid. ")"; 164 165 $result = $this->ldap->list_groups_memberUid($filter_gid); 166 167 if( $result && is_array($result) ) 168 { 169 array_shift($result); 170 $i = 0; 171 172 foreach($result as $value) 173 { 174 $Groups[$i]['dn'] = $value['dn']; 175 $Groups[$i]['gidnumber'] = $value['gidnumber'][0]; 176 if(array_key_exists('memberuid',$value)) 177 { 178 array_shift($value['memberuid']); 179 $Groups[$i++]['memberuid'] = $value['memberuid']; 180 } 181 } 182 183 $search = array(); 184 $search_Gid = array(); 185 186 // Verifica Uid em Grupo Bloqueado 187 foreach($Groups as $value) 188 { 189 if( array_search( $uid , $value['memberuid'] ) !== false ) 190 { 191 $ou = substr($value['dn'],strpos($value['dn'], "ou=")); 192 $search[] = strtoupper(substr($ou, 0, strpos($ou, ",dc="))); 193 $search_Gid[] = $value['gidnumber']; 194 } 195 } 196 } 197 198 if( $this->groupsLocked() ) 199 { 200 if( count($search) > 0 ) 201 { 202 // Verifica permissões do grupo 203 foreach($groupsLocked as $value) 204 { 205 $tpGroups = explode(":",$value); 206 if( $tpGroups[1] == $search_Gid[0] ) 207 { 208 $ousTp = explode(",",$tpGroups[2]); 209 $ou_User = substr($this->ou_User,3); 210 211 if( array_search( $ou_User, $ousTp) !== false ) 212 return "true"; 213 } 214 } 215 return "false"; 216 } 217 else 218 return "true"; 219 } 220 else 221 { 222 // Se Bloqueado verifica o Grupo 223 if( count($search) > 0 ) 224 { 225 if( array_search($this->ou_User, $search) === false ) 226 { 227 // Verifica permissões do grupo 228 foreach($groupsLocked as $value) 229 { 230 $tpGroups = explode(":",$value); 231 if( $tpGroups[1] == $search_Gid[0] ) 232 { 233 $ousTp = explode(",",$tpGroups[2]); 234 $ou_User = substr($this->ou_User,3); 235 236 if( array_search( $ou_User, $ousTp) !== false ) 237 return "true"; 238 } 239 } 240 return "false"; 241 } 242 return "true"; 243 } 244 return "true"; 245 } 109 246 } 110 247 }
Note: See TracChangeset
for help on using the changeset viewer.