Overview

Packages

  • Kronolith
  • None

Classes

  • Kronolith
  • Kronolith_Ajax_Application
  • Kronolith_Ajax_Imple_ContactAutoCompleter
  • Kronolith_Ajax_Imple_Embed
  • Kronolith_Ajax_Imple_TagActions
  • Kronolith_Ajax_Imple_TagAutoCompleter
  • Kronolith_Api
  • Kronolith_Calendar
  • Kronolith_Calendar_External
  • Kronolith_Calendar_External_Tasks
  • Kronolith_Calendar_Holiday
  • Kronolith_Calendar_Internal
  • Kronolith_Calendar_Remote
  • Kronolith_Calendar_Resource
  • Kronolith_Calendars_Base
  • Kronolith_Calendars_Default
  • Kronolith_Calendars_Kolab
  • Kronolith_Day
  • Kronolith_Driver
  • Kronolith_Driver_Holidays
  • Kronolith_Driver_Horde
  • Kronolith_Driver_Ical
  • Kronolith_Driver_Kolab
  • Kronolith_Driver_Mock
  • Kronolith_Driver_Resource
  • Kronolith_Driver_Sql
  • Kronolith_Event
  • Kronolith_Event_Holidays
  • Kronolith_Event_Horde
  • Kronolith_Event_Ical
  • Kronolith_Event_Kolab
  • Kronolith_Event_Resource
  • Kronolith_Event_Sql
  • Kronolith_Exception
  • Kronolith_Factory_Calendars
  • Kronolith_Factory_Geo
  • Kronolith_Form_CreateCalendar
  • Kronolith_Form_CreateResource
  • Kronolith_Form_CreateResourceGroup
  • Kronolith_Form_DeleteCalendar
  • Kronolith_Form_DeleteResource
  • Kronolith_Form_DeleteResourceGroup
  • Kronolith_Form_EditCalendar
  • Kronolith_Form_EditRemoteCalendar
  • Kronolith_Form_EditResource
  • Kronolith_Form_EditResourceGroup
  • Kronolith_Form_SubscribeRemoteCalendar
  • Kronolith_Form_UnsubscribeRemoteCalendar
  • Kronolith_FreeBusy
  • Kronolith_FreeBusy_View
  • Kronolith_FreeBusy_View_Day
  • Kronolith_FreeBusy_View_Month
  • Kronolith_FreeBusy_View_Week
  • Kronolith_FreeBusy_View_Workweek
  • Kronolith_Geo_Base
  • Kronolith_Geo_Mysql
  • Kronolith_Geo_Sql
  • Kronolith_LoginTasks_SystemTask_Upgrade
  • Kronolith_LoginTasks_Task_PurgeEvents
  • Kronolith_Notification_Listener_AjaxStatus
  • Kronolith_Resource
  • Kronolith_Resource_Base
  • Kronolith_Resource_Group
  • Kronolith_Resource_Single
  • Kronolith_Storage
  • Kronolith_Storage_Kolab
  • Kronolith_Storage_Sql
  • Kronolith_Tagger
  • Kronolith_Test
  • Kronolith_View_Day
  • Kronolith_View_DeleteEvent
  • Kronolith_View_EditEvent
  • Kronolith_View_Event
  • Kronolith_View_ExportEvent
  • Kronolith_View_Month
  • Kronolith_View_Week
  • Kronolith_View_WorkWeek
  • Kronolith_View_Year
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Kronolith_Calendar_Internal defines an API for single internal (share)
  4:  * calendars.
  5:  *
  6:  * Copyright 2010-2012 Horde LLC (http://www.horde.org/)
  7:  *
  8:  * See the enclosed file COPYING for license information (GPL). If you
  9:  * did not receive this file, see http://www.horde.org/licenses/gpl.
 10:  *
 11:  * @author  Jan Schneider <jan@horde.org>
 12:  * @package Kronolith
 13:  */
 14: class Kronolith_Calendar_Internal extends Kronolith_Calendar
 15: {
 16:     /**
 17:      * The share of this calendar.
 18:      *
 19:      * @var Horde_Share_Object
 20:      */
 21:     protected $_share;
 22: 
 23:     /**
 24:      * Constructor.
 25:      *
 26:      * @param array $params  A hash with any parameters that this calendar
 27:      *                       might need.
 28:      *                       Required parameters:
 29:      *                       - share: The share of this calendar.
 30:      */
 31:     public function __construct($params = array())
 32:     {
 33:         if (!isset($params['share'])) {
 34:             throw new BadMethodCallException('share parameter is missing');
 35:         }
 36:         if (!($params['share'] instanceof Horde_Share_Object)) {
 37:             throw new InvalidArgumentException('share parameter is not a Horde_Share_Object');
 38:         }
 39:         parent::__construct($params);
 40:     }
 41: 
 42:     /**
 43:      * Returns the owner of this calendar.
 44:      *
 45:      * @return string  This calendar's owner.
 46:      */
 47:     public function owner()
 48:     {
 49:         return $this->_share->get('owner');
 50:     }
 51: 
 52:     /**
 53:      * Returns the name of this calendar.
 54:      *
 55:      * @return string  This calendar's name.
 56:      */
 57:     public function name()
 58:     {
 59:         return $this->_share->get('name');
 60:     }
 61: 
 62:     /**
 63:      * Returns the description of this calendar.
 64:      *
 65:      * @return string  This calendar's description.
 66:      */
 67:     public function description()
 68:     {
 69:         return $this->_share->get('desc');
 70:     }
 71: 
 72:     /**
 73:      * Returns the background color for this calendar.
 74:      *
 75:      * @return string  A HTML color code.
 76:      */
 77:     public function background()
 78:     {
 79:         $color = $this->_share->get('color');
 80:         return empty($color) ? parent::background() : $color;
 81:     }
 82: 
 83:     /**
 84:      * Encapsulates permissions checking.
 85:      *
 86:      * @param integer $permission  The permission to check for.
 87:      * @param string $user         The user to check permissions for. Defaults
 88:      *                             to the current user.
 89:      * @param string $creator      An event creator, to check for creator
 90:      *                             permissions.
 91:      *
 92:      * @return boolean  Whether the user has the permission on this calendar.
 93:      */
 94:     public function hasPermission($permission, $user = null, $creator = null)
 95:     {
 96:         if ($user === null) {
 97:             $user = $GLOBALS['registry']->getAuth();
 98:         }
 99:         return $this->_share->hasPermission($user, $permission, $creator);
100:     }
101: 
102:     /**
103:      * Whether this calendar is supposed to be displayed in lists.
104:      *
105:      * @return boolean  True if this calendar should be displayed.
106:      */
107:     public function display()
108:     {
109:         return $this->owner() == $GLOBALS['registry']->getAuth() ||
110:             empty($GLOBALS['conf']['share']['hidden']) ||
111:             in_array($this->_share->getName(), $GLOBALS['display_calendars']);
112:     }
113: 
114:     /**
115:      * Returns the share of this calendar.
116:      *
117:      * @return Horde_Share_Object  This calendar's share.
118:      */
119:     public function share()
120:     {
121:         return $this->_share;
122:     }
123: 
124:     /**
125:      * Returns a hash representing this calendar.
126:      *
127:      * @return array  A simple hash.
128:      */
129:     public function toHash()
130:     {
131:         $id = $this->_share->getName();
132:         $owner = $GLOBALS['registry']->getAuth() &&
133:             $this->owner() == $GLOBALS['registry']->getAuth();
134: 
135:         $hash = parent::toHash();
136:         $hash['name']  = $this->name()
137:           . ($owner || !$this->owner() ? '' : ' [' . $GLOBALS['registry']->convertUsername($this->owner(), false) . ']');
138:         $hash['owner'] = $owner;
139:         $hash['show']  = in_array($id, $GLOBALS['display_calendars']);
140:         $hash['edit']  = $this->hasPermission(Horde_Perms::EDIT);
141:         $hash['sub']   = Horde::url($GLOBALS['registry']->get('webroot', 'horde') . ($GLOBALS['conf']['urls']['pretty'] == 'rewrite' ? '/rpc/kronolith/' : '/rpc.php/kronolith/'), true, -1)
142:             . ($this->owner() ? $this->owner() : '-system-') . '/'
143:             . $id . '.ics';
144:         $hash['feed']  = (string)Kronolith::feedUrl($id);
145:         $hash['embed'] = Kronolith::embedCode($id);
146:         $hash['tg']    = array_values(Kronolith::getTagger()->getTags($id, 'calendar'));
147:         if ($owner) {
148:             $hash['perms'] = Kronolith::permissionToJson($this->_share->getPermission());
149:         }
150: 
151:         return $hash;
152:     }
153: }
154: 
API documentation generated by ApiGen