source: trunk/admin/inc/class.sovoip.inc.php @ 357

Revision 357, 3.6 KB checked in by niltonneto, 16 years ago (diff)

Adição da funcionalidade que permite liberar grupos do
Expresso para utilização do "Click do Dial" nos módulos.

  • Property svn:executable set to *
Line 
1<?php
2
3 /**************************************************************************\
4  * Expresso Livre - Voip - administration                                   *
5  *                                                                                                                                      *
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
13define('PHPGW_INCLUDE_ROOT', '../');
14define('PHPGW_API_INC','../phpgwapi/inc');
15require_once( PHPGW_API_INC . '/class.common.inc.php' );
16
17class sovoip
18{
19        private $db;
20        private $common;
21        private $ldap;
22        private $ldap_host;
23        private $ldap_root_dn;
24        private $ldap_root_pw;
25        private $ldap_context;
26
27        final function __construct()
28        {
29                $this->ldap_host         = $_SESSION['admin']['server']['ldap_host'];
30                $this->ldap_root_dn      = $_SESSION['admin']['server']['ldap_root_dn'];
31                $this->ldap_root_pw  = $_SESSION['admin']['server']['ldap_root_pw'];
32                $this->ldap_context  = $_SESSION['admin']['server']['ldap_context'];
33                $this->common = new common();
34        }
35
36        final function __destruct()
37        {
38                if( $this->ldap )
39                        ldap_close($this->ldap);
40        }
41
42        public final function getOuLdap()
43        {
44                $this->ldap = $this->common->ldapConnect();
45               
46                if ( $this->ldap )     
47                {
48                        $filter = "ou=*";
49                        $justthese = array("ou");
50                        $search = ldap_list($this->ldap, $this->ldap_context, $filter, $justthese);
51                        $entry = ldap_get_entries($this->ldap, $search);
52                }
53
54                if( $entry )
55                {
56                        foreach($entry as $tmp)
57                                if( $tmp['ou'][0] != "" )
58                                        $result_ou[] = $tmp['ou'][0];
59                }
60               
61                natcasesort($result_ou);
62
63                return (($result_ou) ? $result_ou : '');
64        }       
65
66        public final function getGroupsLdap($pOrg)
67        {
68                $organization = 'ou=' . $pOrg['ou'] .",". $this->ldap_context;
69               
70                $this->ldap = $this->common->ldapConnect($this->ldap_host,$this->ldap_root_dn,$this->ldap_root_pw);
71               
72                if( $this->ldap )       
73                {
74                        $filter = "(&(phpgwAccountType=g)(objectClass=posixGroup))";
75                        $justthese = array("cn");
76                        $search = ldap_list($this->ldap, $organization, $filter, $justthese);
77                        $entry = ldap_get_entries( $this->ldap, $search );
78
79                        if( $entry )
80                        {
81                                foreach($entry as $tmp)
82                                        if( $tmp['cn'][0] != "" )
83                                                $result_groups[] = $tmp['cn'][0];
84                        }
85                       
86                        natcasesort($result_groups);
87                }
88               
89                return (($result_groups) ? $result_groups : '');
90        }
91
92        public final function setConfDB($pConf)
93        {
94                $this->db = $GLOBALS['phpgw']->db;
95               
96                if( $this->db )
97                {
98                        foreach($pConf as $key => $tmp )
99                        {
100                                $query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' and config_name ='".trim($key)."'";
101                               
102                                $this->db->query($query);
103                                       
104                                if(!$this->db->next_record())
105                                {
106                                        $query = "INSERT INTO phpgw_config(config_app,config_name,config_value) VALUES('phpgwapi','".trim($key)."','".$tmp."')";
107                                        $this->db->query($query);
108                                }
109                                else
110                                {
111                                        $query = "UPDATE phpgw_config SET config_value = '".$tmp."' WHERE config_app = 'phpgwapi' AND config_name = '".trim($key)."'";
112                                        $this->db->query($query);
113                                }
114                        }
115                }       
116        }
117
118        public final function getConfDB()
119        {
120                $this->db = $GLOBALS['phpgw']->db;
121
122                if( $this->db )
123                {
124                        $query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' and config_name = 'voip_groups'";
125                       
126                        if(!$this->db->query($query))
127                                return null;
128                       
129                        while($this->db->next_record())
130                                $result[] = $this->db->row();           
131                }
132
133                return (($result) ? $result : '');             
134        }
135}
136?>
Note: See TracBrowser for help on using the repository browser.