getDriver() public static method

This singleton method automatically retrieves all parameters required for the specified driver.
public static getDriver ( string $driver = null, string $calendar = null ) : Kronolith_Driver
$driver string The type of concrete Kronolith_Driver subclass to return.
$calendar string The calendar name. The format depends on the driver being used.
return Kronolith_Driver The newly created concrete Kronolith_Driver instance.
コード例 #1
0
ファイル: Resource.php プロジェクト: jubinpatel/horde
 /**
  * Adds a new resource to storage
  *
  * @param Kronolith_Resource_Base $resource
  *
  * @return unknown_type
  */
 public static function addResource(Kronolith_Resource_Base $resource)
 {
     // Create a new calendar id.
     $calendar = uniqid(mt_rand());
     $resource->set('calendar', $calendar);
     $driver = Kronolith::getDriver('Resource');
     return $driver->save($resource);
 }
コード例 #2
0
ファイル: KolabTest.php プロジェクト: raz0rsdge/horde
 public static function setUpBeforeClass()
 {
     return;
     parent::setUpBeforeClass();
     self::createKolabShares(self::$setup);
     list($share, $other_share) = self::_createDefaultShares();
     self::$driver = Kronolith::getDriver('Kolab', $share->getName());
     self::$type = 'Kolab';
 }
コード例 #3
0
ファイル: SqliteTest.php プロジェクト: jubinpatel/horde
 public static function setUpBeforeClass()
 {
     self::$callback = array(__CLASS__, 'getDb');
     parent::setUpBeforeClass();
     $migrator = new Horde_Db_Migration_Migrator($GLOBALS['injector']->getInstance('Horde_Db_Adapter'), null, array('migrationsPath' => __DIR__ . '/../../../../../../migration', 'schemaTableName' => 'kronolith_test_schema'));
     $migrator->up();
     list($share, $other_share) = self::_createDefaultShares();
     self::$driver = Kronolith::getDriver('Sql', $share->getName());
     self::$type = 'Sql';
 }
コード例 #4
0
ファイル: EditResource.php プロジェクト: DSNS-LAB/Dmail
 /**
  * @throws Kronolith_Exception
  */
 public function execute()
 {
     switch ($this->_vars->submitbutton) {
         case _("Save"):
             $new_name = $this->_vars->get('name');
             $this->_resource->set('name', $new_name);
             $this->_resource->set('description', $this->_vars->get('description'));
             $this->_resource->set('response_type', $this->_vars->get('responsetype'));
             $this->_resource->set('email', $this->_vars->get('email'));
             /* Update group memberships */
             $driver = Kronolith::getDriver('Resource');
             $existing_groups = $driver->getGroupMemberships($this->_resource->getId());
             $new_groups = $this->_vars->get('category');
             $new_groups = is_null($new_groups) ? array() : $new_groups;
             foreach ($existing_groups as $gid) {
                 $i = array_search($gid, $new_groups);
                 if ($i === false) {
                     // No longer in this group
                     $group = $driver->getResource($gid);
                     $members = $group->get('members');
                     $idx = array_search($this->_resource->getId(), $members);
                     if ($idx !== false) {
                         unset($members[$idx]);
                         reset($members);
                         $group->set('members', $members);
                         $group->save();
                     }
                 } else {
                     // We know it's already in the group, remove it so we don't
                     // have to check/add it again later.
                     unset($new_groups[$i]);
                 }
             }
             reset($new_groups);
             foreach ($new_groups as $gid) {
                 $group = $driver->getResource($gid);
                 $members = $group->get('members');
                 $members[] = $this->_resource->getId();
                 $group->set('members', $members);
                 $group->save();
             }
             try {
                 $this->_resource->save();
             } catch (Exception $e) {
                 throw new Kronolith_Exception(sprintf(_("Unable to save resource \"%s\": %s"), $new_name, $e->getMessage()));
             }
             return $this->_resource;
         case _("Delete"):
             Horde::url('resources/delete.php')->add('c', $this->_vars->c)->redirect();
             break;
         case _("Cancel"):
             Horde::url($GLOBALS['prefs']->getValue('defaultview') . '.php', true)->redirect();
             break;
     }
 }
コード例 #5
0
 /**
  */
 protected function _handleAutoCompleter($input)
 {
     $ret = array();
     // For now, return all resources.
     $resources = Kronolith::getDriver('Resource')->listResources(Horde_Perms::READ, array(), 'name');
     foreach ($resources as $r) {
         if (strpos(Horde_String::lower($r->get('name')), Horde_String::lower($input)) !== false) {
             $ret[] = array('name' => $r->get('name'), 'code' => $r->getId());
         }
     }
     return $ret;
 }
コード例 #6
0
 /**
  * @throws Kronolith_Exception
  */
 public function __construct($vars)
 {
     parent::__construct($vars, _("Create Resource Group"));
     $resources = Kronolith::getDriver('Resource')->listResources(Horde_Perms::READ, array('isgroup' => 0));
     $enum = array();
     foreach ($resources as $resource) {
         $enum[$resource->getId()] = htmlspecialchars($resource->get('name'));
     }
     $this->addVariable(_("Name"), 'name', 'text', true);
     $this->addVariable(_("Description"), 'description', 'longtext', false, false, null, array(4, 60));
     $this->addVariable(_("Resources"), 'members', 'multienum', false, false, null, array('enum' => $enum));
     $this->setButtons(array(_("Create")));
 }
