v3.0-git
--------
+[jan] Send alarm notifications with HTML part and convert to Horde_View.
[jan] Default task lists no longer have the user name as the ID.
[jan] Create a default task list if the user doesn't own any yet.
[jan] Add start date to possible colums in task list (Joel Smith
}
/**
+ * Builds the body MIME part of a multipart message.
+ *
+ * @param Horde_View $view A view to render the HTML and plain text
+ * templates for the messate.
+ * @param string $template The template base name for the view.
+ * @param Horde_Mime_Part $image The MIME part of a related image.
+ *
+ * @return Horde_Mime_Part A multipart/alternative MIME part.
+ */
+ public static function buildMimeMessage(Horde_View $view, $template,
+ Horde_Mime_Part $image)
+ {
+ $multipart = new Horde_Mime_Part();
+ $multipart->setType('multipart/alternative');
+ $bodyText = new Horde_Mime_Part();
+ $bodyText->setType('text/plain');
+ $bodyText->setCharset('UTF-8');
+ $bodyText->setContents($view->render($template . '.plain.php'));
+ $bodyText->setDisposition('inline');
+ $multipart->addPart($bodyText);
+ $bodyHtml = new Horde_Mime_Part();
+ $bodyHtml->setType('text/html');
+ $bodyHtml->setCharset('UTF-8');
+ $bodyHtml->setContents($view->render($template . '.html.php'));
+ $bodyHtml->setDisposition('inline');
+ $related = new Horde_Mime_Part();
+ $related->setType('multipart/related');
+ $related->setContentTypeParameter('start', $bodyHtml->setContentId());
+ $related->addPart($bodyHtml);
+ $related->addPart($image);
+ $multipart->addPart($related);
+ return $multipart;
+ }
+
+ /**
+ * Returns a MIME part for an image to be embedded into a HTML document.
+ *
+ * @param string $file An image file name.
+ *
+ * @return Horde_Mime_Part A MIME part representing the image.
+ */
+ public static function getImagePart($file)
+ {
+ $background = Horde_Themes::img($file);
+ $image = new Horde_Mime_Part();
+ $image->setType('image/png');
+ $image->setContents(file_get_contents($background->fs));
+ $image->setContentId();
+ $image->setDisposition('attachment');
+ return $image;
+ }
+
+ /**
* Returns the real name, if available, of a user.
*/
public static function getUserName($uid)
}
}
if (isset($methods['mail'])) {
- $methods['mail']['body'] = sprintf(
- _("We would like to remind you of this due task.\n\n%s\n\nDate: %s\nTime: %s\n\n%s"),
- $this->name,
- strftime($prefs->getValue('date_format'), $this->due),
- date($prefs->getValue('twentyFour') ? 'H:i' : 'h:ia', $this->due),
- $this->desc);
+ $image = Nag::getImagePart('big_alarm.png');
+
+ $view = new Horde_View(array('templatePath' => NAG_TEMPLATES . '/alarm', 'encoding' => 'UTF-8'));
+ new Horde_View_Helper_Text($view);
+ $view->task = $this;
+ $view->imageId = $image->getContentId();
+ $view->due = new Horde_Date($this->due);
+ $view->dateFormat = $prefs->getValue('date_format');
+ $view->timeFormat = $prefs->getValue('twentyFour') ? 'H:i' : 'h:ia';
+ if (!$prefs->isLocked('task_alarms')) {
+ $view->prefsUrl = Horde::url(Horde::getServiceLink('prefs', 'nag'), true)->remove(session_name());
+ }
+
+ $methods['mail']['mimepart'] = Nag::buildMimeMessage($view, 'mail', $image);
}
return array(
'id' => $this->uid,
--- /dev/null
+<p><font size="4"><strong><a href="<?php echo Horde_Util::removeParameter($this->task->view_link, session_name()) ?>"><?php echo $this->h($this->task->name) ?></a></strong></font></p>
+
+<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
+ <td width="140" valign="top">
+ <img src="cid:<?php echo $this->imageId ?>" />
+ </td>
+ <td valign="top">
+ <table width="100%" border="0" cellpadding="5" cellspacing="0">
+ <?php $i = 0 ?>
+
+ <tr<?php if ($i++ % 2) echo ' bgcolor="#f1f1f1"' ?>>
+ <td nowrap="nowrap" align="right">
+ <font size="2"><strong><?php echo _("Date and time:") ?></strong></font>
+ </td>
+ <td width="5"> </td>
+ <td width="100%"><font size="2"><strong><?php echo $this->due->strftime($this->dateFormat) ?>, <?php echo $this->due->format($this->timeFormat) ?></strong></font></td>
+ </tr>
+
+ <?php if (strlen($this->task->desc)): ?>
+
+ <tr<?php if ($i++ % 2) echo ' bgcolor="#f1f1f1"' ?>>
+ <td nowrap="nowrap" align="right" valign="top">
+ <font size="2"><strong><?php echo _("Description:") ?></strong></font>
+ </td>
+ <td width="5"> </td>
+ <td width="100%"><font size="2"><strong><?php echo $GLOBALS['injector']->getInstance('Horde_Core_Factory_TextFilter')->filter($this->task->desc, 'text2html', array('parselevel' => Horde_Text_Filter_Text2html::MICRO, 'callback' => null)) ?></strong></font></td>
+ </tr>
+ <?php endif ?>
+
+ </table>
+ </td>
+</tr></table>
+
+<?php if ($this->prefsUrl): ?>
+<p><font size="1"><?php printf(_("You get this message because your task list is configured to send you reminders of due tasks with alarms. You can change this if you %slogin to the task list%s and change your preferences."), '<a href="' . $this->prefsUrl . '">', '</a>') ?></font></p>
+<?php endif ?>
--- /dev/null
+<?php echo _("We would like to remind you of this due task.") ?>
+
+
+<?php echo $this->task->name ?>
+
+
+<?php echo _("Date:") ?> <?php echo $this->due->strftime($this->dateFormat) ?>
+
+<?php echo _("Time:") ?> <?php echo $this->due->format($this->timeFormat) ?>
+
+
+<?php echo $this->task->desc ?>