[ Index ]
 

Code source de eGroupWare 1.2.106-2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/news_admin/inc/ -> class.boacl.inc.php (source)

   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: class.boacl.inc.php 19569 2005-11-03 06:25:48Z ralfbecker $ */
  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->accounts = $GLOBALS['egw']->accounts->get_list();
  31              $this->debug = False;
  32              //all this is only needed when called from uiacl. not from ui,
  33              if($session)
  34              {
  35                  $this->read_sessiondata();
  36                  $this->use_session = True;
  37                  foreach(array('start','query','sort','order') as $var)
  38                  {
  39                      if (isset($_POST[$var]))
  40                      {
  41                          $this->$var = $_POST[$var];
  42                      }
  43                      elseif (isset($_GET[$var]))
  44                      {
  45                          $this->$var = $_GET[$var];
  46                      }
  47                  }
  48                  $this->catbo =& CreateObject('phpgwapi.categories');
  49  //                $main_cat = array(array('id' => 0, 'name' => lang('Global news')));
  50  //                $this->cats = array_merge($main_cat,$this->catbo->return_array('all',$this->start,True,$this->query,$this->sort,'cat_name',True));
  51                  $this->cats = $this->catbo->return_array('all',$this->start,True,$this->query,$this->sort,'cat_name',True);
  52              }
  53              $this->permissions = $this->get_permissions(True);
  54          }
  55  
  56  		function save_sessiondata()
  57          {
  58              $data = array(
  59                  'start' => $this->start,
  60                  'query' => $this->query,
  61                  'sort'  => $this->sort,
  62                  'order' => $this->order,
  63                  'limit' => $this->limit,
  64              );
  65              if($this->debug) { echo '<br>Read:'; _debug_array($data); }
  66              $GLOBALS['egw']->session->appsession('session_data','news_admin_acl',$data);
  67          }
  68  
  69  		function read_sessiondata()
  70          {
  71              $data = $GLOBALS['egw']->session->appsession('session_data','news_admin_acl');
  72              if($this->debug) { echo '<br>Read:'; _debug_array($data); }
  73  
  74              $this->start  = $data['start'];
  75              $this->query  = $data['query'];
  76              $this->sort   = $data['sort'];
  77              $this->order  = $data['order'];
  78              $this->limit = $data['limit'];
  79          }
  80  
  81  		function get_rights($cat_id)
  82          {
  83              return $GLOBALS['egw']->acl->get_all_rights('L'.$cat_id,'news_admin');
  84          }
  85  
  86  		function is_permitted($cat_id,$right)
  87          {
  88              return $this->permissions['L'.$cat_id] & $right;
  89          }
  90  
  91  		function is_readable($cat_id)
  92          {
  93              return $this->is_permitted($cat_id,EGW_ACL_READ);
  94          }
  95  
  96  		function is_writeable($cat_id)
  97          {
  98              return $this->is_permitted($cat_id,EGW_ACL_ADD);
  99          }
 100  
 101  		function set_rights($cat_id,$read,$write)
 102          {
 103              $readcat = $read ? $read : array();
 104              $writecat = $write ? $write : array();
 105  
 106              $GLOBALS['egw']->acl->delete_repository('news_admin','L' . $cat_id,false);
 107  
 108              foreach($this->accounts as $account)
 109              {
 110                  $account_id = $account['account_id'];
 111                  //write implies read
 112                  $rights = in_array($account_id,$writecat) ?
 113                      (EGW_ACL_READ | EGW_ACL_ADD) :
 114                      (in_array($account_id,$readcat) ? EGW_ACL_READ : False);
 115  
 116                  if ($rights)
 117                  {
 118                      $GLOBALS['egw']->acl->add_repository('news_admin','L'.$cat_id,$account_id,$rights);
 119                  }
 120              }
 121          }
 122  
 123          //access permissions for current user
 124  		function get_permissions($inc_groups = False)
 125          {
 126              return $GLOBALS['egw']->acl->get_all_location_rights($GLOBALS['egw_info']['user']['account_id'],'news_admin',$inc_groups);
 127          }
 128      }


Généré le : Sun Feb 25 17:20:01 2007 par Balluche grâce à PHPXref 0.7