public function __construct($month = null, $year = null, &$Database)
 {
     $this->Database = $Database;
     //Instantiate the PDO Object
     parent::__construct($month, $year);
     //Call the parent constructor
 }
Ejemplo n.º 2
0
 /**
  * Constructor
  *
  * @param Backend\BackendInterface $caldavBackend
  * @param array $calendarInfo
  */
 function __construct(Backend\BackendInterface $caldavBackend, $calendarInfo)
 {
     $required = ['{http://calendarserver.org/ns/}shared-url', '{http://sabredav.org/ns}owner-principal', '{http://sabredav.org/ns}read-only'];
     foreach ($required as $r) {
         if (!isset($calendarInfo[$r])) {
             throw new \InvalidArgumentException('The ' . $r . ' property must be specified for SharedCalendar(s)');
         }
     }
     parent::__construct($caldavBackend, $calendarInfo);
 }
Ejemplo n.º 3
0
 /**
  * Constructor
  *
  * @access	public
  * @return	null
  */
 public function __construct()
 {
     parent::__construct();
     // -------------------------------------
     //  Grab cached data
     // -------------------------------------
     if (isset($this->cache['CDT'])) {
         foreach ($this->cache['CDT']['default'] as $k => $v) {
             $this->{$k} = $v;
         }
     } else {
         $this->change_date($this->year(), $this->month(), $this->day());
         $this->change_time($this->hour(), $this->minute());
         // -------------------------------------
         //  Cache
         // -------------------------------------
         $this->cache['CDT']['default'] = $this->datetime_array();
     }
 }
Ejemplo n.º 4
0
 /**
  * Конструктор класса
  *
  * @param string $name
  * @param string $module
  * @param array $params
  * @access public
  */
 public function __construct($name, array $params = null)
 {
     parent::__construct($name, $params);
     $this->setCalendar(new CalendarObject($this->getParam('month'), $this->getParam('year')));
     //Отмечаем использованные даты календаря
     $range = $this->calendar->getRange();
     $dateFormat = '"Y-m-d"';
     // Если диапазон календаря заканчивается в будущем - отсекаем до текущего момента
     if ($range->end->getTimestamp() > time()) {
         $endRange = date($dateFormat);
     } else {
         $endRange = $range->end->format($dateFormat);
     }
     $conditions = array_merge(array('post_created>=' . $range->start->format($dateFormat) . ' AND post_created<=' . $endRange), $this->getParam('filter'));
     if ($blogId = (int) $this->getParam('blog_id')) {
         $conditions['blog_id'] = $blogId;
     }
     $existingDates = simplifyDBResult($this->dbh->select('SELECT DISTINCT DATE_FORMAT(post_created, "%Y-%c-%e") as post_date FROM blog_post' . $this->dbh->buildWhereCondition($conditions)), 'post_date');
     if (is_array($existingDates)) {
         foreach ($existingDates as $date) {
             $this->calendar->getItemByDate(\DateTime::createFromFormat('Y-m-d', $date))->setProperty('selected', 'selected');
         }
     }
 }
Ejemplo n.º 5
0
 function __construct()
 {
     parent::__construct('http://www.lkp.pingst.se/kalender');
 }
