[2] | 1 | <?php |
---|
| 2 | /**************************************************************************\ |
---|
| 3 | * eGroupWare - Administration * |
---|
| 4 | * http://www.egroupware.org * |
---|
| 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 | |
---|
| 13 | class uiaclmanager |
---|
| 14 | { |
---|
| 15 | var $template; |
---|
| 16 | var $nextmatchs; |
---|
| 17 | var $public_functions = array( |
---|
| 18 | 'list_apps' => True, |
---|
| 19 | 'access_form' => True, |
---|
| 20 | 'account_list' => True |
---|
| 21 | ); |
---|
| 22 | |
---|
| 23 | function uiaclmanager() |
---|
| 24 | { |
---|
| 25 | $this->account_id = (int)$_GET['account_id']; |
---|
| 26 | if (!$this->account_id || $GLOBALS['phpgw']->acl->check('account_access',64,'admin')) |
---|
| 27 | { |
---|
| 28 | $GLOBALS['phpgw']->redirect_link('/index.php'); |
---|
| 29 | } |
---|
| 30 | $this->template = createobject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
| 31 | } |
---|
| 32 | |
---|
| 33 | function common_header() |
---|
| 34 | { |
---|
| 35 | $GLOBALS['phpgw_info']['flags']['app_header'] = lang('Admin') . ' - ' . lang('ACL Manager') . |
---|
| 36 | ': ' . $GLOBALS['phpgw']->common->grab_owner_name($this->account_id); |
---|
| 37 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 38 | echo parse_navbar(); |
---|
| 39 | } |
---|
| 40 | |
---|
| 41 | function list_apps() |
---|
| 42 | { |
---|
| 43 | $this->common_header(); |
---|
| 44 | |
---|
| 45 | $GLOBALS['phpgw']->hooks->process('acl_manager',array('preferences')); |
---|
| 46 | |
---|
| 47 | $this->template->set_file(array( |
---|
| 48 | 'app_list' => 'acl_applist.tpl' |
---|
| 49 | )); |
---|
| 50 | $this->template->set_block('app_list','list'); |
---|
| 51 | $this->template->set_block('app_list','app_row'); |
---|
| 52 | $this->template->set_block('app_list','app_row_noicon'); |
---|
| 53 | $this->template->set_block('app_list','link_row'); |
---|
| 54 | $this->template->set_block('app_list','spacer_row'); |
---|
| 55 | |
---|
| 56 | if (is_array($GLOBALS['acl_manager'])) |
---|
| 57 | { |
---|
| 58 | foreach($GLOBALS['acl_manager'] as $app => $locations) |
---|
| 59 | { |
---|
| 60 | $icon = $GLOBALS['phpgw']->common->image($app,array('navbar.gif',$app.'.gif')); |
---|
| 61 | $this->template->set_var('icon_backcolor',$GLOBALS['phpgw_info']['theme']['row_off']); |
---|
| 62 | $this->template->set_var('link_backcolor',$GLOBALS['phpgw_info']['theme']['row_off']); |
---|
| 63 | $this->template->set_var('app_name',$GLOBALS['phpgw_info']['apps'][$app]['title']); |
---|
| 64 | $this->template->set_var('a_name',$appname); |
---|
| 65 | $this->template->set_var('app_icon',$icon); |
---|
| 66 | |
---|
| 67 | if ($icon) |
---|
| 68 | { |
---|
| 69 | $this->template->fp('rows','app_row',True); |
---|
| 70 | } |
---|
| 71 | else |
---|
| 72 | { |
---|
| 73 | $this->template->fp('rows','app_row_noicon',True); |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | if (is_array($locations)) |
---|
| 77 | { |
---|
| 78 | foreach($locations as $loc => $value) |
---|
| 79 | { |
---|
| 80 | $link_values = array( |
---|
| 81 | 'menuaction' => 'admin.uiaclmanager.access_form', |
---|
| 82 | 'location' => $loc, |
---|
| 83 | 'acl_app' => $app, |
---|
| 84 | 'account_id' => $this->account_id |
---|
| 85 | ); |
---|
| 86 | |
---|
| 87 | $this->template->set_var('link_location',$GLOBALS['phpgw']->link('/index.php',$link_values)); |
---|
| 88 | $this->template->set_var('lang_location',lang($value['name'])); |
---|
| 89 | $this->template->fp('rows','link_row',True); |
---|
| 90 | } |
---|
| 91 | } |
---|
| 92 | |
---|
| 93 | $this->template->parse('rows','spacer_row',True); |
---|
| 94 | } |
---|
| 95 | } |
---|
| 96 | $this->template->set_var(array( |
---|
| 97 | 'cancel_action' => $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiaccounts.list_users'), |
---|
| 98 | 'lang_cancel' => lang('Cancel') |
---|
| 99 | )); |
---|
| 100 | $this->template->pfp('out','list'); |
---|
| 101 | } |
---|
| 102 | |
---|
| 103 | function access_form() |
---|
| 104 | { |
---|
| 105 | $location = $_GET['location']; |
---|
| 106 | |
---|
| 107 | if ($_POST['submit'] || $_POST['cancel']) |
---|
| 108 | { |
---|
| 109 | if ($_POST['submit']) |
---|
| 110 | { |
---|
| 111 | $total_rights = 0; |
---|
| 112 | if (is_array($_POST['acl_rights'])) |
---|
| 113 | { |
---|
| 114 | foreach($_POST['acl_rights'] as $rights) |
---|
| 115 | { |
---|
| 116 | $total_rights += $rights; |
---|
| 117 | } |
---|
| 118 | } |
---|
| 119 | if ($total_rights) |
---|
| 120 | { |
---|
| 121 | $GLOBALS['phpgw']->acl->add_repository($_GET['acl_app'], $location, $this->account_id, $total_rights); |
---|
| 122 | } |
---|
| 123 | else // we dont need to save 0 rights (= no restrictions) |
---|
| 124 | { |
---|
| 125 | $GLOBALS['phpgw']->acl->delete_repository($_GET['acl_app'], $location, $this->account_id); |
---|
| 126 | } |
---|
| 127 | } |
---|
| 128 | $this->list_apps(); |
---|
| 129 | return; |
---|
| 130 | } |
---|
| 131 | $GLOBALS['phpgw']->hooks->single('acl_manager',$_GET['acl_app']); |
---|
| 132 | $acl_manager = $GLOBALS['acl_manager'][$_GET['acl_app']][$location]; |
---|
| 133 | |
---|
| 134 | $this->common_header(); |
---|
| 135 | $this->template->set_file('form','acl_manager_form.tpl'); |
---|
| 136 | |
---|
| 137 | $acc = createobject('phpgwapi.accounts',$this->account_id); |
---|
| 138 | $acc->read_repository(); |
---|
| 139 | $afn = $GLOBALS['phpgw']->common->display_fullname($acc->data['account_lid'],$acc->data['firstname'],$acc->data['lastname']); |
---|
| 140 | |
---|
| 141 | $this->template->set_var('lang_message',lang('Check items to <b>%1</b> to %2 for %3',lang($acl_manager['name']),$GLOBALS['phpgw_info']['apps'][$_GET['acl_app']]['title'],$afn)); |
---|
| 142 | $link_values = array( |
---|
| 143 | 'menuaction' => 'admin.uiaclmanager.access_form', |
---|
| 144 | 'acl_app' => $_GET['acl_app'], |
---|
| 145 | 'location' => urlencode($_GET['location']), |
---|
| 146 | 'account_id' => $this->account_id |
---|
| 147 | ); |
---|
| 148 | |
---|
| 149 | $acl = createobject('phpgwapi.acl',$this->account_id); |
---|
| 150 | $acl->read_repository(); |
---|
| 151 | $grants = $acl->get_rights($location,$_GET['acl_app']); |
---|
| 152 | |
---|
| 153 | $this->template->set_var('form_action',$GLOBALS['phpgw']->link('/index.php',$link_values)); |
---|
| 154 | |
---|
| 155 | $total = 0; |
---|
| 156 | foreach($acl_manager['rights'] as $name => $value) |
---|
| 157 | { |
---|
| 158 | $cb .= '<input type="checkbox" name="acl_rights[]" value="'.$value.'"'.($grants & $value ? ' checked' : '').'> '.lang($name)."<br>\n"; |
---|
| 159 | } |
---|
| 160 | $this->template->set_var('select_values',$cb); |
---|
| 161 | $this->template->set_var('lang_submit',lang('Save')); |
---|
| 162 | $this->template->set_var('lang_cancel',lang('Cancel')); |
---|
| 163 | |
---|
| 164 | $this->template->pfp('out','form'); |
---|
| 165 | } |
---|
| 166 | } |
---|