From 7bba0e916d545e2ef716175159ce6b131b08881b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cornelius=20Wei=C3=9F?= Date: Tue, 27 Sep 2005 23:29:06 +0000 Subject: [PATCH] start work on calendar sidebox hook --- resources/inc/class.bo_acl.inc.php | 2 +- resources/inc/class.resources_hooks.inc.php | 4 ++ resources/inc/class.ui_resources.inc.php | 43 +++++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/resources/inc/class.bo_acl.inc.php b/resources/inc/class.bo_acl.inc.php index 1b13b4db62..580bad3f07 100755 --- a/resources/inc/class.bo_acl.inc.php +++ b/resources/inc/class.bo_acl.inc.php @@ -38,7 +38,7 @@ $this->so =& CreateObject('resources.so_acl'); $this->permissions = $this->so->get_permissions($GLOBALS['egw_info']['user']['account_id'],true); - $this->egw_cats =& createobject('phpgwapi.categories'); + $this->egw_cats = createobject('phpgwapi.categories','','resources'); $this->accounts = $GLOBALS['egw']->accounts->get_list(); $this->debug = False; diff --git a/resources/inc/class.resources_hooks.inc.php b/resources/inc/class.resources_hooks.inc.php index 6a2e7c5dbb..51252e174f 100644 --- a/resources/inc/class.resources_hooks.inc.php +++ b/resources/inc/class.resources_hooks.inc.php @@ -114,6 +114,10 @@ class resources_hooks 'type' => 'r',// one char type-identifiy for this resources 'icon' => 'calicon',//icon 'participants_header' => lang('resources'), // header of participants from this type + 'cal_sidebox' => array( + 'menu_title' => lang('Select resources'), + 'file' => 'resources.ui_resources.get_calendar_sidebox' + ) ); } } diff --git a/resources/inc/class.ui_resources.inc.php b/resources/inc/class.ui_resources.inc.php index 138111dc04..7fa9979f50 100755 --- a/resources/inc/class.ui_resources.inc.php +++ b/resources/inc/class.ui_resources.inc.php @@ -33,6 +33,7 @@ class ui_resources // print_r($GLOBALS['egw_info']); die(); $this->tmpl =& CreateObject('etemplate.etemplate','resources.show'); $this->bo =& CreateObject('resources.bo_resources'); + $this->html =& $GLOBALS['egw']->html; // $this->calui = CreateObject('resources.ui_calviews'); if(!@is_object($GLOBALS['egw']->js)) @@ -459,5 +460,47 @@ class ui_resources $this->tmpl->read('resources.resource_select'); $this->tmpl->exec('resources.ui_resources.select',$content,$sel_options,$no_button,$preserv,2); } + + /** + * get_calendar_sidebox + * get data für calendar sidebox + * + * @author Lukas Weiss + * @return array with: label=>link or array with text + */ + function get_calendar_sidebox($view_menuaction, $date='') + { + $selectbox_content = array(lang('Select resources')); + $selectbox_content[0] = lang('Select resources'); + $cats = $this->bo->acl->get_cats(EGW_ACL_READ); + + // this gets the resource-ids of the cats and implodes them to the array-key of the selectbox, + // so it is possible to select all resources of a category + foreach($cats as $cat_id => $cat_name) + { + $resources = $this->bo->so->search(array('cat_id' => $cat_id),'res_id'); + foreach($resources as $res) $key .= ($key == "")?'r'.$res['res_id']:',r'.$res['res_id']; + $selectbox_content[$key] = $cat_name; + } + $selectbox = $this->html->select( + 'owner', + 'uical_select_resource', + $selectbox_content, + $no_lang=true, + $options='style="width: 165px;" name="res_id" onchange="load_cal(\''. + $GLOBALS['egw']->link('/index.php',array( + 'menuaction' => $view_menuaction, + 'date' => $date, + )).'\',\'uical_select_resource\');" id="uical_select_resource"', + $multiple=0 + ); + return array( + array( + 'text' => $selectbox, + 'no_lang' => True, + 'link' => False + ) + ); + } }