Ejemplo n.º 1
0
 protected function _hours()
 {
     $hours_html = '';
     $dayWidth = round(100 / $this->_days);
     $week = $this->_start->weekOfYear();
     $span = (7 - $week) % 7 + 1;
     $span_left = $this->_days;
     $t = new Horde_Date($this->_start);
     while ($span_left > 0) {
         $span_left -= $span;
         $week_label = Horde::url('#')->link(array('onclick' => 'return switchDateView(\'Week\',' . $t->dateString() . ');')) . "Week" . ' ' . $week . '</a>';
         $hours_html .= sprintf('<th colspan="%d" width="%s%%">%s</th>', $span, $dayWidth, $week_label);
         $week++;
         $t->mday += 7;
         $span = min($span_left, 7);
     }
     $hours_html .= '</tr><tr><td width="100" class="label">&nbsp;</td>';
     for ($i = 0; $i < $this->_days; $i++) {
         $t = new Horde_Date(array('month' => $this->_start->month, 'mday' => $this->_start->mday + $i, 'year' => $this->_start->year));
         $day_label = Horde::url('#')->link(array('onclick' => 'return switchDateView(\'Day\',' . $t->dateString() . ');')) . ($i + 1) . '.</a>';
         $hours_html .= sprintf('<th width="%s%%">%s</th>', $dayWidth, $day_label);
     }
     for ($i = 0; $i < $this->_days; $i++) {
         $start = new Horde_Date(array('hour' => $this->_startHour, 'month' => $this->_start->month, 'mday' => $this->_start->mday + $i, 'year' => $this->_start->year));
         $end = new Horde_Date(array('hour' => $this->_endHour, 'month' => $this->_start->month, 'mday' => $this->_start->mday + $i, 'year' => $this->_start->year));
         $this->_timeBlocks[] = array($start, $end);
     }
     return $hours_html;
 }
Ejemplo n.º 2
0
 /**
  * Saves the txt_datavalue or int_datavalue depending on context.
  *
  * Folds special data types into a serializable, preferably search-friendly
  * format.
  */
 public function setDataValue($value)
 {
     /* These field-specific handlers should better be delegated to field
      * definitions. */
     switch ($this->property->datatype) {
         case 'date':
         case 'datetime':
         case 'hourminutesecond':
         case 'monthdayyear':
         case 'monthyear':
         case 'time':
             if (is_array($value)) {
                 // Directly passing the array makes funny breakage :(
                 $dt = new Horde_Date();
                 foreach ($value as $marker => $content) {
                     if (strlen($content)) {
                         $dt->{$marker} = $content;
                     }
                 }
                 $value = $dt->datestamp();
             }
             break;
         case 'image':
             $value = $value['hash'];
             break;
     }
     return $this->txt_datavalue = $value;
 }
Ejemplo n.º 3
0
 /**
  * Constructor.
  *
  * @param array $config  Configuration key-value pairs.
  */
 public function __construct($config = array())
 {
     global $prefs, $registry;
     parent::__construct($config);
     $blank = new Horde_Url();
     $this->addNewButton(_("_New Event"), $blank, array('id' => 'kronolithNewEvent'));
     $this->newExtra = $blank->link(array_merge(array('id' => 'kronolithQuickEvent'), Horde::getAccessKeyAndTitle(_("Quick _insert"), false, true)));
     $sidebar = $GLOBALS['injector']->createInstance('Horde_View');
     /* Minical. */
     $today = new Horde_Date($_SERVER['REQUEST_TIME']);
     $sidebar->today = $today->format('F Y');
     $sidebar->weekdays = array();
     for ($i = $prefs->getValue('week_start_monday'), $c = $i + 7; $i < $c; $i++) {
         $weekday = Horde_Nls::getLangInfo(constant('DAY_' . ($i % 7 + 1)));
         $sidebar->weekdays[$weekday] = Horde_String::substr($weekday, 0, 2);
     }
     /* Calendars. */
     $sidebar->newShares = $registry->getAuth() && !$prefs->isLocked('default_share');
     $sidebar->admin = $registry->isAdmin();
     $sidebar->resourceAdmin = $registry->isAdmin() || $GLOBALS['injector']->getInstance('Horde_Core_Perms')->hasAppPermission('resource_management');
     $sidebar->resources = $GLOBALS['conf']['resources']['enabled'];
     $sidebar->addRemote = !$prefs->isLocked('remote_cals');
     $remotes = unserialize($prefs->getValue('remote_cals'));
     $sidebar->showRemote = !($prefs->isLocked('remote_cals') && empty($remotes));
     $this->content = $sidebar->render('dynamic/sidebar');
 }
Ejemplo n.º 4
0
 public function processRequest(Horde_Controller_Request $request, Horde_Controller_Response $response)
 {
     $this->_mapper = $GLOBALS['injector']->getInstance('Horde_Routes_Mapper');
     $this->_matchDict = new Horde_Support_Array($this->_mapper->match($request->getPath()));
     $injector = $this->getInjector();
     switch ($this->_matchDict->action) {
         case 'category':
             $driver = $injector->getInstance('Dolcore_Factory_Driver')->create($injector);
             $categories = $driver->getCategoriesApi();
             $discussionApi = $driver->getDiscussionApi();
             $category = $categories->getCategory($this->_matchDict->category);
             /* Write a category's currently running Umfragen */
             $now = new Horde_Date(time());
             $template = $this->getInjector()->createInstance('Horde_Template');
             $template->set('updated', $now->format(DATE_ATOM));
             $template->set('category_caption', $category->getCaption());
             $template->set('category_id', $category->id);
             $discussions = array();
             foreach ($discussionApi->listDiscussions(array('category' => $category->id)) as $discussion) {
                 $discussions[$discussion->id]['title'] = $discussion->text;
                 $discussions[$discussion->id]['details'] = $discussion->hintergrund;
                 $discussions[$discussion->id]['modified'] = $discussion->erstelldatum;
                 $discussions[$discussion->id]['id'] = Dolcore::getUrlFor('discussion', array('discussion_id' => $discussion->id), true, true);
                 $discussions[$discussion->id]['url'] = Dolcore::getUrlFor('discussion', array('discussion_id' => $discussion->id), true, true);
             }
             $template->set('discussions', $discussions);
             $response->setBody($template->fetch(DOLCORE_TEMPLATES . '/feeds/atom.xml'));
             break;
         case 'categories':
             break;
     }
 }
