1 | <? |
---|
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 bomanagers |
---|
13 | { |
---|
14 | var $public_functions = array( |
---|
15 | 'add_managers' => True, |
---|
16 | 'edit_managers' => True |
---|
17 | ); |
---|
18 | |
---|
19 | function add_managers() |
---|
20 | { |
---|
21 | // Nao sendo Admin, sai |
---|
22 | if ($GLOBALS['phpgw']->acl->check('account_access',4,'admin')) |
---|
23 | { |
---|
24 | ExecMethod('admin.uiaccounts.list_users'); |
---|
25 | return false; |
---|
26 | } |
---|
27 | |
---|
28 | //Escrevre no Banco a ACL do gerente |
---|
29 | $sql = "INSERT INTO phpgw_expressoadmin (manager_lid, context, acl) " |
---|
30 | . "VALUES('" . $_POST['manager_lid'] . "','" . $_POST['context'] . "','" . $this->make_manager_acl($_POST) . "')"; |
---|
31 | $GLOBALS['phpgw']->db->query($sql); |
---|
32 | |
---|
33 | //Escrevre no Banco as aplicações que o gerente tem direito de disponibilizar aos seus usuarios. |
---|
34 | foreach($_POST['applications_list'] as $app=>$value) |
---|
35 | { |
---|
36 | $sql = "INSERT INTO phpgw_expressoadmin_apps (manager_lid, context, app) " |
---|
37 | . "VALUES('" . $_POST['manager_lid'] . "','" . $_POST['context'] . "','" . $app . "')"; |
---|
38 | $GLOBALS['phpgw']->db->query($sql); |
---|
39 | } |
---|
40 | |
---|
41 | //Retorna ao list managers |
---|
42 | ExecMethod('expressoAdmin1_2.uimanagers.list_managers'); |
---|
43 | return True; |
---|
44 | } |
---|
45 | |
---|
46 | function edit_managers() |
---|
47 | { |
---|
48 | // Nao sendo Admin, sai |
---|
49 | if ($GLOBALS['phpgw']->acl->check('account_access',4,'admin')) |
---|
50 | { |
---|
51 | ExecMethod('expressoAdmin1_2.uiaccounts.list_users'); |
---|
52 | return False; |
---|
53 | } |
---|
54 | |
---|
55 | //Executa update na tabela para atualizar ACL |
---|
56 | $sql = "UPDATE phpgw_expressoadmin SET manager_lid = '".$_POST['manager_lid'] |
---|
57 | . "',context = '".$_POST['context'] |
---|
58 | . "',acl = '" . $this->make_manager_acl($_POST) |
---|
59 | . "' WHERE manager_lid = '" . $_POST['old_manager_lid']."' AND context = '" . $_POST['old_context'] ."'"; |
---|
60 | $GLOBALS['phpgw']->db->query($sql); |
---|
61 | |
---|
62 | |
---|
63 | //Deleta as aplicações e adiciona as novas. |
---|
64 | //Deleta |
---|
65 | $sql = "DELETE FROM phpgw_expressoadmin_apps WHERE " |
---|
66 | . "manager_lid = '" . $_POST['old_manager_lid']."' AND " |
---|
67 | . "context = '" . $_POST['old_context']."'"; |
---|
68 | $GLOBALS['phpgw']->db->query($sql); |
---|
69 | |
---|
70 | // Adiciona |
---|
71 | if (count($_POST['applications_list'])) |
---|
72 | { |
---|
73 | foreach($_POST['applications_list'] as $app=>$value) |
---|
74 | { |
---|
75 | $sql = "INSERT INTO phpgw_expressoadmin_apps (manager_lid, context, app) " |
---|
76 | . "VALUES('" . $_POST['manager_lid'] . "','" . $_POST['context'] . "','" . $app . "')"; |
---|
77 | $GLOBALS['phpgw']->db->query($sql); |
---|
78 | } |
---|
79 | } |
---|
80 | |
---|
81 | // Retorna ao list managers |
---|
82 | ExecMethod('expressoAdmin1_2.uimanagers.list_managers'); |
---|
83 | return True; |
---|
84 | } |
---|
85 | |
---|
86 | function make_manager_acl($array_post) |
---|
87 | { |
---|
88 | $total_manager_acl = 0; |
---|
89 | foreach ($array_post as $atribute=>$value) |
---|
90 | { |
---|
91 | $acl = strstr($atribute, 'acl_'); |
---|
92 | |
---|
93 | if ($acl !== false) |
---|
94 | { |
---|
95 | $total_manager_acl += $value; |
---|
96 | } |
---|
97 | } |
---|
98 | return $total_manager_acl; |
---|
99 | } |
---|
100 | } |
---|
101 | ?> |
---|