mirror of
https://github.com/e107inc/e107.git
synced 2025-08-09 16:17:14 +02:00
Work on event calendar, including bringing 1.x and 2.x versions more in line
This commit is contained in:
@@ -39,6 +39,11 @@ if (!defined('EC_DEFAULT_CATEGORY')) { define('EC_DEFAULT_CATEGORY','Default');
|
||||
|
||||
include_lan(e_PLUGIN.'calendar_menu/languages/'.e_LANGUAGE.'_class.php');
|
||||
|
||||
|
||||
/**
|
||||
* Class of useful data and functions for the event calendar plugin
|
||||
* Included in all application files
|
||||
*/
|
||||
class ecal_class
|
||||
{
|
||||
public $pref; // Calendar prefs - now in a separate DB record. Use same name as legacy array to simplify change
|
||||
@@ -52,7 +57,7 @@ class ecal_class
|
||||
var $cal_timedate; // Time/date stamp used by event calendar (user set)
|
||||
var $now_date; // Time/date array from $time_now
|
||||
var $site_date; // Time/date array from $site_timedate
|
||||
var $cal_date ; // Time/date array from $cal_timedate
|
||||
var $cal_date; // Time/date array from $cal_timedate
|
||||
|
||||
var $cal_super; // True if current user is a calendar supervisor
|
||||
var $extra_query; // Extra bit of mysql query used for non-supervisor (read) queries
|
||||
@@ -75,6 +80,7 @@ class ecal_class
|
||||
public $days = array(EC_LAN_25, EC_LAN_19, EC_LAN_20, EC_LAN_21, EC_LAN_22, EC_LAN_23, EC_LAN_24); // Array Sunday..Saturday
|
||||
private $months = array(EC_LAN_0, EC_LAN_1, EC_LAN_2, EC_LAN_3, EC_LAN_4, EC_LAN_5, EC_LAN_6,
|
||||
EC_LAN_7, EC_LAN_8, EC_LAN_9, EC_LAN_10, EC_LAN_11); // 'Long' month names
|
||||
|
||||
public $recur_type = array(
|
||||
'0' => EC_LAN_RECUR_00, // 'no'
|
||||
'1' => EC_LAN_RECUR_01, //'annual'
|
||||
@@ -108,7 +114,7 @@ class ecal_class
|
||||
|
||||
// Get all the times in terms of 'clock time' - i.e. allowing for TZ, DST, etc
|
||||
// All the times in the DB should be 'absolute' - so if we compare with 'clock time' it should work out.
|
||||
$this->time_now = time();
|
||||
$this->time_now = $this->clockToAbs(time());
|
||||
$this->site_timedate = $this->time_now + ($this->pref['time_offset'] * 3600); // Check sign of offset
|
||||
$this->user_timedate = $this->time_now + TIMEOFFSET;
|
||||
switch ($this->pref['eventpost_caltime'])
|
||||
@@ -171,6 +177,7 @@ class ecal_class
|
||||
$this->date_separator = '/';
|
||||
}
|
||||
}
|
||||
|
||||
switch ($temp)
|
||||
{ // Event entry calendar
|
||||
case 2 :
|
||||
@@ -424,7 +431,7 @@ class ecal_class
|
||||
{
|
||||
$e107 = e107::getInstance();
|
||||
|
||||
$log_titles = array( '1' => 'EC_ADM_01',
|
||||
$log_titles = array('1' => 'EC_ADM_01',
|
||||
'2' => 'EC_ADM_02',
|
||||
'3' => 'EC_ADM_03',
|
||||
'4' => 'EC_ADM_04',
|
||||
@@ -450,11 +457,13 @@ class ecal_class
|
||||
switch ($event_type)
|
||||
{
|
||||
case 5 :
|
||||
case 1 : $e107->e_event->trigger('ecalnew', $edata_ec);
|
||||
case 1 :
|
||||
$e107->e_event->trigger('ecalnew', $edata_ec);
|
||||
break;
|
||||
case 2 :
|
||||
case 3 :
|
||||
case 4 : $e107->e_event->trigger('ecaledit', $edata_ec);
|
||||
case 4 :
|
||||
$e107->e_event->trigger('ecaledit', $edata_ec);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -499,21 +508,34 @@ class ecal_class
|
||||
*/
|
||||
function gmgetdate($date)
|
||||
{
|
||||
$value = getdate($date-date('Z'));
|
||||
$value = getdate($date-date('Z') + (date('I') ? 3600 : 0));
|
||||
|
||||
$value['month'] = $this->months[$value['mon'] - 1]; // Looks like getdate doesn't use the specified site language
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Turn a 'clock time' into an absolute time
|
||||
*/
|
||||
function clockToAbs($val)
|
||||
{
|
||||
$temp = getdate($val);
|
||||
$temp['month'] = $this->months[$temp['mon'] - 1]; // Looks like getdate doesn't use the specified site language
|
||||
return gmmktime($temp['hours'], $temp['minutes'], $temp['seconds'], $temp['mon'], $temp['mday'], $temp['year']);
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------
|
||||
// Recurring event handling
|
||||
//------------------------------------------------
|
||||
|
||||
|
||||
/**
|
||||
* Internal utility - Generate a list of time/date based on a 'first event' date, an interval and start/finish times
|
||||
* Generate a list of regularly recurring events based on a 'first event' date, an interval and start/finish times
|
||||
*
|
||||
* All fields are Unix-style time/date stamps
|
||||
* @param int $first_event
|
||||
* @param int $first_event Earliest possible date/time for first occurrence of event (may not be precisely what's required)
|
||||
* @param int $last_event
|
||||
* @param int $interval - interval between events (in seconds)
|
||||
* @param int $start_time
|
||||
@@ -560,6 +582,14 @@ class ecal_class
|
||||
|
||||
/**
|
||||
* Generate a list of recurring events based on a 'first event' date, an interval type and start/finish window
|
||||
* Returns an array of start times
|
||||
*
|
||||
* For day number, '0' = 'Sunday'
|
||||
*
|
||||
* $first_event, $last_event are the start/end dates from the definition of the recurring event in the DB
|
||||
* $start_time, $end_time define the window currently of interest (usually a month)
|
||||
*
|
||||
* All parameters are Unix time stamps or numbers of seconds
|
||||
* @param int $first_event - earliest date for events
|
||||
* @param int $last_event - latest time for date of event
|
||||
* @param int $interval_type - numeric code defining the interval between events (N.B> day number zero is Sunday)
|
||||
@@ -583,7 +613,10 @@ class ecal_class
|
||||
|
||||
$interval = array('5' => 28*86400, '6' => 14*86400, '7' => 7*86400, '8' => 86400);
|
||||
// Do the easy ones first
|
||||
if (array_key_exists($interval_type, $interval)) return $this->gen_recur_regular($first_event, $last_event, $interval[$interval_type], $start_time, $end_time);
|
||||
if (array_key_exists($interval_type, $interval))
|
||||
{
|
||||
return $this->gen_recur_regular($first_event, $last_event, $interval[$interval_type], $start_time, $end_time);
|
||||
}
|
||||
|
||||
// We're messing around with months and years here
|
||||
$inc_array['year'] = 0;
|
||||
@@ -630,14 +663,14 @@ class ecal_class
|
||||
// Now loop through using the increment - we may discard a few, but getting clever may be worse!
|
||||
$cont = TRUE;
|
||||
|
||||
do {
|
||||
do
|
||||
{
|
||||
$tstamp = gmmktime($event['hours'],$event['minutes'],$event['seconds'],$event['mon'],$event['mday'],$event['year']);
|
||||
if ($interval_type >= 100)
|
||||
{ // $tstamp has the first of the month
|
||||
$day_diff = $day_number - gmdate('w',$tstamp);
|
||||
if ($day_diff <0) $day_diff += 7;
|
||||
$day_diff += (7 * $week_offset) - 7;
|
||||
// echo "Day difference = ".$day_diff." Stamp=".$tstamp." Week day: ".$dofwk."<br />";
|
||||
$tstamp += $day_diff*86400;
|
||||
}
|
||||
if ($tstamp >= $start_time)
|
||||
@@ -661,6 +694,12 @@ class ecal_class
|
||||
|
||||
/**
|
||||
* Generate comma separated list of fields for table, with optional alias prefix.
|
||||
*
|
||||
* @param string $table - optional table name/alias (prefixed to each field name if specified)
|
||||
* @param string $list - comma separated list of required fields
|
||||
* @param string $must_have - comma-separated list of mandatory fields - always included in the list
|
||||
*
|
||||
* @return string comma-separated list of fields for use in query
|
||||
*/
|
||||
function gen_field_list($table, $list, $must_have = '')
|
||||
{
|
||||
@@ -691,9 +730,9 @@ class ecal_class
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Function to return all events between a given start and end date
|
||||
* Return all events between a given start and end date
|
||||
* If $start_only is TRUE, only searches based on the start date/time
|
||||
* Potential option to hook in other routines here later
|
||||
* @param int $start_time - earliest time for events
|
||||
* @param int $end_time - latest time for start of event
|
||||
|
@@ -129,7 +129,7 @@ if ((isset($_POST['ne_insert']) || isset($_POST['ne_update'])) && ($cal_super |
|
||||
$ev_title = $tp->toDB($_POST['ne_title']);
|
||||
$ev_location = $tp->toDB($_POST['ne_location']);
|
||||
$ev_event = $tp->toDB($_POST['ne_event']);
|
||||
$ev_email = $tp >toDB($_POST['ne_email']);
|
||||
$ev_email = $tp->toDB($_POST['ne_email']);
|
||||
$ev_thread = $tp->toDB($_POST['ne_thread']);
|
||||
$temp_date = $ecal_class->gmgetdate($ecal_class->make_date(0,0,$_POST['start_date']));
|
||||
$ev_allday = intval($_POST['allday']);
|
||||
@@ -671,12 +671,12 @@ if ($action == 'ne' || $action == 'ed')
|
||||
|
||||
$ns->tablerender($caption, $text);
|
||||
require_once(FOOTERF);
|
||||
exit;
|
||||
exit();
|
||||
}
|
||||
else
|
||||
{
|
||||
header('location:'.e_PLUGIN.'calendar_menu/event.php');
|
||||
exit;
|
||||
exit();
|
||||
}
|
||||
} // End of "Enter New Event"
|
||||
|
||||
@@ -755,7 +755,7 @@ else
|
||||
{
|
||||
if ($ds == 'one')
|
||||
{ // Show events from one day
|
||||
// $tmp = getdate($action);
|
||||
// $tmp = $ecal_class->gmgetdate($action);
|
||||
// $selected_day = $tmp['mday'];
|
||||
// $selected_mon = $tmp['mon'];
|
||||
$start_time = intval($action);
|
||||
|
Reference in New Issue
Block a user