update documentation to run properly in phpdoumentor

This commit is contained in:
Cornelius Weiß 2005-11-09 21:03:35 +00:00
parent a53e060aa0
commit 4e20826dcf
7 changed files with 522 additions and 480 deletions

View File

@ -1,209 +1,215 @@
<?php
/**************************************************************************\
* eGroupWare - resources *
* http://www.egroupware.org *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
* -------------------------------------------- *
\**************************************************************************/
/**************************************************************************\
* eGroupWare - resources *
* http://www.egroupware.org *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
* -------------------------------------------- *
\**************************************************************************/
/* $Id$ */
/* $Id$ */
/**
* ACL business object for resources
*
* @package resources
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
*/
class bo_acl
{
/**
* @var $permissions Holds alls permissions for resources of user
*/
var $permissions;
class bo_acl
var $acl;
var $start = 0;
var $query = '';
var $sort = '';
var $total = 0;
var $accounts;
var $cats;
var $debug;
var $use_session = False;
function bo_acl($session=False)
{
/**
* @var $permissions Holds alls permissions for resources of user
*/
var $permissions;
define('EGW_ACL_CAT_ADMIN',64);
define('EGW_ACL_DIRECT_BOOKING',128);
define('EGW_ACL_CALREAD',256);
$this->permissions = $GLOBALS['egw']->acl->get_all_location_rights($GLOBALS['egw_info']['user']['account_id'],'resources',true);
$this->egw_cats =& CreateObject('phpgwapi.categories','','resources');
$this->accounts = $GLOBALS['egw']->accounts->get_list();
$this->debug = False;
var $acl;
var $start = 0;
var $query = '';
var $sort = '';
var $total = 0;
var $accounts;
var $cats;
var $debug;
var $use_session = False;
function bo_acl($session=False)
//all this is only needed when called from uiacl.
if($session)
{
define('EGW_ACL_CAT_ADMIN',64);
define('EGW_ACL_DIRECT_BOOKING',128);
define('EGW_ACL_CALREAD',256);
$this->permissions = $GLOBALS['egw']->acl->get_all_location_rights($GLOBALS['egw_info']['user']['account_id'],'resources',true);
$this->egw_cats =& CreateObject('phpgwapi.categories','','resources');
$this->accounts = $GLOBALS['egw']->accounts->get_list();
$this->debug = False;
//all this is only needed when called from uiacl.
if($session)
$this->read_sessiondata();
$this->use_session = True;
foreach(array('start','query','sort','order') as $var)
{
$this->read_sessiondata();
$this->use_session = True;
foreach(array('start','query','sort','order') as $var)
if (isset($_POST[$var]))
{
if (isset($_POST[$var]))
{
$this->$var = $_POST[$var];
}
elseif (isset($_GET[$var]))
{
$this->$var = $_GET[$var];
}
$this->$var = $_POST[$var];
}
$this->save_sessiondata();
$this->cats = $this->egw_cats->return_array('all',$this->start,True,$this->query,$this->sort,'cat_name',True);
}
}
/**
* get list of cats where current user has given rights
*
* @author Cornelius Weiss <egw@von-und-zu-weiss.de>
* @param int $perm_type one of EGW_ACL_READ, EGW_ACL_ADD, EGW_ACL_EDIT, EGW_ACL_DELETE, EGW_ACL_DIRECT_BOOKING
* @return array cat_id => cat_name
* TODO mark subcats and so on!
*/
function get_cats($perm_type)
{
$cats = $this->egw_cats->return_sorted_array(0,False,'','','',!$type);
while (list(,$cat) = @each($cats))
{
if($this->is_permitted($cat['id'],$perm_type))
elseif (isset($_GET[$var]))
{
for ($j=0,$s=''; $j < $cat['level']; $j++)
{
$s .= '&nbsp;';
}
$s .= $GLOBALS['egw']->strip_html($cat['name']);
if ($cat['app_name'] == 'phpgw')
{
$s .= '&nbsp;&lt;' . lang('Global') . '&gt;';
}
if ($cat['owner'] == '-1')
{
$s .= '&nbsp;&lt;' . lang('Global') . '&nbsp;' . lang($cat['app_name']) . '&gt;';
}
$perm_cats[$cat['id']] = $s;
$this->$var = $_GET[$var];
}
}
return $perm_cats;
$this->save_sessiondata();
$this->cats = $this->egw_cats->return_array('all',$this->start,True,$this->query,$this->sort,'cat_name',True);
}
/**
* gets name of category
*
* @author Lukas Weiss <wnz.gh05t@users.sourceforge.net>
* @param int $cat_id
* @return mixed name of category
*/
function get_cat_name($cat_id)
}
/**
* get list of cats where current user has given rights
*
* @author Cornelius Weiss <egw@von-und-zu-weiss.de>
* @param int $perm_type one of EGW_ACL_READ, EGW_ACL_ADD, EGW_ACL_EDIT, EGW_ACL_DELETE, EGW_ACL_DIRECT_BOOKING
* @return array cat_id => cat_name
* TODO mark subcats and so on!
*/
function get_cats($perm_type)
{
$cats = $this->egw_cats->return_sorted_array(0,False,'','','',!$type);
while (list(,$cat) = @each($cats))
{
return $this->egw_cats->id2name($cat_id);
}
/**
* gets userid of admin for given category
*
* @author Cornelius Weiss <egw@von-und-zu-weiss.de>
* @param int $cat_id
* @return int userid of cat admin
*/
function get_cat_admin($cat_id)
{
$cat_rights = $this->get_rights($cat_id);
foreach ($cat_rights as $userid => $right)
if($this->is_permitted($cat['id'],$perm_type))
{
if ($right & EGW_ACL_CAT_ADMIN)
for ($j=0,$s=''; $j < $cat['level']; $j++)
{
return $userid;
$s .= '&nbsp;';
}
$s .= $GLOBALS['egw']->strip_html($cat['name']);
if ($cat['app_name'] == 'phpgw')
{
$s .= '&nbsp;&lt;' . lang('Global') . '&gt;';
}
if ($cat['owner'] == '-1')
{
$s .= '&nbsp;&lt;' . lang('Global') . '&nbsp;' . lang($cat['app_name']) . '&gt;';
}
$perm_cats[$cat['id']] = $s;
}
return lang('none');
}
/**
* cheks one of the following rights for current user:
*
* EGW_ACL_READ, EGW_ACL_ADD, EGW_ACL_EDIT, EGW_ACL_DELETE, EGW_ACL_DIRECT_BOOKING
*
* @param int $cat_id
* @param int $right
* @return bool user is permitted or not for right
*/
function is_permitted($cat_id,$right)
return $perm_cats;
}
/**
* gets name of category
*
* @author Lukas Weiss <wnz.gh05t@users.sourceforge.net>
* @param int $cat_id
* @return mixed name of category
*/
function get_cat_name($cat_id)
{
return $this->egw_cats->id2name($cat_id);
}
/**
* gets userid of admin for given category
*
* @author Cornelius Weiss <egw@von-und-zu-weiss.de>
* @param int $cat_id
* @return int userid of cat admin
*/
function get_cat_admin($cat_id)
{
$cat_rights = $this->get_rights($cat_id);
foreach ($cat_rights as $userid => $right)
{
return $this->permissions['L'.$cat_id] & $right;
}
/**
* gets all rights from all user for given cat
*
* @param int $cat_id
* @return array userid => right
*/
function get_rights($cat_id)
{
return $GLOBALS['egw']->acl->get_all_rights('L'.$cat_id,'resources');
}
// privat functions from here on -------------------------------------------------------------------------
function save_sessiondata()
{
$data = array(
'start' => $this->start,
'query' => $this->query,
'sort' => $this->sort,
'order' => $this->order,
'limit' => $this->limit,
);
if($this->debug) { echo '<br>Read:'; _debug_array($data); }
$GLOBALS['egw']->session->appsession('session_data','resources_acl',$data);
}
function read_sessiondata()
{
$data = $GLOBALS['egw']->session->appsession('session_data','resources_acl');
if($this->debug) { echo '<br>Read:'; _debug_array($data); }
$this->start = $data['start'];
$this->query = $data['query'];
$this->sort = $data['sort'];
$this->order = $data['order'];
$this->limit = $data['limit'];
}
function set_rights($cat_id,$read,$write,$calread,$calbook,$admin)
{
$readcat = $read ? $read : array();
$writecat = $write ? $write : array();
$calreadcat = $calread ? $calread : array();
$calbookcat = $calbook ? $calbook : array();
$admincat = $admin ? $admin : array();
$GLOBALS['egw']->acl->delete_repository('resources','L' . $cat_id,false);
foreach($this->accounts as $num => $account)
if ($right & EGW_ACL_CAT_ADMIN)
{
$account_id = $account['account_id'];
$rights = false;
$rights = in_array($account_id,$readcat) ? ($rights | EGW_ACL_READ) : false;
$rights = in_array($account_id,$writecat) ? ($rights | EGW_ACL_READ | EGW_ACL_ADD | EGW_ACL_EDIT | EGW_ACL_DELETE): $rights;
$rights = in_array($account_id,$calreadcat) ? ($rights | EGW_ACL_CALREAD) : $rights;
$rights = in_array($account_id,$calbookcat) ? ($rights | EGW_ACL_DIRECT_BOOKING | EGW_ACL_CALREAD) : $rights;
$rights = in_array($account_id,$admincat) ? ($rights = 511) : $rights;
if ($rights)
{
$GLOBALS['egw']->acl->add_repository('resources','L'.$cat_id,$account_id,$rights);
}
return $userid;
}
}
return lang('none');
}
/**
* cheks one of the following rights for current user:
*
* EGW_ACL_READ, EGW_ACL_ADD, EGW_ACL_EDIT, EGW_ACL_DELETE, EGW_ACL_DIRECT_BOOKING
*
* @param int $cat_id
* @param int $right
* @return bool user is permitted or not for right
*/
function is_permitted($cat_id,$right)
{
return $this->permissions['L'.$cat_id] & $right;
}
/**
* gets all rights from all user for given cat
*
* @param int $cat_id
* @return array userid => right
*/
function get_rights($cat_id)
{
return $GLOBALS['egw']->acl->get_all_rights('L'.$cat_id,'resources');
}
// privat functions from here on -------------------------------------------------------------------------
function save_sessiondata()
{
$data = array(
'start' => $this->start,
'query' => $this->query,
'sort' => $this->sort,
'order' => $this->order,
'limit' => $this->limit,
);
if($this->debug) { echo '<br>Read:'; _debug_array($data); }
$GLOBALS['egw']->session->appsession('session_data','resources_acl',$data);
}
function read_sessiondata()
{
$data = $GLOBALS['egw']->session->appsession('session_data','resources_acl');
if($this->debug) { echo '<br>Read:'; _debug_array($data); }
$this->start = $data['start'];
$this->query = $data['query'];
$this->sort = $data['sort'];
$this->order = $data['order'];
$this->limit = $data['limit'];
}
function set_rights($cat_id,$read,$write,$calread,$calbook,$admin)
{
$readcat = $read ? $read : array();
$writecat = $write ? $write : array();
$calreadcat = $calread ? $calread : array();
$calbookcat = $calbook ? $calbook : array();
$admincat = $admin ? $admin : array();
$GLOBALS['egw']->acl->delete_repository('resources','L' . $cat_id,false);
foreach($this->accounts as $num => $account)
{
$account_id = $account['account_id'];
$rights = false;
$rights = in_array($account_id,$readcat) ? ($rights | EGW_ACL_READ) : false;
$rights = in_array($account_id,$writecat) ? ($rights | EGW_ACL_READ | EGW_ACL_ADD | EGW_ACL_EDIT | EGW_ACL_DELETE): $rights;
$rights = in_array($account_id,$calreadcat) ? ($rights | EGW_ACL_CALREAD) : $rights;
$rights = in_array($account_id,$calbookcat) ? ($rights | EGW_ACL_DIRECT_BOOKING | EGW_ACL_CALREAD) : $rights;
$rights = in_array($account_id,$admincat) ? ($rights = 511) : $rights;
if ($rights)
{
$GLOBALS['egw']->acl->add_repository('resources','L'.$cat_id,$account_id,$rights);
}
}
}
}

