Changeset 2511 for sandbox/jabberit_messenger/trophy_expresso/inc
- Timestamp:
- 04/13/10 17:48:28 (14 years ago)
- Location:
- sandbox/jabberit_messenger/trophy_expresso/inc
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/jabberit_messenger/trophy_expresso/inc/WebService.php
r2471 r2511 12 12 class WebService 13 13 { 14 function __construct() 15 { 16 require_once("../../header.session.inc.php"); 17 } 18 19 public final function getPhoto($pUid) 20 { 21 require_once("class.LdapIM.inc.php"); 22 23 $ldap = new LdapIM(); 24 25 $uid = $pUid; 26 if( strpos($pUid, "/") ) 27 $uid = substr($pUid, 0, strpos($pUid, "/")); 28 29 $photo = $ldap->getPhotoUser($uid, true); 30 31 if ( !$photo ) 32 $photo = $ldap->getPhotoUser($uid, false); 33 34 if( $photo ) 35 $photo = imagecreatefromstring($photo); 36 else 37 $photo = imagecreatefrompng("../templates/default/images/photo.png"); 38 39 header("Content-Type: image/jpeg"); 40 $width = imagesx($photo); 41 $height = imagesy($photo); 42 $twidth = 60; 43 $theight = 80; 44 $small_photo = imagecreatetruecolor ($twidth, $theight); 45 imagecopyresampled($small_photo, $photo, 0, 0, 0, 0,$twidth, $theight, $width, $height); 46 imagejpeg($small_photo,'',100); 47 48 return; 49 } 50 14 51 public final function getPhotoSession($pUid, $pOu) 15 52 { … … 17 54 if( strpos($pUid, "@") ) 18 55 $uid = substr($pUid, 0, strpos($pUid, "@")); 19 20 require_once("../../header.session.inc.php");21 56 22 57 if( isset($_SESSION['phpgw_info']['jabberit_messenger']['photo'][$pOu][$uid]) ) … … 40 75 } 41 76 42 // Ph p - fotos pelo php;43 if(trim($_REQUEST['ph pPhoto']) != "")77 // Photo in Session 78 if(trim($_REQUEST['photo_session']) != "") 44 79 { 45 80 $obj = new WebService(); 46 $ou = $_REQUEST[' phpOu'];47 $jid = $_REQUEST['ph pPhoto'];81 $ou = $_REQUEST['ou']; 82 $jid = $_REQUEST['photo_session']; 48 83 49 84 $obj->getPhotoSession($jid, $ou); 50 85 } 51 86 87 // Photo Ldap 88 if(trim($_REQUEST['photo_ldap'])) 89 { 90 $obj = new WebService(); 91 $jid = $_REQUEST['photo_ldap']; 92 $obj->getPhoto($jid); 93 } 52 94 53 95 ?> -
sandbox/jabberit_messenger/trophy_expresso/inc/class.LdapIM.inc.php
r2421 r2511 303 303 } 304 304 305 public final function getPhotoUser( $_uid, $ldapRoot ) 306 { 307 308 $uid = substr($_uid, 0, strpos($_uid, "@")); 309 $host = substr($_uid, (strpos($_uid, "@") + 1)); 310 311 if( $ldapRoot ) 312 { 313 $this->ldapRoot(); 314 } 315 else 316 { 317 $confHosts = $this->hostsJabber; 318 319 for( $i = 0; $i < count($confHosts); $i++ ) 320 { 321 if( trim($host) === trim($confHosts[$i]['jabberName']) ) 322 { 323 $this->ldap_host = $confHosts[$i]['serverLdap']; 324 $this->ldap_context = $confHosts[$i]['contextLdap']; 325 $this->ldap_user = $confHosts[$i]['user']; 326 $this->ldap_org = $confHosts[$i]['org']; 327 $this->ldap_pass = $confHosts[$i]['password']; 328 $this->ldap = $this->ldapCatalog(); 329 } 330 } 331 } 332 333 if( $this->ldap ) 334 { 335 $filter = "(&(phpgwaccounttype=u)(uid=".$uid."))"; 336 $justthese = array($this->attribute, "uidNumber", "phpgwAccontVisible", "dn", "jpegPhoto"); 337 $search = ldap_search( $this->ldap, $this->ldap_context, $filter, $justthese, 0, $this->max_result + 1); 338 $entry = ldap_get_entries( $this->ldap, $search ); 339 340 for( $i = 0 ; $i < $entry['count']; $i++ ) 341 { 342 if( $entry[$i]['jpegphoto'][0] && $entry[$i]['phpgwaccountvisible'][0] != '-1' ) 343 { 344 $filterPhoto = "(objectclass=*)"; 345 $photoLdap = ldap_read($this->ldap, $entry[$i]['dn'], $filterPhoto, array("jpegPhoto")); 346 $firstEntry = ldap_first_entry($this->ldap, $photoLdap); 347 $photo = ldap_get_values_len($this->ldap, $firstEntry, "jpegPhoto"); 348 349 if( $this->ldap ) 350 ldap_close($this->ldap); 351 352 return $photo[0]; 353 } 354 } 355 } 356 357 return false; 358 } 359 305 360 public final function getUsersLdapCatalog( $search, $uid = false, $pLdap = false ) 306 361 {
Note: See TracChangeset
for help on using the changeset viewer.