source: trunk/news_admin/inc/class.uiacl.inc.php @ 2

Revision 2, 4.3 KB checked in by niltonneto, 17 years ago (diff)

Removida todas as tags usadas pelo CVS ($Id, $Source).
Primeira versão no CVS externo.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2        /**************************************************************************\
3        * eGroupWare - News                                                        *
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
14        class uiacl
15        {
16                var $start = 0;
17                var $query = '';
18                var $sort  = '';
19                var $order = '';
20                var $bo;
21                var $accounts;
22                var $nextmatchs = '';
23                var $rights;
24                var $public_functions = array(
25                        'acllist'       => True,
26                        );
27
28                function uiacl()
29                {
30                        $this->bo = createobject('news_admin.boacl',True);
31                        $this->accounts = $GLOBALS['phpgw']->accounts->get_list('groups');
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                                }
61                        }
62
63                        $GLOBALS['phpgw']->template->set_file('acl', 'acl.tpl');
64                        $GLOBALS['phpgw']->template->set_block('acl','cat_list','Cblock');
65                        $GLOBALS['phpgw']->template->set_var(array(
66                                'title' => $GLOBALS['phpgw_info']['apps']['news_admin']['title'] . ' - ' . lang('Configure Access Permissions'),
67                                'lang_search' => lang('Search'),
68                                'lang_save' => lang('Save'),
69                                'lang_done' => lang('Done'),
70                                'lang_read' => lang('Read permissions'),
71                                'lang_write' => lang('Write permissions'),
72                                'lang_implies' => lang('implies read permission'),
73                        ));
74
75                        $left  = $this->nextmatchs->left('/index.php',$this->start,$this->bo->catbo->total_records,'menuaction=news_admin.uiacl.acllist');
76                        $right = $this->nextmatchs->right('/index.php',$this->start,$this->bo->catbo->total_records,'menuaction=news_admin.uiacl.acllist');
77                       
78                        $GLOBALS['phpgw']->template->set_var(array(
79                                'left' => $left,
80                                'right' => $right,
81                                'lang_showing' => $this->nextmatchs->show_hits($this->bo->catbo->total_records,$this->start),
82                                'th_bg' => $GLOBALS['phpgw_info']['theme']['th_bg'],
83                                'sort_cat' => $this->nextmatchs->show_sort_order(
84                                        $this->sort,'cat_name','cat_name','/index.php',lang('Category'),'&menuaction=news_admin.uiacl.acllist'
85                                ),
86                                'query' => $this->query,
87                        ));
88
89                        @reset($this->bo->cats);
90                        while (list(,$cat) = @each($this->bo->cats))
91                        {
92                                $this->rights = $this->bo->get_rights($cat['id']);
93
94                                $tr_color = $this->nextmatchs->alternate_row_color($tr_color);
95                                $GLOBALS['phpgw']->template->set_var(array(
96                                        'tr_color' => $tr_color,
97                                        'catname' => $cat['name'],
98                                        'catid' => $cat['id'],
99                                        'read' => $this->selectlist(PHPGW_ACL_READ),
100                                        'write' => $this->selectlist(PHPGW_ACL_ADD)
101                                ));
102                                $GLOBALS['phpgw']->template->parse('Cblock','cat_list',True);
103                        }
104                        $GLOBALS['phpgw']->template->pfp('out','acl',True);
105                }
106
107                function selectlist($right)
108                {
109                        reset($this->bo->accounts);
110                        while (list($null,$account) = each($this->bo->accounts))
111                        {
112                                $selectlist .= '<option value="' . $account['account_id'] . '"';
113                                if($this->rights[$account['account_id']] & $right)
114                                {
115                                        $selectlist .= ' selected="selected"';
116                                }
117                                $selectlist .= '>' . $account['account_firstname'] . ' ' . $account['account_lastname']
118                                                                                . ' [ ' . $account['account_lid'] . ' ]' . '</option>' . "\n";
119                        }
120                        return $selectlist;
121                }
122
123                function deny()
124                {
125                        echo '<p><center><b>'.lang('Access not permitted').'</b></center>';
126                        $GLOBALS['phpgw']->common->phpgw_exit(True);
127                }
128        }
129?>
Note: See TracBrowser for help on using the repository browser.