"documented and moderniced class a little"

This commit is contained in:
Ralf Becker 2009-11-19 10:02:00 +00:00
parent 9e6d97f106
commit f0be57c0d2

View File

@ -1,23 +1,42 @@
<?php
/**************************************************************************\
* eGroupWare - Preferences *
* 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$ */
/**
* EGroupware - UI for setting ACL
*
* @link http://www.egroupware.org
* @package preferences
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
/**
* UI for setting ACL
*/
class uiaclprefs
{
/**
* Instance of acl class
*
* @var acl
*/
var $acl;
/**
* Instance of Template class
*
* @var Template
*/
var $template;
/**
* Functions callable via menuaction
*
* @var array
*/
var $public_functions = array('index' => True);
/**
* UI to set / show ACL
*
*/
function index()
{
$query_types = array(
@ -41,13 +60,13 @@
}
else
{
$GLOBALS['egw']->translation->add_app($acl_app);
translation::add_app($acl_app);
}
// make acl called via sidebox menu of an app, to behave like a part of that app
$referer = $_POST['referer'];
if (!$referer)
{
$referer = $GLOBALS['egw']->common->get_referer('/preferences/index.php');
$referer = common::get_referer('/preferences/index.php');
}
//echo '<p align="right">'."search_type='$search_type'</p>\n";
@ -69,20 +88,17 @@
if (($GLOBALS['egw_info']['server']['deny_user_grants_access'] || $owner != $GLOBALS['egw_info']['user']['account_id'])
&& !isset($GLOBALS['egw_info']['user']['apps']['admin']) || $acl_app_not_passed)
{
$GLOBALS['egw']->common->egw_header();
echo parse_navbar();
echo '<center><b>' . lang('Access not permitted') . '</b></center>';
$GLOBALS['egw']->common->egw_footer();
$GLOBALS['egw']->framework->render('<center><b>' . lang('Access not permitted') . '</b></center>',null,true);
return;
}
$owner_name = $GLOBALS['egw']->common->grab_owner_name($owner);
$owner_name = common::grab_owner_name($owner);
if(!($no_privat_grants = $GLOBALS['egw']->accounts->get_type($owner) == 'g'))
{
// admin setting acl-rights is handled as with group-rights => no private grants !!
$no_privat_grants = $owner != $GLOBALS['egw_info']['user']['account_id'];
}
$this->acl =& CreateObject('phpgwapi.acl',(int)$owner);
$this->acl = new acl((int)$owner);
$this->acl->read_repository();
if ($_POST['save'] || $_POST['apply'])
@ -144,13 +160,13 @@
}
if ($_POST['save'] || $_POST['cancel'])
{
$GLOBALS['egw']->redirect_link($referer);
egw::redirect_link($referer);
}
$GLOBALS['egw_info']['flags']['app_header'] = lang('%1 - Preferences',$GLOBALS['egw_info']['apps'][$acl_app]['title']).' - '.lang('acl').': '.$owner_name;
$GLOBALS['egw']->common->egw_header();
common::egw_header();
echo parse_navbar();
$this->template =& CreateObject('phpgwapi.Template',$GLOBALS['egw']->common->get_tpl_dir($acl_app));
$this->template = new Template(common::get_tpl_dir($acl_app));
$templates = Array (
'preferences' => '../../../preferences/templates/default/acl.tpl',
'row_colspan' => 'preference_colspan.tpl',
@ -176,7 +192,7 @@
$var = Array(
'errors' => '',
'title' => '<br>',
'action_url' => $GLOBALS['egw']->link('/index.php','menuaction=preferences.uiaclprefs.index&acl_app=' . $acl_app),
'action_url' => egw::link('/index.php','menuaction=preferences.uiaclprefs.index&acl_app=' . $acl_app),
'lang_save' => lang('Save'),
'lang_apply' => lang('Apply'),
'lang_cancel' => lang('Cancel'),
@ -207,11 +223,7 @@
$totalentries = $GLOBALS['egw']->accounts->total;
$shownentries = count($accounts);
$memberships = array();
foreach((array) $GLOBALS['egw']->accounts->membership($owner) as $data)
{
if ($data) $memberships[] = $data['account_id'];
}
$memberships = $GLOBALS['egw']->accounts->memberships($owner,true);
$header_type = '';
$processed = Array();
foreach((array)$accounts as $uid => $data)
@ -236,7 +248,7 @@
}
else
{
$this->display_row($tr_class,'u_',$data['account_id'],$GLOBALS['egw']->common->display_fullname($data['account_lid'],$data['account_firstname'],$data['account_lastname']),$no_privat_grants,$memberships);
$this->display_row($tr_class,'u_',$data['account_id'],common::display_fullname($data['account_lid'],$data['account_firstname'],$data['account_lastname']),$no_privat_grants,$memberships);
}
$processed[] = $data['account_id'];
}
@ -268,7 +280,7 @@
$extra_parms['query'] = $letter;
$this->template->set_var(array(
'letter' => $letter,
'link' => $GLOBALS['egw']->link('/index.php',$extra_parms),
'link' => egw::link('/index.php',$extra_parms),
'class' => $query == $letter && $search_type == 'start' ? 'letter_box_active' : 'letter_box',
));
$this->template->fp('letter_search_cells','letter_search',True);
@ -278,7 +290,7 @@
unset($extra_parms['search_type']);
$this->template->set_var(array(
'letter' => lang('all'),
'link' => $GLOBALS['egw']->link('/index.php',$extra_parms),
'link' => egw::link('/index.php',$extra_parms),
'class' => $search_type != 'start' || !in_array($query,$letters) ? 'letter_box_active' : 'letter_box',
));
$this->template->fp('letter_search_cells','letter_search',True);
@ -288,6 +300,16 @@
$this->template->pfp('out','preferences');
}
/**
* Check if a single acl is checked and evtl. disabled
*
* @param string $label
* @param int $id account_id
* @param string $acl
* @param int $rights
* @param int $right
* @param boolean $disabled disable cell
*/
function check_acl($label,$id,$acl,$rights,$right,$disabled=False)
{
//echo "<p>check_acl($label,$id,$acl,$rights,$right,$disabled)</p>\n";
@ -301,6 +323,16 @@
$this->template->set_var($acl.'_selected',$rights_set);
}
/**
* Display an acl row for a given account
*
* @param string $tr_class
* @param string $label
* @param int $id account_id
* @param string $name
* @param boolean $no_privat_grants
* @param array $memberships
*/
function display_row($tr_class,$label,$id,$name,$no_privat_grants,$memberships)
{
//echo "<p>display_row(,$label,$id,$name,$no_privat_grants,".print_r($memberships,true).")</p>\n";
@ -343,4 +375,3 @@
$this->template->parse('row','acl_row',True);
}
}
?>