phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] phpgroupware/ipc_test_suite/sources/app/class.ipc_ca


From: nomail
Subject: [Phpgroupware-cvs] phpgroupware/ipc_test_suite/sources/app/class.ipc_calendar.inc.php, 1.1.2.2
Date: Fri, 14 May 2004 20:39:44 +0200

Update of /phpgroupware/ipc_test_suite/sources/app
Modified Files:
        Branch: Version-0_9_16-branch
          class.ipc_calendar.inc.php

date: 2004/05/14 18:39:44;  author: mkaemmerer;  state: Exp;  lines: +86 -6

Log Message:
- new version from DS
=====================================================================
Index: phpgroupware/ipc_test_suite/sources/app/class.ipc_calendar.inc.php
diff -u 
phpgroupware/ipc_test_suite/sources/app/class.ipc_calendar.inc.php:1.1.2.1 
phpgroupware/ipc_test_suite/sources/app/class.ipc_calendar.inc.php:1.1.2.2
--- phpgroupware/ipc_test_suite/sources/app/class.ipc_calendar.inc.php:1.1.2.1  
Mon Apr  5 19:42:00 2004
+++ phpgroupware/ipc_test_suite/sources/app/class.ipc_calendar.inc.php  Fri May 
14 18:39:44 2004
@@ -69,14 +69,53 @@
                */
                function getData($id, $type, $version='')
                {
-                       if(($type != 'text/x-ical') && ($type != 
'text/calendar'))
-                               return false;
-
                        if(!is_integer($id) || ($id<=0))
                                return false;
 
-                       $data = $this->bo_iCal->export(array('l_event_id' => 
$id));
-                       return $data;
+                       switch($type)
+                       {
+                               case 'text/x-ical':
+                               case 'text/calendar':
+                                       return 
$this->bo_iCal->export(array('l_event_id' => $id));
+                               break;
+                               case 'text/xml':
+                                       return false;
+                               break;
+                               case 'x-phpgroupware/search-index-data-item':
+                                       $event = $this->bo->read_entry($id);
+                                       if(!$event)
+                                       {
+                                               return false;
+                                       }
+
+                                       $event_array = 
$this->bo->event2array($event);
+                                       $fields = array();
+                                       while(list($key, $value) = 
each($event_array))
+                                       {
+                                               if(isset($value['data']))
+                                               {
+                                                       
if(is_array($value['data']))
+                                                       {
+                                                               $fields[$key] = 
implode(',', $value['data']);
+                                                       }
+                                                       else
+                                                       {
+                                                               $fields[$key] = 
$value['data'];
+                                                       }
+                                               }
+                                       }
+
+                                       $fields['id']          = $id;
+                                       $fields['owner_id']    = 
$event['owner'];
+                                       $fields['priority']    = 
$event['priority'];
+                                       $fields['category_id'] = 
$event['category'];
+                                       $fields['last_mod']    = 
$this->bo->maketime($event['modtime']);
+
+                                       return 
$this->_export_index_data_item($fields);
+                               break;
+                               default:
+                                       return false;
+                       }
                }
 
 
@@ -85,9 +124,10 @@
                * The optional lastmod parameter allows a limitations of the 
data id list.
                * The list contains all the id's of the modified data since the 
passed lastmod timestamp.
                * @param integer $lastmod last modification time, default is -1 
and means return all data id's
+               * @param string $restriction restrict the result for a special 
use of the id list. The possible restrictions are 'syncable' or 'searchable'. 
When using 'syncable' only person ids will be returned in the result. 
'searchable' returns all ids for both persons and orgs without check the owner. 
Otherwise no restriction will be used and the result contains all ids for both 
persons and orgs from the owner.
                * @return array list of data id's, if $lastmod is set, only 
modified entry id's, else all id's returned
                */
-               function getIdList($lastmod=-1)
+               function getIdList($lastmod=-1, $restriction='')
                {
                        return $this->bo->so->cal->list_dirty_events($lastmod);
                }
@@ -156,5 +196,45 @@
                        else
                                return true;
                }
+
+               function &_export_index_data_item($fields)
+               {
+                       $index_xml_item = CreateObject('search.index_xml_item', 
'calendar', $fields['id']);
+                       $index_xml_item->setDisplayName($fields['title']);
+                       $index_xml_item->setPriority($fields['priority']);
+
+                       $catId   = 
$fields['category_id']?$fields['category_id']:'';
+                       $catName = $fields['category']?$fields['category']:'';
+                       $index_xml_item->setCategory($catId, $catName);
+
+                       $ownerId = $fields['owner_id'];
+                       $groupId = '';
+                       $visibilty = $fields['access'];
+                       $index_xml_item->setAccess($ownerId, $groupId, 
$visibilty);
+
+                       $created    = $fields['created']?$fields['created']:'';
+                       $modified   = 
$fields['last_mod']?$fields['last_mod']:'';
+                       $lastAccess = 
$fields['lastAccess']?$fields['lastAccess']:'';
+                       $index_xml_item->setTimestamp($created, $modified, 
$lastAccess);
+
+                       // create csv file string
+                       $csv = implode(',', array_keys($fields));
+                       $csv .= "\r\n";
+
+                       $values = array_values($fields);
+                       for($i=0; $i<count($values); ++$i)
+                       {
+                               if($i>0)
+                                       $csv .= ",";
+                               $csv .= str_replace(",", "\,", 
addslashes($values[$i]));
+                       }
+                       $csv .= "\r\n";
+
+                       $index_xml_item->setContent($csv, 'text/csv', '1.0');
+                       $index_xml_item->setContentTransferEncoding('base64');
+
+                       return $index_xml_item;
+               }
+
        }
 ?>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]