calendar GUI classes now use centralized method in categories class to check for category permissions

This commit is contained in:
Christian Binder 2009-11-26 08:28:06 +00:00
parent 30fd54c4ac
commit 5ce294aa5c
4 changed files with 12 additions and 33 deletions

View File

@ -165,35 +165,6 @@ class calendar_ui
unset($GLOBALS['egw_info']['user']['preferences']['common']['auto_hide_sidebox']); unset($GLOBALS['egw_info']['user']['preferences']['common']['auto_hide_sidebox']);
} }
/**
* Checks category permissions
* Takes a commaseparated list of category ids
* and truncates it by the ones the user does not have the requested permission on
*
* @param int $needed necessary ACL right: EGW_ACL_{READ|EDIT|DELETE}
* @param string $categories commaseparated list of category ids
* @return string truncated commaseparated list of category ids
*/
function check_category_perms($needed, $categories)
{
if (empty($categories)) return $categories;
$cat_arr = explode(',',$categories);
if (!empty($cat_arr) && is_array($cat_arr) && count($cat_arr) > 0)
{
foreach($cat_arr as $id=>$cat_id)
{
if (!$this->categories->check_perms($needed, $cat_id))
{
unset($cat_arr[$id]);
}
}
$categories = implode(',',$cat_arr);
}
return $categories;
}
/** /**
* Checks and terminates (or returns for home) with a message if $this->owner include a user/resource we have no read-access to * Checks and terminates (or returns for home) with a message if $this->owner include a user/resource we have no read-access to
* *

View File

@ -1047,8 +1047,11 @@ class calendar_uiforms extends calendar_ui
} }
$content['participants']['no_add'] = true; $content['participants']['no_add'] = true;
// respect category ACLs // respect category permissions
$content['category'] = $this->check_category_perms(EGW_ACL_READ, $event['category']); if(!empty($event['category']))
{
$content['category'] = $this->categories->check_list(EGW_ACL_READ, $event['category']);
}
} }
else else
{ {

View File

@ -312,7 +312,12 @@ class calendar_uilist extends calendar_ui
} }
if (empty($event['description'])) $event['description'] = ' '; // no description screws the titles horz. alignment if (empty($event['description'])) $event['description'] = ' '; // no description screws the titles horz. alignment
if (empty($event['location'])) $event['location'] = ' '; // no location screws the owner horz. alignment if (empty($event['location'])) $event['location'] = ' '; // no location screws the owner horz. alignment
$event['category'] = $this->check_category_perms(EGW_ACL_READ, $event['category']);
// respect category permissions
if(!empty($event['category']))
{
$event['category'] = $this->categories->check_list(EGW_ACL_READ, $event['category']);
}
$rows[] = $event; $rows[] = $event;
} }

View File

@ -1160,7 +1160,7 @@ class calendar_uiviews extends calendar_ui
$is_private = !$this->bo->check_perms(EGW_ACL_READ,$event); $is_private = !$this->bo->check_perms(EGW_ACL_READ,$event);
$icons = !$is_private ? $this->event_icons($event) : array(html::image('calendar','private',lang('private'))); $icons = !$is_private ? $this->event_icons($event) : array(html::image('calendar','private',lang('private')));
$cats = $this->bo->categories($this->check_category_perms(EGW_ACL_READ, $event['category']),$color); $cats = $this->bo->categories($this->categories->check_list(EGW_ACL_READ, $event['category']),$color);
// these values control varius aspects of the geometry of the eventWidget // these values control varius aspects of the geometry of the eventWidget
$small_trigger_width = 120 + 20*count($icons); $small_trigger_width = 120 + 20*count($icons);
$corner_radius=$width > $small_trigger_width ? 10 : 5; $corner_radius=$width > $small_trigger_width ? 10 : 5;