1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-06 14:46:56 +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
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*
* Event calendar plugin - admin functions
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/admin_config.php,v $
* $Revision: 1.14 $
* $Date: 2009-11-18 01:05:23 $
* $Author: e107coders $
* $Revision: 1.15 $
* $Date: 2009-11-22 10:11:24 $
* $Author: e107steved $
*/
$eplug_admin = true; // Make sure we show admin theme
$e_sub_cat = 'event_calendar';
require_once("../../class2.php");
require_once('../../class2.php');
require_once(e_HANDLER."userclass_class.php");
if (!getperms("P"))
if (!getperms('P'))
{
header("location:".e_BASE."index.php");
exit;
@@ -28,7 +28,7 @@ if (!getperms("P"))
include_lan(e_PLUGIN.'calendar_menu/languages/'.e_LANGUAGE.'_admin_calendar_menu.php');
$message = "";
$message = '';
$calendarmenu_text = ''; // Notice removal
$calendarmenu_msg = ''; // Notice removal
@@ -164,15 +164,15 @@ if (isset($_POST['deleteold']) && isset($_POST['eventpost_deleteoldmonths']))
if (isset($_POST['cache_clear']))
{
$ec_qs[0] = "confcache";
$ec_qs[0] = 'confcache';
}
//-------------------------------------------------
require_once(e_ADMIN."auth.php");
require_once(e_ADMIN.'auth.php');
if (!defined("USER_WIDTH")){ define("USER_WIDTH","width:auto"); }
if (!defined('USER_WIDTH')){ define('USER_WIDTH','width:auto'); }
@@ -195,7 +195,7 @@ if (isset($_POST['confirmdeleteold']) && isset($ec_qs[0]) && ($ec_qs[0] == "back
$message = EC_ADLAN_A149." : ".$sql->mySQLresult;
}
$ec_qs[0] = "maint";
$ec_qs[0] = 'maint';
}
@@ -346,7 +346,7 @@ if(isset($ec_qs[0]) && $ec_qs[0] == "cat")
case '1': // Edit existing record
{
// We edit the record
$calendarmenu_db->db_Select("event_cat", "*", "event_cat_id='$calendarmenu_id'");
$calendarmenu_db->db_Select('event_cat', '*', 'event_cat_id='.$calendarmenu_id);
$calendarmenu_row = $calendarmenu_db->db_Fetch() ;
extract($calendarmenu_row);
$calendarmenu_cap1 = EC_ADLAN_A24;
@@ -356,15 +356,15 @@ if(isset($ec_qs[0]) && $ec_qs[0] == "cat")
// First, set up a dummy event
global $thisevent;
$thisevent = array('event_start' => $ecal_class->time_now, 'event_end' => ($ecal_class->time_now)+3600,
'event_title' => "Test event", 'event_details' => EC_ADLAN_A191,
'event_title' => 'Test event', 'event_details' => EC_ADLAN_A191,
'event_cat_name' => $event_cat_name, 'event_location' => EC_ADLAN_A192,
'event_contact' => USEREMAIL,
'event_thread' => SITEURL."dodgypage",
'event_thread' => SITEURL.'dodgypage',
'event_id' => '6');
// *************** SEND EMAIL HERE **************
require_once(e_PLUGIN."calendar_menu/calendar_shortcodes.php");
require_once(e_HANDLER . "mail.php");
require_once(e_PLUGIN.'calendar_menu/calendar_shortcodes.php');
require_once(e_HANDLER . 'mail.php');
switch ($ecal_send_email)
{
case 1 : $cal_msg = $event_cat_msg1;
@@ -372,8 +372,8 @@ if(isset($ec_qs[0]) && $ec_qs[0] == "cat")
case 2 : $cal_msg = $event_cat_msg2;
break;
}
$cal_msg = $tp -> parseTemplate($cal_msg, FALSE, $calendar_shortcodes);
$cal_title = $tp -> parseTemplate($pref['eventpost_mailsubject'], FALSE, $calendar_shortcodes);
$cal_msg = $tp -> parseTemplate($cal_msg, TRUE);
$cal_title = $tp -> parseTemplate($pref['eventpost_mailsubject'], TRUE);
$user_email = USEREMAIL;
$user_name = USERNAME;
// $cal_msg = str_replace("\r","\n",$cal_msg);

View File

@@ -6,38 +6,46 @@
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*
* Event calendar plugin - large calendar display
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/calendar.php,v $
* $Revision: 1.6 $
* $Date: 2009-11-18 01:05:23 $
* $Author: e107coders $
* $Revision: 1.7 $
* $Date: 2009-11-22 10:11:28 $
* $Author: e107steved $
*/
require_once("../../class2.php");
if (!isset($pref['plug_installed']['calendar_menu'])) header('Location: '.e_BASE.'index.php');
require_once(e_PLUGIN.'calendar_menu/calendar_shortcodes.php');
require_once('../../class2.php');
$e107 = e107::getInstance();
if (!$e107->isInstalled('calendar_menu')) header('Location: '.e_BASE.'index.php');
if (isset($_POST['viewallevents']))
{
Header("Location: " . e_PLUGIN . 'calendar_menu/event.php?' . $_POST['enter_new_val']);
Header('Location: '.e_PLUGIN.'calendar_menu/event.php?'.intval($_POST['enter_new_val']));
exit;
}
if (isset($_POST['doit']))
{
Header("Location: " . e_PLUGIN . 'calendar_menu/event.php?ne.' . $_POST['enter_new_val']);
Header('Location: '.e_PLUGIN.'calendar_menu/event.php?ne.'.intval($_POST['enter_new_val']));
exit;
}
if (isset($_POST['subs']))
{
Header("Location: " . e_PLUGIN . 'calendar_menu/subscribe.php');
Header('Location: '.e_PLUGIN.'calendar_menu/subscribe.php');
exit;
}
if (isset($_POST['printlists']))
{
Header("Location: " . e_PLUGIN . 'calendar_menu/ec_pf_page.php');
Header('Location: '.e_PLUGIN.'calendar_menu/ec_pf_page.php');
exit();
}
include_lan(e_PLUGIN.'calendar_menu/languages/'.e_LANGUAGE.'.php');
define("PAGE_NAME", EC_LAN_121);
e107::getScParser();
require_once(e_PLUGIN.'calendar_menu/calendar_shortcodes.php');
require_once('ecal_class.php');
include_lan(e_PLUGIN.'calendar_menu/languages/'.e_LANGUAGE.'.php');
define('PAGE_NAME', EC_LAN_121);
require_once(e_PLUGIN.'calendar_menu/ecal_class.php');
$ecal_class = new ecal_class;
if (is_readable(THEME.'calendar_template.php'))
@@ -50,60 +58,39 @@ else
}
$cat_filter = intval(varset($_POST['event_cat_ids'],0));
$cat_filter = intval(varset($_POST['event_cat_ids'],-1));
if ($cat_filter == -1) $cat_filter = '*';
require_once(HEADERF);
// get date within area to display
$qs = explode(".", e_QUERY);
if(varset($qs[0],'') == "")
unset($dateArray);
if (e_QUERY)
{
$qs = explode('.', e_QUERY); // Get date from query
$dateArray = getdate($qs[0]);
}
if (!is_array($dateArray))
{ // Show current month
$datearray = $ecal_class->cal_date;
}
else
{ // Get date from query
$datearray = getdate($qs[0]);
$dateArray = $ecal_class->cal_date;
}
// Note: A lot of the following variables are used within the shortcodes
$month = $datearray['mon']; // Number of month being shown
$year = $datearray['year']; // Number of year being shown
$monthstart = mktime(0, 0, 0, $month, 1, $year); // Start of month to be shown
$monthend = mktime(0, 0, 0, $month + 1, 1, $year) - 1; // End of month to be shown
$prevmonth = $month-1;
$prevyear = $year;
if ($prevmonth == 0)
{
$prevmonth = 12;
$prevyear = $year-1;
}
$previous = mktime(0, 0, 0, $prevmonth, 1, $prevyear); // Used by nav
$nextmonth = $month + 1;
$nextyear = $year;
if ($nextmonth == 13)
{
$nextmonth = 1;
$nextyear = $year + 1;
}
$next = mktime(0, 0, 0, $nextmonth, 1, $nextyear);
$py = $year-1; // Number of previous year for nav
$prevlink = mktime(0, 0, 0, $month, 1, $py);
$ny = $year + 1; // Number of next year for nav
$nextlink = mktime(0, 0, 0, $month, 1, $ny);
$prop = gmmktime(0, 0, 0, $month, 1, $year); // Sets start date for new event entry
// These are used in the day display loop
$month = $dateArray['mon']; // Number of month being shown
$year = $dateArray['year']; // Number of year being shown
$nowmonth = $ecal_class->cal_date['mon'];
$nowyear = $ecal_class->cal_date['year'];
$nowday = $ecal_class->cal_date['mday'];
// set up arrays for calendar display ------------------------------------------------------------------
// $months is used in the navigator buttons. $monthabb is used for month list
$months = Array(EC_LAN_0, EC_LAN_1, EC_LAN_2, EC_LAN_3, EC_LAN_4, EC_LAN_5, EC_LAN_6, EC_LAN_7, EC_LAN_8, EC_LAN_9, EC_LAN_10, EC_LAN_11);
$monthabb = Array(EC_LAN_JAN, EC_LAN_FEB, EC_LAN_MAR, EC_LAN_APR, EC_LAN_MAY, EC_LAN_JUN, EC_LAN_JUL, EC_LAN_AUG, EC_LAN_SEP, EC_LAN_OCT, EC_LAN_NOV, EC_LAN_DEC);
// Set date window for display
$monthstart = mktime(0, 0, 0, $month, 1, $year); // Start of month to be shown
$monthend = mktime(0, 0, 0, $month + 1, 1, $year) - 1; // End of month to be shown
$days = array(EC_LAN_DAY_1, EC_LAN_DAY_2, EC_LAN_DAY_3, EC_LAN_DAY_4, EC_LAN_DAY_5, EC_LAN_DAY_6, EC_LAN_DAY_7, EC_LAN_DAY_8, EC_LAN_DAY_9, EC_LAN_DAY_10, EC_LAN_DAY_11, EC_LAN_DAY_12, EC_LAN_DAY_13, EC_LAN_DAY_14, EC_LAN_DAY_15, EC_LAN_DAY_16, EC_LAN_DAY_17, EC_LAN_DAY_18, EC_LAN_DAY_19, EC_LAN_DAY_20, EC_LAN_DAY_21, EC_LAN_DAY_22, EC_LAN_DAY_23, EC_LAN_DAY_24, EC_LAN_DAY_25, EC_LAN_DAY_26, EC_LAN_DAY_27, EC_LAN_DAY_28, EC_LAN_DAY_29, EC_LAN_DAY_30, EC_LAN_DAY_31);
setScVar('event_calendar_shortcodes', 'ecalClass', &$ecal_class); // Give shortcodes a pointer to calendar class
callScFunc('event_calendar_shortcodes','setCalDate', $dateArray); // Tell shortcodes the date to display
setScVar('event_calendar_shortcodes', 'catFilter', $cat_filter); // Category filter
//-------------------------------------------------
@@ -111,10 +98,10 @@ $days = array(EC_LAN_DAY_1, EC_LAN_DAY_2, EC_LAN_DAY_3, EC_LAN_DAY_4, EC_LAN_DAY
//-------------------------------------------------
// time switch buttons
$cal_text = $tp -> parseTemplate($CALENDAR_TIME_TABLE, FALSE, $calendar_shortcodes);
$cal_text = $e107->tp->parseTemplate($CALENDAR_TIME_TABLE, TRUE);
// navigation buttons
$nav_text = $tp -> parseTemplate($CALENDAR_NAVIGATION_TABLE, FALSE, $calendar_shortcodes);
$nav_text = $e107->tp->parseTemplate($CALENDAR_NAVIGATION_TABLE, TRUE);
// We'll need virtually all of the event-related fields, so get them regardless. Just cut back on category fields
$ev_list = $ecal_class->get_events($monthstart, $monthend, FALSE, $cat_filter, TRUE, '*', 'event_cat_name,event_cat_icon');
@@ -174,49 +161,51 @@ $events = array();
// ****** CAUTION - the category dropdown also used $sql object - take care to avoid interference!
$start = $monthstart;
$numberdays = date("t", $start); // number of days in this month
$numberdays = date('t', $start); // number of days in this month
$text = "";
$text .= $tp -> parseTemplate($CALENDAR_CALENDAR_START, FALSE, $calendar_shortcodes);
$text .= $tp -> parseTemplate($CALENDAR_CALENDAR_HEADER_START, FALSE, $calendar_shortcodes);
$text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_START, TRUE);
$text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_HEADER_START, TRUE);
// Display the column headers
for ($i = 0; $i < 7; $i++)
{
$day = $ecal_class->day_offset_string($i);
$text .= $tp -> parseTemplate($CALENDAR_CALENDAR_HEADER, FALSE, $calendar_shortcodes);
setScVar('event_calendar_shortcodes', 'headerDay', $ecal_class->day_offset_string($i));
$text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_HEADER, TRUE);
}
$text .= $tp -> parseTemplate($CALENDAR_CALENDAR_HEADER_END, FALSE, $calendar_shortcodes);
$text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_HEADER_END, TRUE);
// Calculate number of days to skip before 'real' days on first line of calendar
$firstdayoffset = date('w',$start) - $ecal_class->ec_first_day_of_week;
if ($firstdayoffset < 0) $firstdayoffset+= 7;
for ($c=0; $c<$firstdayoffset; $c++)
for ($i=0; $i<$firstdayoffset; $i++)
{
$text .= $tp -> parseTemplate($CALENDAR_CALENDAR_DAY_NON, FALSE, $calendar_shortcodes);
$text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_DAY_NON, TRUE);
}
$loop = $firstdayoffset;
for ($c = 1; $c <= $numberdays; $c++)
{ // Loop through the number of days in this month
$startt = $start; // Used by shortcodes - start of current day
$stopp = $start + 86399; // End of current day
$got_ev = array_key_exists($c, $events) && is_array($events[$c]) && count($events[$c]) > 0; // Flag set if events today
setScVar('event_calendar_shortcodes', 'todayStart', $start); // Start of current day
setScVar('event_calendar_shortcodes', 'curDay', $c); // Current day of month
$got_ev = array_key_exists($c, $events) && is_array($events[$c]) && count($events[$c]) > 0; // Flag set if events on this day
// Highlight the current day.
if ($nowday == $c && $month == $nowmonth && $year == $nowyear)
{ //today
$text .= $tp -> parseTemplate($CALENDAR_CALENDAR_DAY_TODAY, FALSE, $calendar_shortcodes);
$text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_DAY_TODAY, TRUE);
}
elseif ($got_ev)
{ //day has events
$text .= $tp -> parseTemplate($CALENDAR_CALENDAR_DAY_EVENT, FALSE, $calendar_shortcodes);
$text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_DAY_EVENT, TRUE);
}
else
{ // no events and not today
$text .= $tp -> parseTemplate($CALENDAR_CALENDAR_DAY_EMPTY, FALSE, $calendar_shortcodes);
$text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_DAY_EMPTY, TRUE);
}
if ($got_ev)
{
@@ -224,20 +213,21 @@ for ($c = 1; $c <= $numberdays; $c++)
{
if ($ev['startofevent'])
{
$ev['indicat'] = "";
$ev['imagesize'] = "8";
$ev['indicat'] = '';
$ev['imagesize'] = '8';
$ev['fulltopic'] = TRUE;
}
else
{
$ev['indicat'] = "";
$ev['imagesize'] = "4";
$ev['indicat'] = '';
$ev['imagesize'] = '4';
$ev['fulltopic'] = FALSE;
}
$text .= $tp -> parseTemplate($CALENDAR_SHOWEVENT, FALSE, $calendar_shortcodes);
setScVar('event_calendar_shortcodes', 'event', $ev); // Give shortcodes the event data
$text .= $e107->tp->parseTemplate($CALENDAR_SHOWEVENT, TRUE);
}
}
$text .= $tp -> parseTemplate($CALENDAR_CALENDAR_DAY_END, FALSE, $calendar_shortcodes);
$text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_DAY_END, TRUE);
$loop++;
if ($loop == 7)
@@ -245,7 +235,7 @@ for ($c = 1; $c <= $numberdays; $c++)
$loop = 0;
if($c != $numberdays)
{
$text .= $tp -> parseTemplate($CALENDAR_CALENDAR_WEEKSWITCH, FALSE, $calendar_shortcodes);
$text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_WEEKSWITCH, TRUE);
}
}
$start += 86400;
@@ -256,12 +246,12 @@ if($loop!=0)
{
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
unset($ev_list);

View File

@@ -1,47 +1,51 @@
<?php
/*
+ ----------------------------------------------------------------------------+
| e107 website system
|
| Copyright (C) 2008-2009 e107 Inc (e107.org)
| http://e107.org
|
|
| 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.6 $
| $Date: 2009-11-18 01:05:23 $
| $Author: e107coders $
|
+----------------------------------------------------------------------------+
* 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)
*
* Forthcoming events menu handler for event calendar
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/calendar_menu.php,v $
* $Revision: 1.7 $
* $Date: 2009-11-22 10:11:28 $
* $Author: e107steved $
*/
if (!defined('e107_INIT')) { exit; }
$ecal_dir = e_PLUGIN.'calendar_menu/';
require_once($ecal_dir.'ecal_class.php');
if (!isset($ecal_class) || !is_object($ecal_class)) $ecal_class = new ecal_class;
$cache_tag = 'nq_event_cal_cal';
$e107 = e107::getInstance();
if (!$e107->isInstalled('calendar_menu')) return '';
global $e107;
// See if the page is already in the cache
$cache_tag = 'nq_event_cal_cal';
if($cacheData = $e107->ecache->retrieve($cache_tag, $ecal_class->max_cache_time))
{
echo $cacheData;
return;
}
include_lan($ecal_dir.'languages/'.e_LANGUAGE.'.php');
global $ecal_dir, $tp;
if (is_readable(THEME."calendar_template.php"))
global $pref;
if (!is_object($ecal_class))
{
require(THEME."calendar_template.php");
require_once(e_PLUGIN.'calendar_menu/ecal_class.php');
$ecal_class = new ecal_class;
}
include_lan(e_PLUGIN.'calendar_menu/languages/'.e_LANGUAGE.'.php');
// Doesn't use shortcodes - rather a specific format for that
//e107::getScParser();
//require_once(e_PLUGIN.'calendar_menu/calendar_shortcodes.php');
if (is_readable(THEME.'calendar_template.php'))
{ // Has to be require
require(THEME.'calendar_template.php');
}
else
{ // Needs to be require - otherwise not loaded if two menus use it
require($ecal_dir."calendar_template.php");
{
require(e_PLUGIN.'calendar_menu/calendar_template.php');
}
$show_recurring = TRUE; // Could be pref later
$cat_filter = ''; // Could be another pref later.
$cat_filter = '*'; // Could be another pref later.
$cal_datearray = $ecal_class->cal_date;
$cal_current_month = $cal_datearray['mon'];
$cal_current_year = $cal_datearray['year'];
@@ -55,14 +59,17 @@ $cal_events = array();
$cal_titles = array();
$cal_recent = array();
$cal_totev = 0;
$ev_list = $ecal_class->get_events($cal_monthstart, $cal_monthend, FALSE, $cat_filter, $show_recurring,
'event_start, event_thread, event_title, event_recurring, event_allday', 'event_cat_icon');
$cal_totev = count($ev_list);
// Generate an array, one element per day of the month, and assign events to them
foreach ($ev_list as $cal_row)
{
if (is_array($cal_row['event_start'])) $temp = $cal_row['event_start']; else $temp = array($cal_row['event_start']);
foreach ($temp as $ts)
{
{ // Split up any recurring events
$cal_start_day = date('j',$ts); // Day of month for start
// Mark start day of each event
$cal_events[$cal_start_day][] = $cal_row['event_cat_icon']; // Only first is actually used
@@ -70,15 +77,16 @@ $cal_totev = count($ev_list);
$cal_titles[$cal_start_day][] = $cal_row['event_title']; // In case titles displayed on mouseover
}
}
// set up month array for calendar display
$cal_months = array(EC_LAN_0, EC_LAN_1, EC_LAN_2, EC_LAN_3, EC_LAN_4, EC_LAN_5, EC_LAN_6, EC_LAN_7, EC_LAN_8, EC_LAN_9, EC_LAN_10, EC_LAN_11);
if ($pref['eventpost_dateformat'] == 'my')
{
$calendar_title = $cal_months[$cal_current_month-1] ." ". $cal_current_year;
$calendar_title = $cal_months[$cal_current_month-1] .' '. $cal_current_year;
}
else
{
$calendar_title = $cal_current_year ." ". $cal_months[$cal_current_month-1];
$calendar_title = $cal_current_year .' '. $cal_months[$cal_current_month-1];
}
switch ($pref['eventpost_menulink'])
{
@@ -111,8 +119,7 @@ for ($i = 0; $i < 7; $i++)
{
$cal_day = $ecal_class->day_offset_string($i);
$cal_text .= $CALENDAR_MENU_HEADER_FRONT;
// $cal_text .= substr($cal_day, 0, $pref['eventpost_lenday']);
$cal_text .= $tp->text_truncate($cal_day, 1, ''); // Unlikely to have room for more than 1 letter
$cal_text .= $e107->tp->text_truncate($cal_day, 1, ''); // Unlikely to have room for more than 1 letter
$cal_text .= $CALENDAR_MENU_HEADER_BACK;
}
$cal_text .= $CALENDAR_MENU_HEADER_END; // Close off header row, open first date row
@@ -142,7 +149,7 @@ for($cal_c = 1; $cal_c <= $numberdays; $cal_c++)
$cal_linkut = gmmktime(0 , 0 , 0 , $cal_current_month, $cal_c, $cal_current_year).".one"; // Always need "one"
if (array_key_exists($cal_c, $cal_events))
{ // There are events today
$cal_event_icon = "calendar_menu/images/" . $cal_events[$cal_c]['0']; // Icon file could be NULL
$cal_event_icon = 'calendar_menu/images/'.$cal_events[$cal_c]['0']; // Icon file could be NULL
$cal_event_count = count($cal_events[$cal_c]); // See how many events today
if ($cal_event_count)
{ // Show icon if it exists

File diff suppressed because it is too large Load Diff

View File

@@ -6,18 +6,20 @@
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*
* Templates for event calendar displays
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/calendar_template.php,v $
* $Revision: 1.9 $
* $Date: 2009-11-18 01:05:23 $
* $Author: e107coders $
* $Revision: 1.10 $
* $Date: 2009-11-22 10:11:29 $
* $Author: e107steved $
*/
// TODO: Replace expandit on events with latest auto-management
if (!defined('e107_INIT')) { exit; }
if (!defined("USER_WIDTH")){ define("USER_WIDTH","width:auto"); }
if (!defined('USER_WIDTH')){ define('USER_WIDTH','width:auto'); }
//global $sc_style;
$ec_images_path = e_IMAGE;
$ec_images_path_abs = e_IMAGE_ABS;
@@ -163,11 +165,14 @@ $EVENT_EVENT_DATETIME[0] = "{EC_EVENT_DATE_START}".EC_LAN_144."{EC_EVENT_TIME_S
$EVENT_EVENT_DATETIME[1] = "{EC_EVENT_DATE_START} ".EC_LAN_84." {EC_EVENT_TIME_START}".EC_LAN_85."{EC_EVENT_TIME_END}";
$EVENT_EVENT_DATETIME[2] = "{EC_EVENT_DATE_START} <b>".EC_LAN_69."</b> {EC_EVENT_DATE_END}";
$EVENT_EVENT_DATETIME[3] = "{EC_EVENT_DATE_START}";
/* This is roughly what's wanted, but div not allowed
$EVENT_EVENT_TABLE = "
<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='display:{EC_EVENT_DISPLAYSTYLE}; padding-top:10px; padding-bottom:10px; text-align:left;'>
<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}' {EC_EVENT_DISPLAYCLASS} style='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
@@ -179,8 +184,27 @@ $EVENT_EVENT_TABLE = "
</td>
</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
//------------------------------------------

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

View File

@@ -6,12 +6,12 @@
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*
* Event calendar - generate lists
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/ec_pf_page.php,v $
* $Revision: 1.6 $
* $Date: 2009-11-19 10:09:58 $
* $Author: marj_nl_fr $
* $Revision: 1.7 $
* $Date: 2009-11-22 10:11:30 $
* $Author: e107steved $
*/
/*
|
@@ -28,23 +28,26 @@
+----------------------------------------------------------------------------+
*/
require_once("../../class2.php");
if (!isset($pref['plug_installed']['calendar_menu'])) header("Location: ".e_BASE."index.php");
include_lan(e_PLUGIN."calendar_menu/languages/".e_LANGUAGE.".php");
define("PAGE_NAME", EC_LAN_80);
require_once('../../class2.php');
$e107 = e107::getInstance();
if (!$e107->isInstalled('calendar_menu')) header('Location: '.e_BASE.'index.php');
include_lan(e_PLUGIN.'calendar_menu/languages/'.e_LANGUAGE.'.php');
define('PAGE_NAME', EC_LAN_80);
require_once(e_PLUGIN.'calendar_menu/ecal_class.php');
$ecal_class = new ecal_class;
require_once(e_PLUGIN."calendar_menu/calendar_shortcodes.php");
$message = "";
e107::getScParser();
require_once(e_PLUGIN.'calendar_menu/calendar_shortcodes.php');
$message = '';
unset($ec_qs);
if (e_QUERY) $ec_qs = explode(".", e_QUERY);
if (e_QUERY) $ec_qs = explode('.', e_QUERY);
else
{
if (!isset($pref['eventpost_printlists']) || ($pref['eventpost_printlists'] == 0))
header("location:".SITEURL); // If disabled, just go back to index page
header('location:'.SITEURL); // If disabled, just go back to index page
}
if (isset($_POST['set_dates']) && isset($_POST['start_date']) && (isset($_POST['end_date'])))
@@ -66,7 +69,6 @@ if (!isset($ec_qs[4]) || (($ec_qs[4]) != 'print') && ($ec_qs[4] != 'pdf') ) $ec_
global $cal_super, $calendar_shortcodes;
$cal_super = $ecal_class->cal_super;
// Get templates, since we may have to give a choice if we're displaying something
@@ -74,14 +76,14 @@ $cal_super = $ecal_class->cal_super;
$EVENT_CAL_PDF_HEADER = array();
$EVENT_CAL_PDF_BODY = array();
$EVENT_CAL_PDF_FOOTER = array();
if (is_readable(e_PLUGIN."calendar_menu/ec_pf_template.php")) require_once(e_PLUGIN."calendar_menu/ec_pf_template.php");
if (is_readable(e_PLUGIN."calendar_menu/ec_pf_user_template.php")) require_once(e_PLUGIN."calendar_menu/ec_pf_user_template.php");
if (is_readable(THEME."ec_pf_template.php")) require_once(THEME."ec_pf_template.php");
if (is_readable(e_PLUGIN.'calendar_menu/ec_pf_template.php')) require_once(e_PLUGIN.'calendar_menu/ec_pf_template.php');
if (is_readable(e_PLUGIN.'calendar_menu/ec_pf_user_template.php')) require_once(e_PLUGIN.'calendar_menu/ec_pf_user_template.php');
if (is_readable(THEME.'ec_pf_template.php')) require_once(THEME.'ec_pf_template.php');
// Hard-coded alternatives
if (!count($EVENT_CAL_PDF_HEADER)) $EVENT_CAL_PDF_HEADER['default'] = "<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_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_FOOTER)) $EVENT_CAL_PDF_FOOTER['default'] = '<br />';
if (!count($EVENT_CAL_PDF_NAMES)) $ec_pdf_template = 'default';
// If one name only, we just assign that
if (count($EVENT_CAL_PDF_NAMES) == 1)
@@ -113,7 +115,7 @@ if (!isset($ec_qs[0]) || !isset($ec_qs[1]))
</tr><tr>
<td class='forumheader3'>".EC_LAN_155."</td>
<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>
</tr>";
if (isset($EVENT_CAL_PDF_NAMES) && is_array($EVENT_CAL_PDF_NAMES) && (count($EVENT_CAL_PDF_NAMES) > 1))
@@ -176,8 +178,9 @@ if ($message !== "")
exit;
}
setScVar('event_calendar_shortcodes', 'ecalClass', &$ecal_class); // Give shortcodes a pointer to calendar class
setScVar('event_calendar_shortcodes', 'catFilter', $cat_filter); // Category filter
global $ec_current_month, $thisevent_start_date, $thisevent_end_date, $ec_output_type, $ec_category_list, $ec_list_title;
$ec_output_type = $ec_qs[4];
if (isset($ec_qs[5])) $ec_list_title = $ec_qs[5]; else $ec_list_title = EC_LAN_163;
$ec_list_title = str_replace('_',' ',$ec_list_title);
@@ -246,16 +249,21 @@ $ev_list = $ecal_class->get_events($ec_start_date, $ec_end_date, FALSE, $cat_fil
if (isset($ec_qs[3])) $ec_pdf_template = $ec_qs[3];
if (!isset($ec_pdf_template) || !array_key_exists($ec_pdf_template,$EVENT_CAL_PDF_NAMES)) $ec_pdf_template = 'default';
/*
// These available to templates/shortcodes to pick up change of start day/month/year
global $ec_last_year, $ec_last_month, $ec_last_day, $ec_year_change, $ec_month_change, $ec_day_change;
global $ec_start_date, $ec_end_date, $ec_pdf_options;
global $ec_current_month, $thisevent_start_date, $thisevent_end_date ;
*/
setScVar('event_calendar_shortcodes', 'printVars', array('lt' => $ec_list_title, 'cat' => $ec_category_list, 'ot' => $ec_output_type,
'sd' => $ec_start_date, 'ed' => $ec_end_date)); // Give shortcodes the event data
$ec_last_year = 0;
$ec_last_month = 0;
$ec_last_day = 0;
$ec_pdf_options = ""; // Can configure the PDF driver
$cal_text = "";
$cal_text = '';
$cal_totev = count($ev_list);
if ($cal_totev > 0)
{
@@ -268,7 +276,7 @@ if ($cal_totev > 0)
// If printing, wrap in a form so the button works
if ($ec_output_type == 'print') $cal_text .= "<form action=''>\n";
// 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
// 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 />";
@@ -281,7 +289,6 @@ if ($cal_totev > 0)
{
$ev_list[$ptr]['event_start'] = $tim;
$thisevent = $ev_list[$ptr];
// echo "Event: ".$thisevent['event_start']." ".$thisevent['event_title']."<br />";
// Decode dates into individual fields - we're bound to want them
$thisevent_start_date = $ecal_class->gmgetdate($thisevent['event_start']);
$thisevent_end_date = $ecal_class->gmgetdate($thisevent['event_end']);
@@ -291,7 +298,10 @@ if ($cal_totev > 0)
$ec_day_change = ($ec_last_day != $thisevent_start_date['mday']);
$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
setScVar('event_calendar_shortcodes', 'changeFlags', array('yc' => $ec_year_change, 'mc' => $ec_month_change, 'dc' => $ec_day_change)); // Give shortcodes the event data
$cal_text .= $e107->tp->parseTemplate($EVENT_CAL_PDF_BODY[$ec_pdf_template],TRUE);
$ec_last_year = $thisevent_start_date['year'];
$ec_last_month = $thisevent_start_date['mon'];
@@ -299,7 +309,7 @@ if ($cal_totev > 0)
}
// 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";
}
else
@@ -310,7 +320,7 @@ else
switch($ec_output_type)
{
case 'display':
$ns->tablerender(EC_LAN_80, $cal_text, 'ec_pf_page');
$e107->ns->tablerender(EC_LAN_80, $cal_text, 'ec_pf_page');
require_once (FOOTERF);
break;
@@ -319,29 +329,25 @@ switch($ec_output_type)
break;
case 'pdf':
//TODO use a better way to pass info to pdf
//TODO find a way to pass initialisation options etc to PDF driver
include_lan(e_PLUGIN.'pdf/languages/'.e_LANGUAGE.'.php');
define('FPDF_FONTPATH', 'font/');
//require the ufpdf class
require_once (e_PLUGIN.'pdf/ufpdf.php');
//require the e107pdf class
require_once (e_PLUGIN.'pdf/e107pdf.php');
if('' == $ec_pdf_options)
{
$pdf = new e107PDF();
}
else
{
$pdf = new e107PDF($ec_pdf_options);
}
// $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);
break;
@@ -427,13 +433,13 @@ function gen_drop($drop_type)
$text = "<select name='".($drop_type ? 'end_date' : 'start_date')."' class='tbox' style='width:140px;' >\n";
if ($drop_type)
{
$start_date = strtotime("-3 months");
$match_date = strtotime("+3 months"); // Propose 3-month list
$start_date = strtotime('-3 months');
$match_date = strtotime('+3 months'); // Propose 3-month list
}
else
{
$start_date = strtotime("-9 months");
// $match_date = strtotime("-1 months");
$start_date = strtotime('-9 months');
// $match_date = strtotime('-1 months');
$match_date = time(); // Use current month for start date
}

View File

@@ -1,4 +1,18 @@
<?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).
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("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']['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_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_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

View File

@@ -6,21 +6,16 @@
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*
* Event calendar class
* Pre-calculates/caches many useful values
* Implements functions used in most of the code
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/ecal_class.php,v $
* $Revision: 1.11 $
* $Date: 2009-11-18 01:05:23 $
* $Author: e107coders $
* $Revision: 1.12 $
* $Date: 2009-11-22 10:11:30 $
* $Author: e107steved $
*/
/*
|
| Event calendar class:
| Pre-calculates/caches many useful values
| Implements functions used in most of the code
|
*/
/*
Preferences used:
@@ -31,7 +26,7 @@ Preferences used:
if (!defined('e107_INIT')) { exit; }
if (!defined("EC_DEFAULT_CATEGORY")) { define('EC_DEFAULT_CATEGORY',"Default"); }
if (!defined('EC_DEFAULT_CATEGORY')) { define('EC_DEFAULT_CATEGORY','Default'); }
class ecal_class
{
@@ -64,28 +59,36 @@ if (!defined("EC_DEFAULT_CATEGORY")) { define('EC_DEFAULT_CATEGORY',"Default");
var $cat_text_cache = array(); // Used to cache category text as read
var $ec_first_day_of_week = 0; // First day of the week
var $days = array(EC_LAN_25, EC_LAN_19, EC_LAN_20, EC_LAN_21, EC_LAN_22, EC_LAN_23, EC_LAN_24); // Array Sunday..Saturday
var $recur_type = array('0' => 'no', '1' => 'annual', '2' => 'biannual', '3' =>'quarterly', '4' => 'monthly', '5' => 'four weekly',
'6' => 'fortnightly', '7' => 'weekly', '8' => 'daily',
'100' => 'Sunday in month',
'101' => 'Monday in month',
'102' => 'Tuesday in month',
'103' => 'Wednesday in month',
'104' => 'Thursday in month',
'105' => 'Friday in month',
'106' => 'Saturday in month'
public $days = array(EC_LAN_25, EC_LAN_19, EC_LAN_20, EC_LAN_21, EC_LAN_22, EC_LAN_23, EC_LAN_24); // Array Sunday..Saturday
public $recur_type = array(
'0' => EC_LAN_RECUR_00, // 'no'
'1' => EC_LAN_RECUR_01, //'annual'
'2' => EC_LAN_RECUR_02, //'biannual'
'3' => EC_LAN_RECUR_03, //'quarterly'
'4' => EC_LAN_RECUR_04, //'monthly'
'5' => EC_LAN_RECUR_05, //'four weekly'
'6' => EC_LAN_RECUR_06, //'fortnightly'
'7' => EC_LAN_RECUR_07, // 'weekly'
'8' => EC_LAN_RECUR_00, // 'daily'
'100' => EC_LAN_RECUR_100, // 'Sunday in month'
'101' => EC_LAN_RECUR_101, // 'Monday in month'
'102' => EC_LAN_RECUR_102, // 'Tuesday in month'
'103' => EC_LAN_RECUR_103, // 'Wednesday in month'
'104' => EC_LAN_RECUR_104, // 'Thursday in month'
'105' => EC_LAN_RECUR_105, // 'Friday in month'
'106' => EC_LAN_RECUR_106 // 'Saturday in month'
);
var $recur_week = array(
'100' => EC_LAN_RECUR_1100, //'First'
'200' => EC_LAN_RECUR_1200, //'Second'
'300' => EC_LAN_RECUR_1300, // 'Third'
'400' => EC_LAN_RECUR_1400 // 'Fourth'
);
var $recur_week = array('100' => 'First', '200' => 'Second', '300' => 'Third', '400' => 'Fourth');
function ecal_class()
public function __construct()
{ // Constructor
global $pref;
if (!isset($pref['plug_installed']['calendar_menu']))
{
header('location:'.e_BASE.'index.php');
exit;
}
// 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.
@@ -223,29 +226,32 @@ if (!defined("EC_DEFAULT_CATEGORY")) { define('EC_DEFAULT_CATEGORY',"Default");
}
function time_string($convtime)
public function time_string($convtime)
{ // Returns a time string from a time stamp, formatted as 24-hour, 12-hour or custom as set in prefs
return gmstrftime($this->time_format_string, $convtime);
}
function event_date_string($convdate)
public function event_date_string($convdate)
{ // Returns a date string from a date stamp, formatted for display in event list
return gmstrftime($this->event_date_format_string,$convdate);
}
function next_date_string($convdate)
public function next_date_string($convdate)
{ // Returns a date string from a date stamp, formatted for display in forthcoming event menu
return gmstrftime($this->next_date_format_string,$convdate);
}
function full_date($convdate)
public function full_date($convdate)
{ // Returns a date as dd-mm-yyyy or yyyy-mm-dd according to prefs (for event entry)
return gmdate($this->cal_format_string, $convdate);
}
function make_date($new_hour, $new_minute, $date_string)
public function make_date($new_hour, $new_minute, $date_string)
{ // Turns a date as entered in the calendar into a time stamp (for event entry)
$tmp = explode($this->date_separator, $date_string);
switch ($this->java_format_code)
@@ -259,14 +265,15 @@ if (!defined("EC_DEFAULT_CATEGORY")) { define('EC_DEFAULT_CATEGORY',"Default");
}
}
// 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];
}
function cal_log($event_type, $event_title = '', $event_string='', $event_start=0)
public function cal_log($event_type, $event_title = '', $event_string='', $event_start=0)
{ // All calendar-related logging intentionally passed through a single point to maintain control
// (so we could also add other info if we wanted)
// Event types:
@@ -275,32 +282,40 @@ if (!defined("EC_DEFAULT_CATEGORY")) { define('EC_DEFAULT_CATEGORY',"Default");
// 3 - delete event
// 4 - Bulk delete
// 5 - add multiple events
global $pref, $admin_log, $e_event, $PLUGINS_DIRECTORY, $e107;
global $pref;
$e107 = e107::getInstance();
$log_titles = array( '1' => 'EC_ADM_01',
'2' => 'EC_ADM_02',
'3' => 'EC_ADM_03',
'4' => 'EC_ADM_04',
'5' => 'EC_ADM_05',
'6' => 'EC_ADM_06',
'7' => 'EC_ADM_07',
'8' => 'EC_ADM_08',
'9' => 'EC_ADM_09',
'10' => 'EC_ADM_10',
'11' => 'EC_ADM_11'
);
// Do the notifies first
$cmessage = $log_titles[$event_type]."<br />";
if ($event_start > 0)
{
$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 Start: '.strftime("%d-%B-%Y",$event_start)."<br />";
$cmessage .= 'Event Link: '.SITEURL.e_PLUGIN_ABS. 'calendar_menu/event.php?'.$event_start." <br />";
}
else
$cmessage .= "Event Start unknown<br />";
$edata_ec = array("cmessage" => $cmessage, "ip" => $e107->getip());
$edata_ec = array('cmessage' => $cmessage, 'ip' => $e107->getip());
switch ($event_type)
{
case 5 :
case 1 : $e_event -> trigger("ecalnew", $edata_ec);
case 1 : $e107->e_event -> trigger('ecalnew', $edata_ec);
break;
case 2 :
case 3 :
case 4 : $e_event -> trigger("ecaledit", $edata_ec);
case 4 : $e107->e_event -> trigger('ecaledit', $edata_ec);
break;
}
@@ -316,7 +331,7 @@ if (!defined("EC_DEFAULT_CATEGORY")) { define('EC_DEFAULT_CATEGORY',"Default");
'4' => 'Event Calendar - Bulk Delete',
'5' => 'Event Calendar - multiple add '.strftime("%d-%B-%Y",$event_start)
);
$admin_log->log_event($log_titles[$event_type],$event_title."&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,'');
}
@@ -345,9 +360,18 @@ if (!defined("EC_DEFAULT_CATEGORY")) { define('EC_DEFAULT_CATEGORY',"Default");
// Recurring event handling
//------------------------------------------------
// Generate a list of recurring events based on a 'first event' date, an interval and start/finish times
// Returns an array of times
function gen_recur_regular($first_event, $last_event, $interval, $start_time, $end_time)
/**
* Internal utility - Generate a list of time/date based on a 'first event' date, an interval and start/finish times
* All fields are Unix-style time/date stamps
* @param int $first_event
* @param int $last_event
* @param int $interval - interval between events (in seconds)
* @param int $start_time
* @param int $end_time - last date in time window
*
* @return array of start date/time entries
*/
protected function gen_recur_regular($first_event, $last_event, $interval, $start_time, $end_time)
{
if ($last_event < $end_time) $end_time = $last_event;
$ret = array();
@@ -361,8 +385,15 @@ if (!defined("EC_DEFAULT_CATEGORY")) { define('EC_DEFAULT_CATEGORY',"Default");
}
function add_dates($main_date,$adder)
{ // Adds an offset of months and years to a date
/**
* Internal utility - adds an offset of months and years to a date
* @param array $main_date - a date in PHP standard array format
* @param array $adder - a month+year offset in PHP standard array format
*
* @return array where 'mon' and 'year' fields filled in
*/
protected function add_dates($main_date,$adder)
{
if ($adder['mon'])
{
$main_date['mon'] += $adder['mon'];
@@ -377,9 +408,17 @@ if (!defined("EC_DEFAULT_CATEGORY")) { define('EC_DEFAULT_CATEGORY',"Default");
}
// Generate a list of recurring events based on a 'first event' date, an interval type and start/finish window
// For day number, '0' = 'Sunday'
function gen_recur($first_event, $last_event, $interval_type, $start_time, $end_time)
/**
* Generate a list of recurring events based on a 'first event' date, an interval type and start/finish window
* @param int $first_event - earliest date for events
* @param int $last_event - latest time for date of event
* @param int $interval_type - numeric code defining the interval between events (N.B> day number zero is Sunday)
* @param int $start_time - start time for each event
* @param int $end_time - end time for each event
*
* @return array of events (may be empty)
*/
public function gen_recur($first_event, $last_event, $interval_type, $start_time, $end_time)
{
if ($last_event < $end_time) $end_time = $last_event;
$ret = array();
@@ -498,9 +537,21 @@ if (!defined("EC_DEFAULT_CATEGORY")) { define('EC_DEFAULT_CATEGORY',"Default");
return $ret;
}
// Read a list of events between start and end dates
// If $start_only is TRUE, only searches based on the start date/time
// Potential option to hook in other routines later
/**
* Function to return all events between a given start and end date
* Potential option to hook in other routines here later
* @param int $start_time - earliest time for events
* @param int $end_time - latest time for start of event
* @param boolean $start_only - TRUE to scan based on start time only. FALSE to select events which overlap the specified time window
* @param boolean|string $cat_filter = FALSE is 'no categories' - returns an empty array.
* $cat_filter = '*' means 'all categories'
* otherwise $cat_filter mst be a comma-separated list of category IDs.
* @param string $event_fields - comma separated list of fields to read from the event record; '*' for all fields
* @param string $cat_fields - comma separated list of fields to read from the category record; '*' for all fields
*
* @return array of events (may be empty)
*/
function get_events($start_time, $end_time, $start_only=FALSE, $cat_filter=0, $inc_recur=FALSE, $event_fields='*', $cat_fields='*')
{
global $sql;
@@ -557,13 +608,23 @@ if (!defined("EC_DEFAULT_CATEGORY")) { define('EC_DEFAULT_CATEGORY',"Default");
}
// Function to return up to a maximum number of events between a given start and end date
// It always uses the event start date only
// It tries to keep the actual number of events in memory to a minimum by discarding when it can.
// Once there are $num_events read, it pulls in the $end_time to speed up checks
// $cat_filter = FALSE is 'no categories' - returns an empty array.
// $cat_filter = '*' means 'all categories'
// otherwise $cat_filter mst be a comma-separated list of category IDs.
/**
* Function to return up to a maximum number of events between a given start and end date
* It always uses the event start date only
* It tries to keep the actual number of events in memory to a minimum by discarding when it can.
* Once there are $num_events read, it pulls in the $end_time to speed up checks
* @param int $num_event - number of events required
* @param int $start_time - earliest time for events
* @param int $end_time - latest time for start of event
* @param boolean|string $cat_filter = FALSE is 'no categories' - returns an empty array.
* $cat_filter = '*' means 'all categories'
* otherwise $cat_filter mst be a comma-separated list of category IDs.
* @param boolean $inc_recur TRUE to include recurring events
* @param string $event_fields - comma separated list of fields to read from the event record; '*' for all fields
* @param string $cat_fields - comma separated list of fields to read from the category record; '*' for all fields
*
* @return array of events (may be empty)
*/
function get_n_events($num_event, $start_time, $end_time, $cat_filter='*', $inc_recur=FALSE, $event_fields='*', $cat_fields='*')
{
global $sql;
@@ -663,7 +724,13 @@ if (!defined("EC_DEFAULT_CATEGORY")) { define('EC_DEFAULT_CATEGORY',"Default");
} // End - function get_n_events()
function get_recur_text($recurring)
/**
* Get text relating to recurring item
* @param int numeric code for type of recurring item
*
* @return string corresponding text description
*/
public function get_recur_text($recurring)
{
if ($recurring >= 100)
{

View File

@@ -6,48 +6,54 @@
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*
* Calender plugin - event listing and event entry
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/event.php,v $
* $Revision: 1.14 $
* $Date: 2009-11-18 01:05:23 $
* $Author: e107coders $
* $Revision: 1.15 $
* $Date: 2009-11-22 10:11:30 $
* $Author: e107steved $
*/
require_once('../../class2.php');
if (!isset($pref['plug_installed']['calendar_menu'])) header("Location: ".e_BASE."index.php");
$e107 = e107::getInstance();
if (!$e107->isInstalled('calendar_menu')) header('Location: '.e_BASE.'index.php');
if (isset($_POST['viewallevents']))
{ // Triggered from NAV_BUT_ALLEVENTS
Header("Location: ".e_PLUGIN."calendar_menu/calendar.php?".$_POST['enter_new_val']);
Header('Location: '.e_PLUGIN.'calendar_menu/calendar.php?'.$_POST['enter_new_val']);
exit();
}
if (isset($_POST['doit']))
{ // Triggered from NAV_BUT_ENTEREVENT
Header("Location: ".e_PLUGIN."calendar_menu/event.php?ne.".$_POST['enter_new_val']);
exit;
Header('Location: '.e_PLUGIN.'calendar_menu/event.php?ne.'.$_POST['enter_new_val']);
exit();
}
if (isset($_POST['subs']))
{
Header("Location: ".e_PLUGIN."calendar_menu/subscribe.php");
Header('Location: '.e_PLUGIN.'calendar_menu/subscribe.php');
exit();
}
if (isset($_POST['printlists']))
{
Header("Location: " . e_PLUGIN . "calendar_menu/ec_pf_page.php");
Header("Location: " . e_PLUGIN . 'calendar_menu/ec_pf_page.php');
exit();
}
include_lan(e_PLUGIN."calendar_menu/languages/".e_LANGUAGE.".php");
define("PAGE_NAME", EC_LAN_80);
include_lan(e_PLUGIN.'calendar_menu/languages/'.e_LANGUAGE.'.php');
define('PAGE_NAME', EC_LAN_80);
require_once(e_PLUGIN.'calendar_menu/ecal_class.php');
global $ecal_class;
if (!is_object($ecal_class)) $ecal_class = new ecal_class;
$cal_super = $ecal_class->cal_super;
require_once(e_PLUGIN."calendar_menu/calendar_shortcodes.php");
require_once(e_HANDLER."calendar/calendar_class.php");
e107::getScParser();
require_once(e_PLUGIN.'calendar_menu/calendar_shortcodes.php');
require_once(e_HANDLER.'calendar/calendar_class.php');
$cal = new DHTML_Calendar(true);
$cat_filter = intval(varset($_POST['event_cat_ids'],-1));
@@ -80,23 +86,23 @@ $ev_fields = array(
if ((isset($_POST['ne_insert']) || isset($_POST['ne_update'])) && ($cal_super || check_class($pref['eventpost_admin'])))
{
$ev_start = $ecal_class->make_date($_POST['ne_hour'], $_POST['ne_minute'],$_POST['start_date']);
if (($_POST['ne_event'] == "") || !isset($_POST['qs']))
if (($_POST['ne_event'] == '') || !isset($_POST['qs']))
{ // Problem - tell user to go away - fields are blank (mostly checked by JS)
header("location:event.php?".$ev_start.".0.m3");
header('location:event.php?'.$ev_start.'.0.m3');
}
elseif (!isset($_POST['ne_category']) || (intval($_POST['ne_category']) == 0))
{
header("location:event.php?".$ev_start.".0.m6");
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_title = $e107->tp->toDB($_POST['ne_title']);
$ev_location = $e107->tp->toDB($_POST['ne_location']);
$ev_event = $e107->tp->toDB($_POST['ne_event']);
$ev_email = $e107->tp -> toDB($_POST['ne_email']);
$ev_category = intval($_POST['ne_category']);
$ev_thread = $tp -> toDB($_POST['ne_thread']);
$ev_thread = $e107->tp->toDB($_POST['ne_thread']);
$temp_date = getdate($ecal_class->make_date(0,0,$_POST['start_date']));
$ev_allday = intval($_POST['allday']);
$recurring = intval($_POST['ec_recur_type']);
@@ -109,8 +115,8 @@ if ((isset($_POST['ne_insert']) || isset($_POST['ne_update'])) && ($cal_super |
}
else
{
$rec_m = "";
$rec_y = "";
$rec_m = '';
$rec_y = '';
}
$report_msg = '.m3';
@@ -151,14 +157,14 @@ if ((isset($_POST['ne_insert']) || isset($_POST['ne_update'])) && ($cal_super |
{
// 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);
header('location:event.php?'.$ev_start.'.'.$qs.$report_msg);
}
}
}
$action = ""; // Remove notice
$action = '';
require_once(HEADERF);
@@ -209,34 +215,43 @@ if ($mult_count > 1)
exit;
}
// Calculate any action, plus start date/number of events, from query
unset($dateArray);
if (isset($_POST['jump']))
{
$smarray = getdate(mktime(0, 0, 0, $_POST['jumpmonth'], 1, $_POST['jumpyear']));
$month = $smarray['mon'];
$year = $smarray['year'];
$dateArray = getdate(mktime(0, 0, 0, $_POST['jumpmonth'], 1, $_POST['jumpyear']));
}
else
{
if (e_QUERY)
{
$qs = explode(".", e_QUERY);
$action = $qs[0]; // Often a date if just viewing
$ds = varset($qs[1],"");
$eveid = varset($qs[2], "");
$qs = explode('.', e_QUERY);
$action = trim($qs[0]); // Often a date if just viewing
$ds = varset($qs[1],'');
$eveid = intval(varset($qs[2], 0));
}
if ($action == "")
if ($action == '')
{
$month = $ecal_class->cal_date['mon'];
$year = $ecal_class->cal_date['year'];
$dateArray = $ecal_class->cal_date; // Use todays date
}
else
{
if (is_numeric($action)) $smarray = getdate($action); else $smarray = getdate($ds);
$month = $smarray['mon'];
$year = $smarray['year'];
if (is_numeric($action))
{
$dateArray = getdate($action);
}
else
{
$dateArray = getdate($ds);
}
}
}
$dateArray['ds'] = $ds; // Way to pass to shortcodes.
$month = $dateArray['mon']; // Number of month being shown
$year = $dateArray['year']; // Number of year being shown
if ($cal_super || check_class($pref['eventpost_admin']))
@@ -253,7 +268,7 @@ if ($cal_super || check_class($pref['eventpost_admin']))
$wr_record = array();
foreach ($ev_fields as $k => $v)
{
$wr_record[$k] = $tp->toDB($_POST['ev_'.$k]);
$wr_record[$k] = $e107->tp->toDB($_POST['ev_'.$k]);
}
$wr_record['event_author'] = USERID.".".USERNAME;
$wr_record['event_datestamp'] = time();
@@ -323,11 +338,6 @@ if ($cal_super || check_class($pref['eventpost_admin']))
} // End - if ($cal_super)
// set up data arrays ----------------------------------------------------------------------------------
// (these used in the nav shortcodes)
$monthabb = Array(EC_LAN_JAN, EC_LAN_FEB, EC_LAN_MAR, EC_LAN_APR, EC_LAN_MAY, EC_LAN_JUN, EC_LAN_JUL, EC_LAN_AUG, EC_LAN_SEP, EC_LAN_OCT, EC_LAN_NOV, EC_LAN_DEC);
$months = array(EC_LAN_0, EC_LAN_1, EC_LAN_2, EC_LAN_3, EC_LAN_4, EC_LAN_5, EC_LAN_6, EC_LAN_7, EC_LAN_8, EC_LAN_9, EC_LAN_10, EC_LAN_11);
// ----------------------------------------------------------------------------------------------------------
// Messages acknowledging actions
$poss_message = array('m1' => EC_LAN_41, 'm2' => EC_LAN_42, 'm3' => EC_LAN_43, 'm4' => EC_LAN_44, 'm5' => EC_LAN_45,
@@ -339,6 +349,7 @@ if (isset($qs[2])) if (isset($poss_message[$qs[2]]))
if ($ec) $message = str_replace('-NUM-',$ec,$message);
}
if (isset($message))
{
$ns->tablerender("", "<div style='text-align:center'><b>".$message."</b></div>");
@@ -353,7 +364,7 @@ function merge_date_time($date, $time)
//-------------------------------------
// enter new event form
//-------------------------------------
if ($action == "ne" || $action == "ed")
if ($action == 'ne' || $action == 'ed')
{
if ($ecal_class->cal_super || check_class($pref['eventpost_admin']))
{
@@ -430,9 +441,21 @@ if ($action == "ne" || $action == "ed")
switch ($action)
{
case "ed" : // Editing existing event - read from database
$sql->db_Select("event", "*", "event_id='".intval($qs[1])."' ");
list($null, $ne_start, $ne_end, $allday, $recurring, $ne_datestamp, $ne_title, $ne_location, $ne_event, $ne_author, $ne_email, $ne_category, $ne_thread) = $sql->db_Fetch();
case 'ed' : // Editing existing event - read from database
$sql->db_Select('event', '*', 'event_id='.intval($qs[1]));
$row = $sql->db_Fetch(MYSQL_ASSOC);
$ne_start = $row['event_start'];
$ne_end = $row['event_end'];
$allday = $row['event_allday'];
$recurring = $row['event_recurring'];
$ne_datestamp = $row['event_datestamp'];
$ne_title = $row['event_title'];
$ne_location = $row['event_location'];
$ne_event = $row['event_details'];
$ne_author = $row['event_author'];
$ne_email = $row['event_contact'];
$ne_category = $row['event_category'];
$ne_thread = $row['event_thread'];
$smarray = $ecal_class->gmgetdate($ne_start);
$ne_hour = $smarray['hours'];
@@ -447,7 +470,7 @@ if ($action == "ne" || $action == "ed")
$caption = EC_LAN_66; // edit Event
break;
case "ne" : // New event - initialise everything
case 'ne' : // New event - initialise everything
$smarray = $ecal_class->gmgetdate($qs[1]);
$month = $smarray['mon'];
$year = $smarray['year'];
@@ -717,46 +740,6 @@ if ($action == "ne" || $action == "ed")
// show events
// $month, $year have the month required
//-----------------------------------------------
$monthstart = mktime(0, 0, 0, $month, 1, $year);
$firstdayarray = getdate($monthstart);
$monthend = mktime(0, 0, 0, $month + 1, 1, $year) -1 ;
$lastdayarray = getdate($monthend);
$prevmonth = ($month-1);
$prevyear = $year;
if ($prevmonth == 0)
{
$prevmonth = 12;
$prevyear = ($year-1);
}
$previous = mktime(0, 0, 0, $prevmonth, 1, $prevyear);
$nextmonth = ($month + 1);
$nextyear = $year;
if ($nextmonth == 13)
{
$nextmonth = 1;
$nextyear = ($year + 1);
}
if ($ds == 'one')
{
$prop = gmmktime(0, 0, 0, $month, $smarray['mday'], $year); // Sets start date for new event entry - exact day of month
}
else
{
$prop = gmmktime(0, 0, 0, $month, 1, $year); // Sets start date for new event entry - beginning of month
}
$next = mktime(0, 0, 0, $nextmonth, 1, $nextyear); // Used by nav buttons
$nowmonth = $ecal_class->cal_date['mon'];
$nowyear = $ecal_class->cal_date['year'];
$py = $year-1;
$prevlink = mktime(0, 0, 0, $month, 1, $py);
$ny = $year + 1;
$nextlink = mktime(0, 0, 0, $month, 1, $ny);
if (is_readable(THEME.'calendar_template.php'))
{ // Has to be require
require(THEME.'calendar_template.php');
@@ -766,12 +749,24 @@ else
require(e_PLUGIN.'calendar_menu/calendar_template.php');
}
setScVar('event_calendar_shortcodes', 'ecalClass', &$ecal_class); // Give shortcodes a pointer to calendar class
callScFunc('event_calendar_shortcodes','setCalDate', $dateArray); // Tell shortcodes the date to display
setScVar('event_calendar_shortcodes', 'catFilter', $cat_filter); // Category filter
setScVar('event_calendar_shortcodes', 'eventDisplayCodes', $EVENT_EVENT_DATETIME); // Templates for different event types
$monthstart = mktime(0, 0, 0, $month, 1, $year);
$monthend = mktime(0, 0, 0, $month + 1, 1, $year) -1 ;
$nowmonth = $ecal_class->cal_date['mon'];
$nowyear = $ecal_class->cal_date['year'];
$text2 = "";
// time switch buttons
$text2 .= $tp -> parseTemplate($CALENDAR_TIME_TABLE, FALSE, $calendar_shortcodes);
$text2 .= $e107->tp->parseTemplate($CALENDAR_TIME_TABLE, TRUE);
// navigation buttons
$text2 .= $tp -> parseTemplate($CALENDAR_NAVIGATION_TABLE, FALSE, $calendar_shortcodes);
$text2 .= $e107->tp->parseTemplate($CALENDAR_NAVIGATION_TABLE, TRUE);
// ****** CAUTION - the category dropdown also used $sql object - take care to avoid interference!
@@ -779,7 +774,7 @@ $text2 .= $tp -> parseTemplate($CALENDAR_NAVIGATION_TABLE, FALSE, $calendar_shor
$ev_list = array();
if ($ds == "event")
if ($ds == 'event')
{ // Show single event - bit of a special case
$ec_err = FALSE;
$qry = "
@@ -790,51 +785,49 @@ if ($ds == "event")
{$ecal_class->extra_query}
";
$sql2->db_Select_gen($qry);
$thisevent = $sql2->db_Fetch();
$thisEvent = $sql2->db_Fetch();
// Recurring events - $action has the actual date required (no time) - could be one of a potentially large number of dates it referred to
if ($thisevent['event_recurring']>='1') // Single event, selected by ID. So day/month must match
if ($thisEvent['event_recurring']>='1') // Single event, selected by ID. So day/month must match
{
$temp_arr = $ecal_class->gen_recur($thisevent['event_start'],$thisevent['event_end'],$thisevent['event_recurring'],$action,$action+86400); // Array of start times - hopefully just one!
$temp_arr = $ecal_class->gen_recur($thisEvent['event_start'],$thisEvent['event_end'],$thisEvent['event_recurring'],$action,$action+86400); // Array of start times - hopefully just one!
if (count($temp_arr) == 1)
{
$thisevent['event_start'] = $temp_arr[0];
$thisevent['event_end'] = merge_date_time($action,$thisevent['event_end']);
$thisEvent['event_start'] = $temp_arr[0];
$thisEvent['event_end'] = merge_date_time($action,$thisEvent['event_end']);
}
else
{ // Error
$ec_err = TRUE;
}
}
$next10_start = $thisevent['event_start'] +1;
$text2 .= $tp -> parseTemplate($EVENT_EVENT_TABLE_START, FALSE, $calendar_shortcodes);
if ($ec_err) $text2.= "Software Error<br />"; else $text2 .= $tp -> parseTemplate($EVENT_EVENT_TABLE, TRUE, $calendar_shortcodes);
$text2 .= $tp -> parseTemplate($EVENT_EVENT_TABLE_END, FALSE, $calendar_shortcodes);
$next10_start = $thisEvent['event_start'] +1;
setScVar('event_calendar_shortcodes', 'event', $thisEvent); // Give shortcodes the event data
$text2 .= $e107->tp->parseTemplate($EVENT_EVENT_TABLE_START, TRUE);
if ($ec_err) $text2.= "Software Error<br />"; else $text2 .= $e107->tp->parseTemplate($EVENT_EVENT_TABLE, TRUE);
$text2 .= $e107->tp->parseTemplate($EVENT_EVENT_TABLE_END, TRUE);
}
else
{
if ($ds == 'one')
{ // Show events from one day
$tmp = getdate($action);
$selected_day = $tmp['mday'];
$selected_mon = $tmp['mon'];
$start_time = $action;
// $tmp = getdate($action);
// $selected_day = $tmp['mday'];
// $selected_mon = $tmp['mon'];
$start_time = intval($action);
$end_time = $action + 86399;
$next10_start = $end_time + 1;
$cap_title = " - ".$months[$selected_mon-1]." ".$selected_day;
}
else
{ // Display whole of selected month
$start_time = $monthstart;
$end_time = $monthend;
$next10_start = $end_time + 1;
$cap_title = '';
}
// echo "Start: ".$start_time." End: ".$end_time." Cat_filter: ".$cat_filter."<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();
@@ -853,21 +846,22 @@ else
}
}
// Add a sort in here
// Add a sort in here - time/date order
ksort($tim_arr);
// display event list for current month
if(count($tim_arr))
{
$text2 .= $tp -> parseTemplate($EVENT_EVENTLIST_TABLE_START, FALSE, $calendar_shortcodes);
$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];
$text2 .= $tp -> parseTemplate($EVENT_EVENT_TABLE, TRUE, $calendar_shortcodes);
//$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 .= $tp -> parseTemplate($EVENT_EVENTLIST_TABLE_END, FALSE, $calendar_shortcodes);
$text2 .= $e107->tp->parseTemplate($EVENT_EVENTLIST_TABLE_END, TRUE);
}
}
@@ -881,25 +875,25 @@ $ev_list = $ecal_class->get_n_events(10, $next10_start, $next10_start+86400000,
$num = count($ev_list);
if ($num != 0)
{
$archive_events = "";
foreach ($ev_list as $thisevent)
setScVar('event_calendar_shortcodes', 'numEvents', $num); // Give shortcodes the number of events to expect
$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
{
$archive_events = $tp -> parseTemplate($EVENT_ARCHIVE_TABLE_EMPTY, FALSE, $calendar_shortcodes);
$archive_events = $e107->tp->parseTemplate($EVENT_ARCHIVE_TABLE_EMPTY, TRUE);
}
$text2 .= $tp -> parseTemplate($EVENT_ARCHIVE_TABLE_START, FALSE, $calendar_shortcodes);
$text2 .= $e107->tp->parseTemplate($EVENT_ARCHIVE_TABLE_START, TRUE);
$text2 .= $archive_events;
$text2 .= $tp -> parseTemplate($EVENT_ARCHIVE_TABLE_END, FALSE, $calendar_shortcodes);
$text2 .= $e107->tp->parseTemplate($EVENT_ARCHIVE_TABLE_END, TRUE);
$caption = EC_LAN_80; // "Event List";
$ns->tablerender($caption.(isset($cap_title) ? $cap_title : ""), $text2);
$e107->ns->tablerender($e107->tp->ParseTemplate('{EC_EVENT_PAGE_TITLE}'), $text2);
// Claim back memory no longer required
unset($ev_list);

View File

@@ -9,14 +9,14 @@
* These messages are for the 'user' pages of the event calendar (including event entry/editing)
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/languages/English.php,v $
* $Revision: 1.9 $
* $Date: 2009-11-18 02:03:35 $
* $Author: marj_nl_fr $
* $Revision: 1.10 $
* $Date: 2009-11-22 10:11:32 $
* $Author: e107steved $
*/
define('EC_ADLAN_1', "Event Calendar");
define('EC_ADLAN_2', "Configure Event Calendar");
define('EC_LAN_TODAY', "today");
define('EC_ADLAN_1', 'Event Calendar');
define('EC_ADLAN_2', 'Configure Event Calendar');
define('EC_LAN_TODAY', 'today');
define('EC_LAN_DAY_1', "1");
define('EC_LAN_DAY_2', "2");
@@ -184,7 +184,7 @@ define('EC_LAN_116', "Monday");
//define('EC_LAN_119', "month/year");
//define('EC_LAN_120', "year/month");
define('EC_LAN_121', "Show Calendar");
define('EC_LAN_122', 'Event information (single event)');
define('EC_LAN_123', "Subscriptions");
define('EC_LAN_124', "Calendar Subscriptions");
define('EC_LAN_125', "Categories available for subscription");
@@ -237,27 +237,53 @@ define('EC_LAN_171', "List including category");
define('EC_LAN_172', "Event Categories: ");
define('EC_LAN_173', "First event starts: ");
define('EC_LAN_174', "Last event ends: ");
define('EC_LAN_175', "All Day");
define('EC_LAN_175', 'All Day');
define('EC_LAN_176', "Recurring pattern: ");
define('EC_LAN_177', "Cancel Entry");
define('EC_LAN_178', "Accept Entries");
define('EC_LAN_179', "Confirmation of multiple event entry");
define('EC_LAN_180', " RECORDS NOT SAVED - DB UPDATE ERROR");
define('EC_LAN_180', 'RECORDS NOT SAVED - DB UPDATE ERROR');
define('EC_LAN_VIEWCALENDAR', "View Calendar");
define('EC_LAN_VIEWALLEVENTS', "View all events");
define('EC_LAN_VIEWCALENDAR', 'View Calendar');
define('EC_LAN_VIEWALLEVENTS', 'View all events');
define('EC_LAN_ALLEVENTS', "All events");
// Recurring events texts - the numeric part of each define is the internal value assigned
define('EC_LAN_RECUR_00', 'no');
define('EC_LAN_RECUR_01', 'annual');
define('EC_LAN_RECUR_02', 'biannual');
define('EC_LAN_RECUR_03', 'quarterly');
define('EC_LAN_RECUR_04', 'monthly');
define('EC_LAN_RECUR_05', 'four weekly');
define('EC_LAN_RECUR_06', 'fortnightly');
define('EC_LAN_RECUR_07', 'weekly');
define('EC_LAN_RECUR_08', 'daily');
define('EC_LAN_RECUR_100', 'Sunday in month');
define('EC_LAN_RECUR_101', 'Monday in month');
define('EC_LAN_RECUR_102', 'Tuesday in month');
define('EC_LAN_RECUR_103', 'Wednesday in month');
define('EC_LAN_RECUR_104', 'Thursday in month');
define('EC_LAN_RECUR_105', 'Friday in month');
define('EC_LAN_RECUR_106', 'Saturday in month');
define('EC_LAN_RECUR_1100', 'First');
define('EC_LAN_RECUR_1200', 'Second');
define('EC_LAN_RECUR_1300', 'Third');
define('EC_LAN_RECUR_1400', 'Fourth');
// Notify
define("NT_LAN_EC_1", "Event Calendar Events");
define("NT_LAN_EC_2", "Event Updated");
define("NT_LAN_EC_3", "Update by");
define("NT_LAN_EC_4", "IP Address");
define("NT_LAN_EC_5", "Message");
define("NT_LAN_EC_6", "Event Calendar - Event added");
define("NT_LAN_EC_7", "New event posted");
define("NT_LAN_EC_8", "Event Calendar - Event modified");
define('NT_LAN_EC_1', 'Event Calendar Events');
define('NT_LAN_EC_2', 'Event Updated');
define('NT_LAN_EC_3', 'Update by');
define('NT_LAN_EC_4', 'IP Address');
define('NT_LAN_EC_5', 'Message');
define('NT_LAN_EC_6', 'Event Calendar - Event added');
define('NT_LAN_EC_7', 'New event posted');
define('NT_LAN_EC_8', 'Event Calendar - Event modified');
// Prefs - language defines can be used in various places where text is set through the admin screens
define('EC_MAILOUT_SUBJECT', "Advice of calendar event"); // Use shortcode EC_MAIL_SUBJECT
?>

View File

@@ -9,9 +9,9 @@
* Messages for admin pages of event calendar
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/languages/English_admin_calendar_menu.php,v $
* $Revision: 1.2 $
* $Date: 2009-11-18 02:03:35 $
* $Author: marj_nl_fr $
* $Revision: 1.3 $
* $Date: 2009-11-22 10:11:32 $
* $Author: e107steved $
*/
define('EC_ADLAN_1', "Event Calendar");

View File

@@ -6,12 +6,12 @@
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Administration - Site Maintenance
* Event calendar - language file for mailout related routines
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/languages/English_mailer.php,v $
* $Revision: 1.3 $
* $Date: 2009-11-18 01:05:23 $
* $Author: e107coders $
* $Revision: 1.4 $
* $Date: 2009-11-22 10:11:32 $
* $Author: e107steved $
*
*/
@@ -21,10 +21,24 @@ define('LAN_EC_MAIL_03', 'Category: ');
define('LAN_EC_MAIL_04', 'Calendar Subscriptions');
define('LAN_EC_MAIL_05', 'Process notifications of events on the calendar');
define('LAN_EC_MAIL_06', 'Mail subscriptions run started at ');
define('LAN_EC_MAIL_07', '');
define('LAN_EC_MAIL_07', 'Event calendar mail --REF--');
define('LAN_EC_MAIL_08', '');
define('LAN_EC_MAIL_09', '');
define('LAN_EC_MAIL_10', '');
// Following messages used in mailout template
define('LAN_EC_MAIL_100', 'Location:');
define('LAN_EC_MAIL_101', 'Posted by:');
define('LAN_EC_MAIL_102', 'Contact:');
define('LAN_EC_MAIL_103', 'All day event:');
define('LAN_EC_MAIL_104', 'When:');
define('LAN_EC_MAIL_105', ' at ');
define('LAN_EC_MAIL_106', 'Ends:');
define('LAN_EC_MAIL_107', '');
define('LAN_EC_MAIL_108', '');
define('LAN_EC_MAIL_109', '');
define('LAN_EC_MAIL_110', '');
?>

View File

@@ -6,43 +6,38 @@
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*
* Forthcoming events menu handler for event calendar
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/next_event_menu.php,v $
* $Revision: 1.7 $
* $Date: 2009-11-18 01:05:23 $
* $Author: e107coders $
* $Revision: 1.8 $
* $Date: 2009-11-22 10:11:30 $
* $Author: e107steved $
*/
if (!defined('e107_INIT')) { exit; }
$e107 = e107::getInstance();
global $ecal_dir, $tp;
$ecal_dir = e_PLUGIN.'calendar_menu/';
if (!$e107->isInstalled('calendar_menu')) return '';
global $e107, $ecal_class, $calendar_shortcodes;
require_once($ecal_dir.'ecal_class.php');
if (!is_object($ecal_class)) $ecal_class = new ecal_class;
$cache_tag = 'nq_event_cal_next';
// See if the page is already in the cache
$cache_tag = 'nq_event_cal_next';
if($cacheData = $e107->ecache->retrieve($cache_tag, $ecal_class->max_cache_time))
{
echo $cacheData;
return;
}
if (!is_object($ecal_class))
{
require_once(e_PLUGIN.'calendar_menu/ecal_class.php');
$ecal_class = new ecal_class;
}
include_lan(e_PLUGIN.'calendar_menu/languages/'.e_LANGUAGE.'.php');
// Values defined through admin pages
$menu_title = varset($pref['eventpost_menuheading'],EC_LAN_140);
$days_ahead = varset($pref['eventpost_daysforward'],30); // Number of days ahead to go
$show_count = varset($pref['eventpost_numevents'],3); // Number of events to show
$show_recurring = varset($pref['eventpost_checkrecur'],1); // Zero to exclude recurring events
$link_in_heading = varset($pref['eventpost_linkheader'],0); // Zero for simple heading, 1 to have clickable link
require($ecal_dir.'calendar_shortcodes.php');
e107::getScParser();
require_once(e_PLUGIN.'calendar_menu/calendar_shortcodes.php');
if (is_readable(THEME.'calendar_template.php'))
{ // Has to be require
require(THEME.'calendar_template.php');
@@ -52,15 +47,25 @@ else
require(e_PLUGIN.'calendar_menu/calendar_template.php');
}
global $pref;
// Values defined through admin pages
$menu_title = varset($pref['eventpost_menuheading'],EC_LAN_140);
$days_ahead = varset($pref['eventpost_daysforward'],30); // Number of days ahead to go
$show_count = varset($pref['eventpost_numevents'],3); // Number of events to show
$show_recurring = varset($pref['eventpost_checkrecur'],1); // Zero to exclude recurring events
$link_in_heading = varset($pref['eventpost_linkheader'],0); // Zero for simple heading, 1 to have clickable link
$start_time = $ecal_class->cal_timedate;
$end_time = $start_time + (86400 * $days_ahead) - 1;
$cal_totev = 0;
$cal_text = '';
$cal_row = array();
global $cal_row, $cal_totev;
setScVar('event_calendar_shortcodes', 'ecalClass', &$ecal_class); // Give shortcodes a pointer to calendar class
//callScFunc('event_calendar_shortcodes','setCalDate', $dateArray); // Tell shortcodes the date to display
//setScVar('event_calendar_shortcodes', 'catFilter', $cat_filter); // Category filter
$ev_list = $ecal_class->get_n_events($show_count, $start_time, $end_time, varset($pref['eventpost_fe_set'],FALSE), $show_recurring,
'event_id,event_start, event_thread, event_title, event_recurring, event_allday, event_category', 'event_cat_icon');
@@ -68,10 +73,12 @@ $ev_list = $ecal_class->get_n_events($show_count, $start_time, $end_time, varset
$cal_totev = count($ev_list);
if ($cal_totev > 0)
{
foreach ($ev_list as $cal_row)
foreach ($ev_list as $thisEvent)
{
$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
@@ -80,7 +87,7 @@ else
$cal_text.= EC_LAN_141;
}
$calendar_title = $tp->toHTML($menu_title,FALSE,'TITLE'); // Allows multi-language title, shortcodes
$calendar_title = $e107->tp->toHTML($menu_title,FALSE,'TITLE'); // Allows multi-language title, shortcodes
if ($link_in_heading == 1)
{
$calendar_title = "<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
ob_start(); // Set up a new output buffer
$ns->tablerender($calendar_title, $cal_text, 'next_event_menu');
$e107->ns->tablerender($calendar_title, $cal_text, 'next_event_menu');
$cache_data = ob_get_flush(); // Get the page content, and display it
$e107->ecache->set($cache_tag, $cache_data); // Save to cache

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,19 +6,21 @@
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*
* Event calendar plugin - mail subscription to events notification
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/subscribe.php,v $
* $Revision: 1.6 $
* $Date: 2009-11-18 01:05:23 $
* $Author: e107coders $
* $Revision: 1.7 $
* $Date: 2009-11-22 10:11:31 $
* $Author: e107steved $
*/
require_once("../../class2.php");
if (!isset($pref['plug_installed']['calendar_menu'])) header("Location: ".e_BASE."index.php");
include_lan(e_PLUGIN . "calendar_menu/languages/".e_LANGUAGE.".php");
require_once('../../class2.php');
$e107 = e107::getInstance();
define("PAGE_NAME", EC_LAN_80);
if (!$e107->isInstalled('calendar_menu')) header('Location: '.e_BASE.'index.php');
include_lan(e_PLUGIN .'calendar_menu/languages/'.e_LANGUAGE.'.php');
global $pref;
define('PAGE_NAME', EC_LAN_80);
require_once(HEADERF);
@@ -28,15 +30,15 @@ $cal_db = new db; // Probably best to keep this
if (isset($_POST['upsubs']))
{
$cal_cats = $tp -> toDB($_POST['event_list']); // IDs of allowed categories
$cal_subs = $tp -> toDB($_POST['event_subd']); // Checkbox results
$cal_db->db_Delete("event_subs", "event_userid='" . USERID . "'"); // Delete all for this user to start
$cal_cats = $e107->tp->toDB($_POST['event_list']); // IDs of allowed categories
$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
foreach($cal_cats as $cal_row)
{ // Now add in a subscription for each allowed category
if ($cal_subs[$cal_row])
{
$cal_inargs = "0,'" . USERID . "','" . $cal_row . "'";
$cal_db->db_Insert("event_subs", $cal_inargs);
$cal_db->db_Insert('event_subs', $cal_inargs);
}
// print $cal_row . $cal_subs[$cal_row] . "<br />";
}
@@ -52,7 +54,7 @@ else
<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>";
// 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())
{
extract($cal_s);
@@ -96,7 +98,7 @@ else
else
$caltext = EC_LAN_143; // No facility
}
$ns->tablerender(EC_LAN_124, $caltext);
$e107->ns->tablerender(EC_LAN_124, $caltext);
require_once(FOOTERF);
?>