source: trunk/instant_messenger/inc/class.contacts_im.inc.php @ 23

Revision 23, 1.7 KB checked in by niltonneto, 17 years ago (diff)

* empty log message *

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2
3require_once "class.ldap_im.inc.php";
4require_once "class.db_im.inc.php";
5
6class contacts_im
7{
8        private $ldap_users;
9        private $db_user;
10       
11        function __construct()
12        {
13                $this->ldap_users = new ldap_im();
14                $this->db_user = new db_im();           
15        }
16               
17        function list_contacts($param)
18        {
19                $org_ldap = $param['ou'];
20                $array_db = $this->db_user->get_accounts_acl();
21                $array_groups_ldap = array();
22                $j = 0;
23
24                for($i=0 ; $i < count($array_db); $i++)
25                        $array_1[] = $this->ldap_users->list_users_ldap($org_ldap,"uidNumber", $array_db[$i]['acl_account']);
26       
27                for($i=0; $i < count($array_1); $i++){
28                        if(array_key_exists("count",$array_1[$i])){
29                                $array_groups_ldap[] = $array_1[$i]['uidnumber'];
30                        }               
31                }
32               
33                for($i=0; $i < count($array_groups_ldap); $i++)
34                        $array_2[]['members'] = $this->ldap_users->list_groups_ldap($org_ldap,$array_groups_ldap[$i]);
35       
36                foreach($array_2 as $tmp){
37                        if($tmp['members'] > 0){
38                                foreach($tmp['members'] as $tmp1)       
39                                        $array_3[] = $tmp1;
40                        }
41                }
42               
43                for($i=0; $i < count($array_1); $i++)
44                        if($array_1[$i]['uid'] != "")
45                                $array_3[] = $array_1[$i]['uid'];
46       
47                @natsort($array_3);
48               
49                $array_4 = @array_values(@array_unique($array_3));
50
51                for($i=0; $i < count($array_4); $i++)
52                        $array_5[] = $this->ldap_users->list_users_ldap($org_ldap,"uid", $array_4[$i]);
53
54                for($i=0 ; $i < count($array_5); $i++){
55                        if($array_5[$i]['phpgwAccountVisible'] != "-1"){
56                                $array_6[] = $array_5[$i]['cn'] . ";" . $array_5[$i]['mail'];
57                        }
58                }
59
60                sort($array_6);
61               
62                for($i=0; $i < count($array_6); $i++){
63                        $aux = explode(";", $array_6[$i]);
64                        $array_7[$j]['cn'] = $aux[0];
65                        $array_7[$j]['mail'] = $aux[1];                 
66                        $j++;
67                }
68               
69                if(count($array_7) > 0)
70                        return $array_7;
71                else
72                        return false;
73        }
74}
75?>
Note: See TracBrowser for help on using the repository browser.