Ejemplo n.º 5
0
 /**
  * Lists all events in the given time range.     *
  *
  * @param Horde_Date $startDate Start of range date object.
  * @param Horde_Date $endDate   End of range data object.
  *
  * @return array Events in the given time range.
  *
  * @throws Horde_Kolab_FreeBusy_Exception If retrieving the events failed.
  */
 public function listEvents(Horde_Date $startDate, Horde_Date $endDate)
 {
     $this->getLogger()->debug(sprintf('Listing events for resource %s between %s and %s.', $this->getResource()->getName(), (string) $startDate->rfc2822DateTime(), (string) $endDate->rfc2822DateTime()));
     $events = $this->getResource()->listEvents($startDate, $endDate);
     $this->getLogger()->debug(sprintf('Found %s events.', count($events)));
     return $events;
 }
Ejemplo n.º 6
0
 protected function _hours()
 {
     global $prefs;
     $hours_html = '';
     $dayWidth = round(100 / $this->_days);
     $span = floor(($this->_endHour - $this->_startHour) / 3);
     if (($this->_endHour - $this->_startHour) % 3) {
         $span++;
     }
     $date_format = $prefs->getValue('date_format');
     for ($i = 0; $i < $this->_days; $i++) {
         $t = new Horde_Date(array('month' => $this->_start->month, 'mday' => $this->_start->mday + $i, 'year' => $this->_start->year));
         $day_label = Horde::url('#')->link(array('onclick' => 'return switchDateView(\'Day\',' . $t->dateString() . ');')) . $t->strftime($date_format) . '</a>';
         $hours_html .= sprintf('<th colspan="%d" width="%s%%">%s</th>', $span, $dayWidth, $day_label);
     }
     $hours_html .= '</tr><tr><td width="100" class="label">&nbsp;</td>';
     $width = round(100 / ($span * $this->_days));
     for ($i = 0; $i < $this->_days; $i++) {
         for ($h = $this->_startHour; $h < $this->_endHour; $h += 3) {
             $start = new Horde_Date(array('hour' => $h, 'month' => $this->_start->month, 'mday' => $this->_start->mday + $i, 'year' => $this->_start->year));
             $end = new Horde_Date($start);
             $end->hour += 2;
             $end->min = 59;
             $this->_timeBlocks[] = array($start, $end);
             $hour = $start->strftime($prefs->getValue('twentyFour') ? '%H:00' : '%I:00');
             $hours_html .= sprintf('<th width="%d%%">%s</th>', $width, $hour);
         }
     }
     return $hours_html;
 }
Ejemplo n.º 7
0
Archivo: Time.php Proyecto: horde/horde
 /**
  * Return the next past or future Span for the time that this Repeater represents
  *   pointer - Symbol representing which temporal direction to fetch the next day
  *             must be either :past or :future
  */
 public function next($pointer = 'future')
 {
     parent::next($pointer);
     $halfDay = 3600 * 12;
     $fullDay = 3600 * 24;
     $first = false;
     if (!$this->currentTime) {
         $first = true;
         $midnight = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day));
         $yesterdayMidnight = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day - 1));
         $tomorrowMidnight = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day + 1));
         if ($pointer == 'future') {
             if ($this->ambiguous) {
                 foreach (array($midnight->add($this->type), $midnight->add($halfDay + $this->type), $tomorrowMidnight->add($this->type)) as $t) {
                     if ($t->compareDateTime($this->now) >= 0) {
                         $this->currentTime = $t;
                         break;
                     }
                 }
             } else {
                 foreach (array($midnight->add($this->type), $tomorrowMidnight->add($this->type)) as $t) {
                     if ($t->compareDateTime($this->now) >= 0) {
                         $this->currentTime = $t;
                         break;
                     }
                 }
             }
         } elseif ($pointer == 'past') {
             if ($this->ambiguous) {
                 foreach (array($midnight->add($halfDay + $this->type), $midnight->add($this->type), $yesterdayMidnight->add($this->type * 2)) as $t) {
                     if ($t->compareDateTime($this->now) <= 0) {
                         $this->currentTime = $t;
                         break;
                     }
                 }
             } else {
                 foreach (array($midnight->add($this->type), $yesterdayMidnight->add($this->type)) as $t) {
                     if ($t->compareDateTime($this->now) <= 0) {
                         $this->currentTime = $t;
                         break;
                     }
                 }
             }
         }
         if (!$this->currentTime) {
             throw new Horde_Date_Repeater_Exception('Current time cannot be null at this point');
         }
     }
     if (!$first) {
         $increment = $this->ambiguous ? $halfDay : $fullDay;
         $this->currentTime->sec += $pointer == 'future' ? $increment : -$increment;
     }
     return new Horde_Date_Span($this->currentTime, $this->currentTime->add(1));
 }
Ejemplo n.º 8
0
 public function testMethodListeventsHasResultArrayTheEventsInTheGivenTimeSpan()
 {
     $rec_start = new Horde_Date('2009-12-12 10:00:00');
     $rec_end = new Horde_Date('2009-12-12 14:00:00');
     $objects = array(array('uid' => 1, 'sensitivity' => 'public', 'start-date' => $rec_start->timestamp(), 'end-date' => $rec_end->timestamp(), 'recurrence' => array('interval' => 1, 'cycle' => 'daily', 'range-type' => 'none')));
     $resource = $this->_getData($objects);
     $start = new Horde_Date('2009-12-13 0:00:00');
     $end = new Horde_Date('2009-12-14 0:00:00');
     $result = $resource->listEvents($start, $end);
     $this->assertInstanceOf('Horde_Kolab_FreeBusy_Object_Event', $result[0]);
 }
