Author: Chuck Hagenbuch (chuck@horde.org)
 /**
  * @throws Kronolith_Exception
  */
 public function execute()
 {
     if ($this->_vars->get('submitbutton') == _("Cancel")) {
         Horde::url($GLOBALS['prefs']->getValue('defaultview') . '.php', true)->redirect();
     }
     return Kronolith::unsubscribeRemoteCalendar($this->_vars->get('url'));
 }
示例#2
0
文件: Ajax.php 项目: jubinpatel/horde
 /**
  * Add base javascript variables to the page.
  */
 protected function _addBaseVars()
 {
     global $conf, $injector, $prefs, $registry;
     $auth_name = $registry->getAuth();
     $has_tasks = Kronolith::hasApiPermission('tasks');
     $identity = $injector->getInstance('Horde_Core_Factory_Identity')->create();
     $app_urls = $js_vars = array();
     if (isset($conf['menu']['apps']) && is_array($conf['menu']['apps'])) {
         foreach ($conf['menu']['apps'] as $app) {
             $app_urls[$app] = strval(Horde::url($registry->getInitialPage($app), true));
         }
     }
     /* Variables used in core javascript files. */
     $js_vars['conf'] = array_filter(array('URI_CALENDAR_EXPORT' => str_replace(array('%23', '%2523', '%7B', '%257B', '%7D', '%257D'), array('#', '#', '{', '{', '}', '}'), strval($registry->downloadUrl('#{calendar}.ics', array('actionID' => 'export', 'all_events' => 1, 'exportID' => Horde_Data::EXPORT_ICALENDAR, 'exportCal' => 'internal_#{calendar}'))->setRaw(true))), 'URI_RESOURCE_EXPORT' => str_replace(array('%23', '%2523', '%7B', '%257B', '%7D', '%257D'), array('#', '#', '{', '{', '}', '}'), strval($registry->downloadUrl('#{calendar}.ics', array('actionID' => 'export', 'all_events' => 1, 'exportID' => Horde_Data::EXPORT_ICALENDAR, 'exportCal' => 'resource_#{calendar}'))->setRaw(true))), 'URI_EVENT_EXPORT' => str_replace(array('%23', '%7B', '%7D'), array('#', '{', '}'), Horde::url('event.php', true)->add(array('view' => 'ExportEvent', 'eventID' => '#{id}', 'calendar' => '#{calendar}', 'type' => '#{type}'))), 'images' => array('alarm' => strval(Horde_Themes::img('alarm-fff.png')), 'attendees' => strval(Horde_Themes::img('attendees-fff.png')), 'exception' => strval(Horde_Themes::img('exception-fff.png')), 'new_event' => strval(Horde_Themes::img('new.png')), 'new_task' => strval(Horde_Themes::img('new_task.png')), 'recur' => strval(Horde_Themes::img('recur-fff.png'))), 'new_event' => $injector->getInstance('Kronolith_View_Sidebar')->newLink . $injector->getInstance('Kronolith_View_Sidebar')->newText . '</a>', 'new_task' => $injector->getInstance('Kronolith_View_SidebarTasks')->newLink . $injector->getInstance('Kronolith_View_SidebarTasks')->newText . '</a>', 'user' => $registry->convertUsername($auth_name, false), 'name' => $identity->getName(), 'email' => strval($identity->getDefaultFromAddress()), 'prefs_url' => strval($registry->getServiceLink('prefs', 'kronolith')->setRaw(true)), 'app_urls' => $app_urls, 'name' => $registry->get('name'), 'has_tasks' => intval($has_tasks), 'has_resources' => intval(!empty($conf['resource']['driver'])), 'login_view' => $prefs->getValue('defaultview') == 'workweek' ? 'week' : $prefs->getValue('defaultview'), 'default_calendar' => 'internal|' . Kronolith::getDefaultCalendar(Horde_Perms::EDIT), 'max_events' => intval($prefs->getValue('max_events')), 'date_format' => Horde_Core_Script_Package_Datejs::translateFormat(Horde_Nls::getLangInfo(D_FMT)), 'time_format' => $prefs->getValue('twentyFour') ? 'HH:mm' : 'hh:mm tt', 'import_file' => Horde_Data::IMPORT_FILE, 'import_url' => Horde_Data::IMPORT_URL, 'show_time' => Kronolith::viewShowTime(), 'default_alarm' => intval($prefs->getValue('default_alarm')), 'status' => array('cancelled' => Kronolith::STATUS_CANCELLED, 'confirmed' => Kronolith::STATUS_CONFIRMED, 'free' => Kronolith::STATUS_FREE, 'tentative' => Kronolith::STATUS_TENTATIVE), 'recur' => array(Horde_Date_Recurrence::RECUR_NONE => 'None', Horde_Date_Recurrence::RECUR_DAILY => 'Daily', Horde_Date_Recurrence::RECUR_WEEKLY => 'Weekly', Horde_Date_Recurrence::RECUR_MONTHLY_DATE => 'Monthly', Horde_Date_Recurrence::RECUR_MONTHLY_WEEKDAY => 'Monthly', Horde_Date_Recurrence::RECUR_YEARLY_DATE => 'Yearly', Horde_Date_Recurrence::RECUR_YEARLY_DAY => 'Yearly', Horde_Date_Recurrence::RECUR_YEARLY_WEEKDAY => 'Yearly'), 'perms' => array('all' => Horde_Perms::ALL, 'show' => Horde_Perms::SHOW, 'read' => Horde_Perms::READ, 'edit' => Horde_Perms::EDIT, 'delete' => Horde_Perms::DELETE, 'delegate' => Kronolith::PERMS_DELEGATE), 'tasks' => $has_tasks ? $registry->tasks->ajaxDefaults() : null));
     /* Make sure this value is not optimized out by array_filter(). */
     $js_vars['conf']['week_start'] = intval($prefs->getValue('week_start_monday'));
     /* Gettext strings. */
     $js_vars['text'] = array('alarm' => _("Alarm:"), 'alerts' => _("Notifications"), 'allday' => _("All day"), 'delete_calendar' => _("Are you sure you want to delete this calendar and all the events in it?"), 'delete_tasklist' => _("Are you sure you want to delete this task list and all the tasks in it?"), 'external_category' => _("Other events"), 'fix_form_values' => _("Please enter correct values in the form first."), 'geocode_error' => _("Unable to locate requested address"), 'hidelog' => _("Hide Notifications"), 'import_warning' => _("Importing calendar data. This may take a while..."), 'more' => _("more..."), 'no_assignee' => _("None"), 'no_calendar_title' => _("The calendar title must not be empty."), 'no_parent' => _("No parent task"), 'no_tasklist_title' => _("The task list title must not be empty."), 'no_url' => _("You must specify a URL."), 'prefs' => _("Preferences"), 'searching' => sprintf(_("Events matching \"%s\""), '#{term}'), 'shared' => _("Shared"), 'tasks' => _("Tasks"), 'unknown_resource' => _("Unknown resource."), 'wrong_auth' => _("The authentication information you specified wasn't accepted."), 'wrong_date_format' => sprintf(_("You used an unknown date format \"%s\". Please try something like \"%s\"."), '#{wrong}', '#{right}'), 'wrong_time_format' => sprintf(_("You used an unknown time format \"%s\". Please try something like \"%s\"."), '#{wrong}', '#{right}'));
     for ($i = 1; $i <= 12; ++$i) {
         $js_vars['text']['month'][$i - 1] = Horde_Nls::getLangInfo(constant('MON_' . $i));
     }
     for ($i = 1; $i <= 7; ++$i) {
         $js_vars['text']['weekday'][$i] = Horde_Nls::getLangInfo(constant('DAY_' . $i));
     }
     foreach (array_diff(array_keys($js_vars['conf']['recur']), array(Horde_Date_Recurrence::RECUR_NONE)) as $recurType) {
         $js_vars['text']['recur'][$recurType] = Kronolith::recurToString($recurType);
     }
     $js_vars['text']['recur']['exception'] = _("Exception");
     // Maps
     $js_vars['conf']['maps'] = $conf['maps'];
     return $js_vars;
 }