コード例 #7
0
ファイル: Sql.php プロジェクト: DSNS-LAB/Dmail
 /**
  * Attempts to open a connection to the SQL server.
  *
  * @throws Kronolith_Exception
  */
 public function initialize()
 {
     if (empty($this->_params['db'])) {
         throw new InvalidArgumentException('Missing required Horde_Db_Adapter instance');
     }
     try {
         $this->_db = $this->_params['db'];
     } catch (Horde_Exception $e) {
         throw new Kronolith_Exception($e);
     }
     $this->_params = array_merge(array('table' => 'kronolith_resources'), $this->_params);
     $this->_driver = Kronolith::getDriver();
     $this->_columns = $this->_db->columns($this->_params['table']);
 }
コード例 #8
0
ファイル: EditResourceGroup.php プロジェクト: raz0rsdge/horde
 /**
  * @throws Kronolith_Exception
  */
 public function __construct($vars, $resource)
 {
     $this->_resource = $resource;
     parent::__construct($vars, sprintf(_("Edit %s"), $resource->get('name')));
     $resources = Kronolith::getDriver('Resource')->listResources(Horde_Perms::READ, array('isgroup' => 0));
     $enum = array();
     foreach ($resources as $r) {
         $enum[$r->getId()] = htmlspecialchars($r->get('name'));
     }
     $this->addHidden('', 'c', 'text', true);
     $this->addVariable(_("Name"), 'name', 'text', true);
     $this->addVariable(_("Description"), 'description', 'longtext', false, false, null, array(4, 60));
     $this->addVariable(_("Resources"), 'members', 'multienum', false, false, null, array('enum' => $enum));
     $this->setButtons(array(_("Save"), array('class' => 'horde-delete', 'value' => _("Delete")), array('class' => 'horde-cancel', 'value' => _("Cancel"))));
 }
コード例 #9
0
 /**
  * @throws Kronolith_Exception
  */
 public function execute()
 {
     if ($this->_vars->get('submitbutton') == _("Cancel")) {
         Horde::url($GLOBALS['prefs']->getValue('defaultview') . '.php', true)->redirect();
     }
     if (!$this->_resource->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE)) {
         throw new Kronolith_Exception(_("Permission denied"));
     }
     // Delete the resource.
     try {
         Kronolith::getDriver('Resource')->delete($this->_resource);
     } catch (Exception $e) {
         throw new Kronolith_Exception(sprintf(_("Unable to delete \"%s\": %s"), $this->_resource->get('name'), $e->getMessage()));
     }
 }
コード例 #10
0
ファイル: CreateResource.php プロジェクト: DSNS-LAB/Dmail
 /**
  * @throws Kronolith_Exception
  */
 public function execute()
 {
     $new = array('name' => $this->_vars->get('name'), 'description' => $this->_vars->get('description'), 'response_type' => $this->_vars->get('responsetype'), 'email' => $this->_vars->get('email'));
     $resource = Kronolith_Resource::addResource(new Kronolith_Resource_Single($new));
     /* Do we need to add this to any groups? */
     $groups = $this->_vars->get('category');
     if (!empty($groups)) {
         foreach ($groups as $group_id) {
             $group = Kronolith::getDriver('Resource')->getResource($group_id);
             $members = $group->get('members');
             $members[] = $resource->getId();
             $group->set('members', $members);
             $group->save();
         }
     }
 }
コード例 #11
0
ファイル: Tagger.php プロジェクト: jubinpatel/horde
 /**
  * Searches for resources that are tagged with all of the requested tags.
  *
  * @param array $tags    Either a tag_id, tag_name or an array.
  * @param array $filter  Array of filter parameters.
  *                       - type (string) - only return either events or
  *                         calendars, not both.
  *                       - user (array) - only include objects owned by
  *                         these users.
  *                       - calendar (array) - restrict to events contained
  *                         in these calendars.
  *
  * @return  A hash of 'calendars' and 'events' that each contain an array
  *          of calendar_ids and event_uids respectively.
  */
 public function search($tags, $filter = array())
 {
     $args = array();
     /* These filters are mutually exclusive */
     if (array_key_exists('user', $filter)) {
         /* semi-hack to see if we are querying for a system-owned share -
          * will need to get the list of all system owned shares and query
          * using a calendar filter instead of a user filter. */
         if (empty($filter['user'])) {
             // @TODO: No way to get only the system shares the current
             // user can see?
             $calendars = $GLOBALS['injector']->getInstance('Kronolith_Shares')->listSystemShares();
             $args['calendarId'] = array();
             foreach ($calendars as $name => $share) {
                 if ($share->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ)) {
                     $args['calendarId'][] = $name;
                 }
             }
         } else {
             // Items owned by specific user(s)
             $args['userId'] = $filter['user'];
         }
     } elseif (!empty($filter[self::TYPE_CALENDAR])) {
         // Only events located in specific calendar(s)
         if (!is_array($filter[self::TYPE_CALENDAR])) {
             $filter[self::TYPE_CALENDAR] = array($filter[self::TYPE_CALENDAR]);
         }
         $args['calendarId'] = $filter[self::TYPE_CALENDAR];
     }
     /* Add the tags to the search */
     $args['tagId'] = $GLOBALS['injector']->getInstance('Content_Tagger')->getTagIds($tags);
     /* Restrict to events or calendars? */
     $cal_results = $event_results = array();
     if (empty($filter['type']) || $filter['type'] == self::TYPE_CALENDAR) {
         $args['typeId'] = $this->_type_ids[self::TYPE_CALENDAR];
         $cal_results = $GLOBALS['injector']->getInstance('Content_Tagger')->getObjects($args);
     }
     if (empty($filter['type']) || $filter['type'] == 'event') {
         $args['typeId'] = $this->_type_ids['event'];
         $event_results = $GLOBALS['injector']->getInstance('Content_Tagger')->getObjects($args);
     }
     $results = array('calendars' => array_values($cal_results), 'events' => !empty($args['calendarId']) && count($event_results) ? Kronolith::getDriver()->filterEventsByCalendar(array_values($event_results), $args['calendarId']) : array_values($event_results));
     return $results;
 }
