From: Michael J. Rubinsky Date: Wed, 26 Jan 2011 18:57:50 +0000 (-0500) Subject: Remaining PHP5 code changes, Horde 4 style for kronolith X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=87af97050871689bc86c162bc8886f92e8422172;p=horde.git Remaining PHP5 code changes, Horde 4 style for kronolith --- diff --git a/kronolith/lib/Day.php b/kronolith/lib/Day.php index c9ddda205..a918272d7 100644 --- a/kronolith/lib/Day.php +++ b/kronolith/lib/Day.php @@ -5,15 +5,15 @@ * @author Chuck Hagenbuch * @package Kronolith */ -class Kronolith_Day extends Horde_Date { - +class Kronolith_Day extends Horde_Date +{ /** * How many time slots are we dividing each hour into? Set from user * preferences. * * @var integer */ - var $_slotsPerHour; + public $slotsPerHour; /** * How many slots do we have per day? Calculated from $_slotsPerHour. @@ -21,7 +21,7 @@ class Kronolith_Day extends Horde_Date { * @see $_slotsPerHour * @var integer */ - var $_slotsPerDay; + public $slotsPerDay; /** * How many minutes are in each slot? Calculated from $_slotsPerHour. @@ -29,14 +29,14 @@ class Kronolith_Day extends Horde_Date { * @see $_slotsPerHour * @var integer */ - var $_slotLength; + public $slotLength; /** * Array of slots holding hours and minutes for each piece of this day. * * @var array */ - var $slots = array(); + public $slots = array(); /** * Constructor. @@ -45,7 +45,7 @@ class Kronolith_Day extends Horde_Date { * @param integer $day * @param integer $year */ - function Kronolith_Day($month = null, $day = null, $year = null) + public function __construct($month = null, $day = null, $year = null) { if (is_null($month)) { $month = date('n'); @@ -58,21 +58,21 @@ class Kronolith_Day extends Horde_Date { } parent::__construct(array('year' => $year, 'month' => $month, 'mday' => $day)); - $this->_slotsPerHour = $GLOBALS['prefs']->getValue('slots_per_hour'); - if (!$this->_slotsPerHour) { - $this->_slotsPerHour = 1; + $this->slotsPerHour = $GLOBALS['prefs']->getValue('slots_per_hour'); + if (!$this->slotsPerHour) { + $this->slotsPerHour = 1; } - $this->_slotsPerDay = $this->_slotsPerHour * 24; - $this->_slotLength = 60 / $this->_slotsPerHour; + $this->slotsPerDay = $this->slotsPerHour * 24; + $this->slotLength = 60 / $this->slotsPerHour; - for ($i = 0; $i < $this->_slotsPerDay; $i++) { - $minutes = $i * $this->_slotLength; + for ($i = 0; $i < $this->slotsPerDay; $i++) { + $minutes = $i * $this->slotLength; $this->slots[$i]['hour'] = (int)($minutes / 60); $this->slots[$i]['min'] = $minutes % 60; } } - function getTime($format, $offset = 0) + public function getTime($format, $offset = 0) { $date = new Horde_Date(array('month' => $this->month, 'mday' => $this->mday + $offset, @@ -80,7 +80,7 @@ class Kronolith_Day extends Horde_Date { return $date->strftime($format); } - function getTomorrow() + public function getTomorrow() { $date = new Horde_Date(array('month' => $this->month, 'mday' => $this->mday + 1, @@ -88,7 +88,7 @@ class Kronolith_Day extends Horde_Date { return $date; } - function getYesterday() + public function getYesterday() { $date = new Horde_Date(array('month' => $this->month, 'mday' => $this->mday - 1, @@ -96,12 +96,12 @@ class Kronolith_Day extends Horde_Date { return $date; } - function isToday() + public function isToday() { return $this->compareDate(new Horde_Date(mktime(0, 0, 0))) == 0; } - function isTomorrow() + public function isTomorrow() { $date = new Horde_Date(array('month' => $this->month, 'mday' => $this->mday - 1, @@ -109,7 +109,7 @@ class Kronolith_Day extends Horde_Date { return $date->compareDate(new Horde_Date(mktime(0, 0, 0))) == 0; } - function diff() + public function diff() { $day2 = new Kronolith_Day(); return Date_Calc::dateDiff($this->mday, $this->month, $this->year, diff --git a/kronolith/lib/Driver.php b/kronolith/lib/Driver.php index 3773e5917..18cc74403 100644 --- a/kronolith/lib/Driver.php +++ b/kronolith/lib/Driver.php @@ -55,9 +55,10 @@ class Kronolith_Driver * Just stores the $params in our newly-created object. All other work is * done by {@link initialize()}. * - * @param array $params Any parameters needed for this driver. + * @param array $params Any parameters needed for this driver. + * @param string $errormsg A custom error message to use. */ - public function __construct($params = array(), $errormsg = null) + public function __construct(array $params = array(), $errormsg = null) { $this->_params = $params; if ($errormsg === null) { diff --git a/kronolith/lib/Storage/Kolab.php b/kronolith/lib/Storage/Kolab.php index bba2be442..fa8b9cb59 100644 --- a/kronolith/lib/Storage/Kolab.php +++ b/kronolith/lib/Storage/Kolab.php @@ -13,7 +13,7 @@ class Kronolith_Storage_Kolab extends Kronolith_Storage { protected $_params = array(); - function __construct($user, $params = array()) + public function __construct($user, array $params = array()) { $this->_user = $user; $this->_params = $params; diff --git a/kronolith/lib/Storage/Sql.php b/kronolith/lib/Storage/Sql.php index 48e4340d7..2989c213c 100644 --- a/kronolith/lib/Storage/Sql.php +++ b/kronolith/lib/Storage/Sql.php @@ -25,9 +25,12 @@ class Kronolith_Storage_Sql extends Kronolith_Storage /** * Constructs a new Kronolith_Storage SQL instance. * + * @param string $user The user the fb info belongs to. * @param array $params A hash containing connection parameters. + * + * @return Kronolith_Storage_Sql */ - public function __construct($user, $params = array()) + public function __construct($user, array $params = array()) { $this->_user = $user; if (empty($params['db'])) { diff --git a/kronolith/lib/View/Day.php b/kronolith/lib/View/Day.php index 6794904c3..aa6759104 100644 --- a/kronolith/lib/View/Day.php +++ b/kronolith/lib/View/Day.php @@ -6,31 +6,38 @@ * @author Jan Schneider * @package Kronolith */ -class Kronolith_View_Day extends Kronolith_Day { - - var $_events = array(); - var $_all_day_events = array(); - var $_all_day_rowspan = array(); - var $_all_day_maxrowspan = 0; - var $_event_matrix = array(); - var $_parsed = false; - var $_span = array(); - var $_totalspan = 0; - var $_sidebyside = false; - var $_currentCalendars = array(); - var $_first; - var $_last; - - function Kronolith_View_Day($date, $events = null) +class Kronolith_View_Day extends Kronolith_Day +{ + public $all_day_events = array(); + public $all_day_rowspan = array(); + public $all_day_maxrowspan = 0; + public $span = array(); + public $totalspan = 0; + public $sidebyside = false; + protected $_events = array(); + protected $_event_matrix = array(); + protected $_parsed = false; + protected $_currentCalendars = array(); + protected $_first; + protected $_last; + + /** + * + * @param Horde_Date $date The day for this view + * @param array $events An array of Kronolith_Event objects + * + * @return Kronolith_View_Day + */ + public function __construct(Horde_Date $date, array $events = null) { - parent::Kronolith_Day($date->month, $date->mday, $date->year); + parent::__construct($date->month, $date->mday, $date->year); - $this->_sidebyside = $GLOBALS['prefs']->getValue('show_shared_side_by_side'); - if ($this->_sidebyside) { + $this->sidebyside = $GLOBALS['prefs']->getValue('show_shared_side_by_side'); + if ($this->sidebyside) { $allCalendars = Kronolith::listInternalCalendars(); foreach ($GLOBALS['display_calendars'] as $cid) { $this->_currentCalendars[$cid] = $allCalendars[$cid]; - $this->_all_day_events[$cid] = array(); + $this->all_day_events[$cid] = array(); } } else { $this->_currentCalendars = array(0); @@ -57,12 +64,17 @@ class Kronolith_View_Day extends Kronolith_Day { } } - function setEvents($events) + /** + * Setter for events array + * + * @param array $events + */ + public function setEvents(array $events) { $this->_events = $events; } - function html() + public function html() { global $prefs; @@ -79,7 +91,7 @@ class Kronolith_View_Day extends Kronolith_Day { $showTime = Kronolith::viewShowTime(); require KRONOLITH_TEMPLATES . '/day/head.inc'; - if ($this->_sidebyside) { + if ($this->sidebyside) { require KRONOLITH_TEMPLATES . '/day/head_side_by_side.inc'; } echo ''; @@ -107,22 +119,22 @@ class Kronolith_View_Day extends Kronolith_Day { * with no rowspan. We put in a rowspan in the row after the last * event to fill all remaining rows. */ $row = ''; - $rowspan = ($this->_all_day_maxrowspan) ? ' rowspan="' . $this->_all_day_maxrowspan . '"' : ''; - for ($k = 0; $k < $this->_all_day_maxrowspan; ++$k) { + $rowspan = ($this->all_day_maxrowspan) ? ' rowspan="' . $this->all_day_maxrowspan . '"' : ''; + for ($k = 0; $k < $this->all_day_maxrowspan; ++$k) { $row = ''; foreach (array_keys($this->_currentCalendars) as $cid) { - if (count($this->_all_day_events[$cid]) === $k) { + if (count($this->all_day_events[$cid]) === $k) { // There are no events or all events for this calendar // have already been printed. - $row .= ' '; - } elseif (count($this->_all_day_events[$cid]) > $k) { + $row .= ' '; + } elseif (count($this->all_day_events[$cid]) > $k) { // We have not printed every all day event yet. Put one // into this row. - $event = $this->_all_day_events[$cid][$k]; + $event = $this->all_day_events[$cid][$k]; $row .= 'getCSSColors() . 'width="' . round(90 / count($this->_currentCalendars)) . '%" ' - . 'valign="top" colspan="' . $this->_span[$cid] . '">' + . 'valign="top" colspan="' . $this->span[$cid] . '">' . $event->getLink($this, true, $this->link(0, true)); if ($showLocation) { $row .= '
' . htmlspecialchars($event->location) . '
'; @@ -135,17 +147,17 @@ class Kronolith_View_Day extends Kronolith_Day { } if ($first_row) { - $row .= ' '; + $row .= ' '; require KRONOLITH_TEMPLATES . '/day/all_day.inc'; } $day_hour_force = $prefs->getValue('day_hour_force'); - $day_hour_start = $prefs->getValue('day_hour_start') / 2 * $this->_slotsPerHour; - $day_hour_end = $prefs->getValue('day_hour_end') / 2 * $this->_slotsPerHour; + $day_hour_start = $prefs->getValue('day_hour_start') / 2 * $this->slotsPerHour; + $day_hour_end = $prefs->getValue('day_hour_end') / 2 * $this->slotsPerHour; $rows = array(); $covered = array(); - for ($i = 0; $i < $this->_slotsPerDay; ++$i) { + for ($i = 0; $i < $this->slotsPerDay; ++$i) { if ($i >= $day_hour_end && $i > $this->_last) { break; } @@ -154,8 +166,8 @@ class Kronolith_View_Day extends Kronolith_Day { } $row = ''; - if (($m = $i % $this->_slotsPerHour) != 0) { - $time = ':' . $m * $this->_slotLength; + if (($m = $i % $this->slotsPerHour) != 0) { + $time = ':' . $m * $this->slotLength; $hourclass = 'halfhour'; } else { $time = Kronolith_View_Day::prefHourFormat($this->slots[$i]['hour']); @@ -175,7 +187,7 @@ class Kronolith_View_Day extends Kronolith_Day { // factor of the total span, we get this event's // individual span by dividing the total span by this // event's overlap. - $span = $this->_span[$cid] / $event->overlap; + $span = $this->span[$cid] / $event->overlap; // Store the indent we're starting this event at // for future use. @@ -208,13 +220,13 @@ class Kronolith_View_Day extends Kronolith_Day { $hspan += $span; $start = new Horde_Date(array( - 'hour' => floor($i / $this->_slotsPerHour), - 'min' => ($i % $this->_slotsPerHour) * $this->_slotLength, + 'hour' => floor($i / $this->slotsPerHour), + 'min' => ($i % $this->slotsPerHour) * $this->slotLength, 'month' => $this->month, 'mday' => $this->mday, 'year' => $this->year)); $end_slot = new Horde_Date($start); - $end_slot->min += $this->_slotLength; + $end_slot->min += $this->slotLength; if (((!$day_hour_force || $i >= $day_hour_start) && $event->start->compareDateTime($start) >= 0 && $event->start->compareDateTime($end_slot) < 0 || @@ -233,7 +245,7 @@ class Kronolith_View_Day extends Kronolith_Day { $row .= 'getCSSColors() - . 'width="' . round((90 / count($this->_currentCalendars)) * ($span / $this->_span[$cid])) . '%" ' + . 'width="' . round((90 / count($this->_currentCalendars)) * ($span / $this->span[$cid])) . '%" ' . 'valign="top" colspan="' . $span . '" rowspan="' . $event->rowspan . '">' . $event->getLink($this, true, $this->link(0, true)); if ($showTime) { @@ -246,7 +258,7 @@ class Kronolith_View_Day extends Kronolith_Day { } } - $diff = $this->_span[$cid] - $hspan; + $diff = $this->span[$cid] - $hspan; if ($diff > 0) { $row .= str_repeat(' ', $diff); } @@ -269,7 +281,7 @@ class Kronolith_View_Day extends Kronolith_Day { } $template = $GLOBALS['injector']->createInstance('Horde_Template'); - $template->set('row_height', round(20 / $this->_slotsPerHour)); + $template->set('row_height', round(20 / $this->slotsPerHour)); $template->set('rows', $rows); $template->set('show_slots', true, true); echo $template->fetch(KRONOLITH_TEMPLATES . '/day/rows.html') @@ -281,27 +293,27 @@ class Kronolith_View_Day extends Kronolith_Day { * what should be on each line of the output table. This is a * little tricky. */ - function parse() + public function parse() { global $prefs; $tmp = array(); - $this->_all_day_maxrowspan = 0; + $this->all_day_maxrowspan = 0; $day_hour_force = $prefs->getValue('day_hour_force'); - $day_hour_start = $prefs->getValue('day_hour_start') / 2 * $this->_slotsPerHour; - $day_hour_end = $prefs->getValue('day_hour_end') / 2 * $this->_slotsPerHour; + $day_hour_start = $prefs->getValue('day_hour_start') / 2 * $this->slotsPerHour; + $day_hour_end = $prefs->getValue('day_hour_end') / 2 * $this->slotsPerHour; // Separate out all day events and do some initialization/prep // for parsing. foreach (array_keys($this->_currentCalendars) as $cid) { - $this->_all_day_events[$cid] = array(); - $this->_all_day_rowspan[$cid] = 0; + $this->all_day_events[$cid] = array(); + $this->all_day_rowspan[$cid] = 0; } foreach ($this->_events as $key => $event) { // If we have side_by_side we only want to include the // event in the proper calendar. - if ($this->_sidebyside) { + if ($this->sidebyside) { $cid = $event->calendar; } else { $cid = 0; @@ -309,9 +321,9 @@ class Kronolith_View_Day extends Kronolith_Day { // All day events are easy; store them seperately. if ($event->isAllDay()) { - $this->_all_day_events[$cid][] = clone $event; - ++$this->_all_day_rowspan[$cid]; - $this->_all_day_maxrowspan = max($this->_all_day_maxrowspan, $this->_all_day_rowspan[$cid]); + $this->all_day_events[$cid][] = clone $event; + ++$this->all_day_rowspan[$cid]; + $this->all_day_maxrowspan = max($this->all_day_maxrowspan, $this->all_day_rowspan[$cid]); } else { // Initialize the number of events that this event // overlaps with. @@ -331,12 +343,12 @@ class Kronolith_View_Day extends Kronolith_Day { // Track the first and last slots in which we have an event // (they each start at the other end of the day and move // towards/past each other as we find events). - $this->_first = $this->_slotsPerDay; + $this->_first = $this->slotsPerDay; $this->_last = 0; // Run through every slot, adding in entries for every event // that we have here. - for ($i = 0; $i < $this->_slotsPerDay; ++$i) { + for ($i = 0; $i < $this->slotsPerDay; ++$i) { // Initialize this slot in the event matrix. foreach (array_keys($this->_currentCalendars) as $cid) { $this->_event_matrix[$cid][$i] = array(); @@ -344,19 +356,19 @@ class Kronolith_View_Day extends Kronolith_Day { // Calculate the start and end times for this slot. $start = new Horde_Date(array( - 'hour' => floor($i / $this->_slotsPerHour), - 'min' => ($i % $this->_slotsPerHour) * $this->_slotLength, + 'hour' => floor($i / $this->slotsPerHour), + 'min' => ($i % $this->slotsPerHour) * $this->slotLength, 'month' => $this->month, 'mday' => $this->mday, 'year' => $this->year)); $end = clone $start; - $end->min += $this->_slotLength; + $end->min += $this->slotLength; // Search through our events. foreach ($this->_events as $key => $event) { // If we have side_by_side we only want to include the // event in the proper calendar. - if ($this->_sidebyside) { + if ($this->sidebyside) { $cid = $event->calendar; } else { $cid = 0; @@ -438,31 +450,31 @@ class Kronolith_View_Day extends Kronolith_Day { $span[$cid] *= $s; } } - $this->_totalspan += $span[$cid]; + $this->totalspan += $span[$cid]; } // Set the final span. if (isset($span)) { - $this->_span = $span; + $this->span = $span; } else { - $this->_totalspan = 1; + $this->totalspan = 1; } // We're now parsed and ready to go. $this->_parsed = true; } - function link($offset = 0, $full = false) + public function link($offset = 0, $full = false) { return Horde::url('day.php', $full) ->add('date', $this->getTime('%Y%m%d', $offset)); } - function getName() + public function getName() { return 'Day'; } - function prefHourFormat($hour) + public function prefHourFormat($hour) { $hour = $hour % 24; if ($GLOBALS['prefs']->getValue('twentyFour')) { @@ -472,7 +484,7 @@ class Kronolith_View_Day extends Kronolith_Day { . ($hour < 12 ? 'am' : 'pm'); } - function _sortByStart($evA, $evB) + protected function _sortByStart($evA, $evB) { $sA = $this->_events[$evA]->start; $sB = $this->_events[$evB]->start; diff --git a/kronolith/lib/View/DeleteEvent.php b/kronolith/lib/View/DeleteEvent.php index de69fa6d9..7740926e2 100644 --- a/kronolith/lib/View/DeleteEvent.php +++ b/kronolith/lib/View/DeleteEvent.php @@ -6,42 +6,55 @@ * @author Chuck Hagenbuch * @package Kronolith */ -class Kronolith_View_DeleteEvent { - - var $event; +class Kronolith_View_DeleteEvent +{ + /** + * @var Kronolith_Event + */ + protected $_event; /** * @param Kronolith_Event $event */ - function Kronolith_View_DeleteEvent($event) + public function __construct(Kronolith_Event $event) { - $this->event = $event; + $this->_event = $event; + } + + public function __get($property) + { + switch ($property) { + case 'event': + return $this->_event; + default: + throw new Exception(_("Property does not exist.")); + } } - function getTitle() + public function getTitle() { - if (!$this->event) { + if (!$this->_event) { return _("Not Found"); } - if (is_string($this->event)) { - return $this->event; + if (is_string($this->_event)) { + return $this->_event; } - return sprintf(_("Delete %s"), $this->event->getTitle()); + return sprintf(_("Delete %s"), $this->_event->getTitle()); } - function link() + public function link() { - return $this->event->getDeleteUrl(); + return $this->_event->getDeleteUrl(); } - function html($active = true) + public function html($active = true) { - if (!$this->event) { + if (!$this->_event) { echo '

' . _("Event not found") . '

'; exit; } - if (is_string($this->event)) { - echo '

' . $this->event . '

'; + if (is_string($this->_event)) { + echo '

' . $this->_event . '

'; exit; } @@ -59,7 +72,7 @@ class Kronolith_View_DeleteEvent { $url = Horde_Util::getFormData('url'); echo ''; if ($active && $GLOBALS['browser']->hasFeature('dom')) { - if ($this->event->hasPermission(Horde_Perms::READ)) { - $view = new Kronolith_View_Event($this->event); + if ($this->_event->hasPermission(Horde_Perms::READ)) { + $view = new Kronolith_View_Event($this->_event); $view->html(false); } - if ($this->event->hasPermission(Horde_Perms::EDIT)) { - $edit = new Kronolith_View_EditEvent($this->event); + if ($this->_event->hasPermission(Horde_Perms::EDIT)) { + $edit = new Kronolith_View_EditEvent($this->_event); $edit->html(false); } } } - function getName() + public function getName() { return 'DeleteEvent'; } diff --git a/kronolith/lib/View/EditEvent.php b/kronolith/lib/View/EditEvent.php index 11b66dd79..e2579559c 100644 --- a/kronolith/lib/View/EditEvent.php +++ b/kronolith/lib/View/EditEvent.php @@ -6,60 +6,74 @@ * @author Chuck Hagenbuch * @package Kronolith */ -class Kronolith_View_EditEvent { - - var $event; +class Kronolith_View_EditEvent +{ + /** + * + * @var Kronolith_Event + */ + protected $_event; /** * @param Kronolith_Event $event */ - function Kronolith_View_EditEvent($event) + public function __construct(Kronolith_Event $event) { - $this->event = $event; + $this->_event = $event; + } + + public function __get($property) + { + switch ($property) { + case 'event': + return $this->_event; + default: + throw new Exception(_("Property does not exist.")); + } } - function getTitle() + public function getTitle() { - if (!$this->event) { + if (!$this->_event) { return _("Not Found"); } - if (is_string($this->event)) { - return $this->event; + if (is_string($this->_event)) { + return $this->_event; } - return sprintf(_("Edit %s"), $this->event->getTitle()); + return sprintf(_("Edit %s"), $this->_event->getTitle()); } - function link() + public function link() { - return $this->event->getEditUrl(); + return $this->_event->getEditUrl(); } - function html($active = true) + public function html($active = true) { - if (!$this->event) { + if (!$this->_event) { echo '

' . _("Event not found") . '

'; exit; } - if (is_string($this->event)) { - echo '

' . $this->event . '

'; + if (is_string($this->_event)) { + echo '

' . $this->_event . '

'; exit; } $identity = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Identity')->create(); - if ($this->event->hasPermission(Horde_Perms::EDIT)) { - $calendar_id = $this->event->calendarType . '_' . $this->event->calendar; + if ($this->_event->hasPermission(Horde_Perms::EDIT)) { + $calendar_id = $this->_event->calendarType . '_' . $this->_event->calendar; } else { $calendar_id = 'internal_' . Kronolith::getDefaultCalendar(Horde_Perms::EDIT); } - if (!$this->event->hasPermission(Horde_Perms::EDIT)) { + if (!$this->_event->hasPermission(Horde_Perms::EDIT)) { try { - $calendar_id .= ':' . $this->event->getShare()->get('owner'); + $calendar_id .= ':' . $this->_event->getShare()->get('owner'); } catch (Exception $e) { } } - $GLOBALS['session']->set('kronolith', 'attendees', $this->event->attendees); - $GLOBALS['session']->set('kronolith', 'resources', $this->event->getResources()); + $GLOBALS['session']->set('kronolith', 'attendees', $this->_event->attendees); + $GLOBALS['session']->set('kronolith', 'resources', $this->_event->getResources()); if ($datetime = Horde_Util::getFormData('datetime')) { $datetime = new Horde_Date($datetime); $month = $datetime->month; @@ -71,22 +85,22 @@ class Kronolith_View_EditEvent { $url = Horde_Util::getFormData('url'); $perms = Horde_Perms::EDIT; - if ($this->event->creator == $GLOBALS['registry']->getAuth()) { + if ($this->_event->creator == $GLOBALS['registry']->getAuth()) { $perms |= Kronolith::PERMS_DELEGATE; } $calendars = Kronolith::listCalendars($perms, true); $buttons = array(); - if (!$this->event->hasPermission(Horde_Perms::EDIT) && + if (!$this->_event->hasPermission(Horde_Perms::EDIT) && ($GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_events') === true || $GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_events') > Kronolith::countEvents())) { $buttons[] = ''; } else { - if ($this->event->hasPermission(Horde_Perms::EDIT)) { + if ($this->_event->hasPermission(Horde_Perms::EDIT)) { $buttons[] = ''; } - if ($this->event->initialized) { - if (!$this->event->recurs() && + if ($this->_event->initialized) { + if (!$this->_event->recurs() && ($GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_events') === true || $GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_events') > Kronolith::countEvents())) { $buttons[] = ''; @@ -101,7 +115,7 @@ class Kronolith_View_EditEvent { ->add(array('month' => $month, 'year' => $year)); } - $event = &$this->event; + $event = &$this->_event; $tags = implode(',', array_values($event->tags)); Horde_Core_Ui_JsCalendar::init(array( @@ -116,18 +130,18 @@ class Kronolith_View_EditEvent { echo ''; if ($active && $GLOBALS['browser']->hasFeature('dom')) { - if ($this->event->hasPermission(Horde_Perms::READ)) { - $view = new Kronolith_View_Event($this->event); + if ($this->_event->hasPermission(Horde_Perms::READ)) { + $view = new Kronolith_View_Event($this->_event); $view->html(false); } - if ($this->event->hasPermission(Horde_Perms::DELETE)) { - $delete = new Kronolith_View_DeleteEvent($this->event); + if ($this->_event->hasPermission(Horde_Perms::DELETE)) { + $delete = new Kronolith_View_DeleteEvent($this->_event); $delete->html(false); } } } - function getName() + public function getName() { return 'EditEvent'; } diff --git a/kronolith/lib/View/Event.php b/kronolith/lib/View/Event.php index 2f73c1768..ba29e17bc 100644 --- a/kronolith/lib/View/Event.php +++ b/kronolith/lib/View/Event.php @@ -5,42 +5,56 @@ * @author Chuck Hagenbuch * @package Kronolith */ -class Kronolith_View_Event { - - var $event; +class Kronolith_View_Event +{ + /** + * + * @var Kronolith_Event + */ + protected $_event; /** * @param Kronolith_Event $event */ - function Kronolith_View_Event($event) + public function __construct(Kronolith_Event $event) { - $this->event = $event; + $this->_event = $event; + } + + public function __get($property) + { + switch ($property) { + case 'event': + return $this->_event; + default: + throw new Exception(_("Property does not exist.")); + } } - function getTitle() + public function getTitle() { - if (!$this->event) { + if (!$this->_event) { return _("Not Found"); } - if (is_string($this->event)) { - return $this->event; + if (is_string($this->_event)) { + return $this->_event; } - return $this->event->getTitle(); + return $this->_event->getTitle(); } - function link() + public function link() { - return $this->event->getViewUrl(); + return $this->_event->getViewUrl(); } - function html($active = true) + public function html($active = true) { - if (!$this->event) { + if (!$this->_event) { echo '

' . _("Event not found") . '

'; exit; } - if (is_string($this->event)) { - echo '

' . $this->event . '

'; + if (is_string($this->_event)) { + echo '

' . $this->_event . '

'; exit; } @@ -49,11 +63,11 @@ class Kronolith_View_Event { $createdby = ''; $modifiedby = ''; $userId = $GLOBALS['registry']->getAuth(); - if ($this->event->uid) { + if ($this->_event->uid) { /* Get the event's history. */ try { $log = $GLOBALS['injector']->getInstance('Horde_History') - ->getHistory('kronolith:' . $this->event->calendar . ':' . $this->event->uid); + ->getHistory('kronolith:' . $this->_event->calendar . ':' . $this->_event->uid); foreach ($log as $entry) { switch ($entry['action']) { case 'add': @@ -78,15 +92,15 @@ class Kronolith_View_Event { } catch (Exception $e) {} } - $creatorId = $this->event->creator; - $description = $this->event->description; - $location = $this->event->location; - $eventurl = $this->event->url; - $private = $this->event->private && $creatorId != $GLOBALS['registry']->getAuth(); + $creatorId = $this->_event->creator; + $description = $this->_event->description; + $location = $this->_event->location; + $eventurl = $this->_event->url; + $private = $this->_event->private && $creatorId != $GLOBALS['registry']->getAuth(); $owner = Kronolith::getUserName($creatorId); - $status = Kronolith::statusToString($this->event->status); - $attendees = $this->event->attendees; - $resources = $this->event->getResources(); + $status = Kronolith::statusToString($this->_event->status); + $attendees = $this->_event->attendees; + $resources = $this->_event->getResources(); if ($datetime = Horde_Util::getFormData('datetime')) { $datetime = new Horde_Date($datetime); $month = $datetime->month; @@ -100,7 +114,7 @@ class Kronolith_View_Event { $timeFormat = $prefs->getValue('twentyFour') ? 'G:i' : 'g:ia'; // Tags - $tags = implode(', ', $this->event->tags); + $tags = implode(', ', $this->_event->tags); echo '