Ejemplo n.º 9
0
 /**
  *
  * @param Horde_Date $start  The start time of the period
  * @param Horde_Date $end   The end time of the period
  *
  * @return array of listTimeObjects arrays.
  */
 public function listTimeObjects(Horde_Date $start = null, Horde_Date $end = null)
 {
     global $conf, $prefs;
     // No need to continue if the forecast days are not in the current
     // range.
     $forecast_start = new Horde_Date(time());
     $forecast_end = clone $forecast_start;
     $forecast_end->mday += 7;
     if ($end->before($forecast_start) || $start->after($forecast_end)) {
         return array();
     }
     $weather = $this->_create();
     $lengths = $weather->getSupportedForecastLengths();
     try {
         $units = $weather->getUnits($weather->units);
         $forecast = $weather->getForecast($this->_location, max(array_keys($lengths)));
         $current = $weather->getCurrentConditions($this->_location);
     } catch (Horde_Service_Weather_Exception $e) {
         throw new Timeobjects_Exception($e);
     }
     $objects = array();
     foreach ($forecast as $data) {
         $day = $data->date;
         $day->hour = 0;
         $day->min = 0;
         $day->sec = 0;
         $day_end = clone $day;
         $day_end->mday++;
         $title = sprintf('%s %d°%s/%d°%s', $data->conditions, $data->high, $units['temp'], $data->low, $units['temp']);
         // Deterine what information we have to display.
         $pop = $data->precipitation_percent === false ? _("N/A") : $data->precipitation_percent . '%';
         if ($forecast->detail == Horde_Service_Weather::FORECAST_TYPE_STANDARD) {
             if ($data->humidity !== false && $data->wind_direction !== false) {
                 $description = sprintf(_("Conditions: %s\nHigh temperature: %d%s\nPrecipitation: %s\nHumidity: %d%%\nWinds: From the %s at %d%s"), _($data->conditions), $data->high, '°' . $units['temp'], $pop, $data->humidity, $data->wind_direction, $data->wind_speed, $units['wind']);
             } else {
                 $description = sprintf(_("Conditions: %s\nHigh temperature: %d%s\nPrecipitation: %s\n"), _($data->conditions), $data->high, '°' . $units['temp'], $pop);
             }
         } elseif ($forecast->detail == Horde_Service_Weather::FORECAST_TYPE_DETAILED) {
             // @TODO
             // No drivers support this yet. AccuWeather will, and possibly
             // wunderground if they accept my request.
         }
         $station = $weather->getStation();
         $body = sprintf(_("Location: %s"), $weather->getStation()->name);
         if (!empty($weather->getStation()->sunrise)) {
             $body .= sprintf(_("Sunrise: %s\nSunset: %s\n"), $weather->getStation()->sunrise, $weather->getStation()->sunset);
         }
         $body .= "\n" . $description;
         $objects[] = array('id' => $day->timestamp(), 'title' => $title, 'description' => $body, 'start' => $day->strftime('%Y-%m-%dT00:00:00'), 'end' => $day_end->strftime('%Y-%m-%dT00:00:00'), 'recurrence' => Horde_Date_Recurrence::RECUR_NONE, 'params' => array(), 'link' => new Horde_Url('#'), 'icon' => (string) Horde_Themes::img('weather/23x23/' . $data->icon));
         $day->mday++;
     }
     return $objects;
 }
Ejemplo n.º 10
0
 /**
  * Outputs the html for a DateGallery tile.
  *
  * @param Ansel_Gallery_Decorator_Date $dgallery  The Ansel_Gallery_Date we are
  *                                     displaying.
  * @param Ansel_Style $style  A style object.
  * @param boolean $mini       Force the use of a mini thumbail?
  * @param array $params       An array containing additional parameters.
  *                            Currently, gallery_view_url and image_view_url
  *                            are used to override the respective urls.
  *                            %g and %i are replaced with image id and
  *                            gallery id, respectively.
  *
  * @return string  The HTML for the tile.
  */
 public function getTile(Ansel_Gallery_Decorator_Date $dgallery, Ansel_Style $style = null, $mini = false, array $params = array())
 {
     $view = $GLOBALS['injector']->createInstance('Horde_View');
     $view->addTemplatePath(ANSEL_TEMPLATES . '/tile');
     // User's preferred date format
     $date_format = $GLOBALS['prefs']->getValue('date_format');
     $date_array = $dgallery->getDate();
     if (empty($date_array['month'])) {
         $date_array['month'] = 1;
     }
     if (empty($date_array['day'])) {
         $date_array['day'] = 1;
     }
     $full_date = new Horde_Date($date_array);
     // Need the unaltered date part array
     $date_array = $dgallery->getDate();
     // Figure out the needed link for the next drill down level. We *must*
     // have at least a year since we are in a date tile.
     if (empty($date_array['month'])) {
         // unit == year
         $view->caption = $full_date->strftime('%Y');
         $next_date = array('year' => (int) $view->caption);
     } elseif (empty($date_array['day'])) {
         // unit == month
         $view->caption = $full_date->strftime('%B %Y');
         $next_date = array('year' => date('Y', $full_date->timestamp()), 'month' => date('n', $full_date->timestamp()));
     } else {
         // unit == day
         $view->caption = $full_date->strftime($date_format);
         $next_date = array('year' => date('Y', $full_date->timestamp()), 'month' => date('n', $full_date->timestamp()), 'day' => date('j', $full_date->timestamp()));
     }
     // Check permissions on the gallery and get appropriate tile image
     if ($dgallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ)) {
         if (is_null($style)) {
             $style = $dgallery->getStyle();
         }
         $thumbstyle = $mini ? 'mini' : 'thumb';
         $view->gallery_image = Ansel::getImageUrl($dgallery->getKeyImage(), $thumbstyle, true, $style);
     } else {
         $view->gallery_image = Horde_Themes::img('thumb-error.png');
     }
     /* Check for being called via the api and generate correct view links */
     if (!isset($params['gallery_view_url'])) {
         if (empty($params['style'])) {
             $gstyle = $dgallery->getStyle();
         } else {
             $gstyle = $params['style'];
         }
         $params = array('gallery' => $dgallery->id, 'view' => 'Gallery', 'slug' => $dgallery->get('slug'));
         $view->view_link = Ansel::getUrlFor('view', array_merge($params, $next_date));
     } else {
         $view->view_link = new Horde_Url(str_replace(array('%g', '%s'), array($dgallery->id, $dgallery->get('slug')), urldecode($params['gallery_view_url'])));
         $view->view_link->add($next_date);
     }
     $view->gallery_count = $dgallery->countImages(true);
     return $view->render('dategallery');
 }
Ejemplo n.º 11
0
 public function getInfo(&$vars, &$var, &$info)
 {
     $due_type = $vars->get('due_type');
     $due = $vars->get('due');
     if (is_array($due)) {
         $due_date = !empty($due['date']) ? $due['date'] : null;
         $due_time = !empty($due['time']) ? $due['time'] : null;
         $due_array = Nag::parseDate("{$due_date} {$due_time}");
         $due_dt = new Horde_Date($due_array);
         $due = $due_dt->timestamp();
     }
     $info = strcasecmp($due_type, 'none') ? $due : 0;
 }
