[kronolith] [PATCH] Mysql support
Luc Saillard
luc+kronolith@alcove.fr
Tue, 17 Jul 2001 19:16:12 +0200
Oops attachement was stripped
diff -Naur -x config kronolith/docs/kronolith.mysql horde/kronolith/docs/kronolith.mysql
--- kronolith/docs/kronolith.mysql Thu Jan 1 01:00:00 1970
+++ horde/kronolith/docs/kronolith.mysql Tue Jul 17 19:02:52 2001
@@ -0,0 +1,71 @@
+# MySQL dump 7.1
+#
+# Host: localhost Database: calendar
+#--------------------------------------------------------
+# Server version 3.22.32-log
+
+#
+# Table structure for table 'events'
+#
+CREATE TABLE events (
+ id int(11) DEFAULT '0' NOT NULL auto_increment,
+ groupid varchar(100) DEFAULT '' NOT NULL,
+ description text,
+ location text,
+ keywords text,
+ title varchar(80),
+ category varchar(80),
+ recur_type int(11) DEFAULT '0',
+ recur_interval int(11),
+ recur_days int(11),
+ start datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
+ end datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
+ recur_enddate date,
+ alarm tinyint(4) DEFAULT '0',
+ PRIMARY KEY (id)
+);
+
+#
+# Dumping data for table 'events'
+#
+
+INSERT INTO events VALUES (9,'luc','test de 10 heures','',NULL,'plop','Personal',1,1,NULL,'2001-07-03 10:00:00','2001-07-03 11:00:00','9999-12-31',0);
+INSERT INTO events VALUES (10,'luc','azaezaea','',NULL,'test de 15 heures','Personal',0,NULL,NULL,'2001-07-03 14:00:00','2001-07-03 15:00:00',NULL,0);
+INSERT INTO events VALUES (11,'luc','ezaeaezaezzea','',NULL,'aezaeaae','Personal',0,NULL,NULL,'2001-07-03 22:00:00','2001-07-03 23:00:00',NULL,0);
+INSERT INTO events VALUES (12,'luc','enrgehrrpehgerer\r\nerterpjeot\r\nsretbsets','',NULL,'test 2','Personal',1,1,NULL,'2001-07-17 14:00:00','2001-07-17 15:00:00','9999-12-31',0);
+
+#
+# Table structure for table 'groups'
+#
+CREATE TABLE groups (
+ name varchar(50) DEFAULT '' NOT NULL,
+ owner varchar(100),
+ mode int(11),
+ PRIMARY KEY (name)
+);
+
+#
+# Dumping data for table 'groups'
+#
+
+INSERT INTO groups VALUES ('luc','luc',1);
+INSERT INTO groups VALUES ('il','luc',3);
+INSERT INTO groups VALUES ('mk','luc',3);
+
+#
+# Table structure for table 'users'
+#
+CREATE TABLE users (
+ userid varchar(100) DEFAULT '' NOT NULL,
+ groupid varchar(100) DEFAULT '' NOT NULL,
+ PRIMARY KEY (userid,groupid)
+);
+
+#
+# Dumping data for table 'users'
+#
+
+INSERT INTO users VALUES ('luc','il');
+INSERT INTO users VALUES ('luc','luc');
+INSERT INTO users VALUES ('luc','mk');
+
diff -Naur -x config kronolith/lib/Driver/mcal.php horde/kronolith/lib/Driver/mcal.php
--- kronolith/lib/Driver/mcal.php Tue Jul 10 22:38:07 2001
+++ horde/kronolith/lib/Driver/mcal.php Tue Jul 17 13:54:54 2001
@@ -39,7 +39,7 @@
function listAlarms($date)
{
- $events = mcal_list_alarms($this->stream, $date['year'], $date['mon'], $date['mday'], $date['hours'], $date['minutes'], $date['seconds']);
+ $events = @mcal_list_alarms($this->stream, $date['year'], $date['mon'], $date['mday'], $date['hours'], $date['minutes'], $date['seconds']);
return is_array($events) ? $events : array();
}
diff -Naur -x config kronolith/lib/Driver/mysql.php horde/kronolith/lib/Driver/mysql.php
--- kronolith/lib/Driver/mysql.php Thu Jan 1 01:00:00 1970
+++ horde/kronolith/lib/Driver/mysql.php Tue Jul 17 18:49:07 2001
@@ -0,0 +1,607 @@
+<?php
+// $Horde: kronolith/lib/Driver/mysql.php,v 1.11 2001/06/08 20:23:32 chuck Exp $
+
+include "Date/Calc.php";
+
+/**
+ * The Kronolith_Driver_mysql:: class implements the Kronolith_Driver
+ * API for an Mysql backend.
+ * Each user is in there own group.
+ * Table users contains a tuple (user,group) like, that we can ask the list of group a user is subscribe
+ * SELECT groupid from users where userid='XXX'
+ * or the list of subscriber for a group
+ * SELECT userid from users where groupid='XXX'
+ * Table groups contains information for a group. Like the main owner (which can change access to the group),
+ * and access mode (public, private, share). For now, a group can't contains another group. If we do this, we need
+ * another sub select request. Perhaps we can propose this with a id like Huffman code. The can only have 26 subcategory.
+ * A-->Z then AA-->AZ ... ZA-->ZZ then AAA--> .... --> ZZZ.
+ * So if we wen search main category , we search with A%
+ *
+ * @author Luc Saillard <luc.saillard@fr.alcove.com>
+ * @version $Revision: 0.1 $
+ * @since Kronolith 0.3
+ * @package kronolith
+ */
+class Kronolith_Driver_mysql {
+
+ var $mcalUsername;
+ var $mcalPassword;
+ var $stream;
+ var $host; /* host:port */
+ var $database;
+ var $userid;
+
+ function Kronolith_Driver_mysql($params)
+ {
+ $this->mcalUsername = $params['username'];
+ $this->mcalPassword = $params['password'];
+ $this->database = $params['database'];
+ $this->host = $params['host'];
+ }
+
+ function open($userid)
+ {
+ if (empty($this->mcalPassword))
+ {
+ $this->stream = mysql_pconnect($this->host, $this->mcalUsername);
+ }
+ else
+ {
+ $this->stream = mysql_pconnect($this->host, $this->mcalUsername, $this->mcalPassword);
+ }
+ if (!mysql_select_db($this->database,$this->stream))
+ {
+ print("Can't open database " . $this->database ."<br>\n");
+ exit();
+ }
+ $this->userid = $userid;
+ }
+
+ function listAlarms($date)
+ {
+ // TODO:
+ $events = array();
+ return is_array($events) ? $events : array();
+ }
+
+ function listEvents($startDate, $endDate)
+ {
+ $events = array();
+
+ $stime=sprintf("%04d%02d%02d000000",$startDate['year'],$startDate['month'],$startDate['day']);
+ $etime=sprintf("%04d%02d%02d235959",$endDate['year'],$endDate['month'],$endDate['day']);
+ /* Check the begin date then check the end date against end,recur_enddate, then check against groupid */
+ $q = "SELECT DISTINCT e.id FROM events AS e, users AS u WHERE " .
+ "e.start >= " . $stime . " AND " .
+ "(e.end <= " . $etime . " OR (e.recur_enddate <= " . $etime . " AND e.recur_type != 0)) AND " .
+ "((u.userid='" . $this->userid . "' AND e.groupid = u.groupid) OR e.groupid = '" . $this->userid . "')";
+ //printf("%s<br>\n",$q);
+ if ($qr=mysql_query($q,$this->stream))
+ {
+ while (list($id) = mysql_fetch_row($qr))
+ {
+ $events[]=$id;
+ }
+ }
+
+ return $events;
+ }
+
+ function getEvent($eventID)
+ {
+ $qr = mysql_query("SELECT id,groupid,description,location,keywords,title,category," .
+ "recur_type,recur_enddate,recur_interval,recur_days,start,end,alarm," .
+ "UNIX_TIMESTAMP(start),UNIX_TIMESTAMP(end),TO_DAYS(recur_enddate) " .
+ "FROM events WHERE id = $eventID",$this->stream);
+ if ($qr)
+ {
+ $row = mysql_fetch_assoc($qr);
+
+ if (is_array($row))
+ {
+ while (list($key,$val) = each($row)) {
+ //print("getEvent($eventID): $key ==> [$val]<br>\n");
+ $res->$key = $val;
+ }
+ list($res->start->year,$res->start->month,$res->start->mday,$res->start->hour,$res->start->minute,$res->start->second) = sscanf($row['start'],"%04d-%02d-%02d %02d:%02d:%02d");
+ list($res->end->year,$res->end->month,$res->end->mday,$res->end->hour,$res->end->minute,$res->end->second) = sscanf($row['end'],"%04d-%02d-%02d %02d:%02d:%02d");
+// list($res->recur_enddate->year,$res->recur_enddate->month,$res->recur_enddate->mday) = sscanf($row['recur_enddate'],"%04d-%02d-%02d");
+
+ $res->startTimestamp=$row['UNIX_TIMESTAMP(start)'];
+ $res->endTimestamp=$row['UNIX_TIMESTAMP(end)'];
+ $res->recur_enddays=$row['TO_DAYS(recur_enddate)'];
+
+ return $res;
+ }
+ }
+ return 0;
+ }
+
+ function getEventObject($eventID = null)
+ {
+ if (isset($eventID))
+ return new Kronolith_Event_mysql($this, $this->getEvent($eventID));
+ else
+ return new Kronolith_Event_mysql($this);
+ }
+
+ function saveEvent($eventID, $properties)
+ {
+ if ($eventID) {
+ $query = "UPDATE events SET ";
+
+ while (list($key,$val) = each($properties))
+ {
+ $query .= " $key='" . mysql_escape_string($val) . "',";
+ }
+ $query=substr($query,0,-1);
+ $query .= " WHERE id = $eventID ";
+
+ //print("$query<br>\n");
+ if (!mysql_query($query, $this->stream))
+ {
+ echo mysql_errno().": ".mysql_error()."<BR>";
+ exit();
+ return false;
+ }
+
+ return true;
+ } else {
+
+ $query = "INSERT INTO events ";
+ $cols_name = "(";
+ $cols_values = "values (";
+
+ while (list($key,$val) = each($properties))
+ {
+ $cols_name .= " $key,";
+ $cols_values .= "'" . mysql_escape_string($val) . "',";
+ }
+
+ $cols_name .= " groupid)";
+ $cols_values .= "'" . mysql_escape_string($this->userid) . "')";
+
+ //print("$query . $cols_name . $cols_values<br>\n");
+ if (!mysql_query($query . $cols_name . $cols_values, $this->stream))
+ {
+ echo mysql_errno().": ".mysql_error()."<BR>";
+ exit();
+ return false;
+ }
+
+ return true;
+ }
+ }
+
+ function nextRecurrence($eventID, $afterDate = null, $weekstart = KRONOLITH_SUNDAY)
+ {
+ return false;
+ //print("</table><h2>nextRecurrence($eventID, " . $afterDate['year'] . "/" . $afterDate['month'] . "/" . $afterDate['mday'] ." , $weekstart)<br>\n");
+ $obj = $this->getEvent($eventID);
+ switch($obj->recur_type)
+ {
+ case KRONOLITH_RECUR_DAILY:
+ /* The formula is :
+ * next_day = cur_day + interval - (cur_day - start_day) % interval
+ * All the calcul is done in days (because we can't use timestamp in a 32 bits integer, year 9999 return -1 ;)
+ */
+ $q = sprintf("SELECT TO_DAYS(FROM_UNIXTIME('%d')),TO_DAYS('%04d-%02d-%02d')",
+ $obj->startTimestamp,$afterDate['year'],$afterDate['month'],$afterDate['mday']);
+
+ //print("<h2>$q<br>");
+ if ($qr=mysql_query($q,$this->stream))
+ {
+ $row = mysql_fetch_array($qr);
+ if (is_array($row))
+ {
+ $start_day = $row[0];
+ $current_day = $row[1];
+ $end_day = $obj->recur_enddays;
+
+ //$start_day = $obj->startTimestamp/3600/24; /* In days */
+ //$current_day = Date_Calc::dateToDays($afterDate['mday'],$afterDate['month'],$afterDate['year']);
+ //$end_day = $obj->recurEndTimestamp/3600/24;
+ if ($obj->recur_interval<=1)
+ $next_day = $current_day;
+ else
+ $next_day = $current_day + $obj->recur_interval - (($current_day - $start_day)%$obj->recur_interval);
+ //printf("start_day=%d next_day=%d end_day=%d<br>\n",$start_day,$next_day,$end_day);
+ /* If the next day is greater than $end_day return nothing */
+ if ($next_day > $end_day)
+ return false;
+ list($res->year,$res->month,$res->mday)=Kronolith_Driver_mysql::daysToDate($next_day);
+ return $res;
+ }
+ }
+ return false;
+ case KRONOLITH_RECUR_WEEKLY:
+ $start_day = $obj->start->mday;
+ $current_day = $afterDate['mday'];
+ if ($obj->recur_interval<=1)
+ $next_day=$current_day;
+ else
+ $next_day = $current_day + $obj->recur_interval - (($current_day - $start_day)%$obj->recur_interval);
+
+ $interval=$obj->recur_interval*7;
+ $start_day = Kronolith::dayOfYear($obj->start->year,$obj->start->month,$obj->start->mday);
+ $current_day = Kronolith::dayOfYear($afterDate['year'],$afterDate['month'], $afterDate['mday']);
+ $next_day = $current_day + $interval - (($current_day - $start_day) % $interval);
+
+ $res->year=$afterDate['year'];
+ $res->month=$afterDate['month'];
+ $res->mday=$next_day;
+
+ break;
+ case KRONOLITH_RECUR_YEARLY:
+ $interval= ($obj->recur_interval*365) + Kronolith::isLeapYear($afterDate['year']);
+ $start_day = Kronolith::dayOfYear($obj->start->year,$obj->start->month,$obj->start->mday);
+ $current_day = Kronolith::dayOfYear($afterDate['year'],$afterDate['month'], $afterDate['mday']);
+ $next_day = $current_day + $interval - (($current_day - $start_day) % $interval);
+ break;
+ default:
+ return false;
+ }
+
+ /* The test is done by the function who use the function */
+ $end_day = Kronolith::dayOfYear($obj->recur_enddate_year,$obj->recur_enddate_month, $obj->recur_enddate_day);
+ printf("start_day=%d, current_day=%d, next_day=%d, end_day=%d\n",$start_day,$current_day,$next_day,$end_day);
+// if ($next_day<=$end_day)
+ {
+ list($year, $month, $mday) = explode(':', date('Y:n:j', $next_day * 3600 *24));
+ print("nextRecurrence(" .$res->year . "/" . $res->month . "/" . $res->mday .")<br>\n");
+ return $res;
+ }
+ }
+
+ function deleteEvent($eventID)
+ {
+ $query = "DELETE from events WHERE id = $eventID";
+ if (!mysql_query($query, $this->stream))
+ {
+ echo mysql_errno().": ".mysql_error()."<BR>";
+ return false;
+ }
+
+ return true;
+ }
+
+ function parseMcalDate($dateObject)
+ {
+ if (count($dateObject) === 0) {
+ return 0;
+ }
+
+ $year = isset($dateObject->year) ? $dateObject->year : 0;
+ $month = isset($dateObject->month) ? $dateObject->month : 0;
+ $day = isset($dateObject->mday) ? $dateObject->mday : 0;
+
+ // Check for events with no recur_enddate
+ if ($year == 9999 && $month == 12 && $day == 31) {
+ return 0;
+ }
+
+ $hour = isset($dateObject->hour) ? $dateObject->hour : 0;
+ $minute = isset($dateObject->min) ? $dateObject->min : 0;
+ $second = isset($dateObject->sec) ? $dateObject->sec : 0;
+
+ return mktime($hour, $minute, $second, $month, $day, $year);
+ }
+
+
+ /**
+ * Converts number of days to a distant unspecified epoch.
+ *
+ * @param int number of days
+ *
+ * @access public
+ *
+ * @return an array(YYYY,MM,DD)
+ */
+
+ function daysToDate($days)
+ {
+ $days -= 1721119;
+ $century = floor(( 4 * $days - 1) / 146097);
+ $days = floor(4 * $days - 1 - 146097 * $century);
+ $day = floor($days / 4);
+
+ $year = floor(( 4 * $day + 3) / 1461);
+ $day = floor(4 * $day + 3 - 1461 * $year);
+ $day = floor(($day + 4) / 4);
+
+ $month = floor(( 5 * $day - 3) / 153);
+ $day = floor(5 * $day - 3 - 153 * $month);
+ $day = floor(($day + 5) / 5);
+
+ if($month < 10)
+ $month +=3;
+ else
+ {
+ $month -=9;
+ if($year++ == 99)
+ {
+ $year = 0;
+ $century++;
+ }
+ }
+ return array($year + $century*100,$month,$day);
+ }
+
+
+
+}
+
+class Kronolith_Event_mysql extends Kronolith_Event {
+
+ var $initialized = false;
+
+ function Kronolith_Event_mysql(&$driver, $eventObject = null)
+ {
+ parent::Kronolith_Event($driver, $eventObject);
+
+ $this->properties=array();
+ $this->eventID=0;
+
+ if (isset($eventObject))
+ $this->parseMcalEvent($eventObject);
+ }
+
+ function save()
+ {
+ if (!$this->initialized) {
+ return false;
+ }
+
+ return $this->driver->saveEvent($this->eventID, $this->properties);
+ }
+
+ function parseMcalEvent($mcalEvent)
+ {
+ $this->title = $mcalEvent->title;
+ if (isset($mcalEvent->category)) {
+ $this->category = $mcalEvent->category;
+ }
+ $this->location = isset($mcalEvent->attrlist['location']) ? $mcalEvent->attrlist['location'] : '';
+ if (isset($mcalEvent->attrlist['keywords'])) {
+ $this->keywords = explode(',', $mcalEvent->attrlist['keywords']);
+ }
+ if (isset($mcalEvent->description)) {
+ $this->description = $mcalEvent->description;
+ }
+ $this->eventID = $mcalEvent->id;
+
+ $this->startTimestamp = $mcalEvent->startTimestamp;
+ $this->endTimestamp = $mcalEvent->endTimestamp;
+ if (isset($mcalEvent->recurEndTimestamp)) {
+ $this->recurEndTimestamp = $mcalEvent->recurEndTimestamp;
+ } else {
+ $this->recurEndTimestamp = 0;
+ }
+
+ if (isset($mcalEvent->alarm))
+ $this->alarm = $mcalEvent->alarm;
+ else
+ $this->alarm = 0;
+
+ $this->recurType = $mcalEvent->recur_type;
+ $this->recurInterval = $mcalEvent->recur_interval;
+ if (isset($mcalEvent->recur_data)) {
+ $this->recurData = $mcalEvent->recur_data;
+ }
+
+ $this->initialized = true;
+ }
+
+ function readFormData($eventData)
+ {
+ global $prefs;
+
+ // basic fields
+ if (isset($eventData['title'])) {
+ $this->properties['title']=$eventData['title'];
+ }
+ if (isset($eventData['description'])) {
+ $this->properties['description']=$eventData['description'];
+ }
+ if (isset($eventData['category'])) {
+ $this->properties['category']=$eventData['category'];
+ }
+ if (isset($eventData['location'])) {
+ $this->properties['location']=$eventData['location'];
+ }
+ if (isset($eventData['keywords'])) {
+ $this->properties['keywords']=$eventData['keywords'];
+ }
+
+ // event start
+ if (isset($eventData['start_year'])
+ && isset($eventData['start_month'])
+ && isset($eventData['start_day'])
+ && isset($eventData['start_hour'])
+ && isset($eventData['start_min'])
+ && (isset($eventData['am_pm'])
+ || ($prefs->getValue('24hr')))) {
+ if (!$prefs->getValue('24hr')) {
+ if ($eventData['am_pm'] == 'PM') {
+ if ($eventData['start_hour'] != 12)
+ $eventData['start_hour'] += 12;
+ } elseif ($eventData['start_hour'] == 12) {
+ $eventData['start_hour'] = 0;
+ }
+ }
+ if (isset($eventData['end_or_dur'])
+ && $eventData['end_or_dur'] == 1
+ && isset($eventData['whole_day'])
+ && $eventData['whole_day'] == 1) {
+ $eventData['start_hour'] = 0;
+ $eventData['start_min'] = 0;
+ $eventDate['dur_day'] = 0;
+ $eventData['dur_hour'] = 24;
+ $eventData['dur_min'] = 0;
+ }
+ $this->properties['start']=sprintf("%04d%02d%02d%02d%02d00",
+ $eventData['start_year'],$eventData['start_month'],$eventData['start_day'],
+ $eventData['start_hour'],$eventData['start_min']);
+
+ if (isset($eventData['end_or_dur'])
+ && $eventData['end_or_dur'] == 1) {
+ // event duration
+ if (isset($eventData['dur_day'])
+ && isset($eventData['dur_hour'])
+ && isset($eventData['dur_min'])) {
+ $endstamp = mktime($eventData['start_hour'] + $eventData['end_hour'],
+ $eventData['start_min'] + $eventData['end_min'],
+ 0,
+ $eventData['start_month'],
+ $eventData['start_day'],
+ $eventData['start_year']);
+
+ $this->properties['end']=date('YmdHis',$endstamp);
+ }
+ } else {
+ // event end
+ if (isset($eventData['end_year'])
+ && isset($eventData['end_month'])
+ && isset($eventData['end_day'])
+ && isset($eventData['end_hour'])
+ && isset($eventData['end_min'])
+ && (isset($eventData['end_am_pm'])
+ || ($prefs->getValue('24hr')))) {
+ if (!$prefs->getValue('24hr')) {
+ if ($eventData['end_am_pm'] == 'PM') {
+ if ($eventData['end_hour'] != 12)
+ $eventData['end_hour'] += 12;
+ } elseif ($eventData['end_hour'] == 12) {
+ $eventData['end_hour'] = 0;
+ }
+ }
+ $endstamp = mktime($eventData['end_hour'],
+ $eventData['end_min'],
+ 0,
+ $eventData['end_month'],
+ $eventData['end_day'],
+ $eventData['end_year']);
+// if ($endstamp < $startstamp)
+// $endstamp = $startstamp;
+ $this->properties['end']=date('YmdHis',$endstamp);
+ }
+ }
+ }
+
+ // alarm
+
+ if (isset($eventData['alarm'])) {
+ if ($eventData['alarm'] == 1 &&
+ isset($eventData['alarm_hour']) &&
+ isset($eventData['alarm_min'])) {
+ $this->properties['alarm']=($eventData['alarm_hour'] * 60 + $eventData['alarm_min']);
+ } else {
+ $this->properties['alarm']=0;
+ }
+ }
+
+ // recurrence
+ if (isset($eventData['recur'])) {
+ if (isset($eventData['recur_enddate_type']) &&
+ $eventData['recur_enddate_type'] == 'none') {
+ $eventData['recur_enddate_year'] = 9999;
+ $eventData['recur_enddate_month'] = 12;
+ $eventData['recur_enddate_day'] = 31;
+ }
+
+ switch ($eventData['recur']) {
+ case KRONOLITH_RECUR_NONE:
+ $this->properties['recur_type']=KRONOLITH_RECUR_NONE;
+ break;
+
+ case KRONOLITH_RECUR_DAILY:
+ if (isset($eventData['recur_enddate_year'])
+ && isset($eventData['recur_enddate_month'])
+ && isset($eventData['recur_enddate_day'])) {
+ if (empty($eventData['recur_daily_interval']))
+ $eventData['recur_daily_interval'] = 1;
+
+ $this->properties['recur_type']=KRONOLITH_RECUR_DAILY;
+ $this->properties['recur_interval']=$eventData['recur_daily_interval'];
+ $this->properties['recur_enddate']=sprintf("%04d%02d%02d",
+ $eventData['recur_enddate_year'],
+ $eventData['recur_enddate_month'],
+ $eventData['recur_enddate_day']);
+ }
+ break;
+
+ case KRONOLITH_RECUR_WEEKLY:
+ if (isset($eventData['recur_enddate_year'])
+ && isset($eventData['recur_enddate_month'])
+ && isset($eventData['recur_enddate_day'])
+ && isset($eventData['weekly'])
+ && is_array($eventData['weekly'])) {
+ $weekdays = 0;
+ foreach ($eventData['weekly'] as $day) {
+ $weekdays |= $day;
+ }
+ if (empty($eventData['recur_weekly_interval']))
+ $eventData['recur_weekly_interval'] = 1;
+
+ $this->properties['recur_type']=KRONOLITH_RECUR_WEEKLY;
+ $this->properties['recur_interval']=$eventData['recur_weekly_interval'];
+ $this->properties['recur_days']=$weekdays;
+ $this->properties['recur_enddate']=sprintf("%04d%02d%02d",
+ $eventData['recur_enddate_year'],
+ $eventData['recur_enddate_month'],
+ $eventData['recur_enddate_day']);
+ }
+ break;
+
+ case KRONOLITH_RECUR_DAY_OF_MONTH:
+ if (isset($eventData['recur_enddate_year'])
+ && isset($eventData['recur_enddate_month'])
+ && isset($eventData['recur_enddate_day'])) {
+ if (empty($eventData['recur_day_of_month_interval']))
+ $eventData['recur_day_of_month_interval'] = 1;
+ $this->properties['recur_type']=KRONOLITH_RECUR_DAY_OF_MONTH;
+ $this->properties['recur_interval']=$eventData['recur_day_of_month_interval'];
+ $this->properties['recur_enddate']=sprintf("%04d%02d%02d",
+ $eventData['recur_enddate_year'],
+ $eventData['recur_enddate_month'],
+ $eventData['recur_enddate_day']);
+ }
+ break;
+
+ case KRONOLITH_RECUR_WEEK_OF_MONTH:
+ if (isset($eventData['recur_enddate_year'])
+ && isset($eventData['recur_enddate_month'])
+ && isset($eventData['recur_enddate_day'])) {
+ if (empty($eventData['recur_week_of_month_interval'])) $eventData['recur_week_of_month_interval'] = 1;
+ $this->properties['recur_type']=KRONOLITH_RECUR_WEEK_OF_MONTH;
+ $this->properties['recur_interval']=$eventData['recur_week_of_month_interval'];
+ $this->properties['recur_enddate']=sprintf("%04d%02d%02d",
+ $eventData['recur_enddate_year'],
+ $eventData['recur_enddate_month'],
+ $eventData['recur_enddate_day']);
+ }
+ break;
+
+ case KRONOLITH_RECUR_YEARLY:
+ if (isset($eventData['recur_enddate_year'])
+ && isset($eventData['recur_enddate_month'])
+ && isset($eventData['recur_enddate_day'])) {
+ if (empty($eventData['recur_yearly_interval'])) $eventData['recur_yearly_interval'] = 1;
+
+ $this->properties['recur_type']=KRONOLITH_RECUR_YEARLY;
+ $this->properties['recur_interval']=$eventData['recur_yearly_interval'];
+ $this->properties['recur_enddate']=sprintf("%04d%02d%02d",
+ $eventData['recur_enddate_year'],
+ $eventData['recur_enddate_month'],
+ $eventData['recur_enddate_day']);
+ }
+ break;
+
+ }
+ }
+
+ $this->initialized = true;
+ }
+
+}
+?>
--
,--------------------------------------------------------------------------.
> Saillard Luc | Free Software Engineer <
> Luc.Saillard@fr.alcove.com | Alcôve, liberating software <
> (www.alcove.com) | http://www.alcove-labs.org/ <
`--------------------------------------------------------------------------'