[dev] Horde Reminder and Alert Addon

Massimiliano Sorcinelli m.sorcinelli at i-synapse.it
Thu May 15 10:12:09 PDT 2003



This is a new feature for horde i would like if you publish it so it can 
enhance.
I've adapted the phprojekt reminder for horde. This is for horde stable version 
2.2.3 and kronolith 1.1 final.
The reminder starts automatically as new windows from login.php you can edit 
kronolith events just cliking them up and open INBOX when new messages comes up.

TODO (if someone wants :-)): Configuration integration (enable and disable this 
feature)

Regards

PS. I'm looking for SyncML (www.syncml.org) integration on Horde. Think to 
syncronize new SyncML enabled device like SonyEricsson P800 via GRPS 
connection, would be beautiful and would make Horde the best featureful web 
groupware. If someone is working on that or interesting in developing please 
contact.

Massimiliano Sorcinelli
m.sorcinelli at i-synapse.it
www.i-synapse.it
Arezzo - Italy.
-------------- next part --------------
diff -u -r -N original/kronolith/lib/Driver/sql.php new/kronolith/lib/Driver/sql.php
--- original/kronolith/lib/Driver/sql.php	2003-04-04 21:24:00.000000000 +0200
+++ new/kronolith/lib/Driver/sql.php	2003-05-14 11:27:02.000000000 +0200
@@ -34,7 +34,7 @@
 
     function listAlarms($date)
     {
-        $allevents = $this->listEvents($date, $date, true);
+        $allevents = $this->listEvents(0, $date, true);
         $events = array();
 
         foreach ($allevents as $eventid) {
@@ -43,9 +43,9 @@
             if ($event->getRecurType() == KRONOLITH_RECUR_NONE) {
                 $diff = Kronolith::dateDiff($date,
                                             Kronolith::timestampToObject($event->startTimestamp));
-                if ($diff->sec < $event->getAlarm() * 60) {
+                //if ($diff->sec < $event->getAlarm() * 60) {
                     $events[] = $eventid;
-                }
+                //}
             } else {
                 $next = $this->nextRecurrence($eventid, $date);
                 if ($next) {
@@ -72,7 +72,7 @@
 
         $etime = sprintf('%04d-%02d-%02d 00:00:00', $endDate->year, $endDate->month, $endDate->mday);
         if (isset($startDate)) {
-            if ($startDate === 0) {
+            if ($startDate == 0) {
                 $startDate = Kronolith::dateObject(array('mday' => 1, 'month' => 1, 'year' => 0000));
             }
             if ($startDate->month == 0) { $startDate->month = 1; }
@@ -104,7 +104,6 @@
 
         /* Run the query. */
         $qr = $this->_db->query($q);
-
         if (!PEAR::isError($qr)) {
             $row = $qr->fetchRow(DB_FETCHMODE_ASSOC);
             while ($row && !PEAR::isError($row)) {
diff -u -r -N original/kronolith/lib/Notification/kronolith.php new/kronolith/lib/Notification/kronolith.php
--- original/kronolith/lib/Notification/kronolith.php	2003-01-03 15:23:36.000000000 +0100
+++ new/kronolith/lib/Notification/kronolith.php	2003-05-13 17:40:31.000000000 +0200
@@ -25,11 +25,11 @@
     {
         switch ($message['type']) {
         case 'kronolith.alarm':
-            echo '<tr><td class="control">' . Horde::img('alarm.gif') . '&nbsp;&nbsp;<b>' . $message['message'] . '</b></td></tr>';
+            echo '<tr><td class="control" bgcolor="#d0d0d0">' . Horde::img('alarm.gif') . '&nbsp;&nbsp;<b>' . $message['message'] . '</b></td></tr>';
             break;
 
         case 'kronolith.event':
-            echo '<tr><td class="control">' . Horde::img('event.gif') . '&nbsp;&nbsp;<b>' . $message['message'] . '</b></td></tr>';
+            echo '<tr><td class="control" bgcolor="#d0d0d0">' . Horde::img('event.gif') . '&nbsp;&nbsp;<b>' . $message['message'] . '</b></td></tr>';
             break;
 
         default:
diff -u -r -N original/kronolith/po/it_IT.po new/kronolith/po/it_IT.po
--- original/kronolith/po/it_IT.po	2001-08-24 22:13:52.000000000 +0200
+++ new/kronolith/po/it_IT.po	2003-05-13 18:41:51.000000000 +0200
@@ -49,13 +49,28 @@
 msgstr "%s è in corso."
 
 #, c-format
+msgid "%s </td></tr><tr><td><b> is in progress.</b>"
+msgstr "%s </td></tr><tr><td><b> è in corso.</b>"
+#, c-format
 msgid "%s is starting now."
 msgstr "%s inizia ora."
 
 #, c-format
+msgid "%s </td></tr><tr><td><b> Is starting now..</b>"
+msgstr "%s </td></tr><tr><td><b> Inizia ora..</b>"
+
+#, c-format
 msgid "%s starts in %s"
 msgstr "%s inizia in %s"
 
+#, c-format
+msgid "%s </td></tr><tr><td><b> starts in %s</b>"
+msgstr "%s </td></tr><tr><td><b> Inizia in %s</b>"
+
+#, c-format
+msgid "%s </td></tr><tr><td><b> is done "
+msgstr "%s </td></tr><tr><td><b> è trascorso "
+
 msgid "<b>Description</b> (optional)"
 msgstr "<b>Descrizione</b> (opzionale)"
 
@@ -236,6 +251,9 @@
 msgid "Options"
 msgstr "Opzioni"
 
+msgid "Import/Export"
+msgstr "Importa/Esporta"
+
 msgid "Pattern"
 msgstr "Modello"
 
@@ -361,6 +379,12 @@
 msgid "Today"
 msgstr "Oggi"
 
+msgid "Goto"
+msgstr "Vai a"
+
+msgid "Print"
+msgstr "Stampa"
+
 msgid "Tu"
 msgstr "Mar"
 
diff -u -r -N original/kronolith/reminder.php new/kronolith/reminder.php
--- original/kronolith/reminder.php	1970-01-01 01:00:00.000000000 +0100
+++ new/kronolith/reminder.php	2003-05-15 17:58:12.000000000 +0200
@@ -0,0 +1,87 @@
+<?php
+
+echo "<html><head><title>Avvisi</title>\n";
+echo "<META http-equiv=Content-Type content='text/html; charset=iso-8859-1'>";
+echo "<META http-equiv=refresh content=30>";
+
+//mail check
+define('IMP_BASE', "../imp");
+require_once IMP_BASE . '/lib/base.php';
+IMP::checkAuthentication();
+$newmail_popup = (Horde::getFormData('newmail_popup') == 'no') ? false : true;
+$newmsgs = 0;
+	$check = imap_check($imp['stream']);
+	$imp['msgcount'] = (is_object($check) && isset($check->Nmsgs)) ? $check->Nmsgs : 0;
+	$new = imap_search($imp['stream'], 'RECENT');
+	$newmsgs = $new ? count($new) : 0;
+	$unseen = imap_search($imp['stream'], 'UNSEEN');
+	$unseenmsgs = $unseen ? count($unseen) : 0;
+	echo "<table border='1' cellpadding='0' cellspacing='0' style='border-collapse: collapse' bordercolor='#111111' width='100%' id='AutoNumber1'>";
+  	echo "<tr><td width='100%'><font color='#0000FF'>Messaggi non letti:</font> ";	
+        $url = Horde::applicationUrl('mailbox.php?newmail_popup=no&mailbox=INBOX', true);
+	$unseenmsgs = Horde::link($url, sprintf(_("Edit '%s'"),"INBOX"), 'menuitem',"_blank") . $unseenmsgs . "</a>";
+	echo $unseenmsgs;
+	echo "</td></tr></table>";
+if ($newmsgs > 0) {
+    include IMP_TEMPLATES . '/mailbox/alert.inc';
+}
+
+
+//events check
+define('KRONOLITH_BASE', dirname(__FILE__));
+$kronolith_configured = (@is_readable(KRONOLITH_BASE . '/config/conf.php') &&
+                         @is_readable(KRONOLITH_BASE . '/config/prefs.php') &&
+                         @is_readable(KRONOLITH_BASE . '/config/html.php'));
+
+if ($kronolith_configured) {
+    include_once KRONOLITH_BASE . '/lib/base.php';
+
+    $uri = $prefs->getValue('userID') . '.php';
+    if ($uri == '.php') {
+        $uri = 'month.php';
+    }
+    if (!empty($_SERVER['QUERY_STRING'])) {
+        $uri .= '?' . $_SERVER['QUERY_STRING'];
+    }
+
+	$now = mktime();
+	$current_date = Kronolith::timestampToObject($now);
+	$events = $calendar->listAlarms($current_date);
+	$messages = array();
+	foreach ($events as $eventID) {
+		$thisEvent = $calendar->getEventObject($eventID);
+    		$differential = $thisEvent->getStartTimestamp() - $now;
+    		$key = $thisEvent->getStartTimestamp();
+	    	while (isset($messages[$key])) {
+	        	$key++;
+	    	}
+		$editurl = Kronolith::addParameter('editevent.php', 'eventID', $thisEvent->getID());
+		$editurl = Kronolith::addParameter($editurl, 'url', Horde::selfURL(true));
+		$editurl = Horde::applicationUrl($editurl);
+		$strView = $thisEvent->getTitle() . " </td></tr><tr><td> " . $thisEvent->getDescription();
+	    	$Titolo = $thisEvent->getTitle();
+	    	$strView = Horde::link($editurl, sprintf(_("Edit '%s'"), $Titolo), 'menuitem',"_blank") . $strView . "</a>";
+	    	$Descrizione = $thisEvent->getDescription();
+	    	if ($differential > -16 && $differential < 15) {
+	  		echo "<body marginheight=0 marginwidth=0  onLoad=\"self.focus();alert('$Titolo \\n\\n $Descrizione')\">\n";
+	        	$messages[$key] = array(sprintf(_("%s </td></tr><tr><td><b> Is starting now..</b>"), $strView), 'kronolith.alarm');
+	    	} else if ($differential < 0 && $now <= $thisEvent->getEndTimestamp()) {
+	        	$messages[$key] = array(sprintf(_("%s </td></tr><tr><td><b> is in progress.</b>"), $strView), 'kronolith.event');
+	    	} else if ($differential > 15 && $differential < 7200) {
+	        	$messages[$key] = array(sprintf(_("%s </td></tr><tr><td><b> starts in %s</b>"), $strView, Kronolith::secondsToString($differential)), 'kronolith.alarm');
+	    	} else  {
+	    		$tStr= "</b> il " . date('d-m-Y', $thisEvent->getEndTimestamp()) . " dalle " . date('H:i', $thisEvent->getStartTimestamp()) . " alle " . date('H:i', $thisEvent->getEndTimestamp());
+	        	$messages[$key] = array(sprintf(_("%s </td></tr><tr><td><b> is done "), $strView ), 'kronolith.alarm');
+	        	$messages[$key][0] = $messages[$key][0] . $tStr;
+	    	}
+	}
+
+	ksort($messages);
+	foreach ($messages as $message) {
+    		$notification->push($message[0], $message[1]);
+	}
+	$notification->notify();
+} else {
+    include KRONOLITH_BASE . '/templates/index/notconfigured.inc';
+}
+?>
diff -u -r -N original/login.php new/login.php
--- original/login.php	2003-01-19 00:57:20.000000000 +0100
+++ new/login.php	2003-05-14 12:08:50.000000000 +0200
@@ -98,6 +98,12 @@
     $js_onLoad = 'setFocus()';
     $template = 'login.inc';
 }
+echo "<script language='JavaScript'>\n";
+$uri2 = 'kronolith/reminder.php';
+$url2 = Horde::applicationUrl($uri2, true);
+echo "WRem = window.open('" . $url2 . "','qqq','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,left=600,top=450,width=400,height=200');";
+echo "</script>\n";
+
 require HORDE_TEMPLATES . '/common-header.inc';
 require HORDE_TEMPLATES . '/login/' . $template;
 require HORDE_TEMPLATES . '/common-footer.inc';


More information about the dev mailing list