Ejemplo n.º 12
0
 /**
  *
  * @global Horde_Prefs $prefs
  * @param Horde_Date $date
  *
  * @return Kronolith_View_Month
  */
 public function __construct(Horde_Date $date)
 {
     global $prefs;
     $this->month = $date->month;
     $this->year = $date->year;
     // Need to calculate the start and length of the view.
     $this->date = new Horde_Date($date);
     $this->date->mday = 1;
     $this->_startday = $this->date->dayOfWeek();
     $this->_daysInView = Date_Calc::weeksInMonth($this->month, $this->year) * 7;
     if (!$prefs->getValue('week_start_monday')) {
         $this->_startOfView = 1 - $this->_startday;
         // We may need to adjust the number of days in the view if
         // we're starting weeks on Sunday.
         if ($this->_startday == Horde_Date::DATE_SUNDAY) {
             $this->_daysInView -= 7;
         }
         $endday = new Horde_Date(array('mday' => Horde_Date_Utils::daysInMonth($this->month, $this->year), 'month' => $this->month, 'year' => $this->year));
         $endday = $endday->dayOfWeek();
         if ($endday == Horde_Date::DATE_SUNDAY) {
             $this->_daysInView += 7;
         }
     } else {
         if ($this->_startday == Horde_Date::DATE_SUNDAY) {
             $this->_startOfView = -5;
         } else {
             $this->_startOfView = 2 - $this->_startday;
         }
     }
     $startDate = new Horde_Date(array('year' => $this->year, 'month' => $this->month, 'mday' => $this->_startOfView));
     $endDate = new Horde_Date(array('year' => $this->year, 'month' => $this->month, 'mday' => $this->_startOfView + $this->_daysInView));
     if ($prefs->getValue('show_shared_side_by_side')) {
         $allCalendars = Kronolith::listInternalCalendars();
         $this->_currentCalendars = array();
         foreach ($GLOBALS['calendar_manager']->get(Kronolith::DISPLAY_CALENDARS) as $id) {
             $this->_currentCalendars[$id] = $allCalendars[$id];
         }
     } else {
         $this->_currentCalendars = array('internal_0' => true);
     }
     try {
         $this->_events = Kronolith::listEvents($startDate, $endDate);
     } catch (Exception $e) {
         $GLOBALS['notification']->push($e, 'horde.error');
         $this->_events = array();
     }
     if (!is_array($this->_events)) {
         $this->_events = array();
     }
 }
Ejemplo n.º 13
0
Archivo: Day.php Proyecto: horde/horde
 protected function _hours()
 {
     global $prefs;
     $hours_html = '';
     $width = round(100 / ($this->_endHour - $this->_startHour + 1));
     $start = new Horde_Date($this->_start);
     $end = new Horde_Date($this->_start);
     $end->min = 59;
     for ($i = $this->_startHour; $i < $this->_endHour; $i++) {
         $start->hour = $end->hour = $i;
         $this->_timeBlocks[] = array(clone $start, clone $end);
         $hours_html .= '<th width="' . $width . '%">' . $start->strftime($prefs->getValue('twentyFour') ? '%H:00' : '%I:00') . '</th>';
     }
     return $hours_html;
 }
Ejemplo n.º 14
0
 public function getInfo(&$vars, &$var, &$info)
 {
     $start_type = $vars->get('start_date');
     $start = $vars->get('start');
     if (is_array($start)) {
         if (empty($start['date'])) {
             $start = null;
         } else {
             $start_array = Nag::parseDate($start['date'], false);
             $start_dt = new Horde_Date($start_array);
             $start = $start_dt->timestamp();
         }
     }
     $info = strcasecmp($start_type, 'none') ? $start : 0;
 }
Ejemplo n.º 15
0
 /**
  */
 public function display(Horde_Core_Prefs_Ui $ui)
 {
     global $browser, $injector, $page_output, $prefs;
     $page_output->addScriptPackage('IMP_Script_Package_Imp');
     $p_css = new Horde_Themes_Element('prefs.css');
     $page_output->addStylesheet($p_css->fs, $p_css->uri);
     $view = new Horde_View(array('templatePath' => IMP_TEMPLATES . '/prefs'));
     $view->addHelper('Horde_Core_View_Helper_Help');
     if (!Horde::isConnectionSecure()) {
         $view->notsecure = true;
         return $view->render('smimeprivatekey');
     }
     $smime_url = IMP_Basic_Smime::url();
     $view->has_key = $prefs->getValue('smime_public_key') && $prefs->getValue('smime_private_key');
     $view->has_sign_key = $prefs->getValue('smime_public_sign_key') && $prefs->getValue('smime_private_sign_key');
     if ($browser->allowFileUploads()) {
         $view->import = true;
         $page_output->addInlineScript(array('$("import_smime_personal").observe("click", function(e) { ' . Horde::popupJs($smime_url, array('params' => array('actionID' => 'import_personal_certs', 'reload' => base64_encode($ui->selfUrl()->setRaw(true))), 'height' => 450, 'width' => 750, 'urlencode' => true)) . '; e.stop(); })'), true);
     }
     if (!$view->has_key) {
         return $view->render('smimeprivatekey');
     }
     $smime = $injector->getInstance('IMP_Smime');
     foreach (array('' => false, '_sign' => true) as $suffix => $secondary) {
         if ($secondary && !$view->has_sign_key) {
             continue;
         }
         $cert = $smime->parseCert($smime->getPersonalPublicKey($secondary));
         if (!empty($cert['validity']['notafter'])) {
             $expired = new Horde_Date($cert['validity']['notafter']);
             if ($expired->before(time())) {
                 $view->{'expiredate' . $suffix} = $expired->strftime($prefs->getValue('date_format'));
                 $view->{'expiretime' . $suffix} = $expired->strftime($prefs->getValue('time_format'));
             }
         }
         $view->{'viewpublic' . $suffix} = $smime_url->copy()->add('actionID', 'view_personal_public' . $suffix . '_key')->link(array('title' => $secondary ? _("View Secondary Personal Public Certificate") : _("View Personal Public Certificate"), 'target' => 'view_key')) . _("View") . '</a>';
         $view->{'infopublic' . $suffix} = $smime_url->copy()->add('actionID', 'info_personal_public' . $suffix . '_key')->link(array('title' => _("Information on Personal Public Certificate"), 'target' => 'info_key')) . _("Details") . '</a>';
         if ($smime->getPassphrase($secondary)) {
             $view->{'passphrase' . $suffix} = $ui->selfUrl(array('special' => true, 'token' => true))->add('unset_smime' . $suffix . '_passphrase', 1)->link(array('title' => _("Unload Passphrase"))) . _("Unload Passphrase") . '</a>';
         } else {
             $imple = $injector->getInstance('Horde_Core_Factory_Imple')->create('IMP_Ajax_Imple_PassphraseDialog', array('params' => array('reload' => $ui->selfUrl()->setRaw(true), 'secondary' => intval($secondary)), 'type' => 'smimePersonal'));
             $view->{'passphrase' . $suffix} = Horde::link('#', _("Enter Passphrase"), null, null, null, null, null, array('id' => $imple->getDomId())) . _("Enter Passphrase");
         }
         $view->{'viewprivate' . $suffix} = $smime_url->copy()->add('actionID', 'view_personal_private' . $suffix . '_key')->link(array('title' => _("View Secondary Personal Private Key"), 'target' => 'view_key')) . _("View") . '</a>';
         $page_output->addInlineScript(array('$("delete_smime_personal' . $suffix . '").observe("click", function(e) { if (!window.confirm(' . json_encode(_("Are you sure you want to delete your keypair? (This is NOT recommended!)")) . ')) { e.stop(); } })'), true);
     }
     return $view->render('smimeprivatekey');
 }
