Ignore:
Timestamp:
04/13/10 17:48:28 (14 years ago)
Author:
alexandrecorreia
Message:

Ticket #986 - Implementado o status de mensagem e a busca da foto no ldap.

Location:
sandbox/jabberit_messenger/trophy_expresso/inc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sandbox/jabberit_messenger/trophy_expresso/inc/WebService.php

    r2471 r2511  
    1212class WebService 
    1313{ 
     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         
    1451        public final function getPhotoSession($pUid, $pOu) 
    1552        { 
     
    1754                if( strpos($pUid, "@") ) 
    1855                        $uid = substr($pUid, 0, strpos($pUid, "@")); 
    19                  
    20                 require_once("../../header.session.inc.php"); 
    2156                 
    2257                if( isset($_SESSION['phpgw_info']['jabberit_messenger']['photo'][$pOu][$uid]) ) 
     
    4075} 
    4176 
    42 // Php - fotos pelo php; 
    43 if(trim($_REQUEST['phpPhoto']) != "") 
     77// Photo in Session 
     78if(trim($_REQUEST['photo_session']) != "") 
    4479{ 
    4580        $obj    = new WebService(); 
    46         $ou             = $_REQUEST['phpOu']; 
    47         $jid    = $_REQUEST['phpPhoto']; 
     81        $ou             = $_REQUEST['ou']; 
     82        $jid    = $_REQUEST['photo_session']; 
    4883         
    4984        $obj->getPhotoSession($jid, $ou); 
    5085} 
    5186 
     87// Photo Ldap  
     88if(trim($_REQUEST['photo_ldap'])) 
     89{ 
     90        $obj    = new WebService(); 
     91        $jid    = $_REQUEST['photo_ldap']; 
     92        $obj->getPhoto($jid); 
     93} 
    5294 
    5395?> 
  • sandbox/jabberit_messenger/trophy_expresso/inc/class.LdapIM.inc.php

    r2421 r2511  
    303303        } 
    304304 
     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 
    305360        public final function getUsersLdapCatalog( $search, $uid = false, $pLdap = false ) 
    306361        { 
Note: See TracChangeset for help on using the changeset viewer.