protected function _create($mbox, $subject, $body)
{
global $notification, $registry;
$list = str_replace(self::TASKLIST_EDIT, '', $mbox);
/* Create a new iCalendar. */
$vCal = new Horde_Icalendar();
$vCal->setAttribute('PRODID', '-//The Horde Project//IMP ' . $registry->getVersion() . '//EN');
$vCal->setAttribute('METHOD', 'PUBLISH');
/* Create a new vTodo object using this message's contents. */
$vTodo = Horde_Icalendar::newComponent('vtodo', $vCal);
$vTodo->setAttribute('SUMMARY', $subject);
$vTodo->setAttribute('DESCRIPTION', $body);
$vTodo->setAttribute('PRIORITY', '3');
/* Get the list of editable tasklists. */
$lists = $this->getTasklists(true);
/* Attempt to add the new vTodo item to the requested tasklist. */
try {
$res = $registry->call('tasks/import', array($vTodo, 'text/calendar', $list));
} catch (Horde_Exception $e) {
$notification->push($e);
return;
}
if (!$res) {
$notification->push(_("An unknown error occured while creating the new task."), 'horde.error');
} elseif (!empty($lists)) {
$name = '"' . htmlspecialchars($subject) . '"';
/* Attempt to convert the object name into a hyperlink. */
if ($registry->hasLink('tasks/show')) {
$name = sprintf('<a href="%s">%s</a>', Horde::url($registry->link('tasks/show', array('uid' => $res))), $name);
}
$notification->push(sprintf(_("%s was successfully added to \"%s\"."), $name, htmlspecialchars($lists[$list]->get('name'))), 'horde.success', array('content.raw'));
}
}