[3524] | 1 | <?php |
---|
| 2 | /** |
---|
| 3 | * eGroupWare - resources |
---|
| 4 | * |
---|
| 5 | * @license http://www.gnu.org/licenses/gpl.html GNU General Public License |
---|
| 6 | * @package resources |
---|
| 7 | * @link http://www.egroupware.org |
---|
| 8 | * @version $Id: class.ui_acl.inc.php 22893 2006-12-07 08:12:19Z nelius_weiss $ |
---|
| 9 | */ |
---|
| 10 | |
---|
| 11 | /** |
---|
| 12 | * ACL userinterface object for resources |
---|
| 13 | * |
---|
| 14 | * @package resources |
---|
| 15 | */ |
---|
| 16 | class ui_acl |
---|
| 17 | { |
---|
| 18 | var $start = 0; |
---|
| 19 | var $query = ''; |
---|
| 20 | var $sort = ''; |
---|
| 21 | var $order = ''; |
---|
| 22 | var $bo; |
---|
| 23 | var $nextmatchs = ''; |
---|
| 24 | var $rights; |
---|
| 25 | var $public_functions = array( |
---|
| 26 | 'acllist' => True, |
---|
| 27 | ); |
---|
| 28 | |
---|
| 29 | function ui_acl() |
---|
| 30 | { |
---|
| 31 | $this->bo =& createobject('resources.bo_acl',True); |
---|
| 32 | $this->nextmatchs =& createobject('phpgwapi.nextmatchs'); |
---|
| 33 | $this->start = $this->bo->start; |
---|
| 34 | $this->query = $this->bo->query; |
---|
| 35 | $this->order = $this->bo->order; |
---|
| 36 | $this->sort = $this->bo->sort; |
---|
| 37 | $this->cat_id = $this->bo->cat_id; |
---|
| 38 | } |
---|
| 39 | |
---|
| 40 | function acllist() |
---|
| 41 | { |
---|
| 42 | if (!$GLOBALS['phpgw']->acl->check('run',1,'admin')) |
---|
| 43 | { |
---|
| 44 | $this->deny(); |
---|
| 45 | } |
---|
| 46 | |
---|
| 47 | if ($_POST['btnDone']) |
---|
| 48 | { |
---|
| 49 | $GLOBALS['phpgw']->redirect_link('/admin/index.php'); |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 53 | echo parse_navbar(); |
---|
| 54 | |
---|
| 55 | if ($_POST['btnSave']) |
---|
| 56 | { |
---|
| 57 | foreach($_POST['catids'] as $cat_id) |
---|
| 58 | { |
---|
| 59 | $this->bo->set_rights($cat_id,$_POST['inputread'][$cat_id],$_POST['inputwrite'][$cat_id], |
---|
| 60 | $_POST['inputcalread'][$cat_id],$_POST['inputcalbook'][$cat_id],$_POST['inputadmin'][$cat_id]); |
---|
| 61 | } |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | $GLOBALS['phpgw']->template->set_file('acl', 'acl.tpl'); |
---|
| 65 | $GLOBALS['phpgw']->template->set_block('acl','cat_list','Cblock'); |
---|
| 66 | $GLOBALS['phpgw']->template->set_var(array( |
---|
| 67 | 'title' => $GLOBALS['phpgw_info']['apps']['resources']['title'] . ' - ' . lang('Configure Access Permissions'), |
---|
| 68 | 'lang_search' => lang('Search'), |
---|
| 69 | 'lang_save' => lang('Save'), |
---|
| 70 | 'lang_done' => lang('Done'), |
---|
| 71 | 'lang_read' => lang('Read permissions'), |
---|
| 72 | 'lang_write' => lang('Write permissions'), |
---|
| 73 | 'lang_implies_read' => lang('implies read permission'), |
---|
| 74 | 'lang_calread' => lang('Read Calendar permissions'), |
---|
| 75 | 'lang_calbook' => lang('Direct booking permissions'), |
---|
| 76 | 'lang_implies_book' => lang('implies booking permission'), |
---|
| 77 | 'lang_cat_admin' => lang('Categories admin') |
---|
| 78 | )); |
---|
| 79 | |
---|
| 80 | $left = $this->nextmatchs->left('/index.php',$this->start,$this->bo->catbo->total_records,'menuaction=resources.uiacl.acllist'); |
---|
| 81 | $right = $this->nextmatchs->right('/index.php',$this->start,$this->bo->catbo->total_records,'menuaction=resources.uiacl.acllist'); |
---|
| 82 | |
---|
| 83 | $GLOBALS['phpgw']->template->set_var(array( |
---|
| 84 | 'left' => $left, |
---|
| 85 | 'right' => $right, |
---|
| 86 | 'lang_showing' => $this->nextmatchs->show_hits($this->bo->catbo->total_records,$this->start), |
---|
| 87 | 'th_bg' => $GLOBALS['phpgw_info']['theme']['th_bg'], |
---|
| 88 | 'sort_cat' => $this->nextmatchs->show_sort_order( |
---|
| 89 | $this->sort,'cat_name','cat_name','/index.php',lang('Category'),'&menuaction=resources.uiacl.acllist' |
---|
| 90 | ), |
---|
| 91 | 'query' => $this->query, |
---|
| 92 | )); |
---|
| 93 | |
---|
| 94 | @reset($this->bo->cats); |
---|
| 95 | while (list(,$cat) = @each($this->bo->cats)) |
---|
| 96 | { |
---|
| 97 | $this->rights = $this->bo->get_rights($cat['id']); |
---|
| 98 | |
---|
| 99 | $tr_color = $this->nextmatchs->alternate_row_color($tr_color); |
---|
| 100 | $GLOBALS['phpgw']->template->set_var(array( |
---|
| 101 | 'tr_color' => $tr_color, |
---|
| 102 | 'catname' => $cat['name'], |
---|
| 103 | 'catid' => $cat['id'], |
---|
| 104 | 'read' => $this->selectlist(phpgw_ACL_READ), |
---|
| 105 | 'write' => $this->selectlist(phpgw_ACL_ADD), |
---|
| 106 | 'calread' => $this->selectlist(phpgw_ACL_CALREAD), |
---|
| 107 | 'calbook' =>$this->selectlist(phpgw_ACL_DIRECT_BOOKING), |
---|
| 108 | 'admin' => '<option value="" selected="1">'.lang('choose categories admin').'</option>'.$this->selectlist(phpgw_ACL_CAT_ADMIN,true) |
---|
| 109 | )); |
---|
| 110 | $GLOBALS['phpgw']->template->parse('Cblock','cat_list',True); |
---|
| 111 | } |
---|
| 112 | $GLOBALS['phpgw']->template->pfp('out','acl',True); |
---|
| 113 | } |
---|
| 114 | |
---|
| 115 | function selectlist($right,$users_only=false) |
---|
| 116 | { |
---|
| 117 | foreach ($GLOBALS['phpgw']->accounts->get_list() as $num => $account) |
---|
| 118 | { |
---|
| 119 | if(!($users_only && $account['account_lastname'] == 'Group')) |
---|
| 120 | { |
---|
| 121 | $selectlist .= '<option value="' . $account['account_id'] . '"'; |
---|
| 122 | if($this->rights[$account['account_id']] & $right) |
---|
| 123 | { |
---|
| 124 | $selectlist .= ' selected="selected"'; |
---|
| 125 | } |
---|
| 126 | $selectlist .= '>' . $account['account_firstname'] . ' ' . $account['account_lastname'] |
---|
| 127 | . ' [ ' . $account['account_lid'] . ' ]' . '</option>' . "\n"; |
---|
| 128 | } |
---|
| 129 | } |
---|
| 130 | return $selectlist; |
---|
| 131 | } |
---|
| 132 | |
---|
| 133 | function deny() |
---|
| 134 | { |
---|
| 135 | echo '<p><center><b>'.lang('Access not permitted').'</b></center>'; |
---|
| 136 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
| 137 | } |
---|
| 138 | } |
---|