* Calendar: Add customizable link title in calendar preferences, in order to append extra fields to calendar's link title.

This commit is contained in:
Hadi Nategh 2014-11-12 16:26:23 +00:00
parent aa2eaf512e
commit cf7017a281
2 changed files with 61 additions and 2 deletions

View File

@ -1827,7 +1827,27 @@ class calendar_bo
} }
return $this->cached_holidays[$year]; return $this->cached_holidays[$year];
} }
/**
* Get translated calendar event fields, presenting as link title options
*
* @param type $event
* @return array array of selected calendar fields
*/
function get_link_options ($event)
{
$options = array (
'end' => lang('End date'),
'id' => lang('ID'),
'owner' => lang('Event owner'),
'category' => lang('Category'),
'location' => lang('Location'),
'creator' => lang('Creator'),
'participants' => lang('Participants')
);
return $options;
}
/** /**
* get title for an event identified by $event * get title for an event identified by $event
* *
@ -1851,6 +1871,35 @@ class calendar_bo
{ {
return $event; return $event;
} }
$type = explode(',',$this->cal_prefs['link_title']);
if (is_array($type))
{
foreach ($type as &$val)
{
switch ($val)
{
case 'end':
case 'modified':
$extra_fields [$val] = $this->format_date($event[$val]);
break;
case 'participants':
foreach ($event[$val] as $key => $value)
{
$extra_fields [$val] = accounts::id2name($key, 'account_fullname');
}
break;
case 'modifier':
case 'creator':
case 'owner':
$extra_fields [$val] = accounts::id2name($event[$val], 'account_fullname');
break;
default:
$extra_fields [] = $event[$val];
}
}
$str_fields = implode(', ',$extra_fields);
if (is_array($extra_fields)) return $this->format_date($event['start']) . ': ' . $event['title'] . ($str_fields? ', ' . $str_fields:'');
}
return $this->format_date($event['start']) . ': ' . $event['title']; return $this->format_date($event['start']) . ': ' . $event['title'];
} }

View File

@ -277,7 +277,7 @@ class calendar_hooks
$export_tzs = array('0' => 'Use Event TZ'); $export_tzs = array('0' => 'Use Event TZ');
$export_tzs += egw_time::getTimezones(); $export_tzs += egw_time::getTimezones();
} }
$link_title_options = ExecMethod('calendar.calendar_bo.get_link_options');
$settings = array( $settings = array(
'1.section' => array( '1.section' => array(
'type' => 'section', 'type' => 'section',
@ -415,6 +415,16 @@ class calendar_hooks
'admin' => False, 'admin' => False,
'forced' => 'all', 'forced' => 'all',
), ),
'link_title' => array(
'type' => 'multiselect',
'label' => 'Link title for events to show',
'name' => 'link_title',
'values' => $link_title_options,
'help' => 'What should links to the calendar events display in other applications.',
'xmlrpc' => True,
'admin' => false,
'default'=> '',
),
'2.section' => array( '2.section' => array(
'type' => 'section', 'type' => 'section',
'title' => lang('appointment settings'), 'title' => lang('appointment settings'),