Ejemplo n.º 16
0
 /**
  */
 protected function _title()
 {
     $title = _("All Calendars");
     $url = Horde::url($GLOBALS['registry']->getInitialPage(), true);
     if (isset($this->_params['calendar']) && $this->_params['calendar'] != '__all') {
         $calendars = Kronolith::listCalendars();
         if (isset($calendars[$this->_params['calendar']])) {
             $title = htmlspecialchars($calendars[$this->_params['calendar']]->name());
         } else {
             $title = _("Calendar not found");
         }
         $url->add('display_cal', $this->_params['calendar']);
     }
     $date = new Horde_Date(time());
     return $title . ', ' . $url->link() . $date->strftime('%B, %Y') . '</a>';
 }
Ejemplo n.º 17
0
 public function __construct(Horde_Date $date)
 {
     $week = $date->weekOfYear();
     $year = $date->year;
     if (!$GLOBALS['prefs']->getValue('week_start_monday') && $date->dayOfWeek() == Horde_Date::DATE_SUNDAY) {
         ++$week;
     }
     if ($week > 51 && $date->month == 1) {
         --$year;
     } elseif ($week == 1 && $date->month == 12) {
         ++$year;
     }
     $this->year = $year;
     $this->week = $week;
     $day = Horde_Date_Utils::firstDayOfWeek($week, $year);
     if (!isset($this->startDay)) {
         if ($GLOBALS['prefs']->getValue('week_start_monday')) {
             $this->startDay = Horde_Date::DATE_MONDAY;
             $this->endDay = Horde_Date::DATE_SUNDAY + 7;
         } else {
             $day->mday--;
             $this->startDay = Horde_Date::DATE_SUNDAY;
             $this->endDay = Horde_Date::DATE_SATURDAY;
         }
     }
     $this->startDate = new Horde_Date($day);
     for ($i = $this->startDay; $i <= $this->endDay; ++$i) {
         $this->days[$i] = new Kronolith_View_Day($day, array());
         $day->mday++;
     }
     $endDate = new Horde_Date($day);
     try {
         $allevents = Kronolith::listEvents($this->startDate, $endDate);
     } catch (Exception $e) {
         $GLOBALS['notification']->push($e, 'horde.error');
         $allevents = array();
     }
     for ($i = $this->startDay; $i <= $this->endDay; ++$i) {
         $date_stamp = $this->days[$i]->dateString();
         $this->days[$i]->events = isset($allevents[$date_stamp]) ? $allevents[$date_stamp] : array();
     }
     $this->sidebyside = $this->days[$this->startDay]->sidebyside;
     $this->_currentCalendars = $this->days[$this->startDay]->currentCalendars;
     $this->slotsPerHour = $this->days[$this->startDay]->slotsPerHour;
     $this->slotsPerDay = $this->days[$this->startDay]->slotsPerDay;
     $this->slotLength = $this->days[$this->startDay]->slotLength;
 }
Ejemplo n.º 18
0
 /**
  * Returns a list of events or tasks.
  *
  * @param integer $folder    A folder ID. If empty, returns objects of all
  *                           visible resources.
  * @param Horde_Date $start  Start date, defaults to epoch.
  * @param Horde_Date $end    End date, defaults to maximum date possible.
  *
  * @return array  List of object hashes.
  * @throws Horde_OpenXchange_Exception.
  */
 protected function _listObjects($folder = null, $start = null, $end = null)
 {
     $this->_login();
     $data = array('session' => $this->_session, 'columns' => implode(',', array_keys($this->_columns)), 'start' => $start ? $start->timestamp() * 1000 : 0, 'end' => $end ? $end->timestamp() * 1000 : PHP_INT_MAX, 'recurrence_master' => true);
     if ($folder) {
         $data['folder'] = $folder;
     }
     $response = $this->_request('GET', $this->_folderType, array('action' => 'all'), $data);
     $events = array();
     foreach ($response['data'] as $event) {
         $map = array();
         foreach (array_values($this->_columns) as $key => $column) {
             $map[$column] = $event[$key];
         }
         $events[] = $map;
     }
     return $events;
 }
Ejemplo n.º 19
0
 /**
  * @dataProvider timezones
  */
 public function testFile($file)
 {
     $result = '';
     $ical = new Horde_Icalendar();
     $ical->parsevCalendar(file_get_contents($file));
     foreach ($ical->getComponents() as $component) {
         if ($component->getType() != 'vEvent') {
             continue;
         }
         $date = $component->getAttribute('DTSTART');
         if (is_array($date)) {
             continue;
         }
         $result .= str_replace("\r", '', $component->getAttribute('SUMMARY')) . "\n";
         $d = new Horde_Date($date);
         $result .= $d->format('H:i') . "\n";
     }
     $this->assertStringEqualsFile(__DIR__ . '/fixtures/vTimezone/' . basename($file, 'ics') . 'txt', $result, 'Failed parsing file ' . basename($file));
 }
Ejemplo n.º 20
0
Archivo: Hour.php Proyecto: horde/horde
 public function this($pointer = 'future')
 {
     parent::this($pointer);
     switch ($pointer) {
         case 'future':
             $hourStart = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day, 'hour' => $this->now->hour, 'min' => $this->now->min + 1));
             $hourEnd = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day, 'hour' => $this->now->hour + 1));
             break;
         case 'past':
             $hourStart = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day, 'hour' => $this->now->hour));
             $hourEnd = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day, 'hour' => $this->now->hour, 'min' => $this->now->min));
             break;
         case 'none':
             $hourStart = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day, 'hour' => $this->now->hour));
             $hourEnd = $hourStart->add(array('hour' => 1));
             break;
     }
     return new Horde_Date_Span($hourStart, $hourEnd);
 }
