source: companies/serpro/calendar/inc/class.uigroup_access.inc.php @ 903

Revision 903, 6.8 KB checked in by niltonneto, 15 years ago (diff)

Importacao inicial do Expresso do Serpro

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