source: trunk/jabberit_messenger/inc/class.contacts_im.inc.php @ 417

Revision 417, 2.7 KB checked in by niltonneto, 16 years ago (diff)

Vide changelog do módulo.
http://www.expressolivre.org/dev/wiki/jabberit/changelog
Alterações feitas por Alexandre Correia
email: alexandrecorreia@…

  • Property svn:executable set to *
Line 
1<?php
2  /***************************************************************************\
3  *  Expresso - Expresso Messenger                                            *
4  *     - Alexandre Correia / Rodrigo Souza                                                               *
5  *     - JETI - http://jeti-im.org/                                                                              *
6  * ------------------------------------------------------------------------- *
7  *  This program is free software; you can redistribute it and/or modify it  *
8  *  under the terms of the GNU General Public License as published by the    *
9  *  Free Software Foundation; either version 2 of the License, or (at your   *
10  *  option) any later version.                                               *
11  \***************************************************************************/
12
13
14require_once "class.ldap_im.inc.php";
15require_once "class.db_im.inc.php";
16
17class contacts_im
18{
19        private $ldap;
20        private $db;
21       
22        public final function __construct()
23        {
24                $this->ldap = new ldap_im();
25                $this->db = new db_im();               
26        }
27
28        private final function users_auth_im($pName)
29        {   
30        $array_uids = $this->db->get_accounts_acl();
31        $count = count($array_uids);
32        $uids_members = array();
33       
34        for($i = 0; $i < $count ;$i+=50)
35        {   
36            $partial_uids = array_slice($array_uids,$i,50);
37            $filter_uid = implode(")(uidnumber=",$partial_uids);
38            $filter_uid = "(uidnumber=". $filter_uid. ")";
39            $result = $this->ldap->list_users_ldap("cn=*".$pName."*", $filter_uid);
40            if ( is_array($result) )
41                $uids_members = array_merge($uids_members,$result);                         
42               
43                if(count($uids_members) > 50){
44                        unset($_SESSION['phpgw_info']['jabberit_messenger']['photo']);         
45                        return 'Many Results';
46                }           
47        }
48        if(count($uids_members) > 0)
49            return $uids_members;
50        else
51            return 0;   
52        }
53               
54        public final function list_contacts($param)
55        {
56                $users  = $this->users_auth_im($param['name']);
57                $order  = array();
58
59                if (!is_array($users) && trim($users) === 'Many Results')
60                        return "<error>Many Results</error>";
61
62                if( is_array($users) )
63                {       
64                        foreach($users as $tmp)
65                        {
66                                if ( !array_key_exists($tmp['dn'], $order) )
67                                        $order[$tmp['dn']] = array();
68
69                                $order[$tmp['dn']][] = '<data><cn>' . $tmp['cn'] . '</cn><mail>' . $tmp['mail'] .'</mail><uid>' . $tmp['uid'] . '</uid><photo>' . $tmp['photo'] . '</photo></data>';
70                        }
71                       
72                        ksort($order);
73                               
74                        $return = '<uids>';
75                        foreach ( $order as $key => $val )
76                                $return .= '<'.$key.'>'.implode('',$val).'</'.$key.'>';
77                        $return .= '</uids>';
78                }
79                else
80                        $return = '<empty/>';
81               
82                return $return;
83        }
84}
85?>
Note: See TracBrowser for help on using the repository browser.