diff --git a/e107_plugins/calendar_menu/admin_config.php b/e107_plugins/calendar_menu/admin_config.php
index 690aea959..a6b15f35f 100644
--- a/e107_plugins/calendar_menu/admin_config.php
+++ b/e107_plugins/calendar_menu/admin_config.php
@@ -6,19 +6,19 @@
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
- *
+ * Event calendar plugin - admin functions
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/admin_config.php,v $
- * $Revision: 1.14 $
- * $Date: 2009-11-18 01:05:23 $
- * $Author: e107coders $
+ * $Revision: 1.15 $
+ * $Date: 2009-11-22 10:11:24 $
+ * $Author: e107steved $
*/
$eplug_admin = true; // Make sure we show admin theme
$e_sub_cat = 'event_calendar';
-require_once("../../class2.php");
+require_once('../../class2.php');
require_once(e_HANDLER."userclass_class.php");
-if (!getperms("P"))
+if (!getperms('P'))
{
header("location:".e_BASE."index.php");
exit;
@@ -28,7 +28,7 @@ if (!getperms("P"))
include_lan(e_PLUGIN.'calendar_menu/languages/'.e_LANGUAGE.'_admin_calendar_menu.php');
-$message = "";
+$message = '';
$calendarmenu_text = ''; // Notice removal
$calendarmenu_msg = ''; // Notice removal
@@ -164,38 +164,38 @@ if (isset($_POST['deleteold']) && isset($_POST['eventpost_deleteoldmonths']))
if (isset($_POST['cache_clear']))
{
- $ec_qs[0] = "confcache";
+ $ec_qs[0] = 'confcache';
}
//-------------------------------------------------
-require_once(e_ADMIN."auth.php");
+require_once(e_ADMIN.'auth.php');
-if (!defined("USER_WIDTH")){ define("USER_WIDTH","width:auto"); }
+if (!defined('USER_WIDTH')){ define('USER_WIDTH','width:auto'); }
// Actually delete back events
if (isset($_POST['confirmdeleteold']) && isset($ec_qs[0]) && ($ec_qs[0] == "backdel"))
{
- $old_date = $ec_qs[1];
- $old_string = strftime("%d %B %Y",$old_date);
+ $old_date = $ec_qs[1];
+ $old_string = strftime("%d %B %Y",$old_date);
// Check both start and end dates to avoid problems with events originally entered under 0.617
- $qry = "event_start < {$old_date} AND event_end < {$old_date} AND event_recurring = 0";
-// $message = "Back delete {$back_count} months. Oldest date = {$old_string} Query = {$qry}";
+ $qry = "event_start < {$old_date} AND event_end < {$old_date} AND event_recurring = 0";
+ // $message = "Back delete {$back_count} months. Oldest date = {$old_string} Query = {$qry}";
if ($sql -> db_Delete("event",$qry))
{
- // Add in a log event
- $ecal_class->cal_log(4,"db_Delete - earlier than {$old_string} (past {$back_count} months)",$qry);
- $message = EC_ADLAN_A146.$old_string.EC_ADLAN_A147;
+ // Add in a log event
+ $ecal_class->cal_log(4,"db_Delete - earlier than {$old_string} (past {$back_count} months)",$qry);
+ $message = EC_ADLAN_A146.$old_string.EC_ADLAN_A147;
}
else
{
- $message = EC_ADLAN_A149." : ".$sql->mySQLresult;
+ $message = EC_ADLAN_A149." : ".$sql->mySQLresult;
}
- $ec_qs[0] = "maint";
+ $ec_qs[0] = 'maint';
}
@@ -346,7 +346,7 @@ if(isset($ec_qs[0]) && $ec_qs[0] == "cat")
case '1': // Edit existing record
{
// We edit the record
- $calendarmenu_db->db_Select("event_cat", "*", "event_cat_id='$calendarmenu_id'");
+ $calendarmenu_db->db_Select('event_cat', '*', 'event_cat_id='.$calendarmenu_id);
$calendarmenu_row = $calendarmenu_db->db_Fetch() ;
extract($calendarmenu_row);
$calendarmenu_cap1 = EC_ADLAN_A24;
@@ -356,15 +356,15 @@ if(isset($ec_qs[0]) && $ec_qs[0] == "cat")
// First, set up a dummy event
global $thisevent;
$thisevent = array('event_start' => $ecal_class->time_now, 'event_end' => ($ecal_class->time_now)+3600,
- 'event_title' => "Test event", 'event_details' => EC_ADLAN_A191,
+ 'event_title' => 'Test event', 'event_details' => EC_ADLAN_A191,
'event_cat_name' => $event_cat_name, 'event_location' => EC_ADLAN_A192,
'event_contact' => USEREMAIL,
- 'event_thread' => SITEURL."dodgypage",
+ 'event_thread' => SITEURL.'dodgypage',
'event_id' => '6');
// *************** SEND EMAIL HERE **************
- require_once(e_PLUGIN."calendar_menu/calendar_shortcodes.php");
- require_once(e_HANDLER . "mail.php");
+ require_once(e_PLUGIN.'calendar_menu/calendar_shortcodes.php');
+ require_once(e_HANDLER . 'mail.php');
switch ($ecal_send_email)
{
case 1 : $cal_msg = $event_cat_msg1;
@@ -372,8 +372,8 @@ if(isset($ec_qs[0]) && $ec_qs[0] == "cat")
case 2 : $cal_msg = $event_cat_msg2;
break;
}
- $cal_msg = $tp -> parseTemplate($cal_msg, FALSE, $calendar_shortcodes);
- $cal_title = $tp -> parseTemplate($pref['eventpost_mailsubject'], FALSE, $calendar_shortcodes);
+ $cal_msg = $tp -> parseTemplate($cal_msg, TRUE);
+ $cal_title = $tp -> parseTemplate($pref['eventpost_mailsubject'], TRUE);
$user_email = USEREMAIL;
$user_name = USERNAME;
// $cal_msg = str_replace("\r","\n",$cal_msg);
diff --git a/e107_plugins/calendar_menu/calendar.php b/e107_plugins/calendar_menu/calendar.php
index 83b411315..1ad0db547 100644
--- a/e107_plugins/calendar_menu/calendar.php
+++ b/e107_plugins/calendar_menu/calendar.php
@@ -6,38 +6,46 @@
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
- *
+ * Event calendar plugin - large calendar display
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/calendar.php,v $
- * $Revision: 1.6 $
- * $Date: 2009-11-18 01:05:23 $
- * $Author: e107coders $
+ * $Revision: 1.7 $
+ * $Date: 2009-11-22 10:11:28 $
+ * $Author: e107steved $
*/
-require_once("../../class2.php");
-if (!isset($pref['plug_installed']['calendar_menu'])) header('Location: '.e_BASE.'index.php');
-require_once(e_PLUGIN.'calendar_menu/calendar_shortcodes.php');
+require_once('../../class2.php');
+$e107 = e107::getInstance();
+if (!$e107->isInstalled('calendar_menu')) header('Location: '.e_BASE.'index.php');
+
if (isset($_POST['viewallevents']))
{
- Header("Location: " . e_PLUGIN . 'calendar_menu/event.php?' . $_POST['enter_new_val']);
+ Header('Location: '.e_PLUGIN.'calendar_menu/event.php?'.intval($_POST['enter_new_val']));
+ exit;
}
if (isset($_POST['doit']))
{
- Header("Location: " . e_PLUGIN . 'calendar_menu/event.php?ne.' . $_POST['enter_new_val']);
+ Header('Location: '.e_PLUGIN.'calendar_menu/event.php?ne.'.intval($_POST['enter_new_val']));
+ exit;
}
if (isset($_POST['subs']))
{
- Header("Location: " . e_PLUGIN . 'calendar_menu/subscribe.php');
+ Header('Location: '.e_PLUGIN.'calendar_menu/subscribe.php');
+ exit;
}
if (isset($_POST['printlists']))
{
- Header("Location: " . e_PLUGIN . 'calendar_menu/ec_pf_page.php');
+ Header('Location: '.e_PLUGIN.'calendar_menu/ec_pf_page.php');
+ exit();
}
-include_lan(e_PLUGIN.'calendar_menu/languages/'.e_LANGUAGE.'.php');
-define("PAGE_NAME", EC_LAN_121);
+e107::getScParser();
+require_once(e_PLUGIN.'calendar_menu/calendar_shortcodes.php');
-require_once('ecal_class.php');
+include_lan(e_PLUGIN.'calendar_menu/languages/'.e_LANGUAGE.'.php');
+define('PAGE_NAME', EC_LAN_121);
+
+require_once(e_PLUGIN.'calendar_menu/ecal_class.php');
$ecal_class = new ecal_class;
if (is_readable(THEME.'calendar_template.php'))
@@ -50,60 +58,39 @@ else
}
-$cat_filter = intval(varset($_POST['event_cat_ids'],0));
+$cat_filter = intval(varset($_POST['event_cat_ids'],-1));
+if ($cat_filter == -1) $cat_filter = '*';
require_once(HEADERF);
+
// get date within area to display
-$qs = explode(".", e_QUERY);
-if(varset($qs[0],'') == "")
-{ // Show current month
- $datearray = $ecal_class->cal_date;
-}
-else
-{ // Get date from query
- $datearray = getdate($qs[0]);
+unset($dateArray);
+if (e_QUERY)
+{
+ $qs = explode('.', e_QUERY); // Get date from query
+ $dateArray = getdate($qs[0]);
}
-
-// Note: A lot of the following variables are used within the shortcodes
-$month = $datearray['mon']; // Number of month being shown
-$year = $datearray['year']; // Number of year being shown
-$monthstart = mktime(0, 0, 0, $month, 1, $year); // Start of month to be shown
-$monthend = mktime(0, 0, 0, $month + 1, 1, $year) - 1; // End of month to be shown
-$prevmonth = $month-1;
-$prevyear = $year;
-if ($prevmonth == 0)
-{
- $prevmonth = 12;
- $prevyear = $year-1;
+if (!is_array($dateArray))
+{ // Show current month
+ $dateArray = $ecal_class->cal_date;
}
-$previous = mktime(0, 0, 0, $prevmonth, 1, $prevyear); // Used by nav
-$nextmonth = $month + 1;
-$nextyear = $year;
-if ($nextmonth == 13)
-{
- $nextmonth = 1;
- $nextyear = $year + 1;
-}
-$next = mktime(0, 0, 0, $nextmonth, 1, $nextyear);
-$py = $year-1; // Number of previous year for nav
-$prevlink = mktime(0, 0, 0, $month, 1, $py);
-$ny = $year + 1; // Number of next year for nav
-$nextlink = mktime(0, 0, 0, $month, 1, $ny);
-
-$prop = gmmktime(0, 0, 0, $month, 1, $year); // Sets start date for new event entry
+// These are used in the day display loop
+$month = $dateArray['mon']; // Number of month being shown
+$year = $dateArray['year']; // Number of year being shown
$nowmonth = $ecal_class->cal_date['mon'];
$nowyear = $ecal_class->cal_date['year'];
$nowday = $ecal_class->cal_date['mday'];
-// set up arrays for calendar display ------------------------------------------------------------------
-// $months is used in the navigator buttons. $monthabb is used for month list
-$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);
-$monthabb = Array(EC_LAN_JAN, EC_LAN_FEB, EC_LAN_MAR, EC_LAN_APR, EC_LAN_MAY, EC_LAN_JUN, EC_LAN_JUL, EC_LAN_AUG, EC_LAN_SEP, EC_LAN_OCT, EC_LAN_NOV, EC_LAN_DEC);
+// Set date window for display
+$monthstart = mktime(0, 0, 0, $month, 1, $year); // Start of month to be shown
+$monthend = mktime(0, 0, 0, $month + 1, 1, $year) - 1; // End of month to be shown
-$days = array(EC_LAN_DAY_1, EC_LAN_DAY_2, EC_LAN_DAY_3, EC_LAN_DAY_4, EC_LAN_DAY_5, EC_LAN_DAY_6, EC_LAN_DAY_7, EC_LAN_DAY_8, EC_LAN_DAY_9, EC_LAN_DAY_10, EC_LAN_DAY_11, EC_LAN_DAY_12, EC_LAN_DAY_13, EC_LAN_DAY_14, EC_LAN_DAY_15, EC_LAN_DAY_16, EC_LAN_DAY_17, EC_LAN_DAY_18, EC_LAN_DAY_19, EC_LAN_DAY_20, EC_LAN_DAY_21, EC_LAN_DAY_22, EC_LAN_DAY_23, EC_LAN_DAY_24, EC_LAN_DAY_25, EC_LAN_DAY_26, EC_LAN_DAY_27, EC_LAN_DAY_28, EC_LAN_DAY_29, EC_LAN_DAY_30, EC_LAN_DAY_31);
+setScVar('event_calendar_shortcodes', 'ecalClass', &$ecal_class); // Give shortcodes a pointer to calendar class
+callScFunc('event_calendar_shortcodes','setCalDate', $dateArray); // Tell shortcodes the date to display
+setScVar('event_calendar_shortcodes', 'catFilter', $cat_filter); // Category filter
//-------------------------------------------------
@@ -111,10 +98,10 @@ $days = array(EC_LAN_DAY_1, EC_LAN_DAY_2, EC_LAN_DAY_3, EC_LAN_DAY_4, EC_LAN_DAY
//-------------------------------------------------
// time switch buttons
-$cal_text = $tp -> parseTemplate($CALENDAR_TIME_TABLE, FALSE, $calendar_shortcodes);
+$cal_text = $e107->tp->parseTemplate($CALENDAR_TIME_TABLE, TRUE);
// navigation buttons
-$nav_text = $tp -> parseTemplate($CALENDAR_NAVIGATION_TABLE, FALSE, $calendar_shortcodes);
+$nav_text = $e107->tp->parseTemplate($CALENDAR_NAVIGATION_TABLE, TRUE);
// We'll need virtually all of the event-related fields, so get them regardless. Just cut back on category fields
$ev_list = $ecal_class->get_events($monthstart, $monthend, FALSE, $cat_filter, TRUE, '*', 'event_cat_name,event_cat_icon');
@@ -123,13 +110,13 @@ $ev_list = $ecal_class->get_events($monthstart, $monthend, FALSE, $cat_filter, T
// For each day there is then a sub-array entry for each event
// Note that the new class-based retrieval adds an 'is_recent' flag to the data if changed according to the configured criteria
$events = array();
- foreach ($ev_list as $row)
- {
- $row['startofevent'] = TRUE; // This sets 'large print' and so on for the first day of an event
+foreach ($ev_list as $row)
+{
+ $row['startofevent'] = TRUE; // This sets 'large print' and so on for the first day of an event
- // check for recurring events in this month (could also use is_array($row['event_start']) as a test)
- if($row['event_recurring'] != '0')
- { // There could be several dates for the same event, if its a daily/weekly event
+ // check for recurring events in this month (could also use is_array($row['event_start']) as a test)
+ if($row['event_recurring'] != '0')
+ { // There could be several dates for the same event, if its a daily/weekly event
$t_start = $row['event_start'];
foreach ($t_start as $ev_start)
{
@@ -137,9 +124,9 @@ $events = array();
$row['event_start'] = $ev_start;
$events[date('j',$ev_start)][] = $row;
}
- }
- else
- { // Its a 'normal' event
+ }
+ else
+ { // Its a 'normal' event
$tmp = date('j',$row['event_start']); // Day of month for start
$tmp2 = date('j',$row['event_end']-1); // Day of month for end - knock off a second to allow for BST and suchlike
@@ -166,57 +153,59 @@ $events = array();
{
$events[$c][] = $row;
}
- }
}
+}
// ****** CAUTION - the category dropdown also used $sql object - take care to avoid interference!
$start = $monthstart;
-$numberdays = date("t", $start); // number of days in this month
+$numberdays = date('t', $start); // number of days in this month
$text = "";
-$text .= $tp -> parseTemplate($CALENDAR_CALENDAR_START, FALSE, $calendar_shortcodes);
-$text .= $tp -> parseTemplate($CALENDAR_CALENDAR_HEADER_START, FALSE, $calendar_shortcodes);
+$text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_START, TRUE);
+$text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_HEADER_START, TRUE);
+// Display the column headers
for ($i = 0; $i < 7; $i++)
{
- $day = $ecal_class->day_offset_string($i);
- $text .= $tp -> parseTemplate($CALENDAR_CALENDAR_HEADER, FALSE, $calendar_shortcodes);
+ setScVar('event_calendar_shortcodes', 'headerDay', $ecal_class->day_offset_string($i));
+ $text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_HEADER, TRUE);
}
-$text .= $tp -> parseTemplate($CALENDAR_CALENDAR_HEADER_END, FALSE, $calendar_shortcodes);
+$text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_HEADER_END, TRUE);
// Calculate number of days to skip before 'real' days on first line of calendar
$firstdayoffset = date('w',$start) - $ecal_class->ec_first_day_of_week;
if ($firstdayoffset < 0) $firstdayoffset+= 7;
-for ($c=0; $c<$firstdayoffset; $c++)
+for ($i=0; $i<$firstdayoffset; $i++)
{
- $text .= $tp -> parseTemplate($CALENDAR_CALENDAR_DAY_NON, FALSE, $calendar_shortcodes);
+ $text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_DAY_NON, TRUE);
}
$loop = $firstdayoffset;
for ($c = 1; $c <= $numberdays; $c++)
{ // Loop through the number of days in this month
- $startt = $start; // Used by shortcodes - start of current day
- $stopp = $start + 86399; // End of current day
- $got_ev = array_key_exists($c, $events) && is_array($events[$c]) && count($events[$c]) > 0; // Flag set if events today
+ setScVar('event_calendar_shortcodes', 'todayStart', $start); // Start of current day
+ setScVar('event_calendar_shortcodes', 'curDay', $c); // Current day of month
+
+ $got_ev = array_key_exists($c, $events) && is_array($events[$c]) && count($events[$c]) > 0; // Flag set if events on this day
// Highlight the current day.
if ($nowday == $c && $month == $nowmonth && $year == $nowyear)
{ //today
- $text .= $tp -> parseTemplate($CALENDAR_CALENDAR_DAY_TODAY, FALSE, $calendar_shortcodes);
+ $text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_DAY_TODAY, TRUE);
}
elseif ($got_ev)
{ //day has events
- $text .= $tp -> parseTemplate($CALENDAR_CALENDAR_DAY_EVENT, FALSE, $calendar_shortcodes);
+ $text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_DAY_EVENT, TRUE);
}
else
{ // no events and not today
- $text .= $tp -> parseTemplate($CALENDAR_CALENDAR_DAY_EMPTY, FALSE, $calendar_shortcodes);
+ $text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_DAY_EMPTY, TRUE);
}
if ($got_ev)
{
@@ -224,44 +213,45 @@ for ($c = 1; $c <= $numberdays; $c++)
{
if ($ev['startofevent'])
{
- $ev['indicat'] = "";
- $ev['imagesize'] = "8";
+ $ev['indicat'] = '';
+ $ev['imagesize'] = '8';
$ev['fulltopic'] = TRUE;
}
else
{
- $ev['indicat'] = "";
- $ev['imagesize'] = "4";
+ $ev['indicat'] = '';
+ $ev['imagesize'] = '4';
$ev['fulltopic'] = FALSE;
}
- $text .= $tp -> parseTemplate($CALENDAR_SHOWEVENT, FALSE, $calendar_shortcodes);
+ setScVar('event_calendar_shortcodes', 'event', $ev); // Give shortcodes the event data
+ $text .= $e107->tp->parseTemplate($CALENDAR_SHOWEVENT, TRUE);
}
}
- $text .= $tp -> parseTemplate($CALENDAR_CALENDAR_DAY_END, FALSE, $calendar_shortcodes);
+ $text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_DAY_END, TRUE);
- $loop++;
- if ($loop == 7)
- {
- $loop = 0;
- if($c != $numberdays)
+ $loop++;
+ if ($loop == 7)
{
- $text .= $tp -> parseTemplate($CALENDAR_CALENDAR_WEEKSWITCH, FALSE, $calendar_shortcodes);
+ $loop = 0;
+ if($c != $numberdays)
+ {
+ $text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_WEEKSWITCH, TRUE);
+ }
}
- }
- $start += 86400;
+ $start += 86400;
}
//remainder cells to end the row properly with empty cells
if($loop!=0)
{
- for ($c=$loop; $c<7; $c++)
- {
- $text .= $tp -> parseTemplate($CALENDAR_CALENDAR_DAY_NON, FALSE, $calendar_shortcodes);
- }
+ for ($c=$loop; $c<7; $c++)
+ {
+ $text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_DAY_NON, TRUE);
+ }
}
-$text .= $tp -> parseTemplate($CALENDAR_CALENDAR_END, FALSE, $calendar_shortcodes);
+$text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_END, TRUE);
-$ns->tablerender(EC_LAN_79, $cal_text . $nav_text . $text);
+$e107->ns->tablerender(EC_LAN_79, $cal_text . $nav_text . $text);
// Claim back memory from key variables
unset($ev_list);
diff --git a/e107_plugins/calendar_menu/calendar_menu.php b/e107_plugins/calendar_menu/calendar_menu.php
index d94f5a44c..d29c4f6c5 100644
--- a/e107_plugins/calendar_menu/calendar_menu.php
+++ b/e107_plugins/calendar_menu/calendar_menu.php
@@ -1,47 +1,51 @@
isInstalled('calendar_menu')) return '';
-global $e107;
// See if the page is already in the cache
+$cache_tag = 'nq_event_cal_cal';
if($cacheData = $e107->ecache->retrieve($cache_tag, $ecal_class->max_cache_time))
{
echo $cacheData;
return;
}
-include_lan($ecal_dir.'languages/'.e_LANGUAGE.'.php');
-global $ecal_dir, $tp;
-if (is_readable(THEME."calendar_template.php"))
+global $pref;
+if (!is_object($ecal_class))
{
- require(THEME."calendar_template.php");
+ require_once(e_PLUGIN.'calendar_menu/ecal_class.php');
+ $ecal_class = new ecal_class;
+}
+include_lan(e_PLUGIN.'calendar_menu/languages/'.e_LANGUAGE.'.php');
+
+// Doesn't use shortcodes - rather a specific format for that
+//e107::getScParser();
+//require_once(e_PLUGIN.'calendar_menu/calendar_shortcodes.php');
+if (is_readable(THEME.'calendar_template.php'))
+{ // Has to be require
+ require(THEME.'calendar_template.php');
}
else
-{ // Needs to be require - otherwise not loaded if two menus use it
- require($ecal_dir."calendar_template.php");
+{
+ require(e_PLUGIN.'calendar_menu/calendar_template.php');
}
+
$show_recurring = TRUE; // Could be pref later
-$cat_filter = ''; // Could be another pref later.
+$cat_filter = '*'; // Could be another pref later.
$cal_datearray = $ecal_class->cal_date;
$cal_current_month = $cal_datearray['mon'];
$cal_current_year = $cal_datearray['year'];
@@ -55,30 +59,34 @@ $cal_events = array();
$cal_titles = array();
$cal_recent = array();
$cal_totev = 0;
+
$ev_list = $ecal_class->get_events($cal_monthstart, $cal_monthend, FALSE, $cat_filter, $show_recurring,
'event_start, event_thread, event_title, event_recurring, event_allday', 'event_cat_icon');
$cal_totev = count($ev_list);
- foreach ($ev_list as $cal_row)
- {
+
+// Generate an array, one element per day of the month, and assign events to them
+foreach ($ev_list as $cal_row)
+{
if (is_array($cal_row['event_start'])) $temp = $cal_row['event_start']; else $temp = array($cal_row['event_start']);
foreach ($temp as $ts)
- {
- $cal_start_day = date('j',$ts); // Day of month for start
- // Mark start day of each event
- $cal_events[$cal_start_day][] = $cal_row['event_cat_icon']; // Only first is actually used
- if (isset($cal_row['is_recent'])) $cal_recent[$cal_start_day] = TRUE;
- $cal_titles[$cal_start_day][] = $cal_row['event_title']; // In case titles displayed on mouseover
+ { // Split up any recurring events
+ $cal_start_day = date('j',$ts); // Day of month for start
+ // Mark start day of each event
+ $cal_events[$cal_start_day][] = $cal_row['event_cat_icon']; // Only first is actually used
+ if (isset($cal_row['is_recent'])) $cal_recent[$cal_start_day] = TRUE;
+ $cal_titles[$cal_start_day][] = $cal_row['event_title']; // In case titles displayed on mouseover
}
- }
+}
+
// set up month array for calendar display
$cal_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);
if ($pref['eventpost_dateformat'] == 'my')
{
- $calendar_title = $cal_months[$cal_current_month-1] ." ". $cal_current_year;
+ $calendar_title = $cal_months[$cal_current_month-1] .' '. $cal_current_year;
}
else
{
- $calendar_title = $cal_current_year ." ". $cal_months[$cal_current_month-1];
+ $calendar_title = $cal_current_year .' '. $cal_months[$cal_current_month-1];
}
switch ($pref['eventpost_menulink'])
{
@@ -109,11 +117,10 @@ $cal_text .= $CALENDAR_MENU_HEADER_START;
// Now do the headings (days of week)
for ($i = 0; $i < 7; $i++)
{
- $cal_day = $ecal_class->day_offset_string($i);
- $cal_text .= $CALENDAR_MENU_HEADER_FRONT;
-// $cal_text .= substr($cal_day, 0, $pref['eventpost_lenday']);
- $cal_text .= $tp->text_truncate($cal_day, 1, ''); // Unlikely to have room for more than 1 letter
- $cal_text .= $CALENDAR_MENU_HEADER_BACK;
+ $cal_day = $ecal_class->day_offset_string($i);
+ $cal_text .= $CALENDAR_MENU_HEADER_FRONT;
+ $cal_text .= $e107->tp->text_truncate($cal_day, 1, ''); // Unlikely to have room for more than 1 letter
+ $cal_text .= $CALENDAR_MENU_HEADER_BACK;
}
$cal_text .= $CALENDAR_MENU_HEADER_END; // Close off header row, open first date row
// Calculate number of days to skip before 'real' days on first line of calendar
@@ -121,7 +128,7 @@ $firstdayoffset = date('w',$cal_start) - $ecal_class->ec_first_day_of_week;
if ($firstdayoffset < 0) $firstdayoffset+= 7;
for ($cal_c = 0; $cal_c < $firstdayoffset; $cal_c++)
{
- $cal_text .= $CALENDAR_MENU_DAY_NON;
+ $cal_text .= $CALENDAR_MENU_DAY_NON;
}
$cal_loop = $firstdayoffset;
// Now do the days of the month
@@ -142,50 +149,50 @@ for($cal_c = 1; $cal_c <= $numberdays; $cal_c++)
$cal_linkut = gmmktime(0 , 0 , 0 , $cal_current_month, $cal_c, $cal_current_year).".one"; // Always need "one"
if (array_key_exists($cal_c, $cal_events))
{ // There are events today
- $cal_event_icon = "calendar_menu/images/" . $cal_events[$cal_c]['0']; // Icon file could be NULL
- $cal_event_count = count($cal_events[$cal_c]); // See how many events today
- if ($cal_event_count)
- { // Show icon if it exists
- $cal_css += 2; // Gives 3 for today, 4 for other day
- if (isset($pref['eventpost_showmouseover']) && ($pref['eventpost_showmouseover'] == 1))
- {
- $cal_ins = " title='";
- foreach ($cal_titles[$cal_c] as $cur_title)
- { // New line would be better, but doesn't get displayed
- $title .= $cal_ins.$cur_title;
- $cal_ins = ", ";
- }
- $title .= "'";
+ $cal_event_icon = 'calendar_menu/images/'.$cal_events[$cal_c]['0']; // Icon file could be NULL
+ $cal_event_count = count($cal_events[$cal_c]); // See how many events today
+ if ($cal_event_count)
+ { // Show icon if it exists
+ $cal_css += 2; // Gives 3 for today, 4 for other day
+ if (isset($pref['eventpost_showmouseover']) && ($pref['eventpost_showmouseover'] == 1))
+ {
+ $cal_ins = " title='";
+ foreach ($cal_titles[$cal_c] as $cur_title)
+ { // New line would be better, but doesn't get displayed
+ $title .= $cal_ins.$cur_title;
+ $cal_ins = ", ";
+ }
+ $title .= "'";
+ }
+ else
+ {
+ if ($cal_event_count == 1)
+ {
+ $title = " title='1 ".EC_LAN_135."' ";
+ }
+ else
+ {
+ $title = " title='{$cal_event_count} " . EC_LAN_106 . "' ";
+ }
+ }
+ if (is_file(e_PLUGIN.$cal_event_icon)) $cal_img = "
";
+ //height='10' width='10'
+ if (isset($cal_recent[$cal_c]) && $cal_recent[$cal_c])
+ {
+ $cal_css += 2;
+ }
}
- else
- {
- if ($cal_event_count == 1)
- {
- $title = " title='1 ".EC_LAN_135."' ";
- }
- else
- {
- $title = " title='{$cal_event_count} " . EC_LAN_106 . "' ";
- }
- }
- if (is_file(e_PLUGIN.$cal_event_icon)) $cal_img = "
";
- //height='10' width='10'
- if (isset($cal_recent[$cal_c]) && $cal_recent[$cal_c])
- {
- $cal_css += 2;
- }
- }
}
$cal_text .= $CALENDAR_MENU_DAY_START[$cal_css]."{$cal_img}";
$cal_text .= $CALENDAR_MENU_DAY_END[$cal_css];
$cal_loop++;
if ($cal_loop == 7)
{ // Start next row
- $cal_loop = 0;
- if ($cal_c != $numberdays)
- {
- $cal_text .= $CALENDAR_MENU_WEEKSWITCH;
- }
+ $cal_loop = 0;
+ if ($cal_c != $numberdays)
+ {
+ $cal_text .= $CALENDAR_MENU_WEEKSWITCH;
+ }
}
}
if ($cal_loop != 0)
diff --git a/e107_plugins/calendar_menu/calendar_shortcodes.php b/e107_plugins/calendar_menu/calendar_shortcodes.php
index 37c7540b2..a967a2cae 100644
--- a/e107_plugins/calendar_menu/calendar_shortcodes.php
+++ b/e107_plugins/calendar_menu/calendar_shortcodes.php
@@ -6,822 +6,1102 @@
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
- *
+ * Shortcodes for event calendar
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/calendar_shortcodes.php,v $
- * $Revision: 1.14 $
- * $Date: 2009-11-18 01:05:23 $
- * $Author: e107coders $
- */
+ * $Revision: 1.15 $
+ * $Date: 2009-11-22 10:11:28 $
+ * $Author: e107steved $
+ *
+*/
+
+/*
+TODO:
+ 1. Could make date/month arrays 1-based instead of 0-based - might simplify maths
+ 2. Good way of reading categories
+
+ 2. EC_EVENT_EVENT_DATE_TIME uses global template variable
+ 3. EC_NEXT_EVENT_GAP uses global $cal_totev - use $numEvents
+ 4. Have 'currentMonth' flag (means 'current day' if $ds == 'one') ?
+ 5. Check whether $prop should be calculated better
+ 4. Finish the conversion!
+*/
if (!defined('e107_INIT')) { exit; }
-include_once(e_HANDLER.'shortcode_handler.php');
-$calendar_shortcodes = $tp -> e_sc -> parse_scbatch(__FILE__);
+//require_once(e_HANDLER.'shortcode_handler.php'); // Should only be temporary?
+include_lan(e_PLUGIN.'calendar_menu/languages/'.e_LANGUAGE.'.php');
+register_shortcode('event_calendar_shortcodes', true);
+initShortcodeClass('event_calendar_shortcodes');
+
/*
-// TIME SWITCH BUTTONS ------------------------------------------------
-SC_BEGIN EC_PREV_MONTH
- global $previous, $months, $prevmonth;
- return "<< ".$months[($prevmonth-1)]."";
-SC_END
+Navigation Shortcodes
+---------------------
+EC_PREV_MONTH
+EC_CURRENT_MONTH
+EC_NEXT_MONTH
+EC_PREV_YEAR
+EC_NEXT_YEAR
+EC_MONTH_LIST
-SC_BEGIN EC_NEXT_MONTH
- global $next, $months, $nextmonth;
- return " ".$months[($nextmonth-1)]." >>";
-SC_END
+Navigation Buttons
+------------------
+EC_NAV_BUT_ALLEVENTS
+EC_NAV_BUT_VIEWCAT
+EC_NAV_BUT_SUBSCRIPTION
+EC_NAV_BUT_ENTEREVENT
+EC_NAV_LINKCURRENTMONTH
+EC_NAV_BUT_PRINTLISTS
-SC_BEGIN EC_CURRENT_MONTH
- global $EC_CURRENT_MONTH, $pref, $months, $month, $year;
- if($pref['eventpost_dateformat'] == 'my')
+Shortcodes for 'big' calendar display
+-------------------------------------
+EC_CALENDAR_CALENDAR_HEADER_DAY
+EC_CALENDAR_CALENDAR_DAY_EVENT_HEADING
+EC_CALENDAR_CALENDAR_DAY_TODAY_HEADING
+EC_CALENDAR_CALENDAR_DAY_EMPTY_HEADING
+EC_CALENDAR_CALENDAR_RECENT_ICON
+
+Shortcodes for Event List
+-------------------------
+EC_EVENTLIST_CAPTION
+
+Return event information
+------------------------
+EC_EVENT_LOCATION - event location
+EC_EVENT_RECENT_ICON
+EC_SHOWEVENT_IMAGE
+EC_SHOWEVENT_INDICAT
+EC_SHOWEVENT_HEADING
+EC_IF_ALLDAY
+EC_IF_SAMEDAY
+EC_IFNOT_SAMEDAY
+EC_IFNOT_ALLDAY
+EC_EVENT_HEADING_DATE - date for heading
+EC_EVENT_DATE_START - date for body
+EC_EVENT_TIME_START
+EC_EVENT_DATE_END
+EC_EVENT_TIME_END
+EC_EVENT_EVENT_DATE_TIME
+EC_EVENT_TITLE
+EC_EVENT_CAT_ICON
+EC_EVENT_ID
+EC_EVENT_DISPLAYSTYLE
+EC_EVENT_DETAILS
+EC_EVENT_CATEGORY
+EC_EVENT_AUTHOR
+EC_EVENT_CONTACT
+EC_EVENT_THREAD
+EC_EVENT_OPTIONS
+EC_EC_EVENT_LINK
+EC_EVENT_SHORT_DATE
+
+Event Archive
+-------------
+EC_EVENTARCHIVE_CAPTION
+EC_EVENTARCHIVE_DATE
+EC_EVENTARCHIVE_DETAILS
+EC_EVENTARCHIVE_HEADING
+EC_EVENTARCHIVE_EMPTY
+
+Forthcoming Events menu
+-----------------------
+EC_NEXT_EVENT_RECENT_ICON
+EC_NEXT_EVENT_TIME
+EC_NEXT_EVENT_DATE
+EC_NEXT_EVENT_TITLE
+EC_NEXT_EVENT_ICON
+EC_NEXT_EVENT_GAP
+
+
+Shortcodes for event calendar mailout
+-------------------------------------
+EC_MAIL_HEADING_DATE - event start date, optional parameter to format date (intended for headings etc)
+EC_MAIL_DATE_START - event start date, optional parameter to format date (intended for body text)
+EC_MAIL_DATE_START_ALLDAY - returns date only for all day events, otherwise empty string
+EC_MAIL_DATE_START_TIMED - returns date only for 'timed' events, otherwise empty string
+EC_MAIL_TIME_START - event start time
+EC_MAIL_DATE_END - event end date (empty string if same as start date)
+EC_MAIL_TIME_END - time at which event ends (empty string if all day)
+EC_MAIL_TITLE - title of event
+EC_MAIL_ID - event ID (in database)
+EC_MAIL_DETAILS - event details
+EC_MAIL_CATEGORY - event category text
+EC_MAIL_LOCATION - use EC_EVENT_LOCATION
+EC_MAIL_CONTACT - event contact
+EC_MAIL_THREAD - forum thread
+EC_MAIL_LINK - link to event detail on web site
+EC_MAIL_SHORT_DATE - short date (day, month) for event start
+EC_MAIL_SUBJECT - subject for mailout
+
+List printing
+-------------
+EC_PR_LIST_TITLE
+EC_PR_CAT_LIST
+EC_PR_CHANGE_YEAR
+EC_PR_CHANGE_MONTH
+EC_NOW_TIME
+EC_NOW_DATE
+EC_PR_LIST_START
+EC_PR_LIST_END
+EC_PRINT_BUTTON
+EC_IF_PRINT
+EC_IFNOT_PRINT
+EC_IF_DISPLAY
+EC_IFNOT_DISPLAY
+EC_IF_PDF
+EC_IFNOT_PDF
+*/
+class event_calendar_shortcodes
+{
+ protected $e107;
+
+ public $event; // Current event being displayed
+ public $ecalClass; // Pointer to event calendar class
+ public $headerDay = 0; // Day number for header
+ public $todayStart; // Start of current day
+ public $curDay; // Current day of month (1..31)
+ public $numEvents = 0; // Number of events to be expected in certain list formats
+ public $catFilter = '*'; // Event category filter
+ public $eventDisplayCodes = ''; // Set to be an array of options
+ public $ecOutputType = ''; // Used by printing routines
+ public $changeFlags = array(); // Used by printing routines
+ public $printVars = array(); // USed by printing routine
+
+ 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
+ private $monthabb = array(EC_LAN_JAN, EC_LAN_FEB, EC_LAN_MAR, EC_LAN_APR, EC_LAN_MAY, EC_LAN_JUN,
+ EC_LAN_JUL, EC_LAN_AUG, EC_LAN_SEP, EC_LAN_OCT, EC_LAN_NOV, EC_LAN_DEC); // 'Short' month names
+ private $days = array(EC_LAN_DAY_1, EC_LAN_DAY_2, EC_LAN_DAY_3, EC_LAN_DAY_4, EC_LAN_DAY_5, EC_LAN_DAY_6, EC_LAN_DAY_7,
+ EC_LAN_DAY_8, EC_LAN_DAY_9, EC_LAN_DAY_10, EC_LAN_DAY_11, EC_LAN_DAY_12, EC_LAN_DAY_13, EC_LAN_DAY_14,
+ EC_LAN_DAY_15, EC_LAN_DAY_16, EC_LAN_DAY_17, EC_LAN_DAY_18, EC_LAN_DAY_19, EC_LAN_DAY_20, EC_LAN_DAY_21,
+ EC_LAN_DAY_22, EC_LAN_DAY_23, EC_LAN_DAY_24, EC_LAN_DAY_25, EC_LAN_DAY_26, EC_LAN_DAY_27, EC_LAN_DAY_28,
+ EC_LAN_DAY_29, EC_LAN_DAY_30, EC_LAN_DAY_31); // Days of month (numbers)
+
+ private $nowDay; // Today
+ private $nowMonth;
+ private $nowYear;
+
+ private $day; // Day of month - often not used
+ private $month; // Month to display
+ private $year; // Year to display
+
+ private $previous; // Previous month - date stamp
+ private $next; // Next month - date stamp
+
+ private $monthStart;
+ private $monthEnd;
+
+ private $prevMonth;
+ private $nextMonth;
+
+ private $prevLink; // Previous year
+ private $py;
+ private $nextLink; // Next year
+ private $ny;
+
+ private $prop; // Start date for new event entry
+ private $ds = ''; // Display type for some shortcodes (mostly event listing)
+
+ private $ourDB; // For when we need a DB object
+
+
+ public function __construct()
{
- $EC_CURRENT_MONTH = $months[($month-1)]." ".$year;
- }
- else
+ $this->e107 = e107::getInstance();
+ }
+
+
+ /**
+ * Set the current date for calendar display
+ *
+ * Routine then calculates various values needed for shortcodes
+ *
+ * @param array $curDate - As returned by getdate()
+ *
+ * @return BOOLEAN TRUE
+ */
+ public function setCalDate($curDate)
{
- $EC_CURRENT_MONTH = $year." ".$months[($month-1)];
+ $this->ds = varset($curDate['ds'],'');
+
+ $this->day = varset($curDate['mday'], 0); // Day number being shown - rarely relevant
+ $this->month = $curDate['mon']; // Number of month being shown
+ $this->year = $curDate['year']; // Number of year being shown
+ $this->monthStart = mktime(0, 0, 0, $curDate['mon'], 1, $curDate['year']); // Start of month to be shown
+ $this->monthEnd = mktime(0, 0, 0, $curDate['mon'] + 1, 1, $curDate['year']) - 1; // End of month to be shown
+
+
+ // Calculate date code for previous month
+ $this->prevMonth = $curDate['mon']-1;
+ $prevYear = $curDate['year'];
+ if ($this->prevMonth == 0)
+ {
+ $this->prevMonth = 12;
+ $prevYear--;
+ }
+ $this->previous = mktime(0, 0, 0, $this->prevMonth, 1, $prevYear); // Previous month - Used by nav
+
+ // Calculate date code for next month
+ $this->nextMonth = $curDate['mon'] + 1;
+ $nextYear = $curDate['year'];
+ if ($this->nextMonth == 13)
+ {
+ $this->nextMonth = 1;
+ $nextYear++;
+ }
+ $this->next = mktime(0, 0, 0, $this->nextMonth, 1, $nextYear); // Next month - used by nav
+
+
+ $this->py = $curDate['year']-1; // Number of previous year for nav
+ $this->prevLink = mktime(0, 0, 0, $curDate['mon'], 1, $this->py);
+ $this->ny = $curDate['year'] + 1; // Number of next year for nav
+ $this->nextLink = mktime(0, 0, 0, $curDate['mon'], 1, $this->ny);
+
+ $this->prop = gmmktime(0, 0, 0, $curDate['mon'], $curDate['mday'], $curDate['year']); // Sets start date for new event entry
+
+ $this->nowMonth = $this->ecalClass->cal_date['mon'];
+ $this->nowYear = $this->ecalClass->cal_date['year'];
+ $this->nowDay = $this->ecalClass->cal_date['mday'];
+ return TRUE;
}
- return $EC_CURRENT_MONTH;
-SC_END
-SC_BEGIN EC_PREV_YEAR
- global $prevlink, $py;
- return "<< ".$py."";
-SC_END
-
-SC_BEGIN EC_NEXT_YEAR
- global $nextlink, $ny;
- return "".$ny." >>";
-SC_END
-
-SC_BEGIN EC_MONTH_LIST
- global $EC_MONTH_LIST, $year, $monthjump, $monthabb;
- $EC_MONTH_LIST = "";
- for ($ii = 0; $ii < 12; $ii++)
+ // Navigation shortcodes
+ public function sc_ec_prev_month($parm = '')
{
- $m = $ii + 1;
- $monthjump = mktime(0, 0, 0, $m, 1, $year);
- $EC_MONTH_LIST .= "".$monthabb[$ii]." ";
+ return "<< ".$this->months[($this->prevMonth-1)]."";
}
- return $EC_MONTH_LIST;
-SC_END
-
-
-// NAVIGATION BUTTONS ------------------------------------------------
-SC_BEGIN EC_NAV_BUT_ALLEVENTS
- $allevents = (e_PAGE == "event.php" ? EC_LAN_96 : EC_LAN_93);
- return "";
-SC_END
-
-SC_BEGIN EC_NAV_BUT_VIEWCAT
- //return "";
- return "";
-SC_END
-
-SC_BEGIN EC_NAV_BUT_SUBSCRIPTION
- global $pref;
- if (isset($pref['eventpost_asubs']) && ($pref['eventpost_asubs']>0) && USER)
+ public function sc_ec_next_month($parm = '')
{
- return "";
+ return " ".$this->months[($this->nextMonth-1)]." >>";
}
-SC_END
-SC_BEGIN EC_NAV_BUT_PRINTLISTS
- global $pref;
- if (isset($pref['eventpost_printlists']) && ($pref['eventpost_printlists']>0) && USER)
+
+ public function sc_ec_current_month($parm = '')
{
- return "";
+ global $pref;
+ if($pref['eventpost_dateformat'] == 'my')
+ {
+ return $this->months[($this->month-1)].' '.$this->year;
+ }
+ return $this->year.' '.$this->months[($this->month-1)];
}
-SC_END
-SC_BEGIN EC_NAV_BUT_ENTEREVENT
- global $EC_NAV_BUT_ENTEREVENT, $pref, $prop, $cal_super;
- $EC_NAV_BUT_ENTEREVENT = "";
- if ($cal_super || check_class($pref['eventpost_admin']))
+
+ public function sc_ec_prev_year($parm = '')
{
- $EC_NAV_BUT_ENTEREVENT .= "";
+ return "<< ".$this->py."";
}
- return $EC_NAV_BUT_ENTEREVENT;
-SC_END
-SC_BEGIN EC_NAV_LINKCURRENTMONTH
- global $EC_NAV_LINKCURRENTMONTH, $month, $nowmonth, $year, $nowyear, $current, $ds;
- $EC_NAV_LINKCURRENTMONTH = "";
- if ($month != $nowmonth || $year != $nowyear || $ds == 'one'){
- $EC_NAV_LINKCURRENTMONTH = "";
- }
- return $EC_NAV_LINKCURRENTMONTH;
-SC_END
-
-SC_BEGIN EC_NAV_CATEGORIES
- global $EC_NAV_CATEGORIES, $sql, $pref, $_POST, $cal_super, $cat_filter;
- (isset($parm) && ($parm == 'nosubmit')) ? $insert = '' : $insert = "onchange='this.form.submit()'";
- $EC_NAV_CATEGORIES = "\n";
- return $EC_NAV_CATEGORIES;
-SC_END
-
-
-
-// CALENDAR SHOWEVENT ------------------------------------------------------------
-SC_BEGIN EC_SHOWEVENT_IMAGE
- //TODO review bullet
- global $ev;
-
- $img = '';
- if($ev['event_cat_icon'] && file_exists(e_PLUGIN."calendar_menu/images/".$ev['event_cat_icon']))
+ public function sc_ec_next_year($parm = '')
{
- $img = "
";
+ return "".$this->ny." >>";
}
- elseif(defined('BULLET'))
- {
- $img = '
';
- }
- elseif(file_exists(THEME.'images/bullet2.gif'))
- {
- $img = '
';
- }
- return $img;
-SC_END
-SC_BEGIN EC_SHOWEVENT_INDICAT
- global $ev;
- return $ev['indicat'];
-SC_END
-SC_BEGIN EC_SHOWEVENT_HEADING
- global $ev, $datearray, $c, $tp;
- $linkut = mktime(0 , 0 , 0 , $datearray['mon'], $c, $datearray['year']);
- $show_title = $tp->toHTML($ev['event_title'],FALSE,'TITLE'); // Remove entities in case need to truncate
- if(isset($ev['fulltopic']) && !$ev['fulltopic'])
+ public function sc_ec_month_list($parm = '')
{
- $show_title = $tp->text_truncate($show_title, 10, "...");
+ $ret = '';
+ for ($ii = 0; $ii < 12; $ii++)
+ {
+ $monthJump = mktime(0, 0, 0, $ii+1, 1, $this->year);
+ $ret .= "".$this->monthabb[$ii]." ";
+ }
+ return $ret;
}
- if($ev['startofevent'])
- {
- return "".$show_title."";
- }
- else
- {
- return "".$show_title."";
- }
-SC_END
+ // Navigation buttons
+ public function sc_ec_nav_but_allevents($parm = '')
+ {
+ $allevents = (e_PAGE == "event.php" ? EC_LAN_96 : EC_LAN_93);
+ return "";
+ }
+
+ public function sc_ec_nav_but_viewcat($parm = '')
+ {
+ return "";
+ }
+
+ public function sc_ec_nav_but_subscription($parm = '')
+ {
+ global $pref;
+ if (isset($pref['eventpost_asubs']) && ($pref['eventpost_asubs']>0) && USER)
+ {
+ return "";
+ }
+ return '';
+ }
+
+ public function sc_ec_nav_but_enterevent($parm = '')
+ {
+ global $pref;
+ $ret = "";
+ if ($this->ecalClass->cal_super || check_class($pref['eventpost_admin']))
+ {
+ $ret .= "";
+ }
+ return $ret;
+ }
+
+ public function sc_ec_nav_linkcurrentmonth($parm = '')
+ {
+ $ret = '';
+ if ($this->month != $this->nowMonth || $this->year != $this->nowYear || $this->ds == 'one')
+ { // Just jump to current page without a query part - that will default to today
+ $ret = "";
+ }
+ return $ret;
+ }
+
+ public function sc_ec_nav_but_printlists($parm = '')
+ {
+ global $pref;
+ if (isset($pref['eventpost_printlists']) && ($pref['eventpost_printlists']>0) && USER)
+ {
+ return "";
+ }
+ }
+
+ // Categories listing
+ public function sc_ec_nav_categories($parm = '')
+ {
+ global $pref;
+ if ($this->ourDB == NULL)
+ {
+ $this->ourDB = new db;
+ }
+ ($parm == 'nosubmit') ? $insert = '' : $insert = "onchange='this.form.submit()'";
+ $ret = "\n";
+ return $ret;
+ }
+
+
+// Event information shortcodes
+//-----------------------------
+
+
+ public function sc_ec_event_location($parm = '')
+ {
+ return $this->event['event_location'];
+ }
+
+ public function sc_ec_event_recent_icon()
+ {
+ return $this->sc_ec_calendar_calendar_recent_icon();
+ }
+
+
+
+ public function sc_ec_if_allday($parm= '')
+ {
+ if (!$this->event['event_allday']) return '';
+ if (trim($parm) == '') return '';
+ return $this->e107->tp->parseTemplate('{'.$parm.'}');
+ }
+
+ public function sc_ec_ifnot_allday($parm= '')
+ {
+ if ($this->event['event_allday']) return '';
+ if (trim($parm) == '') return '';
+ return $this->e107->tp->parseTemplate('{'.$parm.'}');
+ }
+
+ public function sc_ec_ifnot_sameday($parm= '')
+ {
+ if (intval($this->event['event_end']/86400) == intval($this->event['event_start']/86400)) return '';
+ if (!$this->event['event_allday']) return '';
+ if (trim($parm) == '') return;
+ return $this->e107->tp->parseTemplate('{'.$parm.'}');
+ }
+
+ public function sc_ec_if_sameday($parm= '')
+ {
+ if (intval($this->event['event_end']/86400) != intval($this->event['event_start']/86400)) return '';
+ if (!$this->event['event_allday']) return '';
+ if (trim($parm) == '') return;
+ return $this->e107->tp->parseTemplate('{'.$parm.'}');
+ }
+
+
+
+// Event mailout shortcodes
+//--------------------------
+ public function sc_ec_mail_heading_date($parm)
+ {
+ if (isset($parm) && ($parm !== ""))
+ {
+ return strftime($parm,$this->event['event_start']);
+ }
+ else
+ {
+ return $this->ecalClass->event_date_string($this->event['event_start']);
+ }
+ }
+
+
+ public function sc_ec_mail_date_start($parm)
+ {
+ return $this->sc_ec_mail_heading_date($parm);
+ }
+
+
+ public function sc_ec_mail_date_start_allday($parm)
+ {
+ if ($this->event['event_allday'] != 1) return '';
+ return $this->sc_ec_mail_heading_date($parm);
+ }
+
+
+ public function sc_ec_mail_date_start_timed($parm)
+ {
+ if ($this->event['event_allday'] == 1) return '';
+ return $this->sc_ec_mail_heading_date($parm);
+ }
+
+
+ public function sc_ec_mail_time_start($parm)
+ {
+ if ($this->event['event_allday'] == 1) return '';
+ return $this->ecalClass->time_string($this->event['event_start']);
+ }
+
+
+ public function sc_ec_mail_date_end($parm = '')
+ {
+ if ($this->event['event_allday'] ||($this->event['event_end'] == $this->event['event_start'])) return '';
+ if ($parm !== '')
+ {
+ return strftime($parm,$this->event['event_end']);
+ }
+ return $this->ecalClass->event_date_string($this->event['event_end']);
+ }
+
+
+
+ public function sc_ec_mail_time_end($parm = '')
+ {
+ if ($this->event['event_allday'] ||($this->event['event_end'] == $this->event['event_start'])) return '';
+ $endds = $ecal_class->time_string($this->event['event_end']);
+ return $endds;
+ }
+
+
+ public function sc_ec_mail_title($parm = '')
+ {
+ return $this->event['event_title'];
+ }
+
+
+ public function sc_ec_mail_id($parm = '')
+ {
+ return 'calevent'.$this->event['event_id'];
+ }
+
+
+ public function sc_ec_mail_details($parm = '')
+ {
+ return $this->e107->tp->toHTML($this->event['event_details'], TRUE,'E_BODY');
+ }
+
+
+
+ public function sc_ec_mail_category($parm = '')
+ {
+ return $this->event['event_cat_name'];
+ }
+
+
+
+
+ public function sc_ec_mail_contact($parm = '')
+ {
+ if ($this->event['event_contact'] == '') return '';
+ return $this->e107->tp->toHTML($this->event['event_contact'],TRUE,'LINKTEXT');
+ }
+
+
+ public function sc_ec_mail_thread($parm = '')
+ {
+ return $this->event['event_thread'];
+ }
+
+
+ public function sc_ec_mail_link($parm = '')
+ {
+ $cal_dayarray = getdate($this->event['event_start']);
+ $cal_linkut = mktime(0 , 0 , 0 , $cal_dayarray['mon'], $cal_dayarray['mday'], $cal_dayarray['year']).".one"; // ALways need "one"
+ return ' '.str_replace(e_HTTP,SITEURL, e_PLUGIN_ABS).'calendar_menu/event.php?'.$cal_linkut.' ';
+ }
+
+
+ public function sc_ec_mail_short_date($parm = '')
+ {
+ return $this->ecalClass->next_date_string($this->event['event_start']);
+ }
+
+
+ // Codes can be used to return a LAN to help with multi-language
+ public function sc_ec_mail_subject($parm = '')
+ {
+ return EC_MAILOUT_SUBJECT;
+ }
+
//------------------------------------------
// CALENDAR CALENDAR - 'Big' calendar
//------------------------------------------
-SC_BEGIN EC_CALENDAR_CALENDAR_HEADER_DAY
- global $day, $pref, $tp;
- if(isset($pref['eventpost_lenday']) && $pref['eventpost_lenday'])
+ public function sc_ec_calendar_calendar_header_day($parm = '')
{
- return "".$tp->text_truncate($day,$pref['eventpost_lenday'],'')."";
+ global $pref;
+ if(isset($pref['eventpost_lenday']) && $pref['eventpost_lenday'])
+ {
+ return "".$this->e107->tp->text_truncate($this->headerDay,$pref['eventpost_lenday'],'')."";
+ }
+ else
+ {
+ return "".$this->headerDay."";
+ }
}
- else
+
+
+ public function sc_ec_calendar_calendar_day_today_heading()
{
- return "".$day."";
+ return "".$this->days[($this->curDay-1)]." [".EC_LAN_TODAY."]";
}
-SC_END
-SC_BEGIN EC_CALENDAR_CALENDAR_DAY_TODAY_HEADING
- global $startt, $c, $days;
- return "".$days[($c-1)]." [".EC_LAN_TODAY."]";
-SC_END
-SC_BEGIN EC_CALENDAR_CALENDAR_DAY_EVENT_HEADING
- global $startt, $c, $days;
- return "".$days[($c-1)]."";
-SC_END
-
-SC_BEGIN EC_CALENDAR_CALENDAR_DAY_EMPTY_HEADING
- global $startt, $c, $days;
- return "".$days[($c-1)]."";
-SC_END
-
-SC_BEGIN EC_CALENDAR_CALENDAR_RECENT_ICON
- global $ev;
- if (!isset($ev['is_recent'])) return "";
- if (!$ev['startofevent']) return ""; // Only display on first day of multi-day events
-// $recent_icon = e_PLUGIN_ABS."calendar_menu/images/recent_icon.png";
- $recent_icon = EC_RECENT_ICON;
- if (file_exists($recent_icon))
+ public function sc_ec_calendar_calendar_day_event_heading()
{
- return "
";
+ return "".$this->days[($this->curDay-1)]."";
}
- return "R";
-SC_END
+ public function sc_ec_calendar_calendar_day_empty_heading()
+ {
+ return "".$this->days[($this->curDay-1)]."";
+ }
+
+
+ public function sc_ec_calendar_calendar_recent_icon()
+ {
+ if (!isset($this->event['is_recent'])) return '';
+ if (!$this->event['startofevent']) return ''; // Only display on first day of multi-day events
+ $recent_icon = EC_RECENT_ICON;
+ if (is_readable($recent_icon))
+ {
+ return "
";
+ }
+ return "R";
+ }
+
+
+ public function sc_ec_event_page_title()
+ {
+ switch ($this->ds)
+ {
+ case 'one' : return EC_LAN_80.': '.$this->day.' '.$this->months[$this->month-1];
+// case 'event' : return EC_LAN_122.': '.$this->day.' '.$this->months[$this->month-1];
+ case 'event' : return EC_LAN_122;
+ default : return EC_LAN_80;
+ }
+ }
+
+
+ public function sc_ec_showevent_image()
+ {
+ //TODO review bullet
+ $img = '';
+ if($this->event['event_cat_icon'] && file_exists(e_PLUGIN.'calendar_menu/images/'.$this->event['event_cat_icon']))
+ {
+ $img = "
event['event_cat_icon']."' alt='' height='".$this->event['imagesize']."' width='".$this->event['imagesize']."' />";
+ }
+ elseif(defined('BULLET'))
+ {
+ $img = '
';
+ }
+ elseif(file_exists(THEME.'images/bullet2.gif'))
+ {
+ $img = '
';
+ }
+ return $img;
+ }
+
+
+ public function sc_ec_showevent_indicat()
+ {
+ return $this->event['indicat'];
+ }
+
+
+
+ public function sc_ec_showevent_heading()
+ {
+ $linkut = mktime(0 , 0 , 0 , $this->month, $this->curDay, $this->year);
+ $show_title = $this->e107->tp->toHTML($this->event['event_title'],FALSE,'TITLE'); // Remove entities in case need to truncate
+ if(isset($this->event['fulltopic']) && !$this->event['fulltopic'])
+ {
+ $show_title = $this->e107->tp->text_truncate($show_title, 10, "...");
+ }
+ if($ev['startofevent'])
+ {
+ return "".$show_title."";
+ }
+ else
+ {
+ return "".$show_title."";
+ }
+ }
+
+
+ public function sc_ec_eventlist_caption()
+ {
+ $ret = '';
+ if ($this->ds == 'one')
+ {
+ $ret = EC_LAN_111.$this->months[$this->month-1].' '.$this->day;
+ }
+ elseif ($this->ds != 'event')
+ {
+ $ret = EC_LAN_112.$this->months[$this->month-1];
+ }
+ return $ret;
+ }
+
+
+//---------------------------------------------------
+// EVENT SHOWEVENT (Detail of individual events)
+//---------------------------------------------------
+
+ public function sc_ec_event_heading_date()
+ {
+ return $this->ecalClass->event_date_string($this->event['event_start']);
+ }
+
+ // Same code as previous
+ public function sc_ec_event_date_start()
+ {
+ return $this->ecalClass->event_date_string($this->event['event_start']);
+ }
+
+
+ public function sc_ec_event_time_start()
+ {
+ if ($this->event['event_allday'] == 1) return '';
+ return $this->ecalClass->time_string($this->event['event_start']);
+ }
+
+
+ public function sc_ec_event_date_end()
+ {
+ if ($this->event['event_end'] == $this->event['event_start']) return '';
+ return $this->ecalClass->event_date_string($this->event['event_end']);
+ }
+
+
+ public function sc_ec_event_time_end()
+ {
+ if ($this->event['event_allday'] ||($this->event['event_end'] == $this->event['event_start'])) return '';
+ return $this->ecalClass->time_string($this->event['event_end']);
+ }
+
+
+ public function sc_ec_event_title()
+ {
+ return $this->event['event_title'];
+ }
+
+
+ public function sc_ec_event_cat_icon()
+ {
+ if ($this->event['event_cat_icon'] && is_readable(e_PLUGIN.'calendar_menu/images/'.$this->event['event_cat_icon']))
+ {
+ return "
";
+ }
+ return '';
+ }
+
+
+ public function sc_ec_event_id()
+ {
+ return 'calevent'.$this->event['event_id'];
+ }
+
+
+ public function sc_ec_event_displaystyle()
+ { // Returns initial state of expandable blocks
+ if (($this->ds=='event') || ($this->ds=='one'))
+ {
+ return ''; // Let block display
+ }
+ return 'display: none; ';
+ }
+
+
+ /**
+ * Display class for event display block - to manage expansion/contraction
+ * When displaying a single event, or a single day's events, block to be expanded
+ * For event lists, block to be contracted
+ *
+ * @param int $param - optional supplementary list of classes to apply
+ *
+ * @return string -
+ */
+ public function sc_ec_event_displayclass($parm='')
+ {
+ if (($this->ds=='event') || ($this->ds=='one'))
+ { // Single event or one day's events - block expanded
+ return " class='{$parm}'";
+ }
+ return " class='e-show-if-js e-hideme {$parm}'"; // Block contracted
+// return " class='e-hide-if-js e-showme {$parm}'"; // Block contracted
+ }
+
+
+ public function sc_ec_event_details()
+ {
+ return $this->e107->tp->toHTML($this->event['event_details'], TRUE, 'BODY');
+ }
+
+
+ public function sc_ec_event_category()
+ {
+ return $this->event['event_cat_name'];
+ }
+
+
+ public function sc_ec_event_author()
+ {
+ $lp = explode(".", $this->event['event_author'],2); // Split into userid.username
+ if (preg_match("/[0-9]+/", $lp[0]))
+ {
+ $event_author_id = $lp[0];
+ $event_author_name = $lp[1];
+ }
+ if(USER)
+ {
+ return "".$event_author_name."";
+ }
+ return $event_author_name;
+ }
+
+
+ public function sc_ec_event_contact()
+ {
+ if ($this->event['event_contact'] == '') return '';
+ $tm = $this->event['event_contact'];
+ if (strpos($tm,'[') === FALSE)
+ { // Add a bbcode if none exists
+ $tm = '[link=mailto:'.trim($tm).']'.substr($tm,0,strpos($tm,'@')).'[/link]';
+ }
+ return $this->e107->tp->toHTML($tm,TRUE,'LINKTEXT'); // Return obfuscated email link
+ }
+
+
+ public function sc_ec_event_thread()
+ {
+ if (isset($this->event['event_thread']) && ($this->event['event_thread'] != ''))
+ {
+ return "
".EC_LAN_39."";
+ }
+ return '';
+ }
+
+
+ public function sc_ec_event_options()
+ {
+ global $pref;
+ $event_author_name = strstr(varset($this->event['event_author'],'0.??'),'.');
+ if (USERNAME == $event_author_name || $this_ecalClass->cal_super || check_class($pref['eventpost_admin']))
+ {
+ return "
event['event_id']."'>
";
+ }
+ }
+
+
+ public function sc_ec_ec_event_link()
+ {
+ $cal_dayarray = getdate($this->event['event_start']);
+ $cal_linkut = mktime(0 , 0 , 0 , $cal_dayarray['mon'], $cal_dayarray['mday'], $cal_dayarray['year']).'.one'; // ALways need "one"
+ return ' '.e_PLUGIN_ABS.'calendar_menu/event.php?'.$cal_linkut.' ';
+ }
+
+
+ // TODO: Resolve global
+ public function sc_ec_event_event_date_time()
+ {
+ $et = 0;
+ if (intval($this->event['event_end']/86400) == intval($this->event['event_start']/86400)) $et += 1;
+ if ($this->event['event_allday']) $et += 2;
+ if (is_array($this->eventDisplayCodes))
+ {
+ return $this->e107->tp->parseTemplate($this->eventDisplayCodes[$et]);
+ }
+ return '--** No template set **--';
+ }
+
+
+ public function sc_ec_event_short_date()
+ {
+ return $this->ecalClass->next_date_string($this->event['event_start']);
+ }
+
//------------------------------------------
// EVENT ARCHIVE (list of next events at bottom of event list)
//------------------------------------------
-SC_BEGIN EC_EVENTARCHIVE_CAPTION
- global $EC_EVENTARCHIVE_CAPTION, $num;
- if ($num == 0)
+
+ public function sc_ec_eventarchive_caption()
{
- $EC_EVENTARCHIVE_CAPTION = EC_LAN_137;
+ if ($this->numEvents == 0)
+ {
+ return EC_LAN_137;
+ }
+ return str_replace('-NUM-', $this->numEvents, EC_LAN_62);
}
- else
+
+
+ public function sc_ec_eventarchive_date()
{
- $EC_EVENTARCHIVE_CAPTION = str_replace("-NUM-", $num, EC_LAN_62);
+ $startds = $this->ecalClass->event_date_string($this->event['event_start']);
+ return "event['event_id']."'>".$startds."";
}
- return $EC_EVENTARCHIVE_CAPTION;
-SC_END
-
-SC_BEGIN EC_EVENTARCHIVE_DATE
- global $EC_EVENTARCHIVE_DATE, $thisevent, $ecal_class;
- $startds = $ecal_class->event_date_string($thisevent['event_start']);
- $EC_EVENTARCHIVE_DATE = "".$startds."";
- return $EC_EVENTARCHIVE_DATE;
-SC_END
-
-SC_BEGIN EC_EVENTARCHIVE_DETAILS
- global $EC_EVENTARCHIVE_DETAILS, $thisevent, $tp;
- $number = 40;
- $rowtext = $tp->toHTML($thisevent['event_details'], TRUE, "nobreak");
- $rowtext = strip_tags($rowtext);
- $words = explode(" ", $rowtext);
- $EC_EVENTARCHIVE_DETAILS = implode(" ", array_slice($words, 0, $number));
- if(count($words) > $number){
- $EC_EVENTARCHIVE_DETAILS .= " ".EC_LAN_133." ";
- }
- return $EC_EVENTARCHIVE_DETAILS;
-SC_END
-
-SC_BEGIN EC_EVENTARCHIVE_EMPTY
- global $EC_EVENTARCHIVE_EMPTY;
- return EC_LAN_37;
-SC_END
-
-SC_BEGIN EC_EVENTARCHIVE_HEADING
- global $EC_EVENTARCHIVE_HEADING, $thisevent;
- $EC_EVENTARCHIVE_HEADING = $thisevent['event_title'];
- return $EC_EVENTARCHIVE_HEADING;
-SC_END
-
-//------------------------------------------
-// EVENT LIST
-//------------------------------------------
-SC_BEGIN EC_EVENTLIST_CAPTION
- global $EC_EVENTLIST_CAPTION, $ds, $months, $selected_mon, $selected_day, $monthstart;
- if ($ds == 'one')
+ public function sc_ec_eventarchive_details()
{
- $EC_EVENTLIST_CAPTION = EC_LAN_111.$months[$selected_mon-1]." ".$selected_day;
+ $number = 40;
+ $rowtext = $this->e107->tp->toHTML($this->event['event_details'], TRUE, 'BODY');
+ $rowtext = strip_tags($rowtext);
+ $words = explode(' ', $rowtext);
+ $ret = implode(' ', array_slice($words, 0, $number));
+ if(count($words) > $number)
+ {
+ $ret .= ' '.EC_LAN_133.' ';
+ }
+ return $ret;
}
- elseif ($ds != 'event')
- {
- $EC_EVENTLIST_CAPTION = EC_LAN_112.$months[date("m", $monthstart)-1];
- }
- return $EC_EVENTLIST_CAPTION;
-SC_END
-//------------------------------------------
-// EVENT SHOWEVENT (Detail of individual events in Event List)
-//------------------------------------------
-// Some of these shortcodes also used by big calendar
-
-SC_BEGIN EC_EVENT_RECENT_ICON
- global $thisevent;
- if (!isset($thisevent['is_recent'])) return;
- $recent_icon = EC_RECENT_ICON;
- if (file_exists($recent_icon))
- {
- return "
";
- }
- return "";
-SC_END
-
-SC_BEGIN EC_EVENT_HEADING_DATE
- global $thisevent, $ecal_class;
- $startds = $ecal_class->event_date_string($thisevent['event_start']);
- return $startds;
-SC_END
-
-SC_BEGIN EC_EVENT_DATE_START
- global $thisevent, $ecal_class;
- $startds = $ecal_class->event_date_string($thisevent['event_start']);
- return $startds;
-SC_END
-
-SC_BEGIN EC_EVENT_TIME_START
- global $thisevent, $ecal_class;
- if ($thisevent['event_allday'] == 1) return "";
- $startds = $ecal_class->time_string($thisevent['event_start']);
- return $startds;
-SC_END
-
-SC_BEGIN EC_EVENT_DATE_END
- global $thisevent, $ecal_class;
-// if (intval($thisevent['event_end']/86400) == intval($thisevent['event_start']/86400)) return ""; // No end date if same day
-// if ($thisevent['event_allday'] ||($thisevent['event_end'] == $thisevent['event_start'])) return "";
- if ($thisevent['event_end'] == $thisevent['event_start']) return "";
- $endds = $ecal_class->event_date_string($thisevent['event_end']);
- return $endds;
-SC_END
-
-SC_BEGIN EC_EVENT_TIME_END
- global $thisevent, $ecal_class;
- if ($thisevent['event_allday'] ||($thisevent['event_end'] == $thisevent['event_start'])) return "";
- $endds = $ecal_class->time_string($thisevent['event_end']);
- return $endds;
-SC_END
-
-SC_BEGIN EC_EVENT_TITLE
- global $thisevent, $tp;
- return $thisevent['event_title'];
-SC_END
-
-SC_BEGIN EC_EVENT_CAT_ICON
- global $thisevent;
- if ($thisevent['event_cat_icon'] && file_exists(e_PLUGIN."calendar_menu/images/".$thisevent['event_cat_icon']))
- {
- return "
";
- }
- else
- {
- return "";
- }
-SC_END
-
-SC_BEGIN EC_EVENT_ID
- global $thisevent;
- return "calevent".$thisevent['event_id'];
-SC_END
-
-SC_BEGIN EC_EVENT_DISPLAYSTYLE
- global $EC_EVENT_DISPLAYSTYLE, $ds;
- if (($ds=="event") || ($ds=="one")){
- $EC_EVENT_DISPLAYSTYLE = "show";
- }else{
- $EC_EVENT_DISPLAYSTYLE = "none";
- }
- return $EC_EVENT_DISPLAYSTYLE;
-SC_END
-
-SC_BEGIN EC_EVENT_DETAILS
- global $thisevent, $tp;
- return $tp->toHTML($thisevent['event_details'], TRUE, 'BODY');
-SC_END
-
-SC_BEGIN EC_EVENT_CATEGORY
- global $EC_EVENT_CATEGORY, $thisevent;
- $EC_EVENT_CATEGORY = $thisevent['event_cat_name'];
- return $EC_EVENT_CATEGORY;
-SC_END
-
-SC_BEGIN EC_EVENT_LOCATION
- global $EC_EVENT_LOCATION, $thisevent;
- if ($thisevent['event_location'] == "")
+ public function sc_ec_eventarchive_empty()
{
- $EC_EVENT_LOCATION = "";
+ return EC_LAN_37;
}
- else
+
+
+ public function sc_ec_eventarchive_heading()
{
- $EC_EVENT_LOCATION = $thisevent['event_location'];
+ return $this->event['event_title'];
}
- return $EC_EVENT_LOCATION;
-SC_END
-SC_BEGIN EC_EVENT_AUTHOR
- global $thisevent;
- $lp = explode(".", $thisevent['event_author'],2);
- if (preg_match("/[0-9]+/", $lp[0]))
- {
- $event_author_id = $lp[0];
- $event_author_name = $lp[1];
- }
- if(USER)
- {
- $EC_EVENT_AUTHOR = "".$event_author_name."";
- }
- else
- {
- $EC_EVENT_AUTHOR = $event_author_name;
- }
- return $EC_EVENT_AUTHOR;
-SC_END
-
-SC_BEGIN EC_EVENT_CONTACT
- global $EC_EVENT_CONTACT, $thisevent,$tp;
- if ($thisevent['event_contact'] == "")
- {
- $EC_EVENT_CONTACT = "";
- }
- else
- {
- $tm = $thisevent['event_contact'];
- if (strpos($tm,'[') === FALSE)
- {
- $tm = '[link=mailto:'.trim($tm).']'.substr($tm,0,strpos($tm,'@')).'[/link]';
- }
- $EC_EVENT_CONTACT = $tp->toHTML($tm,TRUE,'LINKTEXT');
- }
- return $EC_EVENT_CONTACT;
-SC_END
-
-SC_BEGIN EC_EVENT_THREAD
- global $thisevent, $ec_images_path;
- return (isset($thisevent['event_thread']) && ($thisevent['event_thread'] != "")) ? "
".EC_LAN_39."" : "";
-SC_END
-
-SC_BEGIN EC_EVENT_OPTIONS
- global $EC_EVENT_OPTIONS, $thisevent, $event_author_name, $cal_super, $pref, $ec_images_path;
- if (USERNAME == $event_author_name || $cal_super || check_class($pref['eventpost_admin']))
- {
- $EC_EVENT_OPTIONS = "
";
- }
- return $EC_EVENT_OPTIONS;
-SC_END
-
-SC_BEGIN EC_EC_EVENT_LINK
- global $thisevent, $PLUGINS_DIRECTORY;
- $cal_dayarray = getdate($thisevent['event_start']);
- $cal_linkut = mktime(0 , 0 , 0 , $cal_dayarray['mon'], $cal_dayarray['mday'], $cal_dayarray['year']).".one"; // ALways need "one"
-// return " ".SITEURL.$PLUGINS_DIRECTORY. "calendar_menu/event.php?".$cal_linkut." ";
- return " ".$pref['siteurl'].$PLUGINS_DIRECTORY. "calendar_menu/event.php?".$cal_linkut." ";
-SC_END
-
-
-SC_BEGIN EC_EVENT_EVENT_DATE_TIME
- global $thisevent, $tp, $EVENT_EVENT_DATETIME;
- $et = 0;
- if (intval($thisevent['event_end']/86400) == intval($thisevent['event_start']/86400)) $et += 1;
- if ($thisevent['event_allday']) $et += 2;
- return $tp->parseTemplate($EVENT_EVENT_DATETIME[$et]);
-SC_END
-
-
-SC_BEGIN EC_EVENT_SHORT_DATE
- global $thisevent, $ecal_class;
- return $ecal_class->next_date_string($thisevent['event_start']);
-SC_END
-
-
-SC_BEGIN EC_IFNOT_ALLDAY
- global $thisevent, $tp;
- if ($thisevent['event_allday']) return;
- if (trim($parm) == "") return;
- return $tp->parseTemplate('{'.$parm.'}');
-SC_END
-
-SC_BEGIN EC_IF_ALLDAY
- global $thisevent, $tp;
- if (!$thisevent['event_allday']) return;
- if (trim($parm) == "") return;
- return $tp->parseTemplate('{'.$parm.'}');
-SC_END
-
-
-SC_BEGIN EC_IFNOT_SAMEDAY
- global $thisevent, $tp;
- if (intval($thisevent['event_end']/86400) == intval($thisevent['event_start']/86400)) return "";
- if (!$thisevent['event_allday']) return;
- if (trim($parm) == "") return;
- return $tp->parseTemplate('{'.$parm.'}');
-SC_END
-
-SC_BEGIN EC_IF_SAMEDAY
- global $thisevent, $tp;
- if (intval($thisevent['event_end']/86400) != intval($thisevent['event_start']/86400)) return "";
- if (!$thisevent['event_allday']) return;
- if (trim($parm) == "") return;
- return $tp->parseTemplate('{'.$parm.'}');
-SC_END
// FORTHCOMING EVENTS MENU
-//--------------------------------------------
+//---------------------------
-SC_BEGIN EC_NEXT_EVENT_RECENT_ICON
- global $cal_row;
- if (!$pref['eventpost_fe_showrecent']) return;
- if (!isset($cal_row['is_recent'])) return;
- $recent_icon = EC_RECENT_ICON;
- if (file_exists($recent_icon))
+ function sc_ec_next_event_recent_icon()
{
- return "
";
- }
- return "";
-SC_END
-
-SC_BEGIN EC_NEXT_EVENT_TIME
- global $cal_row, $ecal_class;
- if ($cal_row['event_allday'] != 1) return $ecal_class->time_string($cal_row['event_start']); else return '';
-SC_END
-
-SC_BEGIN EC_NEXT_EVENT_DATE
- global $cal_row, $ecal_class;
- return $ecal_class->next_date_string($cal_row['event_start']);
-SC_END
-
-SC_BEGIN EC_NEXT_EVENT_TITLE
- global $pref, $cal_row;
- if (isset($pref['eventpost_namelink']) && ($pref['eventpost_namelink'] == '2') && (isset($cal_row['event_thread']) && ($cal_row['event_thread'] != "")))
- {
- $fe_event_title = "";
- }
- else
- {
- $fe_event_title = "";
- }
- $fe_event_title .= $cal_row['event_title']."";
- return $fe_event_title;
-SC_END
-
-SC_BEGIN EC_NEXT_EVENT_ICON
- global $pref, $cal_row;
- $fe_icon_file = "";
- if ($pref['eventpost_showcaticon'] == 1)
- {
- if($cal_row['event_cat_icon'] && file_exists($ecal_dir."images/".$cal_row['event_cat_icon']))
+ global $pref;
+ if (!$pref['eventpost_fe_showrecent']) return;
+ if (!isset($this->event['is_recent'])) return;
+ $recent_icon = EC_RECENT_ICON;
+ if (is_readable($recent_icon))
{
- $fe_icon_file = $ecal_dir."images/".$cal_row['event_cat_icon'];
+ return "
";
}
- elseif(defined('BULLET'))
+ return '';
+ }
+
+
+ public function sc_ec_next_event_time()
+ {
+ if ($this->event['event_allday'] != 1)
{
- $fe_icon_file = THEME.'images/'.BULLET;
+ return $this->ecalClass->time_string($this->event['event_start']);
}
- elseif(file_exists(THEME.'images/bullet2.gif'))
+ return '';
+ }
+
+
+ public function sc_ec_next_event_date()
+ {
+ return $this->ecalClass->next_date_string($this->event['event_start']);
+ }
+
+
+ public function sc_ec_next_event_title()
+ {
+ global $pref;
+ if (isset($pref['eventpost_namelink']) && ($pref['eventpost_namelink'] == '2') && (isset($this->event['event_thread']) && ($this->event['event_thread'] != '')))
{
- $fe_icon_file = THEME.'images/bullet2.gif';
+ $fe_event_title = "";
}
- }
- return $fe_icon_file;
-SC_END
-
-SC_BEGIN EC_NEXT_EVENT_GAP
- global $cal_totev;
- if ($cal_totev) return "
"; else return "";
-SC_END
-
-
-// Event mailout shortcodes
-//--------------------------
-SC_BEGIN EC_MAIL_HEADING_DATE
- global $thisevent, $ecal_class;
- if (isset($parm) && ($parm !== ""))
- {
- return strftime($parm,$thisevent['event_start']);
- }
- else
- {
- return $ecal_class->event_date_string($thisevent['event_start']);
- }
-SC_END
-
-SC_BEGIN EC_MAIL_DATE_START
- global $thisevent, $ecal_class;
- if (isset($parm) && ($parm !== ""))
- {
- return strftime($parm,$thisevent['event_start']);
- }
- else
- {
- return $ecal_class->event_date_string($thisevent['event_start']);
- }
-SC_END
-
-SC_BEGIN EC_MAIL_TIME_START
- global $thisevent, $ecal_class;
- if ($thisevent['event_allday'] == 1) return "";
- $startds = $ecal_class->time_string($thisevent['event_start']);
- return $startds;
-SC_END
-
-SC_BEGIN EC_MAIL_DATE_END
- global $thisevent, $ecal_class;
- if ($thisevent['event_allday'] ||($thisevent['event_end'] == $thisevent['event_start'])) return "";
- if (isset($parm) && ($parm !== ""))
- {
- return strftime($parm,$thisevent['event_end']);
- }
- else
- {
- return $ecal_class->event_date_string($thisevent['event_end']);
- }
-SC_END
-
-SC_BEGIN EC_MAIL_TIME_END
- global $thisevent, $ecal_class;
- if ($thisevent['event_allday'] ||($thisevent['event_end'] == $thisevent['event_start'])) return "";
- $endds = $ecal_class->time_string($thisevent['event_end']);
- return $endds;
-SC_END
-
-SC_BEGIN EC_MAIL_TITLE
- global $thisevent;
- return $thisevent['event_title'];
-SC_END
-
-
-SC_BEGIN EC_MAIL_ID
- global $thisevent;
- return "calevent".$thisevent['event_id'];
-SC_END
-
-
-SC_BEGIN EC_MAIL_DETAILS
- global $EVENT_DETAILS, $thisevent, $tp;
- return $tp->toHTML($thisevent['event_details'], TRUE,'BODY, no_make_clickable');
-SC_END
-
-
-SC_BEGIN EC_MAIL_CATEGORY
- global $EVENT_CATEGORY, $thisevent;
- $EVENT_CATEGORY = $thisevent['event_cat_name'];
- return $EVENT_CATEGORY;
-SC_END
-
-SC_BEGIN EC_MAIL_LOCATION
- global $EVENT_LOCATION, $thisevent;
- if ($thisevent['event_location'] == "")
- {
- $EVENT_LOCATION = "";
+ else
+ {
+ $fe_event_title = "event['event_id']."'>";
+ }
+ $fe_event_title .= $this->event['event_title']."";
+ return $fe_event_title;
}
- else
+
+
+ public function sc_ec_next_event_icon()
{
- $EVENT_LOCATION = $thisevent['event_location'];
+ global $pref;
+ $fe_icon_file = '';
+ if ($pref['eventpost_showcaticon'] == 1)
+ {
+ if($this->event['event_cat_icon'] && is_readable(e_PLUGIN.'calendar_menu/images/'.$this->event['event_cat_icon']))
+ {
+ $fe_icon_file = e_PLUGIN_ABS.'calendar_menu/images/'.$this->event['event_cat_icon'];
+ }
+ elseif(defined('BULLET'))
+ {
+ $fe_icon_file = THEME.'images/'.BULLET;
+ }
+ elseif(file_exists(THEME.'images/bullet2.gif'))
+ {
+ $fe_icon_file = THEME.'images/bullet2.gif';
+ }
+ }
+ return $fe_icon_file;
}
- return $EVENT_LOCATION;
-SC_END
-SC_BEGIN EC_MAIL_CONTACT
- global $MAIL_CONTACT, $thisevent,$tp;
- if ($thisevent['event_contact'] == "")
+ public function sc_ec_next_event_gap()
{
- $MAIL_CONTACT = "";
+ if ($this->numEvents) return '
'; // Return a newline as a gap on all but last item
+ return '';
}
- else
- {
- $MAIL_CONTACT = $tp->toHTML($thisevent['event_contact'],TRUE,"LINKTEXT");
- }
- return $MAIL_CONTACT;
-SC_END
-
-SC_BEGIN EC_MAIL_THREAD
- global $thisevent;
- return (isset($thisevent['event_thread']) && ($thisevent['event_thread'] != "")) ? $thisevent['event_thread'] : "";
-SC_END
-
-SC_BEGIN EC_MAIL_LINK
- global $thisevent, $PLUGINS_DIRECTORY, $pref;
- $cal_dayarray = getdate($thisevent['event_start']);
- $cal_linkut = mktime(0 , 0 , 0 , $cal_dayarray['mon'], $cal_dayarray['mday'], $cal_dayarray['year']).".one"; // ALways need "one"
-// return " ".SITEURL.$PLUGINS_DIRECTORY. "calendar_menu/event.php?".$cal_linkut." ";
- return " ".$pref['siteurl'].$PLUGINS_DIRECTORY. "calendar_menu/event.php?".$cal_linkut." ";
-SC_END
-SC_BEGIN EC_MAIL_SHORT_DATE
- global $thisevent, $ecal_class;
- return $ecal_class->next_date_string($thisevent['event_start']);
-SC_END
-
-// Codes can be used to return a LAN to help with multi-language
-SC_BEGIN EC_MAIL_SUBJECT
- return EC_MAILOUT_SUBJECT;
-SC_END
// Specific to the 'listings' page
//--------------------------------
-SC_BEGIN EC_PR_LIST_TITLE
- global $ec_list_title;
- return $ec_list_title;
-SC_END
+
+ public function sc_ec_pr_list_title()
+ {
+ return $this->printVars['lt'];
+ }
-SC_BEGIN EC_PR_CAT_LIST
- global $ec_category_list;
- if (is_array($ec_category_list))
- return implode(", ",$ec_category_list);
- else
- return $ec_category_list;
-SC_END
+
+ public function sc_ec_pr_cat_list()
+ {
+ if (is_array($this->printVars['cat']))
+ {
+ return implode(', ',$this->printVars['cat']);
+ }
+ return $this->printVars['cat'];
+ }
+
+ public function sc_ec_pr_change_year()
+ {
+ if (!$this->changeFlags['yc']) return '';
+ $thisevent_start_date = $this->ecalClass->gmgetdate($this->event['event_start']);
+ return $thisevent_start_date['year'];
+ }
+
+ public function sc_ec_pr_change_month()
+ {
+ if (!$this->changeFlags['mc']) return '';
+ $thisevent_start_date = $this->ecalClass->gmgetdate($this->event['event_start']);
+ return $thisevent_start_date['month'];
+ }
-SC_BEGIN EC_PR_CHANGE_YEAR
- global $ec_year_change, $thisevent_start_date;
- if ($ec_year_change) return $thisevent_start_date['year'];
-SC_END
+ public function sc_ec_pr_list_start($parm = '')
+ {
+ if ($parm)
+ {
+ return $this->ecalClass->event_date_string($this->printVars['sd']);
+ }
+ return strftime($parm,$this->printVars['sd']);
+ }
+
+ public function sc_ec_pr_list_end($parm = '')
+ {
+ if ($parm)
+ {
+ return $this->ecalClass->event_date_string($this->printVars['ed']);
+ }
+ return strftime($parm,$this->printVars['ed']);
+ }
-SC_BEGIN EC_PR_CHANGE_MONTH
- global $ec_month_change, $thisevent_start_date;
- if ($ec_month_change) return $thisevent_start_date['month'];
-SC_END
+ public function sc_ec_now_date($parm = '')
+ {
+ if ($parm == '') return $this->ecalClass->event_date_string(time());
+ return strftime($parm,time());
+ }
+
+ public function sc_ec_now_time($parm = '')
+ {
+ if ($parm == '') return $this->ecalClass->time_string(time());
+ return strftime($parm,time());
+ }
-SC_BEGIN EC_PR_LIST_START
- global $ecal_class, $ec_start_date;
- if (isset($parm) && ($parm !== ""))
- {
- return strftime($parm,$ec_start_date);
- }
- else
- {
- return $ecal_class->event_date_string($ec_start_date);
- }
-SC_END
+ public function sc_ec_print_button()
+ {
+ if ($this->printVars['ot'] != 'print') return;
+ return "";
+ }
-SC_BEGIN EC_PR_LIST_END
- global $ecal_class, $ec_end_date;
- if (isset($parm) && ($parm !== ""))
- return strftime($parm,$ec_end_date);
- else
- return $ecal_class->event_date_string($ec_end_date);
-SC_END
+ public function sc_ec_if_print($parm = '')
+ {
+ if ($this->printVars['ot'] != 'print') return;
+ if (trim($parm) == '') return;
+ return $this->e107->tp->parseTemplate('{'.$parm.'}');
+ }
+
+ public function sc_ec_ifnot_print($parm = '')
+ {
+ if ($this->printVars['ot'] == 'print') return;
+ if (trim($parm) == '') return;
+ return $this->e107->tp->parseTemplate('{'.$parm.'}');
+ }
+
+ public function sc_ec_if_display($parm = '')
+ {
+ if ($this->printVars['ot'] != 'display') return;
+ if (trim($parm) == '') return;
+ return $this->e107->tp->parseTemplate('{'.$parm.'}');
+ }
+
+ public function sc_ec_ifnot_display($parm = '')
+ {
+ if ($this->printVars['ot'] == 'display') return;
+ if (trim($parm) == '') return;
+ return $this->e107->tp->parseTemplate('{'.$parm.'}');
+ }
+
+ public function sc_ec_if_pdf($parm = '')
+ {
+ if ($this->printVars['ot'] != 'pdf') return;
+ if (trim($parm) == '') return;
+ return $this->e107->tp->parseTemplate('{'.$parm.'}');
+ }
+
+ public function sc_ec_ifnot_pdf($parm = '')
+ {
+ if ($this->printVars['ot'] == 'pdf') return;
+ if (trim($parm) == '') return;
+ return $this->e107->tp->parseTemplate('{'.$parm.'}');
+ }
+
+} // END - shortcode class
-SC_BEGIN EC_NOW_DATE
- global $ecal_class;
- if (isset($parm) && ($parm !== ""))
- return strftime($parm,time());
- else
- return $ecal_class->event_date_string(time());
-SC_END
-
-
-SC_BEGIN EC_NOW_TIME
- global $ecal_class;
- if (isset($parm) && ($parm !== ""))
- return strftime($parm,time());
- else
- return $ecal_class->time_string(time());
-SC_END
-
-
-SC_BEGIN EC_PRINT_BUTTON
- global $ec_output_type;
- if ($ec_output_type != 'print') return;
- return "";
-SC_END
-
-
-SC_BEGIN EC_IF_PRINT
- global $ec_output_type, $tp;
- if ($ec_output_type != 'print') return;
- if (trim($parm) == "") return;
- return $tp->parseTemplate('{'.$parm.'}');
-SC_END
-
-SC_BEGIN EC_IFNOT_PRINT
- global $ec_output_type, $tp;
- if ($ec_output_type == 'print') return;
- if (trim($parm) == "") return;
- return $tp->parseTemplate('{'.$parm.'}');
-SC_END
-
-SC_BEGIN EC_IF_DISPLAY
- global $ec_output_type, $tp;
- if ($ec_output_type != 'display') return;
- if (trim($parm) == "") return;
- return $tp->parseTemplate('{'.$parm.'}');
-SC_END
-
-SC_BEGIN EC_IFNOT_DISPLAY
- global $ec_output_type, $tp;
- if ($ec_output_type == 'display') return;
- if (trim($parm) == "") return;
- return $tp->parseTemplate('{'.$parm.'}');
-SC_END
-
-SC_BEGIN EC_IF_PDF
- global $ec_output_type, $tp;
- if ($ec_output_type != 'pdf') return;
- if (trim($parm) == "") return;
- return $tp->parseTemplate('{'.$parm.'}');
-SC_END
-
-SC_BEGIN EC_IFNOT_PDF
- global $ec_output_type, $tp;
- if ($ec_output_type == 'pdf') return;
- if (trim($parm) == "") return;
- return $tp->parseTemplate('{'.$parm.'}');
-SC_END
-
-SC_BEGIN EC_PDF_OPTS
- global $ec_pdf_options;
- $ec_pdf_options = $parm;
-SC_END
-
-*/
-?>
\ No newline at end of file
+?>
diff --git a/e107_plugins/calendar_menu/calendar_template.php b/e107_plugins/calendar_menu/calendar_template.php
index cbd9c1890..4b472f35b 100644
--- a/e107_plugins/calendar_menu/calendar_template.php
+++ b/e107_plugins/calendar_menu/calendar_template.php
@@ -6,18 +6,20 @@
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
- *
+ * Templates for event calendar displays
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/calendar_template.php,v $
- * $Revision: 1.9 $
- * $Date: 2009-11-18 01:05:23 $
- * $Author: e107coders $
+ * $Revision: 1.10 $
+ * $Date: 2009-11-22 10:11:29 $
+ * $Author: e107steved $
*/
+// TODO: Replace expandit on events with latest auto-management
+
if (!defined('e107_INIT')) { exit; }
-if (!defined("USER_WIDTH")){ define("USER_WIDTH","width:auto"); }
-
+if (!defined('USER_WIDTH')){ define('USER_WIDTH','width:auto'); }
+//global $sc_style;
$ec_images_path = e_IMAGE;
$ec_images_path_abs = e_IMAGE_ABS;
@@ -163,11 +165,14 @@ $EVENT_EVENT_DATETIME[0] = "{EC_EVENT_DATE_START}".EC_LAN_144."{EC_EVENT_TIME_S
$EVENT_EVENT_DATETIME[1] = "{EC_EVENT_DATE_START} ".EC_LAN_84." {EC_EVENT_TIME_START}".EC_LAN_85."{EC_EVENT_TIME_END}";
$EVENT_EVENT_DATETIME[2] = "{EC_EVENT_DATE_START} ".EC_LAN_69." {EC_EVENT_DATE_END}";
$EVENT_EVENT_DATETIME[3] = "{EC_EVENT_DATE_START}";
+
+
+/* This is roughly what's wanted, but div not allowed
$EVENT_EVENT_TABLE = "
- {EC_EVENT_RECENT_ICON}{EC_EVENT_CAT_ICON}{EC_EVENT_HEADING_DATE}{EC_IFNOT_ALLDAY=EC_EVENT_TIME_START} - {EC_EVENT_TITLE}
-
+ {EC_EVENT_RECENT_ICON}{EC_EVENT_CAT_ICON}{EC_EVENT_HEADING_DATE}{EC_IFNOT_ALLDAY=EC_EVENT_TIME_START} - {EC_EVENT_TITLE}
+
\n
@@ -179,8 +184,27 @@ $EVENT_EVENT_TABLE = "
\n
";
+*/
+// This works, but not using latest class structure
+$EVENT_EVENT_TABLE = "
+
+
+ {EC_EVENT_RECENT_ICON}{EC_EVENT_CAT_ICON}{EC_EVENT_HEADING_DATE}{EC_IFNOT_ALLDAY=EC_EVENT_TIME_START} - {EC_EVENT_TITLE}
+
+
+
+ \n
+ {EC_EVENT_LOCATION}
+ {EC_EVENT_DETAILS}
+ {EC_EVENT_THREAD}
+
+
+ |
+ \n
+";
+
//------------------------------------------
// CALENDAR CALENDAR - 'Big' calendar
//------------------------------------------
diff --git a/e107_plugins/calendar_menu/e_cron.php b/e107_plugins/calendar_menu/e_cron.php
new file mode 100644
index 000000000..c8ccca362
--- /dev/null
+++ b/e107_plugins/calendar_menu/e_cron.php
@@ -0,0 +1,408 @@
+e107 = e107::getInstance();
+ $this->debugLevel = 2;
+ }
+
+
+
+ /**
+ * Cron configuration
+ *
+ * Defines one or more cron tasks to be performed
+ *
+ * @return array of task arrays
+ */
+ public function config()
+ {
+ $cron = array();
+ $cron[] = array('name' => LAN_EC_MAIL_04, 'function' => 'processSubs', 'description' => LAN_EC_MAIL_05);
+ return $cron;
+ }
+
+
+ private function checkDB()
+ {
+ if ($this->ourDB == NULL)
+ {
+ $this->ourDB = new db;
+ }
+ }
+
+
+ /**
+ * Logging routine - writes lines to a text file
+ *
+ * Auto-opens log file (if necessary) on first call
+ *
+ * @param string $logText - body of text to write
+ * @param boolean $closeAfter - if TRUE, log file closed before exit; otherwise left open
+ *
+ * @return none
+ */
+ function logLine($logText, $closeAfter = FALSE, $addTimeDate = FALSE)
+ {
+ if ($this->logRequirement == 0) return;
+
+ $logFilename = e_FILE.'logs/calendar_mail.txt';
+ if ($this->logHandle == NULL)
+ {
+ if (!($this->logHandle = fopen($logFilename, "a")))
+ { // Problem creating file?
+ echo "File open failed! ";
+ $this->logRequirement = 0;
+ return;
+ }
+ }
+
+ if (fwrite($this->logHandle,($addTimeDate ? date('D j M Y G:i:s').': ' : '').$logText."\r\n") == FALSE)
+ {
+ $this->logRequirement = 0;
+ echo 'File write failed! ';
+ }
+
+ if ($closeAfter)
+ {
+ fclose($this->logHandle);
+ $this->logHandle = NULL;
+ }
+ }
+
+
+
+ /**
+ * Called to process the calendar menu subscriptions list - the cron task must be set to call us once/day (typically at about 0100)
+ *
+ * Emails are added to the queue.
+ * Various events are logged in a text file
+ *
+ * @return none
+ */
+ public function processSubs()
+ {
+ global $pref;
+
+ require_once(e_PLUGIN.'calendar_menu/ecal_class.php');
+ $this->ecalClass = new ecal_class;
+
+ e107::getScParser();
+ require_once(e_PLUGIN.'calendar_menu/calendar_shortcodes.php');
+ if (is_readable(THEME.'ec_mailout_template.php'))
+ { // Has to be require
+ require(THEME.'ec_mailout_template.php');
+ }
+ else
+ {
+ require(e_PLUGIN.'calendar_menu/ec_mailout_template.php');
+ }
+
+
+ $this->startTime = mktime(0, 0, 0, date('n'), date('d'), date('Y')); // Date for start processing
+ setScVar('event_calendar_shortcodes', 'ecalClass', &$this->ecalClass); // Give shortcode a pointer to calendar class
+
+
+ $this->logRequirement = varset($pref['eventpost_emaillog'], 0);
+ if ($this->debugLevel >= 2) $this->logRequirement = 2; // Force full logging if debug
+
+
+ // Start of the 'real' code
+ $this->logLine("\r\n\r\n".LAN_EC_MAIL_06.date('D j M Y G:i:s'));
+
+
+ // Start with the 'in advance' emails
+ $cal_args = "select * from #event left join #event_cat on event_category=event_cat_id where (event_cat_subs>0 OR event_cat_force_class>0) and
+ event_cat_last < " . intval($this->startTime) . " and
+ event_cat_ahead > 0 and
+ event_start >= (" . intval($this->startTime) . "+(86400*(event_cat_ahead))) and
+ event_start < (" . intval($this->startTime) . "+(86400*(event_cat_ahead+1))) and
+ find_in_set(event_cat_notify,'1,3,5,7')";
+
+ $this->sendMailshot($cal_args, 'Advance',1, $calendar_shortcodes);
+
+
+ $insertString = 'event_cat_today < '.intval($this->startTime).' and';
+ if ($this->debugLevel > 0) $insertString = ''; // Allows us to so a mailshot every call of cron tick
+
+ // then for today
+ $cal_args = "select * from #event left join #event_cat on event_category=event_cat_id where (event_cat_subs>0 OR event_cat_force_class>0) and
+ {$insertString} event_start >= (" . intval($this->startTime) . ") and
+ event_start < (86400+" . intval($this->startTime) . ") and
+ find_in_set(event_cat_notify,'2,3,6,7')";
+
+ $this->sendMailshot($cal_args, 'today',2, $calendar_shortcodes);
+
+
+ // Finally do 'day before' emails (its an alternative to 'today' emails)
+ $cal_args = "select * from #event left join #event_cat on event_category=event_cat_id where (event_cat_subs>0 OR event_cat_force_class>0) and
+ {$insertString} event_start >= (" . intval($this->startTime) ." + 86400 ) and
+ event_start < (" . intval($this->startTime) ." + 172800) and
+ find_in_set(event_cat_notify,'4,5,6,7')";
+
+ $this->sendMailshot($cal_args, 'tomorrow',2, $calendar_shortcodes);
+
+
+ $this->logLine(' .. Run completed',TRUE, TRUE);
+ return TRUE;
+ }
+
+
+ // Function called to load in default templates (messages) if required - only accesses database once
+ function loadDefaultMessages()
+ {
+ if (($this->defaultMessage[1] != '') && ($this->defaultMessage[2] != '')) return;
+ $this->checkDB();
+ if ($this->ourDB->db_Select('event_cat', 'event_cat_msg1,event_cat_msg2', "event_cat_name = '".EC_DEFAULT_CATEGORY."' "))
+ {
+ if ($row = $this->ourDB->db_Fetch())
+ {
+ $this->defaultMessage[1] = $row['event_cat_msg1'];
+ $this->defaultMessage[2] = $row['event_cat_msg2'];
+ }
+ }
+ // Put in generic message rather than nothing - will help flag omission
+ if ($this->defaultMessage[1] == '') $this->defaultMessage[1] = EC_LAN_146;
+ if ($this->defaultMessage[2] == '') $this->defaultMessage[2] = EC_LAN_147;
+ }
+
+
+ private function checkMailManager()
+ {
+ if ($this->mailManager == NULL)
+ {
+ require_once(e_HANDLER .'mail_manager_class.php');
+ $this->mailManager = new e107MailManager();
+ }
+ }
+
+
+ /*
+ Function to actually send a mailshot
+ */
+ function sendMailshot($cal_query, $shot_type, $msg_num, $calendar_shortcodes)
+ {
+ global $pref;
+
+ if ($this->logRequirement > 1)
+ {
+ $this->logLine(' Starting emails for '.$shot_type, FALSE, TRUE);
+ if ($this->debugLevel >= 2) $this->logLine("\r\n Query is: ".$cal_query);
+ }
+
+ if ($num_cat_proc = $this->e107->sql->db_Select_gen($cal_query))
+ { // Got at least one event to process here
+ if ($this->logRequirement > 1)
+ $this->logLine(' - '.$num_cat_proc.' categories found to process');
+
+ $this->checkDB(); // Make sure we've got another DB object
+ while ($thisevent = $this->e107->sql->db_Fetch())
+ { // Process one event at a time
+
+ $this->logLine(' Processing event: '.$event_title);
+ setScVar('event_calendar_shortcodes', 'event', $thisevent); // Save current values in shortcode
+
+ // Note that event processed, and generate the email
+ if ($msg_num == 1)
+ {
+ $this->ourDB->db_Update('event_cat', 'event_cat_last='.time().' where event_cat_id='.intval($event_cat_id));
+ $cal_msg = $thisevent['event_cat_msg1'];
+ }
+ else
+ {
+ $this->ourDB->db_Update('event_cat', 'event_cat_today='.time().' where event_cat_id='.intval($event_cat_id));
+ $cal_msg = $thisevent['event_cat_msg2'];
+ }
+
+ if (trim($cal_msg) == '')
+ {
+ $this->loadDefaultMessages();
+ $cal_msg = $this->defaultMessage[$msg_num];
+ }
+
+
+ // Parsing the template here means we can't use USER-related shortcodes
+ // Main ones which are relevant: MAIL_DATE_START, MAIL_TIME_START, MAIL_DATE_END,
+ // MAIL_TIME_END, MAIL_TITLE, MAIL_DETAILS, MAIL_CATEGORY, MAIL_LOCATION,
+ // MAIL_CONTACT, MAIL_THREAD (maybe). Also MAIL_LINK, MAIL_SHORT_DATE
+ // Best to strip entities here rather than at entry - handles old events as well
+ // Note that certain user-related substitutions will work, however - |USERID|, |USERNAME|, |DISPLAYNAME|
+ $cal_title = html_entity_decode($this->e107->tp->parseTemplate($pref['eventpost_mailsubject'], TRUE),ENT_QUOTES,CHARSET);
+ $cal_msg = html_entity_decode($this->e107->tp->parseTemplate($cal_msg, TRUE),ENT_QUOTES,CHARSET);
+
+ // Four cases for the query:
+ // 1. No forced mailshots - based on event_subs table only Need INNER JOIN
+ // 2. Forced mailshot to members - send to all users (don't care about subscriptions) Don't need JOIN
+ // 3. Forced mailshot to group of members - based on user table only Don't need JOIN
+ // 4. Forced mailshot to group, plus optional subscriptions - use the lot! Need LEFT JOIN
+ // (Always block sent to banned members)
+ $manual_subs = (isset($pref['eventpost_asubs']) && ($pref['eventpost_asubs'] == '1'));
+ $subs_fields = '';
+ $subs_join = '';
+ $whereClause = '';
+ $group_clause = '';
+
+ if ($event_cat_force_class != e_UC_MEMBER)
+ { // Cases 1, 3, 4 (basic query does for case 2)
+ if ((!$thisevent['event_cat_force_class']) || ($manual_subs))
+ { // Cases 1 & 4 - need to join with event_subs database
+ $subs_fields = ", es.* ";
+ if ($thisevent['event_cat_force_class']) $subs_join = 'LEFT'; else $subs_join = 'INNER';
+ $subs_join .= ' join `#event_subs` AS es on u.`user_id`=es.`event_userid` ';
+ $whereClause = ' es.`event_cat`='.intval($thisevent['event_category']).' ';
+ $group_clause = ' GROUP BY u.`user_id`';
+ }
+
+ if ($event_cat_force_class)
+ { // cases 3 and 4 - ... and check for involuntary subscribers
+ if ($whereClause) $whereClause .= ' OR ';
+ if ($thisevent['event_cat_force_class'] == e_UC_ADMIN)
+ {
+ $whereClause .= '(u.`user_admin` = 1 )';
+ }
+ else
+ {
+ $whereClause .= "find_in_set('".intval($thisevent['event_cat_force_class'])."', u.`user_class`)";
+ $group_clause = ' GROUP BY u.`user_id`';
+ }
+ }
+
+ if ($whereClause) $whereClause = ' AND ('.$whereClause.' ) ';
+ } // End of cases 1, 3, 4
+
+ $cal_emilargs = "SELECT u.`user_id`, u.`user_class`, u.`user_email`, u.`user_name`, u.`user_ban`, u.`user_admin`{$subs_fields}
+ from `#user` AS u {$subs_join}
+ WHERE u.`user_ban` = 0 {$whereClause} {$group_clause}";
+
+
+ if ($this->debugLevel >= 2)
+ {
+ $this->logLine("\r\n Email selection query is: ".$cal_emilargs);
+ }
+ if ($num_shots = $this->ourDB->db_Select_gen($cal_emilargs))
+ {
+ $this->logLine(' - '.$num_shots.' emails found to send');
+
+ // Definitely got some emails to send here
+ $this->checkMailManager(); // Make sure our mail manager is loaded
+
+ // Start by adding the email details
+ $email = array(
+ 'mail_create_app' => 'calendar_menu',
+ 'mail_title' => str_replace('--REF--', intval(time()/3600), LAN_EC_MAIL_07),
+ 'mail_subject' => $cal_title,
+ 'mail_body' => $cal_msg,
+ 'mail_sender_email' => $pref['eventpost_mailaddress'],
+ 'mail_sender_name' => $pref['eventpost_mailfrom'],
+ 'mail_send_style' => 'textonly'
+ );
+ if (FALSE === ($mailMainID = $this->mailManager->saveEmail($email, TRUE)))
+ {
+ $this->logLine('Error adding mail body to database - run abandoned');
+ break;
+ }
+ $this->mailManager->mailInitCounters($mailMainID); // Initialise counters for emails added
+
+
+ // Now loop through adding users
+ while ($row = $this->ourDB->db_Fetch())
+ {
+ if ($ec_debug_level == 0)
+ {
+ $recipient = array(
+ 'mail_recipient_id' => $row['user_id'],
+ 'mail_recipient_name' => $row['user_name'],
+ 'mail_recipient_email' => $row['user_email'],
+ 'mail_target_info' => array( // Adding this info means it could be substituted
+ 'USERID' => $row['user_id'],
+ 'DISPLAYNAME' => $row['user_name'],
+ 'USERNAME' => $row['user_loginname']
+ )
+ );
+ $result = $this->mailManager->mailAddNoDup($mailMainID, $recipient, MAIL_STATUS_TEMP);
+ if ($result === FALSE)
+ {
+ $this->logLine("Error adding recipient {$row['user_id']}");
+ }
+ }
+ else
+ {
+ $send_result = " **DEBUG**";
+ }
+ if ($ec_log_requirement > 1)
+ {
+ $this->logLine(' Send to '.$user_id.':'.$user_email.' Name: '.$user_name.' Result = '.$send_result);
+ }
+ }
+ $this->mailManager->mailUpdateCounters($mailMainID); // Save counters to DB
+ if ($this->mailManager->activateEmail($mailMainID, FALSE, time() + 80000) === TRUE)
+ {
+ $this->logLine("Email {$mailMainID} activated");
+ }
+ else
+ {
+ $this->logLine("Error activating email {$mailMainID}");
+ }
+ }
+ elseif ($num_cat === FALSE)
+ {
+ $this->logLine(' User read error for '.$shot_type.': '.$this->ourDB->$mySQLlastErrNum.':'.$this->ourDB->$mySQLlastErrText);
+ }
+ elseif ($this->logRequirement > 1)
+ {
+ $this->logLine(' - no users found.');
+ }
+ } // while
+
+ if ($this->logRequirement > 1)
+ {
+ $this->logLine(' Completed emails for '.$shot_type.' at '.date('D j M Y G:i:s'));
+ }
+ }
+ elseif ($num_cat === FALSE)
+ {
+ $this->logLine(' DB read error for '.$shot_type.': '.$this->e107->sql->$mySQLlastErrNum.':'.$this->e107->sql->$mySQLlastErrText);
+ }
+ elseif ($this->logRequirement > 1)
+ {
+ $this->logLine(' - no records found.');
+ }
+ }
+}
+
+
+
+?>
\ No newline at end of file
diff --git a/e107_plugins/calendar_menu/ec_mailout_template.php b/e107_plugins/calendar_menu/ec_mailout_template.php
index b8ca87eea..7536080af 100644
--- a/e107_plugins/calendar_menu/ec_mailout_template.php
+++ b/e107_plugins/calendar_menu/ec_mailout_template.php
@@ -6,65 +6,73 @@
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
- *
+ * Event calendar mailout - template file
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/ec_mailout_template.php,v $
- * $Revision: 1.3 $
- * $Date: 2009-11-18 01:05:23 $
- * $Author: e107coders $
+ * $Revision: 1.4 $
+ * $Date: 2009-11-22 10:11:29 $
+ * $Author: e107steved $
*/
/*
This template is used during the subscription mailouts - it is inserted at the front of the text
defined for each category.
Main purpose is to define the 'pre' and 'post' styles, but it can be used much as any E107 template
+
+Language constants should be in the English_mailer.php file
*/
if (!defined('e107_INIT')) { exit; }
-$sc_style['EC_MAIL_HEADING_DATE']['pre'] = "";
-$sc_style['EC_MAIL_HEADING_DATE']['post'] = "";
+global $sc_style;
-$sc_style['EC_MAIL_SHORT_DATE']['pre'] = "";
-$sc_style['EC_MAIL_SHORT_DATE']['post'] = "";
+$sc_style['EC_MAIL_HEADING_DATE']['pre'] = '';
+$sc_style['EC_MAIL_HEADING_DATE']['post'] = '';
-$sc_style['EC_MAIL_TITLE']['pre'] = "";
-$sc_style['EC_MAIL_TITLE']['post'] = "";
+$sc_style['EC_MAIL_SHORT_DATE']['pre'] = '';
+$sc_style['EC_MAIL_SHORT_DATE']['post'] = '';
-$sc_style['EC_MAIL_ID']['pre'] = "";
-$sc_style['EC_MAIL_ID']['post'] = "";
+$sc_style['EC_MAIL_TITLE']['pre'] = '';
+$sc_style['EC_MAIL_TITLE']['post'] = '';
-$sc_style['EC_MAIL_DETAILS']['pre'] = "";
-$sc_style['EC_MAIL_DETAILS']['post'] = "";
+$sc_style['EC_MAIL_ID']['pre'] = '';
+$sc_style['EC_MAIL_ID']['post'] = '';
-$sc_style['EC_MAIL_LOCATION']['pre'] = EC_LAN_32." ";
-$sc_style['EC_MAIL_LOCATION']['post'] = "";
+$sc_style['EC_MAIL_DETAILS']['pre'] = '';
+$sc_style['EC_MAIL_DETAILS']['post'] = '';
-$sc_style['EC_MAIL_AUTHOR']['pre'] = EC_LAN_31." ";
-$sc_style['EC_MAIL_AUTHOR']['post'] = "";
+$sc_style['EC_MAIL_LOCATION']['pre'] = LAN_EC_MAIL_100.' ';
+$sc_style['EC_MAIL_LOCATION']['post'] = '';
-$sc_style['EC_MAIL_CONTACT']['pre'] = EC_LAN_33." ";
-$sc_style['EC_MAIL_CONTACT']['post'] = "";
+$sc_style['EC_MAIL_AUTHOR']['pre'] = LAN_EC_MAIL_101.' ';
+$sc_style['EC_MAIL_AUTHOR']['post'] = '';
-$sc_style['EC_MAIL_THREAD']['pre'] = "";
-$sc_style['EC_MAIL_THREAD']['post'] = "";
+$sc_style['EC_MAIL_CONTACT']['pre'] = LAN_EC_MAIL_102.' ';
+$sc_style['EC_MAIL_CONTACT']['post'] = '';
-$sc_style['EC_MAIL_LINK']['pre'] = "";
-$sc_style['EC_MAIL_LINK']['post'] = "";
+$sc_style['EC_MAIL_THREAD']['pre'] = '';
+$sc_style['EC_MAIL_THREAD']['post'] = '';
-$sc_style['EC_MAIL_CATEGORY']['pre'] = "";
-$sc_style['EC_MAIL_CATEGORY']['post'] = "";
+$sc_style['EC_MAIL_LINK']['pre'] = '';
+$sc_style['EC_MAIL_LINK']['post'] = '';
-$sc_style['EC_MAIL_DATE_START']['pre'] = (isset($thisevent['event_allday']) && $thisevent['event_allday']) ? EC_LAN_68." " : EC_LAN_29." ";
-$sc_style['EC_MAIL_DATE_START']['post'] = "";
+$sc_style['EC_MAIL_CATEGORY']['pre'] = '';
+$sc_style['EC_MAIL_CATEGORY']['post'] = '';
-$sc_style['EC_MAIL_TIME_START']['pre'] = EC_LAN_144;
-$sc_style['EC_MAIL_TIME_START']['post'] = "";
+$sc_style['EC_MAIL_DATE_START']['pre'] = '';
+$sc_style['EC_MAIL_DATE_START']['post'] = '';
+$sc_style['EC_MAIL_DATE_START_ALLDAY']['pre'] = LAN_EC_MAIL_103.' ';
+$sc_style['EC_MAIL_DATE_START_ALLDAY']['post'] = '';
+$sc_style['EC_MAIL_DATE_START_TIMED']['pre'] = LAN_EC_MAIL_104.' ';
+$sc_style['EC_MAIL_DATE_START_TIMED']['post'] = '';
-$sc_style['EC_MAIL_DATE_END']['pre'] = EC_LAN_69." ";
-$sc_style['EC_MAIL_DATE_END']['post'] = "";
+$sc_style['EC_MAIL_TIME_START']['pre'] = LAN_EC_MAIL_105;
+$sc_style['EC_MAIL_TIME_START']['post'] = '';
-$sc_style['EC_MAIL_TIME_END']['pre'] = EC_LAN_144;
-$sc_style['EC_MAIL_TIME_END']['post'] = "";
+$sc_style['EC_MAIL_DATE_END']['pre'] = LAN_EC_MAIL_106.' ';
+$sc_style['EC_MAIL_DATE_END']['post'] = '';
+
+$sc_style['EC_MAIL_TIME_END']['pre'] = LAN_EC_MAIL_105;
+$sc_style['EC_MAIL_TIME_END']['post'] = '';
?>
diff --git a/e107_plugins/calendar_menu/ec_pf_page.php b/e107_plugins/calendar_menu/ec_pf_page.php
index 830659bae..36ced8c1f 100644
--- a/e107_plugins/calendar_menu/ec_pf_page.php
+++ b/e107_plugins/calendar_menu/ec_pf_page.php
@@ -6,12 +6,12 @@
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
- *
+ * Event calendar - generate lists
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/ec_pf_page.php,v $
- * $Revision: 1.6 $
- * $Date: 2009-11-19 10:09:58 $
- * $Author: marj_nl_fr $
+ * $Revision: 1.7 $
+ * $Date: 2009-11-22 10:11:30 $
+ * $Author: e107steved $
*/
/*
|
@@ -28,35 +28,38 @@
+----------------------------------------------------------------------------+
*/
-require_once("../../class2.php");
-if (!isset($pref['plug_installed']['calendar_menu'])) header("Location: ".e_BASE."index.php");
-include_lan(e_PLUGIN."calendar_menu/languages/".e_LANGUAGE.".php");
-define("PAGE_NAME", EC_LAN_80);
+require_once('../../class2.php');
+$e107 = e107::getInstance();
+if (!$e107->isInstalled('calendar_menu')) header('Location: '.e_BASE.'index.php');
+include_lan(e_PLUGIN.'calendar_menu/languages/'.e_LANGUAGE.'.php');
+define('PAGE_NAME', EC_LAN_80);
require_once(e_PLUGIN.'calendar_menu/ecal_class.php');
$ecal_class = new ecal_class;
-require_once(e_PLUGIN."calendar_menu/calendar_shortcodes.php");
-$message = "";
+e107::getScParser();
+require_once(e_PLUGIN.'calendar_menu/calendar_shortcodes.php');
+
+$message = '';
unset($ec_qs);
-if (e_QUERY) $ec_qs = explode(".", e_QUERY);
+if (e_QUERY) $ec_qs = explode('.', e_QUERY);
else
{
if (!isset($pref['eventpost_printlists']) || ($pref['eventpost_printlists'] == 0))
- header("location:".SITEURL); // If disabled, just go back to index page
+ header('location:'.SITEURL); // If disabled, just go back to index page
}
if (isset($_POST['set_dates']) && isset($_POST['start_date']) && (isset($_POST['end_date'])))
{
- $ec_qs[0] = $_POST['start_date'];
- $ec_qs[1] = $_POST['end_date'];
- if (isset($_POST['event_cat_ids']))
- {
- $ec_qs[2] = $_POST['event_cat_ids'];
- if ($ec_qs[2] == 'all') $ec_qs[2] = '*';
- }
- if (isset($_POST['template_choice'])) $ec_qs[3] = $_POST['template_choice'];
+ $ec_qs[0] = $_POST['start_date'];
+ $ec_qs[1] = $_POST['end_date'];
+ if (isset($_POST['event_cat_ids']))
+ {
+ $ec_qs[2] = $_POST['event_cat_ids'];
+ if ($ec_qs[2] == 'all') $ec_qs[2] = '*';
+ }
+ if (isset($_POST['template_choice'])) $ec_qs[3] = $_POST['template_choice'];
}
if (!isset($ec_qs[3])) $ec_qs[3] = 'default'; // Template
@@ -66,7 +69,6 @@ if (!isset($ec_qs[4]) || (($ec_qs[4]) != 'print') && ($ec_qs[4] != 'pdf') ) $ec_
-global $cal_super, $calendar_shortcodes;
$cal_super = $ecal_class->cal_super;
// Get templates, since we may have to give a choice if we're displaying something
@@ -74,14 +76,14 @@ $cal_super = $ecal_class->cal_super;
$EVENT_CAL_PDF_HEADER = array();
$EVENT_CAL_PDF_BODY = array();
$EVENT_CAL_PDF_FOOTER = array();
-if (is_readable(e_PLUGIN."calendar_menu/ec_pf_template.php")) require_once(e_PLUGIN."calendar_menu/ec_pf_template.php");
-if (is_readable(e_PLUGIN."calendar_menu/ec_pf_user_template.php")) require_once(e_PLUGIN."calendar_menu/ec_pf_user_template.php");
-if (is_readable(THEME."ec_pf_template.php")) require_once(THEME."ec_pf_template.php");
+if (is_readable(e_PLUGIN.'calendar_menu/ec_pf_template.php')) require_once(e_PLUGIN.'calendar_menu/ec_pf_template.php');
+if (is_readable(e_PLUGIN.'calendar_menu/ec_pf_user_template.php')) require_once(e_PLUGIN.'calendar_menu/ec_pf_user_template.php');
+if (is_readable(THEME.'ec_pf_template.php')) require_once(THEME.'ec_pf_template.php');
// Hard-coded alternatives
-if (!count($EVENT_CAL_PDF_HEADER)) $EVENT_CAL_PDF_HEADER['default'] = " ";
-if (!count($EVENT_CAL_PDF_BODY)) $EVENT_CAL_PDF_BODY['default'] = "{EC_MAIL_DATE_START} {EC_MAIL_TIME_START} {EC_MAIL_TITLE} ";
-if (!count($EVENT_CAL_PDF_FOOTER)) $EVENT_CAL_PDF_FOOTER['default'] = " ";
+if (!count($EVENT_CAL_PDF_HEADER)) $EVENT_CAL_PDF_HEADER['default'] = ' ';
+if (!count($EVENT_CAL_PDF_BODY)) $EVENT_CAL_PDF_BODY['default'] = '{EC_MAIL_DATE_START} {EC_MAIL_TIME_START} {EC_MAIL_TITLE} ';
+if (!count($EVENT_CAL_PDF_FOOTER)) $EVENT_CAL_PDF_FOOTER['default'] = ' ';
if (!count($EVENT_CAL_PDF_NAMES)) $ec_pdf_template = 'default';
// If one name only, we just assign that
if (count($EVENT_CAL_PDF_NAMES) == 1)
@@ -113,7 +115,7 @@ if (!isset($ec_qs[0]) || !isset($ec_qs[1]))
";
if (isset($EVENT_CAL_PDF_NAMES) && is_array($EVENT_CAL_PDF_NAMES) && (count($EVENT_CAL_PDF_NAMES) > 1))
@@ -176,8 +178,9 @@ if ($message !== "")
exit;
}
+setScVar('event_calendar_shortcodes', 'ecalClass', &$ecal_class); // Give shortcodes a pointer to calendar class
+setScVar('event_calendar_shortcodes', 'catFilter', $cat_filter); // Category filter
-global $ec_current_month, $thisevent_start_date, $thisevent_end_date, $ec_output_type, $ec_category_list, $ec_list_title;
$ec_output_type = $ec_qs[4];
if (isset($ec_qs[5])) $ec_list_title = $ec_qs[5]; else $ec_list_title = EC_LAN_163;
$ec_list_title = str_replace('_',' ',$ec_list_title);
@@ -246,60 +249,67 @@ $ev_list = $ecal_class->get_events($ec_start_date, $ec_end_date, FALSE, $cat_fil
if (isset($ec_qs[3])) $ec_pdf_template = $ec_qs[3];
if (!isset($ec_pdf_template) || !array_key_exists($ec_pdf_template,$EVENT_CAL_PDF_NAMES)) $ec_pdf_template = 'default';
-
+/*
// These available to templates/shortcodes to pick up change of start day/month/year
global $ec_last_year, $ec_last_month, $ec_last_day, $ec_year_change, $ec_month_change, $ec_day_change;
global $ec_start_date, $ec_end_date, $ec_pdf_options;
+global $ec_current_month, $thisevent_start_date, $thisevent_end_date ;
+*/
+
+setScVar('event_calendar_shortcodes', 'printVars', array('lt' => $ec_list_title, 'cat' => $ec_category_list, 'ot' => $ec_output_type,
+ 'sd' => $ec_start_date, 'ed' => $ec_end_date)); // Give shortcodes the event data
+
$ec_last_year = 0;
$ec_last_month = 0;
$ec_last_day = 0;
-$ec_pdf_options = ""; // Can configure the PDF driver
-$cal_text = "";
+$cal_text = '';
$cal_totev = count($ev_list);
if ($cal_totev > 0)
{
- if (isset($ec_template_styles[$ec_pdf_template]) && is_array($ec_template_styles[$ec_pdf_template]))
- {
- $ec_current_overrides = $ec_template_styles[$ec_pdf_template]; // Possible array of codes to override standard $sc_style
- $sc_style = array_merge($sc_style,$ec_current_overrides); // Override as necessary
- }
+ if (isset($ec_template_styles[$ec_pdf_template]) && is_array($ec_template_styles[$ec_pdf_template]))
+ {
+ $ec_current_overrides = $ec_template_styles[$ec_pdf_template]; // Possible array of codes to override standard $sc_style
+ $sc_style = array_merge($sc_style,$ec_current_overrides); // Override as necessary
+ }
-// If printing, wrap in a form so the button works
- if ($ec_output_type == 'print') $cal_text .= "\n";
}
else
@@ -310,40 +320,36 @@ else
switch($ec_output_type)
{
case 'display':
- $ns->tablerender(EC_LAN_80, $cal_text, 'ec_pf_page');
+ $e107->ns->tablerender(EC_LAN_80, $cal_text, 'ec_pf_page');
require_once (FOOTERF);
break;
case 'print':
echo $cal_text;
- break;
+ break;
case 'pdf':
- //TODO use a better way to pass info to pdf
+ //TODO find a way to pass initialisation options etc to PDF driver
include_lan(e_PLUGIN.'pdf/languages/'.e_LANGUAGE.'.php');
define('FPDF_FONTPATH', 'font/');
//require the ufpdf class
require_once (e_PLUGIN.'pdf/ufpdf.php');
//require the e107pdf class
require_once (e_PLUGIN.'pdf/e107pdf.php');
- if('' == $ec_pdf_options)
- {
- $pdf = new e107PDF();
- }
- else
- {
- $pdf = new e107PDF($ec_pdf_options);
- }
+ $pdf = new e107PDF();
// $text = array($text, $creator, $author, $title, $subject, $keywords, $url);
- $text = array($cal_text,
- '',
- '',
- EC_LAN_163,
- '',
- '',
- e_SELF.e_QUERY);
+ $text = array(
+ $cal_text,
+ '',
+ '',
+ EC_LAN_163, // Title
+ '',
+ '',
+ e_SELF.'?'.e_QUERY, // URL
+ '' // Page orientation
+ );
$pdf->makePDF($text);
- break;
+ break;
}
@@ -424,31 +430,31 @@ function decode_date($date_string, $last_day = FALSE)
// For the last date we want end of next
function gen_drop($drop_type)
{
- $text = "\n";
+ return $text;
}
?>
diff --git a/e107_plugins/calendar_menu/ec_pf_template.php b/e107_plugins/calendar_menu/ec_pf_template.php
index ff7e61b89..d265525cd 100644
--- a/e107_plugins/calendar_menu/ec_pf_template.php
+++ b/e107_plugins/calendar_menu/ec_pf_template.php
@@ -1,4 +1,18 @@
';
$sc_style['EC_PR_CHANGE_YEAR']['post'] = '';
@@ -41,7 +55,7 @@ $sc_style['EC_PR_LIST_TITLE']['post'] = "";
$EVENT_CAL_PDF_NAMES['default'] = EC_LAN_165;
$EVENT_CAL_PDF_HEADER['default'] = "{EC_PR_LIST_TITLE} {EC_PR_CAT_LIST} ".EC_LAN_168."{EC_PR_LIST_START=%d-%m-%Y} ".EC_LAN_169."{EC_PR_LIST_END=%d-%m-%Y} ";
$EVENT_CAL_PDF_BODY['default'] = "{EC_PR_CHANGE_YEAR}{EC_PR_CHANGE_MONTH}{EC_MAIL_SHORT_DATE} {EC_MAIL_TIME_START} {EC_MAIL_TITLE} \n";
-$EVENT_CAL_PDF_FOOTER['default'] = "---End of List--- {EC_IFNOT_DISPLAY=EC_NOW_DATE}{EC_IFNOT_DISPLAY=EC_NOW_TIME} {EC_PRINT_BUTTON}";
+$EVENT_CAL_PDF_FOOTER['default'] = "---End of List---
{EC_IFNOT_DISPLAY=EC_NOW_DATE}{EC_IFNOT_DISPLAY=EC_NOW_TIME} {EC_PRINT_BUTTON}";
// - A simple tabular style
diff --git a/e107_plugins/calendar_menu/ecal_class.php b/e107_plugins/calendar_menu/ecal_class.php
index 800d2cab6..2808da895 100644
--- a/e107_plugins/calendar_menu/ecal_class.php
+++ b/e107_plugins/calendar_menu/ecal_class.php
@@ -6,21 +6,16 @@
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
- *
+ * Event calendar class
+ * Pre-calculates/caches many useful values
+ * Implements functions used in most of the code
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/ecal_class.php,v $
- * $Revision: 1.11 $
- * $Date: 2009-11-18 01:05:23 $
- * $Author: e107coders $
+ * $Revision: 1.12 $
+ * $Date: 2009-11-22 10:11:30 $
+ * $Author: e107steved $
*/
-/*
-|
-| Event calendar class:
-| Pre-calculates/caches many useful values
-| Implements functions used in most of the code
-|
-*/
/*
Preferences used:
@@ -31,10 +26,10 @@ Preferences used:
if (!defined('e107_INIT')) { exit; }
-if (!defined("EC_DEFAULT_CATEGORY")) { define('EC_DEFAULT_CATEGORY',"Default"); }
+if (!defined('EC_DEFAULT_CATEGORY')) { define('EC_DEFAULT_CATEGORY','Default'); }
- class ecal_class
- {
+class ecal_class
+{
// Useful time/date variables - set up on creation, and available externally
// (All the times and dates are consistent, being derived from $time_now, which is the time the constructor was
// called - probably doesn't matter, but may help someone.
@@ -64,28 +59,36 @@ if (!defined("EC_DEFAULT_CATEGORY")) { define('EC_DEFAULT_CATEGORY',"Default");
var $cat_text_cache = array(); // Used to cache category text as read
var $ec_first_day_of_week = 0; // First day of the week
- var $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
- var $recur_type = array('0' => 'no', '1' => 'annual', '2' => 'biannual', '3' =>'quarterly', '4' => 'monthly', '5' => 'four weekly',
- '6' => 'fortnightly', '7' => 'weekly', '8' => 'daily',
- '100' => 'Sunday in month',
- '101' => 'Monday in month',
- '102' => 'Tuesday in month',
- '103' => 'Wednesday in month',
- '104' => 'Thursday in month',
- '105' => 'Friday in month',
- '106' => 'Saturday in month'
+ 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
+ public $recur_type = array(
+ '0' => EC_LAN_RECUR_00, // 'no'
+ '1' => EC_LAN_RECUR_01, //'annual'
+ '2' => EC_LAN_RECUR_02, //'biannual'
+ '3' => EC_LAN_RECUR_03, //'quarterly'
+ '4' => EC_LAN_RECUR_04, //'monthly'
+ '5' => EC_LAN_RECUR_05, //'four weekly'
+ '6' => EC_LAN_RECUR_06, //'fortnightly'
+ '7' => EC_LAN_RECUR_07, // 'weekly'
+ '8' => EC_LAN_RECUR_00, // 'daily'
+ '100' => EC_LAN_RECUR_100, // 'Sunday in month'
+ '101' => EC_LAN_RECUR_101, // 'Monday in month'
+ '102' => EC_LAN_RECUR_102, // 'Tuesday in month'
+ '103' => EC_LAN_RECUR_103, // 'Wednesday in month'
+ '104' => EC_LAN_RECUR_104, // 'Thursday in month'
+ '105' => EC_LAN_RECUR_105, // 'Friday in month'
+ '106' => EC_LAN_RECUR_106 // 'Saturday in month'
+ );
+ var $recur_week = array(
+ '100' => EC_LAN_RECUR_1100, //'First'
+ '200' => EC_LAN_RECUR_1200, //'Second'
+ '300' => EC_LAN_RECUR_1300, // 'Third'
+ '400' => EC_LAN_RECUR_1400 // 'Fourth'
);
- var $recur_week = array('100' => 'First', '200' => 'Second', '300' => 'Third', '400' => 'Fourth');
- function ecal_class()
+ public function __construct()
{ // Constructor
- global $pref;
- if (!isset($pref['plug_installed']['calendar_menu']))
- {
- header('location:'.e_BASE.'index.php');
- exit;
- }
+ global $pref;
// 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.
@@ -222,51 +225,55 @@ if (!defined("EC_DEFAULT_CATEGORY")) { define('EC_DEFAULT_CATEGORY',"Default");
}
}
-
- function time_string($convtime)
+
+
+ public function time_string($convtime)
{ // Returns a time string from a time stamp, formatted as 24-hour, 12-hour or custom as set in prefs
- return gmstrftime($this->time_format_string, $convtime);
+ return gmstrftime($this->time_format_string, $convtime);
}
- function event_date_string($convdate)
+
+ public function event_date_string($convdate)
{ // Returns a date string from a date stamp, formatted for display in event list
- return gmstrftime($this->event_date_format_string,$convdate);
+ return gmstrftime($this->event_date_format_string,$convdate);
}
- function next_date_string($convdate)
+ public function next_date_string($convdate)
{ // Returns a date string from a date stamp, formatted for display in forthcoming event menu
- return gmstrftime($this->next_date_format_string,$convdate);
+ return gmstrftime($this->next_date_format_string,$convdate);
}
- function full_date($convdate)
+ public function full_date($convdate)
{ // Returns a date as dd-mm-yyyy or yyyy-mm-dd according to prefs (for event entry)
- return gmdate($this->cal_format_string, $convdate);
+ return gmdate($this->cal_format_string, $convdate);
}
-
- function make_date($new_hour, $new_minute, $date_string)
+
+
+ public function make_date($new_hour, $new_minute, $date_string)
{ // Turns a date as entered in the calendar into a time stamp (for event entry)
- $tmp = explode($this->date_separator, $date_string);
- switch ($this->java_format_code)
- {
- case 2 :
- return gmmktime($new_hour, $new_minute, 0, $tmp[1], $tmp[0], $tmp[2]); // dd-mm-yyyy
- case 3 :
- return gmmktime($new_hour, $new_minute, 0, $tmp[0], $tmp[1], $tmp[2]); // mm-dd-yyyy
- default :
- return gmmktime($new_hour, $new_minute, 0, $tmp[1], $tmp[2], $tmp[0]); // yyyy-mm-dd
- }
+ $tmp = explode($this->date_separator, $date_string);
+ switch ($this->java_format_code)
+ {
+ case 2 :
+ return gmmktime($new_hour, $new_minute, 0, $tmp[1], $tmp[0], $tmp[2]); // dd-mm-yyyy
+ case 3 :
+ return gmmktime($new_hour, $new_minute, 0, $tmp[0], $tmp[1], $tmp[2]); // mm-dd-yyyy
+ default :
+ return gmmktime($new_hour, $new_minute, 0, $tmp[1], $tmp[2], $tmp[0]); // yyyy-mm-dd
+ }
}
-
+
+
// Return day of week string relative to the start of the week
- function day_offset_string($doff)
+ public function day_offset_string($doff)
{
- return $this->days[($doff+$this->ec_first_day_of_week) % 7];
+ return $this->days[($doff+$this->ec_first_day_of_week) % 7];
}
- function cal_log($event_type, $event_title = '', $event_string='', $event_start=0)
+ public function cal_log($event_type, $event_title = '', $event_string='', $event_start=0)
{ // All calendar-related logging intentionally passed through a single point to maintain control
// (so we could also add other info if we wanted)
// Event types:
@@ -275,32 +282,40 @@ if (!defined("EC_DEFAULT_CATEGORY")) { define('EC_DEFAULT_CATEGORY',"Default");
// 3 - delete event
// 4 - Bulk delete
// 5 - add multiple events
- global $pref, $admin_log, $e_event, $PLUGINS_DIRECTORY, $e107;
-
+ global $pref;
+ $e107 = e107::getInstance();
+
$log_titles = array( '1' => 'EC_ADM_01',
'2' => 'EC_ADM_02',
'3' => 'EC_ADM_03',
'4' => 'EC_ADM_04',
'5' => 'EC_ADM_05',
+ '6' => 'EC_ADM_06',
+ '7' => 'EC_ADM_07',
+ '8' => 'EC_ADM_08',
+ '9' => 'EC_ADM_09',
+ '10' => 'EC_ADM_10',
+ '11' => 'EC_ADM_11'
);
-// Do the notifies first
+
+ // Do the notifies first
$cmessage = $log_titles[$event_type]." ";
if ($event_start > 0)
{
- $cmessage .= "Event Start: ".strftime("%d-%B-%Y",$event_start)." ";
- $cmessage .= "Event Link: ".$pref['siteurl'].$PLUGINS_DIRECTORY. "calendar_menu/event.php?".$event_start." ";
+ $cmessage .= 'Event Start: '.strftime("%d-%B-%Y",$event_start)." ";
+ $cmessage .= 'Event Link: '.SITEURL.e_PLUGIN_ABS. 'calendar_menu/event.php?'.$event_start." ";
}
else
$cmessage .= "Event Start unknown ";
- $edata_ec = array("cmessage" => $cmessage, "ip" => $e107->getip());
+ $edata_ec = array('cmessage' => $cmessage, 'ip' => $e107->getip());
switch ($event_type)
{
case 5 :
- case 1 : $e_event -> trigger("ecalnew", $edata_ec);
+ case 1 : $e107->e_event -> trigger('ecalnew', $edata_ec);
break;
case 2 :
case 3 :
- case 4 : $e_event -> trigger("ecaledit", $edata_ec);
+ case 4 : $e107->e_event -> trigger('ecaledit', $edata_ec);
break;
}
@@ -316,21 +331,21 @@ if (!defined("EC_DEFAULT_CATEGORY")) { define('EC_DEFAULT_CATEGORY',"Default");
'4' => 'Event Calendar - Bulk Delete',
'5' => 'Event Calendar - multiple add '.strftime("%d-%B-%Y",$event_start)
);
- $admin_log->log_event($log_titles[$event_type],$event_title." \n".$log_detail[$event_type]."\n".$event_string,'');
+ $e107->admin_log->log_event($log_titles[$event_type],$event_title." \n".$log_detail[$event_type]."\n".$event_string,'');
}
function get_category_text($ev_cat)
{
- global $sql;
- if (!isset($this->cat_text_cache[$ev_cat]))
- {
- $sql->db_Select('event_cat','event_cat_name',"event_cat_id='{$ev_cat}'");
- $row = $sql->db_Fetch();
- $this->cat_text_cache[$ev_cat] = $row['event_cat_name'];
- }
- return $this->cat_text_cache[$ev_cat];
+ global $sql;
+ if (!isset($this->cat_text_cache[$ev_cat]))
+ {
+ $sql->db_Select('event_cat','event_cat_name',"event_cat_id='{$ev_cat}'");
+ $row = $sql->db_Fetch();
+ $this->cat_text_cache[$ev_cat] = $row['event_cat_name'];
+ }
+ return $this->cat_text_cache[$ev_cat];
}
@@ -338,31 +353,47 @@ if (!defined("EC_DEFAULT_CATEGORY")) { define('EC_DEFAULT_CATEGORY',"Default");
// time() -date('Z') gives the correction to 'null out' the TZ and DST adjustments that getdate() does
function gmgetdate($date)
{
- return getdate($date-date('Z'));
+ return getdate($date-date('Z'));
}
//------------------------------------------------
// Recurring event handling
//------------------------------------------------
-// Generate a list of recurring events based on a 'first event' date, an interval and start/finish times
-// Returns an array of times
- function gen_recur_regular($first_event, $last_event, $interval, $start_time, $end_time)
+ /**
+ * Internal utility - Generate a list of time/date 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 $last_event
+ * @param int $interval - interval between events (in seconds)
+ * @param int $start_time
+ * @param int $end_time - last date in time window
+ *
+ * @return array of start date/time entries
+ */
+ protected function gen_recur_regular($first_event, $last_event, $interval, $start_time, $end_time)
{
- if ($last_event < $end_time) $end_time = $last_event;
- $ret = array();
- $first_event = $first_event + ceil(($start_time-$first_event)/$interval)*$interval;
- while ($first_event <= $end_time)
- {
- $ret[] = $first_event;
- $first_event += $interval;
- }
- return $ret;
+ if ($last_event < $end_time) $end_time = $last_event;
+ $ret = array();
+ $first_event = $first_event + ceil(($start_time-$first_event)/$interval)*$interval;
+ while ($first_event <= $end_time)
+ {
+ $ret[] = $first_event;
+ $first_event += $interval;
+ }
+ return $ret;
}
- function add_dates($main_date,$adder)
- { // Adds an offset of months and years to a date
+ /**
+ * Internal utility - adds an offset of months and years to a date
+ * @param array $main_date - a date in PHP standard array format
+ * @param array $adder - a month+year offset in PHP standard array format
+ *
+ * @return array where 'mon' and 'year' fields filled in
+ */
+ protected function add_dates($main_date,$adder)
+ {
if ($adder['mon'])
{
$main_date['mon'] += $adder['mon'];
@@ -377,9 +408,17 @@ if (!defined("EC_DEFAULT_CATEGORY")) { define('EC_DEFAULT_CATEGORY',"Default");
}
-// Generate a list of recurring events based on a 'first event' date, an interval type and start/finish window
-// For day number, '0' = 'Sunday'
- function gen_recur($first_event, $last_event, $interval_type, $start_time, $end_time)
+ /**
+ * Generate a list of recurring events based on a 'first event' date, an interval type and start/finish window
+ * @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)
+ * @param int $start_time - start time for each event
+ * @param int $end_time - end time for each event
+ *
+ * @return array of events (may be empty)
+ */
+ public function gen_recur($first_event, $last_event, $interval_type, $start_time, $end_time)
{
if ($last_event < $end_time) $end_time = $last_event;
$ret = array();
@@ -498,9 +537,21 @@ if (!defined("EC_DEFAULT_CATEGORY")) { define('EC_DEFAULT_CATEGORY',"Default");
return $ret;
}
-// Read a list of events between start and end dates
-// If $start_only is TRUE, only searches based on the start date/time
-// Potential option to hook in other routines later
+
+ /**
+ * Function to return all events between a given start and end date
+ * 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
+ * @param boolean $start_only - TRUE to scan based on start time only. FALSE to select events which overlap the specified time window
+ * @param boolean|string $cat_filter = FALSE is 'no categories' - returns an empty array.
+ * $cat_filter = '*' means 'all categories'
+ * otherwise $cat_filter mst be a comma-separated list of category IDs.
+ * @param string $event_fields - comma separated list of fields to read from the event record; '*' for all fields
+ * @param string $cat_fields - comma separated list of fields to read from the category record; '*' for all fields
+ *
+ * @return array of events (may be empty)
+ */
function get_events($start_time, $end_time, $start_only=FALSE, $cat_filter=0, $inc_recur=FALSE, $event_fields='*', $cat_fields='*')
{
global $sql;
@@ -557,13 +608,23 @@ if (!defined("EC_DEFAULT_CATEGORY")) { define('EC_DEFAULT_CATEGORY',"Default");
}
- // Function to return up to a maximum number of events between a given start and end date
- // It always uses the event start date only
- // It tries to keep the actual number of events in memory to a minimum by discarding when it can.
- // Once there are $num_events read, it pulls in the $end_time to speed up checks
- // $cat_filter = FALSE is 'no categories' - returns an empty array.
- // $cat_filter = '*' means 'all categories'
- // otherwise $cat_filter mst be a comma-separated list of category IDs.
+ /**
+ * Function to return up to a maximum number of events between a given start and end date
+ * It always uses the event start date only
+ * It tries to keep the actual number of events in memory to a minimum by discarding when it can.
+ * Once there are $num_events read, it pulls in the $end_time to speed up checks
+ * @param int $num_event - number of events required
+ * @param int $start_time - earliest time for events
+ * @param int $end_time - latest time for start of event
+ * @param boolean|string $cat_filter = FALSE is 'no categories' - returns an empty array.
+ * $cat_filter = '*' means 'all categories'
+ * otherwise $cat_filter mst be a comma-separated list of category IDs.
+ * @param boolean $inc_recur TRUE to include recurring events
+ * @param string $event_fields - comma separated list of fields to read from the event record; '*' for all fields
+ * @param string $cat_fields - comma separated list of fields to read from the category record; '*' for all fields
+ *
+ * @return array of events (may be empty)
+ */
function get_n_events($num_event, $start_time, $end_time, $cat_filter='*', $inc_recur=FALSE, $event_fields='*', $cat_fields='*')
{
global $sql;
@@ -663,18 +724,24 @@ if (!defined("EC_DEFAULT_CATEGORY")) { define('EC_DEFAULT_CATEGORY',"Default");
} // End - function get_n_events()
- function get_recur_text($recurring)
+ /**
+ * Get text relating to recurring item
+ * @param int numeric code for type of recurring item
+ *
+ * @return string corresponding text description
+ */
+ public function get_recur_text($recurring)
{
- if ($recurring >= 100)
- {
- return $this->recur_week[100*intval($recurring/100)]." ".$this->recur_type[100+($recurring % 10)];
- }
- else
- {
- return $this->recur_type[$recurring];
- }
+ if ($recurring >= 100)
+ {
+ return $this->recur_week[100*intval($recurring/100)]." ".$this->recur_type[100+($recurring % 10)];
+ }
+ else
+ {
+ return $this->recur_type[$recurring];
+ }
}
- }// End - class definition
+}// End - class definition
?>
diff --git a/e107_plugins/calendar_menu/event.php b/e107_plugins/calendar_menu/event.php
index 8a7409048..8d8eab7a1 100644
--- a/e107_plugins/calendar_menu/event.php
+++ b/e107_plugins/calendar_menu/event.php
@@ -6,48 +6,54 @@
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
- *
+ * Calender plugin - event listing and event entry
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/event.php,v $
- * $Revision: 1.14 $
- * $Date: 2009-11-18 01:05:23 $
- * $Author: e107coders $
+ * $Revision: 1.15 $
+ * $Date: 2009-11-22 10:11:30 $
+ * $Author: e107steved $
*/
+
require_once('../../class2.php');
-if (!isset($pref['plug_installed']['calendar_menu'])) header("Location: ".e_BASE."index.php");
+$e107 = e107::getInstance();
+if (!$e107->isInstalled('calendar_menu')) header('Location: '.e_BASE.'index.php');
if (isset($_POST['viewallevents']))
{ // Triggered from NAV_BUT_ALLEVENTS
- Header("Location: ".e_PLUGIN."calendar_menu/calendar.php?".$_POST['enter_new_val']);
+ Header('Location: '.e_PLUGIN.'calendar_menu/calendar.php?'.$_POST['enter_new_val']);
+ exit();
}
if (isset($_POST['doit']))
{ // Triggered from NAV_BUT_ENTEREVENT
- Header("Location: ".e_PLUGIN."calendar_menu/event.php?ne.".$_POST['enter_new_val']);
- exit;
+ Header('Location: '.e_PLUGIN.'calendar_menu/event.php?ne.'.$_POST['enter_new_val']);
+ exit();
}
if (isset($_POST['subs']))
{
- Header("Location: ".e_PLUGIN."calendar_menu/subscribe.php");
+ Header('Location: '.e_PLUGIN.'calendar_menu/subscribe.php');
+ exit();
}
if (isset($_POST['printlists']))
{
- Header("Location: " . e_PLUGIN . "calendar_menu/ec_pf_page.php");
+ Header("Location: " . e_PLUGIN . 'calendar_menu/ec_pf_page.php');
+ exit();
}
-include_lan(e_PLUGIN."calendar_menu/languages/".e_LANGUAGE.".php");
-define("PAGE_NAME", EC_LAN_80);
+include_lan(e_PLUGIN.'calendar_menu/languages/'.e_LANGUAGE.'.php');
+define('PAGE_NAME', EC_LAN_80);
require_once(e_PLUGIN.'calendar_menu/ecal_class.php');
global $ecal_class;
if (!is_object($ecal_class)) $ecal_class = new ecal_class;
$cal_super = $ecal_class->cal_super;
-require_once(e_PLUGIN."calendar_menu/calendar_shortcodes.php");
-require_once(e_HANDLER."calendar/calendar_class.php");
+e107::getScParser();
+require_once(e_PLUGIN.'calendar_menu/calendar_shortcodes.php');
+require_once(e_HANDLER.'calendar/calendar_class.php');
$cal = new DHTML_Calendar(true);
$cat_filter = intval(varset($_POST['event_cat_ids'],-1));
@@ -79,86 +85,86 @@ $ev_fields = array(
//--------------------------------------
if ((isset($_POST['ne_insert']) || isset($_POST['ne_update'])) && ($cal_super || check_class($pref['eventpost_admin'])))
{
- $ev_start = $ecal_class->make_date($_POST['ne_hour'], $_POST['ne_minute'],$_POST['start_date']);
- if (($_POST['ne_event'] == "") || !isset($_POST['qs']))
- { // Problem - tell user to go away - fields are blank (mostly checked by JS)
- header("location:event.php?".$ev_start.".0.m3");
- }
- elseif (!isset($_POST['ne_category']) || (intval($_POST['ne_category']) == 0))
- {
- header("location:event.php?".$ev_start.".0.m6");
- }
- else
- {
- $ev_end = $ecal_class->make_date($_POST['end_hour'], $_POST['end_minute'],$_POST['end_date']);
- $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_category = intval($_POST['ne_category']);
- $ev_thread = $tp -> toDB($_POST['ne_thread']);
- $temp_date = getdate($ecal_class->make_date(0,0,$_POST['start_date']));
- $ev_allday = intval($_POST['allday']);
- $recurring = intval($_POST['ec_recur_type']);
- if ($recurring >= 100) $recurring += intval($_POST['ec_recur_week']) - 100;
- //
- if ($_POST['recurring'] == 1)
+ $ev_start = $ecal_class->make_date($_POST['ne_hour'], $_POST['ne_minute'],$_POST['start_date']);
+ if (($_POST['ne_event'] == '') || !isset($_POST['qs']))
+ { // Problem - tell user to go away - fields are blank (mostly checked by JS)
+ header('location:event.php?'.$ev_start.'.0.m3');
+ }
+ elseif (!isset($_POST['ne_category']) || (intval($_POST['ne_category']) == 0))
{
- $rec_m = $temp_date['mday']; // Day of month
- $rec_y = $temp_date['mon']; // Month number
- }
+ header('location:event.php?'.$ev_start.'.0.m6');
+ }
else
{
- $rec_m = "";
- $rec_y = "";
- }
-
- $report_msg = '.m3';
- if (isset($_POST['ne_insert']))
- { // Bits specific to inserting a new event
- $qs = preg_replace("/ne./i", "", $_POST['qs']);
- if ($_POST['ec_gen_multiple'])
- {
- $mult_count = $ecal_class->gen_recur($ev_start,$ev_end,$recurring,$ev_start,$ev_end);
- }
- if ($mult_count <= 1)
- {
- $qry = " 0, '".intval($ev_start)."', '".intval($ev_end)."', '".$ev_allday."', '".$recurring."', '".time()."', '$ev_title', '$ev_location', '$ev_event', '".USERID.".".USERNAME."', '".$ev_email."', '".$ev_category."', '".$ev_thread."', '".intval($rec_m)."', '".intval($rec_y)."' ";
- $sql->db_Insert("event", $qry);
+ $ev_end = $ecal_class->make_date($_POST['end_hour'], $_POST['end_minute'],$_POST['end_date']);
+ $ev_title = $e107->tp->toDB($_POST['ne_title']);
+ $ev_location = $e107->tp->toDB($_POST['ne_location']);
+ $ev_event = $e107->tp->toDB($_POST['ne_event']);
+ $ev_email = $e107->tp -> toDB($_POST['ne_email']);
+ $ev_category = intval($_POST['ne_category']);
+ $ev_thread = $e107->tp->toDB($_POST['ne_thread']);
+ $temp_date = getdate($ecal_class->make_date(0,0,$_POST['start_date']));
+ $ev_allday = intval($_POST['allday']);
+ $recurring = intval($_POST['ec_recur_type']);
+ if ($recurring >= 100) $recurring += intval($_POST['ec_recur_week']) - 100;
+ //
+ if ($_POST['recurring'] == 1)
+ {
+ $rec_m = $temp_date['mday']; // Day of month
+ $rec_y = $temp_date['mon']; // Month number
+ }
+ else
+ {
+ $rec_m = '';
+ $rec_y = '';
+ }
+
+ $report_msg = '.m3';
+ if (isset($_POST['ne_insert']))
+ { // Bits specific to inserting a new event
+ $qs = preg_replace("/ne./i", "", $_POST['qs']);
+ if ($_POST['ec_gen_multiple'])
+ {
+ $mult_count = $ecal_class->gen_recur($ev_start,$ev_end,$recurring,$ev_start,$ev_end);
+ }
+ if ($mult_count <= 1)
+ {
+ $qry = " 0, '".intval($ev_start)."', '".intval($ev_end)."', '".$ev_allday."', '".$recurring."', '".time()."', '$ev_title', '$ev_location', '$ev_event', '".USERID.".".USERNAME."', '".$ev_email."', '".$ev_category."', '".$ev_thread."', '".intval($rec_m)."', '".intval($rec_y)."' ";
+ $sql->db_Insert("event", $qry);
- $id = mysql_insert_id();
- $data = array('method'=>'create', 'table'=>'event', 'id'=>$id, 'plugin'=>'calendar_menu', 'function'=>'dbCalendarCreate');
- $e_event->triggerHook($data);
+ $id = mysql_insert_id();
+ $data = array('method'=>'create', 'table'=>'event', 'id'=>$id, 'plugin'=>'calendar_menu', 'function'=>'dbCalendarCreate');
+ $e_event->triggerHook($data);
- $ecal_class->cal_log(1,'db_Insert',$qry, $ev_start);
- $report_msg = '.m4';
- }
+ $ecal_class->cal_log(1,'db_Insert',$qry, $ev_start);
+ $report_msg = '.m4';
+ }
+ }
+
+ if (isset($_POST['ne_update']))
+ { // Bits specific to updating an existing event
+ $qry = "event_start='".intval($ev_start)."', event_end='".intval($ev_end)."', event_allday='".$ev_allday."', event_recurring='".$recurring."', event_datestamp= '".time()."', event_title= '$ev_title', event_location='$ev_location', event_details='$ev_event', event_contact='".$ev_email."', event_category='".$ev_category."', event_thread='".$ev_thread."', event_rec_m='".intval($rec_m)."', event_rec_y='".intval($rec_y)."' WHERE event_id='".intval($_POST['id'])."' ";
+ $sql->db_Update("event", $qry);
+
+ $data = array('method'=>'update', 'table'=>'event', 'id'=>intval($_POST['id']), 'plugin'=>'calendar_menu', 'function'=>'dbCalendarUpdate');
+ $e_event->triggerHook($data);
+
+ $ecal_class->cal_log(2,'db_Update',$qry, $ev_start);
+ $qs = preg_replace("/ed./i", "", $_POST['qs']);
+ $report_msg = '.m5';
+ }
+ if ($mult_count <= 1)
+ {
+ // Now clear cache - just do the lot for now - get clever later
+ $e107cache->clear('nq_event_cal');
+ header('location:event.php?'.$ev_start.'.'.$qs.$report_msg);
+ }
}
-
- if (isset($_POST['ne_update']))
- { // Bits specific to updating an existing event
- $qry = "event_start='".intval($ev_start)."', event_end='".intval($ev_end)."', event_allday='".$ev_allday."', event_recurring='".$recurring."', event_datestamp= '".time()."', event_title= '$ev_title', event_location='$ev_location', event_details='$ev_event', event_contact='".$ev_email."', event_category='".$ev_category."', event_thread='".$ev_thread."', event_rec_m='".intval($rec_m)."', event_rec_y='".intval($rec_y)."' WHERE event_id='".intval($_POST['id'])."' ";
- $sql->db_Update("event", $qry);
-
- $data = array('method'=>'update', 'table'=>'event', 'id'=>intval($_POST['id']), 'plugin'=>'calendar_menu', 'function'=>'dbCalendarUpdate');
- $e_event->triggerHook($data);
-
- $ecal_class->cal_log(2,'db_Update',$qry, $ev_start);
- $qs = preg_replace("/ed./i", "", $_POST['qs']);
- $report_msg = '.m5';
- }
- if ($mult_count <= 1)
- {
- // Now clear cache - just do the lot for now - get clever later
- $e107cache->clear('nq_event_cal');
- header("location:event.php?".$ev_start.".".$qs.$report_msg);
- }
- }
}
-$action = ""; // Remove notice
+$action = '';
require_once(HEADERF);
@@ -209,35 +215,44 @@ if ($mult_count > 1)
exit;
}
+
+// Calculate any action, plus start date/number of events, from query
+unset($dateArray);
if (isset($_POST['jump']))
{
- $smarray = getdate(mktime(0, 0, 0, $_POST['jumpmonth'], 1, $_POST['jumpyear']));
- $month = $smarray['mon'];
- $year = $smarray['year'];
+ $dateArray = getdate(mktime(0, 0, 0, $_POST['jumpmonth'], 1, $_POST['jumpyear']));
}
else
{
- if (e_QUERY)
+ if (e_QUERY)
{
- $qs = explode(".", e_QUERY);
- $action = $qs[0]; // Often a date if just viewing
- $ds = varset($qs[1],"");
- $eveid = varset($qs[2], "");
+ $qs = explode('.', e_QUERY);
+ $action = trim($qs[0]); // Often a date if just viewing
+ $ds = varset($qs[1],'');
+ $eveid = intval(varset($qs[2], 0));
}
- if ($action == "")
+ if ($action == '')
{
- $month = $ecal_class->cal_date['mon'];
- $year = $ecal_class->cal_date['year'];
+ $dateArray = $ecal_class->cal_date; // Use todays date
}
else
{
- if (is_numeric($action)) $smarray = getdate($action); else $smarray = getdate($ds);
- $month = $smarray['mon'];
- $year = $smarray['year'];
+ if (is_numeric($action))
+ {
+ $dateArray = getdate($action);
+ }
+ else
+ {
+ $dateArray = getdate($ds);
+ }
}
}
+$dateArray['ds'] = $ds; // Way to pass to shortcodes.
+$month = $dateArray['mon']; // Number of month being shown
+$year = $dateArray['year']; // Number of year being shown
+
if ($cal_super || check_class($pref['eventpost_admin']))
{ // Bits relating to 'delete event', and generation of multiple events
@@ -253,7 +268,7 @@ if ($cal_super || check_class($pref['eventpost_admin']))
$wr_record = array();
foreach ($ev_fields as $k => $v)
{
- $wr_record[$k] = $tp->toDB($_POST['ev_'.$k]);
+ $wr_record[$k] = $e107->tp->toDB($_POST['ev_'.$k]);
}
$wr_record['event_author'] = USERID.".".USERNAME;
$wr_record['event_datestamp'] = time();
@@ -323,22 +338,18 @@ if ($cal_super || check_class($pref['eventpost_admin']))
} // End - if ($cal_super)
-// set up data arrays ----------------------------------------------------------------------------------
-// (these used in the nav shortcodes)
-$monthabb = Array(EC_LAN_JAN, EC_LAN_FEB, EC_LAN_MAR, EC_LAN_APR, EC_LAN_MAY, EC_LAN_JUN, EC_LAN_JUL, EC_LAN_AUG, EC_LAN_SEP, EC_LAN_OCT, EC_LAN_NOV, EC_LAN_DEC);
-$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);
-// ----------------------------------------------------------------------------------------------------------
// Messages acknowledging actions
$poss_message = array('m1' => EC_LAN_41, 'm2' => EC_LAN_42, 'm3' => EC_LAN_43, 'm4' => EC_LAN_44, 'm5' => EC_LAN_45,
'm6' => EC_LAN_145, 'm7' => 'Could have saved -NUM- events');
if (isset($qs[2])) if (isset($poss_message[$qs[2]]))
{
- $message = $poss_message[$qs[2]];
- $ec = varset($qs[3],0);
- if ($ec) $message = str_replace('-NUM-',$ec,$message);
+ $message = $poss_message[$qs[2]];
+ $ec = varset($qs[3],0);
+ if ($ec) $message = str_replace('-NUM-',$ec,$message);
}
+
if (isset($message))
{
$ns->tablerender("", "".$message." ");
@@ -347,92 +358,104 @@ if (isset($message))
function merge_date_time($date, $time)
{
- return ((86400*intval($date/86400)) + ($time % 86400));
+ return ((86400*intval($date/86400)) + ($time % 86400));
}
//-------------------------------------
// enter new event form
//-------------------------------------
-if ($action == "ne" || $action == "ed")
+if ($action == 'ne' || $action == 'ed')
{
- if ($ecal_class->cal_super || check_class($pref['eventpost_admin']))
- {
- function make_calendar($boxname, $boxvalue)
+ if ($ecal_class->cal_super || check_class($pref['eventpost_admin']))
{
- global $ecal_class, $cal;
-
- unset($cal_options);
- unset($cal_attrib);
- $cal_options['firstDay'] = $ecal_class->ec_first_day_of_week;
- $cal_options['showsTime'] = false;
- $cal_options['showOthers'] = true;
- $cal_options['weekNumbers'] = false;
- $cal_options['ifFormat'] = $ecal_class->dcal_format_string;
- $cal_attrib['class'] = "tbox";
- $cal_attrib['size'] = "12";
- $cal_attrib['name'] = $boxname;
- $cal_attrib['value'] = $boxvalue;
- return $cal->make_input_field($cal_options, $cal_attrib);
- }
+ function make_calendar($boxname, $boxvalue)
+ {
+ global $ecal_class, $cal;
+
+ unset($cal_options);
+ unset($cal_attrib);
+ $cal_options['firstDay'] = $ecal_class->ec_first_day_of_week;
+ $cal_options['showsTime'] = false;
+ $cal_options['showOthers'] = true;
+ $cal_options['weekNumbers'] = false;
+ $cal_options['ifFormat'] = $ecal_class->dcal_format_string;
+ $cal_attrib['class'] = "tbox";
+ $cal_attrib['size'] = "12";
+ $cal_attrib['name'] = $boxname;
+ $cal_attrib['value'] = $boxvalue;
+ return $cal->make_input_field($cal_options, $cal_attrib);
+ }
- function make_hourmin($boxname,$cur_hour,$cur_minute)
- {
- global $pref;
- if (isset($pref['eventpost_fivemins'])) $incval = 5; else $incval = 1;
- $retval = " \n";
- for($count = "00"; $count <= "23"; $count++)
- {
- $val = sprintf("%02d", $count);
- $retval .= "\n";
- }
- $retval .= "\n
- \n";
- for($count = "00"; $count <= "59"; $count+= $incval)
- {
- $val = sprintf("%02d", $count);
- $retval .= "\n";
- }
- $retval .= "\n";
- return $retval;
- }
+ function make_hourmin($boxname,$cur_hour,$cur_minute)
+ {
+ global $pref;
+ if (isset($pref['eventpost_fivemins'])) $incval = 5; else $incval = 1;
+ $retval = " \n";
+ for($count = "00"; $count <= "23"; $count++)
+ {
+ $val = sprintf("%02d", $count);
+ $retval .= "\n";
+ }
+ $retval .= "\n
+ \n";
+ for($count = "00"; $count <= "59"; $count+= $incval)
+ {
+ $val = sprintf("%02d", $count);
+ $retval .= "\n";
+ }
+ $retval .= "\n";
+ return $retval;
+ }
- function recur_select($curval)
- {
- global $ecal_class;
- while ($curval > 150) { $curval -= 100; } // Could have values up to about 406
- $ret = "";
- foreach ($ecal_class->recur_type as $k => $v)
- {
- $selected = ($curval == $k) ? " selected = 'selected'" : "";
- $ret .= "\n";
- }
- $ret .= "\n";
- return $ret;
- }
-
-
- function recur_week_select($curval)
- {
- global $ecal_class;
- $disp = $curval < 100 ? " style='display:none;'" : "";
- $curval -= intval($curval % 10); // Should make it an exact multiple of 100
- $ret = "";
- foreach ($ecal_class->recur_week as $k => $v)
- {
- $selected = ($curval == $k) ? " selected = 'selected'" : "";
- $ret .= "\n";
- }
- $ret .= "\n";
- return $ret;
- }
+ function recur_select($curval)
+ {
+ global $ecal_class;
+ while ($curval > 150) { $curval -= 100; } // Could have values up to about 406
+ $ret = "";
+ foreach ($ecal_class->recur_type as $k => $v)
+ {
+ $selected = ($curval == $k) ? " selected = 'selected'" : "";
+ $ret .= "\n";
+ }
+ $ret .= "\n";
+ return $ret;
+ }
+
+
+ function recur_week_select($curval)
+ {
+ global $ecal_class;
+ $disp = $curval < 100 ? " style='display:none;'" : "";
+ $curval -= intval($curval % 10); // Should make it an exact multiple of 100
+ $ret = "";
+ foreach ($ecal_class->recur_week as $k => $v)
+ {
+ $selected = ($curval == $k) ? " selected = 'selected'" : "";
+ $ret .= "\n";
+ }
+ $ret .= "\n";
+ return $ret;
+ }
switch ($action)
{
- case "ed" : // Editing existing event - read from database
- $sql->db_Select("event", "*", "event_id='".intval($qs[1])."' ");
- list($null, $ne_start, $ne_end, $allday, $recurring, $ne_datestamp, $ne_title, $ne_location, $ne_event, $ne_author, $ne_email, $ne_category, $ne_thread) = $sql->db_Fetch();
+ case 'ed' : // Editing existing event - read from database
+ $sql->db_Select('event', '*', 'event_id='.intval($qs[1]));
+ $row = $sql->db_Fetch(MYSQL_ASSOC);
+ $ne_start = $row['event_start'];
+ $ne_end = $row['event_end'];
+ $allday = $row['event_allday'];
+ $recurring = $row['event_recurring'];
+ $ne_datestamp = $row['event_datestamp'];
+ $ne_title = $row['event_title'];
+ $ne_location = $row['event_location'];
+ $ne_event = $row['event_details'];
+ $ne_author = $row['event_author'];
+ $ne_email = $row['event_contact'];
+ $ne_category = $row['event_category'];
+ $ne_thread = $row['event_thread'];
$smarray = $ecal_class->gmgetdate($ne_start);
$ne_hour = $smarray['hours'];
@@ -447,7 +470,7 @@ if ($action == "ne" || $action == "ed")
$caption = EC_LAN_66; // edit Event
break;
- case "ne" : // New event - initialise everything
+ case 'ne' : // New event - initialise everything
$smarray = $ecal_class->gmgetdate($qs[1]);
$month = $smarray['mon'];
$year = $smarray['year'];
@@ -717,46 +740,6 @@ if ($action == "ne" || $action == "ed")
// show events
// $month, $year have the month required
//-----------------------------------------------
-$monthstart = mktime(0, 0, 0, $month, 1, $year);
-$firstdayarray = getdate($monthstart);
-$monthend = mktime(0, 0, 0, $month + 1, 1, $year) -1 ;
-$lastdayarray = getdate($monthend);
-
-$prevmonth = ($month-1);
-$prevyear = $year;
-if ($prevmonth == 0)
-{
- $prevmonth = 12;
- $prevyear = ($year-1);
-}
-$previous = mktime(0, 0, 0, $prevmonth, 1, $prevyear);
-
-$nextmonth = ($month + 1);
-$nextyear = $year;
-if ($nextmonth == 13)
-{
- $nextmonth = 1;
- $nextyear = ($year + 1);
-}
-
-if ($ds == 'one')
-{
- $prop = gmmktime(0, 0, 0, $month, $smarray['mday'], $year); // Sets start date for new event entry - exact day of month
-}
-else
-{
- $prop = gmmktime(0, 0, 0, $month, 1, $year); // Sets start date for new event entry - beginning of month
-}
-$next = mktime(0, 0, 0, $nextmonth, 1, $nextyear); // Used by nav buttons
-$nowmonth = $ecal_class->cal_date['mon'];
-$nowyear = $ecal_class->cal_date['year'];
-
-
-$py = $year-1;
-$prevlink = mktime(0, 0, 0, $month, 1, $py);
-$ny = $year + 1;
-$nextlink = mktime(0, 0, 0, $month, 1, $ny);
-
if (is_readable(THEME.'calendar_template.php'))
{ // Has to be require
require(THEME.'calendar_template.php');
@@ -766,12 +749,24 @@ else
require(e_PLUGIN.'calendar_menu/calendar_template.php');
}
+setScVar('event_calendar_shortcodes', 'ecalClass', &$ecal_class); // Give shortcodes a pointer to calendar class
+callScFunc('event_calendar_shortcodes','setCalDate', $dateArray); // Tell shortcodes the date to display
+setScVar('event_calendar_shortcodes', 'catFilter', $cat_filter); // Category filter
+setScVar('event_calendar_shortcodes', 'eventDisplayCodes', $EVENT_EVENT_DATETIME); // Templates for different event types
+
+$monthstart = mktime(0, 0, 0, $month, 1, $year);
+$monthend = mktime(0, 0, 0, $month + 1, 1, $year) -1 ;
+
+$nowmonth = $ecal_class->cal_date['mon'];
+$nowyear = $ecal_class->cal_date['year'];
+
+
$text2 = "";
// time switch buttons
-$text2 .= $tp -> parseTemplate($CALENDAR_TIME_TABLE, FALSE, $calendar_shortcodes);
+$text2 .= $e107->tp->parseTemplate($CALENDAR_TIME_TABLE, TRUE);
// navigation buttons
-$text2 .= $tp -> parseTemplate($CALENDAR_NAVIGATION_TABLE, FALSE, $calendar_shortcodes);
+$text2 .= $e107->tp->parseTemplate($CALENDAR_NAVIGATION_TABLE, TRUE);
// ****** CAUTION - the category dropdown also used $sql object - take care to avoid interference!
@@ -779,7 +774,7 @@ $text2 .= $tp -> parseTemplate($CALENDAR_NAVIGATION_TABLE, FALSE, $calendar_shor
$ev_list = array();
-if ($ds == "event")
+if ($ds == 'event')
{ // Show single event - bit of a special case
$ec_err = FALSE;
$qry = "
@@ -790,85 +785,84 @@ if ($ds == "event")
{$ecal_class->extra_query}
";
$sql2->db_Select_gen($qry);
- $thisevent = $sql2->db_Fetch();
+ $thisEvent = $sql2->db_Fetch();
// Recurring events - $action has the actual date required (no time) - could be one of a potentially large number of dates it referred to
- if ($thisevent['event_recurring']>='1') // Single event, selected by ID. So day/month must match
+ if ($thisEvent['event_recurring']>='1') // Single event, selected by ID. So day/month must match
{
- $temp_arr = $ecal_class->gen_recur($thisevent['event_start'],$thisevent['event_end'],$thisevent['event_recurring'],$action,$action+86400); // Array of start times - hopefully just one!
- if (count($temp_arr) == 1)
- {
- $thisevent['event_start'] = $temp_arr[0];
- $thisevent['event_end'] = merge_date_time($action,$thisevent['event_end']);
- }
- else
- { // Error
- $ec_err = TRUE;
- }
+ $temp_arr = $ecal_class->gen_recur($thisEvent['event_start'],$thisEvent['event_end'],$thisEvent['event_recurring'],$action,$action+86400); // Array of start times - hopefully just one!
+ if (count($temp_arr) == 1)
+ {
+ $thisEvent['event_start'] = $temp_arr[0];
+ $thisEvent['event_end'] = merge_date_time($action,$thisEvent['event_end']);
+ }
+ else
+ { // Error
+ $ec_err = TRUE;
+ }
}
- $next10_start = $thisevent['event_start'] +1;
- $text2 .= $tp -> parseTemplate($EVENT_EVENT_TABLE_START, FALSE, $calendar_shortcodes);
- if ($ec_err) $text2.= "Software Error "; else $text2 .= $tp -> parseTemplate($EVENT_EVENT_TABLE, TRUE, $calendar_shortcodes);
- $text2 .= $tp -> parseTemplate($EVENT_EVENT_TABLE_END, FALSE, $calendar_shortcodes);
+ $next10_start = $thisEvent['event_start'] +1;
+ setScVar('event_calendar_shortcodes', 'event', $thisEvent); // Give shortcodes the event data
+ $text2 .= $e107->tp->parseTemplate($EVENT_EVENT_TABLE_START, TRUE);
+ if ($ec_err) $text2.= "Software Error "; else $text2 .= $e107->tp->parseTemplate($EVENT_EVENT_TABLE, TRUE);
+ $text2 .= $e107->tp->parseTemplate($EVENT_EVENT_TABLE_END, TRUE);
}
else
{
- if ($ds == 'one')
- { // Show events from one day
- $tmp = getdate($action);
- $selected_day = $tmp['mday'];
- $selected_mon = $tmp['mon'];
- $start_time = $action;
- $end_time = $action + 86399;
- $next10_start = $end_time + 1;
- $cap_title = " - ".$months[$selected_mon-1]." ".$selected_day;
- }
- else
- { // Display whole of selected month
- $start_time = $monthstart;
- $end_time = $monthend;
- $next10_start = $end_time + 1;
- $cap_title = '';
- }
-
-// echo "Start: ".$start_time." End: ".$end_time." Cat_filter: ".$cat_filter." ";
- // We'll need virtually all of the event-related fields, so get them regardless
- $ev_list = $ecal_class->get_events($start_time, $end_time, FALSE, $cat_filter, TRUE, '*', 'event_cat_name,event_cat_icon');
-
-// echo count($ev_list)." records found ";
-
-// Now go through and multiply up any recurring records
- $tim_arr = array();
- foreach ($ev_list as $k=>$event)
- {
- if (is_array($event['event_start']))
- {
- foreach ($event['event_start'] as $t)
- {
- $tim_arr[$t] = $k;
- }
+ if ($ds == 'one')
+ { // Show events from one day
+// $tmp = getdate($action);
+// $selected_day = $tmp['mday'];
+// $selected_mon = $tmp['mon'];
+ $start_time = intval($action);
+ $end_time = $action + 86399;
+ $next10_start = $end_time + 1;
}
else
- {
- $tim_arr[$event['event_start']] = $k;
+ { // Display whole of selected month
+ $start_time = $monthstart;
+ $end_time = $monthend;
+ $next10_start = $end_time + 1;
}
- }
-
- // Add a sort in here
- ksort($tim_arr);
-// display event list for current month
- if(count($tim_arr))
- {
- $text2 .= $tp -> parseTemplate($EVENT_EVENTLIST_TABLE_START, FALSE, $calendar_shortcodes);
- foreach ($tim_arr as $tim => $ptr)
+ // echo "Start: ".$start_time." End: ".$end_time." Cat_filter: ".$cat_filter." ";
+ // We'll need virtually all of the event-related fields, so get them regardless
+ $ev_list = $ecal_class->get_events($start_time, $end_time, FALSE, $cat_filter, TRUE, '*', 'event_cat_name,event_cat_icon');
+
+
+ // Now go through and multiply up any recurring records
+ $tim_arr = array();
+ foreach ($ev_list as $k=>$event)
{
- $ev_list[$ptr]['event_start'] = $tim;
-// $text2 .= show_event($ev_list[$ptr]);
- $thisevent = $ev_list[$ptr];
- $text2 .= $tp -> parseTemplate($EVENT_EVENT_TABLE, TRUE, $calendar_shortcodes);
+ if (is_array($event['event_start']))
+ {
+ foreach ($event['event_start'] as $t)
+ {
+ $tim_arr[$t] = $k;
+ }
+ }
+ else
+ {
+ $tim_arr[$event['event_start']] = $k;
+ }
+ }
+
+ // Add a sort in here - time/date order
+ ksort($tim_arr);
+
+ // display event list for current month
+ if(count($tim_arr))
+ {
+ $text2 .= $e107->tp->parseTemplate($EVENT_EVENTLIST_TABLE_START, TRUE);
+ foreach ($tim_arr as $tim => $ptr)
+ {
+ $ev_list[$ptr]['event_start'] = $tim;
+ // $text2 .= show_event($ev_list[$ptr]);
+ //$thisevent = $ev_list[$ptr];
+ setScVar('event_calendar_shortcodes', 'event', $ev_list[$ptr]); // Give shortcodes the event data
+ $text2 .= $e107->tp->parseTemplate($EVENT_EVENT_TABLE, TRUE);
+ }
+ $text2 .= $e107->tp->parseTemplate($EVENT_EVENTLIST_TABLE_END, TRUE);
}
- $text2 .= $tp -> parseTemplate($EVENT_EVENTLIST_TABLE_END, FALSE, $calendar_shortcodes);
- }
}
@@ -881,25 +875,25 @@ $ev_list = $ecal_class->get_n_events(10, $next10_start, $next10_start+86400000,
$num = count($ev_list);
if ($num != 0)
{
- $archive_events = "";
- foreach ($ev_list as $thisevent)
- {
-// echo "Event start: ".$thisevent['event_start']." ";
- $archive_events .= $tp -> parseTemplate($EVENT_ARCHIVE_TABLE, FALSE, $calendar_shortcodes);
- }
+ setScVar('event_calendar_shortcodes', 'numEvents', $num); // Give shortcodes the number of events to expect
+ $archive_events = '';
+ foreach ($ev_list as $thisEvent)
+ {
+ setScVar('event_calendar_shortcodes', 'event', $thisEvent); // Give shortcodes the event data
+ $archive_events .= $e107->tp->parseTemplate($EVENT_ARCHIVE_TABLE, TRUE);
+ }
}
else
{
- $archive_events = $tp -> parseTemplate($EVENT_ARCHIVE_TABLE_EMPTY, FALSE, $calendar_shortcodes);
+ $archive_events = $e107->tp->parseTemplate($EVENT_ARCHIVE_TABLE_EMPTY, TRUE);
}
-$text2 .= $tp -> parseTemplate($EVENT_ARCHIVE_TABLE_START, FALSE, $calendar_shortcodes);
+$text2 .= $e107->tp->parseTemplate($EVENT_ARCHIVE_TABLE_START, TRUE);
$text2 .= $archive_events;
-$text2 .= $tp -> parseTemplate($EVENT_ARCHIVE_TABLE_END, FALSE, $calendar_shortcodes);
+$text2 .= $e107->tp->parseTemplate($EVENT_ARCHIVE_TABLE_END, TRUE);
-$caption = EC_LAN_80; // "Event List";
-$ns->tablerender($caption.(isset($cap_title) ? $cap_title : ""), $text2);
+$e107->ns->tablerender($e107->tp->ParseTemplate('{EC_EVENT_PAGE_TITLE}'), $text2);
// Claim back memory no longer required
unset($ev_list);
diff --git a/e107_plugins/calendar_menu/languages/English.php b/e107_plugins/calendar_menu/languages/English.php
index 58b2ad4b8..c1a5df499 100644
--- a/e107_plugins/calendar_menu/languages/English.php
+++ b/e107_plugins/calendar_menu/languages/English.php
@@ -9,14 +9,14 @@
* These messages are for the 'user' pages of the event calendar (including event entry/editing)
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/languages/English.php,v $
- * $Revision: 1.9 $
- * $Date: 2009-11-18 02:03:35 $
- * $Author: marj_nl_fr $
+ * $Revision: 1.10 $
+ * $Date: 2009-11-22 10:11:32 $
+ * $Author: e107steved $
*/
-
-define('EC_ADLAN_1', "Event Calendar");
-define('EC_ADLAN_2', "Configure Event Calendar");
-define('EC_LAN_TODAY', "today");
+
+define('EC_ADLAN_1', 'Event Calendar');
+define('EC_ADLAN_2', 'Configure Event Calendar');
+define('EC_LAN_TODAY', 'today');
define('EC_LAN_DAY_1', "1");
define('EC_LAN_DAY_2', "2");
@@ -184,7 +184,7 @@ define('EC_LAN_116', "Monday");
//define('EC_LAN_119', "month/year");
//define('EC_LAN_120', "year/month");
define('EC_LAN_121', "Show Calendar");
-
+define('EC_LAN_122', 'Event information (single event)');
define('EC_LAN_123', "Subscriptions");
define('EC_LAN_124', "Calendar Subscriptions");
define('EC_LAN_125', "Categories available for subscription");
@@ -237,27 +237,53 @@ define('EC_LAN_171', "List including category");
define('EC_LAN_172', "Event Categories: ");
define('EC_LAN_173', "First event starts: ");
define('EC_LAN_174', "Last event ends: ");
-define('EC_LAN_175', "All Day");
+define('EC_LAN_175', 'All Day');
define('EC_LAN_176', "Recurring pattern: ");
define('EC_LAN_177', "Cancel Entry");
define('EC_LAN_178', "Accept Entries");
define('EC_LAN_179', "Confirmation of multiple event entry");
-define('EC_LAN_180', " RECORDS NOT SAVED - DB UPDATE ERROR");
+define('EC_LAN_180', 'RECORDS NOT SAVED - DB UPDATE ERROR');
-define('EC_LAN_VIEWCALENDAR', "View Calendar");
-define('EC_LAN_VIEWALLEVENTS', "View all events");
+define('EC_LAN_VIEWCALENDAR', 'View Calendar');
+define('EC_LAN_VIEWALLEVENTS', 'View all events');
define('EC_LAN_ALLEVENTS', "All events");
+// Recurring events texts - the numeric part of each define is the internal value assigned
+define('EC_LAN_RECUR_00', 'no');
+define('EC_LAN_RECUR_01', 'annual');
+define('EC_LAN_RECUR_02', 'biannual');
+define('EC_LAN_RECUR_03', 'quarterly');
+define('EC_LAN_RECUR_04', 'monthly');
+define('EC_LAN_RECUR_05', 'four weekly');
+define('EC_LAN_RECUR_06', 'fortnightly');
+define('EC_LAN_RECUR_07', 'weekly');
+define('EC_LAN_RECUR_08', 'daily');
+define('EC_LAN_RECUR_100', 'Sunday in month');
+define('EC_LAN_RECUR_101', 'Monday in month');
+define('EC_LAN_RECUR_102', 'Tuesday in month');
+define('EC_LAN_RECUR_103', 'Wednesday in month');
+define('EC_LAN_RECUR_104', 'Thursday in month');
+define('EC_LAN_RECUR_105', 'Friday in month');
+define('EC_LAN_RECUR_106', 'Saturday in month');
+
+define('EC_LAN_RECUR_1100', 'First');
+define('EC_LAN_RECUR_1200', 'Second');
+define('EC_LAN_RECUR_1300', 'Third');
+define('EC_LAN_RECUR_1400', 'Fourth');
+
+
// Notify
-define("NT_LAN_EC_1", "Event Calendar Events");
-define("NT_LAN_EC_2", "Event Updated");
-define("NT_LAN_EC_3", "Update by");
-define("NT_LAN_EC_4", "IP Address");
-define("NT_LAN_EC_5", "Message");
-define("NT_LAN_EC_6", "Event Calendar - Event added");
-define("NT_LAN_EC_7", "New event posted");
-define("NT_LAN_EC_8", "Event Calendar - Event modified");
+define('NT_LAN_EC_1', 'Event Calendar Events');
+define('NT_LAN_EC_2', 'Event Updated');
+define('NT_LAN_EC_3', 'Update by');
+define('NT_LAN_EC_4', 'IP Address');
+define('NT_LAN_EC_5', 'Message');
+define('NT_LAN_EC_6', 'Event Calendar - Event added');
+define('NT_LAN_EC_7', 'New event posted');
+define('NT_LAN_EC_8', 'Event Calendar - Event modified');
// Prefs - language defines can be used in various places where text is set through the admin screens
define('EC_MAILOUT_SUBJECT', "Advice of calendar event"); // Use shortcode EC_MAIL_SUBJECT
+
+?>
\ No newline at end of file
diff --git a/e107_plugins/calendar_menu/languages/English_admin_calendar_menu.php b/e107_plugins/calendar_menu/languages/English_admin_calendar_menu.php
index 8ecef33af..6c84e6aaf 100644
--- a/e107_plugins/calendar_menu/languages/English_admin_calendar_menu.php
+++ b/e107_plugins/calendar_menu/languages/English_admin_calendar_menu.php
@@ -9,9 +9,9 @@
* Messages for admin pages of event calendar
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/languages/English_admin_calendar_menu.php,v $
- * $Revision: 1.2 $
- * $Date: 2009-11-18 02:03:35 $
- * $Author: marj_nl_fr $
+ * $Revision: 1.3 $
+ * $Date: 2009-11-22 10:11:32 $
+ * $Author: e107steved $
*/
define('EC_ADLAN_1', "Event Calendar");
@@ -380,4 +380,4 @@ define("NT_LAN_EC_5", "Message");
define("NT_LAN_EC_6", "Event Calendar - Event added");
define("NT_LAN_EC_7", "New event posted");
define("NT_LAN_EC_8", "Event Calendar - Event modified");
-*/
+*/
\ No newline at end of file
diff --git a/e107_plugins/calendar_menu/languages/English_mailer.php b/e107_plugins/calendar_menu/languages/English_mailer.php
index f7df7725d..a729592b4 100644
--- a/e107_plugins/calendar_menu/languages/English_mailer.php
+++ b/e107_plugins/calendar_menu/languages/English_mailer.php
@@ -6,12 +6,12 @@
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
- * Administration - Site Maintenance
+ * Event calendar - language file for mailout related routines
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/languages/English_mailer.php,v $
- * $Revision: 1.3 $
- * $Date: 2009-11-18 01:05:23 $
- * $Author: e107coders $
+ * $Revision: 1.4 $
+ * $Date: 2009-11-22 10:11:32 $
+ * $Author: e107steved $
*
*/
@@ -21,10 +21,24 @@ define('LAN_EC_MAIL_03', 'Category: ');
define('LAN_EC_MAIL_04', 'Calendar Subscriptions');
define('LAN_EC_MAIL_05', 'Process notifications of events on the calendar');
define('LAN_EC_MAIL_06', 'Mail subscriptions run started at ');
-define('LAN_EC_MAIL_07', '');
+define('LAN_EC_MAIL_07', 'Event calendar mail --REF--');
define('LAN_EC_MAIL_08', '');
define('LAN_EC_MAIL_09', '');
define('LAN_EC_MAIL_10', '');
+// Following messages used in mailout template
+define('LAN_EC_MAIL_100', 'Location:');
+define('LAN_EC_MAIL_101', 'Posted by:');
+define('LAN_EC_MAIL_102', 'Contact:');
+define('LAN_EC_MAIL_103', 'All day event:');
+define('LAN_EC_MAIL_104', 'When:');
+define('LAN_EC_MAIL_105', ' at ');
+define('LAN_EC_MAIL_106', 'Ends:');
+define('LAN_EC_MAIL_107', '');
+define('LAN_EC_MAIL_108', '');
+define('LAN_EC_MAIL_109', '');
+define('LAN_EC_MAIL_110', '');
+
+
?>
diff --git a/e107_plugins/calendar_menu/next_event_menu.php b/e107_plugins/calendar_menu/next_event_menu.php
index 27318aa35..12f24eecd 100644
--- a/e107_plugins/calendar_menu/next_event_menu.php
+++ b/e107_plugins/calendar_menu/next_event_menu.php
@@ -6,43 +6,38 @@
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
- *
+ * Forthcoming events menu handler for event calendar
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/next_event_menu.php,v $
- * $Revision: 1.7 $
- * $Date: 2009-11-18 01:05:23 $
- * $Author: e107coders $
+ * $Revision: 1.8 $
+ * $Date: 2009-11-22 10:11:30 $
+ * $Author: e107steved $
*/
if (!defined('e107_INIT')) { exit; }
+$e107 = e107::getInstance();
-global $ecal_dir, $tp;
-$ecal_dir = e_PLUGIN.'calendar_menu/';
+if (!$e107->isInstalled('calendar_menu')) return '';
-global $e107, $ecal_class, $calendar_shortcodes;
-require_once($ecal_dir.'ecal_class.php');
-if (!is_object($ecal_class)) $ecal_class = new ecal_class;
-
-$cache_tag = 'nq_event_cal_next';
// See if the page is already in the cache
+$cache_tag = 'nq_event_cal_next';
if($cacheData = $e107->ecache->retrieve($cache_tag, $ecal_class->max_cache_time))
{
echo $cacheData;
return;
}
+if (!is_object($ecal_class))
+{
+ require_once(e_PLUGIN.'calendar_menu/ecal_class.php');
+ $ecal_class = new ecal_class;
+}
+
include_lan(e_PLUGIN.'calendar_menu/languages/'.e_LANGUAGE.'.php');
-// Values defined through admin pages
-$menu_title = varset($pref['eventpost_menuheading'],EC_LAN_140);
-$days_ahead = varset($pref['eventpost_daysforward'],30); // Number of days ahead to go
-$show_count = varset($pref['eventpost_numevents'],3); // Number of events to show
-$show_recurring = varset($pref['eventpost_checkrecur'],1); // Zero to exclude recurring events
-$link_in_heading = varset($pref['eventpost_linkheader'],0); // Zero for simple heading, 1 to have clickable link
-
-
-require($ecal_dir.'calendar_shortcodes.php');
+e107::getScParser();
+require_once(e_PLUGIN.'calendar_menu/calendar_shortcodes.php');
if (is_readable(THEME.'calendar_template.php'))
{ // Has to be require
require(THEME.'calendar_template.php');
@@ -52,15 +47,25 @@ else
require(e_PLUGIN.'calendar_menu/calendar_template.php');
}
+global $pref;
+
+// Values defined through admin pages
+$menu_title = varset($pref['eventpost_menuheading'],EC_LAN_140);
+$days_ahead = varset($pref['eventpost_daysforward'],30); // Number of days ahead to go
+$show_count = varset($pref['eventpost_numevents'],3); // Number of events to show
+$show_recurring = varset($pref['eventpost_checkrecur'],1); // Zero to exclude recurring events
+$link_in_heading = varset($pref['eventpost_linkheader'],0); // Zero for simple heading, 1 to have clickable link
+
+
$start_time = $ecal_class->cal_timedate;
$end_time = $start_time + (86400 * $days_ahead) - 1;
-$cal_totev = 0;
$cal_text = '';
-$cal_row = array();
-global $cal_row, $cal_totev;
+setScVar('event_calendar_shortcodes', 'ecalClass', &$ecal_class); // Give shortcodes a pointer to calendar class
+//callScFunc('event_calendar_shortcodes','setCalDate', $dateArray); // Tell shortcodes the date to display
+//setScVar('event_calendar_shortcodes', 'catFilter', $cat_filter); // Category filter
$ev_list = $ecal_class->get_n_events($show_count, $start_time, $end_time, varset($pref['eventpost_fe_set'],FALSE), $show_recurring,
'event_id,event_start, event_thread, event_title, event_recurring, event_allday, event_category', 'event_cat_icon');
@@ -68,19 +73,21 @@ $ev_list = $ecal_class->get_n_events($show_count, $start_time, $end_time, varset
$cal_totev = count($ev_list);
if ($cal_totev > 0)
{
- foreach ($ev_list as $cal_row)
- {
- $cal_totev --; // Can use this to modify inter-event gap
- $cal_text .= $tp->parseTemplate($EVENT_CAL_FE_LINE,TRUE,$calendar_shortcodes);
- }
+ foreach ($ev_list as $thisEvent)
+ {
+ $cal_totev --; // Can use this to modify inter-event gap
+ setScVar('event_calendar_shortcodes', 'numEvents', $cal_totev); // Number of events to display
+ setScVar('event_calendar_shortcodes', 'event', $thisEvent); // Give shortcodes the event data
+ $cal_text .= $e107->tp->parseTemplate($EVENT_CAL_FE_LINE,TRUE);
+ }
}
else
{
- if ($pref['eventpost_fe_hideifnone']) return '';
- $cal_text.= EC_LAN_141;
+ if ($pref['eventpost_fe_hideifnone']) return '';
+ $cal_text.= EC_LAN_141;
}
-$calendar_title = $tp->toHTML($menu_title,FALSE,'TITLE'); // Allows multi-language title, shortcodes
+$calendar_title = $e107->tp->toHTML($menu_title,FALSE,'TITLE'); // Allows multi-language title, shortcodes
if ($link_in_heading == 1)
{
$calendar_title = "".$calendar_title."";
@@ -88,7 +95,7 @@ if ($link_in_heading == 1)
// Now handle the data, cache as well
ob_start(); // Set up a new output buffer
-$ns->tablerender($calendar_title, $cal_text, 'next_event_menu');
+$e107->ns->tablerender($calendar_title, $cal_text, 'next_event_menu');
$cache_data = ob_get_flush(); // Get the page content, and display it
$e107->ecache->set($cache_tag, $cache_data); // Save to cache
diff --git a/e107_plugins/calendar_menu/subs_menu.php b/e107_plugins/calendar_menu/subs_menu.php
deleted file mode 100644
index 1be9040d3..000000000
--- a/e107_plugins/calendar_menu/subs_menu.php
+++ /dev/null
@@ -1,325 +0,0 @@
-";
-
-if ($ec_run_from_menu)
-{
- if ($cacheData = $e107cache->retrieve("nomd5_cal_subs",$ecal_class->max_cache_time, TRUE)) exit;
-}
-
-include_lan(e_PLUGIN."calendar_menu/languages/".e_LANGUAGE.".php"); // May be needed for mailouts
-
-if (!isset($calendar_shortcodes)) require(e_PLUGIN."calendar_menu/calendar_shortcodes.php");
-if (is_readable(THEME."ec_mailout_template.php"))
-{ // Has to be require
- require(THEME."ec_mailout_template.php");
-}
-else
-{
- require(e_PLUGIN."calendar_menu/ec_mailout_template.php");
-}
-
-
-$ec_debug_level = 0; // Set to 1 or 2 to suppress actual sending of emails
-$ec_default_msg_1 = "";
-$ec_default_msg_2 = "";
-
-
-if (($ec_debug_level > 0) && e_QUERY)
-{ // Run with query of ?dd-mm[-yy] to test specific date
- list($day,$month,$year) = explode("-",e_QUERY);
- if (!isset($year) || ($year == 0)) $year = date("Y");
- $cal_starttime = mktime(0,0,0,$month,$day,$year);
- echo "Debug run for {$day}-{$month}-{$year} ";
-}
-else
-{ // Normal operation
- $cal_starttime = mktime(0, 0, 0, date("n"), date("d"), date("Y"));
-}
-
-
-$ec_log_requirement = 0; // Logging required 0=none, 1=summary, 2=detailed
-if (isset($pref['eventpost_emaillog'])) $ec_log_requirement = $pref['eventpost_emaillog'];
-if ($ec_debug_level >= 2) $ec_log_requirement = 2; // Force full logging if debug
-
-
-function subs_log_a_line($log_text,$close_after = FALSE, $log_always = FALSE)
-{
- global $ec_log_requirement, $ec_run_from_menu;
- if ($ec_log_requirement == 0) return;
- if ($ec_run_from_menu && ($log_always == FALSE)) return;
-// echo "Logging: ".$log_text." ";
- static $handle = NULL;
- //FIXME need another name
- $log_filename = e_MEDIA."logs/calendar_mail.txt";
- if ($handle == NULL)
- {
- if (!($handle = fopen($log_filename, "a")))
- { // Problem creating file?
- echo "File open failed! ";
- $ec_log_requirement = 0;
- return;
- }
- }
-
- if (fwrite($handle,$log_text) == FALSE)
- {
- $ec_log_requirement = 0;
- echo "File write failed! ";
- }
-
- if ($close_after)
- {
- fclose($handle);
- $handle = NULL;
- }
-}
-
-
-// Start of the 'real' code
-subs_log_a_line("\r\n\r\nMail subscriptions run started at ".date("D j M Y G:i:s"),TRUE,FALSE);
-
-
-
-// Start with the 'in advance' emails
-$cal_args = "select * from #event left join #event_cat on event_category=event_cat_id where (event_cat_subs>0 OR event_cat_force_class>0) and
-event_cat_last < " . intval($cal_starttime) . " and
-event_cat_ahead > 0 and
-event_start >= (" . intval($cal_starttime) . "+(86400*(event_cat_ahead))) and
-event_start < (" . intval($cal_starttime) . "+(86400*(event_cat_ahead+1))) and
-find_in_set(event_cat_notify,'1,3,5,7')";
-
-ec_send_mailshot($cal_args, 'Advance',1, $calendar_shortcodes);
-
-
-
-// then for today
-$cal_args = "select * from #event left join #event_cat on event_category=event_cat_id where (event_cat_subs>0 OR event_cat_force_class>0) and
-event_cat_today < " . intval($cal_starttime) . " and
-event_start >= (" . intval($cal_starttime) . ") and
-event_start < (86400+" . intval($cal_starttime) . ") and
-find_in_set(event_cat_notify,'2,3,6,7')";
-
-ec_send_mailshot($cal_args, 'today',2, $calendar_shortcodes);
-
-
-if ($ec_debug_level == 0)
-{
-// Finally do 'day before' emails (its an alternative to 'today' emails)
-$cal_args = "select * from #event left join #event_cat on event_category=event_cat_id where (event_cat_subs>0 OR event_cat_force_class>0) and
-event_cat_today < " . intval($cal_starttime) . " and
-event_start >= (" . intval($cal_starttime) ." + 86400 ) and
-event_start < (" . intval($cal_starttime) ." + 172800) and
-find_in_set(event_cat_notify,'4,5,6,7')";
-}
-else
-{
-// Finally do 'day before' emails (its an alternative to 'today' emails)
-$cal_args = "select * from #event left join #event_cat on event_category=event_cat_id where (event_cat_subs>0 OR event_cat_force_class>0) and
-event_start >= (" . intval($cal_starttime) ." + 86400 ) and
-event_start < (" . intval($cal_starttime) ." + 172800) and
-find_in_set(event_cat_notify,'4,5,6,7')";
-}
-
-ec_send_mailshot($cal_args, 'tomorrow',2, $calendar_shortcodes);
-
-
-subs_log_a_line("\r\n .. completed at ".date("D j M Y G:i:s")."\r\n",TRUE,FALSE);
-
-// This stops the mailout running again until first access of tomorrow
-if ($ec_run_from_menu)
-{
- $e107cache->set("nomd5_cal_subs", time(),TRUE);
-}
-
-// Done
-
-
-
-// Function called to load in default templates (messages) if required - only accesses database once
-function ec_load_default_messages()
-{
- global $sql2, $ec_default_msg_1, $ec_default_msg_2;
- if (($ec_default_msg_1 != "") && ($ec_default_msg_2 != "")) return;
- if ($sql2->db_Select("event_cat", "*", "event_cat_name = '".EC_DEFAULT_CATEGORY."' "))
- {
- if ($row = $sql2->db_Fetch())
- {
- $ec_default_msg_1 = $row['event_cat_msg1'];
- $ec_default_msg_2 = $row['event_cat_msg2'];
- }
- }
- // Put in generic message rather than nothing - will help flag omission
- if ($ec_default_msg_1 == "") $ec_default_msg_1 = EC_LAN_146;
- if ($ec_default_msg_2 == "") $ec_default_msg_2 = EC_LAN_147;
-}
-
-/*
- Function to actually send a mailshot
-*/
-function ec_send_mailshot($cal_query, $shot_type, $msg_num, $calendar_shortcodes)
-{
- global $sql, $sql2;
- global $ec_debug_level, $ec_log_requirement;
- global $pref, $tp, $thisevent;
- global $ec_default_msg_1, $ec_default_msg_2;
-
- if ($ec_log_requirement > 1)
- {
- subs_log_a_line("\r\n Starting emails for ".$shot_type." at ".date("D j M Y G:i:s"),FALSE,FALSE);
- if ($ec_debug_level >= 2) subs_log_a_line("\r\n Query is: ".$cal_query."\r\n",FALSE,FALSE);
- }
-
- if ($num_cat_proc = $sql->db_Select_gen($cal_query))
- { // Got at least one event to process here
- if ($ec_log_requirement > 1)
- subs_log_a_line(" - ".$num_cat_proc." categories found to process\r\n",FALSE,TRUE);
-
- require_once(e_HANDLER . "mail.php");
- while ($cal_row = $sql->db_Fetch())
- { // Process one event at a time
- $thisevent = $cal_row; // Used for shortcodes
- extract($cal_row);
-
- subs_log_a_line(" Processing event: ".$event_title." \r\n",FALSE,TRUE);
-
- // Note that event processed, and generate the email
- if ($msg_num == 1)
- {
- $sql2->db_Update("event_cat", "event_cat_last=" . time() . " where event_cat_id=" . intval($event_cat_id));
-// $cal_msg = $event_title . "\n\n" . $event_cat_msg1;
- $cal_msg = $event_cat_msg1;
- if (trim($cal_msg) == "")
- {
- ec_load_default_messages();
- $cal_msg = $ec_default_msg_1;
- }
- }
- else
- {
- $sql2->db_Update("event_cat", "event_cat_today=" . time() . " where event_cat_id=" . intval($event_cat_id));
-// $cal_msg = $event_title . "\n\n" . $event_cat_msg2;
- $cal_msg = $event_cat_msg2;
- if (trim($cal_msg) == "")
- {
- ec_load_default_messages();
- $cal_msg = $ec_default_msg_2;
- }
- }
- // Parsing the template here means we can't use USER-related shortcodes
- // Main ones which are relevant: MAIL_DATE_START, MAIL_TIME_START, MAIL_DATE_END,
- // MAIL_TIME_END, MAIL_TITLE, MAIL_DETAILS, MAIL_CATEGORY, MAIL_LOCATION,
- // MAIL_CONTACT, MAIL_THREAD (maybe). Also MAIL_LINK, MAIL_SHORT_DATE
- // Best to strip entities here rather than at entry - handles old events as well
- $cal_title = html_entity_decode($tp -> parseTemplate($pref['eventpost_mailsubject'], FALSE, $calendar_shortcodes),ENT_QUOTES,CHARSET);
- $cal_msg = html_entity_decode($tp -> parseTemplate($cal_msg, FALSE, $calendar_shortcodes),ENT_QUOTES,CHARSET);
- // $cal_msg = str_replace("\r","\n",$cal_msg);
-
- // Four cases for the query:
- // 1. No forced mailshots - based on event_subs table only Need INNER JOIN
- // 2. Forced mailshot to members - send to all users (don't care about subscriptions) Don't need JOIN
- // 3. Forced mailshot to group of members - based on user table only Don't need JOIN
- // 4. Forced mailshot to group, plus optional subscriptions - use the lot! Need LEFT JOIN
- // (Always block sent to banned members)
- $manual_subs = (isset($pref['eventpost_asubs']) && ($pref['eventpost_asubs'] == '1'));
- $subs_fields = '';
- $subs_join = '';
- $whereClause = '';
- $group_clause = '';
-
- if ($event_cat_force_class != e_UC_MEMBER)
- { // Cases 1, 3, 4 (basic query does for case 2)
- if ((!$event_cat_force_class) || ($manual_subs))
- { // Cases 1 & 4 - need to join with event_subs database
- $subs_fields = ", es.* ";
- if ($event_cat_force_class) $subs_join = "LEFT"; else $subs_join = "INNER";
- $subs_join .= " join #event_subs AS es on u.user_id=es.event_userid ";
- $whereClause = " es.event_cat='".intval($event_category)."' ";
- $group_clause = " GROUP BY u.user_id";
- }
-
- if ($event_cat_force_class)
- { // cases 3 and 4 - ... and check for involuntary subscribers
- if ($whereClause) $whereClause .= " OR ";
- if ($event_cat_force_class == e_UC_ADMIN)
- {
- $whereClause .= "(u.user_admin = 1 )";
- }
- else
- {
- $whereClause .= "find_in_set('".intval($event_cat_force_class)."', u.user_class)";
-// $forced_regexp = "'(^|,)(".intval($event_cat_force_class).")(,|$)'";
-// $whereClause .= " (u.user_class REGEXP '".$forced_regexp."') ";
- $group_clause = " GROUP BY u.user_id";
- }
- }
-
- if ($whereClause) $whereClause = ' AND ('.$whereClause.' ) ';
- } // End of cases 1, 3, 4
-
- $cal_emilargs = "SELECT u.user_id, u.user_class, u.user_email, u.user_name, u.user_ban, u.user_admin{$subs_fields}
- from #user AS u {$subs_join}
- WHERE u.user_ban = '0' {$whereClause} {$group_clause}";
-
-
- if ($ec_debug_level >= 2)
- {
- subs_log_a_line("\r\n Email selection query is: ".$cal_emilargs."\r\n",FALSE,TRUE);
- }
- if ($num_shots = $sql2->db_Select_gen($cal_emilargs))
- {
- subs_log_a_line(" - ".$num_shots." emails found to send\r\n",FALSE,TRUE);
-
- while ($cal_emrow = $sql2->db_Fetch())
- {
- extract($cal_emrow);
- if ($ec_debug_level == 0)
- $send_result = sendemail($user_email, $cal_title, $cal_msg, $user_name, $pref['eventpost_mailaddress'], $pref['eventpost_mailfrom']);
- else
- $send_result = " **DEBUG**";
- if ($ec_log_requirement > 1)
- {
- subs_log_a_line(" Send to ".$user_id.':'.$user_email." Name: ".$user_name." Result = ".$send_result."\r\n",FALSE,TRUE);
- }
- }
- }
- } // while
- if ($ec_log_requirement > 1)
- {
- subs_log_a_line(" Completed emails for ".$shot_type." at ".date("D j M Y G:i:s")."\r\n",TRUE,TRUE);
- }
- }
-}
-
-
-
-?>
\ No newline at end of file
diff --git a/e107_plugins/calendar_menu/subscribe.php b/e107_plugins/calendar_menu/subscribe.php
index a880fc730..35d97a2a4 100644
--- a/e107_plugins/calendar_menu/subscribe.php
+++ b/e107_plugins/calendar_menu/subscribe.php
@@ -6,97 +6,99 @@
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
- *
+ * Event calendar plugin - mail subscription to events notification
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/subscribe.php,v $
- * $Revision: 1.6 $
- * $Date: 2009-11-18 01:05:23 $
- * $Author: e107coders $
+ * $Revision: 1.7 $
+ * $Date: 2009-11-22 10:11:31 $
+ * $Author: e107steved $
*/
-require_once("../../class2.php");
-if (!isset($pref['plug_installed']['calendar_menu'])) header("Location: ".e_BASE."index.php");
-include_lan(e_PLUGIN . "calendar_menu/languages/".e_LANGUAGE.".php");
+require_once('../../class2.php');
+$e107 = e107::getInstance();
-define("PAGE_NAME", EC_LAN_80);
+if (!$e107->isInstalled('calendar_menu')) header('Location: '.e_BASE.'index.php');
+include_lan(e_PLUGIN .'calendar_menu/languages/'.e_LANGUAGE.'.php');
+global $pref;
+define('PAGE_NAME', EC_LAN_80);
require_once(HEADERF);
if ((USER) && (isset($pref['eventpost_asubs']) && ($pref['eventpost_asubs'] == '1')))
{
-$cal_db = new db; // Probably best to keep this
+ $cal_db = new db; // Probably best to keep this
-if (isset($_POST['upsubs']))
-{
- $cal_cats = $tp -> toDB($_POST['event_list']); // IDs of allowed categories
- $cal_subs = $tp -> toDB($_POST['event_subd']); // Checkbox results
- $cal_db->db_Delete("event_subs", "event_userid='" . USERID . "'"); // Delete all for this user to start
- foreach($cal_cats as $cal_row)
- { // Now add in a subscription for each allowed category
- if ($cal_subs[$cal_row])
- {
- $cal_inargs = "0,'" . USERID . "','" . $cal_row . "'";
- $cal_db->db_Insert("event_subs", $cal_inargs);
- }
- // print $cal_row . $cal_subs[$cal_row] . " ";
- }
- $caltext = "";
-}
-else
-{
- $caltext = "";
+ }
}
else
{
- if (isset($pref['eventpost_asubs']) && ($pref['eventpost_asubs'] == '1'))
- $caltext = EC_LAN_142; // Register or log in
- else
- $caltext = EC_LAN_143; // No facility
+ if (isset($pref['eventpost_asubs']) && ($pref['eventpost_asubs'] == '1'))
+ $caltext = EC_LAN_142; // Register or log in
+ else
+ $caltext = EC_LAN_143; // No facility
}
-$ns->tablerender(EC_LAN_124, $caltext);
+$e107->ns->tablerender(EC_LAN_124, $caltext);
require_once(FOOTERF);
?>
\ No newline at end of file
|