1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-06 06:38:00 +02:00

Event calendar - convert to use new shortcode method (NO GLOBALS!!!!), use new mailout routines and cron handler

This commit is contained in:
e107steved
2009-11-22 10:11:32 +00:00
parent 2d270c5317
commit eb8cc4bfb5
17 changed files with 2477 additions and 1955 deletions

View File

@@ -6,19 +6,19 @@
* Released under the terms and conditions of the * Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * 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 $ * $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/admin_config.php,v $
* $Revision: 1.14 $ * $Revision: 1.15 $
* $Date: 2009-11-18 01:05:23 $ * $Date: 2009-11-22 10:11:24 $
* $Author: e107coders $ * $Author: e107steved $
*/ */
$eplug_admin = true; // Make sure we show admin theme $eplug_admin = true; // Make sure we show admin theme
$e_sub_cat = 'event_calendar'; $e_sub_cat = 'event_calendar';
require_once("../../class2.php"); require_once('../../class2.php');
require_once(e_HANDLER."userclass_class.php"); require_once(e_HANDLER."userclass_class.php");
if (!getperms("P")) if (!getperms('P'))
{ {
header("location:".e_BASE."index.php"); header("location:".e_BASE."index.php");
exit; exit;
@@ -28,7 +28,7 @@ if (!getperms("P"))
include_lan(e_PLUGIN.'calendar_menu/languages/'.e_LANGUAGE.'_admin_calendar_menu.php'); include_lan(e_PLUGIN.'calendar_menu/languages/'.e_LANGUAGE.'_admin_calendar_menu.php');
$message = ""; $message = '';
$calendarmenu_text = ''; // Notice removal $calendarmenu_text = ''; // Notice removal
$calendarmenu_msg = ''; // Notice removal $calendarmenu_msg = ''; // Notice removal
@@ -164,38 +164,38 @@ if (isset($_POST['deleteold']) && isset($_POST['eventpost_deleteoldmonths']))
if (isset($_POST['cache_clear'])) 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 // Actually delete back events
if (isset($_POST['confirmdeleteold']) && isset($ec_qs[0]) && ($ec_qs[0] == "backdel")) if (isset($_POST['confirmdeleteold']) && isset($ec_qs[0]) && ($ec_qs[0] == "backdel"))
{ {
$old_date = $ec_qs[1]; $old_date = $ec_qs[1];
$old_string = strftime("%d %B %Y",$old_date); $old_string = strftime("%d %B %Y",$old_date);
// Check both start and end dates to avoid problems with events originally entered under 0.617 // 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"; $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}"; // $message = "Back delete {$back_count} months. Oldest date = {$old_string} Query = {$qry}";
if ($sql -> db_Delete("event",$qry)) if ($sql -> db_Delete("event",$qry))
{ {
// Add in a log event // Add in a log event
$ecal_class->cal_log(4,"db_Delete - earlier than {$old_string} (past {$back_count} months)",$qry); $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; $message = EC_ADLAN_A146.$old_string.EC_ADLAN_A147;
} }
else 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 case '1': // Edit existing record
{ {
// We edit the 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() ; $calendarmenu_row = $calendarmenu_db->db_Fetch() ;
extract($calendarmenu_row); extract($calendarmenu_row);
$calendarmenu_cap1 = EC_ADLAN_A24; $calendarmenu_cap1 = EC_ADLAN_A24;
@@ -356,15 +356,15 @@ if(isset($ec_qs[0]) && $ec_qs[0] == "cat")
// First, set up a dummy event // First, set up a dummy event
global $thisevent; global $thisevent;
$thisevent = array('event_start' => $ecal_class->time_now, 'event_end' => ($ecal_class->time_now)+3600, $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_cat_name' => $event_cat_name, 'event_location' => EC_ADLAN_A192,
'event_contact' => USEREMAIL, 'event_contact' => USEREMAIL,
'event_thread' => SITEURL."dodgypage", 'event_thread' => SITEURL.'dodgypage',
'event_id' => '6'); 'event_id' => '6');
// *************** SEND EMAIL HERE ************** // *************** SEND EMAIL HERE **************
require_once(e_PLUGIN."calendar_menu/calendar_shortcodes.php"); require_once(e_PLUGIN.'calendar_menu/calendar_shortcodes.php');
require_once(e_HANDLER . "mail.php"); require_once(e_HANDLER . 'mail.php');
switch ($ecal_send_email) switch ($ecal_send_email)
{ {
case 1 : $cal_msg = $event_cat_msg1; 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; case 2 : $cal_msg = $event_cat_msg2;
break; break;
} }
$cal_msg = $tp -> parseTemplate($cal_msg, FALSE, $calendar_shortcodes); $cal_msg = $tp -> parseTemplate($cal_msg, TRUE);
$cal_title = $tp -> parseTemplate($pref['eventpost_mailsubject'], FALSE, $calendar_shortcodes); $cal_title = $tp -> parseTemplate($pref['eventpost_mailsubject'], TRUE);
$user_email = USEREMAIL; $user_email = USEREMAIL;
$user_name = USERNAME; $user_name = USERNAME;
// $cal_msg = str_replace("\r","\n",$cal_msg); // $cal_msg = str_replace("\r","\n",$cal_msg);

View File

@@ -6,38 +6,46 @@
* Released under the terms and conditions of the * Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * 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 $ * $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/calendar.php,v $
* $Revision: 1.6 $ * $Revision: 1.7 $
* $Date: 2009-11-18 01:05:23 $ * $Date: 2009-11-22 10:11:28 $
* $Author: e107coders $ * $Author: e107steved $
*/ */
require_once("../../class2.php"); require_once('../../class2.php');
if (!isset($pref['plug_installed']['calendar_menu'])) header('Location: '.e_BASE.'index.php'); $e107 = e107::getInstance();
require_once(e_PLUGIN.'calendar_menu/calendar_shortcodes.php'); if (!$e107->isInstalled('calendar_menu')) header('Location: '.e_BASE.'index.php');
if (isset($_POST['viewallevents'])) 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'])) 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'])) 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'])) 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'); e107::getScParser();
define("PAGE_NAME", EC_LAN_121); 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; $ecal_class = new ecal_class;
if (is_readable(THEME.'calendar_template.php')) 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); require_once(HEADERF);
// get date within area to display // get date within area to display
$qs = explode(".", e_QUERY); unset($dateArray);
if(varset($qs[0],'') == "") if (e_QUERY)
{ // Show current month {
$datearray = $ecal_class->cal_date; $qs = explode('.', e_QUERY); // Get date from query
} $dateArray = getdate($qs[0]);
else
{ // Get date from query
$datearray = getdate($qs[0]);
} }
if (!is_array($dateArray))
// Note: A lot of the following variables are used within the shortcodes { // Show current month
$month = $datearray['mon']; // Number of month being shown $dateArray = $ecal_class->cal_date;
$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;
} }
$previous = mktime(0, 0, 0, $prevmonth, 1, $prevyear); // Used by nav
$nextmonth = $month + 1; // These are used in the day display loop
$nextyear = $year; $month = $dateArray['mon']; // Number of month being shown
if ($nextmonth == 13) $year = $dateArray['year']; // Number of year being shown
{
$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
$nowmonth = $ecal_class->cal_date['mon']; $nowmonth = $ecal_class->cal_date['mon'];
$nowyear = $ecal_class->cal_date['year']; $nowyear = $ecal_class->cal_date['year'];
$nowday = $ecal_class->cal_date['mday']; $nowday = $ecal_class->cal_date['mday'];
// set up arrays for calendar display ------------------------------------------------------------------ // Set date window for display
// $months is used in the navigator buttons. $monthabb is used for month list $monthstart = mktime(0, 0, 0, $month, 1, $year); // Start of month to be shown
$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); $monthend = mktime(0, 0, 0, $month + 1, 1, $year) - 1; // End of month to be shown
$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);
$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 // time switch buttons
$cal_text = $tp -> parseTemplate($CALENDAR_TIME_TABLE, FALSE, $calendar_shortcodes); $cal_text = $e107->tp->parseTemplate($CALENDAR_TIME_TABLE, TRUE);
// navigation buttons // 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 // 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'); $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 // 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 // Note that the new class-based retrieval adds an 'is_recent' flag to the data if changed according to the configured criteria
$events = array(); $events = array();
foreach ($ev_list as $row) foreach ($ev_list as $row)
{ {
$row['startofevent'] = TRUE; // This sets 'large print' and so on for the first day of an event $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) // check for recurring events in this month (could also use is_array($row['event_start']) as a test)
if($row['event_recurring'] != '0') if($row['event_recurring'] != '0')
{ // There could be several dates for the same event, if its a daily/weekly event { // There could be several dates for the same event, if its a daily/weekly event
$t_start = $row['event_start']; $t_start = $row['event_start'];
foreach ($t_start as $ev_start) foreach ($t_start as $ev_start)
{ {
@@ -137,9 +124,9 @@ $events = array();
$row['event_start'] = $ev_start; $row['event_start'] = $ev_start;
$events[date('j',$ev_start)][] = $row; $events[date('j',$ev_start)][] = $row;
} }
} }
else else
{ // Its a 'normal' event { // Its a 'normal' event
$tmp = date('j',$row['event_start']); // Day of month for start $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 $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; $events[$c][] = $row;
} }
}
} }
}
// ****** CAUTION - the category dropdown also used $sql object - take care to avoid interference! // ****** CAUTION - the category dropdown also used $sql object - take care to avoid interference!
$start = $monthstart; $start = $monthstart;
$numberdays = date("t", $start); // number of days in this month $numberdays = date('t', $start); // number of days in this month
$text = ""; $text = "";
$text .= $tp -> parseTemplate($CALENDAR_CALENDAR_START, FALSE, $calendar_shortcodes); $text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_START, TRUE);
$text .= $tp -> parseTemplate($CALENDAR_CALENDAR_HEADER_START, FALSE, $calendar_shortcodes); $text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_HEADER_START, TRUE);
// Display the column headers
for ($i = 0; $i < 7; $i++) for ($i = 0; $i < 7; $i++)
{ {
$day = $ecal_class->day_offset_string($i); setScVar('event_calendar_shortcodes', 'headerDay', $ecal_class->day_offset_string($i));
$text .= $tp -> parseTemplate($CALENDAR_CALENDAR_HEADER, FALSE, $calendar_shortcodes); $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 // 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; $firstdayoffset = date('w',$start) - $ecal_class->ec_first_day_of_week;
if ($firstdayoffset < 0) $firstdayoffset+= 7; 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; $loop = $firstdayoffset;
for ($c = 1; $c <= $numberdays; $c++) for ($c = 1; $c <= $numberdays; $c++)
{ // Loop through the number of days in this month { // Loop through the number of days in this month
$startt = $start; // Used by shortcodes - start of current day setScVar('event_calendar_shortcodes', 'todayStart', $start); // Start of current day
$stopp = $start + 86399; // End 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 today
$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. // Highlight the current day.
if ($nowday == $c && $month == $nowmonth && $year == $nowyear) if ($nowday == $c && $month == $nowmonth && $year == $nowyear)
{ //today { //today
$text .= $tp -> parseTemplate($CALENDAR_CALENDAR_DAY_TODAY, FALSE, $calendar_shortcodes); $text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_DAY_TODAY, TRUE);
} }
elseif ($got_ev) elseif ($got_ev)
{ //day has events { //day has events
$text .= $tp -> parseTemplate($CALENDAR_CALENDAR_DAY_EVENT, FALSE, $calendar_shortcodes); $text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_DAY_EVENT, TRUE);
} }
else else
{ // no events and not today { // 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) if ($got_ev)
{ {
@@ -224,44 +213,45 @@ for ($c = 1; $c <= $numberdays; $c++)
{ {
if ($ev['startofevent']) if ($ev['startofevent'])
{ {
$ev['indicat'] = ""; $ev['indicat'] = '';
$ev['imagesize'] = "8"; $ev['imagesize'] = '8';
$ev['fulltopic'] = TRUE; $ev['fulltopic'] = TRUE;
} }
else else
{ {
$ev['indicat'] = ""; $ev['indicat'] = '';
$ev['imagesize'] = "4"; $ev['imagesize'] = '4';
$ev['fulltopic'] = FALSE; $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++; $loop++;
if ($loop == 7) if ($loop == 7)
{
$loop = 0;
if($c != $numberdays)
{ {
$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 //remainder cells to end the row properly with empty cells
if($loop!=0) if($loop!=0)
{ {
for ($c=$loop; $c<7; $c++) for ($c=$loop; $c<7; $c++)
{ {
$text .= $tp -> parseTemplate($CALENDAR_CALENDAR_DAY_NON, FALSE, $calendar_shortcodes); $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 // Claim back memory from key variables
unset($ev_list); unset($ev_list);

View File

@@ -1,47 +1,51 @@
<?php <?php
/* /*
+ ----------------------------------------------------------------------------+ * e107 website system
| e107 website system *
| * Copyright (C) 2008-2009 e107 Inc (e107.org)
| Copyright (C) 2008-2009 e107 Inc (e107.org) * Released under the terms and conditions of the
| http://e107.org * GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
| *
| * Forthcoming events menu handler for event calendar
| Released under the terms and conditions of the *
| GNU General Public License (http://gnu.org). * $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/calendar_menu.php,v $
| * $Revision: 1.7 $
| $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/calendar_menu.php,v $ * $Date: 2009-11-22 10:11:28 $
| $Revision: 1.6 $ * $Author: e107steved $
| $Date: 2009-11-18 01:05:23 $ */
| $Author: e107coders $
|
+----------------------------------------------------------------------------+
*/
if (!defined('e107_INIT')) { exit; } if (!defined('e107_INIT')) { exit; }
$ecal_dir = e_PLUGIN.'calendar_menu/'; $e107 = e107::getInstance();
require_once($ecal_dir.'ecal_class.php'); if (!$e107->isInstalled('calendar_menu')) return '';
if (!isset($ecal_class) || !is_object($ecal_class)) $ecal_class = new ecal_class;
$cache_tag = 'nq_event_cal_cal';
global $e107;
// See if the page is already in the cache // 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)) if($cacheData = $e107->ecache->retrieve($cache_tag, $ecal_class->max_cache_time))
{ {
echo $cacheData; echo $cacheData;
return; return;
} }
include_lan($ecal_dir.'languages/'.e_LANGUAGE.'.php'); global $pref;
global $ecal_dir, $tp; if (!is_object($ecal_class))
if (is_readable(THEME."calendar_template.php"))
{ {
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 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 $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_datearray = $ecal_class->cal_date;
$cal_current_month = $cal_datearray['mon']; $cal_current_month = $cal_datearray['mon'];
$cal_current_year = $cal_datearray['year']; $cal_current_year = $cal_datearray['year'];
@@ -55,30 +59,34 @@ $cal_events = array();
$cal_titles = array(); $cal_titles = array();
$cal_recent = array(); $cal_recent = array();
$cal_totev = 0; $cal_totev = 0;
$ev_list = $ecal_class->get_events($cal_monthstart, $cal_monthend, FALSE, $cat_filter, $show_recurring, $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'); 'event_start, event_thread, event_title, event_recurring, event_allday', 'event_cat_icon');
$cal_totev = count($ev_list); $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']); if (is_array($cal_row['event_start'])) $temp = $cal_row['event_start']; else $temp = array($cal_row['event_start']);
foreach ($temp as $ts) foreach ($temp as $ts)
{ { // Split up any recurring events
$cal_start_day = date('j',$ts); // Day of month for start $cal_start_day = date('j',$ts); // Day of month for start
// Mark start day of each event // Mark start day of each event
$cal_events[$cal_start_day][] = $cal_row['event_cat_icon']; // Only first is actually used $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; 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 $cal_titles[$cal_start_day][] = $cal_row['event_title']; // In case titles displayed on mouseover
} }
} }
// set up month array for calendar display // 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); $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') 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 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']) switch ($pref['eventpost_menulink'])
{ {
@@ -109,11 +117,10 @@ $cal_text .= $CALENDAR_MENU_HEADER_START;
// Now do the headings (days of week) // Now do the headings (days of week)
for ($i = 0; $i < 7; $i++) for ($i = 0; $i < 7; $i++)
{ {
$cal_day = $ecal_class->day_offset_string($i); $cal_day = $ecal_class->day_offset_string($i);
$cal_text .= $CALENDAR_MENU_HEADER_FRONT; $cal_text .= $CALENDAR_MENU_HEADER_FRONT;
// $cal_text .= substr($cal_day, 0, $pref['eventpost_lenday']); $cal_text .= $e107->tp->text_truncate($cal_day, 1, ''); // Unlikely to have room for more than 1 letter
$cal_text .= $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_BACK;
} }
$cal_text .= $CALENDAR_MENU_HEADER_END; // Close off header row, open first date row $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 // 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; if ($firstdayoffset < 0) $firstdayoffset+= 7;
for ($cal_c = 0; $cal_c < $firstdayoffset; $cal_c++) for ($cal_c = 0; $cal_c < $firstdayoffset; $cal_c++)
{ {
$cal_text .= $CALENDAR_MENU_DAY_NON; $cal_text .= $CALENDAR_MENU_DAY_NON;
} }
$cal_loop = $firstdayoffset; $cal_loop = $firstdayoffset;
// Now do the days of the month // 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" $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)) if (array_key_exists($cal_c, $cal_events))
{ // There are events today { // There are events today
$cal_event_icon = "calendar_menu/images/" . $cal_events[$cal_c]['0']; // Icon file could be NULL $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 $cal_event_count = count($cal_events[$cal_c]); // See how many events today
if ($cal_event_count) if ($cal_event_count)
{ // Show icon if it exists { // Show icon if it exists
$cal_css += 2; // Gives 3 for today, 4 for other day $cal_css += 2; // Gives 3 for today, 4 for other day
if (isset($pref['eventpost_showmouseover']) && ($pref['eventpost_showmouseover'] == 1)) if (isset($pref['eventpost_showmouseover']) && ($pref['eventpost_showmouseover'] == 1))
{ {
$cal_ins = " title='"; $cal_ins = " title='";
foreach ($cal_titles[$cal_c] as $cur_title) foreach ($cal_titles[$cal_c] as $cur_title)
{ // New line would be better, but doesn't get displayed { // New line would be better, but doesn't get displayed
$title .= $cal_ins.$cur_title; $title .= $cal_ins.$cur_title;
$cal_ins = ", "; $cal_ins = ", ";
} }
$title .= "'"; $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 = "<img src='".e_PLUGIN_ABS.$cal_event_icon."' alt='' />";
//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 = "<img src='".e_PLUGIN_ABS.$cal_event_icon."' alt='' />";
//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]."<a {$title} href='" . e_PLUGIN . "calendar_menu/event.php?{$cal_linkut}'>{$cal_img}</a>"; $cal_text .= $CALENDAR_MENU_DAY_START[$cal_css]."<a {$title} href='" . e_PLUGIN . "calendar_menu/event.php?{$cal_linkut}'>{$cal_img}</a>";
$cal_text .= $CALENDAR_MENU_DAY_END[$cal_css]; $cal_text .= $CALENDAR_MENU_DAY_END[$cal_css];
$cal_loop++; $cal_loop++;
if ($cal_loop == 7) if ($cal_loop == 7)
{ // Start next row { // Start next row
$cal_loop = 0; $cal_loop = 0;
if ($cal_c != $numberdays) if ($cal_c != $numberdays)
{ {
$cal_text .= $CALENDAR_MENU_WEEKSWITCH; $cal_text .= $CALENDAR_MENU_WEEKSWITCH;
} }
} }
} }
if ($cal_loop != 0) if ($cal_loop != 0)

File diff suppressed because it is too large Load Diff

View File

@@ -6,18 +6,20 @@
* Released under the terms and conditions of the * Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * 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 $ * $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/calendar_template.php,v $
* $Revision: 1.9 $ * $Revision: 1.10 $
* $Date: 2009-11-18 01:05:23 $ * $Date: 2009-11-22 10:11:29 $
* $Author: e107coders $ * $Author: e107steved $
*/ */
// TODO: Replace expandit on events with latest auto-management
if (!defined('e107_INIT')) { exit; } 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 = e_IMAGE;
$ec_images_path_abs = e_IMAGE_ABS; $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[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} <b>".EC_LAN_69."</b> {EC_EVENT_DATE_END}"; $EVENT_EVENT_DATETIME[2] = "{EC_EVENT_DATE_START} <b>".EC_LAN_69."</b> {EC_EVENT_DATE_END}";
$EVENT_EVENT_DATETIME[3] = "{EC_EVENT_DATE_START}"; $EVENT_EVENT_DATETIME[3] = "{EC_EVENT_DATE_START}";
/* This is roughly what's wanted, but div not allowed
$EVENT_EVENT_TABLE = " $EVENT_EVENT_TABLE = "
<tr> <tr>
<td > <td >
<div title='".EC_LAN_132."' class='fcaption' style='cursor:pointer; text-align:left; border:0px solid #000;' onclick=\"expandit('{EC_EVENT_ID}')\">{EC_EVENT_RECENT_ICON}{EC_EVENT_CAT_ICON}{EC_EVENT_HEADING_DATE}{EC_IFNOT_ALLDAY=EC_EVENT_TIME_START}&nbsp;-&nbsp;{EC_EVENT_TITLE}</div> <a href='#{EC_EVENT_ID}' class='e-show-if-js e-expandit fcaption'><div title='".EC_LAN_132."' style='cursor:pointer; text-align:left; border:0px solid #000;' >{EC_EVENT_RECENT_ICON}{EC_EVENT_CAT_ICON}{EC_EVENT_HEADING_DATE}{EC_IFNOT_ALLDAY=EC_EVENT_TIME_START}&nbsp;-&nbsp;{EC_EVENT_TITLE}</div></a>
<div id='{EC_EVENT_ID}' style='display:{EC_EVENT_DISPLAYSTYLE}; padding-top:10px; padding-bottom:10px; text-align:left;'> <div id='{EC_EVENT_ID}' {EC_EVENT_DISPLAYCLASS} style='padding-top:10px; padding-bottom:10px; text-align:left;'>
<table style='width:100%;' cellspacing='0' cellpadding='0'> <table style='width:100%;' cellspacing='0' cellpadding='0'>
<tr><td colspan='2' class='forumheader3'>{EC_EVENT_AUTHOR} {EC_EVENT_CAT_ICON} {EC_EVENT_CATEGORY} {EC_EVENT_CONTACT} {EC_EVENT_OPTIONS}</td></tr> <tr><td colspan='2' class='forumheader3'>{EC_EVENT_AUTHOR} {EC_EVENT_CAT_ICON} {EC_EVENT_CATEGORY} {EC_EVENT_CONTACT} {EC_EVENT_OPTIONS}</td></tr>
<tr><td colspan='2' class='forumheader3'>{EC_EVENT_EVENT_DATE_TIME}</td></tr>\n <tr><td colspan='2' class='forumheader3'>{EC_EVENT_EVENT_DATE_TIME}</td></tr>\n
@@ -179,8 +184,27 @@ $EVENT_EVENT_TABLE = "
</td> </td>
</tr>\n </tr>\n
"; ";
*/
// This works, but not using latest class structure
$EVENT_EVENT_TABLE = "
<tr>
<td >
<div title='".EC_LAN_132."' class='fcaption' style='cursor:pointer; text-align:left; border:0px solid #000;' onclick=\"expandit('{EC_EVENT_ID}')\">{EC_EVENT_RECENT_ICON}{EC_EVENT_CAT_ICON}{EC_EVENT_HEADING_DATE}{EC_IFNOT_ALLDAY=EC_EVENT_TIME_START}&nbsp;-&nbsp;{EC_EVENT_TITLE}</div>
<div id='{EC_EVENT_ID}' style='{EC_EVENT_DISPLAYSTYLE}padding-top:10px; padding-bottom:10px; text-align:left;'>
<table style='width:100%;' cellspacing='0' cellpadding='0'>
<tr><td colspan='2' class='forumheader3'>{EC_EVENT_AUTHOR} {EC_EVENT_CAT_ICON} {EC_EVENT_CATEGORY} {EC_EVENT_CONTACT} {EC_EVENT_OPTIONS}</td></tr>
<tr><td colspan='2' class='forumheader3'>{EC_EVENT_EVENT_DATE_TIME}</td></tr>\n
{EC_EVENT_LOCATION}
{EC_EVENT_DETAILS}
{EC_EVENT_THREAD}
</table>
</div>
</td>
</tr>\n
";
//------------------------------------------ //------------------------------------------
// CALENDAR CALENDAR - 'Big' calendar // CALENDAR CALENDAR - 'Big' calendar
//------------------------------------------ //------------------------------------------

View File

@@ -0,0 +1,408 @@
<?php
/*
* e107 website system
*
* Copyright (C) 2001-2009 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Plugin configuration module - gsitemap
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/e_cron.php,v $
* $Revision: 1.1 $
* $Date: 2009-11-22 10:11:31 $
* $Author: e107steved $
*
*/
if (!defined('e107_INIT')) { exit; }
include_lan(e_PLUGIN.'/calendar_menu/languages/English_mailer.php');
class calendar_menu_cron // include plugin-folder in the name.
{
private $logRequirement = 0; // Flag to determine logging level
private $debugLevel = 0; // Used for internal debugging
private $logHandle = NULL;
private $ecalClass; // Calendar library routines
private $e107;
private $defaultMessage = array(); // Used where nothing special defined
private $startTime; // Start date for processing
private $mailManager;
private $ourDB; // Used for some things
public function __construct()
{
$this->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!<br />";
$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!<br />';
}
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.');
}
}
}
?>

View File

@@ -6,65 +6,73 @@
* Released under the terms and conditions of the * Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * 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 $ * $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/ec_mailout_template.php,v $
* $Revision: 1.3 $ * $Revision: 1.4 $
* $Date: 2009-11-18 01:05:23 $ * $Date: 2009-11-22 10:11:29 $
* $Author: e107coders $ * $Author: e107steved $
*/ */
/* /*
This template is used during the subscription mailouts - it is inserted at the front of the text This template is used during the subscription mailouts - it is inserted at the front of the text
defined for each category. defined for each category.
Main purpose is to define the 'pre' and 'post' styles, but it can be used much as any E107 template 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; } if (!defined('e107_INIT')) { exit; }
$sc_style['EC_MAIL_HEADING_DATE']['pre'] = ""; global $sc_style;
$sc_style['EC_MAIL_HEADING_DATE']['post'] = "";
$sc_style['EC_MAIL_SHORT_DATE']['pre'] = ""; $sc_style['EC_MAIL_HEADING_DATE']['pre'] = '';
$sc_style['EC_MAIL_SHORT_DATE']['post'] = ""; $sc_style['EC_MAIL_HEADING_DATE']['post'] = '';
$sc_style['EC_MAIL_TITLE']['pre'] = ""; $sc_style['EC_MAIL_SHORT_DATE']['pre'] = '';
$sc_style['EC_MAIL_TITLE']['post'] = ""; $sc_style['EC_MAIL_SHORT_DATE']['post'] = '';
$sc_style['EC_MAIL_ID']['pre'] = ""; $sc_style['EC_MAIL_TITLE']['pre'] = '';
$sc_style['EC_MAIL_ID']['post'] = ""; $sc_style['EC_MAIL_TITLE']['post'] = '';
$sc_style['EC_MAIL_DETAILS']['pre'] = ""; $sc_style['EC_MAIL_ID']['pre'] = '';
$sc_style['EC_MAIL_DETAILS']['post'] = ""; $sc_style['EC_MAIL_ID']['post'] = '';
$sc_style['EC_MAIL_LOCATION']['pre'] = EC_LAN_32." "; $sc_style['EC_MAIL_DETAILS']['pre'] = '';
$sc_style['EC_MAIL_LOCATION']['post'] = ""; $sc_style['EC_MAIL_DETAILS']['post'] = '';
$sc_style['EC_MAIL_AUTHOR']['pre'] = EC_LAN_31." "; $sc_style['EC_MAIL_LOCATION']['pre'] = LAN_EC_MAIL_100.' ';
$sc_style['EC_MAIL_AUTHOR']['post'] = ""; $sc_style['EC_MAIL_LOCATION']['post'] = '';
$sc_style['EC_MAIL_CONTACT']['pre'] = EC_LAN_33." "; $sc_style['EC_MAIL_AUTHOR']['pre'] = LAN_EC_MAIL_101.' ';
$sc_style['EC_MAIL_CONTACT']['post'] = ""; $sc_style['EC_MAIL_AUTHOR']['post'] = '';
$sc_style['EC_MAIL_THREAD']['pre'] = ""; $sc_style['EC_MAIL_CONTACT']['pre'] = LAN_EC_MAIL_102.' ';
$sc_style['EC_MAIL_THREAD']['post'] = ""; $sc_style['EC_MAIL_CONTACT']['post'] = '';
$sc_style['EC_MAIL_LINK']['pre'] = ""; $sc_style['EC_MAIL_THREAD']['pre'] = '';
$sc_style['EC_MAIL_LINK']['post'] = ""; $sc_style['EC_MAIL_THREAD']['post'] = '';
$sc_style['EC_MAIL_CATEGORY']['pre'] = ""; $sc_style['EC_MAIL_LINK']['pre'] = '';
$sc_style['EC_MAIL_CATEGORY']['post'] = ""; $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_CATEGORY']['pre'] = '';
$sc_style['EC_MAIL_DATE_START']['post'] = ""; $sc_style['EC_MAIL_CATEGORY']['post'] = '';
$sc_style['EC_MAIL_TIME_START']['pre'] = EC_LAN_144; $sc_style['EC_MAIL_DATE_START']['pre'] = '';
$sc_style['EC_MAIL_TIME_START']['post'] = ""; $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_TIME_START']['pre'] = LAN_EC_MAIL_105;
$sc_style['EC_MAIL_DATE_END']['post'] = ""; $sc_style['EC_MAIL_TIME_START']['post'] = '';
$sc_style['EC_MAIL_TIME_END']['pre'] = EC_LAN_144; $sc_style['EC_MAIL_DATE_END']['pre'] = LAN_EC_MAIL_106.' ';
$sc_style['EC_MAIL_TIME_END']['post'] = ""; $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'] = '';
?> ?>

View File

@@ -6,12 +6,12 @@
* Released under the terms and conditions of the * Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * 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 $ * $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/ec_pf_page.php,v $
* $Revision: 1.6 $ * $Revision: 1.7 $
* $Date: 2009-11-19 10:09:58 $ * $Date: 2009-11-22 10:11:30 $
* $Author: marj_nl_fr $ * $Author: e107steved $
*/ */
/* /*
| |
@@ -28,35 +28,38 @@
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
require_once("../../class2.php"); require_once('../../class2.php');
if (!isset($pref['plug_installed']['calendar_menu'])) header("Location: ".e_BASE."index.php"); $e107 = e107::getInstance();
include_lan(e_PLUGIN."calendar_menu/languages/".e_LANGUAGE.".php"); if (!$e107->isInstalled('calendar_menu')) header('Location: '.e_BASE.'index.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'); require_once(e_PLUGIN.'calendar_menu/ecal_class.php');
$ecal_class = new ecal_class; $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); unset($ec_qs);
if (e_QUERY) $ec_qs = explode(".", e_QUERY); if (e_QUERY) $ec_qs = explode('.', e_QUERY);
else else
{ {
if (!isset($pref['eventpost_printlists']) || ($pref['eventpost_printlists'] == 0)) 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']))) if (isset($_POST['set_dates']) && isset($_POST['start_date']) && (isset($_POST['end_date'])))
{ {
$ec_qs[0] = $_POST['start_date']; $ec_qs[0] = $_POST['start_date'];
$ec_qs[1] = $_POST['end_date']; $ec_qs[1] = $_POST['end_date'];
if (isset($_POST['event_cat_ids'])) if (isset($_POST['event_cat_ids']))
{ {
$ec_qs[2] = $_POST['event_cat_ids']; $ec_qs[2] = $_POST['event_cat_ids'];
if ($ec_qs[2] == 'all') $ec_qs[2] = '*'; if ($ec_qs[2] == 'all') $ec_qs[2] = '*';
} }
if (isset($_POST['template_choice'])) $ec_qs[3] = $_POST['template_choice']; if (isset($_POST['template_choice'])) $ec_qs[3] = $_POST['template_choice'];
} }
if (!isset($ec_qs[3])) $ec_qs[3] = 'default'; // Template 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; $cal_super = $ecal_class->cal_super;
// Get templates, since we may have to give a choice if we're displaying something // 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_HEADER = array();
$EVENT_CAL_PDF_BODY = array(); $EVENT_CAL_PDF_BODY = array();
$EVENT_CAL_PDF_FOOTER = 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_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(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(THEME.'ec_pf_template.php')) require_once(THEME.'ec_pf_template.php');
// Hard-coded alternatives // Hard-coded alternatives
if (!count($EVENT_CAL_PDF_HEADER)) $EVENT_CAL_PDF_HEADER['default'] = "<br />"; if (!count($EVENT_CAL_PDF_HEADER)) $EVENT_CAL_PDF_HEADER['default'] = '<br />';
if (!count($EVENT_CAL_PDF_BODY)) $EVENT_CAL_PDF_BODY['default'] = "{EC_MAIL_DATE_START} {EC_MAIL_TIME_START} {EC_MAIL_TITLE}<br />"; if (!count($EVENT_CAL_PDF_BODY)) $EVENT_CAL_PDF_BODY['default'] = '{EC_MAIL_DATE_START} {EC_MAIL_TIME_START} {EC_MAIL_TITLE}<br />';
if (!count($EVENT_CAL_PDF_FOOTER)) $EVENT_CAL_PDF_FOOTER['default'] = "<br />"; if (!count($EVENT_CAL_PDF_FOOTER)) $EVENT_CAL_PDF_FOOTER['default'] = '<br />';
if (!count($EVENT_CAL_PDF_NAMES)) $ec_pdf_template = 'default'; if (!count($EVENT_CAL_PDF_NAMES)) $ec_pdf_template = 'default';
// If one name only, we just assign that // If one name only, we just assign that
if (count($EVENT_CAL_PDF_NAMES) == 1) if (count($EVENT_CAL_PDF_NAMES) == 1)
@@ -113,7 +115,7 @@ if (!isset($ec_qs[0]) || !isset($ec_qs[1]))
</tr><tr> </tr><tr>
<td class='forumheader3'>".EC_LAN_155."</td> <td class='forumheader3'>".EC_LAN_155."</td>
<td class='forumheader3' style='text_align:center'>"; <td class='forumheader3' style='text_align:center'>";
$cal_text .= $tp->parseTemplate('{EC_NAV_CATEGORIES=nosubmit}',FALSE,$calendar_shortcodes); $cal_text .= $e107->tp->parseTemplate('{EC_NAV_CATEGORIES=nosubmit}',FALSE,$calendar_shortcodes);
$cal_text .= "</td> $cal_text .= "</td>
</tr>"; </tr>";
if (isset($EVENT_CAL_PDF_NAMES) && is_array($EVENT_CAL_PDF_NAMES) && (count($EVENT_CAL_PDF_NAMES) > 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; 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]; $ec_output_type = $ec_qs[4];
if (isset($ec_qs[5])) $ec_list_title = $ec_qs[5]; else $ec_list_title = EC_LAN_163; 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); $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_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'; 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 // 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_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_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_year = 0;
$ec_last_month = 0; $ec_last_month = 0;
$ec_last_day = 0; $ec_last_day = 0;
$ec_pdf_options = ""; // Can configure the PDF driver
$cal_text = ""; $cal_text = '';
$cal_totev = count($ev_list); $cal_totev = count($ev_list);
if ($cal_totev > 0) if ($cal_totev > 0)
{ {
if (isset($ec_template_styles[$ec_pdf_template]) && is_array($ec_template_styles[$ec_pdf_template])) 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 $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 $sc_style = array_merge($sc_style,$ec_current_overrides); // Override as necessary
} }
// If printing, wrap in a form so the button works // If printing, wrap in a form so the button works
if ($ec_output_type == 'print') $cal_text .= "<form action=''>\n"; if ($ec_output_type == 'print') $cal_text .= "<form action=''>\n";
// Add header // Add header
$cal_text .= $tp->parseTemplate($EVENT_CAL_PDF_HEADER[$ec_pdf_template],TRUE,$calendar_shortcodes); $cal_text .= $e107->tp->parseTemplate($EVENT_CAL_PDF_HEADER[$ec_pdf_template],TRUE);
// Debug code // Debug code
// echo "Start date: ".strftime("%d-%m-%Y %H:%M:%S",$ec_start_date)."<br />"; // echo "Start date: ".strftime("%d-%m-%Y %H:%M:%S",$ec_start_date)."<br />";
// echo "End date: ".strftime("%d-%m-%Y %H:%M:%S",$ec_end_date)."<br />"; // echo "End date: ".strftime("%d-%m-%Y %H:%M:%S",$ec_end_date)."<br />";
// echo "Template: ".$ec_pdf_template,"<br />"; // echo "Template: ".$ec_pdf_template,"<br />";
// echo "Header: ".$EVENT_CAL_PDF_HEADER[$ec_pdf_template]."<br />"; // echo "Header: ".$EVENT_CAL_PDF_HEADER[$ec_pdf_template]."<br />";
// echo "Body: ".$EVENT_CAL_PDF_BODY[$ec_pdf_template]."<br />"; // echo "Body: ".$EVENT_CAL_PDF_BODY[$ec_pdf_template]."<br />";
// echo "Footer: ".$EVENT_CAL_PDF_FOOTER[$ec_pdf_template]."<br />"; // echo "Footer: ".$EVENT_CAL_PDF_FOOTER[$ec_pdf_template]."<br />";
foreach ($tim_arr as $tim => $ptr) foreach ($tim_arr as $tim => $ptr)
{ {
$ev_list[$ptr]['event_start'] = $tim; $ev_list[$ptr]['event_start'] = $tim;
$thisevent = $ev_list[$ptr]; $thisevent = $ev_list[$ptr];
// echo "Event: ".$thisevent['event_start']." ".$thisevent['event_title']."<br />"; // Decode dates into individual fields - we're bound to want them
// Decode dates into individual fields - we're bound to want them $thisevent_start_date = $ecal_class->gmgetdate($thisevent['event_start']);
$thisevent_start_date = $ecal_class->gmgetdate($thisevent['event_start']); $thisevent_end_date = $ecal_class->gmgetdate($thisevent['event_end']);
$thisevent_end_date = $ecal_class->gmgetdate($thisevent['event_end']);
$ec_year_change = ($ec_last_year != $thisevent_start_date['year']); $ec_year_change = ($ec_last_year != $thisevent_start_date['year']);
$ec_month_change = ($ec_last_month != $thisevent_start_date['mon']); $ec_month_change = ($ec_last_month != $thisevent_start_date['mon']);
$ec_day_change = ($ec_last_day != $thisevent_start_date['mday']); $ec_day_change = ($ec_last_day != $thisevent_start_date['mday']);
$cal_totev --; // Can use this to modify inter-event gap $cal_totev --; // Can use this to modify inter-event gap
$cal_text .= $tp->parseTemplate($EVENT_CAL_PDF_BODY[$ec_pdf_template],FALSE,$calendar_shortcodes); setScVar('event_calendar_shortcodes', 'numEvents', $cal_totev); // Number of events to display
setScVar('event_calendar_shortcodes', 'event', $thisevent); // Give shortcodes the event data
$ec_last_year = $thisevent_start_date['year']; setScVar('event_calendar_shortcodes', 'changeFlags', array('yc' => $ec_year_change, 'mc' => $ec_month_change, 'dc' => $ec_day_change)); // Give shortcodes the event data
$ec_last_month = $thisevent_start_date['mon']; $cal_text .= $e107->tp->parseTemplate($EVENT_CAL_PDF_BODY[$ec_pdf_template],TRUE);
$ec_last_day = $thisevent_start_date['mday'];
} $ec_last_year = $thisevent_start_date['year'];
$ec_last_month = $thisevent_start_date['mon'];
$ec_last_day = $thisevent_start_date['mday'];
}
// Add footer // Add footer
$cal_text .= $tp->parseTemplate($EVENT_CAL_PDF_FOOTER[$ec_pdf_template],FALSE,$calendar_shortcodes); $cal_text .= $e107->tp->parseTemplate($EVENT_CAL_PDF_FOOTER[$ec_pdf_template],TRUE);
if ($ec_output_type == 'print') $cal_text .= "</form>\n"; if ($ec_output_type == 'print') $cal_text .= "</form>\n";
} }
else else
@@ -310,40 +320,36 @@ else
switch($ec_output_type) switch($ec_output_type)
{ {
case 'display': 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); require_once (FOOTERF);
break; break;
case 'print': case 'print':
echo $cal_text; echo $cal_text;
break; break;
case 'pdf': 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'); include_lan(e_PLUGIN.'pdf/languages/'.e_LANGUAGE.'.php');
define('FPDF_FONTPATH', 'font/'); define('FPDF_FONTPATH', 'font/');
//require the ufpdf class //require the ufpdf class
require_once (e_PLUGIN.'pdf/ufpdf.php'); require_once (e_PLUGIN.'pdf/ufpdf.php');
//require the e107pdf class //require the e107pdf class
require_once (e_PLUGIN.'pdf/e107pdf.php'); require_once (e_PLUGIN.'pdf/e107pdf.php');
if('' == $ec_pdf_options) $pdf = new e107PDF();
{
$pdf = new e107PDF();
}
else
{
$pdf = new e107PDF($ec_pdf_options);
}
// $text = array($text, $creator, $author, $title, $subject, $keywords, $url); // $text = array($text, $creator, $author, $title, $subject, $keywords, $url);
$text = array($cal_text, $text = array(
'', $cal_text,
'', '',
EC_LAN_163, '',
'', EC_LAN_163, // Title
'', '',
e_SELF.e_QUERY); '',
e_SELF.'?'.e_QUERY, // URL
'' // Page orientation
);
$pdf->makePDF($text); $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 // For the last date we want end of next
function gen_drop($drop_type) function gen_drop($drop_type)
{ {
$text = "<select name='".($drop_type ? 'end_date' : 'start_date')."' class='tbox' style='width:140px;' >\n"; $text = "<select name='".($drop_type ? 'end_date' : 'start_date')."' class='tbox' style='width:140px;' >\n";
if ($drop_type) if ($drop_type)
{ {
$start_date = strtotime("-3 months"); $start_date = strtotime('-3 months');
$match_date = strtotime("+3 months"); // Propose 3-month list $match_date = strtotime('+3 months'); // Propose 3-month list
} }
else else
{ {
$start_date = strtotime("-9 months"); $start_date = strtotime('-9 months');
// $match_date = strtotime("-1 months"); // $match_date = strtotime('-1 months');
$match_date = time(); // Use current month for start date $match_date = time(); // Use current month for start date
} }
// Get date to be 1st of month // Get date to be 1st of month
$date = getdate($match_date); $date = getdate($match_date);
$match_date = mktime(0,0,0,$date['mon'],1,$date['year'],FALSE); $match_date = mktime(0,0,0,$date['mon'],1,$date['year'],FALSE);
for ($i = 0; $i < 24; $i++) for ($i = 0; $i < 24; $i++)
{ {
$sel_text = (($match_date == $start_date) ? "selected='selected'" : ""); $sel_text = (($match_date == $start_date) ? "selected='selected'" : "");
$date = getdate($start_date); $date = getdate($start_date);
$text .= "<option value = '{$date['year']}{$date['mon']}' {$sel_text}>{$date['month']} {$date['year']} </option>\n"; $text .= "<option value = '{$date['year']}{$date['mon']}' {$sel_text}>{$date['month']} {$date['year']} </option>\n";
$start_date = mktime(0,0,0,$date['mon']+1,1,$date['year'],FALSE); $start_date = mktime(0,0,0,$date['mon']+1,1,$date['year'],FALSE);
} }
$text .= "</select>\n"; $text .= "</select>\n";
return $text; return $text;
} }
?> ?>

View File

@@ -1,4 +1,18 @@
<?php <?php
/*
* e107 website system
*
* Copyright (C) 2008-2009 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Event calendar - template file for list generator
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/ec_pf_template.php,v $
* $Revision: 1.2 $
* $Date: 2009-11-22 10:11:30 $
* $Author: e107steved $
*/
/* /*
Templates file for the event calendar listings (display/print/pdf). Templates file for the event calendar listings (display/print/pdf).
There can be more than one template defined, in which case they are selectable. There can be more than one template defined, in which case they are selectable.
@@ -20,7 +34,7 @@ There are two ways of managing the styling of the various shortcodes:
*/ */
if (!defined('e107_INIT')) { exit; } if (!defined('e107_INIT')) { exit; }
if (!defined("USER_WIDTH")){ define("USER_WIDTH","width:auto"); } if (!defined('USER_WIDTH')){ define('USER_WIDTH','width:auto'); }
$sc_style['EC_PR_CHANGE_YEAR']['pre'] = '<br /><em><strong>'; $sc_style['EC_PR_CHANGE_YEAR']['pre'] = '<br /><em><strong>';
$sc_style['EC_PR_CHANGE_YEAR']['post'] = '</strong></em>'; $sc_style['EC_PR_CHANGE_YEAR']['post'] = '</strong></em>';
@@ -41,7 +55,7 @@ $sc_style['EC_PR_LIST_TITLE']['post'] = "</h3>";
$EVENT_CAL_PDF_NAMES['default'] = EC_LAN_165; $EVENT_CAL_PDF_NAMES['default'] = EC_LAN_165;
$EVENT_CAL_PDF_HEADER['default'] = "{EC_PR_LIST_TITLE}<br />{EC_PR_CAT_LIST}<br />".EC_LAN_168."{EC_PR_LIST_START=%d-%m-%Y}<br />".EC_LAN_169."{EC_PR_LIST_END=%d-%m-%Y}<br />"; $EVENT_CAL_PDF_HEADER['default'] = "{EC_PR_LIST_TITLE}<br />{EC_PR_CAT_LIST}<br />".EC_LAN_168."{EC_PR_LIST_START=%d-%m-%Y}<br />".EC_LAN_169."{EC_PR_LIST_END=%d-%m-%Y}<br />";
$EVENT_CAL_PDF_BODY['default'] = "{EC_PR_CHANGE_YEAR}{EC_PR_CHANGE_MONTH}{EC_MAIL_SHORT_DATE} {EC_MAIL_TIME_START} {EC_MAIL_TITLE}<br />\n"; $EVENT_CAL_PDF_BODY['default'] = "{EC_PR_CHANGE_YEAR}{EC_PR_CHANGE_MONTH}{EC_MAIL_SHORT_DATE} {EC_MAIL_TIME_START} {EC_MAIL_TITLE}<br />\n";
$EVENT_CAL_PDF_FOOTER['default'] = "---End of List---<br />{EC_IFNOT_DISPLAY=EC_NOW_DATE}{EC_IFNOT_DISPLAY=EC_NOW_TIME}<br />{EC_PRINT_BUTTON}"; $EVENT_CAL_PDF_FOOTER['default'] = "---End of List---<br /><br />{EC_IFNOT_DISPLAY=EC_NOW_DATE}{EC_IFNOT_DISPLAY=EC_NOW_TIME}<br />{EC_PRINT_BUTTON}";
// - A simple tabular style // - A simple tabular style

View File

@@ -6,21 +6,16 @@
* Released under the terms and conditions of the * Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * 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 $ * $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/ecal_class.php,v $
* $Revision: 1.11 $ * $Revision: 1.12 $
* $Date: 2009-11-18 01:05:23 $ * $Date: 2009-11-22 10:11:30 $
* $Author: e107coders $ * $Author: e107steved $
*/ */
/*
|
| Event calendar class:
| Pre-calculates/caches many useful values
| Implements functions used in most of the code
|
*/
/* /*
Preferences used: Preferences used:
@@ -31,10 +26,10 @@ Preferences used:
if (!defined('e107_INIT')) { exit; } 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 // 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 // (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. // 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 $cat_text_cache = array(); // Used to cache category text as read
var $ec_first_day_of_week = 0; // First day of the week 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 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
var $recur_type = array('0' => 'no', '1' => 'annual', '2' => 'biannual', '3' =>'quarterly', '4' => 'monthly', '5' => 'four weekly', public $recur_type = array(
'6' => 'fortnightly', '7' => 'weekly', '8' => 'daily', '0' => EC_LAN_RECUR_00, // 'no'
'100' => 'Sunday in month', '1' => EC_LAN_RECUR_01, //'annual'
'101' => 'Monday in month', '2' => EC_LAN_RECUR_02, //'biannual'
'102' => 'Tuesday in month', '3' => EC_LAN_RECUR_03, //'quarterly'
'103' => 'Wednesday in month', '4' => EC_LAN_RECUR_04, //'monthly'
'104' => 'Thursday in month', '5' => EC_LAN_RECUR_05, //'four weekly'
'105' => 'Friday in month', '6' => EC_LAN_RECUR_06, //'fortnightly'
'106' => 'Saturday in month' '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 { // Constructor
global $pref; global $pref;
if (!isset($pref['plug_installed']['calendar_menu']))
{
header('location:'.e_BASE.'index.php');
exit;
}
// Get all the times in terms of 'clock time' - i.e. allowing for TZ, DST, etc // 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. // 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 { // 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 { // 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 { // 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) { // 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) { // Turns a date as entered in the calendar into a time stamp (for event entry)
$tmp = explode($this->date_separator, $date_string); $tmp = explode($this->date_separator, $date_string);
switch ($this->java_format_code) switch ($this->java_format_code)
{ {
case 2 : case 2 :
return gmmktime($new_hour, $new_minute, 0, $tmp[1], $tmp[0], $tmp[2]); // dd-mm-yyyy return gmmktime($new_hour, $new_minute, 0, $tmp[1], $tmp[0], $tmp[2]); // dd-mm-yyyy
case 3 : case 3 :
return gmmktime($new_hour, $new_minute, 0, $tmp[0], $tmp[1], $tmp[2]); // mm-dd-yyyy return gmmktime($new_hour, $new_minute, 0, $tmp[0], $tmp[1], $tmp[2]); // mm-dd-yyyy
default : default :
return gmmktime($new_hour, $new_minute, 0, $tmp[1], $tmp[2], $tmp[0]); // yyyy-mm-dd 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 // 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 { // All calendar-related logging intentionally passed through a single point to maintain control
// (so we could also add other info if we wanted) // (so we could also add other info if we wanted)
// Event types: // Event types:
@@ -275,32 +282,40 @@ if (!defined("EC_DEFAULT_CATEGORY")) { define('EC_DEFAULT_CATEGORY',"Default");
// 3 - delete event // 3 - delete event
// 4 - Bulk delete // 4 - Bulk delete
// 5 - add multiple events // 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', $log_titles = array( '1' => 'EC_ADM_01',
'2' => 'EC_ADM_02', '2' => 'EC_ADM_02',
'3' => 'EC_ADM_03', '3' => 'EC_ADM_03',
'4' => 'EC_ADM_04', '4' => 'EC_ADM_04',
'5' => 'EC_ADM_05', '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]."<br />"; $cmessage = $log_titles[$event_type]."<br />";
if ($event_start > 0) if ($event_start > 0)
{ {
$cmessage .= "Event Start: ".strftime("%d-%B-%Y",$event_start)."<br />"; $cmessage .= 'Event Start: '.strftime("%d-%B-%Y",$event_start)."<br />";
$cmessage .= "Event Link: ".$pref['siteurl'].$PLUGINS_DIRECTORY. "calendar_menu/event.php?".$event_start." <br />"; $cmessage .= 'Event Link: '.SITEURL.e_PLUGIN_ABS. 'calendar_menu/event.php?'.$event_start." <br />";
} }
else else
$cmessage .= "Event Start unknown<br />"; $cmessage .= "Event Start unknown<br />";
$edata_ec = array("cmessage" => $cmessage, "ip" => $e107->getip()); $edata_ec = array('cmessage' => $cmessage, 'ip' => $e107->getip());
switch ($event_type) switch ($event_type)
{ {
case 5 : case 5 :
case 1 : $e_event -> trigger("ecalnew", $edata_ec); case 1 : $e107->e_event -> trigger('ecalnew', $edata_ec);
break; break;
case 2 : case 2 :
case 3 : case 3 :
case 4 : $e_event -> trigger("ecaledit", $edata_ec); case 4 : $e107->e_event -> trigger('ecaledit', $edata_ec);
break; break;
} }
@@ -316,21 +331,21 @@ if (!defined("EC_DEFAULT_CATEGORY")) { define('EC_DEFAULT_CATEGORY',"Default");
'4' => 'Event Calendar - Bulk Delete', '4' => 'Event Calendar - Bulk Delete',
'5' => 'Event Calendar - multiple add '.strftime("%d-%B-%Y",$event_start) '5' => 'Event Calendar - multiple add '.strftime("%d-%B-%Y",$event_start)
); );
$admin_log->log_event($log_titles[$event_type],$event_title."&nbsp;\n".$log_detail[$event_type]."\n".$event_string,''); $e107->admin_log->log_event($log_titles[$event_type],$event_title."&nbsp;\n".$log_detail[$event_type]."\n".$event_string,'');
} }
function get_category_text($ev_cat) function get_category_text($ev_cat)
{ {
global $sql; global $sql;
if (!isset($this->cat_text_cache[$ev_cat])) if (!isset($this->cat_text_cache[$ev_cat]))
{ {
$sql->db_Select('event_cat','event_cat_name',"event_cat_id='{$ev_cat}'"); $sql->db_Select('event_cat','event_cat_name',"event_cat_id='{$ev_cat}'");
$row = $sql->db_Fetch(); $row = $sql->db_Fetch();
$this->cat_text_cache[$ev_cat] = $row['event_cat_name']; $this->cat_text_cache[$ev_cat] = $row['event_cat_name'];
} }
return $this->cat_text_cache[$ev_cat]; 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 // time() -date('Z') gives the correction to 'null out' the TZ and DST adjustments that getdate() does
function gmgetdate($date) function gmgetdate($date)
{ {
return getdate($date-date('Z')); return getdate($date-date('Z'));
} }
//------------------------------------------------ //------------------------------------------------
// Recurring event handling // 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 * Internal utility - Generate a list of time/date based on a 'first event' date, an interval and start/finish times
function gen_recur_regular($first_event, $last_event, $interval, $start_time, $end_time) * 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; if ($last_event < $end_time) $end_time = $last_event;
$ret = array(); $ret = array();
$first_event = $first_event + ceil(($start_time-$first_event)/$interval)*$interval; $first_event = $first_event + ceil(($start_time-$first_event)/$interval)*$interval;
while ($first_event <= $end_time) while ($first_event <= $end_time)
{ {
$ret[] = $first_event; $ret[] = $first_event;
$first_event += $interval; $first_event += $interval;
} }
return $ret; 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']) if ($adder['mon'])
{ {
$main_date['mon'] += $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' * Generate a list of recurring events based on a 'first event' date, an interval type and start/finish window
function gen_recur($first_event, $last_event, $interval_type, $start_time, $end_time) * @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; if ($last_event < $end_time) $end_time = $last_event;
$ret = array(); $ret = array();
@@ -498,9 +537,21 @@ if (!defined("EC_DEFAULT_CATEGORY")) { define('EC_DEFAULT_CATEGORY',"Default");
return $ret; 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='*') function get_events($start_time, $end_time, $start_only=FALSE, $cat_filter=0, $inc_recur=FALSE, $event_fields='*', $cat_fields='*')
{ {
global $sql; 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 * Function to return up to a maximum number of events between a given start and end date
// It tries to keep the actual number of events in memory to a minimum by discarding when it can. * It always uses the event start date only
// Once there are $num_events read, it pulls in the $end_time to speed up checks * It tries to keep the actual number of events in memory to a minimum by discarding when it can.
// $cat_filter = FALSE is 'no categories' - returns an empty array. * Once there are $num_events read, it pulls in the $end_time to speed up checks
// $cat_filter = '*' means 'all categories' * @param int $num_event - number of events required
// otherwise $cat_filter mst be a comma-separated list of category IDs. * @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='*') function get_n_events($num_event, $start_time, $end_time, $cat_filter='*', $inc_recur=FALSE, $event_fields='*', $cat_fields='*')
{ {
global $sql; global $sql;
@@ -663,18 +724,24 @@ if (!defined("EC_DEFAULT_CATEGORY")) { define('EC_DEFAULT_CATEGORY',"Default");
} // End - function get_n_events() } // 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) if ($recurring >= 100)
{ {
return $this->recur_week[100*intval($recurring/100)]." ".$this->recur_type[100+($recurring % 10)]; return $this->recur_week[100*intval($recurring/100)]." ".$this->recur_type[100+($recurring % 10)];
} }
else else
{ {
return $this->recur_type[$recurring]; return $this->recur_type[$recurring];
} }
} }
}// End - class definition }// End - class definition
?> ?>

View File

@@ -6,48 +6,54 @@
* Released under the terms and conditions of the * Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * 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 $ * $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/event.php,v $
* $Revision: 1.14 $ * $Revision: 1.15 $
* $Date: 2009-11-18 01:05:23 $ * $Date: 2009-11-22 10:11:30 $
* $Author: e107coders $ * $Author: e107steved $
*/ */
require_once('../../class2.php'); 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'])) if (isset($_POST['viewallevents']))
{ // Triggered from NAV_BUT_ALLEVENTS { // 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'])) if (isset($_POST['doit']))
{ // Triggered from NAV_BUT_ENTEREVENT { // Triggered from NAV_BUT_ENTEREVENT
Header("Location: ".e_PLUGIN."calendar_menu/event.php?ne.".$_POST['enter_new_val']); Header('Location: '.e_PLUGIN.'calendar_menu/event.php?ne.'.$_POST['enter_new_val']);
exit; exit();
} }
if (isset($_POST['subs'])) 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'])) 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"); include_lan(e_PLUGIN.'calendar_menu/languages/'.e_LANGUAGE.'.php');
define("PAGE_NAME", EC_LAN_80); define('PAGE_NAME', EC_LAN_80);
require_once(e_PLUGIN.'calendar_menu/ecal_class.php'); require_once(e_PLUGIN.'calendar_menu/ecal_class.php');
global $ecal_class; global $ecal_class;
if (!is_object($ecal_class)) $ecal_class = new ecal_class; if (!is_object($ecal_class)) $ecal_class = new ecal_class;
$cal_super = $ecal_class->cal_super; $cal_super = $ecal_class->cal_super;
require_once(e_PLUGIN."calendar_menu/calendar_shortcodes.php"); e107::getScParser();
require_once(e_HANDLER."calendar/calendar_class.php"); require_once(e_PLUGIN.'calendar_menu/calendar_shortcodes.php');
require_once(e_HANDLER.'calendar/calendar_class.php');
$cal = new DHTML_Calendar(true); $cal = new DHTML_Calendar(true);
$cat_filter = intval(varset($_POST['event_cat_ids'],-1)); $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']))) 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']); $ev_start = $ecal_class->make_date($_POST['ne_hour'], $_POST['ne_minute'],$_POST['start_date']);
if (($_POST['ne_event'] == "") || !isset($_POST['qs'])) if (($_POST['ne_event'] == '') || !isset($_POST['qs']))
{ // Problem - tell user to go away - fields are blank (mostly checked by JS) { // Problem - tell user to go away - fields are blank (mostly checked by JS)
header("location:event.php?".$ev_start.".0.m3"); header('location:event.php?'.$ev_start.'.0.m3');
} }
elseif (!isset($_POST['ne_category']) || (intval($_POST['ne_category']) == 0)) 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)
{ {
$rec_m = $temp_date['mday']; // Day of month header('location:event.php?'.$ev_start.'.0.m6');
$rec_y = $temp_date['mon']; // Month number }
}
else else
{ {
$rec_m = ""; $ev_end = $ecal_class->make_date($_POST['end_hour'], $_POST['end_minute'],$_POST['end_date']);
$rec_y = ""; $ev_title = $e107->tp->toDB($_POST['ne_title']);
} $ev_location = $e107->tp->toDB($_POST['ne_location']);
$ev_event = $e107->tp->toDB($_POST['ne_event']);
$report_msg = '.m3'; $ev_email = $e107->tp -> toDB($_POST['ne_email']);
if (isset($_POST['ne_insert'])) $ev_category = intval($_POST['ne_category']);
{ // Bits specific to inserting a new event $ev_thread = $e107->tp->toDB($_POST['ne_thread']);
$qs = preg_replace("/ne./i", "", $_POST['qs']); $temp_date = getdate($ecal_class->make_date(0,0,$_POST['start_date']));
if ($_POST['ec_gen_multiple']) $ev_allday = intval($_POST['allday']);
{ $recurring = intval($_POST['ec_recur_type']);
$mult_count = $ecal_class->gen_recur($ev_start,$ev_end,$recurring,$ev_start,$ev_end); if ($recurring >= 100) $recurring += intval($_POST['ec_recur_week']) - 100;
} //
if ($mult_count <= 1) if ($_POST['recurring'] == 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)."' "; $rec_m = $temp_date['mday']; // Day of month
$sql->db_Insert("event", $qry); $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(); $id = mysql_insert_id();
$data = array('method'=>'create', 'table'=>'event', 'id'=>$id, 'plugin'=>'calendar_menu', 'function'=>'dbCalendarCreate'); $data = array('method'=>'create', 'table'=>'event', 'id'=>$id, 'plugin'=>'calendar_menu', 'function'=>'dbCalendarCreate');
$e_event->triggerHook($data); $e_event->triggerHook($data);
$ecal_class->cal_log(1,'db_Insert',$qry, $ev_start); $ecal_class->cal_log(1,'db_Insert',$qry, $ev_start);
$report_msg = '.m4'; $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); require_once(HEADERF);
@@ -209,35 +215,44 @@ if ($mult_count > 1)
exit; exit;
} }
// Calculate any action, plus start date/number of events, from query
unset($dateArray);
if (isset($_POST['jump'])) if (isset($_POST['jump']))
{ {
$smarray = getdate(mktime(0, 0, 0, $_POST['jumpmonth'], 1, $_POST['jumpyear'])); $dateArray = getdate(mktime(0, 0, 0, $_POST['jumpmonth'], 1, $_POST['jumpyear']));
$month = $smarray['mon'];
$year = $smarray['year'];
} }
else else
{ {
if (e_QUERY) if (e_QUERY)
{ {
$qs = explode(".", e_QUERY); $qs = explode('.', e_QUERY);
$action = $qs[0]; // Often a date if just viewing $action = trim($qs[0]); // Often a date if just viewing
$ds = varset($qs[1],""); $ds = varset($qs[1],'');
$eveid = varset($qs[2], ""); $eveid = intval(varset($qs[2], 0));
} }
if ($action == "") if ($action == '')
{ {
$month = $ecal_class->cal_date['mon']; $dateArray = $ecal_class->cal_date; // Use todays date
$year = $ecal_class->cal_date['year'];
} }
else else
{ {
if (is_numeric($action)) $smarray = getdate($action); else $smarray = getdate($ds); if (is_numeric($action))
$month = $smarray['mon']; {
$year = $smarray['year']; $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'])) if ($cal_super || check_class($pref['eventpost_admin']))
{ // Bits relating to 'delete event', and generation of multiple events { // 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(); $wr_record = array();
foreach ($ev_fields as $k => $v) 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_author'] = USERID.".".USERNAME;
$wr_record['event_datestamp'] = time(); $wr_record['event_datestamp'] = time();
@@ -323,22 +338,18 @@ if ($cal_super || check_class($pref['eventpost_admin']))
} // End - if ($cal_super) } // 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 // 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, $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'); 'm6' => EC_LAN_145, 'm7' => 'Could have saved -NUM- events');
if (isset($qs[2])) if (isset($poss_message[$qs[2]])) if (isset($qs[2])) if (isset($poss_message[$qs[2]]))
{ {
$message = $poss_message[$qs[2]]; $message = $poss_message[$qs[2]];
$ec = varset($qs[3],0); $ec = varset($qs[3],0);
if ($ec) $message = str_replace('-NUM-',$ec,$message); if ($ec) $message = str_replace('-NUM-',$ec,$message);
} }
if (isset($message)) if (isset($message))
{ {
$ns->tablerender("", "<div style='text-align:center'><b>".$message."</b></div>"); $ns->tablerender("", "<div style='text-align:center'><b>".$message."</b></div>");
@@ -347,92 +358,104 @@ if (isset($message))
function merge_date_time($date, $time) function merge_date_time($date, $time)
{ {
return ((86400*intval($date/86400)) + ($time % 86400)); return ((86400*intval($date/86400)) + ($time % 86400));
} }
//------------------------------------- //-------------------------------------
// enter new event form // enter new event form
//------------------------------------- //-------------------------------------
if ($action == "ne" || $action == "ed") if ($action == 'ne' || $action == 'ed')
{ {
if ($ecal_class->cal_super || check_class($pref['eventpost_admin'])) if ($ecal_class->cal_super || check_class($pref['eventpost_admin']))
{
function make_calendar($boxname, $boxvalue)
{ {
global $ecal_class, $cal; function make_calendar($boxname, $boxvalue)
{
unset($cal_options); global $ecal_class, $cal;
unset($cal_attrib);
$cal_options['firstDay'] = $ecal_class->ec_first_day_of_week; unset($cal_options);
$cal_options['showsTime'] = false; unset($cal_attrib);
$cal_options['showOthers'] = true; $cal_options['firstDay'] = $ecal_class->ec_first_day_of_week;
$cal_options['weekNumbers'] = false; $cal_options['showsTime'] = false;
$cal_options['ifFormat'] = $ecal_class->dcal_format_string; $cal_options['showOthers'] = true;
$cal_attrib['class'] = "tbox"; $cal_options['weekNumbers'] = false;
$cal_attrib['size'] = "12"; $cal_options['ifFormat'] = $ecal_class->dcal_format_string;
$cal_attrib['name'] = $boxname; $cal_attrib['class'] = "tbox";
$cal_attrib['value'] = $boxvalue; $cal_attrib['size'] = "12";
return $cal->make_input_field($cal_options, $cal_attrib); $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) function make_hourmin($boxname,$cur_hour,$cur_minute)
{ {
global $pref; global $pref;
if (isset($pref['eventpost_fivemins'])) $incval = 5; else $incval = 1; if (isset($pref['eventpost_fivemins'])) $incval = 5; else $incval = 1;
$retval = " <select name='{$boxname}hour' id='{$boxname}hour' class='tbox'>\n"; $retval = " <select name='{$boxname}hour' id='{$boxname}hour' class='tbox'>\n";
for($count = "00"; $count <= "23"; $count++) for($count = "00"; $count <= "23"; $count++)
{ {
$val = sprintf("%02d", $count); $val = sprintf("%02d", $count);
$retval .= "<option value='{$val}' ".(isset($cur_hour) && $count == $cur_hour ? "selected='selected'" :"")." >".$val."</option>\n"; $retval .= "<option value='{$val}' ".(isset($cur_hour) && $count == $cur_hour ? "selected='selected'" :"")." >".$val."</option>\n";
} }
$retval .= "</select>\n $retval .= "</select>\n
<select name='{$boxname}minute' class='tbox'>\n"; <select name='{$boxname}minute' class='tbox'>\n";
for($count = "00"; $count <= "59"; $count+= $incval) for($count = "00"; $count <= "59"; $count+= $incval)
{ {
$val = sprintf("%02d", $count); $val = sprintf("%02d", $count);
$retval .= "<option ".(isset($cur_minute) && $count == $cur_minute ? "selected='selected'" :"")." value='{$val}'>".$val."</option>\n"; $retval .= "<option ".(isset($cur_minute) && $count == $cur_minute ? "selected='selected'" :"")." value='{$val}'>".$val."</option>\n";
} }
$retval .= "</select>\n"; $retval .= "</select>\n";
return $retval; return $retval;
} }
function recur_select($curval) function recur_select($curval)
{ {
global $ecal_class; global $ecal_class;
while ($curval > 150) { $curval -= 100; } // Could have values up to about 406 while ($curval > 150) { $curval -= 100; } // Could have values up to about 406
$ret = "<select class='tbox' name='ec_recur_type' onchange=\"proc_recur(this.value);\">"; $ret = "<select class='tbox' name='ec_recur_type' onchange=\"proc_recur(this.value);\">";
foreach ($ecal_class->recur_type as $k => $v) foreach ($ecal_class->recur_type as $k => $v)
{ {
$selected = ($curval == $k) ? " selected = 'selected'" : ""; $selected = ($curval == $k) ? " selected = 'selected'" : "";
$ret .= "<option value='{$k}'{$selected}>{$v}</option>\n"; $ret .= "<option value='{$k}'{$selected}>{$v}</option>\n";
} }
$ret .= "</select>\n"; $ret .= "</select>\n";
return $ret; return $ret;
} }
function recur_week_select($curval) function recur_week_select($curval)
{ {
global $ecal_class; global $ecal_class;
$disp = $curval < 100 ? " style='display:none;'" : ""; $disp = $curval < 100 ? " style='display:none;'" : "";
$curval -= intval($curval % 10); // Should make it an exact multiple of 100 $curval -= intval($curval % 10); // Should make it an exact multiple of 100
$ret = "<span id='rec_week_sel'{$disp}><select class='tbox' name='ec_recur_week'>"; $ret = "<span id='rec_week_sel'{$disp}><select class='tbox' name='ec_recur_week'>";
foreach ($ecal_class->recur_week as $k => $v) foreach ($ecal_class->recur_week as $k => $v)
{ {
$selected = ($curval == $k) ? " selected = 'selected'" : ""; $selected = ($curval == $k) ? " selected = 'selected'" : "";
$ret .= "<option value='{$k}'{$selected}>{$v}</option>\n"; $ret .= "<option value='{$k}'{$selected}>{$v}</option>\n";
} }
$ret .= "</select></span>\n"; $ret .= "</select></span>\n";
return $ret; return $ret;
} }
switch ($action) switch ($action)
{ {
case "ed" : // Editing existing event - read from database case 'ed' : // Editing existing event - read from database
$sql->db_Select("event", "*", "event_id='".intval($qs[1])."' "); $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(); $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); $smarray = $ecal_class->gmgetdate($ne_start);
$ne_hour = $smarray['hours']; $ne_hour = $smarray['hours'];
@@ -447,7 +470,7 @@ if ($action == "ne" || $action == "ed")
$caption = EC_LAN_66; // edit Event $caption = EC_LAN_66; // edit Event
break; break;
case "ne" : // New event - initialise everything case 'ne' : // New event - initialise everything
$smarray = $ecal_class->gmgetdate($qs[1]); $smarray = $ecal_class->gmgetdate($qs[1]);
$month = $smarray['mon']; $month = $smarray['mon'];
$year = $smarray['year']; $year = $smarray['year'];
@@ -717,46 +740,6 @@ if ($action == "ne" || $action == "ed")
// show events // show events
// $month, $year have the month required // $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')) if (is_readable(THEME.'calendar_template.php'))
{ // Has to be require { // Has to be require
require(THEME.'calendar_template.php'); require(THEME.'calendar_template.php');
@@ -766,12 +749,24 @@ else
require(e_PLUGIN.'calendar_menu/calendar_template.php'); 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 = ""; $text2 = "";
// time switch buttons // time switch buttons
$text2 .= $tp -> parseTemplate($CALENDAR_TIME_TABLE, FALSE, $calendar_shortcodes); $text2 .= $e107->tp->parseTemplate($CALENDAR_TIME_TABLE, TRUE);
// navigation buttons // 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! // ****** 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(); $ev_list = array();
if ($ds == "event") if ($ds == 'event')
{ // Show single event - bit of a special case { // Show single event - bit of a special case
$ec_err = FALSE; $ec_err = FALSE;
$qry = " $qry = "
@@ -790,85 +785,84 @@ if ($ds == "event")
{$ecal_class->extra_query} {$ecal_class->extra_query}
"; ";
$sql2->db_Select_gen($qry); $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 // 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! $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) if (count($temp_arr) == 1)
{ {
$thisevent['event_start'] = $temp_arr[0]; $thisEvent['event_start'] = $temp_arr[0];
$thisevent['event_end'] = merge_date_time($action,$thisevent['event_end']); $thisEvent['event_end'] = merge_date_time($action,$thisEvent['event_end']);
} }
else else
{ // Error { // Error
$ec_err = TRUE; $ec_err = TRUE;
} }
} }
$next10_start = $thisevent['event_start'] +1; $next10_start = $thisEvent['event_start'] +1;
$text2 .= $tp -> parseTemplate($EVENT_EVENT_TABLE_START, FALSE, $calendar_shortcodes); setScVar('event_calendar_shortcodes', 'event', $thisEvent); // Give shortcodes the event data
if ($ec_err) $text2.= "Software Error<br />"; else $text2 .= $tp -> parseTemplate($EVENT_EVENT_TABLE, TRUE, $calendar_shortcodes); $text2 .= $e107->tp->parseTemplate($EVENT_EVENT_TABLE_START, TRUE);
$text2 .= $tp -> parseTemplate($EVENT_EVENT_TABLE_END, FALSE, $calendar_shortcodes); if ($ec_err) $text2.= "Software Error<br />"; else $text2 .= $e107->tp->parseTemplate($EVENT_EVENT_TABLE, TRUE);
$text2 .= $e107->tp->parseTemplate($EVENT_EVENT_TABLE_END, TRUE);
} }
else else
{ {
if ($ds == 'one') if ($ds == 'one')
{ // Show events from one day { // Show events from one day
$tmp = getdate($action); // $tmp = getdate($action);
$selected_day = $tmp['mday']; // $selected_day = $tmp['mday'];
$selected_mon = $tmp['mon']; // $selected_mon = $tmp['mon'];
$start_time = $action; $start_time = intval($action);
$end_time = $action + 86399; $end_time = $action + 86399;
$next10_start = $end_time + 1; $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."<br />";
// 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<br />";
// 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;
}
} }
else else
{ { // Display whole of selected month
$tim_arr[$event['event_start']] = $k; $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 // echo "Start: ".$start_time." End: ".$end_time." Cat_filter: ".$cat_filter."<br />";
if(count($tim_arr)) // 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');
$text2 .= $tp -> parseTemplate($EVENT_EVENTLIST_TABLE_START, FALSE, $calendar_shortcodes);
foreach ($tim_arr as $tim => $ptr)
// Now go through and multiply up any recurring records
$tim_arr = array();
foreach ($ev_list as $k=>$event)
{ {
$ev_list[$ptr]['event_start'] = $tim; if (is_array($event['event_start']))
// $text2 .= show_event($ev_list[$ptr]); {
$thisevent = $ev_list[$ptr]; foreach ($event['event_start'] as $t)
$text2 .= $tp -> parseTemplate($EVENT_EVENT_TABLE, TRUE, $calendar_shortcodes); {
$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); $num = count($ev_list);
if ($num != 0) if ($num != 0)
{ {
$archive_events = ""; setScVar('event_calendar_shortcodes', 'numEvents', $num); // Give shortcodes the number of events to expect
foreach ($ev_list as $thisevent) $archive_events = '';
{ foreach ($ev_list as $thisEvent)
// echo "Event start: ".$thisevent['event_start']."<br />"; {
$archive_events .= $tp -> parseTemplate($EVENT_ARCHIVE_TABLE, FALSE, $calendar_shortcodes); setScVar('event_calendar_shortcodes', 'event', $thisEvent); // Give shortcodes the event data
} $archive_events .= $e107->tp->parseTemplate($EVENT_ARCHIVE_TABLE, TRUE);
}
} }
else 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 .= $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"; $e107->ns->tablerender($e107->tp->ParseTemplate('{EC_EVENT_PAGE_TITLE}'), $text2);
$ns->tablerender($caption.(isset($cap_title) ? $cap_title : ""), $text2);
// Claim back memory no longer required // Claim back memory no longer required
unset($ev_list); unset($ev_list);

View File

@@ -9,14 +9,14 @@
* These messages are for the 'user' pages of the event calendar (including event entry/editing) * 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 $ * $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/languages/English.php,v $
* $Revision: 1.9 $ * $Revision: 1.10 $
* $Date: 2009-11-18 02:03:35 $ * $Date: 2009-11-22 10:11:32 $
* $Author: marj_nl_fr $ * $Author: e107steved $
*/ */
define('EC_ADLAN_1', "Event Calendar"); define('EC_ADLAN_1', 'Event Calendar');
define('EC_ADLAN_2', "Configure Event Calendar"); define('EC_ADLAN_2', 'Configure Event Calendar');
define('EC_LAN_TODAY', "today"); define('EC_LAN_TODAY', 'today');
define('EC_LAN_DAY_1', "1"); define('EC_LAN_DAY_1', "1");
define('EC_LAN_DAY_2', "2"); define('EC_LAN_DAY_2', "2");
@@ -184,7 +184,7 @@ define('EC_LAN_116', "Monday");
//define('EC_LAN_119', "month/year"); //define('EC_LAN_119', "month/year");
//define('EC_LAN_120', "year/month"); //define('EC_LAN_120', "year/month");
define('EC_LAN_121', "Show Calendar"); define('EC_LAN_121', "Show Calendar");
define('EC_LAN_122', 'Event information (single event)');
define('EC_LAN_123', "Subscriptions"); define('EC_LAN_123', "Subscriptions");
define('EC_LAN_124', "Calendar Subscriptions"); define('EC_LAN_124', "Calendar Subscriptions");
define('EC_LAN_125', "Categories available for subscription"); 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_172', "Event Categories: ");
define('EC_LAN_173', "First event starts: "); define('EC_LAN_173', "First event starts: ");
define('EC_LAN_174', "Last event ends: "); 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_176', "Recurring pattern: ");
define('EC_LAN_177', "Cancel Entry"); define('EC_LAN_177', "Cancel Entry");
define('EC_LAN_178', "Accept Entries"); define('EC_LAN_178', "Accept Entries");
define('EC_LAN_179', "Confirmation of multiple event entry"); 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_VIEWCALENDAR', 'View Calendar');
define('EC_LAN_VIEWALLEVENTS', "View all events"); define('EC_LAN_VIEWALLEVENTS', 'View all events');
define('EC_LAN_ALLEVENTS', "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 // Notify
define("NT_LAN_EC_1", "Event Calendar Events"); define('NT_LAN_EC_1', 'Event Calendar Events');
define("NT_LAN_EC_2", "Event Updated"); define('NT_LAN_EC_2', 'Event Updated');
define("NT_LAN_EC_3", "Update by"); define('NT_LAN_EC_3', 'Update by');
define("NT_LAN_EC_4", "IP Address"); define('NT_LAN_EC_4', 'IP Address');
define("NT_LAN_EC_5", "Message"); define('NT_LAN_EC_5', 'Message');
define("NT_LAN_EC_6", "Event Calendar - Event added"); define('NT_LAN_EC_6', 'Event Calendar - Event added');
define("NT_LAN_EC_7", "New event posted"); define('NT_LAN_EC_7', 'New event posted');
define("NT_LAN_EC_8", "Event Calendar - Event modified"); 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 // 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 define('EC_MAILOUT_SUBJECT', "Advice of calendar event"); // Use shortcode EC_MAIL_SUBJECT
?>

View File

@@ -9,9 +9,9 @@
* Messages for admin pages of event calendar * Messages for admin pages of event calendar
* *
* $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/languages/English_admin_calendar_menu.php,v $ * $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/languages/English_admin_calendar_menu.php,v $
* $Revision: 1.2 $ * $Revision: 1.3 $
* $Date: 2009-11-18 02:03:35 $ * $Date: 2009-11-22 10:11:32 $
* $Author: marj_nl_fr $ * $Author: e107steved $
*/ */
define('EC_ADLAN_1', "Event Calendar"); 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_6", "Event Calendar - Event added");
define("NT_LAN_EC_7", "New event posted"); define("NT_LAN_EC_7", "New event posted");
define("NT_LAN_EC_8", "Event Calendar - Event modified"); define("NT_LAN_EC_8", "Event Calendar - Event modified");
*/ */

View File

@@ -6,12 +6,12 @@
* Released under the terms and conditions of the * Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * 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 $ * $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/languages/English_mailer.php,v $
* $Revision: 1.3 $ * $Revision: 1.4 $
* $Date: 2009-11-18 01:05:23 $ * $Date: 2009-11-22 10:11:32 $
* $Author: e107coders $ * $Author: e107steved $
* *
*/ */
@@ -21,10 +21,24 @@ define('LAN_EC_MAIL_03', 'Category: ');
define('LAN_EC_MAIL_04', 'Calendar Subscriptions'); define('LAN_EC_MAIL_04', 'Calendar Subscriptions');
define('LAN_EC_MAIL_05', 'Process notifications of events on the calendar'); 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_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_08', '');
define('LAN_EC_MAIL_09', ''); define('LAN_EC_MAIL_09', '');
define('LAN_EC_MAIL_10', ''); 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', '');
?> ?>

View File

@@ -6,43 +6,38 @@
* Released under the terms and conditions of the * Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * 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 $ * $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/next_event_menu.php,v $
* $Revision: 1.7 $ * $Revision: 1.8 $
* $Date: 2009-11-18 01:05:23 $ * $Date: 2009-11-22 10:11:30 $
* $Author: e107coders $ * $Author: e107steved $
*/ */
if (!defined('e107_INIT')) { exit; } if (!defined('e107_INIT')) { exit; }
$e107 = e107::getInstance();
global $ecal_dir, $tp; if (!$e107->isInstalled('calendar_menu')) return '';
$ecal_dir = e_PLUGIN.'calendar_menu/';
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 // 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)) if($cacheData = $e107->ecache->retrieve($cache_tag, $ecal_class->max_cache_time))
{ {
echo $cacheData; echo $cacheData;
return; 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'); include_lan(e_PLUGIN.'calendar_menu/languages/'.e_LANGUAGE.'.php');
// Values defined through admin pages e107::getScParser();
$menu_title = varset($pref['eventpost_menuheading'],EC_LAN_140); require_once(e_PLUGIN.'calendar_menu/calendar_shortcodes.php');
$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');
if (is_readable(THEME.'calendar_template.php')) if (is_readable(THEME.'calendar_template.php'))
{ // Has to be require { // Has to be require
require(THEME.'calendar_template.php'); require(THEME.'calendar_template.php');
@@ -52,15 +47,25 @@ else
require(e_PLUGIN.'calendar_menu/calendar_template.php'); 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; $start_time = $ecal_class->cal_timedate;
$end_time = $start_time + (86400 * $days_ahead) - 1; $end_time = $start_time + (86400 * $days_ahead) - 1;
$cal_totev = 0;
$cal_text = ''; $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, $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'); '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); $cal_totev = count($ev_list);
if ($cal_totev > 0) if ($cal_totev > 0)
{ {
foreach ($ev_list as $cal_row) foreach ($ev_list as $thisEvent)
{ {
$cal_totev --; // Can use this to modify inter-event gap $cal_totev --; // Can use this to modify inter-event gap
$cal_text .= $tp->parseTemplate($EVENT_CAL_FE_LINE,TRUE,$calendar_shortcodes); 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 else
{ {
if ($pref['eventpost_fe_hideifnone']) return ''; if ($pref['eventpost_fe_hideifnone']) return '';
$cal_text.= EC_LAN_141; $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) if ($link_in_heading == 1)
{ {
$calendar_title = "<a class='forumlink' href='".e_PLUGIN_ABS."calendar_menu/event.php' >".$calendar_title."</a>"; $calendar_title = "<a class='forumlink' href='".e_PLUGIN_ABS."calendar_menu/event.php' >".$calendar_title."</a>";
@@ -88,7 +95,7 @@ if ($link_in_heading == 1)
// Now handle the data, cache as well // Now handle the data, cache as well
ob_start(); // Set up a new output buffer 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 $cache_data = ob_get_flush(); // Get the page content, and display it
$e107->ecache->set($cache_tag, $cache_data); // Save to cache $e107->ecache->set($cache_tag, $cache_data); // Save to cache

View File

@@ -1,325 +0,0 @@
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2009 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/subs_menu.php,v $
* $Revision: 1.9 $
* $Date: 2009-11-18 01:05:23 $
* $Author: e107coders $
*/
if (!defined('e107_INIT')) { exit; }
// This menu is best called from a cron job - see readme.pdf
global $ec_default_msg_1, $ec_default_msg_2, $ec_log_requirement, $ec_debug_level, $ec_run_from_menu, $tp;
global $ecal_class;
if (!is_object($ecal_class))
{
require_once('ecal_class.php');
$ecal_class = new ecal_class;
}
// Work out whether we're being called as a menu (i.e. within a displayed page) or not
$ec_run_from_menu = (defined('USER_AREA') && USER_AREA) || (defined('ADMIN_AREA') && ADMIN_AREA);
//echo ($ec_run_from_menu == TRUE ? "Run from menu" : "Standalone")."<br />";
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}<br />";
}
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."<br />";
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!<br />";
$ec_log_requirement = 0;
return;
}
}
if (fwrite($handle,$log_text) == FALSE)
{
$ec_log_requirement = 0;
echo "File write failed!<br />";
}
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);
}
}
}
?>

View File

@@ -6,97 +6,99 @@
* Released under the terms and conditions of the * Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * 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 $ * $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/subscribe.php,v $
* $Revision: 1.6 $ * $Revision: 1.7 $
* $Date: 2009-11-18 01:05:23 $ * $Date: 2009-11-22 10:11:31 $
* $Author: e107coders $ * $Author: e107steved $
*/ */
require_once("../../class2.php"); require_once('../../class2.php');
if (!isset($pref['plug_installed']['calendar_menu'])) header("Location: ".e_BASE."index.php"); $e107 = e107::getInstance();
include_lan(e_PLUGIN . "calendar_menu/languages/".e_LANGUAGE.".php");
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); require_once(HEADERF);
if ((USER) && (isset($pref['eventpost_asubs']) && ($pref['eventpost_asubs'] == '1'))) 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'])) if (isset($_POST['upsubs']))
{ {
$cal_cats = $tp -> toDB($_POST['event_list']); // IDs of allowed categories $cal_cats = $e107->tp->toDB($_POST['event_list']); // IDs of allowed categories
$cal_subs = $tp -> toDB($_POST['event_subd']); // Checkbox results $cal_subs = $e107->tp->toDB($_POST['event_subd']); // Checkbox results
$cal_db->db_Delete("event_subs", "event_userid='" . USERID . "'"); // Delete all for this user to start $cal_db->db_Delete('event_subs', "event_userid='" . USERID . "'"); // Delete all for this user to start
foreach($cal_cats as $cal_row) foreach($cal_cats as $cal_row)
{ // Now add in a subscription for each allowed category { // Now add in a subscription for each allowed category
if ($cal_subs[$cal_row]) if ($cal_subs[$cal_row])
{ {
$cal_inargs = "0,'" . USERID . "','" . $cal_row . "'"; $cal_inargs = "0,'" . USERID . "','" . $cal_row . "'";
$cal_db->db_Insert("event_subs", $cal_inargs); $cal_db->db_Insert('event_subs', $cal_inargs);
} }
// print $cal_row . $cal_subs[$cal_row] . "<br />"; // print $cal_row . $cal_subs[$cal_row] . "<br />";
} }
$caltext = "<table class='fborder' width='97%'> $caltext = "<table class='fborder' width='97%'>
<tr><td class='fcaption' >" . EC_LAN_130 . "</td></tr> <tr><td class='fcaption' >" . EC_LAN_130 . "</td></tr>
<tr><td class='forumheader3' ><a href='calendar.php'>" . EC_LAN_131 . "</a></tr> <tr><td class='forumheader3' ><a href='calendar.php'>" . EC_LAN_131 . "</a></tr>
<tr><td class='fcaption' >&nbsp;</td></tr></table>"; <tr><td class='fcaption' >&nbsp;</td></tr></table>";
} }
else else
{ {
$caltext = "<form id='calsubs' action='" . e_SELF . "' method='post' > $caltext = "<form id='calsubs' action='" . e_SELF . "' method='post' >
<table class='fborder' width='97%'> <table class='fborder' width='97%'>
<tr><td class='fcaption' colspan='3'>" . EC_LAN_125 . "</td></tr> <tr><td class='fcaption' colspan='3'>" . EC_LAN_125 . "</td></tr>
<tr><td class='forumheader2' >" . EC_LAN_126 . "</td><td class='forumheader2' >" . EC_LAN_127 . "</td><td class='forumheader2' >" . EC_LAN_136 . "</td></tr>"; <tr><td class='forumheader2' >" . EC_LAN_126 . "</td><td class='forumheader2' >" . EC_LAN_127 . "</td><td class='forumheader2' >" . EC_LAN_136 . "</td></tr>";
// Get list of currently subscribed // Get list of currently subscribed
$cal_db->db_Select("event_subs", "event_cat", "where event_userid='" . USERID . "'", "nowhere"); $cal_db->db_Select('event_subs', 'event_cat', "where event_userid='" . USERID . "'", "nowhere");
while ($cal_s = $cal_db->db_Fetch()) while ($cal_s = $cal_db->db_Fetch())
{
extract($cal_s);
$cal_array[] = $event_cat;
} // while
// Get list of categories that have subscriptions and are visible to this member
$cal_args = "select * from #event_cat
where event_cat_subs>0 and (find_in_set(event_cat_class,'".USERCLASS_LIST."') OR find_in_set(event_cat_force_class,'".USERCLASS_LIST."'))";
if ($cal_db->db_Select_gen($cal_args))
{
// echo $cal_args."<br />";
while ($cal_row = $cal_db->db_Fetch())
{
extract($cal_row);
$caltext .= "<tr><td class='forumheader3' style='width:10%;'>";
if (check_class($event_cat_force_class))
{ {
$caltext .= EC_LAN_126; extract($cal_s);
} $cal_array[] = $event_cat;
} // while
// Get list of categories that have subscriptions and are visible to this member
$cal_args = "select * from #event_cat
where event_cat_subs>0 and (find_in_set(event_cat_class,'".USERCLASS_LIST."') OR find_in_set(event_cat_force_class,'".USERCLASS_LIST."'))";
if ($cal_db->db_Select_gen($cal_args))
{
// echo $cal_args."<br />";
while ($cal_row = $cal_db->db_Fetch())
{
extract($cal_row);
$caltext .= "<tr><td class='forumheader3' style='width:10%;'>";
if (check_class($event_cat_force_class))
{
$caltext .= EC_LAN_126;
}
else
{
$caltext .= "<input type='hidden' name='event_list[]' value='" . $event_cat_id . "' />
<input type='checkbox' class='tbox' value='1' name='event_subd[$event_cat_id]' " . (in_array($event_cat_id, $cal_array)?"checked='checked' ":"") . " /> </td>";
}
$caltext .= "<td class='forumheader3'>{$event_cat_name}</td><td class='forumheader3'>{$event_cat_description}</td></tr>";
}
}
else else
{ {
$caltext .= "<input type='hidden' name='event_list[]' value='" . $event_cat_id . "' /> $caltext .= "<tr><td class='forumheader3' colspan='3'>" . EC_LAN_128 . "</td></tr>";
<input type='checkbox' class='tbox' value='1' name='event_subd[$event_cat_id]' " . (in_array($event_cat_id, $cal_array)?"checked='checked' ":"") . " /> </td>"; }
} $caltext .= "<tr><td class='forumheader3' colspan='3'><input class='tbox' type='submit' value='" . EC_LAN_129 . "' name='upsubs' /></td></tr>";
$caltext .= "<td class='forumheader3'>{$event_cat_name}</td><td class='forumheader3'>{$event_cat_description}</td></tr>"; $caltext .= "</table></form>";
} }
}
else
{
$caltext .= "<tr><td class='forumheader3' colspan='3'>" . EC_LAN_128 . "</td></tr>";
}
$caltext .= "<tr><td class='forumheader3' colspan='3'><input class='tbox' type='submit' value='" . EC_LAN_129 . "' name='upsubs' /></td></tr>";
$caltext .= "</table></form>";
}
} }
else else
{ {
if (isset($pref['eventpost_asubs']) && ($pref['eventpost_asubs'] == '1')) if (isset($pref['eventpost_asubs']) && ($pref['eventpost_asubs'] == '1'))
$caltext = EC_LAN_142; // Register or log in $caltext = EC_LAN_142; // Register or log in
else else
$caltext = EC_LAN_143; // No facility $caltext = EC_LAN_143; // No facility
} }
$ns->tablerender(EC_LAN_124, $caltext); $e107->ns->tablerender(EC_LAN_124, $caltext);
require_once(FOOTERF); require_once(FOOTERF);
?> ?>