From 92dc786ebc1bbc1831445e1ca9568f6163bd884a Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Sat, 7 Jan 2012 22:21:48 +0000 Subject: [PATCH] * Calendar: showing now all open calendars in the owner-selection, not just accounts. Allows to close them from all views --- calendar/inc/class.calendar_ui.inc.php | 22 ++++++++++++---------- phpgwapi/inc/class.uiaccountsel.inc.php | 16 +++++++++++----- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/calendar/inc/class.calendar_ui.inc.php b/calendar/inc/class.calendar_ui.inc.php index 3f66a43b1c..15966e216a 100644 --- a/calendar/inc/class.calendar_ui.inc.php +++ b/calendar/inc/class.calendar_ui.inc.php @@ -286,7 +286,14 @@ class calendar_ui $set_owners = explode(',',$set_states['owner']); if ((string)$set_owners[0] === '0') // set exactly the specified owners (without the 0) { - $set_states['owner'] = substr($set_states['owner'],2); + if ($set_states['owner'] === '0,r0') // small fix for resources + { + $set_states['owner'] = $default; // --> set default, instead of none + } + else + { + $set_states['owner'] = substr($set_states['owner'],2); + } } else // change only the owners of the given type { @@ -782,13 +789,8 @@ class calendar_ui { $grants[] = $grant['grantor']; } - // exclude non-accounts from the account-selection - $accounts = array(); - foreach(explode(',',$this->owner) as $owner) - { - if (is_numeric($owner)) $accounts[] = $owner; - } - if (!$accounts) $grants[''] = lang('None'); + // we no longer exclude non-accounts from the account-selection: it shows all types of participants + $accounts = explode(',',$this->owner); $file[] = array( 'text' => " @@ -813,7 +815,7 @@ function load_cal(url,id) { egw::link('/index.php',array( 'menuaction' => $this->view_menuaction, 'date' => $this->date, - ),false).'\',\'uical_select_owner\');"','',$grants), + ),false).'\',\'uical_select_owner\');"','',$grants,false,array($this->bo,'participant_name')), 'no_lang' => True, 'link' => False ); diff --git a/phpgwapi/inc/class.uiaccountsel.inc.php b/phpgwapi/inc/class.uiaccountsel.inc.php index 60f71f185b..236cb86d10 100644 --- a/phpgwapi/inc/class.uiaccountsel.inc.php +++ b/phpgwapi/inc/class.uiaccountsel.inc.php @@ -80,11 +80,12 @@ class uiaccountsel * Or a string which gets added as first Option with value='', eg. lang('all'), can also be specified in the array with key '' * @param boolean $nohtml if true, returns an array with the key 'selected' as the selected participants, * and with the key 'participants' as the participants data as would fit in a select. + * @param callback $label_callback=null callback to fetch a label for non-accounts * @return string/array string with html for !$nohtml, array('selected' => $selected,'participants' => $select) */ - function selection($name,$element_id,$selected,$use='accounts',$lines=0,$not=False,$options='',$onchange='',$select=False,$nohtml=false) + function selection($name,$element_id,$selected,$use='accounts',$lines=0,$not=False,$options='',$onchange='',$select=False,$nohtml=false,$label_callback=null) { - //echo "

uiaccountsel::selection('$name',".print_r($selected,True).",'$use',rows=$lines,$not,'$options','$onchange',".print_r($select,True).") account_selection=$this->account_selection

\n"; + error_log(__METHOD__."('$name',".array2string($selected).",'$use',rows=$lines,$not,'$options','$onchange',".array2string($select).",$nohtml,$label_callback) account_selection=$this->account_selection"); $multi_size=4; if ($lines < 0) { @@ -190,19 +191,24 @@ class uiaccountsel { continue; // dont display that one } + $label = common::grab_owner_name($id); + if ($label[0] === '#' && $label_callback) + { + if (!($label = call_user_func($label_callback, $id))) continue; + } if (in_array($id,$selected)) // show already selected accounts first { - $already_selected[$id] = common::grab_owner_name($id); + $already_selected[$id] = $label; } elseif ($this->accounts->get_type($id) == 'u') { - $users[$id] = !is_array($val) ? common::grab_owner_name($id) : + $users[$id] = !is_array($val) ? $label : common::display_fullname( $val['account_lid'],$val['account_firstname'],$val['account_lastname']); } else { - $groups[$id] = common::grab_owner_name($id); + $groups[$id] = $label; } } // sort users and groups alphabeticaly and put the groups behind the users