Changeset 151 for trunk/instant_messenger/inc/class.ldap_im.inc.php
- Timestamp:
- 01/18/08 15:17:58 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/instant_messenger/inc/class.ldap_im.inc.php
r68 r151 6 6 private $conn; 7 7 private $user; 8 private $jid; 8 9 private $password; 9 10 10 11 function __construct() 11 12 { 12 $this->ldap_host = $_SESSION['phpgw_info']['instant_messenger']['server_ldap_jabber']; 13 $this->ldap_context = $_SESSION['phpgw_info']['instant_messenger']['context_ldap_jabber']; 14 $this->user = $_SESSION['phpgw_info']['instant_messenger']['user_ldap_jabber']; 15 $this->password = $_SESSION['phpgw_info']['instant_messenger']['password_ldap_jabber']; 13 session_start(); 14 $this->ldap_host = $_SESSION['phpgw_info']['instant_messenger']['server_ldap_jabber']; 15 $this->ldap_context = $_SESSION['phpgw_info']['instant_messenger']['context_ldap_jabber']; 16 $this->user = $_SESSION['phpgw_info']['instant_messenger']['user_ldap_jabber']; 17 $this->password = $_SESSION['phpgw_info']['instant_messenger']['password_ldap_jabber']; 18 $this->jid = $_SESSION['phpgw_info']['instant_messenger']['user']; 16 19 $this->connect_ldap(false); 20 session_write_close(); 17 21 } 18 22 … … 33 37 } 34 38 35 function get_photo_ldap($ user,$getPhoto)39 function get_photo_ldap($pUser,$getPhoto) 36 40 { 37 $user = ( $ user == "user" ) ? $_SESSION['phpgw_info']['instant_messenger']['user'] : $user ;41 $user = ( $pUser == "im_avatar" ) ? $this->jid : $pUser ; 38 42 39 if ($this->conn) { 43 if ($this->conn) 44 { 40 45 $filter="(&(uid=".$user.")(phpgwAccountType=u))"; 41 46 $justthese = array("jpegphoto"); 42 $search = ldap_search($this->conn,$this->ldap_context, $filter, $justthese);43 $entry = ldap_first_entry($this->conn, $search);47 $search = @ldap_search($this->conn,$this->ldap_context, $filter, $justthese); 48 $entry = @ldap_first_entry($this->conn, $search); 44 49 $jpeg_data = @ldap_get_values_len($this->conn, $entry, "jpegphoto"); 45 50 46 if( count($jpeg_data) > 1) {47 51 if( count($jpeg_data) > 1) 52 { 48 53 $photo = imagecreatefromstring($jpeg_data[0]); 49 if($photo){ 50 if($getPhoto){ 54 if($photo) 55 { 56 if($getPhoto) 57 { 51 58 header("Content-Type: image/jpeg"); 52 59 $width = imagesx($photo); … … 59 66 return; 60 67 }else{ 61 return 1;68 return "true"; 62 69 } 63 70 }else{ 64 return 0;71 return "false"; 65 72 } 66 73 }else{ 67 return 0;74 return "false"; 68 75 } 69 76 } … … 72 79 function photo_ldap($user) 73 80 { 74 $uid = ( $user['uid'] == " user" ) ? $_SESSION['phpgw_info']['instant_messenger']['user']: $user['uid'] ;81 $uid = ( $user['uid'] == "im_avatar" ) ? $this->jid : $user['uid'] ; 75 82 return $this->get_photo_ldap($uid,false); 76 83 } … … 143 150 function list_organizations_ldap() 144 151 { 145 $result_org = array(); 146 $i = 0; 147 if ($this->conn) { 152 $result_org = "<organizations><ou></ou>"; 153 154 if ($this->conn) 155 { 148 156 $filter="ou=*"; 149 157 $justthese = array("ou"); … … 152 160 } 153 161 154 foreach($entry as $tmp){ 155 if($tmp['ou'][0] != ""){ 156 $result_org[$i] = $tmp['ou'][0]; 157 $i++; 158 } 159 } 160 sort($result_org); 162 foreach($entry as $tmp) 163 if($tmp['ou'][0] != "") 164 $result_org .= "<ou>" . $tmp['ou'][0] . "</ou>"; 165 166 $result_org .= "</organizations>"; 167 161 168 return $result_org; 162 169 } … … 176 183 } 177 184 178 if(trim($_REQUEST['user']) != ""){ 185 if(trim($_REQUEST['user']) != "") 186 { 179 187 $obj_img = new ldap_im(); 180 188 $obj_img->get_photo_ldap($_REQUEST['user'],true);
Note: See TracChangeset
for help on using the changeset viewer.