示例#3
0
 /**
  * @throws Kronolith_Exception
  */
 public function execute()
 {
     if ($this->_vars->get('submitbutton') == _("Cancel")) {
         Horde::url($GLOBALS['prefs']->getValue('defaultview') . '.php', true)->redirect();
     }
     Kronolith::deleteShare($this->_calendar);
 }
示例#4
0
 /**
  * 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);
 }
示例#5
0
文件: Base.php 项目: DSNS-LAB/Dmail
 /**
  * Create the default calendar share for the current user.
  *
  * @return Horde_Share_Object The new default share.
  */
 public function createDefaultShare()
 {
     $share = $this->_shares->newShare($this->_user, strval(new Horde_Support_Randomid()), $this->_getDefaultShareName());
     $share->set('color', Kronolith::randomColor());
     $this->_prepareDefaultShare($share);
     $this->_shares->addShare($share);
     return $share;
 }
示例#6
0
 /**
  */
 protected function _getAddressbookSearchParams()
 {
     $params = Kronolith::getAddressbookSearchParams();
     $ob = new stdClass();
     $ob->fields = $params['fields'];
     $ob->sources = $params['sources'];
     return $ob;
 }
示例#7
0
 /**
  * @throws Kronolith_Exception
  */
 public function execute()
 {
     $info = array();
     foreach (array('name', 'color', 'description', 'tags', 'system') as $key) {
         $info[$key] = $this->_vars->get($key);
     }
     return Kronolith::addShare($info);
 }
