source: sandbox/2.3-MailArchiver/calendar/inc/class.uigroup_access.inc.php @ 6779

Revision 6779, 7.0 KB checked in by rafaelraymundo, 12 years ago (diff)

Ticket #2946 - Liberado Expresso(branch 2.3) integrado ao MailArchiver?.

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='calendar/js/search.js' type='text/javascript'></script>";                         
74                                // Fim                         
75                               
76                                $this->template->set_var('lang_Loading',lang("Loading"));
77                                $this->template->set_var('lang_Searching', lang("Searching"));
78                                $this->template->set_var('lang_Users', lang("Users"));
79                                $this->template->set_var('lang_Groups', lang("Groups"));
80                                $this->template->set_var('template_set', $this->template_dir);
81                                $this->template->set_var('lang_Event_participants', lang("Event's participants"));
82                                $this->template->set_var('lang_Add', lang("Add"));
83                                $this->template->set_var('lang_Remove', lang("Remove"));
84                                $this->template->set_var('lang_Organization', lang("Organization"));
85                                $this->template->set_var('lang_Search_for', lang("Search for"));
86                                $this->template->set_var('lang_Available_users_and_groups', lang("Available users and groups"));
87                                $this->template->set_var('lang_User_to_grant_access', lang("User to grant access"));
88                                $this->template->set_var('lang_Group_to_share_calendar', lang("Group to share calendar"));
89                                $this->template->set_var('scripts',$scripts);
90                        }
91                }       
92                               
93                $this->template->set_var('tr_color',$this->theme['th_bg']);             
94                $this->template->set_var('lang_granted_user',lang("Granted user"));                     
95                $this->template->set_var('lang_shared_group',lang("Shared group"));
96               
97                $this->template->set_var('lang_rights',lang("Rights"));
98                $this->template->set_var('lang_read',lang("Read"));
99                $this->template->set_var('lang_add',lang("Add"));
100                $this->template->set_var('lang_edit',lang("Edit"));
101                $this->template->set_var('lang_delete',lang("Delete"));
102                $this->template->set_var('lang_private',lang("Private"));
103               
104                $this->template->set_var('lang_access_type',lang("Permission"));               
105                $this->template->set_var('lang_remove',lang("remove"));
106               
107                $this->template->set_var('lang_confirm',lang("Do you confirm this action?"));
108                $this->template->set_var('lang_success',lang("The sharing was granted."));
109                $this->template->set_var('lang_exist',lang("This sharing already exist."));
110                $this->template->set_var('lang_nouser',lang("No user was selected"));
111                $this->template->set_var('lang_nogroup',lang("No group was selected"));
112                $this->template->set_var('lang_nopermissiontype',lang("No permission type was selected"));
113                $this->template->set_var('lang_typemoreletters',lang("Type more %1 letters.","X"));             
114                                                                       
115                $grants = $this->get_grants('calendar');
116               
117                $i = 0;
118                $data = array();
119                if($grants) {           
120                        foreach($grants as $key => $acl) {                             
121                                $GLOBALS['phpgw']->accounts->get_account_name($acl['userID'], &$lid, &$fuser, &$luser);
122                                $GLOBALS['phpgw']->accounts->get_account_name($acl['groupID'], &$lid, &$groupname, &$lname);                   
123                                $rights = $acl['rights'] & PHPGW_ACL_READ ? "L" : "";
124                                $rights.= $acl['rights'] & PHPGW_ACL_ADD ? "A" : "";
125                                $rights.= $acl['rights'] & PHPGW_ACL_EDIT ? "E" : "";
126                                $rights.= $acl['rights'] & PHPGW_ACL_DELETE ? "R" : "";
127                                $rights.= $acl['rights'] & PHPGW_ACL_PRIVATE ? "P" : "";
128                       
129                                $data[$fuser." ".$luser.$i++] = array('granted_user'    => $fuser." ".$luser,
130                                                'shared_group'     => $groupname,
131                                                'access_type'      => $rights,
132                                                'tr_color_header'  => "#DCDCDC",
133                                                'select'   => $key
134                                        );
135                        }
136                        ksort($data);
137                        foreach($data as $key => $var){
138                                $this->template->set_var($var);                 
139                                $this->template->parse('list_t','list',$var);                           
140                        }
141                }               
142               
143                $this->template->pfp('out', 'main');
144        }
145
146        private function get_grants($app){
147                return $this->bo->get_grants($app);             
148        }
149        public function search_user($params){           
150                return $this->bo->search_user($params);
151        }       
152        public final function add_user($params) {                               
153                $rights  = strstr($params['rights'],"L") ? 1 : 0;
154                $rights |= strstr($params['rights'],"A") ? 2 : 0;
155                $rights |= strstr($params['rights'],"E") ? 4 : 0;
156                $rights |= strstr($params['rights'],"R") ? 8 : 0;
157                $rights |= strstr($params['rights'],"P") ? 16 : 0;
158                $params["id"] .= ";".$rights;
159                return $this->bo->add_user($params);
160        }
161        public final function rem_user($params) {
162                return $this->bo->rem_user($params);
163        }
164}
165?>
Note: See TracBrowser for help on using the repository browser.