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
Files:
1 added
7 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        { 
  • sandbox/jabberit_messenger/trophy_expresso/js/AddUser.js

    r2471 r2511  
    5757                                                                 
    5858                                                                var _img_path  = path_jabberit + 'inc/WebService.php?' + Date.parse( new Date ); 
    59                                                                         _img_path += '&phpPhoto=' + jid + '&phpOu=' + ou; 
     59                                                                        _img_path += '&photo_session=' + jid + '&ou=' + ou; 
    6060                                                                 
    6161                                                                _newUser.style.backgroundImage = 'url(' + _img_path + ')'; 
  • sandbox/jabberit_messenger/trophy_expresso/js/loadIM.js

    r2491 r2511  
    167167                                _optionsItens.setAttribute("style", "margin: 20px 0px 0px -4px;"); 
    168168                                _optionsItens.className         = "x-menu"; 
    169                                 _optionsItens.style.zIndex      = '99999'; 
     169                                _optionsItens.style.zIndex      = '999999'; 
    170170                                _optionsItens.innerHTML         = _itens;   
    171171                                                                                   
     
    182182        { 
    183183                return document.getElementById( elementId ); 
     184        } 
     185         
     186        function getPhotoUser( jid ) 
     187        { 
     188                var _divPhoto = getElement( jid + '__photo' ); 
     189 
     190                if( _divPhoto.style.backgroundImage.indexOf('photo.png') > 0 ) 
     191                { 
     192                        var _imgUser  = path_jabberit + 'inc/WebService.php?' + Date.parse( new Date ); 
     193                                _imgUser += '&photo_ldap=' + jid; 
     194 
     195                        _divPhoto.style.backgroundImage = 'url(' + _imgUser + ')'; 
     196                } 
    184197        } 
    185198         
     
    332345                                _optionsItens.setAttribute("style", "margin: -10px 0px 0px 20px;"); 
    333346                                _optionsItens.className         = "x-menu"; 
    334                                 _optionsItens.style.zIndex      = '99999'; 
     347                                _optionsItens.style.zIndex      = zIndex++; 
    335348                                _optionsItens.innerHTML         = _itens;   
    336349                                _optionsItens.onmouseout        = function(){ showhidden.hiddenObject(false); };         
     
    373386                var paramListContact =  
    374387                { 
     388                        'idUser'                : getUserCurrent().jid, 
     389                        'full_name'             : (( fullName.length < 25 ) ? fullName : ( fullName.substring( 0, 25) + "...")), 
    375390                        'path_jabberit' : path_jabberit, 
    376                         'full_name'             : (( fullName.length < 25 ) ? fullName : ( fullName.substring( 0, 25) + "..."))  
     391                        'zIndex_'               : zIndex++ 
    377392                }; 
    378393                 
     
    394409                 
    395410                _winBuild( winRosterDiv ); 
     411 
     412                // Photo User 
     413                getPhotoUser(getUserCurrent().jid); 
    396414        } 
    397415 
     
    442460                                               ['Não Disponível', 'xa', '<img src="'+path_jabberit+'templates/default/images/xa.gif" />'], 
    443461                                               ['Ocupado', 'dnd', '<img src="'+path_jabberit+'templates/default/images/dnd.gif" />'], 
     462                                               ['Mensagem de Status...', 'status', '<img src="'+path_jabberit+'templates/default/images/message_normal.gif" />']                                                 
    444463                                          ]; 
    445464                         
     
    477496                if( arguments.length > 0 ) 
    478497                { 
    479                         var _text       = arguments[0]; 
    480                         var _img        = arguments[1]; 
    481                          
    482                         getElement('statusJabberImg').setAttribute("style", "background-image: url('"+path_jabberit+"templates/default/images/"+_img+".gif'); margin-left: 13px;width:15px; height:15px;"); 
    483                         getElement('statusJabberText').innerHTML = _text; 
    484                         getElement('status_jabber_expresso').style.background = "url('"+path_jabberit+"templates/default/images/"+_img+".gif') no-repeat"; 
     498                        if( arguments[1] != 'status' ) 
     499                        { 
     500                                var _text       = arguments[0]; 
     501                                var _img        = arguments[1]; 
     502                                 
     503                                getElement('statusJabberImg').setAttribute("style", "background-image: url('"+path_jabberit+"templates/default/images/"+_img+".gif'); margin-left: 13px;width:15px; height:15px;"); 
     504                                getElement('statusJabberText').innerHTML = _text; 
     505                                getElement('status_jabber_expresso').style.background = "url('"+path_jabberit+"templates/default/images/"+_img+".gif') no-repeat"; 
     506                        } 
    485507                }        
    486508        } 
     
    550572        loadIM.prototype.addContact                     = addContact; 
    551573        loadIM.prototype.configEvents           = configEvents; 
     574        loadIM.prototype.getPhotoUser           = getPhotoUser; 
    552575        loadIM.prototype.getUserCurrent         = getUserCurrent; 
    553576        loadIM.prototype.getZIndex                      = getZindex; 
  • sandbox/jabberit_messenger/trophy_expresso/js/trophyim.js

    r2491 r2511  
    656656                                'path_jabberit' : path_jabberit 
    657657        }; 
    658          
     658 
     659        titleWindow = barejid.toLowerCase(); 
     660                titleWindow = titleWindow.substring(0, titleWindow.indexOf('@')); 
     661 
    659662        if( TrophyIM.rosterObj.roster[barejid] ) 
    660663        { 
     
    664667            } 
    665668        } 
    666         else 
    667         { 
    668                 titleWindow = barejid.toLowerCase(); 
    669                 titleWindow = titleWindow.substring(0, titleWindow.indexOf('@')); 
    670         }        
    671669 
    672670        var winChatBox =  
     
    687685         
    688686        _winBuild(winChatBox); 
     687 
     688        // Photo User; 
     689                loadIM.getPhotoUser(barejid); 
    689690                 
    690691                loadIM.configEvents( document.getElementById( barejid + '__sendBox'), 
     
    9991000                for( var i = 0 ; i < users.length; i++ ) 
    10001001                { 
    1001                         if( TrophyIM.rosterObj.roster[users[i]].contact.groups ) 
    1002                         { 
    1003                                 var groups = TrophyIM.rosterObj.roster[users[i]].contact.groups; 
    1004                                  
    1005                                 if( groups.length > 0 ) 
     1002                        if( TrophyIM.rosterObj.roster[users[i]].contact.jid != loadIM.getUserCurrent().jid ) 
     1003                        { 
     1004                                if( TrophyIM.rosterObj.roster[users[i]].contact.groups ) 
    10061005                                { 
    1007                                         for( var j = 0; j < groups.length; j++ ) 
    1008                                                 addItem( TrophyIM.rosterObj.roster[users[i]], groups[j], element, j ); 
     1006                                        var groups = TrophyIM.rosterObj.roster[users[i]].contact.groups; 
     1007                                         
     1008                                        if( groups.length > 0 ) 
     1009                                        { 
     1010                                                for( var j = 0; j < groups.length; j++ ) 
     1011                                                        addItem( TrophyIM.rosterObj.roster[users[i]], groups[j], element, j ); 
     1012                                        } 
     1013                                        else 
     1014                                        { 
     1015                                                addItem( TrophyIM.rosterObj.roster[users[i]], "Geral", element, 0 ); 
     1016                                        } 
    10091017                                } 
    10101018                                else 
     
    10131021                                } 
    10141022                        } 
    1015                         else 
    1016                         { 
    1017                                 addItem( TrophyIM.rosterObj.roster[users[i]], "Geral", element, 0 ); 
    1018                         } 
    10191023                }        
    10201024        }, 
     
    10461050     */ 
    10471051 
    1048         setPresence : function( show ) 
    1049         { 
    1050                 TrophyIM.connection.send($pres( ).c('show').t(show).tree()); 
     1052        setPresence : function( type ) 
     1053        { 
     1054                if( type != 'status') 
     1055                { 
     1056                        TrophyIM.connection.send($pres( ).c('show').t(type).tree()); 
     1057                } 
     1058                else 
     1059                { 
     1060                        var _show       = "available"; 
     1061                        var _status     = ""; 
     1062                         
     1063                        if (( _status = prompt("Digite sua mensagem !") )) 
     1064                        { 
     1065                                for(var resource in TrophyIM.rosterObj.roster[loadIM.getUserCurrent().jid].presence ) 
     1066                                {        
     1067                                        if ( TROPHYIM_RESOURCE === ("/" + resource) ) 
     1068                                                _show = TrophyIM.rosterObj.roster[loadIM.getUserCurrent().jid].presence[resource].show; 
     1069                                } 
     1070 
     1071                                var _presence = $pres( ); 
     1072                                _presence.node.appendChild( Strophe.xmlElement( 'show' ) ).appendChild( Strophe.xmlTextNode( _show ) ); 
     1073                                _presence.node.appendChild( Strophe.xmlElement( 'status' ) ).appendChild( Strophe.xmlTextNode( _status ) ); 
     1074                                 
     1075                                TrophyIM.connection.send( _presence.tree() ); 
     1076                        } 
     1077                } 
    10511078        }, 
    10521079         
     
    11571184        this.addContact = function(jid, subscription, name, groups ) 
    11581185        { 
    1159         if( jid != loadIM.getUserCurrent().jid ) 
    1160         {  
    1161                 if( subscription !== "remove" ) 
    1162                 { 
    1163                         var contact             = { jid:jid, subscription:subscription, name:name, groups:groups } 
    1164                         var jid_lower   = jid.toLowerCase(); 
    1165                  
    1166                                 if ( this.roster[jid_lower] ) 
     1186                if( subscription !== "remove" ) 
     1187        { 
     1188                var contact             = { jid:jid, subscription:subscription, name:name, groups:groups } 
     1189                var jid_lower   = jid.toLowerCase(); 
     1190         
     1191                        if ( this.roster[jid_lower] ) 
     1192                        { 
     1193                    this.roster[jid_lower]['contact'] = contact; 
     1194                } 
     1195                        else 
     1196                        { 
     1197                    this.roster[jid_lower] = {contact:contact}; 
     1198                } 
     1199         
     1200                        groups = groups ? groups : ['']; 
     1201                 
     1202                        for ( var g = 0; g < groups.length; g++ ) 
     1203                        { 
     1204                                if ( !this.groups[groups[g]] ) 
    11671205                                { 
    1168                             this.roster[jid_lower]['contact'] = contact; 
    1169                         } 
    1170                                 else 
    1171                                 { 
    1172                             this.roster[jid_lower] = {contact:contact}; 
    1173                         } 
    1174                  
    1175                                 groups = groups ? groups : ['']; 
    1176                          
    1177                                 for ( var g = 0; g < groups.length; g++ ) 
    1178                                 { 
    1179                                         if ( !this.groups[groups[g]] ) 
    1180                                         { 
    1181                                 this.groups[groups[g]] = {}; 
    1182                             } 
    1183                              
    1184                                         this.groups[groups[g]][jid_lower] = jid_lower; 
    1185                         } 
     1206                        this.groups[groups[g]] = {}; 
     1207                    } 
     1208                     
     1209                                this.groups[groups[g]][jid_lower] = jid_lower; 
    11861210                } 
    1187                 else 
    1188                 { 
    1189                         this.removeContact(jid); 
    1190                 } 
     1211        } 
     1212        else 
     1213        { 
     1214                this.removeContact(jid); 
    11911215        } 
    11921216    } 
     
    13141338        var jid_lower = barejid.toLowerCase(); 
    13151339         
    1316         if( barejid != loadIM.getUserCurrent().jid ) 
    1317         { 
    1318                         if( show != 'unavailable') 
    1319                         { 
    1320                     if (!this.roster[jid_lower]) 
    1321                                 { 
    1322                         this.addContact(barejid, 'not-in-roster'); 
    1323                     } 
    1324                     var presence = 
    1325                                 { 
    1326                         resource:resource, priority:priority, show:show, status:status 
    1327                     } 
    1328                      
    1329                                 if (!this.roster[jid_lower]['presence']) 
    1330                                 { 
    1331                         this.roster[jid_lower]['presence'] = {} 
    1332                     } 
    1333                     this.roster[jid_lower]['presence'][resource] = presence 
    1334                 } 
    1335                         else if (this.roster[jid_lower] && this.roster[jid_lower]['presence'] && this.roster[jid_lower]['presence'][resource]) 
    1336                         { 
    1337                     delete this.roster[jid_lower]['presence'][resource]; 
    1338                 } 
    1339                  
    1340                         this.addChange(jid_lower); 
    1341                  
    1342                         if (TrophyIM.activeChats['divs'][jid_lower]) 
    1343                         { 
    1344                     TrophyIM.setTabPresence(jid_lower, TrophyIM.activeChats['divs'][jid_lower]['tab']); 
    1345                 } 
    1346         } 
     1340                if( show != 'unavailable') 
     1341                { 
     1342            if (!this.roster[jid_lower]) 
     1343                        { 
     1344                this.addContact(barejid, 'not-in-roster'); 
     1345            } 
     1346            var presence = 
     1347                        { 
     1348                resource:resource, priority:priority, show:show, status:status 
     1349            } 
     1350             
     1351                        if (!this.roster[jid_lower]['presence']) 
     1352                        { 
     1353                this.roster[jid_lower]['presence'] = {} 
     1354            } 
     1355            this.roster[jid_lower]['presence'][resource] = presence 
     1356        } 
     1357                else if (this.roster[jid_lower] && this.roster[jid_lower]['presence'] && this.roster[jid_lower]['presence'][resource]) 
     1358                { 
     1359            delete this.roster[jid_lower]['presence'][resource]; 
     1360        } 
     1361         
     1362                this.addChange(jid_lower); 
    13471363    } 
    13481364 
  • sandbox/jabberit_messenger/trophy_expresso/xsl/chatBox.xsl

    r2437 r2511  
    1313                                <div style="margin:2px;"> 
    1414                                        <textarea id="{$jidTo}__sendBox" class="trophyimchatinput" style="padding-left: 78px; height:130px; width:360px;"></textarea> 
    15                                         <div style="position:relative;margin:-126px 0 0 3px;width:60px ;height:80px ;background-image:url('{$path_jabberit}templates/default/images/photo.png');"></div> 
    16                                          
     15                                        <div id="{$jidTo}__photo" style="position:relative;margin:-126px 0 0 3px;width:60px ;height:80px ;background-image:url('{$path_jabberit}templates/default/images/photo.png');" /> 
    1716                                        <div style="margin: 5px;"> 
    1817                                                <input type="button" value="Send" onclick="TrophyIM.sendMessage('{$jidTo}')"/> 
  • sandbox/jabberit_messenger/trophy_expresso/xsl/contactsList.xsl

    r2491 r2511  
    33        <xsl:output method="html" omit-xml-declaration="yes"/> 
    44         
     5        <xsl:param name="idUser"/> 
     6        <xsl:param name="full_name" /> 
    57        <xsl:param name="path_jabberit" /> 
    6         <xsl:param name="full_name" /> 
     8        <xsl:param name="zIndex_" /> 
    79         
    810        <xsl:template match="contacts_list"> 
    911                 
    1012                <fieldset style="margin:2px; border:1px dotted #000000; height: 90px;"> 
    11                         <div style="margin:0px; width:60px; height:80px; background-image:url('{$path_jabberit}/templates/default/images/photo.png');"/> 
    12                          
     13                        <div id="{$idUser}__photo" style="margin:0px; width:60px; height:80px; background-image:url('{$path_jabberit}/templates/default/images/photo.png');"/> 
    1314                        <div style="position: absolute; margin-top: -19px; margin-left: 75px; cursor: pointer;" onclick="loadIM.setPresence(this);"> 
    1415                                <div id="statusJabberImg" style="background-image: url('{$path_jabberit}/templates/default/images/available.gif'); margin-left: 13px;width:15px; height:15px;"></div> 
     
    2526                </fieldset> 
    2627                                 
    27                 <div id="JabberIMRoster" style="margin-top:3px;overflow-y: auto; height: 267px;"></div> 
     28                <div id="JabberIMRoster" style="margin-top:3px;overflow-y: auto; height: 267px; z-index:{$zIndex_};"></div> 
    2829                  
    2930        </xsl:template> 
Note: See TracChangeset for help on using the changeset viewer.