source: trunk/expressoAdmin1_2/inc/class.uimanagers.inc.php @ 63

Revision 63, 25.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        /************************************************************************************\
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 uimanagers
13        {
14                var $public_functions = array
15                (
16                        'list_managers'         => True,
17                        'add_managers'          => True,
18                        'delete_managers'       => True,
19                        'edit_managers'         => True,
20                        'validate'                      => True
21                );
22
23                var $functions;
24                var $config;
25
26                function uimanagers()
27                {
28                        $this->functions = CreateObject('expressoAdmin1_2.functions');
29                        $c = CreateObject('phpgwapi.config','expressoAdmin1_2');
30                        $c->read_repository();
31                        $this->config = $c->config_data;
32                }
33
34                function row_action($lang,$link,$manager_lid,$context)
35                {       
36                        return '<a href="'.$GLOBALS['phpgw']->link('/index.php',Array(
37                                'menuaction' => 'expressoAdmin1_2.uimanagers.'.$link,
38                                'action'                =>      $lang,
39                                'manager_lid' => $manager_lid,
40                                'context' => $context
41                        )).'" onmouseover="window.status=\''.lang($lang).' Manager\'; return true;" onmouseout="window.status=\'\';" >'.lang($lang).' </a>';
42                }
43                               
44                function list_managers()
45                {
46                        // Caso nao seja admin, sai.
47                        if ($GLOBALS['phpgw']->acl->check('group_access',1,'admin'))
48                        {
49                                $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/admin/index.php'));
50                        }
51                        // Imprime o NavBar
52                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
53                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('List Managers');
54                        $GLOBALS['phpgw']->common->phpgw_header();
55
56                        // Seta o template
57                        $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
58                        $p->set_file(array('managers' => 'managers.tpl'));
59                        $p->set_block('managers','body','body');
60                        $p->set_block('managers','row','row');
61                        $p->set_block('managers','row_empty','row_empty');
62
63                        $var = Array(
64                                'action'                        => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uimanagers.add_managers'),
65                                'tr_color'                      => '#DDDDDD',
66                                'th_bg'                 => $GLOBALS['phpgw_info']['theme']['th_bg'],
67                                'lang_add_manager'      => lang('Add Manager'),
68                                'lang_manager_lid'      => lang('Manager LID'),
69                                'lang_manager_cn'       => lang('Manager name'),
70                                'lang_context'          => lang('Context'),
71                                'lang_edit'             => lang('Edit'),
72                                'lang_delete'           => lang('Delete')
73                        );
74
75                        // le do banco de dados para pegar os administradors.
76                        $query = 'SELECT manager_lid,context FROM phpgw_expressoadmin ORDER by manager_lid';
77                        $GLOBALS['phpgw']->db->query($query);
78                        while($GLOBALS['phpgw']->db->next_record())
79                        {
80                                $managers[] = $GLOBALS['phpgw']->db->row();
81                        }
82                        $ldap_conn = $GLOBALS['phpgw']->common->ldapConnect();
83                        $justthese = array("cn");
84                        // Loop para listar os administradores
85                        if (count($managers))
86                        {
87                                foreach($managers as $array_managers)
88                                {
89                                        $filter="(&(phpgwAccountType=u)(uid=".$array_managers['manager_lid']."))";
90                                        $ldap_search = ldap_search($ldap_conn, $GLOBALS['phpgw_info']['server']['ldap_context'], $filter, $justthese);
91                                        $ldap_result = ldap_get_entries($ldap_conn, $ldap_search);
92                                        $p->set_var('manager_lid', $array_managers[manager_lid]);
93                                        $p->set_var('manager_cn', $ldap_result[0]['cn'][0] == '' ? '<font color=red>NAO ENCONTRADO NO LDAP</font>' : $ldap_result[0]['cn'][0]);
94                                        $p->set_var('context', $array_managers[context]);
95                                        $p->set_var('link_edit',$this->row_action('edit','edit_managers',$array_managers[manager_lid],$array_managers[context]));
96                                        $p->set_var('link_delete',$this->row_action('delete','delete_managers',$array_managers[manager_lid],$array_managers[context]));
97                                        $p->fp('rows','row',True);
98                                }
99                        }
100                        $p->set_var($var);
101                        $p->pfp('out','body');
102                        ldap_close($ldap_conn);
103                }
104
105
106                function add_managers()
107                {
108                        // Caso nao seja admin, sai.
109                        if ($GLOBALS['phpgw']->acl->check('group_access',1,'admin'))
110                        {
111                                $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/admin/index.php'));
112                        }
113                       
114                        // Seta o template
115                        $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
116                        $p->set_file(array('managers' => 'managers_form.tpl'));
117                        $p->set_block('managers','form','form');
118
119                        // Imprime o NavBar
120                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
121                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Add Managers');
122                        $GLOBALS['phpgw']->common->phpgw_header();
123                       
124                        // Seta variaveis javas necessárias
125                        $webserver_url = $GLOBALS['phpgw_info']['server']['webserver_url'];
126                        $scripts_java = '';
127                        $scripts_java .= '<script type="text/javascript" src="'.$webserver_url.'/expressoAdmin1_2/js/jscode/expressoadmin.js"></script>';
128                       
129                        // App, create list of available apps
130                        $this->nextmatchs = createobject('phpgwapi.nextmatchs');
131                        $apps = CreateObject('phpgwapi.applications',$_account_id);
132                        $db_perms = $apps->read_account_specific();
133                        $availableApps = $GLOBALS['phpgw_info']['apps'];
134                        uasort($availableApps,create_function('$a,$b','return strcasecmp($a["title"],$b["title"]);'));
135
136                        // Loop para criar dinamicamente uma tabela com 3 colunas, cada coluna com um aplicativo e um check box.
137                        $applications_list = '';
138                        $app_col1 = '';
139                        $app_col2 = '';
140                        $app_col3 = '';
141                        $total_apps = count($availableApps);
142                        $i = 0;
143                        foreach($availableApps as $app => $data)
144                        {
145                                // 1 coluna
146                                if (($i +1) % 3 == 1)
147                                {
148                                        if ($_POST['applications_list'][$app] == 1)
149                                                $checked = 'checked';
150                                        else
151                                                $checked = '';
152                                        $app_col1 = sprintf("<td>%s</td><td width='10'><input type='checkbox' name='applications_list[%s]' value='1' %s %s></td>\n",
153                                        $data['title'],$app,$checked, $disabled);
154                                       
155                                        if ($i == ($total_apps-1))
156                                                $applications_list .= sprintf('<tr bgcolor="%s">%s</tr>',$this->nextmatchs->alternate_row_color(), $app_col1);
157                                }
158                                // 2 coluna
159                                if (($i +1) % 3 == 2)
160                                {
161                                        if ($_POST['applications_list'][$app] == 1)
162                                                $checked = 'checked';
163                                        else
164                                                $checked = '';
165                                        $app_col2 = sprintf("<td>%s</td><td width='10'><input type='checkbox' name='applications_list[%s]' value='1' %s %s></td>\n",
166                                        $data['title'],$app,$checked, $disabled);
167                                       
168                                        if ($i == ($total_apps-1))
169                                                $applications_list .= sprintf('<tr bgcolor="%s">%s%s</tr>',$this->nextmatchs->alternate_row_color(), $app_col1,$app_col2);
170                                }
171                                // 3 coluna
172                                if (($i +1) % 3 == 0)
173                                {
174                                        if ($_POST['applications_list'][$app] == 1)
175                                                $checked = 'checked';
176                                        else
177                                                $checked = '';
178                                        $app_col3 = sprintf("<td>%s</td><td width='10'><input type='checkbox' name='applications_list[%s]' value='1' %s %s></td>\n",
179                                        $data['title'],$app,$checked, $disabled);
180                                       
181                                        // Cria nova linha
182                                        $applications_list .= sprintf('<tr bgcolor="%s">%s%s%s</tr>',$this->nextmatchs->alternate_row_color(), $app_col1, $app_col2, $app_col3);                                       
183                                }
184                                $i++;
185                        }
186                               
187                        // Seta variaveis que estao no TPL
188                        $var = Array(
189                                'scripts_java'                  =>      $scripts_java, 
190                                'action'                                => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uimanagers.validate'),
191                                'display_samba_suport'  => $this->config['expressoAdmin_samba_support'] == 'true' ? '' : 'display:none',
192                               
193                                'type'                                  => "add",
194                                'color_bg1'                             => "#E8F0F0",
195                                'color_bg2'                             => "#D3DCE3",
196                                'color_font1'                   => "#DDDDDD",
197                                'color_font2'                   => "#EEEEEE",
198                                'lang_back'                                             => lang('Back'),
199                                'lang_add_save_manager'                 => lang('Add Manager'),
200                                'lang_manager_lid'                              => lang('Manager LID'),
201                                'lang_context'                                  => lang('Context'),
202                                'lang_type_access'                              => lang('Tipo de acessos'),
203                                'lang_add_users'                                => lang('Add users'),
204                                'lang_edit_users'                               => lang('Edit users'),
205                                'lang_delete_users'                             => lang('Delete users'),
206                                'lang_view_users'                               => lang('View user'),
207                                'lang_rename_user'                              => lang('Rename users'),
208                                'lang_view_user'                                => lang('View users'),
209                                'lang_manipulate_corporative_information' => lang('Manipulate corporative information'),
210                                'lang_add_groups'                               => lang('Add groups'),
211                                'lang_edit_groups'                              => lang('Edit groups'),
212                                'lang_delete_groups'                    => lang('Delete groups'),
213                                'lang_edit_email_attribute_from_the_groups'     =>      lang('Edit email attribute from the groups'),
214                                'lang_change_user_password'             => lang('Change users password'),
215                                'lang_change_users_quote'               => lang('Change users quote'),
216                                'lang_set_user_default_password'=> lang('Set default users password'),
217                                'lang_empty_user_inbox'                 => lang('Empty user inbox'),
218                                'lang_edit_sambausers_attributes'=> lang('Edit SAMBA users attributes'),
219                                'lang_edit_sambadomains'                => lang('Edit SAMBA domains'),
220                                'lang_add_email_lists'                  => lang('Add email lists'),
221                                'lang_edit_email_lists'                 => lang('Edit email lists'),
222                                'lang_delete_email_lists'               => lang('Delete email lists'),
223                                'lang_view_email_lists'                 => lang('View email lists'),
224                                'lang_create_orgs'                              => lang('Create Organizations'),
225                                'lang_edit_orgs'                                => lang('Edit Organizations'),
226                                'lang_delete_orgs'                              => lang('Delete Organizations'),
227                                'lang_view_global_sessions'             => lang('View sessions (global)'),
228                                'lang_view_logs'                                => lang('View logs'),
229                                'lang_create_computers'                 => lang('Create computers'),
230                                'lang_edit_computers'                   => lang('Edit computers'),
231                                'lang_delete_computers'                 => lang('Delete computers'),
232                                'error_messages'                                => $_POST['error_messages'] == '' ? '' : '<script language="JavaScript1.3">alert("'.$_POST['error_messages'].'");</script>',
233                                'manager_lid'                                   => $_POST['manager_lid'],
234                                'context'                                               => $_POST['context'],
235                                'add_users'                                     => $_POST['add_users'] != '' ? 'checked' : '',
236                                'edit_users'                                    => $_POST['edit_users'] != '' ? 'checked' : '',
237                                'view_users'                                    => $_POST['view_users'] != '' ? 'checked' : '',
238                                'manipulate_corporative_information' => $_POST['manipulate_corporative_information'] != '' ? 'checked' : '',
239                                'delete_users'                                  => $_POST['delete_users'] != '' ? 'checked' : '',
240                                'add_groups'                                    => $_POST['add_groups'] != '' ? 'checked' : '',
241                                'edit_groups'                                   => $_POST['edit_groups'] != '' ? 'checked' : '',
242                                'delete_groups'                                 => $_POST['delete_groups'] != '' ? 'checked' : '',
243                                'change_users_password'                 => $_POST['change_users_password'] != '' ? 'checked' : '',
244                                'change_users_quote'                    => $_POST['change_users_quote'] != '' ? 'checked' : '',
245                                'set_user_default_password'             => $_POST['set_user_default_password'] != '' ? 'checked' : '',
246                                'edit_sambausers_attributes'    => $_POST['edit_sambausers_attributes'] != '' ? 'checked' : '',
247                                'edit_sambadomains'                             => $_POST['edit_sambadomains'] != '' ? 'checked' : '',
248                                'add_maillists'                                 => $_POST['add_maillists'] != '' ? 'checked' : '',
249                                'edit_maillists'                                => $_POST['edit_maillists'] != '' ? 'checked' : '',
250                                'delete_maillists'                              => $_POST['delete_maillists'] != '' ? 'checked' : '',
251                                'create_sectors'                                => $_POST['create_sectors'] != '' ? 'checked' : '',
252                                'edit_sectors'                                  => $_POST['edit_sectors'] != '' ? 'checked' : '',
253                                'delete_sectors'                                => $_POST['delete_sectors'] != '' ? 'checked' : '',
254                                'view_global_sessions'                  => $_POST['view_global_sessions'] != '' ? 'checked' : '',
255                                'view_logs'                                             => $_POST['view_logs'] != '' ? 'checked' : '',
256
257                                'app_list'                                              => $applications_list
258                        );
259                        $p->set_var($var);
260                        echo $p->fp('out','form');
261                }
262       
263                function delete_managers()
264                {
265                        // Criar uma verificação e jogar a query para o BO.
266                        $context = $_GET['context'];
267                        $manager_lid = $_GET['manager_lid'];
268                       
269                        $query = "DELETE FROM phpgw_expressoadmin WHERE manager_lid = '".$manager_lid."' AND context = '" . $context ."'";
270                        $GLOBALS['phpgw']->db->query($query);
271                       
272                        // Remove Gerente da tabela dos apps
273                        $query = "DELETE FROM phpgw_expressoadmin_apps WHERE "
274                        . "manager_lid = '".$manager_lid."' AND "
275                        . "context = '".$context."'";
276                        $GLOBALS['phpgw']->db->query($query);           
277                       
278                        // Remove Gerente na ACL do expressoadmin
279                        $accounts = CreateObject('phpgwapi.accounts');
280                        $manager_id = $accounts->name2id($_GET['manager_lid']);
281                        $sql = "DELETE FROM phpgw_acl WHERE acl_appname = 'expressoadmin' AND acl_account = '" . $manager_id . "'";
282                        $GLOBALS['phpgw']->db->query($sql);                     
283                       
284                        ExecMethod('expressoAdmin1_2.uimanagers.list_managers');
285                }
286       
287                function edit_managers()
288                {
289                        // Caso nao seja admin, sai.
290                        if ($GLOBALS['phpgw']->acl->check('group_access',1,'admin'))
291                        {
292                                $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/admin/index.php'));
293                        }
294                       
295                        // Verifica se eh a primeira entrada, ai eu tenho o get, senao pego o post.
296                        if ($_GET['manager_lid'] != '')
297                        {
298                                $_POST['manager_lid']   = $_GET['manager_lid'];
299                                $_POST['context']               = $_GET['context'];
300                                $old_manager_lid                = $_GET['manager_lid'];
301                                $old_context                    = $_GET['context'];
302                                $first_time = true;
303                        }
304                        elseif ($_POST['manager_lid'] != '')
305                        {
306                                $old_manager_lid        = $_POST['old_manager_lid'];
307                                $old_context            = $_POST['old_context'];                               
308                                $first_time             = false;
309                        }
310                       
311                        if ($first_time)
312                        {
313                                //Pesquisa no Banco e pega os valores da ACL
314                                $query = "SELECT * FROM phpgw_expressoadmin WHERE manager_lid = '" . $_GET['manager_lid'] . "' AND context = '" . $_GET['context'] . "'";
315                                $GLOBALS['phpgw']->db->query($query);
316                                while($GLOBALS['phpgw']->db->next_record())
317                                {
318                                        $manager[] = $GLOBALS['phpgw']->db->row();
319                                }
320                       
321                                //Pesquisa no Banco e pega os valores dos apps.
322                                $query = "SELECT * FROM phpgw_expressoadmin_apps WHERE manager_lid = '" . $_GET['manager_lid'] . "' AND context = '" . $_GET['context'] . "'";
323                                $GLOBALS['phpgw']->db->query($query);
324                                $i=0;
325                                $manager[0]['apps'] = array();
326                                while($GLOBALS['phpgw']->db->next_record())
327                                {
328                                        $tmp[$i] = $GLOBALS['phpgw']->db->row();
329                                        $_POST['applications_list'][$tmp[$i]['app']] = 1;
330                                        $manager[0]['apps'][$tmp[$i]['app']] = 1;
331                                        $i++;
332                                }
333                       
334                                //Cria vetor da ACL
335                                $acl = $this->functions->make_array_acl($manager[0]['acl']);
336                                $_POST['add_users']                             = $acl['add_users'];
337                                $_POST['edit_users']                    = $acl['edit_users'];
338                                $_POST['delete_users']                  = $acl['delete_users'];
339                                $_POST['rename_users']                  = $acl['rename_users'];
340                                $_POST['view_users']                    = $acl['view_users'];
341                                $_POST['manipulate_corporative_information'] = $acl['manipulate_corporative_information'];
342                                $_POST['add_groups']                    = $acl['add_groups'];
343                                $_POST['edit_groups']                   = $acl['edit_groups'];
344                                $_POST['delete_groups']                 = $acl['delete_groups'];
345                                $_POST['edit_email_groups']             = $acl['edit_email_groups'];
346                                $_POST['change_users_password'] = $acl['change_users_password'];
347                                $_POST['change_users_quote']    = $acl['change_users_quote'];
348                                $_POST['set_user_default_password']     = $acl['set_user_default_password'];
349                                $_POST['empty_user_inbox']              = $acl['empty_user_inbox'];
350                                $_POST['edit_sambausers_attributes'] = $acl['edit_sambausers_attributes'];
351                                $_POST['edit_sambadomains']     = $acl['edit_sambadomains'];
352                                $_POST['add_maillists']                 = $acl['add_maillists'];
353                                $_POST['edit_maillists']                = $acl['edit_maillists'];
354                                $_POST['delete_maillists']              = $acl['delete_maillists'];
355                                $_POST['create_sectors']                = $acl['create_sectors'];
356                                $_POST['edit_sectors']                  = $acl['edit_sectors'];
357                                $_POST['delete_sectors']                = $acl['delete_sectors'];
358                                $_POST['create_computers']              = $acl['create_computers'];
359                                $_POST['edit_computers']                = $acl['edit_computers'];
360                                $_POST['delete_computers']              = $acl['delete_computers'];
361                                $_POST['view_global_sessions']  = $acl['view_global_sessions'];
362                                $_POST['view_logs']                             = $acl['view_logs'];
363                        }
364                       
365                        // Seta o template
366                        $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
367                        //$accounts = CreateObject('phpgwapi.accounts');
368                        $p->set_file(array('managers' => 'managers_form.tpl'));
369                        $p->set_block('managers','form','form');
370                       
371                        // Imprime o NavBar
372                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
373                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Edit Managers');
374                        $GLOBALS['phpgw']->common->phpgw_header();
375
376                        // Seta variaveis javas necessárias
377                        $webserver_url = $GLOBALS['phpgw_info']['server']['webserver_url'];
378                        $scripts_java = '';
379                        $scripts_java .= '<script type="text/javascript" src="'.$webserver_url.'/expressoAdmin1_2/js/jscode/expressoadmin.js"></script>';
380
381                        // App, create list of available apps
382                        $this->nextmatchs = createobject('phpgwapi.nextmatchs');
383                        $apps = CreateObject('phpgwapi.applications',$_account_id);
384                        $db_perms = $apps->read_account_specific();
385                        $availableApps = $GLOBALS['phpgw_info']['apps'];
386                       
387                        uasort($availableApps,create_function('$a,$b','return strcasecmp($a["title"],$b["title"]);'));
388                       
389                        // Loop para criar dinamicamente uma tabela com 3 colunas, cada coluna com um aplicativo e um check box.
390                        $applications_list = '';
391                        $app_col1 = '';
392                        $app_col2 = '';
393                        $app_col3 = '';
394                        $total_apps = count($availableApps);
395                        $i = 0;
396
397                        foreach($availableApps as $app => $data)
398                        {
399                                // 1 coluna
400                                if (($i +1) % 3 == 1)
401                                {
402                                        if ($_POST['applications_list'][$app] == 1)
403                                                $checked = 'checked';
404                                        else
405                                                $checked = '';
406                                        $app_col1 = sprintf("<td>%s</td><td width='10'><input type='checkbox' name='applications_list[%s]' value='1' %s %s></td>\n",
407                                        $data['title'],$app,$checked, $disabled);
408                                       
409                                        if ($i == ($total_apps-1))
410                                                $applications_list .= sprintf('<tr bgcolor="%s">%s</tr>',$this->nextmatchs->alternate_row_color(), $app_col1);
411                                }
412                                // 2 coluna
413                                if (($i +1) % 3 == 2)
414                                {
415                                        if ($_POST['applications_list'][$app] == 1)
416                                                $checked = 'checked';
417                                        else
418                                                $checked = '';
419                                        $app_col2 = sprintf("<td>%s</td><td width='10'><input type='checkbox' name='applications_list[%s]' value='1' %s %s></td>\n",
420                                        $data['title'],$app,$checked, $disabled);
421                                       
422                                        if ($i == ($total_apps-1))
423                                                $applications_list .= sprintf('<tr bgcolor="%s">%s%s</tr>',$this->nextmatchs->alternate_row_color(), $app_col1,$app_col2);
424                                }
425                                // 3 coluna
426                                if (($i +1) % 3 == 0)
427                                {
428                                        if ($_POST['applications_list'][$app] == 1)
429                                                $checked = 'checked';
430                                        else
431                                                $checked = '';
432                                        $app_col3 = sprintf("<td>%s</td><td width='10'><input type='checkbox' name='applications_list[%s]' value='1' %s %s></td>\n",
433                                        $data['title'],$app,$checked, $disabled);
434                                       
435                                        // Cria nova linha
436                                        $applications_list .= sprintf('<tr bgcolor="%s">%s%s%s</tr>',$this->nextmatchs->alternate_row_color(), $app_col1, $app_col2, $app_col3);                                       
437                                }
438                                $i++;
439                        }
440
441                        $var = Array(
442                                'scripts_java' => $scripts_java,
443                                'action' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uimanagers.validate'),
444                                'display_samba_suport'  => $this->config['expressoAdmin_samba_support'] == 'true' ? '' : 'display:none',
445                                'color_bg1'     => "#E8F0F0",
446                                'color_bg2'     => "#D3DCE3",
447                                'color_font1'   => "#DDDDDD",
448                                'color_font2'   => "#EEEEEE",
449                                'type'                  => "edit",
450                                'lang_back'                                             => lang('Back'),
451                                'lang_add_save_manager'                 => lang('Save'),
452                                'lang_manager_lid'                              => lang('Manager LID'),
453                                'lang_context'                                  => lang('Contexto'),
454                                'lang_type_access'                              => lang('Tipo de acessos'),
455                                'lang_add_users'                                => lang('Add users'),
456                                'lang_edit_users'                               => lang('Edit users'),
457                                'lang_delete_users'                             => lang('Delete users'),
458                                'lang_view_users'                               => lang('View users'),
459                                'lang_rename_user'                              => lang('Rename users'),
460                                'lang_view_user'                                => lang('View users'),
461                                'lang_manipulate_corporative_information' => lang('Manipulate corporative information'),
462                                'lang_add_groups'                               => lang('Add groups'),
463                                'lang_edit_groups'                              => lang('Edit groups'),
464                                'lang_delete_groups'                    => lang('Delete groups'),
465                                'lang_edit_email_attribute_from_the_groups'     =>      lang('Edit email attribute from the groups'),
466                                'lang_change_user_password'             => lang('Change users password'),
467                                'lang_change_users_quote'               => lang('Change users quote'),
468                                'lang_set_user_default_password'=> lang('Set default user password'),
469                                'lang_empty_user_inbox'                 => lang('Empty user inbox'),
470                                'lang_edit_sambausers_attributes'=> lang('Edit SAMBA users attributes'),
471                                'lang_edit_sambadomains'                => lang('Edit SAMBA domains'),
472                                'lang_add_email_lists'                  => lang('Add email lists'),
473                                'lang_edit_email_lists'                 => lang('Edit email lists'),
474                                'lang_delete_email_lists'               => lang('Delete email lists'),
475                                'lang_view_email_lists'                 => lang('View email lists'),
476                                'lang_create_orgs'                              => lang('Create Organizations'),
477                                'lang_edit_orgs'                                => lang('Edit Organizations'),
478                                'lang_delete_orgs'                              => lang('Delete Organizations'),
479                                'lang_view_sessions'                    => lang('View sessions (local)'),
480                                'lang_view_global_sessions'             => lang('View sessions (global)'),
481                                'lang_view_logs'                                => lang('View Logs'),
482                                'lang_create_computers'                 => lang('Create computers'),
483                                'lang_edit_computers'                   => lang('Edit computers'),
484                                'lang_delete_computers'                 => lang('Delete computers'),                           
485                                'error_messages'                                => $_POST['error_messages'] == '' ? '' : '<script language="JavaScript1.3">alert("'.$_POST['error_messages'].'");</script>',
486                                'manager_lid'                                   => $_POST['manager_lid'],
487                                'context'                                               => $_POST['context'],
488                                'add_users'                                     => $_POST['add_users'] != '' ? 'checked' : '',
489                                'edit_users'                                    => $_POST['edit_users'] != '' ? 'checked' : '',
490                                'delete_users'                                  => $_POST['delete_users'] != '' ? 'checked' : '',
491                                'rename_users'                                  => $_POST['rename_users'] != '' ? 'checked' : '',
492                                'view_users'                                    => $_POST['view_users'] != '' ? 'checked' : '',
493                                'manipulate_corporative_information' => $_POST['manipulate_corporative_information'] != '' ? 'checked' : '',
494                                'add_groups'                                    => $_POST['add_groups'] != '' ? 'checked' : '',
495                                'edit_groups'                                   => $_POST['edit_groups'] != '' ? 'checked' : '',
496                                'delete_groups'                                 => $_POST['delete_groups'] != '' ? 'checked' : '',
497                                'edit_email_groups'                             => $_POST['edit_email_groups'] != '' ? 'checked' : '',
498                                'change_users_password'                 => $_POST['change_users_password'] != '' ? 'checked' : '',
499                                'change_users_quote'                    => $_POST['change_users_quote'] != '' ? 'checked' : '',
500                                'set_user_default_password'             => $_POST['set_user_default_password'] != '' ? 'checked' : '',
501                                'empty_user_inbox'                              => $_POST['empty_user_inbox'] != '' ? 'checked' : '',
502                                'edit_sambausers_attributes'    => $_POST['edit_sambausers_attributes'] != '' ? 'checked' : '',
503                                'edit_sambadomains'                             => $_POST['edit_sambadomains'] != '' ? 'checked' : '',
504                                'add_maillists'                                 => $_POST['add_maillists'] != '' ? 'checked' : '',
505                                'edit_maillists'                                => $_POST['edit_maillists'] != '' ? 'checked' : '',
506                                'delete_maillists'                              => $_POST['delete_maillists'] != '' ? 'checked' : '',
507                                'create_sectors'                                => $_POST['create_sectors'] != '' ? 'checked' : '',
508                                'edit_sectors'                                  => $_POST['edit_sectors'] != '' ? 'checked' : '',
509                                'delete_sectors'                                => $_POST['delete_sectors'] != '' ? 'checked' : '',
510                                'create_computers'                              => $_POST['create_computers'] != '' ? 'checked' : '',
511                                'edit_computers'                                => $_POST['edit_computers'] != '' ? 'checked' : '',
512                                'delete_computers'                              => $_POST['delete_computers'] != '' ? 'checked' : '',
513                                'view_sessions'                                 => $_POST['view_sessions'] != '' ? 'checked' : '',
514                                'view_global_sessions'                  => $_POST['view_global_sessions'] != '' ? 'checked' : '',
515                                'view_logs'                                             => $_POST['view_logs'] != '' ? 'checked' : '',
516                               
517                                // Para o update no banco, preciso saber oq foi alterado e para que.
518                                // Talvez so o manager e o contexto.
519                                'old_manager_lid'       => $old_manager_lid,
520                                'old_context'           => $old_context,
521                                'app_list'                      => $applications_list
522                        );
523                        $p->set_var($var);
524                        echo $p->fp('out','form');
525                }
526               
527                function validate()
528                {       
529                        $accounts = CreateObject('phpgwapi.accounts');
530                        $errors = array();
531                       
532                        // verifica se o manager existe. caso retorne 1 existe e eh uma conta de usuario.
533                        $manager_lid_exists = $accounts->exists($_POST['manager_lid']);
534                        if ($manager_lid_exists != 1)
535                        {
536                                $_POST['error_messages'] = lang("Manager LID don't exist.");
537                                if ($_POST['type'] == 'add')   
538                                        $this->add_managers();
539                                elseif ($_POST['type'] == 'edit')
540                                        $this->edit_managers();
541                                return;
542                        }
543                       
544                        // Verifica se o contexto existe.
545                        $dn                     = $GLOBALS['phpgw_info']['server']['ldap_root_dn'];
546                        $passwd         = $GLOBALS['phpgw_info']['server']['ldap_root_pw'];
547                        $ldap_conn      = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']);
548                        ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3);
549                        ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0);
550                        ldap_bind($ldap_conn,$dn,$passwd);
551                       
552                        $sr=@ldap_list($ldap_conn, $_POST['context'], "cn=*");
553                        if (!$sr)
554                        {
555                                $_POST['error_messages'] = lang("Context don't exist.");                       
556                                ldap_close($ldap_conn);
557                                if ($_POST['type'] == 'add')   
558                                        $this->add_managers();
559                                elseif ($_POST['type'] == 'edit')
560                                        $this->edit_managers();
561                                return;
562                        }
563                       
564                        if ($_POST['type'] == 'add')
565                        {
566                                //Verifica se ja existe o manager com aquele contexto cadastrado
567                                $query = "SELECT manager_lid FROM phpgw_expressoadmin WHERE manager_lid = '" . $_POST['manager_lid'] . "' AND context = '" . $_POST['context'] . "'";                           
568                                $GLOBALS['phpgw']->db->query($query);
569                                $num_registros = 0;
570                                while($GLOBALS['phpgw']->db->next_record())
571                                {
572                                        $tmp[] = $GLOBALS['phpgw']->db->row();
573                                        $num_registros++;
574                                }
575                                if ($num_registros != 0)
576                                {
577                                        $_POST['error_messages'] = lang('Este Gerente, neste contexto já exite !!');
578                                        $this->add_managers();
579                                        return;
580                                }
581                        }
582                       
583                        if ($_POST['type'] == 'add')
584                                ExecMethod('expressoAdmin1_2.bomanagers.add_managers');
585                        elseif ($_POST['type'] == 'edit')
586                                ExecMethod('expressoAdmin1_2.bomanagers.edit_managers');
587                       
588                        return true;
589                }
590        }
591?>
Note: See TracBrowser for help on using the repository browser.