Ejemplo n.º 21
0
 /**
  *
  * @global Horde_Prefs $prefs
  * @param Horde_Date $date
  *
  * @return Kronolith_View_Month
  */
 public function __construct(Horde_Date $date)
 {
     global $prefs;
     $this->month = $date->month;
     $this->year = $date->year;
     // Need to calculate the start and length of the view.
     $this->date = new Horde_Date($date);
     $this->date->mday = 1;
     $this->_startday = $this->date->dayOfWeek();
     if (!$prefs->getValue('week_start_monday')) {
         $this->_startOfView = 1 - $this->_startday;
     } else {
         if ($this->_startday == Horde_Date::DATE_SUNDAY) {
             $this->_startOfView = -5;
         } else {
             $this->_startOfView = 2 - $this->_startday;
         }
     }
     $startDate = new Horde_Date($this->year, $this->month, $this->_startOfView);
     $this->_endDate = new Horde_Date($this->year, $this->month, Horde_Date_Utils::daysInMonth($this->month, $this->year) + 1);
     $this->_endDate->mday += (7 - ($this->_endDate->format('w') - $prefs->getValue('week_start_monday'))) % 7;
     if ($prefs->getValue('show_shared_side_by_side')) {
         $allCalendars = Kronolith::listInternalCalendars();
         $this->_currentCalendars = array();
         foreach ($GLOBALS['calendar_manager']->get(Kronolith::DISPLAY_CALENDARS) as $id) {
             $this->_currentCalendars[$id] = $allCalendars[$id];
         }
     } else {
         $this->_currentCalendars = array('internal_0' => true);
     }
     try {
         $this->_events = Kronolith::listEvents($startDate, $this->_endDate);
     } catch (Exception $e) {
         $GLOBALS['notification']->push($e, 'horde.error');
         $this->_events = array();
     }
     if (!is_array($this->_events)) {
         $this->_events = array();
     }
 }
Ejemplo n.º 22
0
 /**
  * Search the database for call detail records, taking permissions into
  * consideration.
  *
  * @return array  [0] contains summary statistics; [1] is an array of the
  *                actual call records.
  * @throws Operator_Exception
  */
 public function getRecords($start, $end, $accountcode = null, $dcontext = null, $rowstart = 0, $rowlimit = 100)
 {
     // Start Date
     if (!is_a($start, 'Horde_Date')) {
         $start = new Horde_Date($start);
     }
     // End Date
     if (!is_a($end, 'Horde_Date')) {
         $end = new Horde_Date($end);
     }
     if ($start->compareDate($end) > 0) {
         throw new Operator_Exception(_("\"Start\" date must be on or before \"End\" date."));
     }
     if (empty($accountcode) || $accountcode == '%') {
         $permentry = 'operator:accountcodes';
     } else {
         $permentry = 'operator:accountcodes:' . $accountcode;
     }
     $perms = $GLOBALS['injector']->getInstance('Horde_Perms');
     if ($GLOBALS['registry']->isAdmin() || $perms->hasPermission('operator:accountcodes', $GLOBALS['registry']->getAuth(), Horde_Perms::READ) || $perms->hasPermission($permentry, $GLOBALS['registry']->getAuth(), Horde_Perms::READ)) {
         return $this->_getRecords($start, $end, $accountcode, $dcontext, $rowstart, $rowlimit);
     }
     throw new Operator_Exception(_("You do not have permission to view call detail records for that account code."));
 }
 /**
  * Returns a simple object suitable for json transport representing this
  * object.
  *
  * Possible properties are:
  * - t: type
  * - i: interval
  * - e: end date
  * - c: count
  * - d: data
  * - co: completions
  * - ex: exceptions
  *
  * @return object  A simple object.
  */
 public function toJson()
 {
     $json = new stdClass();
     $json->t = $this->recurType;
     $json->i = $this->recurInterval;
     if ($this->hasRecurEnd()) {
         $json->e = $this->recurEnd->toJson();
     }
     if ($this->recurCount) {
         $json->c = $this->recurCount;
     }
     if ($this->recurData) {
         $json->d = $this->recurData;
     }
     if ($this->completions) {
         $json->co = $this->completions;
     }
     if ($this->exceptions) {
         $json->ex = $this->exceptions;
     }
     return $json;
 }
Ejemplo n.º 24
0
 /**
  * @static
  *
  * @param mixed $date  The date to calculate the difference from. Can be
  *                     either a timestamp integer value, or an array
  *                     with date parts: 'day', 'month', 'year'.
  *
  * @return string
  */
 function getAgo($date)
 {
     if ($date === null) {
         return '';
     }
     try {
         $today = new Horde_Date(time());
         $date = new Horde_Date($date);
         $ago = $date->toDays() - $today->toDays();
     } catch (Horde_Date_Exception $e) {
         return '';
     }
     if ($ago < -1) {
         return sprintf(Horde_Form_Translation::t(" (%s days ago)"), abs($ago));
     } elseif ($ago == -1) {
         return Horde_Form_Translation::t(" (yesterday)");
     } elseif ($ago == 0) {
         return Horde_Form_Translation::t(" (today)");
     } elseif ($ago == 1) {
         return Horde_Form_Translation::t(" (tomorrow)");
     } else {
         return sprintf(Horde_Form_Translation::t(" (in %s days)"), $ago);
     }
 }
Ejemplo n.º 25
0
 public function testToiCalendar()
 {
     $test = new Horde_Date('20100101130000');
     $this->assertEquals('20100101T130000', $test->toiCalendar(true));
     $this->assertEquals('20100101T120000Z', $test->toiCalendar(false));
     $test = new Horde_Date('20100101130000', 'America/Argentina/Buenos_Aires');
     $this->assertEquals('20100101T130000', $test->toiCalendar(true));
     $this->assertEquals('20100101T160000Z', $test->toiCalendar(false));
 }
Ejemplo n.º 26
0
 protected function _fqlToTurba($fields, $result)
 {
     //$remove = array();
     foreach ($fields as $field) {
         if (strpos($field, '.') !== false) {
             $key = substr($field, 0, strpos($field, '.'));
             $subfield = substr($field, strpos($field, '.') + 1);
             $result[$field] = $result[$key][$subfield];
         }
     }
     if (!empty($result['birthday_date'])) {
         // Make sure the birthdate is in a standard format that
         // listDateObjects will understand.
         $bday = new Horde_Date($result['birthday_date']);
         $result['birthday_date'] = $bday->format('Y-m-d');
     }
     return $result;
 }
Ejemplo n.º 27
0
 /**
  * Converts an UTC timestamp like "20061222T110000Z" into a local
  * timestamp like "20061222T130000" using the server timezone.
  *
  * @param array $utc  Array with a datetime string in UTC.
  *
  * @return string  The datetime string converted to the local timezone.
  */
 protected function _convertUTC2LocalTime($utc)
 {
     $date = new Horde_Date($utc[0]);
     $date->setTimezone(date_default_timezone_get());
     return $date->format("Ymd\\THis");
 }
