forked from extern/egroupware
Fix resource categories:
- category admin is different from category owner - fix error saving ACL - fix missing column IDs, which prevented user from resizing or toggling some columns
This commit is contained in:
parent
91eb837aa9
commit
726d2c3a51
@ -244,7 +244,7 @@ class resources_acl_bo
|
|||||||
|
|
||||||
$GLOBALS['egw']->acl->delete_repository('resources','L' . $cat_id,false);
|
$GLOBALS['egw']->acl->delete_repository('resources','L' . $cat_id,false);
|
||||||
|
|
||||||
foreach(array_unique(array_intersect($readcat, $writecat, $calreadcat, $calbookcat, $admincat)) as $account_id)
|
foreach(array_unique(array_merge($readcat, $writecat, $calreadcat, $calbookcat, $admincat)) as $account_id)
|
||||||
{
|
{
|
||||||
$rights = false;
|
$rights = false;
|
||||||
$rights = in_array($account_id,$readcat) ? ($rights | Acl::READ) : false;
|
$rights = in_array($account_id,$readcat) ? ($rights | Acl::READ) : false;
|
||||||
|
@ -35,7 +35,8 @@ class resources_acl_ui
|
|||||||
'read' => Acl::READ,
|
'read' => Acl::READ,
|
||||||
'write' => Acl::ADD,
|
'write' => Acl::ADD,
|
||||||
'calread' => resources_acl_bo::CAL_READ,
|
'calread' => resources_acl_bo::CAL_READ,
|
||||||
'calwrite' => resources_acl_bo::DIRECT_BOOKING
|
'calwrite' => resources_acl_bo::DIRECT_BOOKING,
|
||||||
|
'admin' => resources_acl_bo::CAT_ADMIN
|
||||||
);
|
);
|
||||||
|
|
||||||
function __construct()
|
function __construct()
|
||||||
@ -64,7 +65,7 @@ class resources_acl_ui
|
|||||||
'row_id' => 'id', // I key into row content to set it's value as row-id, eg. 'id'
|
'row_id' => 'id', // I key into row content to set it's value as row-id, eg. 'id'
|
||||||
'parent_id' => 'parent',// I key into row content of children linking them to their parent, also used as col_filter to query children
|
'parent_id' => 'parent',// I key into row content of children linking them to their parent, also used as col_filter to query children
|
||||||
'dataStorePrefix'=> 'categories',// Avoid conflict with user list when in admin
|
'dataStorePrefix'=> 'categories',// Avoid conflict with user list when in admin
|
||||||
'actions' => $this->get_actions(), // I array with actions, see nextmatch_widget::egw_actions
|
'actions' => self::get_actions(), // I array with actions, see nextmatch_widget::egw_actions
|
||||||
'placeholder_actions' => array('add') // I Array Optional list of actions allowed on the placeholder. If not provided, it's ["add"].
|
'placeholder_actions' => array('add') // I Array Optional list of actions allowed on the placeholder. If not provided, it's ["add"].
|
||||||
);
|
);
|
||||||
$template = new Etemplate('resources.acl');
|
$template = new Etemplate('resources.acl');
|
||||||
@ -73,7 +74,7 @@ class resources_acl_ui
|
|||||||
$template->exec(__METHOD__, $content, $sel_options, $readonlys);
|
$template->exec(__METHOD__, $content, $sel_options, $readonlys);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function get_actions($appname='resources') {
|
protected static function get_actions($appname='resources') {
|
||||||
|
|
||||||
$actions = array(
|
$actions = array(
|
||||||
'open' => array( // does edit if allowed, otherwise view
|
'open' => array( // does edit if allowed, otherwise view
|
||||||
@ -163,6 +164,10 @@ class resources_acl_ui
|
|||||||
{
|
{
|
||||||
$this->deny();
|
$this->deny();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$config = Api\Config::read('resources');
|
||||||
|
$location_cats = $config['location_cats'] ? explode(',', $config['location_cats']) : array();
|
||||||
|
|
||||||
if (!isset($content))
|
if (!isset($content))
|
||||||
{
|
{
|
||||||
if (!(isset($_GET['cat_id']) && $_GET['cat_id'] > 0 &&
|
if (!(isset($_GET['cat_id']) && $_GET['cat_id'] > 0 &&
|
||||||
@ -193,8 +198,18 @@ class resources_acl_ui
|
|||||||
try {
|
try {
|
||||||
$cats->edit($content);
|
$cats->edit($content);
|
||||||
resources_acl_bo::set_rights(
|
resources_acl_bo::set_rights(
|
||||||
$content['id'], $content['read'], $content['write'], $content['calread'], $content['calwrite'], null
|
$content['id'], $content['read'], $content['write'], $content['calread'], $content['calwrite'], Array($content['admin'])
|
||||||
);
|
);
|
||||||
|
if($content['location'])
|
||||||
|
{
|
||||||
|
$location_cats[] = $content['id'];
|
||||||
|
$location_cats = array_unique($location_cats);
|
||||||
|
}
|
||||||
|
else if(($key = array_search($content['id'], $location_cats)) !== false)
|
||||||
|
{
|
||||||
|
unset($location_cats[$key]);
|
||||||
|
}
|
||||||
|
config::save_value('location_cats', implode(',', $location_cats), 'resources');
|
||||||
$msg = lang('Category saved.');
|
$msg = lang('Category saved.');
|
||||||
}
|
}
|
||||||
catch (Api\Exception\WrongUserinput $e)
|
catch (Api\Exception\WrongUserinput $e)
|
||||||
@ -224,24 +239,24 @@ class resources_acl_ui
|
|||||||
$content['icon_url'] = $content['base_url'] . $content['data']['icon'];
|
$content['icon_url'] = $content['base_url'] . $content['data']['icon'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure $content['owner'] is an array otherwise it wont show up values in the multiselectbox
|
|
||||||
if($content['owner'] == 0)
|
|
||||||
{
|
|
||||||
unset($content['owner']);
|
|
||||||
}
|
|
||||||
else if (!is_array($content['owner']))
|
|
||||||
{
|
|
||||||
$content['owner'] = explode(',',$content['owner']);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach(self::$acl_map as $field => $acl)
|
foreach(self::$acl_map as $field => $acl)
|
||||||
{
|
{
|
||||||
$content[$field] = $GLOBALS['egw']->acl->get_ids_for_location('L'.$content['id'], $acl, 'resources');
|
$content[$field] = $GLOBALS['egw']->acl->get_ids_for_location('L'.$content['id'], $acl, 'resources');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make sure $content['admin'] is an array otherwise it wont show up values in the multiselectbox
|
||||||
|
if($content['admin'] == 0)
|
||||||
|
{
|
||||||
|
unset($content['admin']);
|
||||||
|
}
|
||||||
|
else if (!is_array($content['admin']))
|
||||||
|
{
|
||||||
|
$content['admin'] = explode(',',$content['admin']);
|
||||||
|
}
|
||||||
|
|
||||||
// Location
|
// Location
|
||||||
$config = Api\Config::read('resources');
|
$content['location'] = in_array($content['id'],$location_cats);
|
||||||
$content['location'] = in_array($content['id'],$config['location_cats'] ? explode(',', $config['location_cats']) : array());
|
|
||||||
|
|
||||||
$tmpl = new Etemplate('resources.acl_edit');
|
$tmpl = new Etemplate('resources.acl_edit');
|
||||||
$tmpl->exec('resources.resources_acl_ui.edit',$content,$sel_options,$readonlys,$content,2);
|
$tmpl->exec('resources.resources_acl_ui.edit',$content,$sel_options,$readonlys,$content,2);
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
<column width="20%"/>
|
<column width="20%"/>
|
||||||
<column width="50"/>
|
<column width="50"/>
|
||||||
<column width="150"/>
|
<column width="150"/>
|
||||||
|
<column width="150"/>
|
||||||
<column width="50"/>
|
<column width="50"/>
|
||||||
<column width="150"/>
|
<column width="150"/>
|
||||||
<column width="150"/>
|
<column width="150"/>
|
||||||
@ -16,17 +17,18 @@
|
|||||||
<rows>
|
<rows>
|
||||||
<row class="th">
|
<row class="th">
|
||||||
<nextmatch-header label="Category" id="id"/>
|
<nextmatch-header label="Category" id="id"/>
|
||||||
<nextmatch-header label="icon"/>
|
<nextmatch-header label="Icon" id="icon"/>
|
||||||
<nextmatch-header statustext="Category admin" id="owner" empty_label="Category admin"/>
|
<nextmatch-header statustext="Category admin" id="admin" label="Category admin"/>
|
||||||
<nextmatch-header id="location" empty_label="Locations / rooms"/>
|
<nextmatch-header statustext="Category admin" id="owner" label="Category owner"/>
|
||||||
<nextmatch-header label="Read permissions" />
|
<nextmatch-header id="location" label="Locations / rooms"/>
|
||||||
|
<nextmatch-header label="Read permissions" id="read"/>
|
||||||
<vbox>
|
<vbox>
|
||||||
<nextmatch-header label="Write permissions" />
|
<nextmatch-header label="Write permissions" id="write" />
|
||||||
<description label="implies read permission"/>
|
<description label="implies read permission"/>
|
||||||
</vbox>
|
</vbox>
|
||||||
<nextmatch-header label="Read Calendar permissions" />
|
<nextmatch-header label="Read Calendar permissions" id="calread"/>
|
||||||
<vbox>
|
<vbox>
|
||||||
<nextmatch-header label="Direct booking permissions" />
|
<nextmatch-header label="Direct booking permissions" id="calwrite"/>
|
||||||
<description label="implies booking permission"/>
|
<description label="implies booking permission"/>
|
||||||
</vbox>
|
</vbox>
|
||||||
</row>
|
</row>
|
||||||
@ -36,6 +38,9 @@
|
|||||||
<description id="${row}[name]" class="$row_cont[class]"/>
|
<description id="${row}[name]" class="$row_cont[class]"/>
|
||||||
</hbox>
|
</hbox>
|
||||||
<image align="center" src="${row}[icon_url]"/>
|
<image align="center" src="${row}[icon_url]"/>
|
||||||
|
<menulist>
|
||||||
|
<menupopup type="select-account" id="${row}[admin]" readonly="true" options="All users,groups"/>
|
||||||
|
</menulist>
|
||||||
<menulist>
|
<menulist>
|
||||||
<menupopup type="select-account" id="${row}[owner]" readonly="true" options="All users,groups"/>
|
<menupopup type="select-account" id="${row}[owner]" readonly="true" options="All users,groups"/>
|
||||||
</menulist>
|
</menulist>
|
||||||
|
@ -18,8 +18,8 @@
|
|||||||
<textbox multiline="true" id="description" rows="5" cols="50" readonly="true"/>
|
<textbox multiline="true" id="description" rows="5" cols="50" readonly="true"/>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<description value="Category owner" for="owner"/>
|
<description value="Category admin" for="admin"/>
|
||||||
<select-account id="owner" account_type="both" needed="1" multiple="true" tags="true"/>
|
<select-account id="admin" account_type="both" tags="true" empty_label="Choose categories admin"/>
|
||||||
</row>
|
</row>
|
||||||
<row class="nmr" disabled="@no_private">
|
<row class="nmr" disabled="@no_private">
|
||||||
<description value="Locations / rooms"/>
|
<description value="Locations / rooms"/>
|
||||||
|
Loading…
Reference in New Issue
Block a user