コード例 #12
0
ファイル: PurgeEvents.php プロジェクト: horde/horde
 /**
  * Purge old events.
  *
  * @throws Kronolith_Exception
  * @throws Horde_Exception_NotFound
  */
 public function execute()
 {
     /* Get the current time minus the number of days specified in
      * 'purge_events_keep'.  An event will be deleted if it has an end
      * time prior to this time. */
     $del_time = new Horde_Date($_SERVER['REQUEST_TIME']);
     $del_time->mday -= $GLOBALS['prefs']->getValue('purge_events_keep');
     /* Need to have Horde_Perms::DELETE on a calendar to delete events
      * from it */
     $calendars = Kronolith::listInternalCalendars(true, Horde_Perms::DELETE);
     /* Start building the search */
     $kronolith_driver = Kronolith::getDriver();
     $query = new StdClass();
     $query->start = null;
     $query->end = $del_time;
     $query->status = null;
     $query->calendars = array(Horde_String::ucfirst($GLOBALS['conf']['calendar']['driver']) => array_keys($calendars));
     $query->creator = $GLOBALS['registry']->getAuth();
     /* Perform the search */
     $days = Kronolith::search($query);
     $count = 0;
     foreach ($days as $events) {
         foreach ($events as $event) {
             /* Delete if no recurrence, or if we are past the last occurence */
             if (!$event->recurs() || $event->recurrence->nextRecurrence($del_time) == false) {
                 if ($event->calendar != $kronolith_driver->calendar) {
                     $kronolith_driver->open($event->calendar);
                 }
                 try {
                     $kronolith_driver->deleteEvent($event->id, true);
                     ++$count;
                 } catch (Exception $e) {
                     Horde::log($e, 'ERR');
                     throw $e;
                 }
             }
         }
     }
     $GLOBALS['notification']->push(sprintf(ngettext("Deleted %d event older than %d days.", "Deleted %d events older than %d days.", $count), $count, $GLOBALS['prefs']->getValue('purge_events_keep')));
 }
コード例 #13
0
ファイル: Single.php プロジェクト: DSNS-LAB/Dmail
 /**
  * Determine if the resource is free during the time period for the
  * supplied event.
  *
  * @param Kronolith_Event $event  The event to check availability for.
  *
  * @return boolean
  * @throws Kronolith_Exception
  */
 public function isFree(Kronolith_Event $event)
 {
     /* Fetch Events */
     $busy = Kronolith::getDriver('Resource', $this->get('calendar'))->listEvents($event->start, $event->end, array('show_recurrence' => true));
     /* No events at all during time period for requested event */
     if (!count($busy)) {
         return true;
     }
     /* Check for conflicts, ignoring the conflict if it's for the
      * same event that is passed. */
     foreach ($busy as $events) {
         foreach ($events as $e) {
             if (!($e->status == Kronolith::STATUS_CANCELLED || $e->status == Kronolith::STATUS_FREE) && $e->uid !== $event->uid) {
                 // Comparing to zero allows the events to start at the same
                 // the previous event ends.
                 if (!($e->start->compareDateTime($event->end) >= 0) && !($e->end->compareDateTime($event->start) <= 0)) {
                     return false;
                 }
             }
         }
     }
     return true;
 }
