source: trunk/calendar/inc/class.uigroup_access.inc.php @ 5132

Revision 5132, 7.1 KB checked in by wmerlotto, 12 years ago (diff)

Ticket #2305 - Enviando alteracoes, desenvolvidas internamente na Prognus, do modulo calendar.

  • Property svn:executable set to *
Line 
1<?php
2
3 /**************************************************************************\
4  * Expresso Livre - Grant Group Access - 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  \**************************************************************************/
12include_once("class.bogroup_access.inc.php");
13
14class uigroup_access
15{
16        var $public_functions = array(
17                'add'           => True,
18                'index'         => True,
19        );
20
21        var $bo;
22        var $template;
23        var $template_dir;
24        var $html;
25        var $theme;
26
27        final function __construct()
28        {
29               
30                $this->bo = new bogroup_access();                               
31        }
32
33        function index(){
34               
35                if (!$GLOBALS['phpgw']->acl->check('run',1,'admin'))
36                {
37                      $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/admin/index.php'));
38                }
39
40                $GLOBALS['phpgw_info']['flags'] = array(
41                                        'currentapp' => 'calendar',
42                                        'nonavbar'   => false,
43                                        'app_header' => lang('Grant Access by Group'),
44                                        'noheader'   => false
45                                        );
46               
47                $GLOBALS['phpgw']->common->phpgw_header();
48                $this->template_dir = 'calendar/templates/'.$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set'];
49                $this->template = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);             
50                if (!is_object($GLOBALS['phpgw']->html)){
51                        $GLOBALS['phpgw']->html = CreateObject('phpgwapi.html');
52                }
53               
54                $this->html = &$GLOBALS['phpgw']->html;
55                $this->theme = $GLOBALS['phpgw_info']['theme'];
56                               
57                $_SESSION['phpgw_info']['server'] = $GLOBALS['phpgw_info']['server'];
58                $this->template->set_file(Array('main'  => 'grant_group_access.tpl'     ));     
59                $this->template->set_block('main','list','list_t');                     
60               
61                // if ExpressoMail 1.2 has been installed and enabled, show the plugin using AJAX.
62                if($GLOBALS['phpgw_info']['server']['cal_expressoMail']) {                                                     
63                        $module_name = 'expressoMail'.(str_replace("1.","1_",$GLOBALS['phpgw_info']['server']['cal_expressoMail']));
64                        if($GLOBALS['phpgw_info']['user']['apps'][$module_name]){                                                               
65                                $ldap_manager = CreateObject('contactcenter.bo_ldap_manager');
66                                $_SESSION['phpgw_info']['expressomail']['user'] = $GLOBALS['phpgw_info']['user'];                               
67                                $_SESSION['phpgw_info']['expressomail']['user']['owner'] = $GLOBALS['phpgw_info']['user']['account_id'];
68                                $_SESSION['phpgw_info']['expressomail']['server'] = $GLOBALS['phpgw_info']['server'];
69                                $_SESSION['phpgw_info']['expressomail']['ldap_server'] = $ldap_manager ? $ldap_manager->srcs[1] : null;
70                                // Carrega todos scripts necessarios                           
71                                $scripts =      "<script src='".$module_name."/js/connector.js' type='text/javascript'></script>".
72                                                        "<script type='text/javascript'>var DEFAULT_URL = '".$module_name."/controller.php?action=';</script> ".                                                                                       
73                                                        "<script src='".$this->template_dir."/js/finder.js' type='text/javascript'></script>".
74                                                        "<script src='".$this->template_dir."/js/search.js' type='text/javascript'></script>";                         
75                                // Fim                         
76                               
77                                $this->template->set_var('lang_Loading',lang("Loading"));
78                                $this->template->set_var('lang_Searching', lang("Searching"));
79                                $this->template->set_var('lang_Users', lang("Users"));
80                                $this->template->set_var('lang_Groups', lang("Groups"));
81                                $this->template->set_var('template_set', $this->template_dir);
82                                $this->template->set_var('lang_Event_participants', lang("Event's participants"));
83                                $this->template->set_var('lang_Add', lang("Add"));
84                                $this->template->set_var('lang_Remove', lang("Remove"));
85                                $this->template->set_var('lang_Organization', lang("Organization"));
86                                $this->template->set_var('lang_Search_for', lang("Search for"));
87                                $this->template->set_var('lang_Available_users_and_groups', lang("Available users and groups"));
88                                $this->template->set_var('lang_User_to_grant_access', lang("User to grant access"));
89                                $this->template->set_var('lang_Group_to_share_calendar', lang("Group to share calendar"));
90                                $this->template->set_var('scripts',$scripts);
91                        }
92                }       
93                               
94                $this->template->set_var('tr_color',$this->theme['th_bg']);             
95                $this->template->set_var('lang_granted_user',lang("Granted user"));                     
96                $this->template->set_var('lang_shared_group',lang("Shared group"));
97               
98                $this->template->set_var('lang_rights',lang("Rights"));
99                $this->template->set_var('lang_read',lang("Read"));
100                $this->template->set_var('lang_add',lang("Add"));
101                $this->template->set_var('lang_edit',lang("Edit"));
102                $this->template->set_var('lang_delete',lang("Delete"));
103                $this->template->set_var('lang_private',lang("Private"));
104               
105                $this->template->set_var('lang_access_type',lang("Permission"));               
106                $this->template->set_var('lang_remove',lang("remove"));
107               
108                $this->template->set_var('lang_confirm',lang("Do you confirm this action?"));
109                $this->template->set_var('lang_success',lang("The sharing was granted."));
110                $this->template->set_var('lang_exist',lang("This sharing already exist."));
111                $this->template->set_var('lang_nouser',lang("No user was selected"));
112                $this->template->set_var('lang_nogroup',lang("No group was selected"));
113                $this->template->set_var('lang_nopermissiontype',lang("No permission type was selected"));
114                $this->template->set_var('lang_typemoreletters',lang("Type more %1 letters.","X"));             
115                                                                       
116                $grants = $this->get_grants('calendar');
117               
118                $i = 0;
119                $data = array();
120                if($grants) {           
121                        foreach($grants as $key => $acl) {                             
122                                $GLOBALS['phpgw']->accounts->get_account_name($acl['userID'], &$lid, &$fuser, &$luser);
123                                $GLOBALS['phpgw']->accounts->get_account_name($acl['groupID'], &$lid, &$groupname, &$lname);                   
124                                $rights = $acl['rights'] & PHPGW_ACL_READ ? "L" : "";
125                                $rights.= $acl['rights'] & PHPGW_ACL_ADD ? "A" : "";
126                                $rights.= $acl['rights'] & PHPGW_ACL_EDIT ? "E" : "";
127                                $rights.= $acl['rights'] & PHPGW_ACL_DELETE ? "R" : "";
128                                $rights.= $acl['rights'] & PHPGW_ACL_PRIVATE ? "P" : "";
129                       
130                                $data[$fuser." ".$luser.$i++] = array('granted_user'    => $fuser." ".$luser,
131                                                'shared_group'     => $groupname,
132                                                'access_type'      => $rights,
133                                                'tr_color_header'  => "#DCDCDC",
134                                                'select'   => $key
135                                        );
136                        }
137                        ksort($data);
138                        foreach($data as $key => $var){
139                                $this->template->set_var($var);                 
140                                $this->template->parse('list_t','list',$var);                           
141                        }
142                }               
143               
144                $this->template->pfp('out', 'main');
145        }
146
147        private function get_grants($app){
148                return $this->bo->get_grants($app);             
149        }
150        public function search_user($params){           
151                return $this->bo->search_user($params);
152        }       
153        public final function add_user($params) {                               
154                $rights  = strstr($params['rights'],"L") ? 1 : 0;
155                $rights |= strstr($params['rights'],"A") ? 2 : 0;
156                $rights |= strstr($params['rights'],"E") ? 4 : 0;
157                $rights |= strstr($params['rights'],"R") ? 8 : 0;
158                $rights |= strstr($params['rights'],"P") ? 16 : 0;
159                $params["id"] .= ";".$rights;
160                return $this->bo->add_user($params);
161        }
162        public final function rem_user($params) {
163                return $this->bo->rem_user($params);
164        }
165}
166?>
Note: See TracBrowser for help on using the repository browser.