source: trunk/expressoAdmin1_2/inc/class.uigroups.inc.php @ 2

Revision 2, 12.5 KB checked in by niltonneto, 17 years ago (diff)

Removida todas as tags usadas pelo CVS ($Id, $Source).
Primeira versão no CVS externo.

  • 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 uigroups
13        {
14                var $public_functions = array
15                (
16                        'list_groups'                           => True,
17                        'add_groups'                            => True,
18                        'edit_groups'                           => True,
19                        'css'                                           => True
20                );
21
22                var $nextmatchs;
23                var $group;
24                var $functions;
25                       
26                function uigroups()
27                {
28                        $this->group            = CreateObject('expressoAdmin1_2.group');
29                        $this->nextmatchs       = createobject('phpgwapi.nextmatchs');
30                        $this->functions        = CreateObject('expressoAdmin1_2.functions');
31                       
32                        $c = CreateObject('phpgwapi.config','expressoAdmin1_2');
33                        $c->read_repository();
34                        $this->current_config = $c->config_data;
35                       
36                        if(!@is_object($GLOBALS['phpgw']->js))
37                        {
38                                $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript');
39                        }
40                        $GLOBALS['phpgw']->js->validate_file('jscode','connector','expressoAdmin1_2');#diretorio, arquivo.js, aplicacao
41                        $GLOBALS['phpgw']->js->validate_file('jscode','expressoadmin','expressoAdmin1_2');
42                        $GLOBALS['phpgw']->js->validate_file('jscode','groups','expressoAdmin1_2');
43                }
44               
45                function list_groups()
46                {
47                        $account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
48                        $acl = $this->functions->read_acl($account_lid);
49                        $context = $acl[0]['context'];
50                        $context_display = $acl[0]['context_display'];
51                       
52                        // Verifica se tem acesso a este modulo
53                        if (!$this->functions->check_acl($account_lid,'list_groups'))
54                        {
55                                $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php'));
56                        }
57
58                        if(isset($_POST['query']))
59                        {
60                                // limit query to limit characters
61                                if(eregi('^[a-z_0-9_-].+$',$_POST['query']))
62                                        $GLOBALS['query'] = $_POST['query'];
63                        }
64                                               
65                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
66                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
67                       
68                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('User groups');
69                        $GLOBALS['phpgw']->common->phpgw_header();
70
71                        $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
72                        $p->set_file(array('groups'   => 'groups.tpl'));
73                        $p->set_block('groups','list','list');
74                        $p->set_block('groups','row','row');
75                        $p->set_block('groups','row_empty','row_empty');
76
77                        // Seta as variaveis padroes.
78                        $var = Array(
79                                'th_bg'                                 => $GLOBALS['phpgw_info']['theme']['th_bg'],
80                                'back_url'                              => $GLOBALS['phpgw']->link('/expressoAdmin1_2/index.php'),
81                                'add_action'                    => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uigroups.add_groups'),
82                                'add_group_disabled'    => $this->functions->check_acl($account_lid,'add_groups') ? '' : 'disabled',
83                                'context'                               => $context,
84                                'context_display'               => $context_display,
85                                'lang_groups_names'             => lang('Groups Names'),
86                                'lang_description'              => lang('Description'),
87                                'lang_add_groups'               => lang('Add Groups'),
88                                'lang_edit'                     => lang('Edit'),
89                                'lang_delete'                   => lang('Delete'),
90                                'lang_back'                             => lang('back'),
91                                'lang_context'                  => lang('context'),
92                                'lang_search'                   => lang('search')
93                        );
94                        $p->set_var($var);
95                       
96                        // Save query
97                        $p->set_var('query', $GLOBALS['query']);
98                       
99                        //Admin make a search
100                        if ($GLOBALS['query'] != '')
101                        {
102                                $groups_info = $this->functions->get_list('groups', $GLOBALS['query'], $context);
103                        }
104                        $total = count($groups_info);
105
106                        if (!count($total) && $GLOBALS['query'] != '')
107                        {
108                                $p->set_var('message',lang('No matches found'));
109                        }
110                        else if ($total)
111                        {
112                                if ($this->functions->check_acl($account_lid,'edit_groups'))
113                                {
114                                        $can_edit = True;
115                                }
116                                if ($this->functions->check_acl($account_lid,'delete_groups'))
117                                {
118                                        $can_delete = True;
119                                }
120
121                                foreach($groups_info as $group)
122                                {
123                                        $tr_color = $this->nextmatchs->alternate_row_color($tr_color);
124                                        $var = Array(
125                                                'tr_color'              => $tr_color,
126                                                'row_cn'                        => $group['cn'],
127                                                'row_description'       => $group['description']
128                                        );
129                                        $p->set_var($var);
130
131                                        if ($can_edit)
132                                        {
133                                                $p->set_var('edit_link',$this->row_action('edit','groups',$group['gidnumber'],$group['cn']));
134                                        }
135                                        else
136                                        {
137                                                $p->set_var('edit_link','&nbsp;');
138                                        }
139
140                                        if ($can_delete)
141                                        {
142                                                $p->set_var('delete_link',"<a href='#' onClick='javascript:delete_group(\"".$group['cn']."\",\"".$group['gidnumber']."\",\"".$context."\");'>Excluir</a>");
143                                        }
144                                        else
145                                        {
146                                                $p->set_var('delete_link','&nbsp;');
147                                        }
148
149                                        $p->fp('rows','row',True);
150                                }
151                        }
152                        $p->parse('rows','row_empty',True);
153                        $p->set_var($var);
154
155                        if (! $GLOBALS['phpgw']->acl->check('group_access',4,'admin'))
156                        {
157                                $p->set_var('input_add','<input type="submit" value="' . lang('Add') . '">');
158                        }
159                        if (! $GLOBALS['phpgw']->acl->check('group_access',2,'admin'))
160                        {
161                                $p->set_var('input_search',lang('Search') . '&nbsp;<input name="query" value="'.htmlspecialchars(stripslashes($GLOBALS['query'])).'">');
162                        }
163                        $p->pfp('out','list');
164                }
165               
166                function add_groups()
167                {
168                        $GLOBALS['phpgw']->js->set_onload('get_available_users(document.forms[0].org_context.value, document.forms[0].ea_check_allUsers.checked);');
169                       
170                        $account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
171                        $acl = $this->functions->read_acl($account_lid);
172                        $manager_context = $acl[0]['context'];
173                       
174                        // Verifica se tem acesso a este modulo
175                        if (!$this->functions->check_acl($account_lid,'add_groups'))
176                        {
177                                $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php'));
178                        }
179
180                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
181                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
182                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Create Group');
183                        $GLOBALS['phpgw']->common->phpgw_header();
184                       
185                        // Set o template
186                        $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
187                        $p->set_file(Array('create_group' => 'groups_form.tpl'));
188
189                        // Pega combo das organizações e seleciona um dos setores em caso de um erro na validaçao dos dados.
190                        $combo_manager_org = $this->functions->get_organizations($manager_context, trim(strtolower($group_info['context'])));
191                        $combo_all_orgs = $this->functions->get_organizations($GLOBALS['phpgw_info']['server']['ldap_context'], trim(strtolower($group_info['context'])));
192                       
193                        // Chama funcao para criar lista de aplicativos disponiveis.
194                        $apps = $this->functions->make_list_app($account_lid, $manager_context, '');
195                       
196                        // Seta variaveis utilizadas pelo tpl.
197                        $var = Array(
198                                'color_bg1'                                     => "#E8F0F0",
199                                'color_bg2'                                     => "#D3DCE3",
200                                'type'                                          => 'create_group',
201                                'cn'                                            => '',
202                                'restrictionsOnGroup'           => $this->current_config['expressoAdmin_restrictionsOnGroup'],
203                                'ldap_context'                          => $GLOBALS['phpgw_info']['server']['ldap_context'],
204                                'lang_back'                                     => lang('Back'),
205                                'lang_save'                                     => lang('save'),
206                                'lang_org'                                      => lang('Organizations'),
207                                'lang_group_name'                       => lang('group name'),
208                                'lang_group_users'                      => lang('Group users'),
209                                'lang_applications'                     => lang('Applications'),
210                                'lang_add_user'                         => lang('Add User'),
211                                'lang_rem_user'                         => lang('Remove User'),
212                                'lang_all_users'                        => lang('Select users from all sub-organizations'),
213                                'apps'                                          => $apps,
214                                'use_attrs_samba_checked'       => $this->current_config['expressoAdmin_samba_support'] == 'true' ? 'CHECKED' : '',
215                                'back_url'                                      => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uigroups.list_groups'),
216                                'combo_manager_org'                     => $combo_manager_org,
217                                'combo_all_orgs'                        => $combo_all_orgs
218                        );
219                        $p->set_var($var);
220
221                        $p->pfp('out','create_group');
222                }
223               
224                function edit_groups()
225                {
226                        $GLOBALS['phpgw']->js->set_onload('get_available_users(document.forms[0].org_context.value, document.forms[0].ea_check_allUsers.checked);');
227                       
228                        $account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
229                        $acl = $this->functions->read_acl($account_lid);
230                        $manager_context = $acl[0]['context'];
231                       
232                        // Verifica se tem acesso a este modulo
233                        if (!$this->functions->check_acl($account_lid,'edit_groups'))
234                        {
235                                $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php'));
236                        }
237
238                        // GET all infomations about the group.
239                        $group_info = $this->group->get_info($_GET['gidnumber'], $manager_context);
240                        //_debug_array($group_info);
241
242                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
243                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
244                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Edit Group');
245                        $GLOBALS['phpgw']->common->phpgw_header();
246
247                        // Set o template
248                        $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
249                        $p->set_file(Array('create_group' => 'groups_form.tpl'));
250
251                        // Pega combo das organizações e seleciona a org do grupo.
252                        $combo_manager_org = $this->functions->get_organizations($manager_context, trim(strtolower($group_info['context'])));
253                        $combo_all_orgs = $this->functions->get_organizations($GLOBALS['phpgw_info']['server']['ldap_context'], trim(strtolower($group_info['context'])));
254
255                        // Usuarios do grupo.
256                        if (count($group_info['memberuid_info']) > 0)
257                        {
258                                foreach ($group_info['memberuid_info'] as $user)
259                                {
260                                        $array_users[$user['uidnumber']] = $user['cn'];
261                                        $array_users_uid[$user['uidnumber']] = $user['uid'];
262                                }
263                                natcasesort($array_users);
264                                foreach ($array_users as $uidnumber=>$cn)
265                                {
266                                        $ea_select_usersInGroup .= "<option value=" . $uidnumber . ">" . $cn . " [" . $array_users_uid[$uidnumber] . "]</option>";
267                                }
268                        }
269                       
270                        // Chama funcao para criar lista de aplicativos disponiveis.
271                        $apps = $this->functions->make_list_app($account_lid, $manager_context, $group_info['apps']);
272                       
273                        // Seta variaveis utilizadas pelo tpl.
274                        $var = Array(
275                                'color_bg1'                                     => "#E8F0F0",
276                                'color_bg2'                                     => "#D3DCE3",
277                                'type'                                          => 'edit_group',
278                                'ldap_context'                          => $GLOBALS['phpgw_info']['server']['ldap_context'],
279                                'lang_back'                                     => lang('Back'),
280                                'lang_save'                                     => lang('save'),
281                                'lang_org'                                      => lang('Organizations'),
282                                'lang_group_name'                       => lang('group name'),
283                                'lang_group_users'                      => lang('Group users'),
284                                'lang_applications'                     => lang('Applications'),
285                                'lang_add_user'                         => lang('Add User'),
286                                'lang_rem_user'                         => lang('Remove User'),
287                                'lang_all_users'                        => lang('Select users from all sub-organizations'),
288                                'gidnumber'                                     => $group_info['gidnumber'],
289                                'manager_context'                       => $manager_context,
290                                'cn'                                            => $group_info['cn'],
291                                'description'                           => $group_info['description'],
292                                'apps'                                          => $apps,
293                                'use_attrs_samba_checked'       => $group_info['sambaGroup'] ? 'CHECKED' : '',
294                                'back_url'                                      => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uigroups.list_groups'),
295                                'combo_manager_org'                     => $combo_manager_org,
296                                'combo_all_orgs'                        => $combo_all_orgs,
297                                'ea_select_usersInGroup'        => $ea_select_usersInGroup
298                        );
299                        $p->set_var($var);
300
301                        $p->pfp('out','create_group');
302                }
303                               
304                function row_action($action,$type,$gidnumber,$group_name)
305                {
306                        return '<a href="'.$GLOBALS['phpgw']->link('/index.php',Array(
307                                'menuaction'            => 'expressoAdmin1_2.uigroups.'.$action.'_'.$type,
308                                'gidnumber'             => $gidnumber,
309                                'group_name'    => $group_name
310                        )).'"> '.lang($action).' </a>';
311                }
312               
313                function css()
314                {
315                        $appCSS = '';
316/*                      'th.activetab
317                        {
318                                color:#000000;
319                                background-color:#D3DCE3;
320                                border-top-width : 1px;
321                                border-top-style : solid;
322                                border-top-color : Black;
323                                border-left-width : 1px;
324                                border-left-style : solid;
325                                border-left-color : Black;
326                                border-right-width : 1px;
327                                border-right-style : solid;
328                                border-right-color : Black;
329                        }
330                       
331                        th.inactivetab
332                        {
333                                color:#000000;
334                                background-color:#E8F0F0;
335                                border-bottom-width : 1px;
336                                border-bottom-style : solid;
337                                border-bottom-color : Black;
338                        }
339                       
340                        .td_left { border-left : 1px solid Gray; border-top : 1px solid Gray; }
341                        .td_right { border-right : 1px solid Gray; border-top : 1px solid Gray; }
342                       
343                        div.activetab{ display:inline; }
344                        div.inactivetab{ display:none; }';*/
345                       
346                        return $appCSS;
347                }
348               
349        }
350?>
Note: See TracBrowser for help on using the repository browser.