Ejemplo n.º 28
0
 /**
  * Returns a time (max, min, avg) that tickets are in a particular state
  * (open, assigned, etc.).
  *
  * @param string $operation  One of 'max', 'min', or 'avg'.
  * @param string $state      The state to measure - 'open', etc.
  * @param string $group_by   A ticket property by which to group the
  *                           results.
  *
  * @return integer|array  The time value requested, or an array of values,
  *                        if the $group_by parameter has been specified.
  *
  * @throws Whups_Exception
  */
 public function getTime($stat, $group_by = null)
 {
     list($operation, $state) = explode('|', $stat);
     $tickets = $this->_getTicketSet('closed');
     if (!count($tickets)) {
         throw new Whups_Exception(_("There is no data for this report."));
     }
     $dataset = array();
     if (empty($group_by)) {
         $dataset[0] = array();
     }
     foreach ($tickets as $info) {
         if (is_null($info['date_resolved'])) {
             continue;
         }
         switch ($state) {
             case 'open':
                 $date1 = new Horde_Date($info['date_resolved']);
                 $diff = $date1->diff(new Horde_Date($info['timestamp']));
                 if (empty($group_by)) {
                     $dataset[0][] = $diff;
                 } else {
                     if (!isset($info[$group_by])) {
                         continue;
                     }
                     if (!isset($dataset[$info[$group_by]])) {
                         $dataset[$info[$group_by]] = array();
                     }
                     $dataset[$info[$group_by]][] = $diff;
                 }
                 break;
         }
     }
     if (!count($dataset) || is_null($group_by) && !count($dataset[0])) {
         return 'N/A';
     }
     switch ($operation) {
         case 'min':
         case 'max':
             foreach (array_keys($dataset) as $group) {
                 $dataset[$group] = $operation($dataset[$group]);
             }
             break;
         case 'avg':
             foreach (array_keys($dataset) as $group) {
                 $dataset[$group] = round(array_sum($dataset[$group]) / count($dataset[$group]), 2);
             }
             break;
     }
     if (empty($group_by)) {
         $dataset = $dataset[0];
     }
     return $dataset;
 }
Ejemplo n.º 29
0
 /**
  * Creates a new event that represents an exception to a recurring event.
  *
  * @param Kronolith_Event $event  The original recurring event.
  * @param Kronolith_Event $copy   If present, contains a copy of $event, but
  *                                with changes from edited event form.
  * @param stdClass $attributes    The attributes passed from the client.
  *                                Expected to contain rstart and rend or
  *                                rday that represents the original
  *                                starting/ending date of the instance.
  *
  * @return Kronolith_Event  The event representing the exception
  */
 protected function _copyEvent(Kronolith_Event $event, Kronolith_Event $copy = null, $attributes = null)
 {
     if (empty($copy)) {
         $copy = clone $event;
     }
     if ($attributes->rstart) {
         $rstart = new Horde_Date($attributes->rstart);
         $rstart->setTimezone($event->start->timezone);
         $rend = new Horde_Date($attributes->rend);
         $rend->setTimezone($event->end->timezone);
     } else {
         $rstart = new Horde_Date($attributes->rday);
         $rstart->setTimezone($event->start->timezone);
         $rstart->hour = $event->start->hour;
         $rstart->min = $event->start->min;
         $rend = $rstart->add($event->getDuration);
         $rend->setTimezone($event->end->timezone);
         $rend->hour = $event->end->hour;
         $rend->min = $event->end->min;
     }
     $uid = $event->uid;
     $otime = $event->start->strftime('%T');
     // Create new event for the exception
     $nevent = $event->getDriver()->getEvent();
     $nevent->baseid = $uid;
     $nevent->exceptionoriginaldate = new Horde_Date($rstart->strftime('%Y-%m-%d') . 'T' . $otime);
     $nevent->exceptionoriginaldate->setTimezone($event->start->timezone);
     $nevent->creator = $event->creator;
     $nevent->title = $copy->title;
     $nevent->description = $copy->description;
     $nevent->location = $copy->location;
     $nevent->private = $copy->private;
     $nevent->url = $copy->url;
     $nevent->status = $copy->status;
     $nevent->attendees = $copy->attendees;
     $nevent->setResources($copy->getResources());
     $nevent->start = $rstart;
     $nevent->end = $rend;
     $nevent->initialized = true;
     return $nevent;
 }
