stuart: server/kolab-resource-handlers/kolab-resource-handlers/fbview/fbview/kronolith attendeescommon.php, 1.1.1.1, 1.2

cvs at intevation.de cvs at intevation.de
Fri Jul 16 00:08:07 CEST 2004


Author: stuart

Update of /kolabrepository/server/kolab-resource-handlers/kolab-resource-handlers/fbview/fbview/kronolith
In directory doto:/tmp/cvs-serv12329/kronolith

Modified Files:
	attendeescommon.php 
Log Message:
Updated the free/busy viewer to use the new XML data format
Added support to show the event title on busy blocks, making them a bit more descriptive


Index: attendeescommon.php
===================================================================
RCS file: /kolabrepository/server/kolab-resource-handlers/kolab-resource-handlers/fbview/fbview/kronolith/attendeescommon.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- attendeescommon.php	11 Jun 2004 10:52:04 -0000	1.1.1.1
+++ attendeescommon.php	15 Jul 2004 22:08:05 -0000	1.2
@@ -14,6 +14,62 @@
 require '/kolab/etc/resmgr/fbview.conf';
 require_once 'Horde/Text.php';
 
+function getKronolithHash($xml_text)
+{
+    $xmldoc = @domxml_open_mem($xml_text, DOMXML_LOAD_PARSING +
+        DOMXML_LOAD_COMPLETE_ATTRS + DOMXML_LOAD_SUBSTITUTE_ENTITIES +
+        DOMXML_LOAD_DONT_KEEP_BLANKS, $error);
+
+    if (!empty($error)) {
+        // There were errors parsing the XML data - abort
+        return false;
+    }
+
+    $noderoot = $xmldoc->document_element();
+    $childnodes = $noderoot->child_nodes();
+
+    $event_hash = array();
+
+    // Build the event hash
+    foreach ($childnodes as $value) {
+        $event_hash[$value->tagname] = $value->get_content();
+    }
+
+    // Perform some sanity checks on the event
+    if (
+        empty($event_hash['uid']) ||
+        empty($event_hash['start-date']) ||
+        empty($event_hash['end-date'])
+    ) {
+        return false;
+    }
+
+    // Make sure we're allowed to view this event
+    if (!empty($event_hash['sensitivity']) && $event_hash['sensitivity'] != 'public') {
+        return false;
+    }
+
+    // Convert the Kolab hash to a corresponding Kronolith hash
+    $kronolith_hash = array();
+    $kronolith_hash['uid'] = $event_hash['uid'];
+    $kronolith_hash['title'] = empty($event_hash['summary']) ? '' : $event_hash['summary'];
+    $kronolith_hash['description'] = empty($event_hash['body']) ? '' : $event_hash['body'];
+    $kronolith_hash['category'] = empty($event_hash['categories']) ? '' : $event_hash['categories'];
+    $kronolith_hash['location'] = empty($event_hash['location']) ? '' : $event_hash['location'];
+
+    $kronolith_hash['start_date'] = empty($event_hash['start-date']) ? '' :
+        substr($event_hash['start-date'], 0, 10);
+    $kronolith_hash['start_time'] = empty($event_hash['start-date']) ? '' :
+        substr($event_hash['start-date'], 11, 8);
+
+    $kronolith_hash['end_date'] = empty($event_hash['start-date']) ? '' :
+        substr($event_hash['start-date'], 0, 10);
+    $kronolith_hash['end_time'] = empty($event_hash['start-date']) ? '' :
+        substr($event_hash['start-date'], 11, 8);
+
+    return $kronolith_hash;
+}
+
 function getFreeBusy($user)
 {
     global $params;
@@ -124,7 +180,7 @@
     if (imapConnect($viewEventUser)) {
         $messages = @imap_sort($imap, SORTDATE, 0, SE_UID, 'SUBJECT "' . $viewEventUID . '"');
         if (!imapSuccess() || !is_array($messages) || count($messages) < 1) {
-            $messages = @imap_sort($imap, SORTDATE, 0, SE_UID, 'BODY "UID:" BODY "' . $viewEventUID . '"');
+            $messages = @imap_sort($imap, SORTDATE, 0, SE_UID, 'BODY "<uid>" BODY "' . $viewEventUID . '" BODY "</uid>"');
         }
 
         if (imapSuccess() && is_array($messages) && count($messages) > 0) {
@@ -135,40 +191,35 @@
             if (imapSuccess()) {
                 $mimemsg = &MIME_Structure::parseTextMIMEMessage($textmsg);
 
-                // Get a text/calendar MIME part
+                // Read in a kolab event object, if one exists
                 $parts = $mimemsg->contentTypeMap();
                 $event = false;
                 foreach ($parts as $mimeid => $conttype) {
-                    if ($conttype == 'text/calendar') {
+                    if ($conttype == 'application/x-vnd.kolab.event') {
                         $part = $mimemsg->getPart($mimeid);
 
-                        $eventICal = &new Horde_iCalendar();
-                        $eventICal->parsevCalendar($part->toString());
-                        $vEvent = $eventICal->findComponent('VEVENT');
-                        if ($vEvent !== false) {
-                            $class = strtoupper($vEvent->getAttributeDefault('CLASS', 'PUBLIC'));
-                            if ($class == 'PUBLIC') {
-                                $event = new Kronolith_Event($GLOBALS['kronolith']);
-                                $event->fromiCalendar($vEvent);
+                        $event_hash = getKronolithHash($part->toString());
+                        if ($event_hash !== false) {
+                            $event = new Kronolith_Event($GLOBALS['kronolith']);
+                            $event->setID($event_hash['uid']);
+                            $event->fromHash($event_hash);
 
-                                $event->setTitle($vEvent->getAttributeDefault('SUMMARY', $viewEventUID));
-                                $event->meetingID = $viewEventUID;
-                                $category = $event->getCategory();
-                                $description = $event->getDescription();
-                                $location = $event->getLocation();
-                                $status = Kronolith::statusToString($event->getStatus());
-                                $attendees = $event->getAttendees();
+                            $event->meetingID = $viewEventUID;
+                            $category = $event->getCategory();
+                            $description = $event->getDescription();
+                            $location = $event->getLocation();
+                            $status = Kronolith::statusToString($event->getStatus());
+                            $attendees = $event->getAttendees();
 
-                                $mylinks = array();
-                                require KRONOLITH_TEMPLATES . '/view/view.inc';
-                            } else {
-                                accessDenied($viewEventUID);
-                            }
+                            $mylinks = array();
+                            require KRONOLITH_TEMPLATES . '/view/view.inc';
                         } else {
                             accessDenied($viewEventUID);
                         }
                     }
                 }
+
+                // TODO: check if an event was actually retrieved
             } else {
                 accessDenied($viewEventUID);
             }





More information about the commits mailing list