示例#8
0
 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';
 }
示例#9
0
文件: edit.php 项目: jubinpatel/horde
function _check_max()
{
    $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')));
        return false;
    }
    return true;
}
示例#10
0
 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';
 }
示例#11
0
 /**
  * @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;
     }
 }
示例#12
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;
 }
示例#13
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")));
 }
示例#14
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']);
 }
示例#15
0
文件: Event.php 项目: DSNS-LAB/Dmail
 public function html($active = true)
 {
     if (!$this->_event) {
         echo '<h3>' . _("Event not found") . '</h3>';
         exit;
     }
     if (is_string($this->_event)) {
         echo '<h3>' . $this->_event . '</h3>';
         exit;
     }
     global $conf, $prefs;
     $this->_event->loadHistory();
     $creatorId = $this->_event->creator;
     $description = $this->_event->description;
     $location = $this->_event->location;
     $eventurl = $this->_event->url;
     $private = $this->_event->isPrivate();
     $owner = Kronolith::getUserName($creatorId);
     $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;
         $year = $datetime->year;
     } else {
         $month = (int) Horde_Util::getFormData('month', date('n'));
         $year = (int) Horde_Util::getFormData('year', date('Y'));
     }
     $dateFormat = $prefs->getValue('date_format');
     $timeFormat = $prefs->getValue('twentyFour') ? 'G:i' : 'g:ia';
     // Tags
     $tags = implode(', ', $this->_event->tags);
     echo '<div id="Event"' . ($active ? '' : ' style="display:none"') . '>';
     require KRONOLITH_TEMPLATES . '/view/view.inc';
     echo '</div>';
     if ($active && $GLOBALS['browser']->hasFeature('dom')) {
         /* We check for read permissions, because we can always save a
          * copy if we can read the event. */
         if ($this->_event->hasPermission(Horde_Perms::READ) && Kronolith::getDefaultCalendar(Horde_Perms::EDIT)) {
             $edit = new Kronolith_View_EditEvent($this->_event);
             $edit->html(false);
         }
         if ($this->_event->hasPermission(Horde_Perms::DELETE)) {
             $delete = new Kronolith_View_DeleteEvent($this->_event);
             $delete->html(false);
         }
     }
 }
示例#16
0
文件: Year.php 项目: DSNS-LAB/Dmail
 /**
  *
  * @param Horde_Date $date
  *
  * @return Kronolith_View_Year
  */
 public function __construct(Horde_Date $date)
 {
     $this->year = $date->year;
     $startDate = new Horde_Date(array('year' => $this->year, 'month' => 1, 'mday' => 1));
     $endDate = new Horde_Date(array('year' => $this->year, 'month' => 12, 'mday' => 31));
     try {
         $this->_events = Kronolith::listEvents($startDate, $endDate, $GLOBALS['calendar_manager']->get(Kronolith::DISPLAY_CALENDARS));
     } catch (Exception $e) {
         $GLOBALS['notification']->push($e, 'horde.error');
         $this->_events = array();
     }
     if (!is_array($this->_events)) {
         $this->_events = array();
     }
 }
