fix not loaded header / CSS, renamed classes for autoloading and changed new admin_denyaccess to use new api

This commit is contained in:
Ralf Becker 2016-05-14 21:04:03 +02:00
parent ff19bd6601
commit a83f4a2483
7 changed files with 190 additions and 237 deletions

View File

@ -15,7 +15,7 @@ use EGroupware\Api\Egw;
/**
* Class to admin cron-job like timed calls of eGroupWare methods
*/
class uiasyncservice
class admin_asyncservice
{
var $public_functions = array(
'index' => True,
@ -29,8 +29,7 @@ class uiasyncservice
}
$GLOBALS['egw_info']['flags']['app_header'] = lang('Admin').' - '.lang('Asynchronous timed services');
$GLOBALS['egw']->framework->header();
echo parse_navbar();
echo $GLOBALS['egw']->framework->header();
$async = $GLOBALS['egw']->asyncservice; // use an own instance, as we might set debug=True
@ -62,7 +61,7 @@ class uiasyncservice
{
echo '<p><b>'.lang("You have no email address for your user set !!!")."</b></p>\n";
}
elseif (!$async->set_timer($times,'test','admin.uiasyncservice.test',$GLOBALS['egw_info']['user']['account_email']))
elseif (!$async->set_timer($times,'test','admin.admin_asyncservice.test',$GLOBALS['egw_info']['user']['account_email']))
{
echo '<p><b>'.lang("Error setting timer, wrong syntax or maybe there's one already running !!!")."</b></p>\n";
}
@ -87,7 +86,7 @@ class uiasyncservice
{
$times = array('min' => '*/5'); // set some default
}
echo '<form action="'.$GLOBALS['egw']->link('/index.php',array('menuaction'=>'admin.uiasyncservice.index')).'" method="POST">'."\n<p>";
echo '<form action="'.$GLOBALS['egw']->link('/index.php',array('menuaction'=>'admin.admin_asyncservice.index')).'" method="POST">'."\n<p>";
echo '<div style="text-align: left; margin: 10px;">'."\n";
$last_run = $async->last_check_run();
@ -188,6 +187,7 @@ class uiasyncservice
}
echo '<p><input type="submit" name="update" value="'.lang('Update').'"></p>'."\n";
echo "</form>\n";
echo $GLOBALS['egw']->framework->footer();
}
function test($to)

View File

