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

Revision 421, 6.9 KB checked in by niltonneto, 16 years ago (diff)

Ocorrência #329 (melhoria)
Compartilhamento de Agenda por Grupos.

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