Skip to content

Commit

Permalink
Start of handling iTip Task replies in the viewer.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrubinsk committed Feb 24, 2015
1 parent d5e9b1d commit ebf752d
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 7 deletions.
12 changes: 11 additions & 1 deletion imp/config/mime_drivers.php
Expand Up @@ -262,7 +262,17 @@
* automatically updated. All other domains require the
* free/busy data to be explicitly updated by user
* action. */
'auto_update_fbreply' => false
'auto_update_fbreply' => false,

/* How task replies are handled when a user opens the message.
* - false: Reply status is never automatically updated; requires
* explicit action by user.
* - true: Reply status is always automatically updated.
* - Array: An array of domains for which replies are always
* automatically updated. All other domains require the
* reply data to be explicitly updated by user
* action. */
'auto_update_taskreply' => false,
),

/* Audio data. */
Expand Down
41 changes: 35 additions & 6 deletions imp/lib/Mime/Viewer/Itip.php
Expand Up @@ -30,6 +30,7 @@ class IMP_Mime_Viewer_Itip extends Horde_Mime_Viewer_Base
const AUTO_UPDATE_EVENT_REPLY = 'auto_update_eventreply';
const AUTO_UPDATE_FB_PUBLISH = 'auto_update_fbpublish';
const AUTO_UPDATE_FB_REPLY = 'auto_update_fbreply';
const AUTO_UPDATE_TASK_REPLY = 'auto_update_taskreply';

/**
* This driver's display capabilities.
Expand Down Expand Up @@ -692,6 +693,13 @@ protected function _vTodo($vtodo, $id, $method)
$sender = _("An unknown person");
}

try {
if (($attendees = $vtodo->getAttribute('ATTENDEE')) &&
!is_array($attendees)) {
$attendees = array($attendees);
}
} catch (Horde_Icalendar_Exception $e) {}

switch ($method) {
case 'PUBLISH':
$desc = _("%s wishes to make you aware of \"%s\".");
Expand All @@ -708,6 +716,29 @@ protected function _vTodo($vtodo, $id, $method)
$options['deny'] = _("Deny task assignment");
}
break;

case 'REPLY':
$desc = _("%s has replied to the assignment of task \"%s\".");
$from = $this->getConfigParam('imp_contents')->getHeader()->getHeader('from');
$sender = $from
? $from->getAddressList(true)->first()->bare_address
: null;

if ($registry->hasMethod('tasks/updateAttendee') &&
$this->_autoUpdateReply(self::AUTO_UPDATE_TASK_REPLY, $sender)) {
try {
$registry->call('tasks/updateAttendee', array(
$vtodo,
$sender
));
$notification->push(_("Respondent Status Updated."), 'horde.success');
} catch (Horde_Exception $e) {
$notification->push(sprintf(_("There was an error updating the task: %s"), $e->getMessage()), 'horde.error');
}
} elseif ($registry->hasMethod('tasks/updateAttendee')) {
$options['update'] = _("Update respondent status");
}
break;
}

$view = $this->_getViewOb();
Expand All @@ -729,16 +760,14 @@ protected function _vTodo($vtodo, $id, $method)
$view->desc2 = $vtodo->getAttribute('DESCRIPTION');
} catch (Horde_Icalendar_Exception $e) {}

try {
$attendees = $vtodo->getAttribute('ATTENDEE');
} catch (Horde_Icalendar_Exception $e) {
$attendees = null;
}

try {
$view->percentComplete = $vtodo->getAttribute('PERCENT-COMPLETE');
} catch (Horde_Icalendar_Exception $e) {}

if (!empty($attendees)) {
$view->attendees = $this->_parseAttendees($vtodo, $attendees);
}

if (!empty($options)) {
reset($options);
$view->options = $options;
Expand Down

0 comments on commit ebf752d

Please sign in to comment.