fixed ACL was wrong way around and made use termenology more clear: data from, access by, ...

This commit is contained in:
Ralf Becker 2013-09-02 09:19:49 +00:00
parent d5613a51fe
commit 991980ac3a
4 changed files with 40 additions and 35 deletions

View File

@ -1,6 +1,6 @@
<?php
/**
* EGroupware: Admin app ACL
* EGroupware: Admin ACL
*
* @link http://www.egroupware.org
* @author Ralf Becker <rb@stylite.de>
@ -56,8 +56,8 @@ class admin_acl
{
$app = !empty($_GET['app']) && isset($GLOBALS['egw_info']['apps'][$_GET['app']]) ?
$_GET['app'] : $state['acl_appname'];
$location = $state['filter'] == 'run' ? 'run' : $state['account_id'];
$account = $state['filter'] == 'run' ? $state['account_id'] : $state['acl_account'];
$location = $state['filter'] == 'run' ? 'run' : null;//$state['account_id'];
$account = $state['account_id'];//$state['filter'] == 'run' ? $state['account_id'] : $state['acl_account'];
$rights = 1;
}
$content = array(
@ -82,7 +82,7 @@ class admin_acl
));
if ($content['save'])
{
self::check_access($content['acl_location']);
self::check_access($content['acl_account'], $content['acl_location']);
if ($content['acl_location'] == 'run')
{
@ -94,7 +94,7 @@ class admin_acl
}
egw_framework::window_close();
}
if ($content['location'] == 'run')
if ($content['acl_location'] == 'run')
{
$readonlys['acl_account'] = true;
}
@ -117,8 +117,12 @@ class admin_acl
{
$readonlys['acl_appname'] = $readonlys['acl_account'] = $readonlys['acl_location'] = true;
}
else
{
$readonlys['acl_account'] = true;
}
// only user himself is allowed to grant private rights!
if ($content['acl_location'] != $GLOBALS['egw_info']['user']['account_id'])
if ($content['acl_account'] != $GLOBALS['egw_info']['user']['account_id'])
{
$readonlys['acl[5]'] = true;
$content['preserve_rights'] = $rights & acl::PRIVAT;
@ -129,7 +133,7 @@ class admin_acl
}
}
// view only, if no rights
if (!self::check_access($content['acl_location'], false))
if (!self::check_access($content['acl_account'], $content['acl_location'], false))
{
$readonlys[__ALL__] = true;
$readonlys['cancel'] = false;
@ -270,7 +274,7 @@ class admin_acl
$query['col_filter']['acl_account'] = $memberships;
}
break;
case 'own':
case 'other':
//$query['col_filter'][] = "acl_location!='run'";
// remove everything not an account-id in location, like category based acl
if ($GLOBALS['egw']->db->Type == 'mysql')
@ -287,7 +291,7 @@ class admin_acl
}
break;
case 'other':
case 'own':
if (empty($query['col_filter']['acl_location']))
{
$query['col_filter']['acl_location'] = $memberships;//$query['account_id'];
@ -323,7 +327,7 @@ class admin_acl
}
}
}
if (!self::check_access($row['acl_location'], false)) // false: do NOT throw an exception!
if (!self::check_access($row['acl_account'], $row['acl_location'], false)) // false: do NOT throw an exception!
{
$row['class'] = 'rowNoEdit';
}
@ -336,12 +340,13 @@ class admin_acl
/**
* Check if current user has access to ACL setting of a given location
*
* @param int|string $location numeric account-id or "run"
* @param int $account_id numeric account-id
* @param int|string $location=null numeric account-id or "run"
* @param boolean $throw=true if true, throw an exception if no access, instead of just returning false
* @return boolean true if access is granted, false if notification_bo
* @throws egw_exception_no_permission
*/
public static function check_access($location, $throw=true)
public static function check_access($account_id, $location=null, $throw=true)
{
static $admin_access;
static $own_access;
@ -351,8 +356,8 @@ class admin_acl
!$GLOBALS['egw']->acl->check('account_access', 64, 'admin'); // ! because this denies access!
$own_access = $admin_access || isset($GLOBALS['egw_info']['user']['apps']['preferences']);
}
if (!($location === 'run' || (int)$location) ||
!((int)$location == (int)$GLOBALS['egw_info']['user']['account_id'] ? $own_access : $admin_access))
if (!($location === 'run' || (int)$account_id) ||
!((int)$account_id == (int)$GLOBALS['egw_info']['user']['account_id'] ? $own_access : $admin_access))
{
if ($throw) throw new egw_exception_no_permission(lang('Permission denied!!!'));
return false;
@ -375,7 +380,7 @@ class admin_acl
{
list($app, $account_id, $location) = explode(':', $id, 3);
self::check_access($location); // throws exception, if no rights
self::check_access($account_id, $location); // throws exception, if no rights
if ((int)$account_id == (int)$GLOBALS['egw_info']['user']['account_id'])
{
@ -451,8 +456,8 @@ class admin_acl
}
$sel_options = array(
'filter' => array(
'other' => 'Rights granted to others',
'own' => 'Own rights granted from others',
'other' => 'Access to my data by others',
'own' => 'My access to other data',
'run' => 'Run rights for applications',
),
);
@ -469,18 +474,18 @@ class admin_acl
{
return array(
'edit' => array(
'caption' => 'Edit ACL',
'caption' => 'Edit',
'default' => true,
'allowOnMultiple' => false,
'onExecute' => 'javaScript:app.admin.acl',
),
'add' => array(
'caption' => 'Add ACL',
'caption' => 'Add',
'onExecute' => 'javaScript:app.admin.acl',
),
'delete' => array(
'confirm' => 'Delete this ACL',
'caption' => 'Delete ACL',
'confirm' => 'Delete this access control',
'caption' => 'Delete',
'disableClass' => 'rowNoEdit',
'onExecute' => 'javaScript:app.admin.acl',
),

View File

@ -2,7 +2,7 @@
/**
* EGroupware - eTemplates for Application admin
* http://www.egroupware.org
* generated by soetemplate::dump4setup() 2013-08-28 14:49
* generated by soetemplate::dump4setup() 2013-09-02 11:13
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package admin
@ -28,9 +28,9 @@ $templ_data[] = array('name' => 'admin.accesslog.rows','template' => '','lang' =
$templ_data[] = array('name' => 'admin.acl','template' => '','lang' => '','group' => '0','version' => '1.9.001','data' => 'a:1:{i:0;a:8:{s:4:"type";s:4:"vbox";s:4:"data";a:2:{i:0;a:0:{}i:1;a:1:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:4:"span";s:8:",message";s:4:"name";s:3:"msg";}}}s:4:"rows";i:1;s:4:"cols";i:1;s:4:"size";s:1:"3";i:1;a:3:{s:4:"type";s:5:"label";s:4:"span";s:8:",message";s:4:"name";s:3:"msg";}i:2;a:3:{s:4:"type";s:9:"nextmatch";s:4:"name";s:2:"nm";s:4:"size";s:14:"admin.acl.rows";}i:3;a:1:{s:4:"type";s:5:"label";}}}','size' => '','style' => '','modified' => '1376413827',);
$templ_data[] = array('name' => 'admin.acl.edit','template' => '','lang' => '','group' => '0','version' => '1.9.001','data' => 'a:2:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:6:{i:0;a:6:{s:2:"h2";s:25:",@acl_location=run,header";s:2:"h3";s:8:",,header";s:2:"h1";s:25:",@acl_location=run,header";s:2:"c4";s:4:",top";s:2:"h4";s:18:",@acl_location=run";s:2:"h5";s:19:",!@acl_location=run";}i:1;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:11:"Application";}s:1:"B";a:5:{s:4:"type";s:6:"select";s:4:"size";s:10:"Select one";s:4:"name";s:11:"acl_appname";s:6:"needed";s:1:"1";s:8:"onchange";i:1;}}i:2;a:2:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:5:"label";s:4:"From";s:4:"size";s:15:",,,acl_location";}s:1:"B";a:3:{s:4:"type";s:14:"select-account";s:4:"name";s:12:"acl_location";s:8:"readonly";s:1:"1";}}i:3;a:2:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:5:"label";s:2:"To";s:4:"size";s:14:",,,acl_account";}s:1:"B";a:3:{s:4:"type";s:14:"select-account";s:4:"name";s:11:"acl_account";s:6:"needed";s:1:"1";}}i:4;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:6:"Rights";}s:1:"B";a:5:{s:4:"type";s:4:"grid";s:7:"options";a:0:{}s:4:"data";a:2:{i:0;a:0:{}i:1;a:1:{s:1:"A";a:5:{s:4:"type";s:8:"checkbox";s:5:"label";s:12:"@label[$row]";s:4:"name";s:9:"acl[$row]";s:4:"span";s:3:"all";s:4:"size";s:22:"{$cont[right][$row]},0";}}}s:4:"rows";i:1;s:4:"cols";i:1;}}i:5;a:2:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:5:"label";s:12:"Applications";s:4:"size";s:7:",,,apps";}s:1:"B";a:3:{s:4:"type";s:10:"select-app";s:4:"size";s:16:"8,,enabled,,,,,0";s:4:"name";s:4:"apps";}}}s:4:"rows";i:5;s:4:"cols";i:2;}i:1;a:4:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"2";i:1;a:3:{s:4:"type";s:6:"button";s:5:"label";s:4:"Save";s:4:"name";s:4:"save";}i:2;a:4:{s:4:"type";s:6:"button";s:4:"name";s:6:"cancel";s:5:"label";s:6:"Cancel";s:7:"onclick";s:15:"window.close();";}}}','size' => '','style' => '','modified' => '1377602915',);
$templ_data[] = array('name' => 'admin.acl.edit','template' => '','lang' => '','group' => '0','version' => '1.9.001','data' => 'a:2:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:6:{i:0;a:6:{s:2:"h2";s:8:",,header";s:2:"h3";s:25:",@acl_location=run,header";s:2:"h1";s:25:",@acl_location=run,header";s:2:"c4";s:4:",top";s:2:"h4";s:18:",@acl_location=run";s:2:"h5";s:19:",!@acl_location=run";}i:1;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:11:"Application";}s:1:"B";a:5:{s:4:"type";s:6:"select";s:4:"size";s:10:"Select one";s:4:"name";s:11:"acl_appname";s:6:"needed";s:1:"1";s:8:"onchange";i:1;}}i:2;a:2:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:5:"label";s:9:"Data from";s:4:"size";s:14:",,,acl_account";}s:1:"B";a:3:{s:4:"type";s:14:"select-account";s:4:"name";s:11:"acl_account";s:6:"needed";s:1:"1";}}i:3;a:2:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:5:"label";s:9:"Access by";s:4:"size";s:15:",,,acl_location";}s:1:"B";a:2:{s:4:"type";s:14:"select-account";s:4:"name";s:12:"acl_location";}}i:4;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:6:"Rights";}s:1:"B";a:5:{s:4:"type";s:4:"grid";s:7:"options";a:0:{}s:4:"data";a:2:{i:0;a:0:{}i:1;a:1:{s:1:"A";a:5:{s:4:"type";s:8:"checkbox";s:5:"label";s:12:"@label[$row]";s:4:"name";s:9:"acl[$row]";s:4:"span";s:3:"all";s:4:"size";s:22:"{$cont[right][$row]},0";}}}s:4:"rows";i:1;s:4:"cols";i:1;}}i:5;a:2:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:5:"label";s:12:"Applications";s:4:"size";s:7:",,,apps";}s:1:"B";a:3:{s:4:"type";s:10:"select-app";s:4:"size";s:16:"8,,enabled,,,,,0";s:4:"name";s:4:"apps";}}}s:4:"rows";i:5;s:4:"cols";i:2;}i:1;a:4:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"2";i:1;a:3:{s:4:"type";s:6:"button";s:5:"label";s:4:"Save";s:4:"name";s:4:"save";}i:2;a:4:{s:4:"type";s:6:"button";s:4:"name";s:6:"cancel";s:5:"label";s:6:"Cancel";s:7:"onclick";s:15:"window.close();";}}}','size' => '','style' => '','modified' => '1377602915',);
$templ_data[] = array('name' => 'admin.acl.rows','template' => '','lang' => '','group' => '0','version' => '1.9.001','data' => 'a:1:{i:0;a:6:{s:4:"type";s:4:"grid";s:4:"data";a:3:{i:0;a:1:{s:1:"A";s:2:"24";}i:1;a:12:{s:1:"A";a:1:{s:4:"type";s:5:"label";}s:1:"B";a:3:{s:4:"type";s:22:"nextmatch-customfilter";s:4:"name";s:11:"acl_appname";s:4:"size";s:27:"select-app,All applications";}s:1:"C";a:4:{s:4:"type";s:23:"nextmatch-accountfilter";s:4:"size";s:17:"All accounts,both";s:4:"name";s:12:"acl_location";s:5:"label";s:4:"From";}s:1:"D";a:4:{s:4:"type";s:23:"nextmatch-accountfilter";s:4:"size";s:17:"All accounts,both";s:4:"name";s:11:"acl_account";s:5:"label";s:2:"To";}s:1:"E";a:3:{s:4:"type";s:16:"nextmatch-header";s:5:"label";s:4:"Read";s:4:"name";s:4:"read";}s:1:"F";a:3:{s:4:"type";s:16:"nextmatch-header";s:5:"label";s:3:"Add";s:4:"name";s:3:"add";}s:1:"G";a:3:{s:4:"type";s:16:"nextmatch-header";s:5:"label";s:4:"Edit";s:4:"name";s:4:"edit";}s:1:"H";a:3:{s:4:"type";s:16:"nextmatch-header";s:5:"label";s:6:"Delete";s:4:"name";s:6:"delete";}s:1:"I";a:3:{s:4:"type";s:16:"nextmatch-header";s:5:"label";s:7:"Private";s:4:"name";s:7:"private";}s:1:"J";a:3:{s:4:"type";s:16:"nextmatch-header";s:5:"label";s:8:"Custom 1";s:4:"name";s:7:"custom1";}s:1:"K";a:3:{s:4:"type";s:16:"nextmatch-header";s:5:"label";s:8:"Custom 2";s:4:"name";s:7:"custom2";}s:1:"L";a:3:{s:4:"type";s:16:"nextmatch-header";s:5:"label";s:8:"Custom 3";s:4:"name";s:7:"custom3";}}i:2;a:12:{s:1:"A";a:4:{s:4:"type";s:5:"image";s:4:"span";s:13:",admin_aclApp";s:4:"name";s:29:"$row_cont[acl_appname]/navbar";s:5:"align";s:6:"center";}s:1:"B";a:3:{s:4:"type";s:10:"select-app";s:4:"name";s:19:"${row}[acl_appname]";s:8:"readonly";s:1:"1";}s:1:"C";a:3:{s:4:"type";s:14:"select-account";s:4:"name";s:20:"${row}[acl_location]";s:8:"readonly";s:1:"1";}s:1:"D";a:3:{s:4:"type";s:14:"select-account";s:4:"name";s:19:"${row}[acl_account]";s:8:"readonly";s:1:"1";}s:1:"E";a:2:{s:4:"type";s:5:"label";s:4:"name";s:12:"${row}[acl1]";}s:1:"F";a:2:{s:4:"type";s:5:"label";s:4:"name";s:12:"${row}[acl2]";}s:1:"G";a:2:{s:4:"type";s:5:"label";s:4:"name";s:12:"${row}[acl4]";}s:1:"H";a:2:{s:4:"type";s:5:"label";s:4:"name";s:12:"${row}[acl8]";}s:1:"I";a:2:{s:4:"type";s:5:"label";s:4:"name";s:13:"${row}[acl16]";}s:1:"J";a:2:{s:4:"type";s:5:"label";s:4:"name";s:13:"${row}[acl64]";}s:1:"K";a:2:{s:4:"type";s:5:"label";s:4:"name";s:14:"${row}[acl128]";}s:1:"L";a:2:{s:4:"type";s:5:"label";s:4:"name";s:14:"${row}[acl256]";}}}s:4:"rows";i:2;s:4:"cols";i:12;s:4:"size";s:4:"100%";s:7:"options";a:1:{i:0;s:4:"100%";}}}','size' => '100%','style' => '','modified' => '1376413969',);
$templ_data[] = array('name' => 'admin.acl.rows','template' => '','lang' => '','group' => '0','version' => '1.9.001','data' => 'a:1:{i:0;a:6:{s:4:"type";s:4:"grid";s:4:"data";a:3:{i:0;a:1:{s:1:"A";s:2:"24";}i:1;a:12:{s:1:"A";a:1:{s:4:"type";s:5:"label";}s:1:"B";a:3:{s:4:"type";s:22:"nextmatch-customfilter";s:4:"name";s:11:"acl_appname";s:4:"size";s:27:"select-app,All applications";}s:1:"C";a:4:{s:4:"type";s:23:"nextmatch-accountfilter";s:4:"size";s:17:"All accounts,both";s:4:"name";s:11:"acl_account";s:5:"label";s:9:"Data from";}s:1:"D";a:4:{s:4:"type";s:23:"nextmatch-accountfilter";s:4:"size";s:17:"All accounts,both";s:4:"name";s:12:"acl_location";s:5:"label";s:9:"Access by";}s:1:"E";a:3:{s:4:"type";s:16:"nextmatch-header";s:5:"label";s:4:"Read";s:4:"name";s:4:"read";}s:1:"F";a:3:{s:4:"type";s:16:"nextmatch-header";s:5:"label";s:3:"Add";s:4:"name";s:3:"add";}s:1:"G";a:3:{s:4:"type";s:16:"nextmatch-header";s:5:"label";s:4:"Edit";s:4:"name";s:4:"edit";}s:1:"H";a:3:{s:4:"type";s:16:"nextmatch-header";s:5:"label";s:6:"Delete";s:4:"name";s:6:"delete";}s:1:"I";a:3:{s:4:"type";s:16:"nextmatch-header";s:5:"label";s:7:"Private";s:4:"name";s:7:"private";}s:1:"J";a:3:{s:4:"type";s:16:"nextmatch-header";s:5:"label";s:8:"Custom 1";s:4:"name";s:7:"custom1";}s:1:"K";a:3:{s:4:"type";s:16:"nextmatch-header";s:5:"label";s:8:"Custom 2";s:4:"name";s:7:"custom2";}s:1:"L";a:3:{s:4:"type";s:16:"nextmatch-header";s:5:"label";s:8:"Custom 3";s:4:"name";s:7:"custom3";}}i:2;a:12:{s:1:"A";a:4:{s:4:"type";s:5:"image";s:4:"span";s:13:",admin_aclApp";s:4:"name";s:29:"$row_cont[acl_appname]/navbar";s:5:"align";s:6:"center";}s:1:"B";a:3:{s:4:"type";s:10:"select-app";s:4:"name";s:19:"${row}[acl_appname]";s:8:"readonly";s:1:"1";}s:1:"C";a:3:{s:4:"type";s:14:"select-account";s:4:"name";s:19:"${row}[acl_account]";s:8:"readonly";s:1:"1";}s:1:"D";a:3:{s:4:"type";s:14:"select-account";s:4:"name";s:20:"${row}[acl_location]";s:8:"readonly";s:1:"1";}s:1:"E";a:2:{s:4:"type";s:5:"label";s:4:"name";s:12:"${row}[acl1]";}s:1:"F";a:2:{s:4:"type";s:5:"label";s:4:"name";s:12:"${row}[acl2]";}s:1:"G";a:2:{s:4:"type";s:5:"label";s:4:"name";s:12:"${row}[acl4]";}s:1:"H";a:2:{s:4:"type";s:5:"label";s:4:"name";s:12:"${row}[acl8]";}s:1:"I";a:2:{s:4:"type";s:5:"label";s:4:"name";s:13:"${row}[acl16]";}s:1:"J";a:2:{s:4:"type";s:5:"label";s:4:"name";s:13:"${row}[acl64]";}s:1:"K";a:2:{s:4:"type";s:5:"label";s:4:"name";s:14:"${row}[acl128]";}s:1:"L";a:2:{s:4:"type";s:5:"label";s:4:"name";s:14:"${row}[acl256]";}}}s:4:"rows";i:2;s:4:"cols";i:12;s:4:"size";s:4:"100%";s:7:"options";a:1:{i:0;s:4:"100%";}}}','size' => '100%','style' => '','modified' => '1376413969',);
$templ_data[] = array('name' => 'admin.applications','template' => '','lang' => '','group' => '0','version' => '1.7.001','data' => 'a:1:{i:0;a:6:{s:4:"type";s:4:"grid";s:4:"data";a:3:{i:0;a:0:{}i:1;a:1:{s:1:"A";a:4:{s:4:"type";s:9:"nextmatch";s:4:"size";s:4:"rows";s:4:"span";s:3:"all";s:4:"name";s:2:"nm";}}i:2;a:1:{s:1:"A";a:4:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"2";i:1;a:3:{s:4:"type";s:6:"button";s:5:"label";s:28:"Number applications serially";s:4:"name";s:6:"number";}i:2;a:2:{s:4:"type";s:5:"label";s:5:"label";s:157:"Number the applications serially. If they are not numbered serially, sorting the applications could work wrong. This will not change the application\'s order.";}}}}s:4:"rows";i:2;s:4:"cols";i:1;s:4:"size";s:7:"100%,,0";s:7:"options";a:2:{i:0;s:4:"100%";i:2;s:1:"0";}}}','size' => '100%,,0','style' => '','modified' => '1276610727',);

View File

@ -14,18 +14,18 @@
<menupopup id="acl_appname" needed="1" onchange="1" options="Select one"/>
</menulist>
</row>
<row disabled="@acl_location=run" part="header">
<description value="From" for="acl_location"/>
<menulist>
<menupopup type="select-account" id="acl_location" readonly="true"/>
</menulist>
</row>
<row part="header">
<description value="To" for="acl_account"/>
<description value="Data from" for="acl_account"/>
<menulist>
<menupopup type="select-account" id="acl_account" needed="1"/>
</menulist>
</row>
<row disabled="@acl_location=run" part="header">
<description value="Access by" for="acl_location"/>
<menulist>
<menupopup type="select-account" id="acl_location"/>
</menulist>
</row>
<row valign="top" disabled="@acl_location=run">
<description value="Rights"/>
<grid>

View File

@ -21,8 +21,8 @@
<row>
<description/>
<nextmatch-customfilter id="acl_appname" options="select-app,All applications"/>
<nextmatch-accountfilter label="From" id="acl_location" options="All accounts,both"/>
<nextmatch-accountfilter label="To" id="acl_account" options="All accounts,both"/>
<nextmatch-accountfilter label="Data from" id="acl_account" options="All accounts,both"/>
<nextmatch-accountfilter label="Access by" id="acl_location" options="All accounts,both"/>
<nextmatch-header label="Read" id="read"/>
<nextmatch-header label="Add" id="add"/>
<nextmatch-header label="Edit" id="edit"/>
@ -38,10 +38,10 @@
<menupopup type="select-app" id="${row}[acl_appname]" readonly="true"/>
</menulist>
<menulist>
<menupopup type="select-account" id="${row}[acl_location]" readonly="true"/>
<menupopup type="select-account" id="${row}[acl_account]" readonly="true"/>
</menulist>
<menulist>
<menupopup type="select-account" id="${row}[acl_account]" readonly="true"/>
<menupopup type="select-account" id="${row}[acl_location]" readonly="true"/>
</menulist>
<description id="${row}[acl1]"/>
<description id="${row}[acl2]"/>