source: trunk/news_admin/inc/class.boacl.inc.php @ 45

Revision 45, 3.8 KB checked in by niltonneto, 17 years ago (diff)

Implementação do FCKEDITOR na edição de artigos no news_admin, para permitir texto rico.

  • 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        /* $Id$ */
14
15        class boacl
16        {
17                var $acl;
18                var $start = 0;
19                var $query = '';
20                var $sort  = '';
21                var $total = 0;
22                var $accounts;
23                var $cats;
24
25                var $debug;
26                var $use_session = False;
27
28                function boacl($session=False)
29                {
30                        $this->so = CreateObject('news_admin.soacl');
31                        $this->accounts = $GLOBALS['phpgw']->accounts->get_list('groups');
32                        $this->debug = False;
33                        //all this is only needed when called from uiacl. not from ui,
34                        if($session)
35                        {
36                                $this->read_sessiondata();
37                                $this->use_session = True;
38                                foreach(array('start','query','sort','order') as $var)
39                                {
40                                        if (isset($_POST[$var]))
41                                        {
42                                                $this->$var = $_POST[$var];
43                                        }
44                                        elseif (isset($_GET[$var]))
45                                        {
46                                                $this->$var = $_GET[$var];
47                                        }
48                                }
49                                $this->save_sessiondata();
50                                $this->catbo = createobject('phpgwapi.categories');
51//                              $main_cat = array(array('id' => 0, 'name' => lang('Global news')));
52//                              $this->cats = array_merge($main_cat,$this->catbo->return_array('all',$this->start,True,$this->query,$this->sort,'cat_name',True));
53                                $this->cats = $this->catbo->return_array('all',$this->start,True,$this->query,$this->sort,'cat_name',True);
54                        }
55                        $this->permissions = $this->get_permissions(True);
56                }
57
58                function save_sessiondata()
59                {
60                        $data = array(
61                                'start' => $this->start,
62                                'query' => $this->query,
63                                'sort'  => $this->sort,
64                                'order' => $this->order,
65                                'limit' => $this->limit,
66                        );
67                        if($this->debug) { echo '<br>Read:'; _debug_array($data); }
68                        $GLOBALS['phpgw']->session->appsession('session_data','news_admin_acl',$data);
69                }
70
71                function read_sessiondata()
72                {
73                        $data = $GLOBALS['phpgw']->session->appsession('session_data','news_admin_acl');
74                        if($this->debug) { echo '<br>Read:'; _debug_array($data); }
75
76                        $this->start  = $data['start'];
77                        $this->query  = $data['query'];
78                        $this->sort   = $data['sort'];
79                        $this->order  = $data['order'];
80                        $this->limit = $data['limit'];
81                }
82
83                function get_rights($cat_id)
84                {
85                        return $this->so->get_rights('L'.$cat_id);
86                }
87
88                function is_permitted($cat_id,$right)
89                {
90                        return $this->permissions['L'.$cat_id] & $right;
91                }
92
93                function is_readable($cat_id)
94                {
95                        return $this->is_permitted($cat_id,PHPGW_ACL_READ);
96                }
97
98                function is_writeable($cat_id)
99                {
100                        return $this->is_permitted($cat_id,PHPGW_ACL_ADD);
101                }
102
103                function set_rights($cat_id,$read,$write)
104                {
105                        $readcat = $read ? $read : array();
106                        $writecat = $write ? $write : array();
107
108                        $this->so->remove_location('L' . $cat_id);
109                        reset($this->accounts);
110                        while (list($null,$account) = each($this->accounts))
111                        {
112                                $account_id = $account['account_id'];
113                                //write implies read
114                                $rights = in_array($account_id,$writecat) ?
115                                        (PHPGW_ACL_READ | PHPGW_ACL_ADD) :
116                                        (in_array($account_id,$readcat) ? PHPGW_ACL_READ : False);
117                                if ($rights)
118                                {
119                                        $GLOBALS['phpgw']->acl->add_repository('news_admin','L'.$cat_id,$account_id,$rights);
120                                }
121                        }
122                }
123
124                //access permissions for current user
125                function get_permissions($inc_groups = False)
126                {
127                        return $this->so->get_permissions($GLOBALS['phpgw_info']['user']['account_id'], $inc_groups);
128                }
129        }
Note: See TracBrowser for help on using the repository browser.