mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-29 03:13:40 +01:00
"documented and moderniced class a little"
This commit is contained in:
parent
9e6d97f106
commit
f0be57c0d2
@ -1,23 +1,42 @@
|
|||||||
<?php
|
<?php
|
||||||
/**************************************************************************\
|
/**
|
||||||
* eGroupWare - Preferences *
|
* EGroupware - UI for setting ACL
|
||||||
* http://www.egroupware.org *
|
*
|
||||||
* -------------------------------------------- *
|
* @link http://www.egroupware.org
|
||||||
* This program is free software; you can redistribute it and/or modify it *
|
* @package preferences
|
||||||
* under the terms of the GNU General Public License as published by the *
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||||
* Free Software Foundation; either version 2 of the License, or (at your *
|
* @version $Id$
|
||||||
* option) any later version. *
|
*/
|
||||||
\**************************************************************************/
|
|
||||||
|
|
||||||
/* $Id$ */
|
/**
|
||||||
|
* UI for setting ACL
|
||||||
class uiaclprefs
|
*/
|
||||||
{
|
class uiaclprefs
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Instance of acl class
|
||||||
|
*
|
||||||
|
* @var acl
|
||||||
|
*/
|
||||||
var $acl;
|
var $acl;
|
||||||
|
/**
|
||||||
|
* Instance of Template class
|
||||||
|
*
|
||||||
|
* @var Template
|
||||||
|
*/
|
||||||
var $template;
|
var $template;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Functions callable via menuaction
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
var $public_functions = array('index' => True);
|
var $public_functions = array('index' => True);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UI to set / show ACL
|
||||||
|
*
|
||||||
|
*/
|
||||||
function index()
|
function index()
|
||||||
{
|
{
|
||||||
$query_types = array(
|
$query_types = array(
|
||||||
@ -41,13 +60,13 @@
|
|||||||
}
|
}
|
||||||
else
|
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
|
// make acl called via sidebox menu of an app, to behave like a part of that app
|
||||||
$referer = $_POST['referer'];
|
$referer = $_POST['referer'];
|
||||||
if (!$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";
|
//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'])
|
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)
|
&& !isset($GLOBALS['egw_info']['user']['apps']['admin']) || $acl_app_not_passed)
|
||||||
{
|
{
|
||||||
$GLOBALS['egw']->common->egw_header();
|
$GLOBALS['egw']->framework->render('<center><b>' . lang('Access not permitted') . '</b></center>',null,true);
|
||||||
echo parse_navbar();
|
|
||||||
echo '<center><b>' . lang('Access not permitted') . '</b></center>';
|
|
||||||
$GLOBALS['egw']->common->egw_footer();
|
|
||||||
return;
|
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'))
|
if(!($no_privat_grants = $GLOBALS['egw']->accounts->get_type($owner) == 'g'))
|
||||||
{
|
{
|
||||||
// admin setting acl-rights is handled as with group-rights => no private grants !!
|
// admin setting acl-rights is handled as with group-rights => no private grants !!
|
||||||
$no_privat_grants = $owner != $GLOBALS['egw_info']['user']['account_id'];
|
$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();
|
$this->acl->read_repository();
|
||||||
|
|
||||||
if ($_POST['save'] || $_POST['apply'])
|
if ($_POST['save'] || $_POST['apply'])
|
||||||
@ -144,13 +160,13 @@
|
|||||||
}
|
}
|
||||||
if ($_POST['save'] || $_POST['cancel'])
|
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_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();
|
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 (
|
$templates = Array (
|
||||||
'preferences' => '../../../preferences/templates/default/acl.tpl',
|
'preferences' => '../../../preferences/templates/default/acl.tpl',
|
||||||
'row_colspan' => 'preference_colspan.tpl',
|
'row_colspan' => 'preference_colspan.tpl',
|
||||||
@ -176,7 +192,7 @@
|
|||||||
$var = Array(
|
$var = Array(
|
||||||
'errors' => '',
|
'errors' => '',
|
||||||
'title' => '<br>',
|
'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_save' => lang('Save'),
|
||||||
'lang_apply' => lang('Apply'),
|
'lang_apply' => lang('Apply'),
|
||||||
'lang_cancel' => lang('Cancel'),
|
'lang_cancel' => lang('Cancel'),
|
||||||
@ -207,11 +223,7 @@
|
|||||||
$totalentries = $GLOBALS['egw']->accounts->total;
|
$totalentries = $GLOBALS['egw']->accounts->total;
|
||||||
$shownentries = count($accounts);
|
$shownentries = count($accounts);
|
||||||
|
|
||||||
$memberships = array();
|
$memberships = $GLOBALS['egw']->accounts->memberships($owner,true);
|
||||||
foreach((array) $GLOBALS['egw']->accounts->membership($owner) as $data)
|
|
||||||
{
|
|
||||||
if ($data) $memberships[] = $data['account_id'];
|
|
||||||
}
|
|
||||||
$header_type = '';
|
$header_type = '';
|
||||||
$processed = Array();
|
$processed = Array();
|
||||||
foreach((array)$accounts as $uid => $data)
|
foreach((array)$accounts as $uid => $data)
|
||||||
@ -236,7 +248,7 @@
|
|||||||
}
|
}
|
||||||
else
|
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'];
|
$processed[] = $data['account_id'];
|
||||||
}
|
}
|
||||||
@ -268,7 +280,7 @@
|
|||||||
$extra_parms['query'] = $letter;
|
$extra_parms['query'] = $letter;
|
||||||
$this->template->set_var(array(
|
$this->template->set_var(array(
|
||||||
'letter' => $letter,
|
'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',
|
'class' => $query == $letter && $search_type == 'start' ? 'letter_box_active' : 'letter_box',
|
||||||
));
|
));
|
||||||
$this->template->fp('letter_search_cells','letter_search',True);
|
$this->template->fp('letter_search_cells','letter_search',True);
|
||||||
@ -278,7 +290,7 @@
|
|||||||
unset($extra_parms['search_type']);
|
unset($extra_parms['search_type']);
|
||||||
$this->template->set_var(array(
|
$this->template->set_var(array(
|
||||||
'letter' => lang('all'),
|
'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',
|
'class' => $search_type != 'start' || !in_array($query,$letters) ? 'letter_box_active' : 'letter_box',
|
||||||
));
|
));
|
||||||
$this->template->fp('letter_search_cells','letter_search',True);
|
$this->template->fp('letter_search_cells','letter_search',True);
|
||||||
@ -288,6 +300,16 @@
|
|||||||
$this->template->pfp('out','preferences');
|
$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)
|
function check_acl($label,$id,$acl,$rights,$right,$disabled=False)
|
||||||
{
|
{
|
||||||
//echo "<p>check_acl($label,$id,$acl,$rights,$right,$disabled)</p>\n";
|
//echo "<p>check_acl($label,$id,$acl,$rights,$right,$disabled)</p>\n";
|
||||||
@ -301,6 +323,16 @@
|
|||||||
$this->template->set_var($acl.'_selected',$rights_set);
|
$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)
|
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";
|
//echo "<p>display_row(,$label,$id,$name,$no_privat_grants,".print_r($memberships,true).")</p>\n";
|
||||||
@ -342,5 +374,4 @@
|
|||||||
}
|
}
|
||||||
$this->template->parse('row','acl_row',True);
|
$this->template->parse('row','acl_row',True);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
Loading…
Reference in New Issue
Block a user