示例#17
0
 /**
  * @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"))));
 }
示例#18
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()));
     }
 }
示例#19
0
 /**
  * @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();
         }
     }
 }
示例#20
0
 /**
  * @throws Kronolith_Exception
  */
 public function execute()
 {
     switch ($this->_vars->submitbutton) {
         case _("Save"):
             $info = array();
             foreach (array('name', 'new_url', 'user', 'password', 'color', 'desc') as $key) {
                 $info[$key == 'new_url' ? 'url' : $key] = $this->_vars->get($key);
             }
             Kronolith::subscribeRemoteCalendar($info, trim($this->_vars->get('url')));
             break;
         case _("Unsubscribe"):
             Horde::url('calendars/remote_unsubscribe.php')->add('url', $this->_vars->url)->redirect();
             break;
         case _("Cancel"):
             Horde::url($GLOBALS['prefs']->getValue('defaultview') . '.php', true)->redirect();
             break;
     }
 }
示例#21
0
 /**
  * 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;
 }
示例#22
0
文件: Tasks.php 项目: horde/horde
 /**
  * Returns a hash representing this calendar.
  *
  * @return array  A simple hash.
  */
 public function toHash()
 {
     global $calendar_manager, $conf, $injector, $registry;
     $owner = $registry->getAuth() && $this->_share->get('owner') == $registry->getAuth();
     $hash = parent::toHash();
     $hash['name'] = Kronolith::getLabel($this->_share);
     $hash['desc'] = (string) $this->_share->get('desc');
     $hash['owner'] = $owner;
     $hash['users'] = Kronolith::listShareUsers($this->_share);
     $hash['fg'] = Kronolith::foregroundColor($this->_share);
     $hash['bg'] = Kronolith::backgroundColor($this->_share);
     $hash['show'] = in_array('tasks/' . $this->_share->getName(), $calendar_manager->get(Kronolith::DISPLAY_EXTERNAL_CALENDARS));
     $hash['edit'] = $this->_share->hasPermission($registry->getAuth(), Horde_Perms::EDIT);
     $hash['caldav'] = $this->caldavUrl();
     $hash['sub'] = Horde::url($registry->get('webroot', 'horde') . ($conf['urls']['pretty'] == 'rewrite' ? '/rpc/nag/' : '/rpc.php/nag/'), true, -1) . ($this->_share->get('owner') ? $registry->convertUsername($this->_share->get('owner'), false) : '-system-') . '/' . $this->_share->getName() . '.ics';
     if ($owner) {
         $hash['perms'] = Kronolith::permissionToJson($this->_share->getPermission(), is_null($this->_share->get('owner')));
     }
     return $hash;
 }
