mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-28 01:28:53 +01:00
* Calendar: create InfoLog from event
added a general infolog_set hook like existing timesheet_set hook, to allow implementing apps to push further data to infolog, modified existing tracker code to use the hook too
This commit is contained in:
parent
b6ef271466
commit
70d5474d96
@ -85,7 +85,12 @@ class calendar_bo
|
||||
* @var array $common_prefs common preferences
|
||||
*/
|
||||
var $common_prefs;
|
||||
|
||||
/**
|
||||
* Custom fields read from the calendar config
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
var $customfields = array();
|
||||
/**
|
||||
* @var int $user nummerical id of the current user-id
|
||||
*/
|
||||
@ -246,6 +251,8 @@ class calendar_bo
|
||||
$this->require_acl_invite = $GLOBALS['egw_info']['server']['require_acl_invite'];
|
||||
|
||||
$this->categories = new categories($this->user,'calendar');
|
||||
|
||||
$this->customfields = config::get_customfields('calendar');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1960,6 +1967,58 @@ class calendar_bo
|
||||
return $ctag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook for infolog to set some extra data and links
|
||||
*
|
||||
* @param array $data event-array preset by infolog plus
|
||||
* @param int $data[id] cal_id
|
||||
* @return array with key => value pairs to set in new event and link_app/link_id arrays
|
||||
*/
|
||||
function infolog_set($data)
|
||||
{
|
||||
if (!($calendar = $this->read($data['id'])))
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
$content = array(
|
||||
'info_cat' => $GLOBALS['egw']->categories->check_list(EGW_ACL_READ, $calendar['category']),
|
||||
'info_priority' => $calendar['priority'] ,
|
||||
'info_public' => $calendar['public'] != 'private',
|
||||
'info_subject' => $calendar['title'],
|
||||
'info_des' => $calendar['description'],
|
||||
'info_location' => $calendar['location'],
|
||||
'info_startdate' => $calendar['range_start'],
|
||||
//'info_enddate' => $calendar['range_end'] ? $calendar['range_end'] : $calendar['uid']
|
||||
'info_contact' => 'calendar:'.$data['id'],
|
||||
);
|
||||
|
||||
unset($content['id']);
|
||||
// Add calendar link to infolog entry
|
||||
$content['link_app'][] = $calendar['info_link']['app'];
|
||||
$content['link_id'][] = $calendar['info_link']['id'];
|
||||
// Copy claendar's links
|
||||
foreach(egw_link::get_links('calendar',$calendar['id'],'','link_lastmod DESC',true) as $link)
|
||||
{
|
||||
if ($link['app'] != egw_link::VFS_APPNAME)
|
||||
{
|
||||
$content['link_app'][] = $link['app'];
|
||||
$content['link_id'][] = $link['id'];
|
||||
}
|
||||
if ($link['app'] == 'addressbook') // prefering contact as primary contact over calendar entry set above
|
||||
{
|
||||
$content['info_contact'] = 'addressbook:'.$link['id'];
|
||||
}
|
||||
}
|
||||
// Copy same custom fields
|
||||
foreach(config::get_customfields('infolog') as $name => $settings)
|
||||
{
|
||||
if ($this->customfields[$name]) $content['#'.$name] = $calendar['#'.$name];
|
||||
}
|
||||
//error_log(__METHOD__.'('.array2string($data).') calendar='.array2string($calendar).' returning '.array2string($content));
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook for timesheet to set some extra data and links
|
||||
*
|
||||
|
@ -535,6 +535,7 @@ class calendar_uiforms extends calendar_ui
|
||||
case 'save':
|
||||
case 'print':
|
||||
case 'apply':
|
||||
case 'infolog':
|
||||
if ($event['id'] && !$this->bo->check_perms(EGW_ACL_EDIT,$event))
|
||||
{
|
||||
switch ($button)
|
||||
@ -546,6 +547,9 @@ class calendar_uiforms extends calendar_ui
|
||||
case 'print': // just print without edit-rights is ok
|
||||
$js = $this->custom_print($event,false);
|
||||
break 2;
|
||||
case 'infolog': // create infolog without edit-rights is ok
|
||||
$this->create_infolog($event['id']);
|
||||
break 2;
|
||||
}
|
||||
$msg = lang('Permission denied');
|
||||
$button = '';
|
||||
@ -872,6 +876,11 @@ class calendar_uiforms extends calendar_ui
|
||||
{
|
||||
$js = $this->custom_mail($event,!$content['id'],($button=='sendrequest'))."\n".$js; // first open the new window and then update the view
|
||||
}
|
||||
|
||||
if ($button == 'infolog')
|
||||
{
|
||||
$this->create_infolog($event['id']);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1093,14 +1102,29 @@ class calendar_uiforms extends calendar_ui
|
||||
*/
|
||||
function custom_print($event,$added)
|
||||
{
|
||||
$vars = array(
|
||||
$vars = array(
|
||||
'menuaction' => 'calendar.calendar_uiforms.edit',
|
||||
'cal_id' => $event['id'],
|
||||
'print' => true,
|
||||
);
|
||||
);
|
||||
return "window.open('".egw::link('/index.php',$vars)."','_blank','width=700,height=700,scrollbars=yes,status=no');";
|
||||
}
|
||||
|
||||
/**
|
||||
* Open new infolog window to convert event to an infolog
|
||||
*
|
||||
* @param array|int $event event or id
|
||||
*/
|
||||
function create_infolog($event,$added)
|
||||
{
|
||||
$vars = array(
|
||||
'menuaction' => 'infolog.infolog_ui.edit',
|
||||
'action' => 'calendar',
|
||||
'action_id' => is_array($event) ? $event['id'] : $event,
|
||||
);
|
||||
egw::redirect_link('/index.php', $vars);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get title of a uid / calendar participant
|
||||
*
|
||||
@ -1157,8 +1181,9 @@ class calendar_uiforms extends calendar_ui
|
||||
'copy' => array('label' => 'Copy', 'title' => 'Copy this event'),
|
||||
'ical' => array('label' => 'Export', 'title' => 'Download this event as iCal'),
|
||||
'print' => array('label' => 'Print', 'title' => 'Print this event'),
|
||||
'mail' => array('label' => 'Mail all participants', 'title' => 'compose a mail to all participants after the event is saved'),
|
||||
'sendrequest' => array('label' => 'Send meetingrequest to all participants', 'title' => 'Send meetingrequest to all participants after the event is saved'),
|
||||
'infolog' => array('label' => 'InfoLog', 'title' => 'Create an InfoLog from this event'),
|
||||
'mail' => array('label' => 'Mail all participants', 'title' => 'Compose a mail to all participants after the event is saved'),
|
||||
'sendrequest' => array('label' => 'Meetingrequest to all participants', 'title' => 'Send meetingrequest to all participants after the event is saved'),
|
||||
),
|
||||
);
|
||||
unset($sel_options['status']['G']);
|
||||
|
@ -820,6 +820,17 @@ class calendar_uilist extends calendar_ui
|
||||
'disableClass' => 'rowNoView',
|
||||
);
|
||||
}
|
||||
if ($GLOBALS['egw_info']['user']['apps']['infolog'])
|
||||
{
|
||||
$actions['infolog_app'] = array(
|
||||
'caption' => 'InfoLog',
|
||||
'icon' => 'infolog/navbar',
|
||||
'group' => $group,
|
||||
'allowOnMultiple' => false,
|
||||
'url' => 'menuaction=infolog.infolog_ui.edit&type=task&action=calendar&action_id=$id',
|
||||
'popup' => egw_link::get_registry('infolog', 'add_popup'),
|
||||
);
|
||||
}
|
||||
if ($GLOBALS['egw_info']['user']['apps']['timesheet'])
|
||||
{
|
||||
$actions['timesheet'] = array( // interactive add for a single event
|
||||
|
@ -98,6 +98,7 @@ countries calendar de Länder
|
||||
country calendar de Land
|
||||
create a new series calendar de Neue Serie anlegen
|
||||
create an exception for the given date calendar de Erzeugt eine Ausnahme am angegebenen Datum
|
||||
create an infolog from this event calendar de Erstelle ein InfoLog von diesem Termin
|
||||
create exception calendar de Ausnahme erzeugen
|
||||
create new links calendar de Neue Verknüpfung erstellen
|
||||
created calendar de Angelegt
|
||||
@ -286,6 +287,7 @@ make freebusy information available to not loged in persons? calendar de Die fre
|
||||
max. number of entries to show (leave empty for no restriction) calendar de Max. Anzahl von Einträgen die angezeigt werden sollen (Kein Eintrag = Keine Beschränkung)
|
||||
maximum available quantity of %1 exceeded! calendar de Maximale Anzahl von %1 erreicht!
|
||||
meeting request calendar de Terminanfrage
|
||||
meetingrequest to all participants calendar de Terminanforderung an alle Teilnehmer
|
||||
merge document... calendar de Dokument einfügen...
|
||||
minutes calendar de Minuten
|
||||
modified calendar de Geändert
|
||||
@ -410,7 +412,6 @@ select resources calendar de Ressourcen auswählen
|
||||
select whether you want the pariticpant stati reset to unkown, if an event is shifted later on. calendar de Wählen Sie aus, in welchem Fall der Teilnehmerstatus von Teilnehmern zurückgesetzt werden soll, wenn ein Termin verschoben wird.
|
||||
select who should get the alarm calendar de Auswählen wer den Alarm erhalten soll
|
||||
selected range calendar de Ausgewählter Zeitraum
|
||||
send meetingrequest to all participants calendar de Terminanforderung an alle Teilnehmer senden
|
||||
send meetingrequest to all participants after the event is saved calendar de Terminanforderung an alle Teilnehmer senden nachdem der Termin gespeichert wurde
|
||||
series deleted calendar de Serientermin wurde gelöscht
|
||||
set a year only for one-time / non-regular holidays. calendar de Nur für einmalige bzw. unregelmäßige Feiertage das Jahr angeben.
|
||||
|
@ -98,6 +98,7 @@ countries calendar en Countries
|
||||
country calendar en Country
|
||||
create a new series calendar en Create a new series
|
||||
create an exception for the given date calendar en Create an exception for the given date
|
||||
create an infolog from this event calendar en Create an InfoLog from this event
|
||||
create exception calendar en Create exception
|
||||
create new links calendar en Create new links
|
||||
created calendar en Created
|
||||
@ -286,6 +287,7 @@ make freebusy information available to not loged in persons? calendar en Make Fr
|
||||
max. number of entries to show (leave empty for no restriction) calendar en Max. number of entries to show. Leave empty for no restriction.
|
||||
maximum available quantity of %1 exceeded! calendar en Maximum available quantity of %1 exceeded!
|
||||
meeting request calendar en Meeting request
|
||||
meetingrequest to all participants calendar en Meetingrequest to all participants
|
||||
merge document... calendar en Merge document...
|
||||
minutes calendar en Minutes
|
||||
modified calendar en Modified
|
||||
@ -410,7 +412,6 @@ select resources calendar en Select resources
|
||||
select whether you want the pariticpant stati reset to unkown, if an event is shifted later on. calendar en Select whether you want the participant status reset to unknown, if an event is shifted later on.
|
||||
select who should get the alarm calendar en Select who should get the alarm
|
||||
selected range calendar en Selected range
|
||||
send meetingrequest to all participants calendar en Send meetingrequest to all participants
|
||||
send meetingrequest to all participants after the event is saved calendar en Send meetingrequest to all participants after the event is saved
|
||||
series deleted calendar en Series deleted
|
||||
set a year only for one-time / non-regular holidays. calendar en Set a year only for one time / non regular holidays.
|
||||
|
@ -43,6 +43,7 @@ $setup_info['calendar']['hooks']['sidebox_menu'] = 'calendar.calendar_ui.sidebox
|
||||
$setup_info['calendar']['hooks']['search_link'] = 'calendar_hooks::search_link';
|
||||
$setup_info['calendar']['hooks']['config_validate'] = 'calendar_hooks::config_validate';
|
||||
$setup_info['calendar']['hooks']['timesheet_set'] = 'calendar.calendar_bo.timesheet_set';
|
||||
$setup_info['calendar']['hooks']['infolog_set'] = 'calendar.calendar_bo.infolog_set';
|
||||
$setup_info['calendar']['hooks']['export_limit'] = 'calendar_hooks::getAppExportLimit';
|
||||
|
||||
/* Dependencies for this app to work */
|
||||
|
@ -1788,49 +1788,29 @@ class infolog_ui
|
||||
unset($action); // it get stored in $content and will cause an other copy after [apply]
|
||||
break;
|
||||
|
||||
case 'tracker':
|
||||
if ($action_id)
|
||||
{
|
||||
egw_link::link('infolog',$content['link_to']['to_id'],$action,$action_id);
|
||||
$content['blur_title'] = egw_link::title($action,$action_id);
|
||||
}
|
||||
$content['info_contact'] = $action.':'.$action_id;
|
||||
$t_bo = new tracker_bo();
|
||||
$tracker = $t_bo->read($action_id);
|
||||
$content['info_subject'] = $tracker['tr_summary'];
|
||||
$content['info_des'] = $tracker['tr_description'];
|
||||
foreach($this->bo->customfields as $name => $value)
|
||||
{
|
||||
if(array_key_exists('#'.$name, $tracker)) {
|
||||
$content['#'.$name] = $tracker['#'.$name];
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'projectmanager':
|
||||
$pm_links = array($action_id);
|
||||
case 'addressbook':
|
||||
case 'projects':
|
||||
case 'calendar':
|
||||
default: // to allow other apps to participate
|
||||
if (strpos($action_id,',') !== false)
|
||||
{
|
||||
foreach (explode(',',$action_id) as $id)
|
||||
{
|
||||
egw_link::link('infolog',$content['link_to']['to_id'],$action,$id);
|
||||
}
|
||||
$content['blur_title'] = egw_link::title($action,'$id').",...";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($action_id)
|
||||
{
|
||||
egw_link::link('infolog',$content['link_to']['to_id'],$action,$action_id);
|
||||
$content['blur_title'] = egw_link::title($action,$action_id);
|
||||
}
|
||||
}
|
||||
$content['info_subject'] = egw_link::title($action, $id);
|
||||
$content['info_contact'] = $action.':'.$action_id;
|
||||
foreach (explode(',', $action_id) as $n => $id)
|
||||
{
|
||||
egw_link::link('infolog', $content['link_to']['to_id'], $action, $id);
|
||||
|
||||
// calling "infolog_set" hook for first, in case app wants to set some more values
|
||||
if (!$n && ($set = $GLOBALS['egw']->hooks->single(array('location'=>'infolog_set','id'=>$action_id),$action)))
|
||||
{
|
||||
foreach((array)$set['link_app'] as $i => $l_app)
|
||||
{
|
||||
if (($l_id=$set['link_id'][$i])) egw_link::link('infolog',$content['link_to']['to_id'],$l_app,$l_id);
|
||||
}
|
||||
unset($set['link_app']);
|
||||
unset($set['link_id']);
|
||||
|
||||
$content = array_merge($content, $set);
|
||||
}
|
||||
}
|
||||
// fall through
|
||||
case '':
|
||||
if ($info_id)
|
||||
{
|
||||
@ -1840,16 +1820,16 @@ class infolog_ui
|
||||
}
|
||||
break; // normal edit
|
||||
}
|
||||
case 'new': // new entry
|
||||
$content['info_startdate'] = (int) $_GET['startdate'] ? (int) $_GET['startdate'] : $set_startdate;
|
||||
$content['info_priority'] = 1; // normal
|
||||
case 'new': // new entry, set some defaults, if not set by infolog_set hook
|
||||
if (empty($content['info_startdate'])) $content['info_startdate'] = (int) $_GET['startdate'] ? (int) $_GET['startdate'] : $set_startdate;
|
||||
if (empty($content['info_priority'])) $content['info_priority'] = 1; // normal
|
||||
$content['info_owner'] = $this->user;
|
||||
if ($type != '')
|
||||
if ($type != '' && empty($content['info_type']))
|
||||
{
|
||||
$content['info_type'] = $type;
|
||||
}
|
||||
$content['info_status'] = $this->bo->status['defaults'][$content['info_type']];
|
||||
$content['info_percent'] = $content['info_status'] == 'done' ? '100%' : '0%';
|
||||
if (empty($content['info_status'])) $content['info_status'] = $this->bo->status['defaults'][$content['info_type']];
|
||||
if (empty($content['info_percent'])) $content['info_percent'] = $content['info_status'] == 'done' ? '100%' : '0%';
|
||||
break;
|
||||
}
|
||||
if (!isset($this->bo->enums['type'][$content['info_type']]))
|
||||
@ -2273,7 +2253,7 @@ class infolog_ui
|
||||
$notifications[$content['notification_type']] = $content['notification'];
|
||||
config::save_value(infolog_tracking::CUSTOM_NOTIFICATION, $notifications,'infolog');
|
||||
}
|
||||
|
||||
|
||||
if($button == 'save' || $button == 'cancel')
|
||||
{
|
||||
egw::redirect_link('/infolog/index.php');
|
||||
|
Loading…
Reference in New Issue
Block a user