コード例 #14
0
ファイル: Event.php プロジェクト: DSNS-LAB/Dmail
 public function readForm()
 {
     global $prefs, $session;
     // Event owner.
     $targetcalendar = Horde_Util::getFormData('targetcalendar');
     if (strpos($targetcalendar, '\\')) {
         list(, $this->creator) = explode('\\', $targetcalendar, 2);
     } elseif (!isset($this->_id)) {
         $this->creator = $GLOBALS['registry']->getAuth();
     }
     // Basic fields.
     $this->title = Horde_Util::getFormData('title', $this->title);
     $this->description = Horde_Util::getFormData('description', $this->description);
     $this->location = Horde_Util::getFormData('location', $this->location);
     $this->timezone = Horde_Util::getFormData('timezone', $this->timezone);
     $this->private = (bool) Horde_Util::getFormData('private');
     // URL.
     $url = Horde_Util::getFormData('eventurl', $this->url);
     if (strlen($url)) {
         // Analyze and re-construct.
         $url = @parse_url($url);
         if ($url) {
             if (function_exists('http_build_url')) {
                 if (empty($url['path'])) {
                     $url['path'] = '/';
                 }
                 $url = http_build_url($url);
             } else {
                 $new_url = '';
                 if (isset($url['scheme'])) {
                     $new_url .= $url['scheme'] . '://';
                 }
                 if (isset($url['user'])) {
                     $new_url .= $url['user'];
                     if (isset($url['pass'])) {
                         $new_url .= ':' . $url['pass'];
                     }
                     $new_url .= '@';
                 }
                 if (isset($url['host'])) {
                     // Convert IDN hosts to ASCII.
                     if (function_exists('idn_to_ascii')) {
                         $url['host'] = @idn_to_ascii($url['host']);
                     } elseif (Horde_Mime::is8bit($url['host'])) {
                         //throw new Kronolith_Exception(_("Invalid character in URL."));
                         $url['host'] = '';
                     }
                     $new_url .= $url['host'];
                 }
                 if (isset($url['path'])) {
                     $new_url .= $url['path'];
                 }
                 if (isset($url['query'])) {
                     $new_url .= '?' . $url['query'];
                 }
                 if (isset($url['fragment'])) {
                     $new_url .= '#' . $url['fragment'];
                 }
                 $url = $new_url;
             }
         }
     }
     $this->url = $url;
     // Status.
     $this->status = Horde_Util::getFormData('status', $this->status);
     // Attendees.
     $attendees = $session->get('kronolith', 'attendees', Horde_Session::TYPE_ARRAY);
     if (!is_null($newattendees = Horde_Util::getFormData('attendees'))) {
         $newattendees = Kronolith::parseAttendees(trim($newattendees));
         foreach ($newattendees as $email => $attendee) {
             if (!isset($attendees[$email])) {
                 $attendees[$email] = $attendee;
             }
         }
         foreach (array_keys($attendees) as $email) {
             if (!isset($newattendees[$email])) {
                 unset($attendees[$email]);
             }
         }
     }
     $this->attendees = $attendees;
     // Event start.
     $allDay = Horde_Util::getFormData('whole_day');
     if ($start_date = Horde_Util::getFormData('start_date')) {
         // From ajax interface.
         $this->start = Kronolith::parseDate($start_date . ' ' . Horde_Util::getFormData('start_time'), true, $this->timezone);
         if ($allDay) {
             $this->start->hour = $this->start->min = $this->start->sec = 0;
         }
     } else {
         // From traditional interface.
         $start = Horde_Util::getFormData('start');
         $start_year = $start['year'];
         $start_month = $start['month'];
         $start_day = $start['day'];
         $start_hour = Horde_Util::getFormData('start_hour');
         $start_min = Horde_Util::getFormData('start_min');
         $am_pm = Horde_Util::getFormData('am_pm');
         if (!$prefs->getValue('twentyFour')) {
             if ($am_pm == 'PM') {
                 if ($start_hour != 12) {
                     $start_hour += 12;
                 }
             } elseif ($start_hour == 12) {
                 $start_hour = 0;
             }
         }
         if (Horde_Util::getFormData('end_or_dur') == 1) {
             if ($allDay) {
                 $start_hour = 0;
                 $start_min = 0;
                 $dur_day = 0;
                 $dur_hour = 24;
                 $dur_min = 0;
             } else {
                 $dur_day = (int) Horde_Util::getFormData('dur_day');
                 $dur_hour = (int) Horde_Util::getFormData('dur_hour');
                 $dur_min = (int) Horde_Util::getFormData('dur_min');
             }
         }
         $this->start = new Horde_Date(array('hour' => $start_hour, 'min' => $start_min, 'month' => $start_month, 'mday' => $start_day, 'year' => $start_year), $this->timezone);
     }
     // Event end.
     if ($end_date = Horde_Util::getFormData('end_date')) {
         // From ajax interface.
         $this->end = Kronolith::parseDate($end_date . ' ' . Horde_Util::getFormData('end_time'), true, $this->timezone);
         if ($allDay) {
             $this->end->hour = $this->end->min = $this->end->sec = 0;
             $this->end->mday++;
         }
     } elseif (Horde_Util::getFormData('end_or_dur') == 1) {
         // Event duration from traditional interface.
         $this->end = new Horde_Date(array('hour' => $start_hour + $dur_hour, 'min' => $start_min + $dur_min, 'month' => $start_month, 'mday' => $start_day + $dur_day, 'year' => $start_year));
     } else {
         // From traditional interface.
         $end = Horde_Util::getFormData('end');
         $end_year = $end['year'];
         $end_month = $end['month'];
         $end_day = $end['day'];
         $end_hour = Horde_Util::getFormData('end_hour');
         $end_min = Horde_Util::getFormData('end_min');
         $end_am_pm = Horde_Util::getFormData('end_am_pm');
         if (!$prefs->getValue('twentyFour')) {
             if ($end_am_pm == 'PM') {
                 if ($end_hour != 12) {
                     $end_hour += 12;
                 }
             } elseif ($end_hour == 12) {
                 $end_hour = 0;
             }
         }
         $this->end = new Horde_Date(array('hour' => $end_hour, 'min' => $end_min, 'month' => $end_month, 'mday' => $end_day, 'year' => $end_year), $this->timezone);
         if ($this->end->compareDateTime($this->start) < 0) {
             $this->end = new Horde_Date($this->start);
         }
     }
     $this->allday = false;
     // Alarm.
     if (!is_null($alarm = Horde_Util::getFormData('alarm'))) {
         if ($alarm) {
             $value = Horde_Util::getFormData('alarm_value');
             $unit = Horde_Util::getFormData('alarm_unit');
             if ($value == 0) {
                 $value = $unit = 1;
             }
             $this->alarm = $value * $unit;
             // Notification.
             if (Horde_Util::getFormData('alarm_change_method')) {
                 $types = Horde_Util::getFormData('event_alarms');
                 $methods = array();
                 if (!empty($types)) {
                     foreach ($types as $type) {
                         $methods[$type] = array();
                         switch ($type) {
                             case 'notify':
                                 $methods[$type]['sound'] = Horde_Util::getFormData('event_alarms_sound');
                                 break;
                             case 'mail':
                                 $methods[$type]['email'] = Horde_Util::getFormData('event_alarms_email');
                                 break;
                             case 'popup':
                                 break;
                         }
                     }
                 }
                 $this->methods = $methods;
             } else {
                 $this->methods = array();
             }
         } else {
             $this->alarm = 0;
             $this->methods = array();
         }
     }
     // Recurrence.
     $this->recurrence = $this->readRecurrenceForm($this->start, $this->timezone, $this->recurrence);
     // Convert to local timezone.
     $this->setTimezone(false);
     // Resources
     $existingResources = $this->_resources;
     if (Horde_Util::getFormData('isajax', false)) {
         $resources = array();
     } else {
         $resources = $session->get('kronolith', 'resources', Horde_Session::TYPE_ARRAY);
     }
     $newresources = Horde_Util::getFormData('resources');
     if (!empty($newresources)) {
         foreach (explode(',', $newresources) as $id) {
             try {
                 $resource = Kronolith::getDriver('Resource')->getResource($id);
             } catch (Kronolith_Exception $e) {
                 $GLOBALS['notification']->push($e->getMessage(), 'horde.error');
                 continue;
             }
             if (!$resource instanceof Kronolith_Resource_Group || $resource->isFree($this)) {
                 $resources[$resource->getId()] = array('attendance' => Kronolith::PART_REQUIRED, 'response' => Kronolith::RESPONSE_NONE, 'name' => $resource->get('name'));
             } else {
                 $GLOBALS['notification']->push(_("No resources from this group were available"), 'horde.error');
             }
         }
     }
     $this->_resources = $resources;
     // Check if we need to remove any resources
     $merged = $existingResources + $this->_resources;
     $delete = array_diff(array_keys($existingResources), array_keys($this->_resources));
     foreach ($delete as $key) {
         // Resource might be declined, in which case it won't have the event
         // on it's calendar.
         if ($merged[$key]['response'] != Kronolith::RESPONSE_DECLINED) {
             try {
                 Kronolith::getDriver('Resource')->getResource($key)->removeEvent($this);
             } catch (Kronolith_Exception $e) {
                 $GLOBALS['notification']->push('foo', 'horde.error');
             }
         }
     }
     // Tags.
     $this->tags = Horde_Util::getFormData('tags', $this->tags);
     // Geolocation
     if (Horde_Util::getFormData('lat') && Horde_Util::getFormData('lon')) {
         $this->geoLocation = array('lat' => Horde_Util::getFormData('lat'), 'lon' => Horde_Util::getFormData('lon'), 'zoom' => Horde_Util::getFormData('zoom'));
     }
     $this->initialized = true;
 }