Ejemplo n.º 6
0
 /**
  * Constructor
  *
  * @access	public
  * @param	array	$data	Array of event data
  * @param	array	$start	Start date info [optional]
  * @param	array	$end	End date info [optional]
  * @param	int		$limit	Limit the number of occurrences to calculate [optional]
  * @return	null
  */
 public function __construct($data, $start = array(), $end = array(), $limit = 0)
 {
     parent::__construct();
     parent::load_calendar_datetime();
     // -------------------------------------
     //  Collect the default data
     // -------------------------------------
     $this->default_data = $data;
     $this->rules = isset($this->default_data['rules']) ? $this->default_data['rules'] : array();
     $this->occurrences = isset($this->default_data['occurrences']) ? $this->default_data['occurrences'] : array();
     $this->exceptions = isset($this->default_data['exceptions']) ? $this->default_data['exceptions'] : array();
     unset($data, $this->default_data['rules'], $this->default_data['occurrences'], $this->default_data['exceptions']);
     $this->limit = $limit == 0 ? $this->limit : $limit;
     // -------------------------------------
     //  If we're only given dates, add the other keys we need
     // -------------------------------------
     if (!isset($data['start_year'])) {
         $dates = $this->CDT->ymd_to_array($this->default_data['start_date']);
         foreach ($dates as $k => $v) {
             $this->default_data['start_' . $k] = $v;
         }
     }
     if (!isset($this->default_data['end_year'])) {
         $dates = $this->CDT->ymd_to_array($this->default_data['end_date']);
         foreach ($dates as $k => $v) {
             $this->default_data['end_' . $k] = $v;
         }
     }
     // -------------------------------------
     //  Make sure we have a start time
     // -------------------------------------
     if (!isset($this->default_data['start_time'])) {
         $this->default_data['start_time'] = '0000';
     } else {
         $this->default_data['start_time'] = str_pad($this->default_data['start_time'], 4, 0, STR_PAD_LEFT);
     }
     // -------------------------------------
     //  Make sure we have an end time
     // -------------------------------------
     if (!isset($this->default_data['end_time'])) {
         $this->default_data['end_time'] = '2359';
     } else {
         $this->default_data['end_time'] = str_pad($this->default_data['end_time'], 4, 0, STR_PAD_LEFT);
     }
     if (isset($this->default_data['start_year'])) {
         $this->event_start = array('year' => $this->default_data['start_year'], 'month' => $this->default_data['start_month'], 'day' => $this->default_data['start_day'], 'ymd' => isset($this->default_data['start_ymd']) ? $this->default_data['start_ymd'] : $this->CDT->make_ymd($this->default_data['start_year'], $this->default_data['start_month'], $this->default_data['start_day']));
     } else {
         $this->event_start = $this->CDT->ymd_to_array($this->default_data['start_date']);
     }
     // -------------------------------------
     //  Use the start data if the equivalent
     //  end data doesn't exist and the event
     //  doesn't recur
     // -------------------------------------
     if (isset($this->default_data['recurs']) and $this->default_data['recurs'] == 'n' and $this->default_data['end_year'] == 0) {
         $this->event_end = array('year' => $this->default_data['start_year'], 'month' => $this->default_data['start_month'], 'day' => $this->default_data['start_day'], 'ymd' => $this->default_data['start_ymd']);
     } else {
         $this->event_end = array('year' => $this->default_data['end_year'], 'month' => $this->default_data['end_month'], 'day' => $this->default_data['end_day'], 'ymd' => isset($this->default_data['end_ymd']) ? $this->default_data['end_ymd'] : $this->CDT->make_ymd($this->default_data['end_year'], $this->default_data['end_month'], $this->default_data['end_day']));
     }
     // -------------------------------------
     //  If $start/$end were given as YMD, convert them
     // -------------------------------------
     if (!is_array($start)) {
         $start = $this->CDT->ymd_to_array($start);
     }
     if (!is_array($end)) {
         $end = $this->CDT->ymd_to_array($end);
     }
     // -------------------------------------
     //  Set the date range
     // -------------------------------------
     if (empty($start) or isset($start['ymd']) and $start['ymd'] == '') {
         $this->range_start = array('year' => $this->event_start['year'], 'month' => $this->event_start['month'], 'day' => $this->event_start['day'], 'ymd' => $this->event_start['ymd'], 'time' => '0000', 'hour' => '00', 'minute' => '00');
     } else {
         $this->range_start = array('year' => $start['year'], 'month' => $start['month'], 'day' => $start['day'], 'ymd' => array_key_exists('ymd', $start) ? $start['ymd'] : $this->CDT->make_ymd($start['year'], $start['month'], $start['day']), 'time' => isset($start['time']) ? $start['time'] : '0000', 'hour' => isset($start['hour']) ? $start['hour'] : '00', 'minute' => isset($start['minute']) ? $start['minute'] : '00');
     }
     //default to event end
     if (empty($end)) {
         $this->range_end = array('year' => $this->event_end['year'], 'month' => $this->event_end['month'], 'day' => $this->event_end['day'], 'ymd' => $this->event_end['ymd'], 'time' => '2359', 'hour' => '23', 'minute' => '59');
     } elseif ($end['year'] == 0) {
         $this->range_end = array('year' => 9999, 'month' => 12, 'day' => 31, 'ymd' => 99991231, 'time' => '2359', 'hour' => '23', 'minute' => '59');
     } else {
         $this->range_end = array('year' => $end['year'], 'month' => $end['month'], 'day' => $end['day'], 'ymd' => array_key_exists('ymd', $end) ? $end['ymd'] : $this->CDT->make_ymd($end['year'], $end['month'], $end['day']), 'time' => isset($end['time']) ? $end['time'] : '2359', 'hour' => isset($end['hour']) ? $end['hour'] : '23', 'minute' => isset($end['minute']) ? $end['minute'] : '59');
     }
     // -------------------------------------
     //  Flip-flop if end is smaller than start
     // -------------------------------------
     if ($this->range_end < $this->range_start) {
         $temp = $this->range_end;
         $this->range_end = $this->range_start;
         $this->range_start = $temp;
     }
     // -------------------------------------
     //  Don't bother continuing if we're out of range
     // -------------------------------------
     if ($this->range_end['ymd'] < $this->event_start['ymd']) {
         return;
     }
     // -------------------------------------
     //  All day
     // -------------------------------------
     $this->default_data['all_day'] = (isset($this->default_data['all_day']) and $this->default_data['all_day'] == 'y');
     // -------------------------------------
     //  If the event is all day, the end time
     //  will be 0000. While calculating
     //  event duration we'll come up a whole
     //  ay short as a result. Thus,
     //  we adjust end time to 2359
     // -------------------------------------
     if ($this->default_data['all_day'] === TRUE) {
         $this->default_data['end_time'] = 2400;
     }
     // -------------------------------------
     //  Calculate the event's duration
     // -------------------------------------
     $this->default_data['duration'] = $this->calculate_duration();
     // -------------------------------------
     //  Multi-day
     // -------------------------------------
     //$this->default_data['multi_day'] = (
     //	$this->default_data['start_date'] == $this->default_data['end_date'] OR
     // ($this->default_data['duration']['days'] == 0 AND
     //$this->default_data['end_time'] == '0000')) ? FALSE : TRUE;
     $this->default_data['multi_day'] = ($this->default_data['start_date'] == $this->default_data['end_date'] or $this->default_data['duration']['days'] == 0) ? FALSE : TRUE;
     // -------------------------------------
     //  Add date arrays
     // -------------------------------------
     $this->CDT->change_datetime($this->default_data['start_year'], $this->default_data['start_month'], $this->default_data['start_day'], substr($this->default_data['start_time'], 0, 2), substr($this->default_data['start_time'], 2));
     $this->default_data['date'] = $this->CDT->datetime_array();
     $this->CDT->change_datetime($this->default_data['end_year'], $this->default_data['end_month'], $this->default_data['end_day'], substr($this->default_data['end_time'], 0, 2), substr($this->default_data['end_time'], 2));
     $this->default_data['end_date'] = $this->CDT->datetime_array();
     // -------------------------------------
     //  Set the date, if appropriate
     // -------------------------------------
     if ($this->event_start['ymd'] >= $this->range_start['ymd'] or $this->event_end['ymd'] >= $this->range_start['ymd']) {
         if (empty($this->rules) or !isset($this->rules['add'][0]) or $this->rules['add'][0]['start_date'] != $this->default_data['start_date']) {
             $this->dates[$this->default_data['start_date']][$this->default_data['start_time'] . $this->default_data['end_time']] = $this->default_data;
         }
     }
     // -------------------------------------
     //  Calculate dates using repetition rules
     // -------------------------------------
     if (!empty($this->rules)) {
         // -------------------------------------
         //  First deal with additive rules
         // -------------------------------------
         if (isset($this->rules['add'])) {
             foreach ($this->rules['add'] as $rule) {
                 $new_dates = $this->add_dates_using_rule($rule);
                 // -------------------------------------
                 //  We can't just += or array_merge() here. Nope,
                 //  gotta do it the long way.
                 // -------------------------------------
                 foreach ($new_dates as $ymd => $times) {
                     foreach ($times as $time => $data) {
                         $this->dates[$ymd][$time] = $data;
                     }
                 }
             }
         }
         // -------------------------------------
         //  He giveth, and He taketh away
         // -------------------------------------
         if (isset($this->rules['sub'])) {
             foreach ($this->rules['sub'] as $rule) {
                 $this->dates = array_diff_key($this->dates, $this->remove_dates_using_rule($rule));
             }
         }
     }
     // -------------------------------------
     //  Add occurrences
     // -------------------------------------
     if (!empty($this->occurrences)) {
         $this->add_occurrences();
     }
     // -------------------------------------
     //  Death to the exceptions!
     // -------------------------------------
     if (!empty($this->exceptions)) {
         $this->remove_exceptions();
     }
     // -------------------------------------------
     // 'calendar_event_end' hook.
     //  - Add additional processing after an event has been created
     if (ee()->extensions->active_hook('calendar_event_end') === TRUE) {
         ee()->extensions->call('calendar_event_end', $this);
         if (ee()->extensions->end_script === TRUE) {
             return;
         }
     }
     //
     // -------------------------------------------
 }
 function __construct(&$mod)
 {
     parent::__construct($mod);
 }