示例#23
0
 /**
  * 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')));
 }
示例#24
0
 public function html($active = true)
 {
     if (!$this->_event) {
         echo '<h3>' . _("Event not found") . '</h3>';
         exit;
     }
     if (is_string($this->_event)) {
         echo '<h3>' . $this->_event . '</h3>';
         exit;
     }
     if ($datetime = Horde_Util::getFormData('datetime')) {
         $datetime = new Horde_Date($datetime);
         $month = $datetime->month;
         $year = $datetime->year;
         $day = $datetime->mday;
     } else {
         $month = Horde_Util::getFormData('month', date('n'));
         $day = Horde_Util::getFormData('mday', date('j'));
         $year = Horde_Util::getFormData('year', date('Y'));
     }
     $url = Horde_Util::getFormData('url');
     echo '<div id="DeleteEvent"' . ($active ? '' : ' style="display:none"') . '>';
     if (!$this->_event->recurs()) {
         require KRONOLITH_TEMPLATES . '/delete/one.inc';
     } else {
         require KRONOLITH_TEMPLATES . '/delete/delete.inc';
     }
     echo '</div>';
     if ($active && $GLOBALS['browser']->hasFeature('dom')) {
         if ($this->_event->hasPermission(Horde_Perms::READ)) {
             $view = new Kronolith_View_Event($this->_event);
             $view->html(false);
         }
         if ($this->_event->hasPermission(Horde_Perms::READ) && Kronolith::getDefaultCalendar(Horde_Perms::EDIT)) {
             $edit = new Kronolith_View_EditEvent($this->_event);
             $edit->html(false);
         }
     }
 }
示例#25
0
 /**
  * Lists all events in the time range, optionally restricting results to
  * only events with alarms.
  *
  * @param Horde_Date $startDate  The start of range date.
  * @param Horde_Date $endDate    The end of date range.
  * @param array $options         Additional options:
  *   - show_recurrence: (boolean) Return every instance of a recurring
  *                       event?
  *                      DEFAULT: false (Only return recurring events once
  *                      inside $startDate - $endDate range)
  *   - has_alarm:       (boolean) Only return events with alarms.
  *                      DEFAULT: false (Return all events)
  *   - json:            (boolean) Store the results of the event's toJson()
  *                      method?
  *                      DEFAULT: false
  *   - cover_dates:     (boolean) Add the events to all days that they
  *                      cover?
  *                      DEFAULT: true
  *   - hide_exceptions: (boolean) Hide events that represent exceptions to
  *                      a recurring event.
  *                      DEFAULT: false (Do not hide exception events)
  *   - fetch_tags:      (boolean) Fetch tags for all events.
  *                      DEFAULT: false (Do not fetch event tags)
  *
  * @throws Kronolith_Exception
  */
 protected function _listEvents(Horde_Date $startDate = null, Horde_Date $endDate = null, array $options = array())
 {
     if (!class_exists('Date_Holidays')) {
         Horde::log('Support for Date_Holidays has been enabled but the package seems to be missing.', 'ERR');
         return array();
     }
     if (is_null($startDate) && !is_null($endDate)) {
         $startDate = clone $endDate;
         $startDate->year--;
     }
     if (is_null($endDate) && !is_null($startDate)) {
         $endDate = clone $startDate;
         $endDate->year++;
     }
     if ($options['has_alarm'] || is_null($startDate) || is_null($endDate)) {
         return array();
     }
     $startDate = clone $startDate;
     $startDate->hour = $startDate->min = $startDate->sec = 0;
     $endDate = clone $endDate;
     $endDate->hour = 23;
     $endDate->min = $endDate->sec = 59;
     Date_Holidays::staticSetProperty('DIE_ON_MISSING_LOCALE', false);
     $results = array();
     for ($year = $startDate->year; $year <= $endDate->year; $year++) {
         $dh = Date_Holidays::factory($this->calendar, $year, $this->_params['language']);
         if (Date_Holidays::isError($dh)) {
             Horde::log(sprintf('Factory was unable to produce driver object for driver %s in year %s with locale %s', $this->calendar, $year, $this->_params['language']), 'ERR');
             continue;
         }
         $dh->addTranslation($this->_params['language']);
         $events = $this->_getEvents($dh, $startDate, $endDate);
         foreach ($events as $event) {
             Kronolith::addEvents($results, $event, $startDate, $endDate, $options['show_recurrence'], $options['json'], $options['cover_dates']);
         }
     }
     return $results;
 }
示例#26
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;
 }