Ejemplo n.º 30
0
 public function vevent2sif($vcard)
 {
     /* Some special handling for all-day vEvents that are not passed
      * as TYPE=DATE (TYPE=DATE does not exist for vCalendar 1.0) */
     if (preg_match('/(\\r\\n|\\r|\\n)DTSTART:.*T000000(\\r\\n|\\r|\\n)/', $vcard)) {
         if (preg_match('/(\\r\\n|\\r|\\n)DTEND:(\\d\\d\\d\\d)(\\d\\d)(\\d\\d)T235959(\\r\\n|\\r|\\n)/', $vcard, $m)) {
             $vcard = preg_replace('/(\\r\\n|\\r|\\n)DTSTART:(.*)T000000(\\r\\n|\\r|\\n)/', "\$1DTSTART;VALUE=DATE:\$2\$3", $vcard);
             $vcard = preg_replace('/(\\r\\n|\\r|\\n)DTEND:(.*)T235959(\\r\\n|\\r|\\n)/', "\$1DTEND;VALUE=DATE:\$2\$3", $vcard);
         }
         // @TODO: else: handle case with DTEND= T240000
     }
     $iCal = new Horde_Icalendar();
     if (!$iCal->parsevCalendar($vcard)) {
         // @TODO: NEVER use die() in a library.
         die("There was an error importing the data.");
     }
     $components = $iCal->getComponents();
     switch (count($components)) {
         case 0:
             // @TODO: NEVER use die() in a library.
             die("No data was found.");
         case 1:
             $content = $components[0];
             break;
         default:
             // @TODO: NEVER use die() in a library.
             die("Multiple components found; only one is supported.");
     }
     $hash = array('ReminderSet' => 0, 'IsRecurring' => 0, 'BusyStatus' => 2);
     $alarm = $end = null;
     $start = $content->getAttribute('DTSTART');
     $start_params = $content->getAttribute('DTSTART', true);
     if (!empty($start_params[0]['VALUE']) && $start_params[0]['VALUE'] == 'DATE') {
         $hash['AllDayEvent'] = 1;
         $hash['Start'] = sprintf('%04d-%02d-%02d', $start['year'], $start['month'], $start['mday']);
         $start = mktime(0, 0, 0, $start['month'], $start['mday'], $start['year']);
     } else {
         $hash['AllDayEvent'] = 0;
         $hash['Start'] = Horde_Icalendar::_exportDateTime($start);
     }
     foreach ($content->getAllAttributes() as $item) {
         $GLOBALS['backend']->logMessage(sprintf('Sync4j for name %s, value %s', $item['name'], is_string($item['value']) ? $item['value'] : var_export($item['value'], true)), 'DEBUG');
         switch (Horde_String::upper($item['name'])) {
             case 'DTSTART':
                 break;
             case 'DTEND':
                 if (!empty($item['params']['VALUE']) && $item['params']['VALUE'] == 'DATE') {
                     $hash['AllDayEvent'] = 1;
                     $date = new Horde_Date($item['value']['year'], $item['value']['month'], $item['value']['mday']);
                     $date->mday--;
                     $hash['End'] = $date->format('Y-m-d');
                     $end = $date->datestamp();
                 } else {
                     $hash['AllDayEvent'] = 0;
                     $hash['End'] = Horde_Icalendar::_exportDateTime($item['value']);
                     $end = $item['value'];
                 }
                 break;
             case 'SUMMARY':
                 $hash['Subject'] = $item['value'];
                 break;
             case 'DESCRIPTION':
                 $hash['Body'] = $item['value'];
                 break;
             case 'LOCATION':
                 $hash['Location'] = $item['value'];
                 break;
             case 'CATEGORIES':
                 $hash['Categories'] = $item['value'];
                 break;
             case 'AALARM':
                 $hash['ReminderSet'] = 1;
                 $alarm = $item['value'];
                 break;
             case 'STATUS':
                 switch (Horde_String::upper($item['value'])) {
                     case 'FREE':
                     case 'CANCELLED':
                         $hash['BusyStatus'] = 0;
                         break;
                     case 'TENTATIVE':
                         $hash['BusyStatus'] = 1;
                         break;
                     case 'CONFIRMED':
                         $hash['BusyStatus'] = 2;
                         break;
                 }
                 break;
             case 'CLASS':
                 switch (Horde_String::upper($item['value'])) {
                     case 'PUBLIC':
                         $hash['Sensitivity'] = 0;
                         break;
                     case 'PRIVATE':
                         $hash['Sensitivity'] = 2;
                         break;
                     case 'CONFIDENTIAL':
                         $hash['Sensitivity'] = 3;
                         break;
                 }
                 break;
             case 'RRULE':
                 // Parse the recurrence rule into keys and values.
                 $rdata = array();
                 $parts = explode(';', $item['value']);
                 foreach ($parts as $part) {
                     list($key, $value) = explode('=', $part, 2);
                     $rdata[Horde_String::upper($key)] = $value;
                 }
                 if (!isset($rdata['FREQ'])) {
                     break;
                 }
                 $hash['IsRecurring'] = 1;
                 if (isset($rdata['BYDAY'])) {
                     $maskdays = array('SU' => Horde_Date::MASK_SUNDAY, 'MO' => Horde_Date::MASK_MONDAY, 'TU' => Horde_Date::MASK_TUESDAY, 'WE' => Horde_Date::MASK_WEDNESDAY, 'TH' => Horde_Date::MASK_THURSDAY, 'FR' => Horde_Date::MASK_FRIDAY, 'SA' => Horde_Date::MASK_SATURDAY);
                     $days = explode(',', $rdata['BYDAY']);
                     $mask = 0;
                     foreach ($days as $day) {
                         $instance = (int) $day;
                         $mask |= $maskdays[str_replace($instance, '', $day)];
                     }
                 }
                 $hash['Interval'] = isset($rdata['INTERVAL']) ? $rdata['INTERVAL'] : 1;
                 switch (Horde_String::upper($rdata['FREQ'])) {
                     case 'DAILY':
                         $hash['RecurrenceType'] = 0;
                         break;
                     case 'WEEKLY':
                         $hash['RecurrenceType'] = 1;
                         if (isset($rdata['BYDAY'])) {
                             $hash['DayOfWeekMask'] = $mask;
                         }
                         break;
                     case 'MONTHLY':
                         if (isset($rdata['BYDAY'])) {
                             $hash['RecurrenceType'] = 3;
                             $hash['Instance'] = $instance;
                             $hash['DayOfWeekMask'] = $mask;
                         } else {
                             $hash['RecurrenceType'] = 2;
                             $hash['DayOfMonth'] = date('j', $start);
                         }
                         break;
                     case 'YEARLY':
                         if (isset($rdata['BYDAY'])) {
                             $hash['RecurrenceType'] = 6;
                             $hash['Instance'] = $instance;
                             $hash['DayOfWeekMask'] = $mask;
                         } else {
                             $hash['RecurrenceType'] = 5;
                             $hash['DayOfMonth'] = date('j', $start);
                         }
                         $hash['MonthOfYear'] = date('n', $start);
                         unset($hash['Interval']);
                         break;
                 }
                 if (isset($rdata['UNTIL'])) {
                     $hash['NoEndDate'] = 0;
                     $hash['PatternEndDate'] = $rdata['UNTIL'];
                 } elseif (isset($rdata['COUNT'])) {
                     $hash['NoEndDate'] = 0;
                     $hash['Occurrences'] = $rdata['COUNT'];
                 } else {
                     $hash['NoEndDate'] = 1;
                 }
                 break;
             case 'EXDATE':
                 if (empty($hash['Exceptions'])) {
                     $hash['Exceptions'] = array();
                 }
                 foreach ($item['values'] as $date) {
                     if ($hash['AllDayEvent'] == 1) {
                         $d = new Horde_Date(array('year' => $date['year'], 'month' => $date['month'], 'mday' => $date['mday'] + 1));
                         $hash['Exceptions'][] = array('ExcludeDate' => $d->format('Y-m-d'));
                     } else {
                         $hash['Exceptions'][] = array('ExcludeDate' => Horde_Icalendar::_exportDate($date));
                     }
                 }
                 break;
         }
     }
     if (!empty($start)) {
         if ($hash['ReminderSet'] && !empty($alarm) && $start != $alarm) {
             $hash['ReminderMinutesBeforeStart'] = ($start - $alarm) / 60;
         } else {
             // Parse VALARM components.
             foreach ($content->getComponents() as $component) {
                 if ($component->getType() != 'vAlarm') {
                     continue;
                 }
                 try {
                     $trigger = $component->getAttribute('TRIGGER');
                 } catch (Horde_Icalendar_Exception $e) {
                     continue;
                 }
                 if (is_array($trigger) || empty($trigger)) {
                     continue;
                 }
                 $hash['ReminderSet'] = 1;
                 $hash['ReminderMinutesBeforeStart'] = -$trigger / 60;
             }
         }
     }
     if (empty($hash['AllDayEvent']) && !empty($start) && !empty($end) && $start != $end) {
         $hash['Duration'] = ($end - $start) / 60;
         $GLOBALS['backend']->logMessage('Duration set to ' . $hash['Duration'], 'DEBUG');
     }
     return Horde_SyncMl_Device_sync4j::array2sif($hash, '<?xml version="1.0"?><appointment>', '</appointment>');
 }