source: sandbox/jabberit_messenger/trophy_expresso/inc/WebService.php @ 2511

Revision 2511, 2.6 KB checked in by alexandrecorreia, 14 years ago (diff)

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

  • Property svn:executable set to *
Line 
1<?php
2  /***************************************************************************\
3  *  Expresso - Expresso Messenger                                            *
4  *     - Alexandre Correia / Rodrigo Souza                                                               *
5  * ------------------------------------------------------------------------- *
6  *  This program is free software; you can redistribute it and/or modify it  *
7  *  under the terms of the GNU General Public License as published by the    *
8  *  Free Software Foundation; either version 2 of the License, or (at your   *
9  *  option) any later version.                                               *
10  \***************************************************************************/
11
12class WebService
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       
51        public final function getPhotoSession($pUid, $pOu)
52        {
53                $uid = $pUid;
54                if( strpos($pUid, "@") )
55                        $uid = substr($pUid, 0, strpos($pUid, "@"));
56               
57                if( isset($_SESSION['phpgw_info']['jabberit_messenger']['photo'][$pOu][$uid]) )
58                {
59                        $photo = imagecreatefromstring($_SESSION['phpgw_info']['jabberit_messenger']['photo'][$pOu][$uid]);
60
61                        header("Content-Type: image/jpeg");
62                        $width = imagesx($photo);
63                        $height = imagesy($photo);
64                        $twidth = 60;
65                        $theight = 80;
66                        $small_photo = imagecreatetruecolor ($twidth, $theight);
67                        imagecopyresampled($small_photo, $photo, 0, 0, 0, 0,$twidth, $theight, $width, $height);
68                        imagejpeg($small_photo,'',100);
69
70                        unset($_SESSION['phpgw_info']['jabberit_messenger']['photo'][$pOu][$uid]);
71
72                        return;
73                }
74        }
75}
76
77// Photo in Session
78if(trim($_REQUEST['photo_session']) != "")
79{
80        $obj    = new WebService();
81        $ou             = $_REQUEST['ou'];
82        $jid    = $_REQUEST['photo_session'];
83       
84        $obj->getPhotoSession($jid, $ou);
85}
86
87// Photo Ldap
88if(trim($_REQUEST['photo_ldap']))
89{
90        $obj    = new WebService();
91        $jid    = $_REQUEST['photo_ldap'];
92        $obj->getPhoto($jid);
93}
94
95?>
Note: See TracBrowser for help on using the repository browser.