* Calendar: showing now all open calendars in the owner-selection, not just accounts. Allows to close them from all views

This commit is contained in:
Ralf Becker 2012-01-07 22:21:48 +00:00
parent 02861daf88
commit 92dc786ebc
2 changed files with 23 additions and 15 deletions

View File

@ -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' => "
<script type=\"text/javascript\">
@ -802,7 +804,7 @@ function load_cal(url,id) {
}
}
if (owner) {
egw_appWindow('calendar').location=url+'&owner='+owner;
egw_appWindow('calendar').location=url+'&owner=0,'+owner;
}
}
</script>
@ -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
);

View File

@ -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 "<p align=right>uiaccountsel::selection('$name',".print_r($selected,True).",'$use',rows=$lines,$not,'$options','$onchange',".print_r($select,True).") account_selection=$this->account_selection</p>\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