* @author Jan Schneider <jan@horde.org>
* @package Kronolith
*/
-class Kronolith_Driver {
-
+class Kronolith_Driver
+{
/**
* A hash containing any parameters for the current driver.
*
* @var array
*/
- var $_params = array();
+ protected $_params = array();
/**
* The current calendar.
*
* @var string
*/
- var $_calendar;
+ protected $_calendar;
/**
* An error message to throw when something is wrong.
*
* @var string
*/
- var $_errormsg;
+ private $_errormsg;
/**
* Constructor.
*
* @param array $params Any parameters needed for this driver.
*/
- function Kronolith_Driver($params = array(), $errormsg = null)
+ public function __construct($params = array(), $errormsg = null)
{
$this->_params = $params;
if ($errormsg === null) {
*
* @return mixed The parameter value or null if not set.
*/
- function getParam($param)
+ public function getParam($param)
{
return isset($this->_params[$param]) ? $this->_params[$param] : null;
}
- function open($calendar)
+ public function open($calendar)
{
$this->_calendar = $calendar;
}
*
* @return string The current calendar name.
*/
- function getCalendar()
+ public function getCalendar()
{
return $this->_calendar;
}
*
* @return string A nice unique string (should be 255 chars or less).
*/
- function generateUID()
+ public function generateUID()
{
return date('YmdHis') . '.'
. substr(str_pad(base_convert(microtime(), 10, 36), 16, uniqid(mt_rand()), STR_PAD_LEFT), -16)
*
* @return mixed True or a PEAR_Error on failure.
*/
- function rename($from, $to)
+ public function rename($from, $to)
{
return true;
}
*
* @return mixed An array of Kronolith_Events or a PEAR_Error.
*/
- function search($query)
+ public function search($query)
{
/* Our default implementation first gets <em>all</em> events in a
* specific period, and then filters based on the actual values that
* @return Horde_Date|boolean The date of the next recurrence or false if
* the event does not recur after $afterDate.
*/
- function nextRecurrence($eventId, $afterDate)
+ public function nextRecurrence($eventId, $afterDate)
{
$event = &$this->getEvent($eventId);
if (is_a($event, 'PEAR_Error')) {
* @return Kronolith_Driver The newly created concrete Kronolith_Driver
* instance, or a PEAR_Error on error.
*/
- function factory($driver = null, $params = null)
+ public function factory($driver = null, $params = null)
{
if ($driver === null) {
$driver = $GLOBALS['conf']['calendar']['driver'];
/**
* Stub to initiate a driver.
*/
- function initialize()
+ public function initialize()
{
return true;
}
/**
* Stub to be overridden in the child class.
*/
- function &getEvent()
+ public function getEvent()
{
- $error = PEAR::raiseError($this->_errormsg);
- return $error;
+ return PEAR::raiseError($this->_errormsg);
+ }
+
+ /**
+ * Stub to be overridden in the child class.
+ */
+ public function getByUID($uid, $calendars = null, $getAll = false)
+ {
+ return PEAR::raiseError($this->_errormsg);
}
/**
* Stub to be overridden in the child class.
*/
- function listAlarms($date, $fullevent = false)
+ public function listAlarms($date, $fullevent = false)
{
return PEAR::raiseError($this->_errormsg);
}
/**
* Stub to be overridden in the child class.
*/
- function listEvents()
+ public function listEvents()
{
return PEAR::raiseError($this->_errormsg);
}
/**
- * Stub o be overridden in the child class.
+ * Stub to be overridden in the child class.
*/
- function saveEvent()
+ public function saveEvent()
{
return PEAR::raiseError($this->_errormsg);
}
/**
* Stub for child class to override if it can implement.
*/
- function removeUserData($user)
+ public function exists()
+ {
+ return PEAR::raiseError('Not supported');
+ }
+
+ /**
+ * Stub to be overridden in the child class.
+ */
+ public function move($eventId, $newCalendar)
+ {
+ return PEAR::raiseError('Not supported');
+ }
+
+ /**
+ * Stub to be overridden in the child class.
+ */
+ public function delete($calendar)
+ {
+ return PEAR::raiseError('Not supported');
+ }
+
+ /**
+ * Stub to be overridden in the child class.
+ */
+ public function deleteEvent($eventId)
+ {
+ return PEAR::raiseError('Not supported');
+ }
+
+ /**
+ * Stub for child class to override if it can implement.
+ */
+ public function removeUserData($user)
{
return PEAR::raiseError(_("Removing user data is not supported with the current calendar storage backend."));
}
* @author Jan Schneider <jan@horde.org>
* @package Kronolith
*/
-class Kronolith_Event {
-
+class Kronolith_Event
+{
/**
* Flag that is set to true if this event has data from either a storage
* backend or a form or other import method.
*
* @var boolean
*/
- var $initialized = false;
+ public $initialized = false;
/**
* Flag that is set to true if this event exists in a storage driver.
*
* @var boolean
*/
- var $stored = false;
+ public $stored = false;
/**
* The driver unique identifier for this event.
*
* @var string
*/
- var $eventID = null;
+ public $eventID = null;
/**
* The UID for this event.
*
* @var string
*/
- var $_uid = null;
+ protected $_uid = null;
/**
* The iCalendar SEQUENCE for this event.
*
* @var integer
*/
- var $_sequence = null;
+ protected $_sequence = null;
/**
* The user id of the creator of the event.
*
* @var string
*/
- var $creatorID = null;
+ public $creatorID = null;
/**
* The title of this event.
*
* @var string
*/
- var $title = '';
+ public $title = '';
/**
* The location this event occurs at.
*
* @var string
*/
- var $location = '';
+ public $location = '';
/**
* The status of this event.
*
* @var integer
*/
- var $status = Kronolith::STATUS_CONFIRMED;
+ public $status = Kronolith::STATUS_CONFIRMED;
/**
* The description for this event
*
* @var string
*/
- var $description = '';
+ public $description = '';
/**
* Remote description of this event (URL).
*
* @var string
*/
- var $remoteUrl = '';
+ public $remoteUrl = '';
/**
* Remote calendar name.
*
* @var string
*/
- var $remoteCal = '';
+ public $remoteCal = '';
/**
* Whether the event is private.
*
* @var boolean
*/
- var $private = false;
+ public $private = false;
/**
* This tag's events.
*
* @var mixed Array of tags or comma delimited string.
*/
- var $tags = array();
+ public $tags = array();
/**
* All the attendees of this event.
*
* @var array
*/
- var $attendees = array();
+ public $attendees = array();
/**
* The start time of the event.
*
* @var Horde_Date
*/
- var $start;
+ public $start;
/**
* The end time of the event.
*
* @var Horde_Date
*/
- var $end;
+ public $end;
/**
* The duration of this event in minutes
*
* @var integer
*/
- var $durMin = 0;
+ public $durMin = 0;
/**
* Whether this is an all-day event.
*
* @var boolean
*/
- var $allday = false;
+ public $allday = false;
/**
* Number of minutes before the event starts to trigger an alarm.
*
* @var integer
*/
- var $alarm = 0;
+ public $alarm = 0;
/**
* The particular alarm methods overridden for this event.
*
* @var array
*/
- var $methods;
+ public $methods;
/**
* The identifier of the calender this event exists on.
*
* @var string
*/
- var $_calendar;
+ protected $_calendar;
/**
* The HTML background color to be used for this event.
*
* @var string
*/
- var $_backgroundColor;
+ protected $_backgroundColor;
/**
* The HTML foreground color to be used for this event.
*
* @var string
*/
- var $_foregroundColor;
+ protected $_foregroundColor;
/**
* The VarRenderer class to use for printing select elements.
*
* @var Horde_UI_VarRenderer
*/
- var $_varRenderer;
+ private $_varRenderer;
/**
* The Horde_Date_Recurrence class for this event.
*
* @var Horde_Date_Recurrence
*/
- var $recurrence;
+ public $recurrence;
/**
* Constructor.
* @param mixed $eventObject Backend specific event object
* that this will represent.
*/
- function Kronolith_Event(&$driver, $eventObject = null)
+ public function __construct(&$driver, $eventObject = null)
{
static $alarm;
* @return Kronolith_Driver A driver that this event can use to save
* itself, etc.
*/
- function &getDriver()
+ public function getDriver()
{
global $kronolith_driver;
if ($kronolith_driver->getCalendar() != $this->_calendar) {
*
* @return Horde_Share This event's share.
*/
- function &getShare()
+ public function getShare()
{
if (isset($GLOBALS['all_calendars'][$this->getCalendar()])) {
$share = $GLOBALS['all_calendars'][$this->getCalendar()];
*
* @return boolean
*/
- function hasPermission($permission, $user = null)
+ public function hasPermission($permission, $user = null)
{
if ($user === null) {
$user = Auth::getAuth();
*
* @return mixed True or a PEAR_Error on failure.
*/
- function save()
+ public function save()
{
if (!$this->isInitialized()) {
return PEAR::raiseError('Event not yet initialized');
*
* @return Horde_iCalendar_vevent The vEvent object for this event.
*/
- function &toiCalendar(&$calendar)
+ public function toiCalendar(&$calendar)
{
$vEvent = &Horde_iCalendar::newComponent('vevent', $calendar);
$v1 = $calendar->getAttribute('VERSION') == '1.0';
* @param Horde_iCalendar_vevent $vEvent The iCalendar data to update
* from.
*/
- function fromiCalendar($vEvent)
+ public function fromiCalendar($vEvent)
{
// Unique ID.
$uid = $vEvent->getAttribute('UID');
*
* @param array $hash Array containing all the values.
*/
- function fromHash($hash)
+ public function fromHash($hash)
{
// See if it's a new event.
if ($this->getId() === null) {
*
* @return array Alarm hash or null.
*/
- function toAlarm($time, $user = null, $prefs = null)
+ public function toAlarm($time, $user = null, $prefs = null)
{
if (!$this->getAlarm()) {
return;
*
* @return object A simple object.
*/
- function toJSON()
+ public function toJSON()
{
$json = new stdClass;
$json->t = $this->getTitle();
/**
* TODO
*/
- function isInitialized()
+ public function isInitialized()
{
return $this->initialized;
}
/**
* TODO
*/
- function isStored()
+ public function isStored()
{
return $this->stored;
}
*
* @return boolean True if event exists, false otherwise.
*/
- function exists()
+ public function exists()
{
if (!isset($this->_uid) || !isset($this->_calendar)) {
return false;
}
}
- function getDuration()
+ public function getDuration()
{
static $duration = null;
if (isset($duration)) {
*
* @return boolean True if this is a recurring event.
*/
- function recurs()
+ public function recurs()
{
return isset($this->recurrence) &&
!$this->recurrence->hasRecurType(Horde_Date_Recurrence::RECUR_NONE);
*
* @return string Human readable recurring type.
*/
- function getRecurName()
+ public function getRecurName()
{
return $this->recurs()
? $this->recurrence->getRecurName()
*
* @return string The formatted date and delete link.
*/
- function exceptionLink($date)
+ public function exceptionLink($date)
{
if (!preg_match('/(\d{4})(\d{2})(\d{2})/', $date, $match)) {
return '';
*
* @return string List of exception dates and delete links.
*/
- function exceptionsList()
+ public function exceptionsList()
{
return implode(', ', array_map(array($this, 'exceptionLink'), $this->recurrence->getExceptions()));
}
- function getCalendar()
+ public function getCalendar()
{
return $this->_calendar;
}
- function setCalendar($calendar)
+ public function setCalendar($calendar)
{
$this->_calendar = $calendar;
}
- function isRemote()
+ public function isRemote()
{
return (bool)$this->remoteCal;
}
*
* @return string The local identifier for this event.
*/
- function getId()
+ public function getId()
{
return $this->eventID;
}
*
* @param string $eventId The local identifier for this event.
*/
- function setId($eventId)
+ public function setId($eventId)
{
if (substr($eventId, 0, 10) == 'kronolith:') {
$eventId = substr($eventId, 10);
*
* @return string The global UID for this event.
*/
- function getUID()
+ public function getUID()
{
return $this->_uid;
}
*
* @param string $uid The global UID for this event.
*/
- function setUID($uid)
+ public function setUID($uid)
{
$this->_uid = $uid;
}
*
* @return integer The sequence for this event.
*/
- function getSequence()
+ public function getSequence()
{
return $this->_sequence;
}
*
* @return string The creator id
*/
- function getCreatorId()
+ public function getCreatorId()
{
return !empty($this->creatorID) ? $this->creatorID : Auth::getAuth();
}
*
* @param string $creatorID The user id for the user who created the event
*/
- function setCreatorId($creatorID)
+ public function setCreatorId($creatorID)
{
$this->creatorID = $creatorID;
}
*
* @return string The title of this event.
*/
- function getTitle($user = null)
+ public function getTitle($user = null)
{
if (isset($this->external) ||
isset($this->contactID) ||
*
* @param string The new title for this event.
*/
- function setTitle($title)
+ public function setTitle($title)
{
$this->title = $title;
}
*
* @return string The description of this event.
*/
- function getDescription()
+ public function getDescription()
{
return $this->description;
}
*
* @param string $description The new description for this event.
*/
- function setDescription($description)
+ public function setDescription($description)
{
$this->description = $description;
}
*
* @return string The location of this event.
*/
- function getLocation()
+ public function getLocation()
{
return $this->location;
}
*
* @param string $location The new location for this event.
*/
- function setLocation($location)
+ public function setLocation($location)
{
$this->location = $location;
}
*
* @return boolean Whether this even is private.
*/
- function isPrivate()
+ public function isPrivate()
{
return $this->private;
}
*
* @param boolean $private Whether this event should be marked private.
*/
- function setPrivate($private)
+ public function setPrivate($private)
{
$this->private = !empty($private);
}
*
* @return integer The status of this event.
*/
- function getStatus()
+ public function getStatus()
{
return $this->status;
}
*
* @return boolean True if the events status is the same as $status.
*/
- function hasStatus($status)
+ public function hasStatus($status)
{
return ($status == $this->status);
}
*
* @param integer $status The new event status.
*/
- function setStatus($status)
+ public function setStatus($status)
{
$this->status = $status;
}
*
* @return array A copy of the attendees array.
*/
- function getAttendees()
+ public function getAttendees()
{
return $this->attendees;
}
* @return boolean True if the specified attendee is present for this
* event.
*/
- function hasAttendee($email)
+ public function hasAttendee($email)
{
$email = String::lower($email);
return isset($this->attendees[$email]);
* @param array $attendees The new attendees array. This should be of the
* correct format to avoid driver problems.
*/
- function setAttendees($attendees)
+ public function setAttendees($attendees)
{
$this->attendees = array_change_key_case($attendees);
}
* @param integer $response The response code of the attendee.
* @param string $name The name of the attendee.
*/
- function addAttendee($email, $attendance, $response, $name = null)
+ public function addAttendee($email, $attendance, $response, $name = null)
{
$email = String::lower($email);
if ($attendance == Kronolith::PART_IGNORE) {
*
* @param string $email The email address of the attendee.
*/
- function removeAttendee($email)
+ public function removeAttendee($email)
{
$email = String::lower($email);
if (isset($this->attendees[$email])) {
}
}
- function isAllDay()
+ public function isAllDay()
{
return $this->allday ||
($this->start->hour == 0 && $this->start->min == 0 && $this->start->sec == 0 &&
$this->end->year > $this->start->year));
}
- function getAlarm()
+ public function getAlarm()
{
return $this->alarm;
}
- function setAlarm($alarm)
+ public function setAlarm($alarm)
{
$this->alarm = $alarm;
}
- function readForm()
+ public function readForm()
{
global $prefs, $cManager;
$this->initialized = true;
}
- function html($property)
+ public function html($property)
{
global $prefs;
'</select>';
}
- function js($property)
+ public function js($property)
{
switch ($property) {
case 'start[month]':
*
* @return string
*/
- function getViewUrl($params = array(), $full = false)
+ public function getViewUrl($params = array(), $full = false)
{
$params['eventID'] = $this->eventID;
if ($this->remoteUrl) {
*
* @return string
*/
- function getEditUrl($params = array())
+ public function getEditUrl($params = array())
{
$params['view'] = 'EditEvent';
$params['eventID'] = $this->eventID;
*
* @return string
*/
- function getDeleteUrl($params = array())
+ public function getDeleteUrl($params = array())
{
$params['view'] = 'DeleteEvent';
$params['eventID'] = $this->eventID;
*
* @return string
*/
- function getExportUrl($params = array())
+ public function getExportUrl($params = array())
{
$params['view'] = 'ExportEvent';
$params['eventID'] = $this->eventID;
return Horde::applicationUrl(Util::addParameter('event.php', $params));
}
- function getLink($datetime = null, $icons = true, $from_url = null, $full = false)
+ public function getLink($datetime = null, $icons = true, $from_url = null, $full = false)
{
global $prefs, $registry;
*
* @return string A CSS string with color definitions.
*/
- function getCSSColors($with_attribute = true)
+ public function getCSSColors($with_attribute = true)
{
$css = 'background-color:' . $this->_backgroundColor . ';color:' . $this->_foregroundColor;
if ($with_attribute) {
/**
* @return string A tooltip for quick descriptions of this event.
*/
- function getTooltip()
+ public function getTooltip()
{
$tooltip = $this->getTimeRange()
. "\n" . sprintf(_("Owner: %s"), ($this->getCreatorId() == Auth::getAuth() ?
* @return string The time range of the event ("All Day", "1:00pm-3:00pm",
* "08:00-22:00").
*/
- function getTimeRange()
+ public function getTimeRange()
{
if ($this->isAllDay()) {
return _("All day");
/**
* @return string The CSS class for the event based on its status.
*/
- function getStatusClass()
+ public function getStatusClass()
{
switch ($this->status) {
case Kronolith::STATUS_CANCELLED:
return 'event';
}
- function _formIDEncode($id)
+ private function _formIDEncode($id)
{
return str_replace(array('[', ']'),
array('_', ''),
* @package Kronolith
*/
-class Kronolith_Driver_holidays extends Kronolith_Driver {
+class Kronolith_Driver_holidays extends Kronolith_Driver
+{
- function listAlarms($date, $fullevent = false)
+ public function listAlarms($date, $fullevent = false)
{
return array();
}
*
* @return array An array of all holidays within the given datespan.
*/
- function listEvents($startDate = null, $endDate = null, $hasAlarm = false)
+ public function listEvents($startDate = null, $endDate = null, $hasAlarm = false)
{
global $language;
return $events;
}
- function _getEvents($dh, $startDate, $endDate)
+ private function _getEvents($dh, $startDate, $endDate)
{
$events = array();
for ($date = new Horde_Date($startDate);
return $events;
}
- function &getEvent($eventId = null)
- {
- return false;
- }
-
- /**
- * Get an event or events with the given UID value.
- *
- * @param string $uid The UID to match
- * @param array $calendars A restricted array of calendar ids to search
- * @param boolean $getAll Return all matching events? If this is false,
- * an error will be returned if more than one event is found.
- *
- * @return Kronolith_Event
- */
- function &getByUID($uid, $calendars = null, $getAll = false)
- {
- return PEAR::raiseError('Not supported');
- }
-
- function exists()
- {
- return PEAR::raiseError('Not supported');
- }
-
- function saveEvent($event)
- {
- return PEAR::raiseError('Not supported');
- }
-
- /**
- * Moves an event to a new calendar.
- *
- * @param string $eventId The event to move.
- * @param string $newCalendar The new calendar.
- */
- function move($eventId, $newCalendar)
- {
- return PEAR::raiseError('Not supported');
- }
-
- /**
- * Deletes a calendar and all its events.
- *
- * @param string $calendar The name of the calendar to delete.
- *
- * @return mixed True or a PEAR_Error on failure.
- */
- function delete($calendar)
- {
- return PEAR::raiseError('Not supported');
- }
-
- /**
- * Deletes an event.
- *
- * @param string $eventId The ID of the event to delete.
- *
- * @return mixed True or a PEAR_Error on failure.
- */
- function deleteEvent($eventId)
- {
- return PEAR::raiseError('Not supported');
- }
-
- function _getTranslationFile($driver)
+ private function _getTranslationFile($driver)
{
static $data_dir;
if (!isset($data_dir)) {
}
-class Kronolith_Event_holidays extends Kronolith_Event {
-
+class Kronolith_Event_holidays extends Kronolith_Event
+{
/**
* The status of this event.
*
* @var integer
*/
- var $status = Kronolith::STATUS_FREE;
+ public $status = Kronolith::STATUS_FREE;
/**
* Whether this is an all-day event.
*
* @var boolean
*/
- var $allday = true;
+ public $allday = true;
/**
* Parse in an event from the driver.
* @param Date_Holidays_Holiday $dhEvent A holiday returned
* from the driver
*/
- function fromDriver($dhEvent)
+ public function fromDriver($dhEvent)
{
$this->stored = true;
$this->initialized = true;
*
* @return string The title of this event
*/
- function getTitle()
+ public function getTitle()
{
return $this->title;
}
*
* @return boolean <code>true</code>
*/
- function isAllDay()
+ public function isAllDay()
{
return true;
}
<?php
-
-require_once 'Horde/iCalendar.php';
-
/**
* The Kronolith_Driver_ical:: class implements the Kronolith_Driver
* API for iCalendar data.
* @author Jan Schneider <jan@horde.org>
* @package Kronolith
*/
-class Kronolith_Driver_ical extends Kronolith_Driver {
-
+class Kronolith_Driver_ical extends Kronolith_Driver
+{
/**
* Cache events as we fetch them to avoid fetching or parsing the same
* event twice.
*
* @var array
*/
- var $_cache = array();
+ private $_cache = array();
- function listAlarms($date, $fullevent = false)
+ public function listAlarms($date, $fullevent = false)
{
return array();
}
*
* @return array Events in the given time range.
*/
- function listEvents($startDate = null, $endDate = null, $hasAlarm = false)
+ public function listEvents($startDate = null, $endDate = null,
+ $hasAlarm = false)
{
$data = $this->_getRemoteCalendar();
if (is_a($data, 'PEAR_Error')) {
return $events;
}
- function getEvent($eventId = null)
+ public function getEvent($eventId = null)
{
$data = $this->_getRemoteCalendar();
if (is_a($data, 'PEAR_Error')) {
$event = new Kronolith_Event_ical($this);
$event->status = Kronolith::STATUS_FREE;
$event->fromiCalendar($components[$eventId]);
- $event->remoteCal = $url;
+ $event->remoteCal = $this->_params['url'];
$event->eventID = $eventId;
return $event;
}
/**
- * Get an event or events with the given UID value.
- *
- * @param string $uid The UID to match
- * @param array $calendars A restricted array of calendar ids to search
- * @param boolean $getAll Return all matching events? If this is false,
- * an error will be returned if more than one event is found.
- *
- * @return Kronolith_Event
- */
- function &getByUID($uid, $calendars = null, $getAll = false)
- {
- return PEAR::raiseError('Not supported');
- }
-
- function exists()
- {
- return PEAR::raiseError('Not supported');
- }
-
- function saveEvent($event)
- {
- return PEAR::raiseError('Not supported');
- }
-
- /**
- * Move an event to a new calendar.
- *
- * @param string $eventId The event to move.
- * @param string $newCalendar The new calendar.
- */
- function move($eventId, $newCalendar)
- {
- return PEAR::raiseError('Not supported');
- }
-
- /**
- * Delete a calendar and all its events.
- *
- * @param string $calendar The name of the calendar to delete.
- *
- * @return mixed True or a PEAR_Error on failure.
- */
- function delete($calendar)
- {
- return PEAR::raiseError('Not supported');
- }
-
- /**
- * Delete an event.
- *
- * @param string $eventId The ID of the event to delete.
- *
- * @return mixed True or a PEAR_Error on failure.
- */
- function deleteEvent($eventId)
- {
- return PEAR::raiseError('Not supported');
- }
-
- /**
* Fetches a remote calendar into the session and return the data.
*
* @return mixed Either the calendar data, or an error on failure.
}
-class Kronolith_Event_ical extends Kronolith_Event {
+class Kronolith_Event_ical extends Kronolith_Event
+{
- function fromDriver($vEvent)
+ public function fromDriver($vEvent)
{
$this->fromiCalendar($vEvent);
$this->initialized = true;
$this->stored = true;
}
- function toDriver()
+ public function toDriver()
{
return $this->toiCalendar();
}
* @author Stuart Binge <omicron@mighty.co.za>
* @package Kronolith
*/
-class Kronolith_Driver_kolab extends Kronolith_Driver {
-
+class Kronolith_Driver_kolab extends Kronolith_Driver
+{
/**
* Our Kolab server connection.
*
* @var Kolab
*/
- var $_kolab = null;
+ private $_kolab = null;
/**
* The wrapper to decide between the Kolab implementation
*
* @var Kronolith_Driver_kolab_wrapper
*/
- var $_wrapper = null;
+ private $_wrapper = null;
/**
* Attempts to open a Kolab Groupware folder.
*
* @return boolean True on success, PEAR_Error on failure.
*/
- function initialize()
+ public function initialize()
{
$this->_kolab = new Kolab();
if (empty($this->_kolab->version)) {
/**
* Change current calendar
*/
- function open($calendar)
+ public function open($calendar)
{
if ($this->_calendar != $calendar) {
$this->_calendar = $calendar;
return true;
}
- function listAlarms($date, $fullevent = false)
+ public function listAlarms($date, $fullevent = false)
{
return $this->_wrapper->listAlarms($date, $fullevent);
}
*
* @return mixed Returns a string with event_id or false if not found.
*/
- function exists($uid, $calendar_id = null)
+ public function exists($uid, $calendar_id = null)
{
return $this->_wrapper->exists($uid, $calendar_id);
}
*
* @return array Events in the given time range.
*/
- function listEvents($startDate = null, $endDate = null, $hasAlarm = false)
+ public function listEvents($startDate = null, $endDate = null, $hasAlarm = false)
{
return $this->_wrapper->listEvents($startDate, $endDate, $hasAlarm);
}
- function getEvent($eventID = null)
+ public function getEvent($eventID = null)
{
return $this->_wrapper->getEvent($eventID);
}
*
* @return Kronolith_Event
*/
- function getByUID($uid, $calendars = null, $getAll = false)
+ public function getByUID($uid, $calendars = null, $getAll = false)
{
return $this->_wrapper->getByUID($uid, $calendars, $getAll);
}
- function saveEvent(&$event)
+ public function saveEvent(&$event)
{
return $this->_wrapper->saveEvent($event);
}
* @param string $eventId The event to move.
* @param string $newCalendar The new calendar.
*/
- function move($eventID, $newCalendar)
+ public function move($eventID, $newCalendar)
{
return $this->_wrapper->move($eventID, $newCalendar);
}
*
* @return mixed True or a PEAR_Error on failure.
*/
- function delete($calendar)
+ public function delete($calendar)
{
return $this->_wrapper->delete($calendar);
}
*
* @return mixed True or a PEAR_Error on failure.
*/
- function rename($from, $to)
+ public function rename($from, $to)
{
return $this->_wrapper->rename($from, $to);
}
*
* @return mixed True or a PEAR_Error on failure.
*/
- function deleteEvent($eventID, $silent = false)
+ public function deleteEvent($eventID, $silent = false)
{
return $this->_wrapper->deleteEvent($eventID, $silent);
}
}
/**
- * Horde Kronolith wrapper to distinguish between both Kolab driver implementations.
+ * Horde Kronolith wrapper to distinguish between both Kolab driver
+ * implementations.
*
* $Horde: kronolith/lib/Driver/kolab.php,v 1.77 2009/01/06 18:01:01 jan Exp $
*
* @author Gunnar Wrobel <wrobel@pardus.de>
* @package Kronolith
*/
-
-class Kronolith_Driver_kolab_wrapper {
+class Kronolith_Driver_kolab_wrapper
+{
/**
* Our Kolab server connection.
*
* @var Kolab
*/
- var $_kolab = null;
+ private $_kolab = null;
/**
* Link to the parent driver object
* @var Kronolith_Driver
*/
- var $_driver = null;
+ private $_driver = null;
/**
* Constructor
*
* @param Kronolith_driver $driver Reference to the Kronolith_Driver
*/
- function Kronolith_Driver_kolab_wrapper(&$driver)
+ public function __contruct(&$driver)
{
$this->_driver = $driver;
$this->_kolab = $driver->_kolab;
}
+
}
* @author Stuart Binge <omicron@mighty.co.za>
* @package Kronolith
*/
-class Kronolith_Driver_kolab_wrapper_old extends Kronolith_Driver_kolab_wrapper {
-
+class Kronolith_Driver_kolab_wrapper_old extends Kronolith_Driver_kolab_wrapper
+{
/**
* Indicates if the wrapper has connected or not
*
* @var boolean
*/
- var $_connected = false;
+ private $_connected = false;
/**
* Reset internal variable on share change
*/
- function reset()
+ public function reset()
{
$this->_connected = false;
}
*
* @return mixed True on success, a PEAR error otherwise
*/
- function connect()
+ public function connect()
{
if ($this->_connected) {
return true;
return true;
}
- function listAlarms($date, $fullevent = false)
+ public function listAlarms($date, $fullevent = false)
{
if (!$this->_kolab) {
return array();
*
* @return mixed Returns a string with event_id or false if not found.
*/
- function exists($uid, $calendar_id = null)
+ public function exists($uid, $calendar_id = null)
{
$this->connect();
*
* @return array Events in the given time range.
*/
- function listEvents($startDate = null, $endDate = null, $hasAlarm = false)
+ public function listEvents($startDate = null, $endDate = null, $hasAlarm = false)
{
$this->connect();
return $events;
}
- function getEvent($eventID = null)
+ public function getEvent($eventID = null)
{
if (is_null($eventID)) {
return new Kronolith_Event_kolab_old($this->_driver);
*
* @return Kronolith_Event
*/
- function getByUID($uid, $calendars = null, $getAll = false)
+ public function getByUID($uid, $calendars = null, $getAll = false)
{
if (!is_array($calendars)) {
$calendars = array_keys(Kronolith::listCalendars(true, PERMS_READ));
return PEAR::raiseError(sprintf(_("Event not found: %s"), $uid));
}
- function saveEvent(&$event)
+ public function saveEvent(&$event)
{
$this->connect();
* @param string $eventId The event to move.
* @param string $newCalendar The new calendar.
*/
- function move($eventID, $newCalendar)
+ public function move($eventID, $newCalendar)
{
$this->connect();
*
* @return mixed True or a PEAR_Error on failure.
*/
- function delete($calendar)
+ public function delete($calendar)
{
// For the old code we don't care
return true;
*
* @return mixed True or a PEAR_Error on failure.
*/
- function rename($from, $to)
+ public function rename($from, $to)
{
// For the old code we don't care
return true;
*
* @return mixed True or a PEAR_Error on failure.
*/
- function deleteEvent($eventID, $silent = false)
+ public function deleteEvent($eventID, $silent = false)
{
$this->connect();
}
-class Kronolith_Event_kolab_old extends Kronolith_Event {
+class Kronolith_Event_kolab_old extends Kronolith_Event
+{
- function fromDriver($dummy)
+ public function fromDriver($dummy)
{
$driver = $this->getDriver();
$kolab = $driver->_kolab;
$this->stored = true;
}
- function toDriver()
+ public function toDriver()
{
}
/**
* Horde Kronolith driver for the Kolab IMAP Server.
+ *
* Copyright 2004-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (ASL). If you
* @author Stuart Binge <omicron@mighty.co.za>
* @package Kronolith
*/
-class Kronolith_Driver_kolab_wrapper_new extends Kronolith_Driver_kolab_wrapper {
-
+class Kronolith_Driver_kolab_wrapper_new extends Kronolith_Driver_kolab_wrapper
+{
/**
* Internal cache of Kronolith_Event_kolab_new. eventID/UID is key
*
* @var array
*/
- var $_events_cache;
+ private $_events_cache;
/**
* Indicates if we have synchronized this folder
*
* @var boolean
*/
- var $_synchronized;
+ private $_synchronized;
/**
* Shortcut to the imap connection
*
* @var Kolab_IMAP
*/
- var $_store;
+ private $_store;
/**
* Constructor
*/
- function Kronolith_Driver_kolab_wrapper_new(&$driver)
+ public function __construct($driver)
{
parent::Kronolith_Driver_kolab_wrapper($driver);
$this->reset();
/**
* Reset internal variable on share change
*/
- function reset()
+ public function reset()
{
$this->_events_cache = array();
$this->_synchronized = false;
// We delay initial synchronization to the first use
// so multiple calendars don't add to the total latency.
// This function must be called before all internal driver functions
- function synchronize($force = false)
+ public function synchronize($force = false)
{
if ($this->_synchronized && !$force) {
return;
$this->_synchronized = true;
}
- function listAlarms($date, $fullevent = false)
+ public function listAlarms($date, $fullevent = false)
{
$allevents = $this->listEvents($date, null, true);
$events = array();
* @return string|boolean Returns a string with event_id or false if
* not found.
*/
- function exists($uid, $calendar_id = null)
+ public function exists($uid, $calendar_id = null)
{
// Log error if someone uses this function in an unsupported way
if ($calendar_id != $this->_driver->_calendar) {
*
* @return array Events in the given time range.
*/
- function listEvents($startDate = null, $endDate = null, $hasAlarm = false)
+ public function listEvents($startDate = null, $endDate = null, $hasAlarm = false)
{
$result = $this->synchronize();
if (is_a($result, 'PEAR_Error')) {
return $ids;
}
- function getEvent($eventId = null)
+ public function getEvent($eventId = null)
{
if (is_null($eventId)) {
return new Kronolith_Event_kolab_new($this->_driver);
*
* @return Kronolith_Event
*/
- function getByUID($uid, $calendars = null, $getAll = false)
+ public function getByUID($uid, $calendars = null, $getAll = false)
{
if (!is_array($calendars)) {
$calendars = array_keys(Kronolith::listCalendars(true, PERMS_READ));
*
* @return mixed UID on success, a PEAR error otherwise
*/
- function saveEvent(&$event)
+ public function saveEvent(&$event)
{
$result = $this->synchronize();
if (is_a($result, 'PEAR_Error')) {
* @param string $eventId The event to move.
* @param string $newCalendar The new calendar.
*/
- function move($eventId, $newCalendar)
+ public function move($eventId, $newCalendar)
{
$event = $this->getEvent($eventId);
*
* @return mixed True or a PEAR_Error on failure.
*/
- function delete($calendar)
+ public function delete($calendar)
{
$this->_driver->open($calendar);
$result = $this->synchronize();
*
* @return mixed True or a PEAR_Error on failure.
*/
- function rename($from, $to)
+ public function rename($from, $to)
{
// FIXME: We can't do much here. We'd need to be called after
// renaming the share here. This needs to be checked again.
*
* @return mixed True or a PEAR_Error on failure.
*/
- function deleteEvent($eventId, $silent = false)
+ public function deleteEvent($eventId, $silent = false)
{
$result = $this->synchronize();
if (is_a($result, 'PEAR_Error')) {
/**
* @package Kronolith
*/
-class Kronolith_Event_kolab_new extends Kronolith_Event {
+class Kronolith_Event_kolab_new extends Kronolith_Event
+{
- function fromDriver($event)
+ public function fromDriver($event)
{
$this->eventID = $event['uid'];
$this->setUID($this->eventID);
$this->stored = true;
}
- function toDriver()
+ public function toDriver()
{
$event = array();
$event['uid'] = $this->getUID();
return $event;
}
+
}
<?php
/**
- * The Kronolith_Driver_sql:: class implements the Kronolith_Driver
- * API for a SQL backend.
+ * The Kronolith_Driver_sql:: class implements the Kronolith_Driver API for a
+ * SQL backend.
*
* @author Luc Saillard <luc.saillard@fr.alcove.com>
* @author Chuck Hagenbuch <chuck@horde.org>
+ * @author Jan Schneider <jan@horde.org>
* @package Kronolith
*/
-class Kronolith_Driver_sql extends Kronolith_Driver {
-
+class Kronolith_Driver_sql extends Kronolith_Driver
+{
/**
* The object handle for the current database connection.
*
* @var DB
*/
- var $_db;
+ private $_db;
/**
* Handle for the current database connection, used for writing. Defaults
*
* @var DB
*/
- var $_write_db;
+ private $_write_db;
/**
* Cache events as we fetch them to avoid fetching the same event from the
*
* @var array
*/
- var $_cache = array();
+ private $_cache = array();
- function listAlarms($date, $fullevent = false)
+ public function listAlarms($date, $fullevent = false)
{
require_once 'Date/Calc.php';
return is_array($events) ? $events : array();
}
- function search($query)
+ public function search($query)
{
require_once 'Horde/SQL.php';
* @return string|boolean Returns a string with event_id or false if
* not found.
*/
- function exists($uid, $calendar_id = null)
+ public function exists($uid, $calendar_id = null)
{
$query = 'SELECT event_id FROM ' . $this->_params['table'] . ' WHERE event_uid = ?';
$values = array($uid);
*
* @return array Events in the given time range.
*/
- function listEvents($startDate = null, $endDate = null, $hasAlarm = false)
+ public function listEvents($startDate = null, $endDate = null,
+ $hasAlarm = false)
{
if (empty($endDate)) {
$endInterval = new Horde_Date(array('mday' => 31, 'month' => 12,
* @return array Events in the given time range satisfying the given
* conditions.
*/
- function listEventsConditional($startInterval, $endInterval,
- $conditions = '', $vals = array())
+ public function listEventsConditional($startInterval, $endInterval,
+ $conditions = '', $vals = array())
{
$q = 'SELECT event_id, event_uid, event_description, event_location,' .
' event_private, event_status, event_attendees,' .
return $events;
}
- function getEvent($eventId = null)
+ public function getEvent($eventId = null)
{
if (is_null($eventId)) {
return new Kronolith_Event_sql($this);
*
* @return Kronolith_Event
*/
- function getByUID($uid, $calendars = null, $getAll = false)
+ public function getByUID($uid, $calendars = null, $getAll = false)
{
$query = 'SELECT event_id, event_uid, calendar_id, event_description,' .
' event_location, event_private, event_status, event_attendees,' .
*
* @param Kronolith_Event $event The event to save.
*/
- function saveEvent(&$event)
+ public function saveEvent($event)
{
if ($event->isStored() || $event->exists()) {
$values = array();
* @param string $eventId The event to move.
* @param string $newCalendar The new calendar.
*/
- function move($eventId, $newCalendar)
+ public function move($eventId, $newCalendar)
{
/* Fetch the event for later use. */
$event = $this->getEvent($eventId);
*
* @return mixed True or a PEAR_Error on failure.
*/
- function delete($calendar)
+ public function delete($calendar)
{
$query = 'DELETE FROM ' . $this->_params['table'] . ' WHERE calendar_id = ?';
$values = array($calendar);
*
* @return mixed True or a PEAR_Error on failure.
*/
- function deleteEvent($eventId, $silent = false)
+ public function deleteEvent($eventId, $silent = false)
{
/* Fetch the event for later use. */
$event = $this->getEvent($eventId);
*
* @return boolean True.
*/
- function initialize()
+ public function initialize()
{
Horde::assertDriverConfig($this->_params, 'calendar',
array('phptype'));
/**
*/
- function _initConn(&$db)
+ private function _initConn(&$db)
{
// Set DB portability options.
switch ($db->phptype) {
*
* @return mixed The converted value.
*/
- function convertFromDriver($value)
+ public function convertFromDriver($value)
{
return String::convertCharset($value, $this->_params['charset']);
}
*
* @return mixed The converted value.
*/
- function convertToDriver($value)
+ public function convertToDriver($value)
{
return String::convertCharset($value, NLS::getCharset(), $this->_params['charset']);
}
*
* @param mixed True | PEAR_Error
*/
- function removeUserData($user)
+ public function removeUserData($user)
{
if (!Auth::isAdmin()) {
return PEAR::raiseError(_("Permission Denied"));
/**
* @package Kronolith
*/
-class Kronolith_Event_sql extends Kronolith_Event {
-
+class Kronolith_Event_sql extends Kronolith_Event
+{
/**
* @var array
*/
- var $_properties = array();
+ private $_properties = array();
- function fromDriver($SQLEvent)
+ public function fromDriver($SQLEvent)
{
$driver = $this->getDriver();
$this->stored = true;
}
- function toDriver()
+ public function toDriver()
{
$driver = $this->getDriver();
}
}
- function getProperties()
+ public function getProperties()
{
return $this->_properties;
}