@ -0,0 +1,168 @@
<?php
/**
* EGgroupware admin - Deny access
*
* @link http://www.egroupware.org
* @package admin
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
use EGroupware\Api;
use EGroupware\Api\Framework;
/**
* Deny access to certain parts of admin
*/
class admin_denyaccess
{
var $template;
var $nextmatchs;
var $public_functions = array(
'list_apps' => True,
'access_form' => True,
'account_list' => True
);
function __construct()
{
$this->account_id = (int)$_GET['account_id'];
if (!$this->account_id || $GLOBALS['egw']->acl->check('account_access',64,'admin'))
{
$GLOBALS['egw']->redirect_link('/index.php');
}
$this->template = new Framework\Template(Framework\Template::get_dir('admin'));
}
function common_header()
{
$GLOBALS['egw_info']['flags']['app_header'] = lang('Admin') . ' - ' . lang('ACL Manager') .
': ' . Api\Accounts::username($this->account_id);
echo $GLOBALS['egw']->framework->header();
}
function list_apps()
{
$this->common_header();
Api\Hooks::process('acl_manager',array('preferences'));
$this->template->set_file(array(
'app_list' => 'acl_applist.tpl'
));
$this->template->set_block('app_list','list');
$this->template->set_block('app_list','app_row');
$this->template->set_block('app_list','app_row_noicon');
$this->template->set_block('app_list','link_row');
$this->template->set_block('app_list','spacer_row');
if (is_array($GLOBALS['acl_manager']))
{
foreach($GLOBALS['acl_manager'] as $app => $locations)
{
$icon = Api\Image::find($app,array('navbar.png',$app.'png','navbar.gif',$app.'.gif'));
$this->template->set_var('icon_backcolor',$GLOBALS['egw_info']['theme']['row_off']);
$this->template->set_var('link_backcolor',$GLOBALS['egw_info']['theme']['row_off']);
$this->template->set_var('app_name',$GLOBALS['egw_info']['apps'][$app]['title']);
$this->template->set_var('app_icon',$icon);
if ($icon)
{
$this->template->fp('rows','app_row',True);
}
else
{
$this->template->fp('rows','app_row_noicon',True);
}
if (is_array($locations))
{
foreach($locations as $loc => $value)
{
$link_values = array(
'menuaction' => 'admin.admin_denyaccess.access_form',
'location' => $loc,
'acl_app' => $app,
'account_id' => $this->account_id
);
$this->template->set_var('link_location',$GLOBALS['egw']->link('/index.php',$link_values));
$this->template->set_var('lang_location',lang($value['name']));
$this->template->fp('rows','link_row',True);
}
}
$this->template->parse('rows','spacer_row',True);
}
}
$this->template->set_var(array(
'cancel_action' => $GLOBALS['egw']->link('/admin/index.php'),
'lang_cancel' => lang('Cancel')
));
$this->template->pfp('out','list');
echo $GLOBALS['egw']->framework->footer();
}
function access_form()
{
$location = $_GET['location'];
if ($_POST['submit'] || $_POST['cancel'])
{
if ($_POST['submit'])
{
$total_rights = 0;
if (is_array($_POST['acl_rights']))
{
foreach($_POST['acl_rights'] as $rights)
{
$total_rights += $rights;
}
}
if ($total_rights)
{
$GLOBALS['egw']->acl->add_repository($_GET['acl_app'], $location, $this->account_id, $total_rights);
}
else // we dont need to save 0 rights (= no restrictions)
{
$GLOBALS['egw']->acl->delete_repository($_GET['acl_app'], $location, $this->account_id);
}
}
$this->list_apps();
return;
}
Api\Hooks::single('acl_manager',$_GET['acl_app']);
$acl_manager = $GLOBALS['acl_manager'][$_GET['acl_app']][$location];
$this->common_header();
$this->template->set_file('form','acl_manager_form.tpl');
$afn = Api\Accounts::username($this->account_id);
$this->template->set_var('lang_message',lang('Check items to <b>%1</b> to %2 for %3',lang($acl_manager['name']),$GLOBALS['egw_info']['apps'][$_GET['acl_app']]['title'],$afn));
$link_values = array(
'menuaction' => 'admin.admin_denyaccess.access_form',
'acl_app' => $_GET['acl_app'],
'location' => urlencode($_GET['location']),
'account_id' => $this->account_id
);
$acl = new Api\Acl($this->account_id);
$acl->read_repository();
$grants = $acl->get_rights($location,$_GET['acl_app']);
$this->template->set_var('form_action',$GLOBALS['egw']->link('/index.php',$link_values));
foreach($acl_manager['rights'] as $name => $value)
{
$cb .= '<input type="checkbox" name="acl_rights[]" value="'.$value.'"'.($grants & $value ? ' checked' : '').'>&nbsp;'.lang($name)."<br>\n";
}
$this->template->set_var('select_values',$cb);
$this->template->set_var('lang_submit',lang('Save'));
$this->template->set_var('lang_cancel',lang('Cancel'));
$this->template->pfp('out','form');
echo $GLOBALS['egw']->framework->footer();
}
}

View File

@ -90,7 +90,7 @@ class admin_hooks
if (!$GLOBALS['egw']->acl->check('mainscreen_messa',1,'admin') || !$GLOBALS['egw']->acl->check('mainscreen_messa',2,'admin'))
{
$file['Change Main Screen Message'] = Egw::link('/index.php','menuaction=admin.uimainscreen.index');
$file['Change Main Screen Message'] = Egw::link('/index.php','menuaction=admin.admin_messages.index');
}
if (! $GLOBALS['egw']->acl->check('current_sessions',1,'admin'))
@ -121,7 +121,7 @@ class admin_hooks
if (! $GLOBALS['egw']->acl->check('asyncservice_acc',1,'admin'))
{
$file['Asynchronous timed services'] = Egw::link('/index.php','menuaction=admin.uiasyncservice.index');
$file['Asynchronous timed services'] = Egw::link('/index.php','menuaction=admin.admin_asyncservice.index');
}
if (! $GLOBALS['egw']->acl->check('db_backup_access',1,'admin'))
@ -210,7 +210,7 @@ class admin_hooks
$actions[] = array(
'description' => 'Deny access',
'url' => '/index.php',
'extradata' => 'menuaction=admin.uiaclmanager.list_apps',
'extradata' => 'menuaction=admin.admin_denyaccess.list_apps',
'icon' => 'cancel',
);
}

View File

