[sork] [vacation][patch] formfield for subject

Martin Luethi horde at humbapa.ch
Tue Feb 3 01:07:32 PST 2004


attached is a small patch who adds a subject-textfield to the vacation-form

take a look at:
host: mail.humbapa.ch
user: test at humbapa.ch
pass: 2004

g. tinu
-------------- next part --------------
Index: main.php
===================================================================
RCS file: /repository/vacation/main.php,v
retrieving revision 1.39
diff -u -r1.39 main.php
--- main.php	2 Feb 2004 17:53:07 -0000	1.39
+++ main.php	3 Feb 2004 08:57:49 -0000
@@ -60,24 +60,25 @@
     case 'set':
         $alias = Util::getFormData('alias', '');
         $vacationmsg = Util::getFormData('mess', false);
+        $vacationtxt = 'Subject: ' . Util::getFormData('subject') . "\n" . $vacationmsg;
         if (!$vacationmsg) {
             $notification->push(_("You must give a vacation message."),
                                 'horde.warning');
         } elseif (!empty($conf['vacation']['validation_pattern']) &&
-                  !@preg_match($conf['vacation']['validation_pattern'], $vacationmsg)) {
+                  !@preg_match($conf['vacation']['validation_pattern'], $vacationtxt)) {
             // Validation is required, and wasn't matched.
             $notification->push(_("Your vacation message is not in the proper format."),
                                 'horde.warning');
         } else {
             // Try and make sure to send Unix linefeeds.
-            $vacationmsg = str_replace("\r\n", "\n", $vacationmsg);
-            $vacationmsg = str_replace("\r", "\n", $vacationmsg);
+            $vacationtxt = str_replace("\r\n", "\n", $vacationtxt);
+            $vacationtxt = str_replace("\r", "\n", $vacationtxt);
 
             // Wrap at 75 characters.
-            $vacationmsg = wordwrap($vacationmsg);
+            $vacationtxt = wordwrap($vacationtxt);
 
             if ($driver->setVacation($user, $realm, $password,
-                                     $vacationmsg, $alias)) {
+                                     $vacationtxt, $alias)) {
                 $notification->push(_("Vacation notice successfully enabled."), 'horde.success');
             } else {
                 $notification->push(sprintf(_("Failure in modifying vacation notice: %s"),
@@ -111,6 +112,13 @@
     // If the driver can't tell the difference between "disabled" and
     // "unknown", be inscrutable.
     $curmessage = $conf['vacation']['default'];
+}
+// Split the vacation-text in a subject and a message
+if (preg_match("/^Subject: ([^\n]+)\n(.+)$/s", $curmessage, $m='')) {
+    $cursubject = $m[1];
+    $curmessage = $m[2];
+} else {
+    $cursubject = '';
 }
 
 $title = _("Change Vacation Notices");
-------------- next part --------------
Index: main.inc
===================================================================
RCS file: /repository/vacation/templates/main/main.inc,v
retrieving revision 1.21
diff -u -r1.21 main.inc
--- main.inc	16 Sep 2003 23:08:48 -0000	1.21
+++ main.inc	28 Jan 2004 13:47:12 -0000
@@ -47,6 +47,13 @@
 
 <div>
 <br />
+<?php echo _("Subject:") ?>
+<br />
+<input name="subject" type="text" size="70" value="<?php echo htmlspecialchars($cursubject) ?>">
+</div>
+
+<div>
+<br />
 <?php echo _("Message:") ?>
 <br />
 <textarea name="mess" rows="8" cols="70"><?php echo htmlspecialchars($curmessage) ?></textarea>


More information about the sork mailing list