source: trunk/expressoAdmin1_2/inc/class.sosectors.inc.php @ 493

Revision 493, 4.5 KB checked in by niltonneto, 16 years ago (diff)

Correção de tradução

  • Property svn:eol-style set to native
  • Property svn:executable set to *
RevLine 
[2]1<?php
2        /**********************************************************************************\
3        * Expresso Administração                                                                                                *
4        * by Joao Alfredo Knopik Junior (joao.alfredo@gmail.com, jakjr@celepar.pr.gov.br)   *
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
12        class sosectors
13        {
14                var $functions;
[396]15                var $ldap_connection;
[471]16                var $db_functions;
[2]17               
18                function sosectors()
19                {
20                        $this->functions = createobject('expressoAdmin1_2.functions');
[471]21                        $this->db_functions = CreateObject('expressoAdmin1_2.db_functions');
[396]22                       
23                        if ( (!empty($GLOBALS['phpgw_info']['server']['ldap_master_host'])) &&
24                                 (!empty($GLOBALS['phpgw_info']['server']['ldap_master_root_dn'])) &&
25                                 (!empty($GLOBALS['phpgw_info']['server']['ldap_master_root_pw'])) )
26                        {
27                                $this->ldap_connection = $GLOBALS['phpgw']->common->ldapConnect($GLOBALS['phpgw_info']['server']['ldap_master_host'],
28                                                                                                   $GLOBALS['phpgw_info']['server']['ldap_master_root_dn'],
29                                                                                                   $GLOBALS['phpgw_info']['server']['ldap_master_root_pw']);
30                        }
31                        else
32                        {
33                                $this->ldap_connection = $GLOBALS['phpgw']->common->ldapConnect();
34                        }
[2]35                }
36               
37                function exist_sector_name($sector_name, $context)
38                {
[396]39                        $search = ldap_list($this->ldap_connection, $context, "ou=" . $sector_name);
40                        $result = ldap_get_entries($this->ldap_connection, $search);
[2]41                       
42                        if ($result['count'] == 0)
43                                return false;
44                        else
45                                return true;
46                }
47               
48                function write_ldap($dn, $info)
49                {
[396]50                        if (ldap_add($this->ldap_connection, $dn, $info))
[2]51                        {
[414]52                                $this->db_functions->write_log("write on ldap", "$dn");
[396]53                                ldap_close($this->ldap_connection);
[2]54                                return true;
55                        }
56                        else
57                        {
[414]58                                echo lang('Error written in LDAP, function write_ldap');
[396]59                                ldap_close($this->ldap_connection);
[2]60                                return false;
61                        }
62                }
63               
64                function get_sector_users($context)
65                {
66                        $justthese = array("cn", "uidNumber", "uid");
67                        $filter="(&(phpgwAccountType=u)(uid=*))";
[396]68                        $search=ldap_search($this->ldap_connection, $context, $filter, $justthese);
69                        $result = ldap_get_entries($this->ldap_connection, $search);
[2]70                        return $result;
71                }
72               
73                function get_sector_groups($context)
74                {
75                        $justthese = array("cn", "gidnumber");
76                        $filter="(&(phpgwAccountType=g)(cn=*))";
[396]77                        $search=ldap_search($this->ldap_connection, $context, $filter, $justthese);
78                        $result = ldap_get_entries($this->ldap_connection, $search);
[2]79                        return $result;
80                }
81
82                function get_sector_subsectors($context)
83                {
84                        $justthese = array("ou");
85                        $filter="(objectClass=organizationalUnit)";
[396]86                        $search=ldap_search($this->ldap_connection, $context, $filter, $justthese);
87                        $result = ldap_get_entries($this->ldap_connection, $search);
[2]88                        return $result;
89                }
90               
91                function delete_sector_ldap_recursively($connection, $dn)
92                {
93                        //searching for sub entries
94                        $search=ldap_list($connection,$dn,"ObjectClass=organizationalUnit",array(""));
95                        $info = ldap_get_entries($connection, $search);
96                       
97                        for($i=0;$i<$info['count'];$i++)
98                        {
99                                //deleting recursively sub entries
100                                $result=$this->delete_sector_ldap_recursively($connection,$info[$i]['dn']);
101                                        if(!$result)
102                                        {
103                                                //return result code, if delete fails
104                                                return($result);
105                                        }
106                        }
107                        return(ldap_delete($connection,$dn));
108                }
[32]109               
110                function get_info($context)
111                {
112                        $filter="(objectClass=organizationalUnit)";
[396]113                        $search=ldap_search($this->ldap_connection, $context, $filter);
114                        $result = ldap_get_entries($this->ldap_connection, $search);
[32]115                        return $result;
116                }
117               
118                function add_attribute($dn, $info)
119                {
[396]120                        if (ldap_mod_add($this->ldap_connection, $dn, $info))
[32]121                        {
[396]122                                ldap_close($this->ldap_connection);
[32]123                                return true;
124                        }
125                        else
126                        {
[493]127                                echo lang('Error written in LDAP, function add_attribute'). ldap_error($this->ldap_connection);
[396]128                                ldap_close($this->ldap_connection);
[32]129                                return false;
130                        }
131                }
132               
133                function remove_attribute($dn, $info)
134                {
[396]135                        if (ldap_mod_del($this->ldap_connection, $dn, $info))
[32]136                        {
[396]137                                ldap_close($this->ldap_connection);
[32]138                                return true;
139                        }
140                        else
141                        {
[493]142                                echo lang('Error written in LDAP, function remove_attribute'). ldap_error($this->ldap_connection);
[396]143                                ldap_close($this->ldap_connection);
[32]144                                return false;
145                        }
146                }
[2]147        }
148?>
Note: See TracBrowser for help on using the repository browser.