@ -11,7 +11,10 @@
use EGroupware\Api;
use EGroupware\Api\Framework;
class uimainscreen
/**
* Mainscreen and login message
*/
class admin_messages
{
var $public_functions = array('index' => True);
@ -35,7 +38,7 @@ class uimainscreen
$GLOBALS['egw']->redirect_link('/admin/index.php');
}
Framework::includeJS('ckeditor','ckeditor','phpgwapi');
Framework::includeJS('ckeditor','ckeditor');
$GLOBALS['egw']->template->set_file(array('message' => 'mainscreen_message.tpl'));
$GLOBALS['egw']->template->set_block('message','form','form');
@ -67,10 +70,9 @@ class uimainscreen
}
if (empty($section))
{
$GLOBALS['egw']->framework->header();
echo parse_navbar();
echo $GLOBALS['egw']->framework->header();
$GLOBALS['egw']->template->set_var('form_action',$GLOBALS['egw']->link('/index.php','menuaction=admin.uimainscreen.index'));
$GLOBALS['egw']->template->set_var('form_action',$GLOBALS['egw']->link('/index.php','menuaction=admin.admin_messages.index'));
$GLOBALS['egw']->template->set_var('value','&nbsp;');
$GLOBALS['egw']->template->fp('rows','row_2',True);
@ -114,10 +116,9 @@ class uimainscreen
Api\Html::htmlspecialchars($current_message) . '</textarea>';
$htmlarea_button = Api\Html::submit_button("yes", lang('activate WYSIWYG-editor'));
}
$GLOBALS['egw']->framework->header();
echo parse_navbar();
echo $GLOBALS['egw']->framework->header();
$GLOBALS['egw']->template->set_var('form_action',$GLOBALS['egw']->link('/index.php','menuaction=admin.uimainscreen.index'));
$GLOBALS['egw']->template->set_var('form_action',$GLOBALS['egw']->link('/index.php','menuaction=admin.admin_messages.index'));
$GLOBALS['egw']->template->set_var('select_lang',$select_lang);
$GLOBALS['egw']->template->set_var('section',$section);
$GLOBALS['egw']->template->set_var('value','&nbsp;');
@ -135,5 +136,7 @@ class uimainscreen
$GLOBALS['egw']->template->set_var('lang_cancel',lang('Cancel'));
$GLOBALS['egw']->template->pparse('out','form');
echo $GLOBALS['egw']->framework->footer();
}
}

View File