コード例 #15
0
ファイル: new.php プロジェクト: horde/horde
if (Kronolith::showAjaxView()) {
    Horde::url('', true)->setAnchor('event')->redirect();
}
/* Check permissions. */
$url = Horde::url($prefs->getValue('defaultview') . '.php', true)->add(array('month' => Horde_Util::getFormData('month'), 'year' => Horde_Util::getFormData('year')));
$perms = $GLOBALS['injector']->getInstance('Horde_Core_Perms');
if ($perms->hasAppPermission('max_events') !== true && $perms->hasAppPermission('max_events') <= Kronolith::countEvents()) {
    Horde::permissionDeniedError('kronolith', 'max_events', sprintf(_("You are not allowed to create more than %d events."), $perms->hasAppPermission('max_events')));
    $url->redirect();
}
$display_resource = $GLOBALS['calendar_manager']->get(Kronolith::DISPLAY_RESOURCE_CALENDARS);
$calendar_id = Horde_Util::getFormData('calendar', empty($display_resource) ? 'internal_' . Kronolith::getDefaultCalendar(Horde_Perms::EDIT) : 'resource_' . $display_resource[0]);
if ($calendar_id == 'internal_' || $calendar_id == 'resource_') {
    $url->redirect();
}
$event = Kronolith::getDriver()->getEvent();
$session->set('kronolith', 'attendees', $event->attendees);
$session->set('kronolith', 'resources', $event->getResources());
$date = Horde_Util::getFormData('datetime');
if ($date) {
    $event->start = new Horde_Date($date);
} else {
    $date = Horde_Util::getFormData('date', date('Ymd')) . '000600';
    $event->start = new Horde_Date($date);
    if ($prefs->getValue('twentyFour')) {
        $event->start->hour = 12;
    }
}
$event->end = new Horde_Date($event->start);
if (Horde_Util::getFormData('allday')) {
    $event->end->mday++;
コード例 #16
0
ファイル: CalendarsManager.php プロジェクト: DSNS-LAB/Dmail
 /**
  * Return list of all resource calendars.
  *
  * @return array  Resource calendars, keyed by calendar id.
  */
 protected function _getAllResource()
 {
     $this->_allResource = array();
     if (!empty($GLOBALS['conf']['resource']['driver'])) {
         foreach (Kronolith::getDriver('Resource')->listResources(Horde_Perms::READ, array('type' => Kronolith_Resource::TYPE_SINGLE)) as $resource) {
             $rcal = new Kronolith_Calendar_Resource(array('resource' => $resource));
             $this->_allResource[$resource->get('calendar')] = $rcal;
         }
     }
     return $this->_allResource;
 }
コード例 #17
0
ファイル: data.php プロジェクト: DSNS-LAB/Dmail
        } else {
            $notification->push(_("This file format is not supported."), 'horde.error');
            $next_step = Horde_Data::IMPORT_FILE;
        }
    }
}
/* We have a final result set. */
if (is_array($next_step)) {
    $events = array();
    $error = false;
    $max_events = $perms->hasAppPermission('max_events');
    if ($max_events !== true) {
        $num_events = Kronolith::countEvents();
    }
    list($type, $calendar) = explode('_', $storage->get('import_cal'), 2);
    $kronolith_driver = Kronolith::getDriver($type, $calendar);
    if (!count($next_step)) {
        $notification->push(sprintf(_("The %s file didn't contain any events."), $file_types[$storage->get('format')]), 'horde.error');
        $error = true;
    } else {
        /* Purge old calendar if requested. */
        if ($storage->get('purge')) {
            try {
                $kronolith_driver->delete($calendar);
                $notification->push(_("Calendar successfully purged."), 'horde.success');
            } catch (Exception $e) {
                $notification->push(sprintf(_("The calendar could not be purged: %s"), $e->getMessage()), 'horde.error');
            }
        }
    }
    $recurrences = array();
コード例 #18
0
ファイル: Api.php プロジェクト: horde/horde
 /**
  * Return an internal calendar.
  *
  * @todo Note: This returns a Kronolith_Calendar_Object object instead of a hash
  * to be consistent with other application APIs. For H6 we need to normalize
  * the APIs to always return non-objects and/or implement some mechanism to
  * mark API methods as non-RPC safe.
  *
  * @param string $id  The calendar uid (share name).
  *
  * @return Kronolith_Calendar The calendar object.
  * @since 4.2.0
  */
 public function getCalendar($id = null)
 {
     $driver = Kronolith::getDriver(null, $id);
     return Kronolith::getCalendar($driver);
 }
コード例 #19
0
ファイル: attend.php プロジェクト: horde/horde
        $msg = _("You have tentatively accepted attendence to this event.");
        break;
    default:
        $action = Kronolith::RESPONSE_NONE;
        $msg = '';
        break;
}
if ((empty($cal) || empty($id)) && empty($uid) || empty($user)) {
    $notification->push(_("The request was incomplete. Some parameters that are necessary to accept or decline an event are missing."), 'horde.error', array('sticky'));
    $title = '';
} else {
    try {
        if (empty($uid)) {
            $event = Kronolith::getDriver(null, $cal)->getEvent($id);
        } else {
            $event = Kronolith::getDriver()->getByUID($uid);
        }
        if (!$event->hasAttendee($user)) {
            $notification->push(_("You are not an attendee of the specified event."), 'horde.error', array('sticky'));
            $title = $event->getTitle();
        } else {
            $event->addAttendee($user, Kronolith::PART_IGNORE, $action);
            try {
                $event->save();
                if (!empty($msg)) {
                    $notification->push($msg, 'horde.success', array('sticky'));
                }
            } catch (Exception $e) {
                $notification->push($e, 'horde.error', array('sticky'));
            }
            $title = $event->getTitle();
コード例 #20
0
ファイル: Base.php プロジェクト: raz0rsdge/horde
 /**
  * Get a storage driver instance for the resource.
  *
  * @return Kronolith_Driver_Resource_* object.
  */
 public function getDriver()
 {
     if (!$this->get('calendar')) {
         return Kronolith::getDriver('Resource');
     } else {
         return Kronolith::getDriver('Resource', $this->get('calendar'));
     }
 }
コード例 #21
0
ファイル: Remote.php プロジェクト: DSNS-LAB/Dmail
 /**
  * Encapsulates permissions checking.
  *
  * @param integer $permission  The permission to check for.
  * @param string $user         The user to check permissions for. Defaults
  *                             to the current user.
  * @param string $creator      An event creator, to check for creator
  *                             permissions.
  *
  * @return boolean  Whether the user has the permission on this calendar.
  */
 public function hasPermission($permission, $user = null, $creator = null)
 {
     return (bool) (Kronolith::getDriver('Ical', $this->_url)->getPermission() & $permission);
 }
コード例 #22
0
ファイル: edit.php プロジェクト: horde/horde
    }
} catch (Exception $e) {
    $notification->push($e);
    $default->redirect();
}
$form = new Kronolith_Form_EditResource($vars, $resource);
// Execute if the form is valid.
if ($form->validate($vars)) {
    $original_name = $resource->get('name');
    try {
        $result = $form->execute();
        if ($result->get('name') != $original_name) {
            $notification->push(sprintf(_("The resource \"%s\" has been renamed to \"%s\"."), $original_name, $resource->get('name')), 'horde.success');
        } else {
            $notification->push(sprintf(_("The resource \"%s\" has been saved."), $original_name), 'horde.success');
        }
        $default->redirect();
    } catch (Exception $e) {
        $notification->push($e);
    }
}
$vars->set('name', $resource->get('name'));
$vars->set('email', $resource->get('email'));
$vars->set('description', $resource->get('description'));
$vars->set('category', Kronolith::getDriver('Resource')->getGroupMemberships($resource->getId()));
$vars->set('responsetype', $resource->get('response_type'));
$page_output->header(array('title' => $form->getTitle()));
require KRONOLITH_TEMPLATES . '/javascript_defs.php';
$notification->notify(array('listeners' => 'status'));
echo $form->renderActive($form->getRenderer(), $vars, Horde::url('resources/edit.php'), 'post');
$page_output->footer();
コード例 #23
0
ファイル: Driver.php プロジェクト: jubinpatel/horde
 /**
  * Deletes an event.
  *
  * @param mixed $eventId   Either the event id to delete, or the event
  *                         object.
  * @param boolean $silent  Don't send notifications, used when deleting
  *                         events in bulk from maintenance tasks.
  *
  * @throws Kronolith_Exception
  * @throws Horde_Exception_NotFound
  * @throws Horde_Mime_Exception
  */
 public function deleteEvent($eventId, $silent = false)
 {
     $event = $this->_deleteEvent($eventId, $silent);
     if (!$event) {
         return;
     }
     /* Log the deletion of this item in the history log. */
     if ($event->uid) {
         try {
             $GLOBALS['injector']->getInstance('Horde_History')->log('kronolith:' . $this->calendar . ':' . $event->uid, array('action' => 'delete'), true);
         } catch (Exception $e) {
             Horde::log($e, 'ERR');
         }
     }
     /* Remove the event from any resources that are attached to it. */
     $resources = $event->getResources();
     if (count($resources)) {
         $rd = Kronolith::getDriver('Resource');
         foreach ($resources as $uid => $resource) {
             if ($resource['response'] !== Kronolith::RESPONSE_DECLINED && $resource['response'] !== Kronolith::RESPONSE_NONE) {
                 $r = $rd->getResource($uid);
                 $r->removeEvent($event);
             }
         }
     }
     /* Remove any pending alarms. */
     $GLOBALS['injector']->getInstance('Horde_Alarm')->delete($event->uid);
     /* Remove any tags */
     $tagger = Kronolith::getTagger();
     $tagger->replaceTags($event->uid, array(), $event->creator, Kronolith_Tagger::TYPE_EVENT);
     /* Remove any geolocation data. */
     try {
         $GLOBALS['injector']->getInstance('Kronolith_Geo')->deleteLocation($event->id);
     } catch (Kronolith_Exception $e) {
     }
     /* Remove any CalDAV mappings. */
     try {
         $GLOBALS['injector']->getInstance('Horde_Dav_Storage')->deleteInternalObjectId($event->id, $event->calendar);
     } catch (Horde_Exception $e) {
         Horde::log($e);
     }
     /* See if this event represents an exception - if so, touch the base
      * event's history. The $isRecurring check is to prevent an infinite
      * loop in the off chance that an exception is entered as a recurring
      * event.
      */
     if ($event->baseid && !$event->recurs()) {
         try {
             $GLOBALS['injector']->getInstance('Horde_History')->log('kronolith:' . $this->calendar . ':' . $event->baseid, array('action' => 'modify'), true);
         } catch (Exception $e) {
             Horde::log($e, 'ERR');
         }
     }
 }
コード例 #24
0
ファイル: Handler.php プロジェクト: kossamums/horde
 /**
  * Returns the driver object for a calendar.
  *
  * @param string $cal  A calendar string in the format "type|name".
  *
  * @return Kronolith_Driver|boolean  A driver instance or false on failure.
  */
 protected function _getDriver($cal)
 {
     list($driver, $calendar) = explode('|', $cal);
     if ($driver == 'internal' && !Kronolith::hasPermission($calendar, Horde_Perms::SHOW)) {
         $GLOBALS['notification']->push(_("Permission Denied"), 'horde.error');
         return false;
     }
     try {
         $kronolith_driver = Kronolith::getDriver($driver, $calendar);
     } catch (Exception $e) {
         $GLOBALS['notification']->push($e, 'horde.error');
         return false;
     }
     if ($driver == 'remote') {
         $kronolith_driver->setParam('timeout', 15);
     }
     return $kronolith_driver;
 }
コード例 #25
0
ファイル: add.php プロジェクト: DSNS-LAB/Dmail
             break 2;
     }
     if ($user == $GLOBALS['registry']->getAuth() && !$kronolith_calendar->hasPermission(Horde_Perms::EDIT)) {
         $notification->push(_("You do not have permission to add events to this calendar."), 'horde.warning');
         break;
     }
     if ($user != $GLOBALS['registry']->getAuth() && !$kronolith_calendar->hasPermission(Kronolith::PERMS_DELEGATE)) {
         $notification->push(_("You do not have permission to delegate events to this user."), 'horde.warning');
         break;
     }
     $perms = $GLOBALS['injector']->getInstance('Horde_Core_Perms');
     if ($perms->hasAppPermission('max_events') !== true && $perms->hasAppPermission('max_events') <= Kronolith::countEvents()) {
         Horde::permissionDeniedError('kronolith', 'max_events', sprintf(_("You are not allowed to create more than %d events."), $perms->hasAppPermission('max_events')));
         break;
     }
     $event = Kronolith::getDriver($targetType, $calendar_id)->getEvent();
     $event->readForm();
     try {
         $event->save();
         Kronolith::notifyOfResourceRejection($event);
         if (Horde_Util::getFormData('sendupdates', false)) {
             try {
                 Kronolith::sendITipNotifications($event, $notification, Kronolith::ITIP_REQUEST);
             } catch (Exception $e) {
                 $notification->push($e, 'horde.error');
             }
         }
     } catch (Exception $e) {
         $notification->push(sprintf(_("There was an error adding the event: %s"), $e->getMessage()), 'horde.error');
     }
 } catch (Exception $e) {
コード例 #26
0
ファイル: Application.php プロジェクト: horde/horde
 /**
  */
 public function davDeleteObject($collection, $object)
 {
     $dav = $GLOBALS['injector']->getInstance('Horde_Dav_Storage');
     $internal = $dav->getInternalCollectionId($collection, 'calendar') ?: $collection;
     if (!Kronolith::hasPermission($internal, Horde_Perms::DELETE)) {
         throw new Kronolith_Exception(_("Calendar does not exist or no permission to delete"));
     }
     try {
         $object = $dav->getInternalObjectId($object, $internal) ?: preg_replace('/\\.ics$/', '', $object);
     } catch (Horde_Dav_Exception $e) {
     }
     $kronolith_driver = Kronolith::getDriver(null, $internal);
     $event = $kronolith_driver->getEvent($object);
     $kronolith_driver->deleteEvent($object);
     try {
         $dav->deleteExternalObjectId($object, $internal);
     } catch (Horde_Dav_Exception $e) {
     }
     // Send iTip messages unless organizer is external.
     // Notifications will get lost, there is no way to return messages to
     // clients.
     if ($event->organizer && !Kronolith::isUserEmail($event->creator, $event->organizer)) {
         return;
     }
     Kronolith::sendITipNotifications($event, new Horde_Notification_Handler(new Horde_Notification_Storage_Object()), Kronolith::ITIP_CANCEL);
 }
コード例 #27
0
ファイル: calendar.php プロジェクト: jubinpatel/horde
<?php

$auth = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Auth')->create();
$groups = array();
try {
    $groups = $GLOBALS['injector']->getInstance('Horde_Group')->listAll(empty($GLOBALS['conf']['share']['any_group']) ? $GLOBALS['registry']->getAuth() : null);
    asort($groups);
} catch (Horde_Group_Exception $e) {
}
$file_upload = $GLOBALS['browser']->allowFileUploads();
if (!empty($GLOBALS['conf']['resource']['driver'])) {
    $resources = Kronolith::getDriver('Resource')->listResources(Horde_Perms::READ, array('type' => Kronolith_Resource::TYPE_SINGLE));
    $resource_enum = array();
    foreach ($resources as $resource) {
        $resource_enum[$resource->getId()] = htmlspecialchars($resource->get('name'));
    }
}
$accountUrl = $GLOBALS['registry']->get('webroot', 'horde');
if (isset($GLOBALS['conf']['urls']['pretty']) && $GLOBALS['conf']['urls']['pretty'] == 'rewrite') {
    $accountUrl .= '/rpc/';
} else {
    $accountUrl .= '/rpc.php/';
}
$accountUrl = Horde::url($accountUrl, true, -1) . 'principals/' . $GLOBALS['registry']->getAuth() . '/';
?>
<div id="kronolithCalendarDialog" class="kronolithDialog">

<form id="kronolithCalendarForminternal" method="post" action="<?php 
echo Horde::url('data.php');
?>
"<?php 
コード例 #28
0
ファイル: delete.php プロジェクト: horde/horde
 * Copyright 1999-2016 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file COPYING for license information (GPL). If you
 * did not receive this file, see http://www.horde.org/licenses/gpl.
 *
 * @author  Chuck Hagenbuch <*****@*****.**>
 * @package Kronolith
 */
require_once __DIR__ . '/lib/Application.php';
Horde_Registry::appInit('kronolith');
if (Kronolith::showAjaxView()) {
    Horde::url('', true)->redirect();
}
$c = Horde_Util::getFormData('calendar');
$driver = Horde_Util::getFormData('type');
$kronolith_driver = Kronolith::getDriver($driver, $c);
if ($eventID = Horde_Util::getFormData('eventID')) {
    try {
        $event = $kronolith_driver->getEvent($eventID);
    } catch (Exception $e) {
        if (($url = Horde_Util::getFormData('url')) === null) {
            $url = Horde::url($prefs->getValue('defaultview') . '.php', true);
        } else {
            $url = new Horde_Url($url);
        }
        $url->redirect();
    }
    if ($driver != 'resource') {
        if ($driver == 'remote') {
            /* The remote server is doing the permission checks for us. */
            $have_perms = true;
コード例 #29
0
ファイル: delete.php プロジェクト: horde/horde
 *
 * See the enclosed file COPYING for license information (GPL). If you
 * did not receive this file, see http://www.horde.org/licenses/gpl.
 *
 * @author Chuck Hagenbuch <*****@*****.**>
 */
require_once __DIR__ . '/../../lib/Application.php';
Horde_Registry::appInit('kronolith');
// Exit if this isn't an authenticated administrative user.
$default = Horde::url($prefs->getValue('defaultview') . '.php', true);
if (!$registry->isAdmin()) {
    $default->redirect();
}
$vars = Horde_Variables::getDefaultVariables();
try {
    $resource = Kronolith::getDriver('Resource')->getResource($vars->get('c'));
    if (!$resource->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE)) {
        $notification->push(_("You are not allowed to delete this resource group."), 'horde.error');
        $default->redirect();
    }
} catch (Exception $e) {
    $notification->push($e);
    $default->redirect();
}
$form = new Kronolith_Form_DeleteResourceGroup($vars, $resource);
// Execute if the form is valid (must pass with POST variables only).
if ($form->validate(new Horde_Variables($_POST))) {
    try {
        $form->execute();
        $notification->push(sprintf(_("The resource group \"%s\" has been deleted."), $resource->get('name')), 'horde.success');
    } catch (Exception $e) {
コード例 #30
0
ファイル: search.php プロジェクト: horde/horde
        if ($range == '+') {
            $event->start = new Horde_Date($time1);
            $event->end = null;
        } elseif ($range == '-') {
            $event->start = null;
            $event->end = new Horde_Date($time1);
        } else {
            $time2 = $time1 + $range;
            $event->start = new Horde_Date(min($time1, $time2));
            $event->end = new Horde_Date(max($time1, $time2));
        }
        $events = Kronolith::search($event);
    }
} else {
    /* Make a new empty event object with default values. */
    $event = Kronolith::getDriver($search_calendar[0], $search_calendar[1])->getEvent();
    $event->title = $event->location = $event->status = $event->description = null;
    /* Set start on today, stop on tomorrow. */
    $event->start = new Horde_Date(mktime(0, 0, 0));
    $event->end = new Horde_Date($event->start);
    $event->end->mday++;
    /* We need to set the event to initialized, otherwise we will end up with
     * a default end date. */
    $event->initialized = true;
    if (Horde_Util::getFormData('actionID') == 'search_calendar') {
        $event->readForm();
        if (Horde_Util::getFormData('status') == Kronolith::STATUS_NONE) {
            $event->status = null;
        }
        $events = Kronolith::search($event, $search_calendar[1] == '__any' ? null : $search_calendar[0] . '|' . $search_calendar[1]);
    }