示例#27
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) {
示例#28
0
文件: Week.php 项目: DSNS-LAB/Dmail
 public function html()
 {
     global $prefs;
     $more_timeslots = $prefs->getValue('time_between_days');
     $include_all_events = !$prefs->getValue('show_shared_side_by_side');
     $showLocation = Kronolith::viewShowLocation();
     $showTime = Kronolith::viewShowTime();
     if (!$this->parsed) {
         $this->parse();
     }
     $slots = $this->days[$this->startDay]->slots;
     $cid = 0;
     require KRONOLITH_TEMPLATES . '/week/head.inc';
     if ($this->sidebyside) {
         require KRONOLITH_TEMPLATES . '/week/head_side_by_side.inc';
     }
     echo '</thead><tbody>';
     $event_count = 0;
     for ($j = $this->startDay; $j <= $this->endDay; ++$j) {
         foreach (array_keys($this->_currentCalendars) as $cid) {
             $event_count = max($event_count, count($this->days[$j]->all_day_events[$cid]));
             reset($this->days[$j]->all_day_events[$cid]);
         }
     }
     $row = '';
     for ($j = $this->startDay; $j <= $this->endDay; ++$j) {
         if ($more_timeslots) {
             $row .= '<td class="kronolith-first-col"><span>' . _("All day") . '</span></td>';
         }
         $row .= '<td colspan="' . $this->days[$j]->totalspan . '" valign="top"';
         if ($this->days[$j]->isToday()) {
             $row .= ' class="kronolith-today"';
         } elseif ($this->days[$j]->dayOfWeek() == 0 || $this->days[$j]->dayOfWeek() == 6) {
             $row .= ' class="kronolith-weekend"';
         }
         $row .= '>';
         foreach (array_keys($this->days[$j]->currentCalendars) as $cid) {
             foreach ($this->days[$j]->all_day_events[$cid] as $event) {
                 $row .= '<div class="kronolith-event"' . $event->getCSSColors() . $event->getLink($this->days[$j], true, $this->link(0, true));
                 if (!$event->isPrivate() && $showLocation) {
                     $row .= '<span class="kronolith-location">' . htmlspecialchars($event->getLocation()) . '</span>';
                 }
                 $row .= '</div>';
             }
         }
         $row .= '</td>';
     }
     $first_row = !$more_timeslots;
     $newEventUrl = _("All day");
     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;
     $rows = array();
     $covered = array();
     for ($i = 0; $i < $this->slotsPerDay; ++$i) {
         if ($i >= $day_hour_end && $i > $this->last) {
             break;
         }
         if ($i < $this->first && $i < $day_hour_start) {
             continue;
         }
         $time = Kronolith_View_Day::prefHourFormat($slots[$i]['hour'], $i % $this->slotsPerHour * $this->slotLength);
         $row = '';
         for ($j = $this->startDay; $j <= $this->endDay; ++$j) {
             // Add spacer between days, or timeslots.
             if ($more_timeslots && $j != $this->startDay) {
                 $row .= '<td class="kronolith-first-col"><span>' . $time . '</span></td>';
             }
             if (!count($this->_currentCalendars)) {
                 $row .= '<td>&nbsp;</td>';
             }
             foreach (array_keys($this->_currentCalendars) as $cid) {
                 // Width (sum of colspans) of events for the current time
                 // slot.
                 $hspan = 0;
                 // $hspan + count of empty TDs in the current timeslot.
                 $current_indent = 0;
                 // $current_indent is initialized to the position of the
                 // first available cell of the day.
                 for (; isset($covered[$j][$i][$current_indent]); ++$current_indent) {
                 }
                 foreach ($this->days[$j]->event_matrix[$cid][$i] as $key) {
                     $event =& $this->days[$j]->events[$key];
                     if ($include_all_events || $event->calendar == $cid) {
                         // Since we've made sure that this event's
                         // overlap is a factor of the total span,
                         // we get this event's individual span by
                         // dividing the total span by this event's
                         // overlap.
                         $span = $this->days[$j]->span[$cid] / $event->overlap;
                         // Store the indent we're starting this event at
                         // for future use.
                         if (!isset($event->indent)) {
                             $event->indent = $current_indent;
                         }
                         // If $event->span is set this mean than we
                         // already calculated the width of the event.
                         if (!isset($event->span)) {
                             // If the first node that we would cover is
                             // already covered, we can assume that table
                             // rendering will take care of pushing the
                             // event over. However, if the first node
                             // _isn't_ covered but any others that we
                             // would covered _are_, we only cover the
                             // available nodes.
                             if (!isset($covered[$j][$i][$event->indent])) {
                                 $collision = false;
                                 $available = 0;
                                 for ($y = $event->indent; $y < $span + $event->indent; ++$y) {
                                     if (isset($covered[$j][$i][$y])) {
                                         $collision = true;
                                         break;
                                     }
                                     $available++;
                                 }
                                 if ($collision) {
                                     $span = $available;
                                 }
                             }
                             // We need to store the computed event span
                             // because in some cases it might not be
                             // possible to compute it again (when only the
                             // first half of the event is in colision).
                             // ceil() is needed because of some float
                             // values (bug ?)
                             $event->span = ceil($span);
                         }
                         $hspan += $event->span;
                         $current_indent += $event->span;
                         $start = new Horde_Date(array('hour' => floor($i / $this->slotsPerHour), 'min' => $i % $this->slotsPerHour * $this->slotLength, 'month' => $this->days[$j]->month, 'mday' => $this->days[$j]->mday, 'year' => $this->days[$j]->year));
                         $slot_end = new Horde_Date($start);
                         $slot_end->min += $this->slotLength;
                         if ((!$day_hour_force || $i >= $day_hour_start) && $event->start->compareDateTime($start) >= 0 && $event->start->compareDateTime($slot_end) < 0 || $start->compareDateTime($this->days[$j]) == 0 || $day_hour_force && $i == $day_hour_start) {
                             // Store the nodes that we're covering for
                             // this event in the coverage graph.
                             for ($x = $i; $x < $i + $event->rowspan; ++$x) {
                                 for ($y = $event->indent; $y < $current_indent; ++$y) {
                                     $covered[$j][$x][$y] = true;
                                 }
                             }
                             $row .= '<td class="kronolith-event"' . $event->getCSSColors() . 'valign="top" ' . 'width="' . floor(90 / count($this->days) / count($this->_currentCalendars) * ($span / $this->days[$j]->span[$cid])) . '%" ' . 'colspan="' . $event->span . '" rowspan="' . $event->rowspan . '">' . '<div class="kronolith-event-info">';
                             if ($showTime) {
                                 $row .= '<span class="kronolith-time">' . htmlspecialchars($event->getTimeRange()) . '</span>';
                             }
                             $row .= $event->getLink($this->days[$j], true, $this->link(0, true));
                             if (!$event->isPrivate() && $showLocation) {
                                 $row .= '<span class="kronolith-location">' . htmlspecialchars($event->getLocation()) . '</span>';
                             }
                             $row .= '</div></td>';
                         }
                     }
                 }
                 $diff = $this->days[$j]->span[$cid] - $hspan;
                 if ($diff > 0) {
                     $row .= '<td colspan="' . $diff . '"';
                     if ($this->days[$j]->isToday()) {
                         $row .= ' class="kronolith-today"';
                     } elseif ($this->days[$j]->dayOfWeek() == 0 || $this->days[$j]->dayOfWeek() == 6) {
                         $row .= ' class="kronolith-weekend"';
                     }
                     $row .= '>&nbsp;</td>';
                 }
             }
         }
         $rows[] = array('row' => $row, 'slot' => $time);
     }
     $template = $GLOBALS['injector']->createInstance('Horde_Template');
     $template->set('row_height', round(20 / $this->slotsPerHour));
     $template->set('rows', $rows);
     echo $template->fetch(KRONOLITH_TEMPLATES . '/day/rows.html') . '</tbody></table>';
 }
示例#29
0
 /**
  * Helper function to add tags from a newly creted event to the tagger.
  *
  * @param Kronolith_Event $event  The event to save tags to storage for.
  */
 protected function _addTags(Kronolith_Event $event)
 {
     $tagger = Kronolith::getTagger();
     $tagger->tag($event->uid, $event->tags, $event->creator, Kronolith_Tagger::TYPE_EVENT);
     // Resources don't currently have owners, so can't tag as owner.
     if ($event->calendarType == 'resource') {
         return;
     }
     // Add tags again, but as the share owner.
     try {
         $cal = $GLOBALS['injector']->getInstance('Kronolith_Shares')->getShare($event->calendar);
     } catch (Horde_Share_Exception $e) {
         Horde::log($e->getMessage(), 'ERR');
         throw new Kronolith_Exception($e);
     }
     if ($cal->get('owner') != $event->creator) {
         $tagger->tag($event->uid, $event->tags, $cal->get('owner'), 'event');
     }
 }
示例#30
0
<?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