@ -1,49 +0,0 @@
<?php
/**************************************************************************\
* eGroupWare - Administration *
* 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 boaclmanager
{
var $ui;
var $so;
var $public_functions = array(
'submit' => True
);
function boaclmanager()
{
//$this->so =& CreateObject('admin.soaclmanager');
$this->ui =& CreateObject('admin.uiaclmanager');
}
function submit()
{
if ($GLOBALS['cancel'])
{
$this->ui->list_apps();
return False;
}
$location = base64_decode($GLOBALS['location']);
$total_rights = 0;
while (is_array($GLOBALS['acl_rights']) && list(,$rights) = each($GLOBALS['acl_rights']))
{
$total_rights += $rights;
}
$GLOBALS['egw']->acl->add_repository($GLOBALS['acl_app'], $location, $GLOBALS['account_id'], $total_rights);
$this->ui->list_apps();
}
}

View File

@ -1,167 +0,0 @@
<?php
/**************************************************************************\
* eGroupWare - Administration *
* 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 uiaclmanager
{
var $template;
var $nextmatchs;
var $public_functions = array(
'list_apps' => True,
'access_form' => True,
'account_list' => True
);
function uiaclmanager()
{
$this->account_id = (int)$_GET['account_id'];
if (!$this->account_id || $GLOBALS['egw']->acl->check('account_access',64,'admin'))
{
$GLOBALS['egw']->redirect_link('/index.php');
}
$this->template =& CreateObject('phpgwapi.Template',EGW_APP_TPL);
}
function common_header()
{
$GLOBALS['egw_info']['flags']['app_header'] = lang('Admin') . ' - ' . lang('ACL Manager') .
': ' . $GLOBALS['egw']->common->grab_owner_name($this->account_id);
$GLOBALS['egw']->common->egw_header();
echo parse_navbar();
}
function list_apps()
{
$this->common_header();
$GLOBALS['egw']->hooks->process('acl_manager',array('preferences'));
$this->template->set_file(array(
'app_list' => 'acl_applist.tpl'
));
$this->template->set_block('app_list','list');
$this->template->set_block('app_list','app_row');
$this->template->set_block('app_list','app_row_noicon');
$this->template->set_block('app_list','link_row');
$this->template->set_block('app_list','spacer_row');
if (is_array($GLOBALS['acl_manager']))
{
foreach($GLOBALS['acl_manager'] as $app => $locations)
{
$icon = $GLOBALS['egw']->common->image($app,array('navbar.png',$app.'png','navbar.gif',$app.'.gif'));
$this->template->set_var('icon_backcolor',$GLOBALS['egw_info']['theme']['row_off']);
$this->template->set_var('link_backcolor',$GLOBALS['egw_info']['theme']['row_off']);
$this->template->set_var('app_name',$GLOBALS['egw_info']['apps'][$app]['title']);
$this->template->set_var('a_name',$appname);
$this->template->set_var('app_icon',$icon);
if ($icon)
{
$this->template->fp('rows','app_row',True);
}
else
{
$this->template->fp('rows','app_row_noicon',True);
}
if (is_array($locations))
{
foreach($locations as $loc => $value)
{
$link_values = array(
'menuaction' => 'admin.uiaclmanager.access_form',
'location' => $loc,
'acl_app' => $app,
'account_id' => $this->account_id
);
$this->template->set_var('link_location',$GLOBALS['egw']->link('/index.php',$link_values));
$this->template->set_var('lang_location',lang($value['name']));
$this->template->fp('rows','link_row',True);
}
}
$this->template->parse('rows','spacer_row',True);
}
}
$this->template->set_var(array(
'cancel_action' => $GLOBALS['egw']->link('/admin/index.php'),
'lang_cancel' => lang('Cancel')
));
$this->template->pfp('out','list');
}
function access_form()
{
$location = $_GET['location'];
if ($_POST['submit'] || $_POST['cancel'])
{
if ($_POST['submit'])
{
$total_rights = 0;
if (is_array($_POST['acl_rights']))
{
foreach($_POST['acl_rights'] as $rights)
{
$total_rights += $rights;
}
}
if ($total_rights)
{
$GLOBALS['egw']->acl->add_repository($_GET['acl_app'], $location, $this->account_id, $total_rights);
}
else // we dont need to save 0 rights (= no restrictions)
{
$GLOBALS['egw']->acl->delete_repository($_GET['acl_app'], $location, $this->account_id);
}
}
$this->list_apps();
return;
}
$GLOBALS['egw']->hooks->single('acl_manager',$_GET['acl_app']);
$acl_manager = $GLOBALS['acl_manager'][$_GET['acl_app']][$location];
$this->common_header();
$this->template->set_file('form','acl_manager_form.tpl');
$acc =& CreateObject('phpgwapi.accounts',$this->account_id);
$acc->read_repository();
$afn = $GLOBALS['egw']->common->display_fullname($acc->data['account_lid'],$acc->data['firstname'],$acc->data['lastname']);
$this->template->set_var('lang_message',lang('Check items to <b>%1</b> to %2 for %3',lang($acl_manager['name']),$GLOBALS['egw_info']['apps'][$_GET['acl_app']]['title'],$afn));
$link_values = array(
'menuaction' => 'admin.uiaclmanager.access_form',
'acl_app' => $_GET['acl_app'],
'location' => urlencode($_GET['location']),
'account_id' => $this->account_id
);
$acl =& CreateObject('phpgwapi.acl',$this->account_id);
$acl->read_repository();
$grants = $acl->get_rights($location,$_GET['acl_app']);
$this->template->set_var('form_action',$GLOBALS['egw']->link('/index.php',$link_values));
$total = 0;
foreach($acl_manager['rights'] as $name => $value)
{
$cb .= '<input type="checkbox" name="acl_rights[]" value="'.$value.'"'.($grants & $value ? ' checked' : '').'>&nbsp;'.lang($name)."<br>\n";
}
$this->template->set_var('select_values',$cb);
$this->template->set_var('lang_submit',lang('Save'));
$this->template->set_var('lang_cancel',lang('Cancel'));
$this->template->pfp('out','form');
}
}

View File

@ -1,6 +1,6 @@
<?php
/**
* EGgroupware administration
* EGgroupware admin - Deny access
*
* @link http://www.egroupware.org
* @package admin
@ -8,13 +8,11 @@
* @version $Id$
*/
use EGroupware\Api;
$GLOBALS['acl_manager']['admin']['site_config_acce'] = array(
'name' => 'Deny access to site configuration',
'rights' => array(
'List Api\Config settings' => 1,
'Change Api\Config settings' => 2
'List config settings' => 1,
'Change config settings' => 2
)
); // added and working ralfbecker