View File

@ -1,18 +1,26 @@
<?php
/**************************************************************************\
* eGroupWare - resources - Resource Management System *
* http://www.egroupware.org *
* Written by Lukas Weiss <wnz_gh05t@users.sourceforge.net> and *
* Cornelius Weiss <egw@von-und-zu-weiss.de> *
* ----------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
/**************************************************************************\
* eGroupWare - resources - Resource Management System *
* http://www.egroupware.org *
* Written by Lukas Weiss <wnz_gh05t@users.sourceforge.net> and *
* Cornelius Weiss <egw@von-und-zu-weiss.de> *
* ----------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
/**
* General business object for resources
*
* @package resources
* @author Cornelius Weiss <egw@von-und-zu-weiss.de>
* @author Lukas Weiss <wnz_gh05t@users.sourceforge.net>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
*/
class bo_resources
{
var $vfs_basedir = '/resources/';

View File

@ -1,19 +1,26 @@
<?php
/**************************************************************************\
* eGroupWare - resources hooks *
* http://www.eGroupWare.org *
* Originally written by Ralf Becker <RalfBecker@outdoor-training.de> *
* Changes for resources by Cornelius Wei<EFBFBD><egw@von-und-zu-weiss.de> *
* *
* ------------------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/**************************************************************************\
* eGroupWare - resources hooks *
* http://www.eGroupWare.org *
* Originally written by Ralf Becker <RalfBecker@outdoor-training.de> *
* Changes for resources by Cornelius Wei<EFBFBD><egw@von-und-zu-weiss.de> *
* *
* ------------------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
/* $Id$ */
/**
* General hook object for resources
* It encapsulats all the diffent hook methods
*
* @package resources
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
*/
class resources_hooks
{
function admin_prefs_sidebox($args)

View File

@ -1,110 +1,110 @@
<?php
/**************************************************************************\
* eGroupWare - eTemplate Extension - Resource Select Widgets *
* http://www.egroupware.org *
* Written by Ralf Becker <RalfBecker@outdoor-training.de> *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/**************************************************************************\
* eGroupWare - eTemplate Extension - Resource Select Widgets *
* http://www.egroupware.org *
* Written by Ralf Becker <RalfBecker@outdoor-training.de> *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
/* $Id$ */
/**
* eTemplate Extension: select a resource
*
* @package resources
* @author RalfBecker-AT-outdoor-training.de
* @license GPL
*/
class resources_select_widget
{
/**
* exported methods of this class
* @var array
*/
var $public_functions = array(
'pre_process' => True,
);
/**
* availible extensions and there names for the editor
* @var array
*/
var $human_name = 'Select Resources';
/**
* eTemplate Extension: select a resource
*
* @package resources
* @author RalfBecker-AT-outdoor-training.de
* @license GPL
*/
class resources_select_widget
* Constructor of the extension
*
* @param string $ui '' for html
*/
function resources_select_widget($ui)
{
/**
* exported methods of this class
* @var array
*/
var $public_functions = array(
'pre_process' => True,
);
/**
* availible extensions and there names for the editor
* @var array
*/
var $human_name = 'Select Resources';
/**
* Constructor of the extension
*
* @param string $ui '' for html
*/
function resources_select_widget($ui)
{
$this->ui = $ui;
}
/**
* pre-processing of the extension
*
* This function is called before the extension gets rendered
*
* @param string $name form-name of the control
* @param mixed &$value value / existing content, can be modified
* @param array &$cell array with the widget, can be modified for ui-independent widgets
* @param array &$readonlys names of widgets as key, to be made readonly
* @param mixed &$extension_data data the extension can store persisten between pre- and post-process
* @param object &$tmpl reference to the template we belong too
* @return boolean true if extra label is allowed, false otherwise
*/
function pre_process($name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl)
{
if ($cell['readonly'] && !is_array($value))
{
// no acl check here cause names are allways viewable
list($res_id,$quantity) = explode(':',$value);
$data = ExecMethod('resources.bo_resources.get_calendar_info',$res_id);
$cell['type'] = 'label';
$value = $data[0]['name']. ($data[0]['useable'] > 1 ? ' ['. ($quantity > 1 ? $quantity : 1). '/'. $data[0]['useable']. ']' : '');
return true;
}
if (!$GLOBALS['egw_info']['user']['apps']['resources'])
{
$cell = $tmpl->empty_cell();
$cell['label'] = 'no resources';
return false;
}
$tpl =& new etemplate('resources.resource_selectbox');
// keep the editor away from the generated tmpls
$tpl->no_onclick = true;
if ($value)
{
foreach((array)$value as $id)
{
list($res_id,$quantity) = explode(':',$id);
$data = ExecMethod('resources.bo_resources.get_calendar_info',$res_id);
$sel_options[$data[0]['res_id'].($quantity > 1 ? (':'.$quantity) : '')] =
$data[0]['name'].' ['.($quantity > 1 ? $quantity : 1).'/'.$data[0]['useable'].']';
}
$tpl->set_cell_attribute('resources','sel_options',$sel_options);
}
$tpl->set_cell_attribute('resources','size',(int)$cell['size'].'+');
$tpl->set_cell_attribute('resources','label',$cell['label']);
$tpl->set_cell_attribute('resources','id','resources_selectbox');
$tpl->set_cell_attribute('resources','name',$cell['name']);
if ($cell['help'])
{
$tpl->set_cell_attribute('resources','help',$cell['help']);
$tpl->set_cell_attribute('popup','label',$cell['help']);
}
$cell['type'] = 'template';
$cell['size'] = $cell['label'] = '';
$cell['name'] = 'resources.resource_selectbox';
$cell['obj'] =& $tpl;
return True; // extra Label Ok
}
$this->ui = $ui;
}
/**
* pre-processing of the extension
*
* This function is called before the extension gets rendered
*
* @param string $name form-name of the control
* @param mixed &$value value / existing content, can be modified
* @param array &$cell array with the widget, can be modified for ui-independent widgets
* @param array &$readonlys names of widgets as key, to be made readonly
* @param mixed &$extension_data data the extension can store persisten between pre- and post-process
* @param object &$tmpl reference to the template we belong too
* @return boolean true if extra label is allowed, false otherwise
*/
function pre_process($name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl)
{
if ($cell['readonly'] && !is_array($value))
{
// no acl check here cause names are allways viewable
list($res_id,$quantity) = explode(':',$value);
$data = ExecMethod('resources.bo_resources.get_calendar_info',$res_id);
$cell['type'] = 'label';
$value = $data[0]['name']. ($data[0]['useable'] > 1 ? ' ['. ($quantity > 1 ? $quantity : 1). '/'. $data[0]['useable']. ']' : '');
return true;
}
if (!$GLOBALS['egw_info']['user']['apps']['resources'])
{
$cell = $tmpl->empty_cell();
$cell['label'] = 'no resources';
return false;
}
$tpl =& new etemplate('resources.resource_selectbox');
// keep the editor away from the generated tmpls
$tpl->no_onclick = true;
if ($value)
{
foreach((array)$value as $id)
{
list($res_id,$quantity) = explode(':',$id);
$data = ExecMethod('resources.bo_resources.get_calendar_info',$res_id);
$sel_options[$data[0]['res_id'].($quantity > 1 ? (':'.$quantity) : '')] =
$data[0]['name'].' ['.($quantity > 1 ? $quantity : 1).'/'.$data[0]['useable'].']';
}
$tpl->set_cell_attribute('resources','sel_options',$sel_options);
}
$tpl->set_cell_attribute('resources','size',(int)$cell['size'].'+');
$tpl->set_cell_attribute('resources','label',$cell['label']);
$tpl->set_cell_attribute('resources','id','resources_selectbox');
$tpl->set_cell_attribute('resources','name',$cell['name']);
if ($cell['help'])
{
$tpl->set_cell_attribute('resources','help',$cell['help']);
$tpl->set_cell_attribute('popup','label',$cell['help']);
}
$cell['type'] = 'template';
$cell['size'] = $cell['label'] = '';
$cell['name'] = 'resources.resource_selectbox';
$cell['obj'] =& $tpl;
return True; // extra Label Ok
}
}

View File

@ -1,20 +1,28 @@
<?php
/**************************************************************************\
* eGroupWare - resources - Resource Management System *
* http://www.egroupware.org *
* Written by Cornelius Weiss <egw@von-und-zu-weiss.de> *
* and Lukas Weiss <wnz_gh05t@users.sourceforge.net> *
* ----------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
/**************************************************************************\
* eGroupWare - resources - Resource Management System *
* http://www.egroupware.org *
* Written by Cornelius Weiss <egw@von-und-zu-weiss.de> *
* and Lukas Weiss <wnz_gh05t@users.sourceforge.net> *
* ----------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
include_once(EGW_INCLUDE_ROOT.'/etemplate/inc/class.so_sql.inc.php');
/**
* General storage object for resources
*
* @package resources
* @author Cornelius Weiss <egw@von-und-zu-weiss.de>
* @author Lukas Weiss <wnz_gh05t@users.sourceforge.net>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
*/
class so_resources extends so_sql
{
function so_resources()

View File

@ -1,141 +1,146 @@
<?php
/**************************************************************************\
* eGroupWare - resources *
* http://www.egroupware.org *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
* -------------------------------------------- *
\**************************************************************************/
/**************************************************************************\
* eGroupWare - resources *
* http://www.egroupware.org *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
* -------------------------------------------- *
\**************************************************************************/
/* $Id$ */
class ui_acl
/* $Id$ */
/**
* ACL userinterface object for resources
*
* @package resources
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
*/
class ui_acl
{
var $start = 0;
var $query = '';
var $sort = '';
var $order = '';
var $bo;
var $accounts;
var $nextmatchs = '';
var $rights;
var $public_functions = array(
'acllist' => True,
);
function ui_acl()
{
var $start = 0;
var $query = '';
var $sort = '';
var $order = '';
var $bo;
var $accounts;
var $nextmatchs = '';
var $rights;
var $public_functions = array(
'acllist' => True,
);
function ui_acl()
{
$this->bo =& createobject('resources.bo_acl',True);
$this->accounts = $GLOBALS['egw']->accounts->get_list();
$this->nextmatchs =& createobject('phpgwapi.nextmatchs');
$this->start = $this->bo->start;
$this->query = $this->bo->query;
$this->order = $this->bo->order;
$this->sort = $this->bo->sort;
$this->cat_id = $this->bo->cat_id;
}
function acllist()
{
if (!$GLOBALS['egw']->acl->check('run',1,'admin'))
{
$this->deny();
}
if ($_POST['btnDone'])
{
$GLOBALS['egw']->redirect_link('/admin/index.php');
}
$GLOBALS['egw']->common->egw_header();
echo parse_navbar();
if ($_POST['btnSave'])
{
foreach($_POST['catids'] as $cat_id)
{
$this->bo->set_rights($cat_id,$_POST['inputread'][$cat_id],$_POST['inputwrite'][$cat_id],
$_POST['inputcalread'][$cat_id],$_POST['inputcalbook'][$cat_id],$_POST['inputadmin'][$cat_id]);
}
}
$GLOBALS['egw']->template->set_file('acl', 'acl.tpl');
$GLOBALS['egw']->template->set_block('acl','cat_list','Cblock');
$GLOBALS['egw']->template->set_var(array(
'title' => $GLOBALS['egw_info']['apps']['resources']['title'] . ' - ' . lang('Configure Access Permissions'),
'lang_search' => lang('Search'),
'lang_save' => lang('Save'),
'lang_done' => lang('Done'),
'lang_read' => lang('Read permissions'),
'lang_write' => lang('Write permissions'),
'lang_implies_read' => lang('implies read permission'),
'lang_calread' => lang('Read Calendar permissions'),
'lang_calbook' => lang('Direct booking permissions'),
'lang_implies_book' => lang('implies booking permission'),
'lang_cat_admin' => lang('Categories admin')
));
$left = $this->nextmatchs->left('/index.php',$this->start,$this->bo->catbo->total_records,'menuaction=resources.uiacl.acllist');
$right = $this->nextmatchs->right('/index.php',$this->start,$this->bo->catbo->total_records,'menuaction=resources.uiacl.acllist');
$GLOBALS['egw']->template->set_var(array(
'left' => $left,
'right' => $right,
'lang_showing' => $this->nextmatchs->show_hits($this->bo->catbo->total_records,$this->start),
'th_bg' => $GLOBALS['egw_info']['theme']['th_bg'],
'sort_cat' => $this->nextmatchs->show_sort_order(
$this->sort,'cat_name','cat_name','/index.php',lang('Category'),'&menuaction=resources.uiacl.acllist'
),
'query' => $this->query,
));
@reset($this->bo->cats);
while (list(,$cat) = @each($this->bo->cats))
{
$this->rights = $this->bo->get_rights($cat['id']);
$tr_color = $this->nextmatchs->alternate_row_color($tr_color);
$GLOBALS['egw']->template->set_var(array(
'tr_color' => $tr_color,
'catname' => $cat['name'],
'catid' => $cat['id'],
'read' => $this->selectlist(EGW_ACL_READ),
'write' => $this->selectlist(EGW_ACL_ADD),
'calread' => $this->selectlist(EGW_ACL_CALREAD),
'calbook' =>$this->selectlist(EGW_ACL_DIRECT_BOOKING),
'admin' => '<option value="" selected="1">'.lang('choose categories admin').'</option>'.$this->selectlist(EGW_ACL_CAT_ADMIN,true)
));
$GLOBALS['egw']->template->parse('Cblock','cat_list',True);
}
$GLOBALS['egw']->template->pfp('out','acl',True);
}
function selectlist($right,$users_only=false)
{
reset($this->bo->accounts);
while (list($null,$account) = each($this->bo->accounts))
{
if(!($users_only && $account['account_lastname'] == 'Group'))
{
$selectlist .= '<option value="' . $account['account_id'] . '"';
if($this->rights[$account['account_id']] & $right)
{
$selectlist .= ' selected="selected"';
}
$selectlist .= '>' . $account['account_firstname'] . ' ' . $account['account_lastname']
. ' [ ' . $account['account_lid'] . ' ]' . '</option>' . "\n";
}
}
return $selectlist;
}
function deny()
{
echo '<p><center><b>'.lang('Access not permitted').'</b></center>';
$GLOBALS['egw']->common->egw_exit(True);
}
$this->bo =& createobject('resources.bo_acl',True);
$this->accounts = $GLOBALS['egw']->accounts->get_list();
$this->nextmatchs =& createobject('phpgwapi.nextmatchs');
$this->start = $this->bo->start;
$this->query = $this->bo->query;
$this->order = $this->bo->order;
$this->sort = $this->bo->sort;
$this->cat_id = $this->bo->cat_id;
}
?>
function acllist()
{
if (!$GLOBALS['egw']->acl->check('run',1,'admin'))
{
$this->deny();
}
if ($_POST['btnDone'])
{
$GLOBALS['egw']->redirect_link('/admin/index.php');
}
$GLOBALS['egw']->common->egw_header();
echo parse_navbar();
if ($_POST['btnSave'])
{
foreach($_POST['catids'] as $cat_id)
{
$this->bo->set_rights($cat_id,$_POST['inputread'][$cat_id],$_POST['inputwrite'][$cat_id],
$_POST['inputcalread'][$cat_id],$_POST['inputcalbook'][$cat_id],$_POST['inputadmin'][$cat_id]);
}
}
$GLOBALS['egw']->template->set_file('acl', 'acl.tpl');
$GLOBALS['egw']->template->set_block('acl','cat_list','Cblock');
$GLOBALS['egw']->template->set_var(array(
'title' => $GLOBALS['egw_info']['apps']['resources']['title'] . ' - ' . lang('Configure Access Permissions'),
'lang_search' => lang('Search'),
'lang_save' => lang('Save'),
'lang_done' => lang('Done'),
'lang_read' => lang('Read permissions'),
'lang_write' => lang('Write permissions'),
'lang_implies_read' => lang('implies read permission'),
'lang_calread' => lang('Read Calendar permissions'),
'lang_calbook' => lang('Direct booking permissions'),
'lang_implies_book' => lang('implies booking permission'),
'lang_cat_admin' => lang('Categories admin')
));
$left = $this->nextmatchs->left('/index.php',$this->start,$this->bo->catbo->total_records,'menuaction=resources.uiacl.acllist');
$right = $this->nextmatchs->right('/index.php',$this->start,$this->bo->catbo->total_records,'menuaction=resources.uiacl.acllist');
$GLOBALS['egw']->template->set_var(array(
'left' => $left,
'right' => $right,
'lang_showing' => $this->nextmatchs->show_hits($this->bo->catbo->total_records,$this->start),
'th_bg' => $GLOBALS['egw_info']['theme']['th_bg'],
'sort_cat' => $this->nextmatchs->show_sort_order(
$this->sort,'cat_name','cat_name','/index.php',lang('Category'),'&menuaction=resources.uiacl.acllist'
),
'query' => $this->query,
));
@reset($this->bo->cats);
while (list(,$cat) = @each($this->bo->cats))
{
$this->rights = $this->bo->get_rights($cat['id']);
$tr_color = $this->nextmatchs->alternate_row_color($tr_color);
$GLOBALS['egw']->template->set_var(array(
'tr_color' => $tr_color,
'catname' => $cat['name'],
'catid' => $cat['id'],
'read' => $this->selectlist(EGW_ACL_READ),
'write' => $this->selectlist(EGW_ACL_ADD),
'calread' => $this->selectlist(EGW_ACL_CALREAD),
'calbook' =>$this->selectlist(EGW_ACL_DIRECT_BOOKING),
'admin' => '<option value="" selected="1">'.lang('choose categories admin').'</option>'.$this->selectlist(EGW_ACL_CAT_ADMIN,true)
));
$GLOBALS['egw']->template->parse('Cblock','cat_list',True);
}
$GLOBALS['egw']->template->pfp('out','acl',True);
}
function selectlist($right,$users_only=false)
{
reset($this->bo->accounts);
while (list($null,$account) = each($this->bo->accounts))
{
if(!($users_only && $account['account_lastname'] == 'Group'))
{
$selectlist .= '<option value="' . $account['account_id'] . '"';
if($this->rights[$account['account_id']] & $right)
{
$selectlist .= ' selected="selected"';
}
$selectlist .= '>' . $account['account_firstname'] . ' ' . $account['account_lastname']
. ' [ ' . $account['account_lid'] . ' ]' . '</option>' . "\n";
}
}
return $selectlist;
}
function deny()
{
echo '<p><center><b>'.lang('Access not permitted').'</b></center>';
$GLOBALS['egw']->common->egw_exit(True);
}
}

View File

@ -1,18 +1,26 @@
<?php
/**************************************************************************\
* eGroupWare - resources - Resource Management System *
* http://www.egroupware.org *
* Written by Lukas Weiss <wnz_gh05t@users.sourceforge.net> and *
* Cornelius Weiss <egw@von-und-zu-weiss.de> *
* ----------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
/**************************************************************************\
* eGroupWare - resources - Resource Management System *
* http://www.egroupware.org *
* Written by Lukas Weiss <wnz_gh05t@users.sourceforge.net> and *
* Cornelius Weiss <egw@von-und-zu-weiss.de> *
* ----------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
/**
* General userinterface object for resources
*
* @package resources
* @author Cornelius Weiss <egw@von-und-zu-weiss.de>
* @author Lukas Weiss <wnz_gh05t@users.sourceforge.net>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
*/
class ui_resources
{
var $public_functions = array(