diff --git a/e107_plugins/calendar_menu/admin_config.php b/e107_plugins/calendar_menu/admin_config.php index 6c4c45f3b..2bf47a44e 100644 --- a/e107_plugins/calendar_menu/admin_config.php +++ b/e107_plugins/calendar_menu/admin_config.php @@ -1,1173 +1,1214 @@ - format, reads the $_POST variable of each name, applies the specified formatting, -// identifies changes, writes back the changes, makes admin log entry -function logPrefChanges(&$prefList, $logRef) -{ - global $admin_log; - $pref = e107::getPref(); - $tp = e107::getParser(); - $prefChanges = array(); - foreach ($prefList as $prefName => $process) - { - switch ($process) - { - case 0 : - $temp = varset($_POST[$prefName],''); - break; - case 1 : - $temp = intval(varset($_POST[$prefName],0)); - break; - case 2 : - $temp = $tp->toDB(varset($_POST[$prefName],'')); - break; - case 3 : // Array of integers - turn into comma-separated string - $tmp = array(); - foreach ($_POST[$prefName] as $v) - { - $tmp[] = intval($v); - } - $temp = implode(",", $tmp); - unset($tmp); - break; - } - if (!isset($pref[$prefName]) || ($temp != $pref[$prefName])) - { // Change to process - $pref[$prefName] = $temp; - $prefChanges[] = $prefName.' => '.$temp; - } - } - if (count($prefChanges)) - { - save_prefs(); - // Do admin logging - $logString = implode('[!br!]', $prefChanges); - $admin_log->log_event($logRef,$logString,''); - } -} - - -$prefSettings = array( - 'updateOptions' => array( - 'eventpost_admin' => 1, // Integer - 'eventpost_super' => 1, // Integer - 'eventpost_adminlog' => 1, // Integer - 'eventpost_menulink' => 1, // Integer - 'eventpost_showmouseover' => 1, // Integer - 'eventpost_showeventcount' => 1, // Integer - 'eventpost_forum' => 1, // Integer - 'eventpost_recentshow' => 2, // String ('LV' or an integer) - 'eventpost_weekstart' => 1, // Integer - 'eventpost_lenday' => 1, // Integer - 'eventpost_dateformat' => 2, // String ('my' or 'ym') - 'eventpost_datedisplay' => 1, // Integer - 'eventpost_fivemins' => 1, // Integer - 'eventpost_editmode' => 1, // Integer - 'eventpost_caltime' => 1, // Integer - 'eventpost_timedisplay' => 1, // Integer - 'eventpost_timecustom' => 2, // String - 'eventpost_dateevent' => 1, // Integer - 'eventpost_eventdatecustom' => 2, // String - 'eventpost_datenext' => 1, // Integer - 'eventpost_nextdatecustom' => 2, // String - 'eventpost_printlists' => 1, // Integer - 'eventpost_asubs' => 1, // Integer - 'eventpost_mailfrom' => 2, // String - 'eventpost_mailsubject' => 2, // String - 'eventpost_mailaddress' => 2, // String - 'eventpost_emaillog' => 1 // Integer - ), - 'updateForthcoming' => array( - 'eventpost_menuheading' => 2, // String - 'eventpost_daysforward' => 1, // Integer - 'eventpost_numevents' => 1, // Integer - 'eventpost_checkrecur' =>1, // Integer - 'eventpost_linkheader' => 1, // Integer - 'eventpost_fe_set' => 3, // Array of class values - 'eventpost_fe_hideifnone' => 1, // Integer - 'eventpost_fe_showrecent' => 1, // Integer - 'eventpost_showcaticon' => 1, // Integer - 'eventpost_namelink' => 1 // Integer - ) -); -if (isset($_POST['updatesettings'])) -{ - logPrefChanges(&$prefSettings['updateOptions'], 'EC_ADM_06'); - $e107cache->clear('nq_event_cal'); // Clear cache as well, in case displays changed - $message = EC_ADLAN_A204; // "Calendar settings updated."; -} - -// ****************** FORTHCOMING EVENTS ****************** -if (isset($_POST['updateforthcoming'])) -{ - logPrefChanges(&$prefSettings['updateForthcoming'], 'EC_ADM_07'); - $e107cache->clear('nq_event_cal'); // Clear cache as well, in case displays changed - $message = EC_ADLAN_A109; // "Forthcoming Events settings updated."; -} - -$action = 'config'; // Default action - show preferences -if (e_QUERY) -{ - $ec_qs = explode('.', e_QUERY); - $action = preg_replace('#\W#', '',$ec_qs[0]); -} - -require_once('ecal_class.php'); -global $ecal_class; -$ecal_class = new ecal_class; - - -// ****************** MAINTENANCE ****************** -if (isset($_POST['deleteold']) && isset($_POST['eventpost_deleteoldmonths'])) -{ - $back_count = intval($_POST['eventpost_deleteoldmonths']); - if (($back_count >= 1) && ($back_count <= 12)) - { - $old_date = intval(mktime(0,0,0,$ecal_class->now_date['mon']-$back_count,1,$ecal_class->now_date['year'])); - $old_string = strftime("%d %B %Y",$old_date); - // $message = "Back delete {$back_count} months. Oldest date = {$old_string}"; - $action = 'confdel'; - $ec_qs[1] = $old_date; - } - else - $message = EC_ADLAN_A148; -} - - -if (isset($_POST['cache_clear'])) -{ - $action = 'confcache'; -} - - -//------------------------------------------------- - -require_once(e_ADMIN.'auth.php'); - -if (!defined('USER_WIDTH')){ define('USER_WIDTH','width:auto'); } - - - -// Actually delete back events -if (isset($_POST['confirmdeleteold']) && ($action == 'backdel')) -{ - $old_date = intval($ec_qs[1]); - $old_string = strftime("%d %B %Y",$old_date); - // Check both start and end dates to avoid problems with events originally entered under 0.617 - $qry = "event_start < {$old_date} AND event_end < {$old_date} AND event_recurring = 0"; - // $message = "Back delete {$back_count} months. Oldest date = {$old_string} Query = {$qry}"; - if ($sql -> db_Delete('event',$qry)) - { - // Add in a log event - $ecal_class->cal_log(4,"db_Delete - earlier than {$old_string} (past {$back_count} months)",$qry); - $message = EC_ADLAN_A146.$old_string.EC_ADLAN_A147; - } - else - { - $message = EC_ADLAN_A149." : ".$sql->mySQLresult; - } - - $action = 'maint'; -} - - -// Actually empty cache -if (isset($_POST['confirmdelcache']) && ($action == 'cachedel')) -{ - $e107cache->clear('nq_event_cal'); - $message = EC_ADLAN_A163; - $action = 'maint'; // Re-display maintenance menu -} - - -// Prompt to delete back events -if ($action == 'confdel') -{ - $old_string = strftime("%d %B %Y",$ec_qs[1]); - $text = " -
- - - - -
".EC_ADLAN_A150.$old_string."
-
- ".$frm->admin_button('confirmdeleteold', EC_ADLAN_A205, 'delete')." -
-
- "; - - $ns->tablerender(EC_ADLAN_A205, $text); -} - - -// Prompt to clear cache -if ($action == 'confcache') -{ - $text = " -
- - - - -
".EC_ADLAN_A162."
-
- ".$frm->admin_button('confirmdelcache', EC_ADLAN_A205, 'delete')." - "; - - $ns->tablerender(EC_ADLAN_A205, $text); -} - - -// Just delete odd email subscriptions -if (isset($ec_qs[2]) && isset($ec_qs[3]) && ($action == 'subs') && ($ec_qs[2] == 'del') && is_numeric($ec_qs[3])) -{ - if ($sql->db_Delete('event_subs',"event_subid='{$ec_qs[3]}'")) - $message = EC_ADLAN_A180.$ec_qs[3]; - else - $message = EC_ADLAN_A181.$ec_qs[3]; -} - - -if (isset($message) && ($message != "")) -{ - $ns->tablerender('', "
{$message}
"); // TODO v2 style - $message = ''; -} - - - -//category -$ecal_send_email = 0; -if($action == 'cat') -{ -// This uses two hidden fields, preset from the category selection menu: -// calendarmenu_action -// 'update' - to create or update a record (actually save the info) -// 'dothings' - create/edit/delete just triggered - $calendarmenu_do = $_POST['calendarmenu_recdel']; has action 1, 2, 3 -// calendarmenu_id - the number of the category - zero indicates a new category -// We may also have $_POST['send_email_1'] or $_POST['send_email_2'] set to generate a test email as well as doing update/save - - 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'); - } - $calendarmenu_db = new DB; - $calendarmenu_action = ''; - if (isset($_POST['calendarmenu_action'])) $calendarmenu_action = $_POST['calendarmenu_action']; - $calendarmenu_edit = FALSE; - // * If we are updating then update or insert the record - if ($calendarmenu_action == 'update') - { - $calendarmenu_id = intval($_POST['calendarmenu_id']); - $calPars = array(); - $calPars['event_cat_name'] = $tp->toDB($_POST['event_cat_name']); - $calPars['event_cat_description'] = $tp->toDB($_POST['event_cat_description']); - $calPars['event_cat_icon'] = $tp->toDB($_POST['ne_new_category_icon']); - $calPars['event_cat_class'] = intval($_POST['event_cat_class']); - $calPars['event_cat_subs'] = intval($_POST['event_cat_subs']); - $calPars['event_cat_force_class'] = intval($_POST['event_cat_force_class']); - $calPars['event_cat_ahead'] = intval($_POST['event_cat_ahead']); - $calPars['event_cat_msg1'] = $tp->toDB($_POST['event_cat_msg1']); - $calPars['event_cat_msg2'] = $tp->toDB($_POST['event_cat_msg2']); - $calPars['event_cat_notify'] = intval($_POST['event_cat_notify']); - $calPars['event_cat_lastupdate'] = intval(time()); - $calPars['event_cat_addclass'] = intval($_POST['event_cat_addclass']); - if ($calendarmenu_id == 0) - { // New record so add it - if ($calendarmenu_db->db_Insert("event_cat", $calPars)) - { - $calendarmenu_msg .= "".EC_ADLAN_A26.""; - $admin_log->log_event(EC_ADM_08,$calPars['event_cat_name'],''); - } - else - { - $calendarmenu_msg .= "".EC_ADLAN_A27.""; - } - } - else - { // Update existing - if ($calendarmenu_db->db_UpdateArray("event_cat", $calPars, 'WHERE `event_cat_id` = '.$calendarmenu_id)) - { // Changes saved - $calendarmenu_msg .= "".EC_ADLAN_A28.""; - $admin_log->log_event(EC_ADM_09,'ID: '.$calendarmenu_id.', '.$calPars['event_cat_name'],''); - } - else - { - $calendarmenu_msg .= "".EC_ADLAN_A29.""; - } - } - // Now see if we need to send a test email - if (isset($_POST['send_email_1'])) $ecal_send_email = 1; - if (isset($_POST['send_email_2'])) $ecal_send_email = 2; - if ($ecal_send_email != 0) - { - $calendarmenu_action = 'dothings'; // This forces us back to category edit screen - $_POST['calendarmenu_selcat'] = $calendarmenu_id; // Record number to use - $_POST['calendarmenu_recdel'] = '1'; // This forces re-read of the record - } - } - - - // We are creating, editing or deleting a record - if ($calendarmenu_action == 'dothings') - { - $calendarmenu_id = intval($_POST['calendarmenu_selcat']); - $calendarmenu_do = intval($_POST['calendarmenu_recdel']); - $calendarmenu_dodel = false; - - switch ($calendarmenu_do) - { - case '1': // Edit existing record - // We edit the record - $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; - $calendarmenu_edit = TRUE; - if ($ecal_send_email != 0) - { // Need to send a test email - // 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_cat_name' => $event_cat_name, 'event_location' => EC_ADLAN_A192, - 'event_contact' => USEREMAIL, - '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'); - switch ($ecal_send_email) - { - case 1 : $cal_msg = $event_cat_msg1; - break; - case 2 : $cal_msg = $event_cat_msg2; - break; - } - $cal_msg = $tp -> parseTemplate($cal_msg, TRUE); - $cal_title = $tp -> parseTemplate($pref['eventpost_mailsubject'], TRUE); - $user_email = USEREMAIL; - $user_name = USERNAME; - $send_result = sendemail($user_email, $cal_title, $cal_msg, $user_name, $pref['eventpost_mailaddress'], $pref['eventpost_mailfrom']); - if ($send_result) - $calendarmenu_msg .= "".EC_ADLAN_A187.$ecal_send_email.""; - else - $calendarmenu_msg .= "".EC_ADLAN_A188.$ecal_send_email.""; - } - break; - - case '2': // New category - // Create new record - $calendarmenu_id = 0; - // set all fields to zero/blank - $calendar_category_name = ''; - $calendar_category_description = ''; - $calendarmenu_cap1 = EC_ADLAN_A23; - $calendarmenu_edit = TRUE; - $event_cat_name = ''; // Define some variables for notice removal - $event_cat_description = ''; - $event_cat_class = e_UC_MEMBER; - $event_cat_addclass = e_UC_ADMIN; - $event_cat_icon = ''; - $event_cat_subs = 0; - $event_cat_notify = 0; - $event_cat_force_class = ''; - $event_cat_ahead = 5; - $event_cat_msg1 = ''; - $event_cat_msg2 = ''; - break; - - case '3': // Delete record - if ($_POST['calendarmenu_okdel'] == '1') - { - if ($calendarmenu_db->db_Select('event', 'event_id', 'event_category='.$calendarmenu_id, 'nowhere')) - { - $calendarmenu_msg .= "".EC_ADLAN_A59.""; - } - else - { - if ($calendarmenu_db->db_Delete('event_cat', 'event_cat_id='.$calendarmenu_id)) - { - $admin_log->log_event(EC_ADM_10,'ID: '.$calendarmenu_id,''); - $calendarmenu_msg .= "".EC_ADLAN_A30.""; - } - else - { - $calendarmenu_msg .= "".EC_ADLAN_A32.""; - } - } - } - else - { - $calendarmenu_msg .= "".EC_ADLAN_A31.""; - } - $calendarmenu_dodel = TRUE; - $calendarmenu_edit = FALSE; - break; - } - - if (!$calendarmenu_dodel) - { - //require_once(e_HANDLER.'file_class.php'); - - $calendarmenu_text .= " -
-
- - - - - - - - - {$calendarmenu_msg} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{$calendarmenu_cap1} - - -
".EC_ADLAN_A21."
".EC_ADLAN_A121."
".EC_ADLAN_A80."".$uc->uc_dropdown('event_cat_class', $event_cat_class, 'public, nobody, member, admin, classes')."
".EC_ADLAN_A94."".$uc->uc_dropdown('event_cat_addclass', $event_cat_addclass, 'public, nobody, member, admin, classes')."
".EC_ADLAN_A219.""; - // - // - //
".EC_ADLAN_A81." 0?"checked='checked'":'')." />
".EC_ADLAN_A86." -
".EC_ADLAN_A82."".$uc->uc_dropdown('event_cat_force_class', $event_cat_force_class, 'nobody, member, admin, classes')."
".EC_ADLAN_A83."
".EC_ADLAN_A84; - if ($calendarmenu_do == 1) - $calendarmenu_text .= "


"; // TODO / FIX v2 style - $calendarmenu_text .= "
"; - if ($event_cat_name != EC_DEFAULT_CATEGORY) - $calendarmenu_text .= "
".EC_ADLAN_A189.""; - $calendarmenu_text .= " -
".EC_ADLAN_A117; - if ($calendarmenu_do == 1) - $calendarmenu_text .= "


"; // TODO / FIX v2 style - $calendarmenu_text .= "
"; - if ($event_cat_name != EC_DEFAULT_CATEGORY) - $calendarmenu_text .= "
".EC_ADLAN_A189.""; - $calendarmenu_text .= " -
-
- ".$frm->admin_button('submits', LAN_UPDATE, 'update')." -
-
-
"; - } - } - if (!$calendarmenu_edit) - { - // Get the category names to display in combo box then display actions available - $calendarmenu2_db = new DB; - $calendarmenu_catopt = ''; - if (!isset($calendarmenu_id)) $calendarmenu_id = -1; - if ($calendarmenu2_db->db_Select('event_cat', 'event_cat_id,event_cat_name', ' order by event_cat_name', 'nowhere')) - { - while ($row = $calendarmenu2_db->db_Fetch()) - { - $calendarmenu_catopt .= ""; - } - } - else - { - $calendarmenu_catopt .= ""; - } - - $calendarmenu_text .= " -
- - - {$calendarmenu_msg} - - - - - - - - -
".EC_ADLAN_A11."
".EC_ADLAN_A18." - ".EC_ADLAN_A13."
- ".EC_ADLAN_A14."
- ".EC_ADLAN_A15." - ".EC_ADLAN_A16." -
-
- ".$frm->admin_button('submits', EC_ADLAN_A17, 'submit')." -
-
"; - } - if(isset($calendarmenu_text)) - { - $ns->tablerender(EC_ADLAN_1." - ".EC_ADLAN_A19, $calendarmenu_text); - } -} - -// ==================================================== -// FORTHCOMING EVENTS OPTIONS -// ==================================================== - -if($action == 'forthcoming') -{ - - if (!isset($pref['eventpost_menuheading'])) $pref['eventpost_menuheading'] = EC_ADLAN_A100; - if (!isset($pref['eventpost_daysforward'])) $pref['eventpost_daysforward'] = 30; - if (!isset($pref['eventpost_numevents'])) $pref['eventpost_numevents'] = 3; - if (!isset($pref['eventpost_checkrecur'])) $pref['eventpost_checkrecur'] = '1'; - if (!isset($pref['eventpost_linkheader'])) $pref['eventpost_linkheader'] = '0'; - if (!isset($pref['eventpost_namelink'])) $pref['eventpost_namelink'] = '1'; - - $text = " -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
".EC_ADLAN_A108." -
".EC_ADLAN_A101." -
".EC_ADLAN_A102." -
".EC_ADLAN_A103."
".EC_ADLAN_A107."
".EC_ADLAN_A199."
".EC_ADLAN_A130."
- -
".EC_ADLAN_A104." -
".EC_ADLAN_A120." -
".EC_ADLAN_A118.""; - -// Now display all the current categories as checkboxes - $cal_fe_prefs = array(); - if (isset($pref['eventpost_fe_set'])) $cal_fe_prefs = array_flip(explode(",",$pref['eventpost_fe_set'])); - if (!isset($calendarmenu2_db) || !is_object($calendarmenu2_db)) $calendarmenu2_db = new DB; // Possible notice here - if ($calendarmenu2_db->db_Select("event_cat", "event_cat_id,event_cat_name", " WHERE (event_cat_name != '".EC_DEFAULT_CATEGORY."') order by event_cat_name", "nowhere")) - { - while ($row = $calendarmenu2_db->db_Fetch()) - { - $selected = isset($cal_fe_prefs[$row['event_cat_id']]); - $text .= "".$row['event_cat_name']."
"; - } - } - else - { - $text .= EC_ADLAN_A119; // No categories, or error - } - - $text .= "
-
- ".$frm->admin_button('updateforthcoming', LAN_UPDATE, 'update')." -
-
-
-
"; - - $ns->tablerender(EC_ADLAN_1." - ".EC_ADLAN_A100, $text); // TODO -} // End of Forthcoming Events Menu Options - - -// ==================================================== -// MAINTENANCE OPTIONS -// ==================================================== - -if(($action == 'maint')) -{ - $text = " -
-
- - - - - -
".EC_ADLAN_A142." - - ".EC_ADLAN_A143." -
-
- ".$frm->admin_button('deleteold', EC_ADLAN_A145, 'delete')." -
-
-
-

"; - - $ns->tablerender(EC_ADLAN_1." - ".EC_ADLAN_A141, $text); - - $text = " -
-
- - - - -
".EC_ADLAN_A160."
-
- ".$frm->admin_button('cache_clear', EC_ADLAN_A161, 'delete')." -
-
"; - - $ns->tablerender(EC_ADLAN_1." - ".EC_ADLAN_A159, $text); - -} - -// ==================================================== -// SUBSCRIPTIONS OPTIONS -// ==================================================== - -if($action == 'subs') -{ - $from = 0; - $amount = 20; // Number per page - could make configurable later if required - if (isset($ec_qs[1])) $from = intval($ec_qs[1]); - - $num_entry = $sql->db_Count("event_subs", "(*)", ""); // Just count the lot - - $qry = "SELECT es.*, u.user_id, u.user_name, u.user_class, ec.event_cat_id, ec.event_cat_name, ec.event_cat_class FROM `#event_subs` AS es - LEFT JOIN `#user` AS u ON es.event_userid = u.user_id - LEFT JOIN `#event_cat` AS ec ON es.event_cat = ec.event_cat_id - ORDER BY u.user_id - LIMIT {$from}, {$amount} "; - - $text = " -
-
- - - - - - - - "; - - if (!$sql->db_Select_gen($qry)) - { - $text .= ""; - $num_entry = 0; - } - else - { - $text .= " - '; - while ($row = $sql->db_Fetch()) - { - // Columns - UID, User name, Category name, Action - $problems = ""; - if (!isset($row['user_id']) || ($row['user_id'] == 0) || (!isset($row['user_name'])) || ($row['user_name'] == "")) - $problems = EC_ADLAN_A198; - if (!check_class($row['event_cat_class'],$row['user_class'])) - { - if ($problems != "") $problems .= "
"; - $problems .= EC_ADLAN_A197; - } - $text .= " - - - - - - - "; - } // End while // TODO / FIX admin_images to ad_links constant? - - // Next-Previous. ========================== - if ($num_entry > $amount) - { - $parms = "{$num_entry},{$amount},{$from},".e_SELF."?".$action.'.[FROM]'; - $text .= "'); - } - } - $text .= "
".EC_ADLAN_A174."
".EC_ADLAN_A175.''.EC_ADLAN_A176."".EC_ADLAN_A177."".EC_ADLAN_A178.''.EC_ADLAN_A179.'
".$row['user_id']."".$row['user_name']."".$row['event_cat_name']."".$problems." - ".LAN_DELETE."
".$tp->parseTemplate("{NEXTPREV={$parms}}".'
"; - - $text .= "   ".str_replace("--NUM--", $num_entry, EC_ADLAN_A182); - - $ns->tablerender(EC_ADLAN_1." - ".EC_ADLAN_A173, $text); -} - - - - -// ======================================================== -// MAIN OPTIONS MENU -// ======================================================== -if($action == 'config') -{ - function select_day_start($val) - { - if ($val == 'sun') $val = 0; elseif ($val == 'mon') $val = 1; // Legacy values - $ret = "\n"; - return $ret; - } - - - $text = " -
-
- - - - - - - - - - "; -$text .= " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
".EC_ADLAN_A208." ". $uc->uc_dropdown('eventpost_admin', $pref['eventpost_admin'], 'public, nobody, member, admin, classes')." -
".EC_ADLAN_A211." ". $uc->uc_dropdown('eventpost_super', $pref['eventpost_super'], 'public, nobody, member, admin, classes')." -
".EC_ADLAN_A134." - - ".EC_ADLAN_A137." -
".EC_ADLAN_A165." - -
".EC_ADLAN_A183." - ".EC_ADLAN_A184."
".EC_ADLAN_A140."
".EC_ADLAN_A213." - - ".EC_ADLAN_A22." -
".EC_ADLAN_A171." - ".EC_ADLAN_A172." -
".EC_ADLAN_A212."".select_day_start($pref['eventpost_weekstart'])."
".EC_ADLAN_A214."
- -
".EC_ADLAN_A215."
- -
".EC_ADLAN_A133."
- -
".EC_ADLAN_A138."  ".EC_ADLAN_A139." -
".EC_ADLAN_A200."
- -
".EC_ADLAN_A122."
- ".EC_ADLAN_A124."".$ecal_class->time_string($ecal_class->time_now)."
- ".EC_ADLAN_A125."".$ecal_class->time_string($ecal_class->site_timedate)."
- ".EC_ADLAN_A126."".$ecal_class->time_string($ecal_class->user_timedate)." -
-
".EC_ADLAN_A129." -
".EC_ADLAN_A123."
- ".EC_ADLAN_A127." -
- - -
".EC_ADLAN_A128." -
".EC_ADLAN_A166."
- ".EC_ADLAN_A169." -
- - -
".EC_ADLAN_A168." -
".EC_ADLAN_A167."
- ".EC_ADLAN_A170." -
- - -
".EC_ADLAN_A168." -
".EC_ADLAN_A193."
- -
".EC_ADLAN_A95."  ".EC_ADLAN_A96." -
".EC_ADLAN_A92." -
".EC_ADLAN_A91." -
".EC_ADLAN_A93." -
".EC_ADLAN_A114."
- -
-
- ".$frm->admin_button('updatesettings', LAN_UPDATE, 'update')." -
-
-
- "; - - $ns->tablerender(EC_ADLAN_1." - ".EC_ADLAN_A207, $text); -} - - -function admin_config_adminmenu() -{ - if (e_QUERY) { - $tmp = explode(".", e_QUERY); - $action = $tmp[0]; - } - if (!isset($action) || ($action == "")) - { - $action = "config"; - } - $var['config']['text'] = EC_ADLAN_A10; - $var['config']['link'] = "admin_config.php"; - - $var['cat']['text'] = EC_ADLAN_A11; - $var['cat']['link'] ="admin_config.php?cat"; - - $var['forthcoming']['text'] = EC_ADLAN_A100; - $var['forthcoming']['link'] ="admin_config.php?forthcoming"; - - $var['maint']['text'] = EC_ADLAN_A141; - $var['maint']['link'] ="admin_config.php?maint"; - - $var['subs']['text'] = EC_ADLAN_A173; - $var['subs']['link'] ="admin_config.php?subs"; - - show_admin_menu(EC_ADLAN_A12, $action, $var); -} - - -require_once(e_ADMIN."footer.php"); - + format, reads the $_POST variable of each name, applies the specified formatting, + * identifies changes, writes back the changes, makes admin log entry + * + * @param array $prefList - each key is the name of a pref; value is an integer representing its type + * @param array $oldPref - array of current pref values + * @param string $logRef - used as title if any changes to be logged + * + * @return - none + */ +function logPrefChanges(&$prefList, &$oldPref, $logRef) +{ + $admin_log = e107::getAdminLog(); + $calNew = e107::getPlugConfig('calendar_menu'); // Initialize calendar_menu prefs. + $tp = e107::getParser(); + $prefChanges = array(); + $mes = eMessage::getInstance(); + + foreach ($prefList as $prefName => $process) + { + switch ($process) + { + case 0 : + $temp = varset($_POST[$prefName],''); + break; + case 1 : + $temp = intval(varset($_POST[$prefName],0)); + break; + case 2 : + $temp = $tp->toDB(varset($_POST[$prefName],'')); + break; + case 3 : // Array of integers - turn into comma-separated string + $tmp = array(); + foreach ($_POST[$prefName] as $v) + { + $tmp[] = intval($v); + } + $temp = implode(",", $tmp); + unset($tmp); + break; + } + if (!isset($oldPref[$prefName]) || ($temp != $oldPref[$prefName])) + { // Change to process + $oldPref[$prefName] = $temp; + $calNew->set($prefName, $temp); + $prefChanges[] = $prefName.' => '.$temp; + } + } + if (count($prefChanges)) + { + $result = $calNew->save(); + if ($result === TRUE) + { + // Do admin logging + $logString = implode('[!br!]', $prefChanges); + $admin_log->log_event($logRef,$logString,''); + $mes->add('Calendar prefs updated', E_MESSAGE_SUCCESS); + } + elseif ($result === FALSE) + { + $mes->add('Error saving calendar prefs', E_MESSAGE_ERROR); + } + else + { // Should never happen + $mes->add('Unexpected result: '.$result, E_MESSAGE_INFO); + + } + } +} + + +$prefSettings = array( + 'updateOptions' => array( + 'eventpost_admin' => 1, // Integer + 'eventpost_super' => 1, // Integer + 'eventpost_adminlog' => 1, // Integer + 'eventpost_menulink' => 1, // Integer + 'eventpost_showmouseover' => 1, // Integer + 'eventpost_showeventcount' => 1, // Integer + 'eventpost_forum' => 1, // Integer + 'eventpost_recentshow' => 2, // String ('LV' or an integer) + 'eventpost_weekstart' => 1, // Integer + 'eventpost_lenday' => 1, // Integer + 'eventpost_dateformat' => 2, // String ('my' or 'ym') + 'eventpost_datedisplay' => 1, // Integer + 'eventpost_fivemins' => 1, // Integer + 'eventpost_editmode' => 1, // Integer + 'eventpost_caltime' => 1, // Integer + 'eventpost_timedisplay' => 1, // Integer + 'eventpost_timecustom' => 2, // String + 'eventpost_dateevent' => 1, // Integer + 'eventpost_eventdatecustom' => 2, // String + 'eventpost_datenext' => 1, // Integer + 'eventpost_nextdatecustom' => 2, // String + 'eventpost_printlists' => 1, // Integer + 'eventpost_asubs' => 1, // Integer + 'eventpost_mailfrom' => 2, // String + 'eventpost_mailsubject' => 2, // String + 'eventpost_mailaddress' => 2, // String + 'eventpost_emaillog' => 1 // Integer + ), + 'updateForthcoming' => array( + 'eventpost_menuheading' => 2, // String + 'eventpost_daysforward' => 1, // Integer + 'eventpost_numevents' => 1, // Integer + 'eventpost_checkrecur' =>1, // Integer + 'eventpost_linkheader' => 1, // Integer + 'eventpost_fe_set' => 3, // Array of class values + 'eventpost_fe_hideifnone' => 1, // Integer + 'eventpost_fe_showrecent' => 1, // Integer + 'eventpost_showcaticon' => 1, // Integer + 'eventpost_namelink' => 1 // Integer + ) +); +if (isset($_POST['updatesettings'])) +{ + logPrefChanges($prefSettings['updateOptions'], $calPref, 'EC_ADM_06'); + $e107cache->clear('nq_event_cal'); // Clear cache as well, in case displays changed + $message = EC_ADLAN_A204; // "Calendar settings updated."; +} + + +// ****************** FORTHCOMING EVENTS ****************** +if (isset($_POST['updateforthcoming'])) +{ + logPrefChanges($prefSettings['updateForthcoming'], $calPref, 'EC_ADM_07'); + $e107cache->clear('nq_event_cal'); // Clear cache as well, in case displays changed + $message = EC_ADLAN_A109; // "Forthcoming Events settings updated."; +} + + +$action = 'config'; // Default action - show preferences +if (e_QUERY) +{ + $ec_qs = explode('.', e_QUERY); + $action = preg_replace('#\W#', '',$ec_qs[0]); +} + +require_once('ecal_class.php'); +$ecal_class = new ecal_class; + + +// ****************** MAINTENANCE ****************** +if (isset($_POST['deleteold']) && isset($_POST['eventpost_deleteoldmonths'])) +{ + $back_count = intval($_POST['eventpost_deleteoldmonths']); + if (($back_count >= 1) && ($back_count <= 12)) + { + $old_date = intval(mktime(0,0,0,$ecal_class->now_date['mon']-$back_count,1,$ecal_class->now_date['year'])); + $old_string = strftime("%d %B %Y",$old_date); + // $message = "Back delete {$back_count} months. Oldest date = {$old_string}"; + $action = 'confdel'; + $ec_qs[1] = $old_date; + } + else + $message = EC_ADLAN_A148; +} + + +if (isset($_POST['cache_clear'])) +{ + $action = 'confcache'; +} + + +//------------------------------------------------- + +require_once(e_ADMIN.'auth.php'); + +if (!defined('USER_WIDTH')){ define('USER_WIDTH','width:auto'); } + + + +// Actually delete back events +if (isset($_POST['confirmdeleteold']) && ($action == 'backdel')) +{ + $old_date = intval($ec_qs[1]); + $old_string = strftime("%d %B %Y",$old_date); + // Check both start and end dates to avoid problems with events originally entered under 0.617 + $qry = "event_start < {$old_date} AND event_end < {$old_date} AND event_recurring = 0"; + // $message = "Back delete {$back_count} months. Oldest date = {$old_string} Query = {$qry}"; + if ($sql -> db_Delete('event',$qry)) + { + // Add in a log event + $ecal_class->cal_log(4,"db_Delete - earlier than {$old_string} (past {$back_count} months)",$qry); + $message = EC_ADLAN_A146.$old_string.EC_ADLAN_A147; + } + else + { + $message = EC_ADLAN_A149." : ".$sql->mySQLresult; + } + + $action = 'maint'; +} + + +// Actually empty cache +if (isset($_POST['confirmdelcache']) && ($action == 'cachedel')) +{ + $e107cache->clear('nq_event_cal'); + $message = EC_ADLAN_A163; + $action = 'maint'; // Re-display maintenance menu +} + + +// Prompt to delete back events +if ($action == 'confdel') +{ + $old_string = strftime("%d %B %Y",$ec_qs[1]); + $text = " +
+ + + + +
".EC_ADLAN_A150.$old_string."
+
+ ".$frm->admin_button('confirmdeleteold', EC_ADLAN_A205, 'delete')." +
+
+ "; + + $ns->tablerender(EC_ADLAN_A205, $text); +} + + +// Prompt to clear cache +if ($action == 'confcache') +{ + $text = " +
+ + + + +
".EC_ADLAN_A162."
+
+ ".$frm->admin_button('confirmdelcache', EC_ADLAN_A205, 'delete')." + "; + + $ns->tablerender(EC_ADLAN_A205, $text); +} + + +// Just delete odd email subscriptions +if (isset($ec_qs[2]) && isset($ec_qs[3]) && ($action == 'subs') && ($ec_qs[2] == 'del') && is_numeric($ec_qs[3])) +{ + if ($sql->db_Delete('event_subs',"event_subid='{$ec_qs[3]}'")) + $message = EC_ADLAN_A180.$ec_qs[3]; + else + $message = EC_ADLAN_A181.$ec_qs[3]; +} + + +if (isset($message) && ($message != "")) +{ + $ns->tablerender('', "
{$message}
"); // TODO v2 style + $message = ''; +} + + + +//category +$ecal_send_email = 0; +if($action == 'cat') +{ +// This uses two hidden fields, preset from the category selection menu: +// calendarmenu_action +// 'update' - to create or update a record (actually save the info) +// 'dothings' - create/edit/delete just triggered - $calendarmenu_do = $_POST['calendarmenu_recdel']; has action 1, 2, 3 +// calendarmenu_id - the number of the category - zero indicates a new category +// We may also have $_POST['send_email_1'] or $_POST['send_email_2'] set to generate a test email as well as doing update/save + + 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'); + } + $calendarmenu_db = new DB; + $calendarmenu_action = ''; + if (isset($_POST['calendarmenu_action'])) $calendarmenu_action = $_POST['calendarmenu_action']; + $calendarmenu_edit = FALSE; + // * If we are updating then update or insert the record + if ($calendarmenu_action == 'update') + { + $calendarmenu_id = intval($_POST['calendarmenu_id']); + $calPars = array(); + $calPars['event_cat_name'] = $tp->toDB($_POST['event_cat_name']); + $calPars['event_cat_description'] = $tp->toDB($_POST['event_cat_description']); + $calPars['event_cat_icon'] = $tp->toDB($_POST['ne_new_category_icon']); + $calPars['event_cat_class'] = intval($_POST['event_cat_class']); + $calPars['event_cat_subs'] = intval($_POST['event_cat_subs']); + $calPars['event_cat_force_class'] = intval($_POST['event_cat_force_class']); + $calPars['event_cat_ahead'] = intval($_POST['event_cat_ahead']); + $calPars['event_cat_msg1'] = $tp->toDB($_POST['event_cat_msg1']); + $calPars['event_cat_msg2'] = $tp->toDB($_POST['event_cat_msg2']); + $calPars['event_cat_notify'] = intval($_POST['event_cat_notify']); + $calPars['event_cat_lastupdate'] = intval(time()); + $calPars['event_cat_addclass'] = intval($_POST['event_cat_addclass']); + if ($calendarmenu_id == 0) + { // New record so add it + if ($calendarmenu_db->db_Insert("event_cat", $calPars)) + { + $calendarmenu_msg .= "".EC_ADLAN_A26.""; + $admin_log->log_event(EC_ADM_08,$calPars['event_cat_name'],''); + } + else + { + $calendarmenu_msg .= "".EC_ADLAN_A27.""; + } + } + else + { // Update existing + if ($calendarmenu_db->db_UpdateArray("event_cat", $calPars, 'WHERE `event_cat_id` = '.$calendarmenu_id)) + { // Changes saved + $calendarmenu_msg .= "".EC_ADLAN_A28.""; + $admin_log->log_event(EC_ADM_09,'ID: '.$calendarmenu_id.', '.$calPars['event_cat_name'],''); + } + else + { + $calendarmenu_msg .= "".EC_ADLAN_A29.""; + } + } + // Now see if we need to send a test email + if (isset($_POST['send_email_1'])) $ecal_send_email = 1; + if (isset($_POST['send_email_2'])) $ecal_send_email = 2; + if ($ecal_send_email != 0) + { + $calendarmenu_action = 'dothings'; // This forces us back to category edit screen + $_POST['calendarmenu_selcat'] = $calendarmenu_id; // Record number to use + $_POST['calendarmenu_recdel'] = '1'; // This forces re-read of the record + } + } + + + // We are creating, editing or deleting a record + if ($calendarmenu_action == 'dothings') + { + $calendarmenu_id = intval($_POST['calendarmenu_selcat']); + $calendarmenu_do = intval($_POST['calendarmenu_recdel']); + $calendarmenu_dodel = false; + + switch ($calendarmenu_do) + { + case '1': // Edit existing record + // We edit the record + $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; + $calendarmenu_edit = TRUE; + if ($ecal_send_email != 0) + { // Need to send a test email + // First, set up a dummy event + $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_cat_name' => $event_cat_name, 'event_location' => EC_ADLAN_A192, + 'event_contact' => USEREMAIL, + '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'); + switch ($ecal_send_email) + { + case 1 : $cal_msg = $event_cat_msg1; + break; + case 2 : $cal_msg = $event_cat_msg2; + break; + } + $cal_msg = $tp -> parseTemplate($cal_msg, TRUE); + $cal_title = $tp -> parseTemplate($calPref['eventpost_mailsubject'], TRUE); + $user_email = USEREMAIL; + $user_name = USERNAME; + $send_result = sendemail($user_email, $cal_title, $cal_msg, $user_name, $calPref['eventpost_mailaddress'], $calPref['eventpost_mailfrom']); + if ($send_result) + $calendarmenu_msg .= "".EC_ADLAN_A187.$ecal_send_email.""; + else + $calendarmenu_msg .= "".EC_ADLAN_A188.$ecal_send_email.""; + } + break; + + case '2': // New category + // Create new record + $calendarmenu_id = 0; + // set all fields to zero/blank + $calendar_category_name = ''; + $calendar_category_description = ''; + $calendarmenu_cap1 = EC_ADLAN_A23; + $calendarmenu_edit = TRUE; + $event_cat_name = ''; // Define some variables for notice removal + $event_cat_description = ''; + $event_cat_class = e_UC_MEMBER; + $event_cat_addclass = e_UC_ADMIN; + $event_cat_icon = ''; + $event_cat_subs = 0; + $event_cat_notify = 0; + $event_cat_force_class = ''; + $event_cat_ahead = 5; + $event_cat_msg1 = ''; + $event_cat_msg2 = ''; + break; + + case '3': // Delete record + if ($_POST['calendarmenu_okdel'] == '1') + { + if ($calendarmenu_db->db_Select('event', 'event_id', 'event_category='.$calendarmenu_id, 'nowhere')) + { + $calendarmenu_msg .= "".EC_ADLAN_A59.""; + } + else + { + if ($calendarmenu_db->db_Delete('event_cat', 'event_cat_id='.$calendarmenu_id)) + { + $admin_log->log_event(EC_ADM_10,'ID: '.$calendarmenu_id,''); + $calendarmenu_msg .= "".EC_ADLAN_A30.""; + } + else + { + $calendarmenu_msg .= "".EC_ADLAN_A32.""; + } + } + } + else + { + $calendarmenu_msg .= "".EC_ADLAN_A31.""; + } + $calendarmenu_dodel = TRUE; + $calendarmenu_edit = FALSE; + break; + } + + if (!$calendarmenu_dodel) + { + //require_once(e_HANDLER.'file_class.php'); + + $calendarmenu_text .= " +
+
+ + + + + + + + + {$calendarmenu_msg} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{$calendarmenu_cap1} + + +
".EC_ADLAN_A21."
".EC_ADLAN_A121."
".EC_ADLAN_A80."".$uc->uc_dropdown('event_cat_class', $event_cat_class, 'public, nobody, member, admin, classes')."
".EC_ADLAN_A94."".$uc->uc_dropdown('event_cat_addclass', $event_cat_addclass, 'public, nobody, member, admin, classes')."
".EC_ADLAN_A219.""; + // + // + //
".EC_ADLAN_A81." 0?"checked='checked'":'')." />
".EC_ADLAN_A86." +
".EC_ADLAN_A82."".$uc->uc_dropdown('event_cat_force_class', $event_cat_force_class, 'nobody, member, admin, classes')."
".EC_ADLAN_A83."
".EC_ADLAN_A84; + if ($calendarmenu_do == 1) + $calendarmenu_text .= "


"; // TODO / FIX v2 style + $calendarmenu_text .= "
"; + if ($event_cat_name != EC_DEFAULT_CATEGORY) + $calendarmenu_text .= "
".EC_ADLAN_A189.""; + $calendarmenu_text .= " +
".EC_ADLAN_A117; + if ($calendarmenu_do == 1) + $calendarmenu_text .= "


"; // TODO / FIX v2 style + $calendarmenu_text .= "
"; + if ($event_cat_name != EC_DEFAULT_CATEGORY) + $calendarmenu_text .= "
".EC_ADLAN_A189.""; + $calendarmenu_text .= " +
+
+ ".$frm->admin_button('submits', LAN_UPDATE, 'update')." +
+
+
"; + } + } + if (!$calendarmenu_edit) + { + // Get the category names to display in combo box then display actions available + $calendarmenu2_db = new DB; + $calendarmenu_catopt = ''; + if (!isset($calendarmenu_id)) $calendarmenu_id = -1; + if ($calendarmenu2_db->db_Select('event_cat', 'event_cat_id,event_cat_name', ' order by event_cat_name', 'nowhere')) + { + while ($row = $calendarmenu2_db->db_Fetch()) + { + $calendarmenu_catopt .= ""; + } + } + else + { + $calendarmenu_catopt .= ""; + } + + $emessage = eMessage::getInstance(); + echo $emessage->render().$text; + + $calendarmenu_text .= " +
+ + + {$calendarmenu_msg} + + + + + + + + +
".EC_ADLAN_A11."
".EC_ADLAN_A18." + ".EC_ADLAN_A13."
+ ".EC_ADLAN_A14."
+ ".EC_ADLAN_A15." + ".EC_ADLAN_A16." +
+
+ ".$frm->admin_button('submits', EC_ADLAN_A17, 'submit')." +
+
"; + } + if(isset($calendarmenu_text)) + { + $ns->tablerender(EC_ADLAN_1." - ".EC_ADLAN_A19, $calendarmenu_text); + } +} + +// ==================================================== +// FORTHCOMING EVENTS OPTIONS +// ==================================================== + +if($action == 'forthcoming') +{ + + if (!isset($calPref['eventpost_menuheading'])) $calPref['eventpost_menuheading'] = EC_ADLAN_A100; + if (!isset($calPref['eventpost_daysforward'])) $calPref['eventpost_daysforward'] = 30; + if (!isset($calPref['eventpost_numevents'])) $calPref['eventpost_numevents'] = 3; + if (!isset($calPref['eventpost_checkrecur'])) $calPref['eventpost_checkrecur'] = '1'; + if (!isset($calPref['eventpost_linkheader'])) $calPref['eventpost_linkheader'] = '0'; + if (!isset($calPref['eventpost_namelink'])) $calPref['eventpost_namelink'] = '1'; + + $emessage = eMessage::getInstance(); + echo $emessage->render().$text; + + $text = " +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
".EC_ADLAN_A108." +
".EC_ADLAN_A101." +
".EC_ADLAN_A102." +
".EC_ADLAN_A103."
".EC_ADLAN_A107."
".EC_ADLAN_A199."
".EC_ADLAN_A130."
+ +
".EC_ADLAN_A104." +
".EC_ADLAN_A120." +
".EC_ADLAN_A118.""; + +// Now display all the current categories as checkboxes + $cal_fe_prefs = array(); + if (isset($calPref['eventpost_fe_set'])) $cal_fe_prefs = array_flip(explode(",",$calPref['eventpost_fe_set'])); + if (!isset($calendarmenu2_db) || !is_object($calendarmenu2_db)) $calendarmenu2_db = new DB; // Possible notice here + if ($calendarmenu2_db->db_Select("event_cat", "event_cat_id,event_cat_name", " WHERE (event_cat_name != '".EC_DEFAULT_CATEGORY."') order by event_cat_name", "nowhere")) + { + while ($row = $calendarmenu2_db->db_Fetch()) + { + $selected = isset($cal_fe_prefs[$row['event_cat_id']]); + $text .= "".$row['event_cat_name']."
"; + } + } + else + { + $text .= EC_ADLAN_A119; // No categories, or error + } + + $text .= "
+
+ ".$frm->admin_button('updateforthcoming', LAN_UPDATE, 'update')." +
+
+
+
"; + + $ns->tablerender(EC_ADLAN_1." - ".EC_ADLAN_A100, $text); // TODO +} // End of Forthcoming Events Menu Options + + +// ==================================================== +// MAINTENANCE OPTIONS +// ==================================================== + +if(($action == 'maint')) +{ + $emessage = eMessage::getInstance(); + echo $emessage->render().$text; + + $text = " +
+
+ + + + + +
".EC_ADLAN_A142." + + ".EC_ADLAN_A143." +
+
+ ".$frm->admin_button('deleteold', EC_ADLAN_A145, 'delete')." +
+
+
+

"; + + $ns->tablerender(EC_ADLAN_1." - ".EC_ADLAN_A141, $text); + + $text = " +
+
+ + + + +
".EC_ADLAN_A160."
+
+ ".$frm->admin_button('cache_clear', EC_ADLAN_A161, 'delete')." +
+
"; + + $ns->tablerender(EC_ADLAN_1." - ".EC_ADLAN_A159, $text); + +} + +// ==================================================== +// SUBSCRIPTIONS OPTIONS +// ==================================================== + +if($action == 'subs') +{ + $emessage = eMessage::getInstance(); + echo $emessage->render().$text; + + $from = 0; + $amount = 20; // Number per page - could make configurable later if required + if (isset($ec_qs[1])) $from = intval($ec_qs[1]); + + $num_entry = $sql->db_Count("event_subs", "(*)", ""); // Just count the lot + + $qry = "SELECT es.*, u.user_id, u.user_name, u.user_class, ec.event_cat_id, ec.event_cat_name, ec.event_cat_class FROM `#event_subs` AS es + LEFT JOIN `#user` AS u ON es.event_userid = u.user_id + LEFT JOIN `#event_cat` AS ec ON es.event_cat = ec.event_cat_id + ORDER BY u.user_id + LIMIT {$from}, {$amount} "; + + $text = " +
+
+ + + + + + + + "; + + if (!$sql->db_Select_gen($qry)) + { + $text .= ""; + $num_entry = 0; + } + else + { + $text .= " + '; + while ($row = $sql->db_Fetch()) + { + // Columns - UID, User name, Category name, Action + $problems = ""; + if (!isset($row['user_id']) || ($row['user_id'] == 0) || (!isset($row['user_name'])) || ($row['user_name'] == "")) + $problems = EC_ADLAN_A198; + if (!check_class($row['event_cat_class'],$row['user_class'])) + { + if ($problems != "") $problems .= "
"; + $problems .= EC_ADLAN_A197; + } + $text .= " + + + + + + + "; + } // End while // TODO / FIX admin_images to ad_links constant? + + // Next-Previous. ========================== + if ($num_entry > $amount) + { + $parms = "{$num_entry},{$amount},{$from},".e_SELF."?".$action.'.[FROM]'; + $text .= "'); + } + } + $text .= "
".EC_ADLAN_A174."
".EC_ADLAN_A175.''.EC_ADLAN_A176."".EC_ADLAN_A177."".EC_ADLAN_A178.''.EC_ADLAN_A179.'
".$row['user_id']."".$row['user_name']."".$row['event_cat_name']."".$problems." + ".LAN_DELETE."
".$tp->parseTemplate("{NEXTPREV={$parms}}".'
"; + + $text .= "   ".str_replace("--NUM--", $num_entry, EC_ADLAN_A182); + + $ns->tablerender(EC_ADLAN_1." - ".EC_ADLAN_A173, $text); +} + + + + +// ======================================================== +// MAIN OPTIONS MENU +// ======================================================== +if($action == 'config') +{ + function select_day_start($val) + { + if ($val == 'sun') $val = 0; elseif ($val == 'mon') $val = 1; // Legacy values + $ret = "\n"; + return $ret; + } + + $emessage = eMessage::getInstance(); + echo $emessage->render().$text; + + $text = " +
+
+ + + + + + + + + + "; +$text .= " + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
".EC_ADLAN_A208." ". $uc->uc_dropdown('eventpost_admin', $calPref['eventpost_admin'], 'public, nobody, member, admin, classes')." +
".EC_ADLAN_A211." ". $uc->uc_dropdown('eventpost_super', $calPref['eventpost_super'], 'public, nobody, member, admin, classes')." +
".EC_ADLAN_A134." + + ".EC_ADLAN_A137." +
".EC_ADLAN_A165." + +
".EC_ADLAN_A183." + ".EC_ADLAN_A184."
".EC_ADLAN_A140."
".EC_ADLAN_A213." + + ".EC_ADLAN_A22." +
".EC_ADLAN_A171." + ".EC_ADLAN_A172." +
".EC_ADLAN_A212."".select_day_start($calPref['eventpost_weekstart'])."
".EC_ADLAN_A214."
+ +
".EC_ADLAN_A215."
+ +
".EC_ADLAN_A133."
+ +
".EC_ADLAN_A138."  ".EC_ADLAN_A139." +
".EC_ADLAN_A200."
+ +
".EC_ADLAN_A122."
+ ".EC_ADLAN_A124."".$ecal_class->time_string($ecal_class->time_now)."
+ ".EC_ADLAN_A125."".$ecal_class->time_string($ecal_class->site_timedate)."
+ ".EC_ADLAN_A126."".$ecal_class->time_string($ecal_class->user_timedate)." +
+
".EC_ADLAN_A129." +
".EC_ADLAN_A123."
+ ".EC_ADLAN_A127." +
+ + +
".EC_ADLAN_A128." +
".EC_ADLAN_A166."
+ ".EC_ADLAN_A169." +
+ + +
".EC_ADLAN_A168." +
".EC_ADLAN_A167."
+ ".EC_ADLAN_A170." +
+ + +
".EC_ADLAN_A168." +
".EC_ADLAN_A193."
+ +
".EC_ADLAN_A95."  ".EC_ADLAN_A96." +
".EC_ADLAN_A92." +
".EC_ADLAN_A91." +
".EC_ADLAN_A93." +
".EC_ADLAN_A114."
+ +
+
+ ".$frm->admin_button('updatesettings', LAN_UPDATE, 'update')." +
+
+
+ "; + + $ns->tablerender(EC_ADLAN_1." - ".EC_ADLAN_A207, $text); +} + + +function admin_config_adminmenu() +{ + if (e_QUERY) { + $tmp = explode(".", e_QUERY); + $action = $tmp[0]; + } + if (!isset($action) || ($action == "")) + { + $action = "config"; + } + $var['config']['text'] = EC_ADLAN_A10; + $var['config']['link'] = "admin_config.php"; + + $var['cat']['text'] = EC_ADLAN_A11; + $var['cat']['link'] ="admin_config.php?cat"; + + $var['forthcoming']['text'] = EC_ADLAN_A100; + $var['forthcoming']['link'] ="admin_config.php?forthcoming"; + + $var['maint']['text'] = EC_ADLAN_A141; + $var['maint']['link'] ="admin_config.php?maint"; + + $var['subs']['text'] = EC_ADLAN_A173; + $var['subs']['link'] ="admin_config.php?subs"; + + show_admin_menu(EC_ADLAN_A12, $action, $var); +} + + +require_once(e_ADMIN."footer.php"); + ?> \ No newline at end of file diff --git a/e107_plugins/calendar_menu/calendar.php b/e107_plugins/calendar_menu/calendar.php index a2db9bb5d..2d9003618 100644 --- a/e107_plugins/calendar_menu/calendar.php +++ b/e107_plugins/calendar_menu/calendar.php @@ -2,7 +2,7 @@ /* * e107 website system * - * Copyright (C) 2008-2009 e107 Inc (e107.org) + * Copyright (C) 2008-2013 e107 Inc (e107.org) * Released under the terms and conditions of the * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * @@ -17,6 +17,8 @@ /** * e107 Event calendar plugin * + * Event calendar plugin - large calendar display + * * @package e107_plugins * @subpackage event_calendar * @version $Id$; @@ -47,7 +49,7 @@ if (isset($_POST['printlists'])) exit(); } -//e107::getScParser(); + require_once(e_PLUGIN.'calendar_menu/calendar_shortcodes.php'); $calSc = new event_calendar_shortcodes(); @@ -102,10 +104,6 @@ $calSc->ecalClass = &$ecal_class; $calSc->setCalDate($dateArray); $calSc->catFilter = $cat_filter; -//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 - //------------------------------------------------- // Start calculating text to display @@ -191,7 +189,6 @@ $text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_HEADER_START, FALSE, $calSc for ($i = 0; $i < 7; $i++) { $calSc->headerDay = $ecal_class->day_offset_string($i); - //setScVar('event_calendar_shortcodes', 'headerDay', $ecal_class->day_offset_string($i)); $text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_HEADER, FALSE, $calSc); } $text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_HEADER_END, FALSE, $calSc); @@ -212,8 +209,6 @@ for ($c = 1; $c <= $numberdays; $c++) { // Loop through the number of days in this month $calSc->todayStart = $start; // Start of current day $calSc->curDay = $c; // Current day of month - //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 @@ -232,24 +227,24 @@ for ($c = 1; $c <= $numberdays; $c++) } if ($got_ev) { - foreach($events[$c] as $ev) - { - if ($ev['startofevent']) + foreach($events[$c] as $ev) { - $ev['indicat'] = ''; - $ev['imagesize'] = '8'; - $ev['fulltopic'] = TRUE; - } - else - { - $ev['indicat'] = ''; - $ev['imagesize'] = '4'; - $ev['fulltopic'] = FALSE; - } - //setScVar('event_calendar_shortcodes', 'event', $ev); // Give shortcodes the event data - $calSc->event = $ev; - $text .= $e107->tp->parseTemplate($CALENDAR_SHOWEVENT, FALSE, $calSc); - } + if ($ev['startofevent']) + { + $ev['indicat'] = ''; + $ev['imagesize'] = '8'; + $ev['fulltopic'] = TRUE; + } + else + { + $ev['indicat'] = ''; + $ev['imagesize'] = '4'; + $ev['fulltopic'] = FALSE; + } + //setScVar('event_calendar_shortcodes', 'event', $ev); // Give shortcodes the event data + $calSc->event = $ev; + $text .= $e107->tp->parseTemplate($CALENDAR_SHOWEVENT, FALSE, $calSc); + } } $text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_DAY_END, FALSE, $calSc); diff --git a/e107_plugins/calendar_menu/calendar_menu.php b/e107_plugins/calendar_menu/calendar_menu.php index 1f061fa99..cbaa5073c 100644 --- a/e107_plugins/calendar_menu/calendar_menu.php +++ b/e107_plugins/calendar_menu/calendar_menu.php @@ -1,227 +1,233 @@ -isInstalled('calendar_menu')) return ''; - -if (!isset($ecal_class)) -{ - require_once(e_PLUGIN.'calendar_menu/ecal_class.php'); - $ecal_class = new ecal_class; -} -// 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; -} -global $pref; -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 -{ - require(e_PLUGIN.'calendar_menu/calendar_template.php'); -} - -$show_recurring = TRUE; // Could be 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']; -$numberdays = date("t", $ecal_class->cal_timedate); // number of days in this month -$cal_monthstart = gmmktime(0, 0, 0, $cal_current_month, 1, $cal_current_year); // Time stamp for first day of month -$cal_firstdayarray = getdate($cal_monthstart); -$cal_monthend = gmmktime(0, 0, 0, $cal_current_month + 1, 1, $cal_current_year) -1; // Time stamp for last day of month -//$cal_thismonth = $cal_datearray['mon']; -$cal_thisday = $cal_datearray['mday']; // Today -$cal_events = array(); -$cal_titles = array(); -$cal_recent = array(); -$cal_totev = 0; - -$ev_list = $ecal_class->get_events($cal_monthstart, $cal_monthend, TRUE, $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 - if (isset($cal_row['is_recent'])) $cal_recent[$cal_start_day] = TRUE; - $cal_titles[$cal_start_day][] = $cal_row['event_title']; // In case titles displayed on mouseover - } -} - -// set up month array for calendar display -$cal_months = array(EC_LAN_0, EC_LAN_1, EC_LAN_2, EC_LAN_3, EC_LAN_4, EC_LAN_5, EC_LAN_6, EC_LAN_7, EC_LAN_8, EC_LAN_9, EC_LAN_10, EC_LAN_11); -if ($pref['eventpost_dateformat'] == 'my') -{ - $calendar_title = $cal_months[$cal_current_month-1] .' '. $cal_current_year; -} -else -{ - $calendar_title = $cal_current_year .' '. $cal_months[$cal_current_month-1]; -} -switch ($pref['eventpost_menulink']) -{ - case 0 : $calendar_title = "".$calendar_title.""; - break; - case 1 : $calendar_title = "".$calendar_title.""; - break; - default : ; -} -$cal_text = $CALENDAR_MENU_START; -if ($pref['eventpost_showeventcount']=='1') -{ - if ($cal_totev) - { - $cal_text .= EC_LAN_26 . ": " . $cal_totev; - } - else - { - $cal_text .= EC_LAN_27; - } - $cal_text .= "

"; -} -$cal_start = $cal_monthstart; // First day of month as time stamp -// Start the table -$cal_text .= $CALENDAR_MENU_TABLE_START; -// Open header row -$cal_text .= $CALENDAR_MENU_HEADER_START; -// Now do the headings (days of week) -for ($i = 0; $i < 7; $i++) -{ - $cal_day = $ecal_class->day_offset_string($i); - $cal_text .= $CALENDAR_MENU_HEADER_FRONT; - $cal_text .= $e107->tp->text_truncate($cal_day, 1, ''); // Unlikely to have room for more than 1 letter - $cal_text .= $CALENDAR_MENU_HEADER_BACK; -} -$cal_text .= $CALENDAR_MENU_HEADER_END; // Close off header row, open first date row -// Calculate number of days to skip before 'real' days on first line of calendar -$firstdayoffset = date('w',$cal_start) - $ecal_class->ec_first_day_of_week; -if ($firstdayoffset < 0) $firstdayoffset+= 7; -for ($cal_c = 0; $cal_c < $firstdayoffset; $cal_c++) -{ - $cal_text .= $CALENDAR_MENU_DAY_NON; -} -$cal_loop = $firstdayoffset; -// Now do the days of the month -for($cal_c = 1; $cal_c <= $numberdays; $cal_c++) -{ // Six cases to decode: - // 1 - Today, no events - // 2 - Some other day, no events - // 3 - Today with events - // 4 - Some other day with events - // 5 - Today with recently added events - // 6 - Some other day with recently added events - $cal_css = 2; // The default - not today, no events - $cal_img = $cal_c; // Default 'image' is the day of the month - $cal_event_count = 0; - $title = ""; - if ($cal_thisday == $cal_c) $cal_css = 1; - $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_count = count($cal_events[$cal_c]); // See how many events today - if ($cal_event_count) - { // Show icon if it exists - $cal_css += 2; // Gives 3 for today, 4 for other day - if (isset($pref['eventpost_showmouseover']) && ($pref['eventpost_showmouseover'] == 1)) - { - $cal_ins = " title='"; - foreach ($cal_titles[$cal_c] as $cur_title) - { // New line would be better, but doesn't get displayed - $title .= $cal_ins.$cur_title; - $cal_ins = ", "; - } - $title .= "'"; - } - else - { - if ($cal_event_count == 1) - { - $title = " title='1 ".EC_LAN_135."' "; - } - else - { - $title = " title='{$cal_event_count} " . EC_LAN_106 . "' "; - } - } - if (isset($cal_recent[$cal_c]) && $cal_recent[$cal_c]) - { - $cal_css += 2; - } - - if (!empty($cal_events[$cal_c]['0'])) - { - $cal_event_icon = 'calendar_menu/images/'.$cal_events[$cal_c]['0']; // Icon file could be NULL - if (is_readable(e_PLUGIN.$cal_event_icon)) - { - $cal_img = ""; - } - } - } - } - $cal_text .= $CALENDAR_MENU_DAY_START[$cal_css]."{$cal_img}"; - $cal_text .= $CALENDAR_MENU_DAY_END[$cal_css]; - $cal_loop++; - if ($cal_loop == 7) - { // Start next row - $cal_loop = 0; - if ($cal_c != $numberdays) - { - $cal_text .= $CALENDAR_MENU_WEEKSWITCH; - } - } -} -if ($cal_loop != 0) -{ -for($cal_a = ($cal_loop + 1); $cal_a <= 7; $cal_a++) -{ - $cal_text .= $CALENDAR_MENU_DAY_NON; -} -} -// Close table -$cal_text .= $CALENDAR_MENU_END; -// Now handle the data, cache as well -ob_start(); // Set up a new output buffer -$ns->tablerender($calendar_title, $cal_text, 'calendar_menu'); -$cache_data = ob_get_flush(); // Get the page content, and display it -$e107->ecache->set($cache_tag, $cache_data); // Save to cache -unset($ev_list); -unset($cal_text); +isInstalled('calendar_menu')) return ''; + +if (!isset($ecal_class)) +{ + require_once(e_PLUGIN.'calendar_menu/ecal_class.php'); + $ecal_class = new ecal_class; +} + +// 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(e_PLUGIN.'calendar_menu/languages/'.e_LANGUAGE.'.php'); + +// Doesn't use shortcodes - rather a specific format for that +if (is_readable(THEME.'calendar_template.php')) +{ // Has to be require + require(THEME.'calendar_template.php'); +} +else +{ + require(e_PLUGIN.'calendar_menu/calendar_template.php'); +} + +$show_recurring = TRUE; // Could be 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']; +$numberdays = date("t", $ecal_class->cal_timedate); // number of days in this month +$cal_monthstart = gmmktime(0, 0, 0, $cal_current_month, 1, $cal_current_year); // Time stamp for first day of month +$cal_firstdayarray = getdate($cal_monthstart); +$cal_monthend = gmmktime(0, 0, 0, $cal_current_month + 1, 1, $cal_current_year) -1; // Time stamp for last day of month +//$cal_thismonth = $cal_datearray['mon']; +$cal_thisday = $cal_datearray['mday']; // Today +$cal_events = array(); +$cal_titles = array(); +$cal_recent = array(); +$cal_totev = 0; + +$ev_list = $ecal_class->get_events($cal_monthstart, $cal_monthend, TRUE, $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 + if (isset($cal_row['is_recent'])) $cal_recent[$cal_start_day] = TRUE; + $cal_titles[$cal_start_day][] = $cal_row['event_title']; // In case titles displayed on mouseover + } +} + +// set up month array for calendar display +$cal_months = array(EC_LAN_0, EC_LAN_1, EC_LAN_2, EC_LAN_3, EC_LAN_4, EC_LAN_5, EC_LAN_6, EC_LAN_7, EC_LAN_8, EC_LAN_9, EC_LAN_10, EC_LAN_11); +if ($this->ecal_class->pref['eventpost_dateformat'] == 'my') +{ + $calendar_title = $cal_months[$cal_current_month-1] .' '. $cal_current_year; +} +else +{ + $calendar_title = $cal_current_year .' '. $cal_months[$cal_current_month-1]; +} + +switch ($this->ecal_class->pref['eventpost_menulink']) +{ + case 0 : + $calendar_title = "".$calendar_title.""; + break; + case 1 : + $calendar_title = "".$calendar_title.""; + break; + default : ; +} + +$cal_text = $CALENDAR_MENU_START; +if ($this->ecal_class->pref['eventpost_showeventcount']=='1') +{ + if ($cal_totev) + { + $cal_text .= EC_LAN_26 . ": " . $cal_totev; + } + else + { + $cal_text .= EC_LAN_27; + } + $cal_text .= "

"; +} + +$cal_start = $cal_monthstart; // First day of month as time stamp +// Start the table +$cal_text .= $CALENDAR_MENU_TABLE_START; +// Open header row +$cal_text .= $CALENDAR_MENU_HEADER_START; +// Now do the headings (days of week) +for ($i = 0; $i < 7; $i++) +{ + $cal_day = $ecal_class->day_offset_string($i); + $cal_text .= $CALENDAR_MENU_HEADER_FRONT; + $cal_text .= $e107->tp->text_truncate($cal_day, 1, ''); // Unlikely to have room for more than 1 letter + $cal_text .= $CALENDAR_MENU_HEADER_BACK; +} +$cal_text .= $CALENDAR_MENU_HEADER_END; // Close off header row, open first date row +// Calculate number of days to skip before 'real' days on first line of calendar +$firstdayoffset = date('w',$cal_start) - $ecal_class->ec_first_day_of_week; +if ($firstdayoffset < 0) $firstdayoffset+= 7; +for ($cal_c = 0; $cal_c < $firstdayoffset; $cal_c++) +{ + $cal_text .= $CALENDAR_MENU_DAY_NON; +} +$cal_loop = $firstdayoffset; +// Now do the days of the month +for($cal_c = 1; $cal_c <= $numberdays; $cal_c++) +{ // Six cases to decode: + // 1 - Today, no events + // 2 - Some other day, no events + // 3 - Today with events + // 4 - Some other day with events + // 5 - Today with recently added events + // 6 - Some other day with recently added events + $cal_css = 2; // The default - not today, no events + $cal_img = $cal_c; // Default 'image' is the day of the month + $cal_event_count = 0; + $title = ""; + if ($cal_thisday == $cal_c) $cal_css = 1; + $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_count = count($cal_events[$cal_c]); // See how many events today + if ($cal_event_count) + { // Show icon if it exists + $cal_css += 2; // Gives 3 for today, 4 for other day + if (isset($this->ecal_class->pref['eventpost_showmouseover']) && ($this->ecal_class->pref['eventpost_showmouseover'] == 1)) + { + $cal_ins = " title='"; + foreach ($cal_titles[$cal_c] as $cur_title) + { // New line would be better, but doesn't get displayed + $title .= $cal_ins.$cur_title; + $cal_ins = ", "; + } + $title .= "'"; + } + else + { + if ($cal_event_count == 1) + { + $title = " title='1 ".EC_LAN_135."' "; + } + else + { + $title = " title='{$cal_event_count} " . EC_LAN_106 . "' "; + } + } + if (isset($cal_recent[$cal_c]) && $cal_recent[$cal_c]) + { + $cal_css += 2; + } + + if (!empty($cal_events[$cal_c]['0'])) + { + $cal_event_icon = 'calendar_menu/images/'.$cal_events[$cal_c]['0']; // Icon file could be NULL + if (is_readable(e_PLUGIN.$cal_event_icon)) + { + $cal_img = ""; + } + } + } + } + $cal_text .= $CALENDAR_MENU_DAY_START[$cal_css]."{$cal_img}"; + $cal_text .= $CALENDAR_MENU_DAY_END[$cal_css]; + $cal_loop++; + if ($cal_loop == 7) + { // Start next row + $cal_loop = 0; + if ($cal_c != $numberdays) + { + $cal_text .= $CALENDAR_MENU_WEEKSWITCH; + } + } +} +if ($cal_loop != 0) +{ + for($cal_a = ($cal_loop + 1); $cal_a <= 7; $cal_a++) + { + $cal_text .= $CALENDAR_MENU_DAY_NON; + } +} +// Close table +$cal_text .= $CALENDAR_MENU_END; +// Now handle the data, cache as well +ob_start(); // Set up a new output buffer +$ns->tablerender($calendar_title, $cal_text, 'calendar_menu'); +$cache_data = ob_get_flush(); // Get the page content, and display it +$e107->ecache->set($cache_tag, $cache_data); // Save to cache +unset($ev_list); +unset($cal_text); ?> \ No newline at end of file diff --git a/e107_plugins/calendar_menu/calendar_menu_setup.php b/e107_plugins/calendar_menu/calendar_menu_setup.php index 2486cd0c2..3ab630209 100644 --- a/e107_plugins/calendar_menu/calendar_menu_setup.php +++ b/e107_plugins/calendar_menu/calendar_menu_setup.php @@ -1,90 +1,174 @@ -_setup -{ - - function install_post($param) - { - $mes = eMessage::getInstance(); - if($this->insertDefaultCategory(FALSE)) - { - $mes->add(EC_ADINST_LAN_06, E_MESSAGE_SUCCESS); - } - else - { - $mes->add(EC_ADINST_LAN_07, E_MESSAGE_ERROR); - } - - $mes->add(EC_ADINST_LAN_04, E_MESSAGE_SUCCESS); - - } - - - function install_pre($param) - { - // echo "Calendar uninstall routine
"; - } - - - function upgrade_post($param) - { - $mes = eMessage::getInstance(); - if($this->insertDefaultCategory(TRUE)) - { - $mes->add(EC_ADINST_LAN_06, E_MESSAGE_SUCCESS); - } - else - { - $mes->add(EC_ADINST_LAN_07, E_MESSAGE_ERROR); - } - } - - - function insertDefaultCategory($isUpgrade = FALSE) // Insert the text for the default category into the DB here - { - $sql = e107::getDb(); - - require_once('ecal_class.php'); // Gets the define for the 'Default' category - if ($isUpgrade && $sql->db_Select('event_cat','event_cat_name',"event_cat_name='".EC_DEFAULT_CATEGORY."' ", TRUE)) - { - return EC_ADINST_LAN_08.'
'; - } - $ec_insert_entries = "INSERT INTO `#event_cat` (event_cat_name, event_cat_description, event_cat_ahead, event_cat_msg1, event_cat_msg2, event_cat_lastupdate) - VALUES ('".EC_DEFAULT_CATEGORY."', '".EC_ADINST_LAN_03."', 5, - '".EC_ADINST_LAN_01."', '".EC_ADINST_LAN_02."', - '".intval(time())."') "; - - return $sql->db_Select_gen($ec_insert_entries); - } -} - +_setup +{ + + function install_post($param) + { + $somethingFailed = FALSE; + + $mes = eMessage::getInstance(); + if ($this->insertDefaultCategory(FALSE, $mes) == FALSE) + { + $somethingFailed = TRUE; + } + + + if ($somethingFailed) + { + $mes->add(EC_ADINST_LAN_04, E_MESSAGE_SUCCESS); + } + else + { + } + + } + + + function install_pre($param) + { + // echo "Calendar uninstall routine
"; + } + + + + /** + * Called to see if plugin upgrade is required + * + * @param $param mixed - no purpose currently + * @return boolean TRUE if upgrade required, FALSE otherwise + */ + function upgrade_required($param = FALSE) + { + $required = FALSE; + + $data = e107::pref('calendar_menu'); + if (count($data) == 0) + { + $required = TRUE; + } + //print_a($data); + return $required; + } + + + + /** + * Upgrade stage 1 + * + * @param $param mixed - no purpose currently + * @return - none + */ + function upgrade_pre($param = FALSE) + { + $mes = eMessage::getInstance(); + $calPref = e107::pref('calendar_menu'); + if (count($calPref) == 0) + { // Need to move prefs over + unset($calPref); + + $calNew = e107::getPlugConfig('calendar_menu'); // Initialize calendar_menu prefs. + $corePrefs = e107::getConfig('core'); // Core Prefs Object. + $pref = e107::pref('core'); // Core Prefs Array. + + foreach($pref as $k=>$v) + { + if(substr($k, 0, 10) == 'eventpost_') + { + $calNew->add($k, $v); + $corePrefs->remove($k); + } + } + $calNew->save(); + $corePrefs->save(); + + $calPref = e107::pref('calendar_menu'); // retrieve calendar_menu pref array. + //print_a($calPref); + + + $mes->add(EC_ADINST_LAN_10, E_MESSAGE_SUCCESS); + } + else + { + $mes->add(EC_ADINST_LAN_09, E_MESSAGE_INFO); // Nothing to do - prefs already moved + } + } + + + + /** + * Upgrade final stage - add default category + * + * @param $param mixed - no purpose currently + * @return - none + */ + function upgrade_post($param) + { + $this->insertDefaultCategory(TRUE); + } + + + /** + * Make sure default category is in calendar database; add it if not. + * + * Adds an appropriate message to the passed message handler. + * Returns TRUE if the call can be deemed a success (category present or added); FALSE on error + */ + function insertDefaultCategory($isUpgrade) // Insert the text for the default category into the DB here + { + $mes = eMessage::getInstance(); + $sql = e107::getDb(); + + require_once(e_PLUGIN.'calendar_menu/ecal_class.php'); // Gets the define for the 'Default' category + if ($isUpgrade && $sql->db_Select('event_cat','event_cat_name',"event_cat_name='".EC_DEFAULT_CATEGORY."' ")) + { + $mes->add(EC_ADINST_LAN_08, E_MESSAGE_INFO); // Nothing to do - default category already present + return TRUE; + } + $ec_insert_entries = "INSERT INTO `#event_cat` (event_cat_name, event_cat_description, event_cat_ahead, event_cat_msg1, event_cat_msg2, event_cat_lastupdate) + VALUES ('".EC_DEFAULT_CATEGORY."', '".EC_ADINST_LAN_03."', 5, + '".EC_ADINST_LAN_01."', '".EC_ADINST_LAN_02."', + '".intval(time())."') "; + + if ($result = $sql->db_Select_gen($ec_insert_entries)) + { + $mes->add(EC_ADINST_LAN_06, E_MESSAGE_SUCCESS); + } + else + { + $mes->add(EC_ADINST_LAN_07, E_MESSAGE_ERROR); + } + return $result; + } +} + ?> \ No newline at end of file diff --git a/e107_plugins/calendar_menu/calendar_shortcodes.php b/e107_plugins/calendar_menu/calendar_shortcodes.php index 8023a574d..1a4577af9 100644 --- a/e107_plugins/calendar_menu/calendar_shortcodes.php +++ b/e107_plugins/calendar_menu/calendar_shortcodes.php @@ -1,1108 +1,1099 @@ -e107 = e107::getInstance(); - } - - - /** - * Set the current date for calendar display - * - * Routine then calculates various values needed for shortcodes - * - * @param array $curDate - As returned by getdate() - * - * @return BOOLEAN TRUE - */ - public function setCalDate($curDate) - { - $this->ds = varset($curDate['ds'],''); - - $this->day = varset($curDate['mday'], 0); // Day number being shown - rarely relevant - $this->month = $curDate['mon']; // Number of month being shown - $this->year = $curDate['year']; // Number of year being shown - $this->monthStart = mktime(0, 0, 0, $curDate['mon'], 1, $curDate['year']); // Start of month to be shown - $this->monthEnd = mktime(0, 0, 0, $curDate['mon'] + 1, 1, $curDate['year']) - 1; // End of month to be shown - - - // Calculate date code for previous month - $this->prevMonth = $curDate['mon']-1; - $prevYear = $curDate['year']; - if ($this->prevMonth == 0) - { - $this->prevMonth = 12; - $prevYear--; - } - $this->previous = mktime(0, 0, 0, $this->prevMonth, 1, $prevYear); // Previous month - Used by nav - - // Calculate date code for next month - $this->nextMonth = $curDate['mon'] + 1; - $nextYear = $curDate['year']; - if ($this->nextMonth == 13) - { - $this->nextMonth = 1; - $nextYear++; - } - $this->next = mktime(0, 0, 0, $this->nextMonth, 1, $nextYear); // Next month - used by nav - - - $this->py = $curDate['year']-1; // Number of previous year for nav - $this->prevLink = mktime(0, 0, 0, $curDate['mon'], 1, $this->py); - $this->ny = $curDate['year'] + 1; // Number of next year for nav - $this->nextLink = mktime(0, 0, 0, $curDate['mon'], 1, $this->ny); - - $this->prop = gmmktime(0, 0, 0, $curDate['mon'], $curDate['mday'], $curDate['year']); // Sets start date for new event entry - - $this->nowMonth = $this->ecalClass->cal_date['mon']; - $this->nowYear = $this->ecalClass->cal_date['year']; - $this->nowDay = $this->ecalClass->cal_date['mday']; - return TRUE; - } - - // Navigation shortcodes - public function sc_ec_prev_month($parm = '') - { - return "<< ".$this->months[($this->prevMonth-1)].""; - } - - public function sc_ec_next_month($parm = '') - { - return " ".$this->months[($this->nextMonth-1)]." >>"; - } - - - public function sc_ec_current_month($parm = '') - { - global $pref; - if($pref['eventpost_dateformat'] == 'my') - { - return $this->months[($this->month-1)].' '.$this->year; - } - return $this->year.' '.$this->months[($this->month-1)]; - } - - - public function sc_ec_prev_year($parm = '') - { - return "<< ".$this->py.""; - } - - public function sc_ec_next_year($parm = '') - { - return "".$this->ny." >>"; - } - - - public function sc_ec_month_list($parm = '') - { - $ret = ''; - for ($ii = 0; $ii < 12; $ii++) - { - $monthJump = mktime(0, 0, 0, $ii+1, 1, $this->year); - $ret .= "".$this->monthabb[$ii]."  "; - } - return $ret; - } - - - // Navigation buttons - public function sc_ec_nav_but_allevents($parm = '') - { - $allevents = (e_PAGE == "event.php" ? EC_LAN_96 : EC_LAN_93); - return ""; - } - - public function sc_ec_nav_but_viewcat($parm = '') - { - return ""; - } - - public function sc_ec_nav_but_subscription($parm = '') - { - global $pref; - if (isset($pref['eventpost_asubs']) && ($pref['eventpost_asubs']>0) && USER) - { - return ""; - } - return ''; - } - - public function sc_ec_nav_but_enterevent($parm = '') - { - global $pref; - $ret = ""; - if ($this->ecalClass->cal_super || check_class($pref['eventpost_admin'])) - { - $ret .= ""; - } - return $ret; - } - - public function sc_ec_nav_linkcurrentmonth($parm = '') - { - $ret = ''; - if ($this->month != $this->nowMonth || $this->year != $this->nowYear || $this->ds == 'one') - { // Just jump to current page without a query part - that will default to today - $ret = ""; - } - return $ret; - } - - public function sc_ec_nav_but_printlists($parm = '') - { - global $pref; - if (isset($pref['eventpost_printlists']) && ($pref['eventpost_printlists']>0) && USER) - { - return ""; - } - } - - // Categories listing - public function sc_ec_nav_categories($parm = '') - { - global $pref; - if ($this->ourDB == NULL) - { - $this->ourDB = new db; // @todo use new method - } - ($parm == 'nosubmit') ? $insert = '' : $insert = "onchange='this.form.submit()'"; - $ret = "\n"; - return $ret; - } - - -// Event information shortcodes -//----------------------------- - - - public function sc_ec_event_location($parm = '') - { - return $this->event['event_location']; - } - - public function sc_ec_event_recent_icon() - { - return $this->sc_ec_calendar_calendar_recent_icon(); - } - - - - public function sc_ec_if_allday($parm= '') - { - if (!$this->event['event_allday']) return ''; - if (trim($parm) == '') return ''; - return $this->e107->tp->parseTemplate('{'.$parm.'}', FALSE, $this); - } - - public function sc_ec_ifnot_allday($parm= '') - { - if ($this->event['event_allday']) return ''; - if (trim($parm) == '') return ''; - return $this->e107->tp->parseTemplate('{'.$parm.'}', FALSE, $this); - } - - public function sc_ec_ifnot_sameday($parm= '') - { - if (intval($this->event['event_end']/86400) == intval($this->event['event_start']/86400)) return ''; - if (!$this->event['event_allday']) return ''; - if (trim($parm) == '') return; - return $this->e107->tp->parseTemplate('{'.$parm.'}', FALSE, $this); - } - - public function sc_ec_if_sameday($parm= '') - { - if (intval($this->event['event_end']/86400) != intval($this->event['event_start']/86400)) return ''; - if (!$this->event['event_allday']) return ''; - if (trim($parm) == '') return; - return $this->e107->tp->parseTemplate('{'.$parm.'}', FALSE, $this); - } - - - -// Event mailout shortcodes -//-------------------------- - public function sc_ec_mail_heading_date($parm) - { - if (isset($parm) && ($parm !== "")) - { - return strftime($parm,$this->event['event_start']); - } - else - { - return $this->ecalClass->event_date_string($this->event['event_start']); - } - } - - - public function sc_ec_mail_date_start($parm) - { - return $this->sc_ec_mail_heading_date($parm); - } - - - public function sc_ec_mail_date_start_allday($parm) - { - if ($this->event['event_allday'] != 1) return ''; - return $this->sc_ec_mail_heading_date($parm); - } - - - public function sc_ec_mail_date_start_timed($parm) - { - if ($this->event['event_allday'] == 1) return ''; - return $this->sc_ec_mail_heading_date($parm); - } - - - public function sc_ec_mail_time_start($parm) - { - if ($this->event['event_allday'] == 1) return ''; - return $this->ecalClass->time_string($this->event['event_start']); - } - - - public function sc_ec_mail_date_end($parm = '') - { - if ($this->event['event_allday'] ||($this->event['event_end'] == $this->event['event_start'])) return ''; - if ($parm !== '') - { - return strftime($parm,$this->event['event_end']); - } - return $this->ecalClass->event_date_string($this->event['event_end']); - } - - - - public function sc_ec_mail_time_end($parm = '') - { - if ($this->event['event_allday'] ||($this->event['event_end'] == $this->event['event_start'])) return ''; - $endds = $ecal_class->time_string($this->event['event_end']); - return $endds; - } - - - public function sc_ec_mail_title($parm = '') - { - return $this->event['event_title']; - } - - - public function sc_ec_mail_id($parm = '') - { - return 'calevent'.$this->event['event_id']; - } - - - public function sc_ec_mail_details($parm = '') - { - return $this->e107->tp->toHTML($this->event['event_details'], TRUE,'E_BODY'); - } - - - - public function sc_ec_mail_category($parm = '') - { - return $this->event['event_cat_name']; - } - - - - - public function sc_ec_mail_contact($parm = '') - { - if ($this->event['event_contact'] == '') return ''; - return $this->e107->tp->toHTML($this->event['event_contact'],TRUE,'LINKTEXT'); - } - - - public function sc_ec_mail_thread($parm = '') - { - return $this->event['event_thread']; - } - - - public function sc_ec_mail_link($parm = '') - { - $cal_dayarray = getdate($this->event['event_start']); - $cal_linkut = mktime(0 , 0 , 0 , $cal_dayarray['mon'], $cal_dayarray['mday'], $cal_dayarray['year']).".one"; // ALways need "one" - return ' '.SITEURLBASE.e_PLUGIN_ABS.'calendar_menu/event.php?'.$cal_linkut.' '; - } - - - public function sc_ec_mail_short_date($parm = '') - { - return $this->ecalClass->next_date_string($this->event['event_start']); - } - - - // Codes can be used to return a LAN to help with multi-language - public function sc_ec_mail_subject($parm = '') - { - return EC_MAILOUT_SUBJECT; - } - - -//------------------------------------------ -// CALENDAR CALENDAR - 'Big' calendar -//------------------------------------------ - public function sc_ec_calendar_calendar_header_day($parm = '') - { - global $pref; - if(isset($pref['eventpost_lenday']) && $pref['eventpost_lenday']) - { - return "".$this->e107->tp->text_truncate($this->headerDay,$pref['eventpost_lenday'],'').""; - } - else - { - return "".$this->headerDay.""; - } - } - - - public function sc_ec_calendar_calendar_day_today_heading() - { - return "".$this->days[($this->curDay-1)]." [".EC_LAN_TODAY."]"; - } - - - public function sc_ec_calendar_calendar_day_event_heading() - { - return "".$this->days[($this->curDay-1)].""; - } - - - public function sc_ec_calendar_calendar_day_empty_heading() - { - return "".$this->days[($this->curDay-1)].""; - } - - - public function sc_ec_calendar_calendar_recent_icon() - { - if (!isset($this->event['is_recent'])) return ''; - if (!$this->event['startofevent']) return ''; // Only display on first day of multi-day events - if (is_readable(EC_RECENT_ICON)) - { - return " "; - } - return "R"; - } - - - public function sc_ec_event_page_title() - { - switch ($this->ds) - { - case 'one' : return EC_LAN_80.': '.$this->day.' '.$this->months[$this->month-1]; -// case 'event' : return EC_LAN_122.': '.$this->day.' '.$this->months[$this->month-1]; - case 'event' : return EC_LAN_122; - default : return EC_LAN_80; - } - } - - - public function sc_ec_showevent_image() - { - //TODO review bullet - $img = ''; - if($this->event['event_cat_icon'] && file_exists(e_PLUGIN.'calendar_menu/images/'.$this->event['event_cat_icon'])) - { - $img = "event['event_cat_icon']."' alt='' height='".$this->event['imagesize']."' width='".$this->event['imagesize']."' />"; - } - elseif(defined('BULLET')) - { - $img = ''; - } - elseif(file_exists(THEME.'images/bullet2.gif')) - { - $img = ''; - } - return $img; - } - - - public function sc_ec_showevent_indicat() - { - return $this->event['indicat']; - } - - - - public function sc_ec_showevent_heading() - { - $linkut = mktime(0 , 0 , 0 , $this->month, $this->curDay, $this->year); - $show_title = $this->e107->tp->toHTML($this->event['event_title'],FALSE,'TITLE'); // Remove entities in case need to truncate - if(isset($this->event['fulltopic']) && !$this->event['fulltopic']) - { - $show_title = $this->e107->tp->text_truncate($show_title, 10, '...'); - } - if($this->event['startofevent']) - { - return "event['event_id']."'>".$show_title.""; - } - else - { - return "event['event_id']."'>".$show_title.""; - } - } - - - public function sc_ec_eventlist_caption() - { - $ret = ''; - if ($this->ds == 'one') - { - $ret = EC_LAN_111.$this->months[$this->month-1].' '.$this->day; - } - elseif ($this->ds != 'event') - { - $ret = EC_LAN_112.$this->months[$this->month-1]; - } - return $ret; - } - - -//--------------------------------------------------- -// EVENT SHOWEVENT (Detail of individual events) -//--------------------------------------------------- - - public function sc_ec_event_heading_date() - { - return $this->ecalClass->event_date_string($this->event['event_start']); - } - - // Same code as previous - public function sc_ec_event_date_start() - { - return $this->ecalClass->event_date_string($this->event['event_start']); - } - - - public function sc_ec_event_time_start() - { - if ($this->event['event_allday'] == 1) return ''; - return $this->ecalClass->time_string($this->event['event_start']); - } - - - public function sc_ec_event_date_end() - { - if ($this->event['event_end'] == $this->event['event_start']) return ''; - return $this->ecalClass->event_date_string($this->event['event_end']); - } - - - public function sc_ec_event_time_end() - { - if ($this->event['event_allday'] ||($this->event['event_end'] == $this->event['event_start'])) return ''; - return $this->ecalClass->time_string($this->event['event_end']); - } - - - public function sc_ec_event_title() - { - return $this->event['event_title']; - } - - - public function sc_ec_event_cat_icon() - { - if ($this->event['event_cat_icon'] && is_readable(e_PLUGIN.'calendar_menu/images/'.$this->event['event_cat_icon'])) - { - return " "; - } - return ''; - } - - - public function sc_ec_event_id() - { - return 'calevent'.$this->event['event_id']; - } - - - public function sc_ec_event_displaystyle() - { // Returns initial state of expandable blocks - if (($this->ds=='event') || ($this->ds=='one')) - { - return ''; // Let block display - } - return 'display: none; '; - } - - - /** - * Display class for event display block - to manage expansion/contraction - * When displaying a single event, or a single day's events, block to be expanded - * For event lists, block to be contracted - * - * @param int $param - optional supplementary list of classes to apply - * - * @return string - - */ - public function sc_ec_event_displayclass($parm='') - { - if (($this->ds=='event') || ($this->ds=='one')) - { // Single event or one day's events - block expanded - return " class='{$parm}'"; - } - return " class='e-show-if-js e-hideme {$parm}'"; // Block contracted -// return " class='e-hide-if-js e-showme {$parm}'"; // Block contracted - } - - - public function sc_ec_event_details() - { - return $this->e107->tp->toHTML($this->event['event_details'], TRUE, 'BODY'); - } - - - public function sc_ec_event_category() - { - return $this->event['event_cat_name']; - } - - - public function sc_ec_event_author() - { - $lp = explode(".", $this->event['event_author'],2); // Split into userid.username - if (preg_match("/[0-9]+/", $lp[0])) - { - $event_author_id = $lp[0]; - $event_author_name = $lp[1]; - } - if(USER) - { - return "".$event_author_name.""; - } - return $event_author_name; - } - - - public function sc_ec_event_contact() - { - if ($this->event['event_contact'] == '') return ''; - $tm = $this->event['event_contact']; - if (strpos($tm,'[') === FALSE) - { // Add a bbcode if none exists - $tm = '[link=mailto:'.trim($tm).']'.substr($tm,0,strpos($tm,'@')).'[/link]'; - } - return $this->e107->tp->toHTML($tm,TRUE,'LINKTEXT'); // Return obfuscated email link - } - - - public function sc_ec_event_thread() - { - if (isset($this->event['event_thread']) && ($this->event['event_thread'] != '')) - { - return " ".EC_LAN_39.""; - } - return ''; - } - - - public function sc_ec_event_options() - { - global $pref; - $event_author_name = strstr(varset($this->event['event_author'],'0.??'),'.'); - if (USERNAME == $event_author_name || $this->ecalClass->cal_super || check_class($pref['eventpost_admin'])) - { - return "".EC_LAN_35 . "  event['event_id']."'>".EC_LAN_36.""; - } - } - - - public function sc_ec_ec_event_link() - { - $cal_dayarray = getdate($this->event['event_start']); - $cal_linkut = mktime(0 , 0 , 0 , $cal_dayarray['mon'], $cal_dayarray['mday'], $cal_dayarray['year']).'.one'; // ALways need "one" - return ' '.e_PLUGIN_ABS.'calendar_menu/event.php?'.$cal_linkut.' '; - } - - - public function sc_ec_event_event_date_time() - { - $et = 0; - if (intval($this->event['event_end']/86400) == intval($this->event['event_start']/86400)) $et += 1; - if ($this->event['event_allday']) $et += 2; - if (is_array($this->eventDisplayCodes)) - { - return $this->e107->tp->parseTemplate($this->eventDisplayCodes[$et], FALSE, $this); - } - return '--** No template set **--'; - } - - - public function sc_ec_event_short_date() - { - return $this->ecalClass->next_date_string($this->event['event_start']); - } - - -//------------------------------------------ -// EVENT ARCHIVE (list of next events at bottom of event list) -//------------------------------------------ - - public function sc_ec_eventarchive_caption() - { - if ($this->numEvents == 0) - { - return EC_LAN_137; - } - return str_replace('-NUM-', $this->numEvents, EC_LAN_62); - } - - - public function sc_ec_eventarchive_date() - { - $startds = $this->ecalClass->event_date_string($this->event['event_start']); - return "event['event_id']."'>".$startds.""; - } - - - public function sc_ec_eventarchive_details() - { - $number = 40; - $rowtext = $this->e107->tp->toHTML($this->event['event_details'], TRUE, 'BODY'); - $rowtext = strip_tags($rowtext); - $words = explode(' ', $rowtext); - $ret = implode(' ', array_slice($words, 0, $number)); - if(count($words) > $number) - { - $ret .= ' '.EC_LAN_133.' '; - } - return $ret; - } - - - public function sc_ec_eventarchive_empty() - { - return EC_LAN_37; - } - - - public function sc_ec_eventarchive_heading() - { - return $this->event['event_title']; - } - - - -// FORTHCOMING EVENTS MENU -//--------------------------- - - function sc_ec_next_event_recent_icon() - { - global $pref; - if (!$pref['eventpost_fe_showrecent']) return; - if (!isset($this->event['is_recent'])) return; - if (is_readable(EC_RECENT_ICON)) - { - return " "; - } - return ''; - } - - - public function sc_ec_next_event_time() - { - if ($this->event['event_allday'] != 1) - { - return $this->ecalClass->time_string($this->event['event_start']); - } - return ''; - } - - - public function sc_ec_next_event_date() - { - return $this->ecalClass->next_date_string($this->event['event_start']); - } - - - public function sc_ec_next_event_title() - { - global $pref; - if (isset($pref['eventpost_namelink']) && ($pref['eventpost_namelink'] == '2') && (isset($this->event['event_thread']) && ($this->event['event_thread'] != ''))) - { - $fe_event_title = ""; - } - else - { - $fe_event_title = "event['event_id']."'>"; - } - $fe_event_title .= $this->event['event_title'].""; - return $fe_event_title; - } - - - public function sc_ec_next_event_icon() - { - global $pref; - $fe_icon_file = ''; - if ($pref['eventpost_showcaticon'] == 1) - { - if($this->event['event_cat_icon'] && is_readable(e_PLUGIN.'calendar_menu/images/'.$this->event['event_cat_icon'])) - { - $fe_icon_file = e_PLUGIN_ABS.'calendar_menu/images/'.$this->event['event_cat_icon']; - } - elseif(defined('BULLET')) - { - $fe_icon_file = THEME_ABS.'images/'.BULLET; - } - elseif(file_exists(THEME.'images/bullet2.gif')) - { - $fe_icon_file = THEME_ABS.'images/bullet2.gif'; - } - } - return $fe_icon_file; - } - - - public function sc_ec_next_event_gap() - { - if ($this->numEvents) return '

'; // Return a newline as a gap on all but last item - return ''; - } - - - - -// Specific to the 'listings' page -//-------------------------------- - - public function sc_ec_pr_list_title() - { - return $this->printVars['lt']; - } - - - - public function sc_ec_pr_cat_list() - { - if (is_array($this->printVars['cat'])) - { - return implode(', ',$this->printVars['cat']); - } - return $this->printVars['cat']; - } - - public function sc_ec_pr_change_year() - { - if (!$this->changeFlags['yc']) return ''; - $thisevent_start_date = $this->ecalClass->gmgetdate($this->event['event_start']); - return $thisevent_start_date['year']; - } - - public function sc_ec_pr_change_month() - { - if (!$this->changeFlags['mc']) return ''; - $thisevent_start_date = $this->ecalClass->gmgetdate($this->event['event_start']); - return $thisevent_start_date['month']; - } - - - public function sc_ec_pr_list_start($parm = '') - { - if ($parm) - { - return $this->ecalClass->event_date_string($this->printVars['sd']); - } - return strftime($parm,$this->printVars['sd']); - } - - public function sc_ec_pr_list_end($parm = '') - { - if ($parm) - { - return $this->ecalClass->event_date_string($this->printVars['ed']); - } - return strftime($parm,$this->printVars['ed']); - } - - - public function sc_ec_now_date($parm = '') - { - if ($parm == '') return $this->ecalClass->event_date_string(time()); - return strftime($parm,time()); - } - - public function sc_ec_now_time($parm = '') - { - if ($parm == '') return $this->ecalClass->time_string(time()); - return strftime($parm,time()); - } - - - public function sc_ec_print_button() - { - if ($this->printVars['ot'] != 'print') return; - return ""; - } - - - public function sc_ec_if_print($parm = '') - { - if ($this->printVars['ot'] != 'print') return; - if (trim($parm) == '') return; - return $this->e107->tp->parseTemplate('{'.$parm.'}', FALSE, $this); - } - - public function sc_ec_ifnot_print($parm = '') - { - if ($this->printVars['ot'] == 'print') return; - if (trim($parm) == '') return; - return $this->e107->tp->parseTemplate('{'.$parm.'}', FALSE, $this); - } - - public function sc_ec_if_display($parm = '') - { - if ($this->printVars['ot'] != 'display') return; - if (trim($parm) == '') return; - return $this->e107->tp->parseTemplate('{'.$parm.'}', FALSE, $this); - } - - public function sc_ec_ifnot_display($parm = '') - { - if ($this->printVars['ot'] == 'display') return; - if (trim($parm) == '') return; - return $this->e107->tp->parseTemplate('{'.$parm.'}', FALSE, $this); - } - - public function sc_ec_if_pdf($parm = '') - { - if ($this->printVars['ot'] != 'pdf') return; - if (trim($parm) == '') return; - return $this->e107->tp->parseTemplate('{'.$parm.'}', FALSE, $this); - } - - public function sc_ec_ifnot_pdf($parm = '') - { - if ($this->printVars['ot'] == 'pdf') return; - if (trim($parm) == '') return; - return $this->e107->tp->parseTemplate('{'.$parm.'}', FALSE, $this); - } - -} // END - shortcode class - - -?> +e107 = e107::getInstance(); + } + + + /** + * Set the current date for calendar display + * + * Routine then calculates various values needed for shortcodes + * + * @param array $curDate - As returned by getdate() + * + * @return BOOLEAN TRUE + */ + public function setCalDate($curDate) + { + $this->ds = varset($curDate['ds'],''); + + $this->day = varset($curDate['mday'], 0); // Day number being shown - rarely relevant + $this->month = $curDate['mon']; // Number of month being shown + $this->year = $curDate['year']; // Number of year being shown + $this->monthStart = mktime(0, 0, 0, $curDate['mon'], 1, $curDate['year']); // Start of month to be shown + $this->monthEnd = mktime(0, 0, 0, $curDate['mon'] + 1, 1, $curDate['year']) - 1; // End of month to be shown + + + // Calculate date code for previous month + $this->prevMonth = $curDate['mon']-1; + $prevYear = $curDate['year']; + if ($this->prevMonth == 0) + { + $this->prevMonth = 12; + $prevYear--; + } + $this->previous = mktime(0, 0, 0, $this->prevMonth, 1, $prevYear); // Previous month - Used by nav + + // Calculate date code for next month + $this->nextMonth = $curDate['mon'] + 1; + $nextYear = $curDate['year']; + if ($this->nextMonth == 13) + { + $this->nextMonth = 1; + $nextYear++; + } + $this->next = mktime(0, 0, 0, $this->nextMonth, 1, $nextYear); // Next month - used by nav + + + $this->py = $curDate['year']-1; // Number of previous year for nav + $this->prevLink = mktime(0, 0, 0, $curDate['mon'], 1, $this->py); + $this->ny = $curDate['year'] + 1; // Number of next year for nav + $this->nextLink = mktime(0, 0, 0, $curDate['mon'], 1, $this->ny); + + $this->prop = gmmktime(0, 0, 0, $curDate['mon'], $curDate['mday'], $curDate['year']); // Sets start date for new event entry + + $this->nowMonth = $this->ecalClass->cal_date['mon']; + $this->nowYear = $this->ecalClass->cal_date['year']; + $this->nowDay = $this->ecalClass->cal_date['mday']; + return TRUE; + } + + // Navigation shortcodes + public function sc_ec_prev_month($parm = '') + { + return "<< ".$this->months[($this->prevMonth-1)].""; + } + + public function sc_ec_next_month($parm = '') + { + return " ".$this->months[($this->nextMonth-1)]." >>"; + } + + + public function sc_ec_current_month($parm = '') + { + if($this->ecalClass->pref['eventpost_dateformat'] == 'my') + { + return $this->months[($this->month-1)].' '.$this->year; + } + return $this->year.' '.$this->months[($this->month-1)]; + } + + + public function sc_ec_prev_year($parm = '') + { + return "<< ".$this->py.""; + } + + public function sc_ec_next_year($parm = '') + { + return "".$this->ny." >>"; + } + + + public function sc_ec_month_list($parm = '') + { + $ret = ''; + for ($ii = 0; $ii < 12; $ii++) + { + $monthJump = mktime(0, 0, 0, $ii+1, 1, $this->year); + $ret .= "".$this->monthabb[$ii]."  "; + } + return $ret; + } + + + // Navigation buttons + public function sc_ec_nav_but_allevents($parm = '') + { + $allevents = (e_PAGE == "event.php" ? EC_LAN_96 : EC_LAN_93); + return ""; + } + + public function sc_ec_nav_but_viewcat($parm = '') + { + return ""; + } + + public function sc_ec_nav_but_subscription($parm = '') + { + if (isset($this->ecalClass->pref['eventpost_asubs']) && ($this->ecalClass->pref['eventpost_asubs']>0) && USER) + { + return ""; + } + return ''; + } + + public function sc_ec_nav_but_enterevent($parm = '') + { + $ret = ""; + if ($this->ecalClass->cal_super || check_class($this->ecalClass->pref['eventpost_admin'])) + { + $ret .= ""; + } + return $ret; + } + + public function sc_ec_nav_linkcurrentmonth($parm = '') + { + $ret = ''; + if ($this->month != $this->nowMonth || $this->year != $this->nowYear || $this->ds == 'one') + { // Just jump to current page without a query part - that will default to today + $ret = ""; + } + return $ret; + } + + public function sc_ec_nav_but_printlists($parm = '') + { + if (isset($this->ecalClass->pref['eventpost_printlists']) && ($this->ecalClass->pref['eventpost_printlists']>0) && USER) + { + return ""; + } + else + return 'Cant print lists'; + } + + // Categories listing + public function sc_ec_nav_categories($parm = '') + { + if ($this->ourDB == NULL) + { + $this->ourDB = new db; // @todo use new method + } + ($parm == 'nosubmit') ? $insert = '' : $insert = "onchange='this.form.submit()'"; + $ret = "\n"; + return $ret; + } + + +// Event information shortcodes +//----------------------------- + + + public function sc_ec_event_location($parm = '') + { + return $this->event['event_location']; + } + + public function sc_ec_event_recent_icon() + { + return $this->sc_ec_calendar_calendar_recent_icon(); + } + + + + public function sc_ec_if_allday($parm= '') + { + if (!$this->event['event_allday']) return ''; + if (trim($parm) == '') return ''; + return $this->e107->tp->parseTemplate('{'.$parm.'}', FALSE, $this); + } + + public function sc_ec_ifnot_allday($parm= '') + { + if ($this->event['event_allday']) return ''; + if (trim($parm) == '') return ''; + return $this->e107->tp->parseTemplate('{'.$parm.'}', FALSE, $this); + } + + public function sc_ec_ifnot_sameday($parm= '') + { + if (intval($this->event['event_end']/86400) == intval($this->event['event_start']/86400)) return ''; + if (!$this->event['event_allday']) return ''; + if (trim($parm) == '') return; + return $this->e107->tp->parseTemplate('{'.$parm.'}', FALSE, $this); + } + + public function sc_ec_if_sameday($parm= '') + { + if (intval($this->event['event_end']/86400) != intval($this->event['event_start']/86400)) return ''; + if (!$this->event['event_allday']) return ''; + if (trim($parm) == '') return; + return $this->e107->tp->parseTemplate('{'.$parm.'}', FALSE, $this); + } + + + +// Event mailout shortcodes +//-------------------------- + public function sc_ec_mail_heading_date($parm) + { + if (isset($parm) && ($parm !== "")) + { + return strftime($parm,$this->event['event_start']); + } + else + { + return $this->ecalClass->event_date_string($this->event['event_start']); + } + } + + + public function sc_ec_mail_date_start($parm) + { + return $this->sc_ec_mail_heading_date($parm); + } + + + public function sc_ec_mail_date_start_allday($parm) + { + if ($this->event['event_allday'] != 1) return ''; + return $this->sc_ec_mail_heading_date($parm); + } + + + public function sc_ec_mail_date_start_timed($parm) + { + if ($this->event['event_allday'] == 1) return ''; + return $this->sc_ec_mail_heading_date($parm); + } + + + public function sc_ec_mail_time_start($parm) + { + if ($this->event['event_allday'] == 1) return ''; + return $this->ecalClass->time_string($this->event['event_start']); + } + + + public function sc_ec_mail_date_end($parm = '') + { + if ($this->event['event_allday'] ||($this->event['event_end'] == $this->event['event_start'])) return ''; + if ($parm !== '') + { + return strftime($parm,$this->event['event_end']); + } + return $this->ecalClass->event_date_string($this->event['event_end']); + } + + + + public function sc_ec_mail_time_end($parm = '') + { + if ($this->event['event_allday'] ||($this->event['event_end'] == $this->event['event_start'])) return ''; + $endds = $ecal_class->time_string($this->event['event_end']); + return $endds; + } + + + public function sc_ec_mail_title($parm = '') + { + return $this->event['event_title']; + } + + + public function sc_ec_mail_id($parm = '') + { + return 'calevent'.$this->event['event_id']; + } + + + public function sc_ec_mail_details($parm = '') + { + return $this->e107->tp->toHTML($this->event['event_details'], TRUE,'E_BODY'); + } + + + + public function sc_ec_mail_category($parm = '') + { + return $this->event['event_cat_name']; + } + + + + + public function sc_ec_mail_contact($parm = '') + { + if ($this->event['event_contact'] == '') return ''; + return $this->e107->tp->toHTML($this->event['event_contact'],TRUE,'LINKTEXT'); + } + + + public function sc_ec_mail_thread($parm = '') + { + return $this->event['event_thread']; + } + + + public function sc_ec_mail_link($parm = '') + { + $cal_dayarray = getdate($this->event['event_start']); + $cal_linkut = mktime(0 , 0 , 0 , $cal_dayarray['mon'], $cal_dayarray['mday'], $cal_dayarray['year']).".one"; // ALways need "one" + return ' '.SITEURLBASE.e_PLUGIN_ABS.'calendar_menu/event.php?'.$cal_linkut.' '; + } + + + public function sc_ec_mail_short_date($parm = '') + { + return $this->ecalClass->next_date_string($this->event['event_start']); + } + + + // Codes can be used to return a LAN to help with multi-language + public function sc_ec_mail_subject($parm = '') + { + return EC_MAILOUT_SUBJECT; + } + + +//------------------------------------------ +// CALENDAR CALENDAR - 'Big' calendar +//------------------------------------------ + public function sc_ec_calendar_calendar_header_day($parm = '') + { + if(isset($this->ecalClass->pref['eventpost_lenday']) && $this->ecalClass->pref['eventpost_lenday']) + { + return "".$this->e107->tp->text_truncate($this->headerDay,$this->ecalClass->pref['eventpost_lenday'],'').""; + } + else + { + return "".$this->headerDay.""; + } + } + + + public function sc_ec_calendar_calendar_day_today_heading() + { + return "".$this->days[($this->curDay-1)]." [".EC_LAN_TODAY."]"; + } + + + public function sc_ec_calendar_calendar_day_event_heading() + { + return "".$this->days[($this->curDay-1)].""; + } + + + public function sc_ec_calendar_calendar_day_empty_heading() + { + return "".$this->days[($this->curDay-1)].""; + } + + + public function sc_ec_calendar_calendar_recent_icon() + { + if (!isset($this->event['is_recent'])) return ''; + if (!$this->event['startofevent']) return ''; // Only display on first day of multi-day events + if (is_readable(EC_RECENT_ICON)) + { + return " "; + } + return "R"; + } + + + public function sc_ec_event_page_title() + { + switch ($this->ds) + { + case 'one' : return EC_LAN_80.': '.$this->day.' '.$this->months[$this->month-1]; +// case 'event' : return EC_LAN_122.': '.$this->day.' '.$this->months[$this->month-1]; + case 'event' : return EC_LAN_122; + default : return EC_LAN_80; + } + } + + + public function sc_ec_showevent_image() + { + //TODO review bullet + $img = ''; + if($this->event['event_cat_icon'] && file_exists(e_PLUGIN.'calendar_menu/images/'.$this->event['event_cat_icon'])) + { + $img = "event['event_cat_icon']."' alt='' height='".$this->event['imagesize']."' width='".$this->event['imagesize']."' />"; + } + elseif(defined('BULLET')) + { + $img = ''; + } + elseif(file_exists(THEME.'images/bullet2.gif')) + { + $img = ''; + } + return $img; + } + + + public function sc_ec_showevent_indicat() + { + return $this->event['indicat']; + } + + + + public function sc_ec_showevent_heading() + { + $linkut = mktime(0 , 0 , 0 , $this->month, $this->curDay, $this->year); + $show_title = $this->e107->tp->toHTML($this->event['event_title'],FALSE,'TITLE'); // Remove entities in case need to truncate + if(isset($this->event['fulltopic']) && !$this->event['fulltopic']) + { + $show_title = $this->e107->tp->text_truncate($show_title, 10, '...'); + } + if($this->event['startofevent']) + { + return "event['event_id']."'>".$show_title.""; + } + else + { + return "event['event_id']."'>".$show_title.""; + } + } + + + public function sc_ec_eventlist_caption() + { + $ret = ''; + if ($this->ds == 'one') + { + $ret = EC_LAN_111.$this->months[$this->month-1].' '.$this->day; + } + elseif ($this->ds != 'event') + { + $ret = EC_LAN_112.$this->months[$this->month-1]; + } + return $ret; + } + + +//--------------------------------------------------- +// EVENT SHOWEVENT (Detail of individual events) +//--------------------------------------------------- + + public function sc_ec_event_heading_date() + { + return $this->ecalClass->event_date_string($this->event['event_start']); + } + + // Same code as previous + public function sc_ec_event_date_start() + { + return $this->ecalClass->event_date_string($this->event['event_start']); + } + + + public function sc_ec_event_time_start() + { + if ($this->event['event_allday'] == 1) return ''; + return $this->ecalClass->time_string($this->event['event_start']); + } + + + public function sc_ec_event_date_end() + { + if ($this->event['event_end'] == $this->event['event_start']) return ''; + return $this->ecalClass->event_date_string($this->event['event_end']); + } + + + public function sc_ec_event_time_end() + { + if ($this->event['event_allday'] ||($this->event['event_end'] == $this->event['event_start'])) return ''; + return $this->ecalClass->time_string($this->event['event_end']); + } + + + public function sc_ec_event_title() + { + return $this->event['event_title']; + } + + + public function sc_ec_event_cat_icon() + { + if ($this->event['event_cat_icon'] && is_readable(e_PLUGIN.'calendar_menu/images/'.$this->event['event_cat_icon'])) + { + return " "; + } + return ''; + } + + + public function sc_ec_event_id() + { + return 'calevent'.$this->event['event_id']; + } + + + public function sc_ec_event_displaystyle() + { // Returns initial state of expandable blocks + if (($this->ds=='event') || ($this->ds=='one')) + { + return ''; // Let block display + } + return 'display: none; '; + } + + + /** + * Display class for event display block - to manage expansion/contraction + * When displaying a single event, or a single day's events, block to be expanded + * For event lists, block to be contracted + * + * @param int $param - optional supplementary list of classes to apply + * + * @return string - + */ + public function sc_ec_event_displayclass($parm='') + { + if (($this->ds=='event') || ($this->ds=='one')) + { // Single event or one day's events - block expanded + return " class='{$parm}'"; + } + return " class='e-show-if-js e-hideme {$parm}'"; // Block contracted +// return " class='e-hide-if-js e-showme {$parm}'"; // Block contracted + } + + + public function sc_ec_event_details() + { + return $this->e107->tp->toHTML($this->event['event_details'], TRUE, 'BODY'); + } + + + public function sc_ec_event_category() + { + return $this->event['event_cat_name']; + } + + + public function sc_ec_event_author() + { + $lp = explode(".", $this->event['event_author'],2); // Split into userid.username + if (preg_match("/[0-9]+/", $lp[0])) + { + $event_author_id = $lp[0]; + $event_author_name = $lp[1]; + } + if(USER) + { + return "".$event_author_name.""; + } + return $event_author_name; + } + + + public function sc_ec_event_contact() + { + if ($this->event['event_contact'] == '') return ''; + $tm = $this->event['event_contact']; + if (strpos($tm,'[') === FALSE) + { // Add a bbcode if none exists + $tm = '[link=mailto:'.trim($tm).']'.substr($tm,0,strpos($tm,'@')).'[/link]'; + } + return $this->e107->tp->toHTML($tm,TRUE,'LINKTEXT'); // Return obfuscated email link + } + + + public function sc_ec_event_thread() + { + if (isset($this->event['event_thread']) && ($this->event['event_thread'] != '')) + { + return " ".EC_LAN_39.""; + } + return ''; + } + + + public function sc_ec_event_options() + { + $event_author_name = strstr(varset($this->event['event_author'],'0.??'),'.'); + if (USERNAME == $event_author_name || $this->ecalClass->cal_super || check_class($this->ecalClass->pref['eventpost_admin'])) + { + return "".EC_LAN_35 . "  event['event_id']."'>".EC_LAN_36.""; + } + } + + + public function sc_ec_ec_event_link() + { + $cal_dayarray = getdate($this->event['event_start']); + $cal_linkut = mktime(0 , 0 , 0 , $cal_dayarray['mon'], $cal_dayarray['mday'], $cal_dayarray['year']).'.one'; // ALways need "one" + return ' '.e_PLUGIN_ABS.'calendar_menu/event.php?'.$cal_linkut.' '; + } + + + public function sc_ec_event_event_date_time() + { + $et = 0; + if (intval($this->event['event_end']/86400) == intval($this->event['event_start']/86400)) $et += 1; + if ($this->event['event_allday']) $et += 2; + if (is_array($this->eventDisplayCodes)) + { + return $this->e107->tp->parseTemplate($this->eventDisplayCodes[$et], FALSE, $this); + } + return '--** No template set **--'; + } + + + public function sc_ec_event_short_date() + { + return $this->ecalClass->next_date_string($this->event['event_start']); + } + + +//------------------------------------------ +// EVENT ARCHIVE (list of next events at bottom of event list) +//------------------------------------------ + + public function sc_ec_eventarchive_caption() + { + if ($this->numEvents == 0) + { + return EC_LAN_137; + } + return str_replace('-NUM-', $this->numEvents, EC_LAN_62); + } + + + public function sc_ec_eventarchive_date() + { + $startds = $this->ecalClass->event_date_string($this->event['event_start']); + return "event['event_id']."'>".$startds.""; + } + + + public function sc_ec_eventarchive_details() + { + $number = 40; + $rowtext = $this->e107->tp->toHTML($this->event['event_details'], TRUE, 'BODY'); + $rowtext = strip_tags($rowtext); + $words = explode(' ', $rowtext); + $ret = implode(' ', array_slice($words, 0, $number)); + if(count($words) > $number) + { + $ret .= ' '.EC_LAN_133.' '; + } + return $ret; + } + + + public function sc_ec_eventarchive_empty() + { + return EC_LAN_37; + } + + + public function sc_ec_eventarchive_heading() + { + return $this->event['event_title']; + } + + + +// FORTHCOMING EVENTS MENU +//--------------------------- + + function sc_ec_next_event_recent_icon() + { + if (!$this->ecalClass->pref['eventpost_fe_showrecent']) return; + if (!isset($this->event['is_recent'])) return; + if (is_readable(EC_RECENT_ICON)) + { + return " "; + } + return ''; + } + + + public function sc_ec_next_event_time() + { + if ($this->event['event_allday'] != 1) + { + return $this->ecalClass->time_string($this->event['event_start']); + } + return ''; + } + + + public function sc_ec_next_event_date() + { + return $this->ecalClass->next_date_string($this->event['event_start']); + } + + + public function sc_ec_next_event_title() + { + if (isset($this->ecalClass->pref['eventpost_namelink']) && ($this->ecalClass->pref['eventpost_namelink'] == '2') && (isset($this->event['event_thread']) && ($this->event['event_thread'] != ''))) + { + $fe_event_title = ""; + } + else + { + $fe_event_title = "event['event_id']."'>"; + } + $fe_event_title .= $this->event['event_title'].""; + return $fe_event_title; + } + + + public function sc_ec_next_event_icon() + { + $fe_icon_file = ''; + if ($this->ecalClass->pref['eventpost_showcaticon'] == 1) + { + if($this->event['event_cat_icon'] && is_readable(e_PLUGIN.'calendar_menu/images/'.$this->event['event_cat_icon'])) + { + $fe_icon_file = e_PLUGIN_ABS.'calendar_menu/images/'.$this->event['event_cat_icon']; + } + elseif(defined('BULLET')) + { + $fe_icon_file = THEME_ABS.'images/'.BULLET; + } + elseif(file_exists(THEME.'images/bullet2.gif')) + { + $fe_icon_file = THEME_ABS.'images/bullet2.gif'; + } + } + return $fe_icon_file; + } + + + public function sc_ec_next_event_gap() + { + if ($this->numEvents) return '

'; // Return a newline as a gap on all but last item + return ''; + } + + + + +// Specific to the 'listings' page +//-------------------------------- + + public function sc_ec_pr_list_title() + { + return $this->printVars['lt']; + } + + + + public function sc_ec_pr_cat_list() + { + if (is_array($this->printVars['cat'])) + { + return implode(', ',$this->printVars['cat']); + } + return $this->printVars['cat']; + } + + public function sc_ec_pr_change_year() + { + if (!$this->changeFlags['yc']) return ''; + $thisevent_start_date = $this->ecalClass->gmgetdate($this->event['event_start']); + return $thisevent_start_date['year']; + } + + public function sc_ec_pr_change_month() + { + if (!$this->changeFlags['mc']) return ''; + $thisevent_start_date = $this->ecalClass->gmgetdate($this->event['event_start']); + return $thisevent_start_date['month']; + } + + + public function sc_ec_pr_list_start($parm = '') + { + if ($parm) + { + return $this->ecalClass->event_date_string($this->printVars['sd']); + } + return strftime($parm,$this->printVars['sd']); + } + + public function sc_ec_pr_list_end($parm = '') + { + if ($parm) + { + return $this->ecalClass->event_date_string($this->printVars['ed']); + } + return strftime($parm,$this->printVars['ed']); + } + + + public function sc_ec_now_date($parm = '') + { + if ($parm == '') return $this->ecalClass->event_date_string(time()); + return strftime($parm,time()); + } + + public function sc_ec_now_time($parm = '') + { + if ($parm == '') return $this->ecalClass->time_string(time()); + return strftime($parm,time()); + } + + + public function sc_ec_print_button() + { + if ($this->printVars['ot'] != 'print') return; + return ""; + } + + + public function sc_ec_if_print($parm = '') + { + if ($this->printVars['ot'] != 'print') return; + if (trim($parm) == '') return; + return $this->e107->tp->parseTemplate('{'.$parm.'}', FALSE, $this); + } + + public function sc_ec_ifnot_print($parm = '') + { + if ($this->printVars['ot'] == 'print') return; + if (trim($parm) == '') return; + return $this->e107->tp->parseTemplate('{'.$parm.'}', FALSE, $this); + } + + public function sc_ec_if_display($parm = '') + { + if ($this->printVars['ot'] != 'display') return; + if (trim($parm) == '') return; + return $this->e107->tp->parseTemplate('{'.$parm.'}', FALSE, $this); + } + + public function sc_ec_ifnot_display($parm = '') + { + if ($this->printVars['ot'] == 'display') return; + if (trim($parm) == '') return; + return $this->e107->tp->parseTemplate('{'.$parm.'}', FALSE, $this); + } + + public function sc_ec_if_pdf($parm = '') + { + if ($this->printVars['ot'] != 'pdf') return; + if (trim($parm) == '') return; + return $this->e107->tp->parseTemplate('{'.$parm.'}', FALSE, $this); + } + + public function sc_ec_ifnot_pdf($parm = '') + { + if ($this->printVars['ot'] == 'pdf') return; + if (trim($parm) == '') return; + return $this->e107->tp->parseTemplate('{'.$parm.'}', FALSE, $this); + } + +} // END - shortcode class + + +?> diff --git a/e107_plugins/calendar_menu/calendar_template.php b/e107_plugins/calendar_menu/calendar_template.php index 95099b8e4..8fbd5a881 100644 --- a/e107_plugins/calendar_menu/calendar_template.php +++ b/e107_plugins/calendar_menu/calendar_template.php @@ -1,320 +1,322 @@ -"; -$sc_style['EC_PREV_MONTH']['post'] = ""; - -$sc_style['EC_CURRENT_MONTH']['pre'] = ""; -$sc_style['EC_CURRENT_MONTH']['post'] = ""; - -$sc_style['EC_NEXT_MONTH']['pre'] = ""; -$sc_style['EC_NEXT_MONTH']['post'] = ""; - -$sc_style['EC_PREV_YEAR']['pre'] = ''; -$sc_style['EC_PREV_YEAR']['post'] = ''; - -$sc_style['EC_MONTH_LIST']['pre'] = ''; -$sc_style['EC_MONTH_LIST']['post'] = ''; - -$sc_style['EC_NEXT_YEAR']['pre'] = ''; -$sc_style['EC_NEXT_YEAR']['post'] = ''; - - -$CALENDAR_TIME_TABLE = " - - - - - -\n - - - - -\n -
{EC_PREV_MONTH}{EC_CURRENT_MONTH}{EC_NEXT_MONTH}
{EC_PREV_YEAR}{EC_MONTH_LIST}{EC_NEXT_YEAR}
"; - - - -// NAVIGATION BUTTONS -//$sc_style['NAV_LINKCURRENTMONTH']['pre'] = ""; -//$sc_style['NAV_LINKCURRENTMONTH']['post'] = ""; -$sc_style['EC_NAV_LINKCURRENTMONTH']['pre'] = ""; -$sc_style['EC_NAV_LINKCURRENTMONTH']['post'] = ""; - -$CALENDAR_NAVIGATION_TABLE = " -
-
- - - -\n -
{EC_NAV_CATEGORIES} {EC_NAV_BUT_ALLEVENTS} {EC_NAV_BUT_VIEWCAT} {EC_NAV_BUT_ENTEREVENT} {EC_NAV_BUT_SUBSCRIPTION} {EC_NAV_BUT_PRINTLISTS} {EC_NAV_LINKCURRENTMONTH}
-
-
"; - - - -// EVENT LIST ------------------------------------------------------------ -$sc_style['EC_EVENTLIST_CAPTION']['pre'] = ""; -$sc_style['EC_EVENTLIST_CAPTION']['post'] = ":

\n"; - -$EVENT_EVENTLIST_TABLE_START = "{EC_EVENTLIST_CAPTION}"; -$EVENT_EVENTLIST_TABLE_END = "
"; - - - -// EVENT ARCHIVE ------------------------------------------------------------ -$sc_style['EC_EVENTARCHIVE_CAPTION']['pre'] = ""; -$sc_style['EC_EVENTARCHIVE_CAPTION']['post'] = "\n"; - -$EVENT_ARCHIVE_TABLE_START = "
{EC_EVENTARCHIVE_CAPTION}"; -$EVENT_ARCHIVE_TABLE = " - - - -\n"; -//
{EVENTARCHIVE_DETAILS} -$EVENT_ARCHIVE_TABLE_EMPTY = "\n"; -$EVENT_ARCHIVE_TABLE_END = "
{EC_EVENT_RECENT_ICON}{EC_EVENTARCHIVE_DATE}{EC_EVENTARCHIVE_HEADING}
{EC_EVENTARCHIVE_EMPTY}
"; - - - -// EVENT SHOW EVENT ------------------------------------------------------------ -$EVENT_EVENT_TABLE_START = ""; -$EVENT_EVENT_TABLE_END = "
"; - -$sc_style['EC_EVENT_HEADING_DATE']['pre'] = ""; -$sc_style['EC_EVENT_HEADING_DATE']['post'] = ""; - -$sc_style['EC_EVENT_DETAILS']['pre'] = ""; -$sc_style['EC_EVENT_DETAILS']['post'] = "\n"; - -$sc_style['EC_EVENT_LOCATION']['pre'] = "".EC_LAN_32." "; -$sc_style['EC_EVENT_LOCATION']['post'] = ""; - -$sc_style['EC_EVENT_AUTHOR']['pre'] = "".EC_LAN_31." "; -$sc_style['EC_EVENT_AUTHOR']['post'] = " "; - -$sc_style['EC_EVENT_CONTACT']['pre'] = "".EC_LAN_33." "; -$sc_style['EC_EVENT_CONTACT']['post'] = " "; - -$sc_style['EC_EVENT_THREAD']['pre'] = ""; -$sc_style['EC_EVENT_THREAD']['post'] = "\n"; - -$sc_style['EC_EVENT_CATEGORY']['pre'] = "".EC_LAN_30." "; -$sc_style['EC_EVENT_CATEGORY']['post'] = " "; - -$sc_style['EC_EVENT_DATE_START']['pre'] = ''; -$sc_style['EC_EVENT_DATE_START']['post'] = ''; - -$sc_style['EC_EVENT_TIME_START']['pre'] = ''; -$sc_style['EC_EVENT_TIME_START']['post'] = ''; - -$sc_style['EC_EVENT_DATE_END']['pre'] = ''; -$sc_style['EC_EVENT_DATE_END']['post'] = ''; - -$sc_style['EC_EVENT_TIME_END']['pre'] = ''; -$sc_style['EC_EVENT_TIME_END']['post'] = ''; - -$sc_style['EC_EVENT_EVENT_DATE_TIME']['pre'] = "".EC_LAN_29." "; -$sc_style['EC_EVENT_EVENT_DATE_TIME']['post'] = ''; - -$sc_style['EC_IFNOT_ALLDAY']['pre'] = EC_LAN_144; -$sc_style['EC_IFNOT_ALLDAY']['post'] = ""; - -// The $EVENT_EVENT_DATETIME strings are used with the EC_EVENT_EVENT_DATE_TIME shortcode. -// There are four cases, each with a corresponding index into $EVENT_EVENT_DATETIME: -// 0 - Normal event, starting and finishing on different dates (the 'original' default) -// 1 - Normal event, starting and finishing on the same day -// 2 - All-day event, starting and finishing on different days -// 3 - All-day event, starting and finishing on the same day -$EVENT_EVENT_DATETIME[0] = "{EC_EVENT_DATE_START}".EC_LAN_144."{EC_EVENT_TIME_START} ".EC_LAN_69." {EC_EVENT_DATE_END}{EC_IFNOT_ALLDAY=EC_EVENT_TIME_END}"; -$EVENT_EVENT_DATETIME[1] = "{EC_EVENT_DATE_START} ".EC_LAN_84." {EC_EVENT_TIME_START}".EC_LAN_85."{EC_EVENT_TIME_END}"; -$EVENT_EVENT_DATETIME[2] = "{EC_EVENT_DATE_START} ".EC_LAN_69." {EC_EVENT_DATE_END}"; -$EVENT_EVENT_DATETIME[3] = "{EC_EVENT_DATE_START}"; - - -$EVENT_EVENT_TABLE = " - - - {EC_EVENT_RECENT_ICON}{EC_EVENT_CAT_ICON}{EC_EVENT_HEADING_DATE}{EC_IFNOT_ALLDAY=EC_EVENT_TIME_START} - {EC_EVENT_TITLE} -
- - - \n - {EC_EVENT_LOCATION} - {EC_EVENT_DETAILS} - {EC_EVENT_THREAD} -
{EC_EVENT_AUTHOR} {EC_EVENT_CAT_ICON} {EC_EVENT_CATEGORY} {EC_EVENT_CONTACT} {EC_EVENT_OPTIONS}
{EC_EVENT_EVENT_DATE_TIME}
-
- -\n -"; - -//------------------------------------------ -// CALENDAR CALENDAR - 'Big' calendar -//------------------------------------------ -$CALENDAR_CALENDAR_START = " -
- ---------"; - -$CALENDAR_CALENDAR_END = " -\n
"; - -// 'Empty' cells where there's not a day at all -$CALENDAR_CALENDAR_DAY_NON = ""; - -//header row -$CALENDAR_CALENDAR_HEADER_START = ""; -$CALENDAR_CALENDAR_HEADER = "{EC_CALENDAR_CALENDAR_HEADER_DAY}"; -$CALENDAR_CALENDAR_HEADER_END = "\n"; - - -$CALENDAR_CALENDAR_WEEKSWITCH = "\n"; - -//today -$CALENDAR_CALENDAR_DAY_TODAY = " - -{EC_CALENDAR_CALENDAR_DAY_TODAY_HEADING}"; - -//day has events -$CALENDAR_CALENDAR_DAY_EVENT = " - -{EC_CALENDAR_CALENDAR_DAY_EVENT_HEADING}"; - -// no events and not today -$CALENDAR_CALENDAR_DAY_EMPTY = " - -{EC_CALENDAR_CALENDAR_DAY_EMPTY_HEADING}"; - -$CALENDAR_CALENDAR_DAY_END = ""; - -// CALENDAR SHOW EVENT -$sc_style['EC_CALENDAR_CALENDAR_RECENT_ICON']['pre'] = ""; -$sc_style['EC_CALENDAR_CALENDAR_RECENT_ICON']['post'] = ""; -$CALENDAR_SHOWEVENT = "{EC_CALENDAR_CALENDAR_RECENT_ICON}\n
{EC_SHOWEVENT_IMAGE}{EC_SHOWEVENT_INDICAT}{EC_SHOWEVENT_HEADING}
"; - - -//------------------------------------------ -// Calendar menu - 'Small' calendar -//------------------------------------------ -$CALENDAR_MENU_HDG_LINK_CLASS = "class='forumlink'"; // Class, and optional style, for menu heading if its a clickable link -$CALENDAR_MENU_START = "
"; -$CALENDAR_MENU_TABLE_START = ""; // colgroup doesn't work! - -$CALENDAR_MENU_END = "
"; - -// Blank cells at beginning and end -$CALENDAR_MENU_DAY_NON = "
"; - -//header row -$CALENDAR_MENU_HEADER_START = "\n"; -$CALENDAR_MENU_HEADER_FRONT = ""; -$CALENDAR_MENU_HEADER_BACK = ""; -$CALENDAR_MENU_HEADER_END = "\n"; - - -$CALENDAR_MENU_WEEKSWITCH = "\n"; - -// Start and end CSS for date cells - six cases to decode, determined by array index: -// 1 - Today, no events -// 2 - Some other day, no events -// 3 - Today with events -// 4 - Some other day with events -// 5 - today with events, one or more of which has recently been added/updated -// 6 - Some other day with events, one or more of which has recently been added/updated - - -//today, no events -$CALENDAR_MENU_DAY_START['1'] = ""; - -// no events and not today -$CALENDAR_MENU_DAY_START['2'] = ""; - -//day has events - same whether its today or not -$CALENDAR_MENU_DAY_START['3'] = ""; -$CALENDAR_MENU_DAY_START['4'] = ""; -// day has events, one which is recently added/updated -$CALENDAR_MENU_DAY_START['5'] = ""; -$CALENDAR_MENU_DAY_START['6'] = ""; -// Example highlight using background colour: -//$CALENDAR_MENU_DAY_START['5'] = ""; -//$CALENDAR_MENU_DAY_START['6'] = ""; - - -$CALENDAR_MENU_DAY_END['1'] = ""; -$CALENDAR_MENU_DAY_END['2'] = ""; -$CALENDAR_MENU_DAY_END['3'] = ""; -$CALENDAR_MENU_DAY_END['4'] = ""; -$CALENDAR_MENU_DAY_END['5'] = ""; -$CALENDAR_MENU_DAY_END['6'] = ""; - -//============================================================================ -// Next event menu template -$sc_style['EC_NEXT_EVENT_TIME']['pre'] = EC_LAN_144; -$sc_style['EC_NEXT_EVENT_TIME']['post'] = ""; -// Following are original styles -//$sc_style['NEXT_EVENT_ICON']['pre'] = " + + + +\n +
{EC_NAV_CATEGORIES} {EC_NAV_BUT_ALLEVENTS} {EC_NAV_BUT_VIEWCAT} {EC_NAV_BUT_ENTEREVENT} {EC_NAV_BUT_SUBSCRIPTION} {EC_NAV_BUT_PRINTLISTS} {EC_NAV_LINKCURRENTMONTH}
+ +"; + + + +// EVENT LIST ------------------------------------------------------------ +$sc_style['EC_EVENTLIST_CAPTION']['pre'] = ""; +$sc_style['EC_EVENTLIST_CAPTION']['post'] = ":

\n"; + +$EVENT_EVENTLIST_TABLE_START = "{EC_EVENTLIST_CAPTION}"; +$EVENT_EVENTLIST_TABLE_END = "
"; + + + +// EVENT ARCHIVE ------------------------------------------------------------ +$sc_style['EC_EVENTARCHIVE_CAPTION']['pre'] = ""; +$sc_style['EC_EVENTARCHIVE_CAPTION']['post'] = "\n"; + +$EVENT_ARCHIVE_TABLE_START = "
{EC_EVENTARCHIVE_CAPTION}"; +$EVENT_ARCHIVE_TABLE = " + + + +\n"; +//
{EVENTARCHIVE_DETAILS} +$EVENT_ARCHIVE_TABLE_EMPTY = "\n"; +$EVENT_ARCHIVE_TABLE_END = "
{EC_EVENT_RECENT_ICON}{EC_EVENTARCHIVE_DATE}{EC_EVENTARCHIVE_HEADING}
{EC_EVENTARCHIVE_EMPTY}
"; + + + +// EVENT SHOW EVENT ------------------------------------------------------------ +$EVENT_EVENT_TABLE_START = ""; +$EVENT_EVENT_TABLE_END = "
"; + +$sc_style['EC_EVENT_HEADING_DATE']['pre'] = ""; +$sc_style['EC_EVENT_HEADING_DATE']['post'] = ""; + +$sc_style['EC_EVENT_DETAILS']['pre'] = ""; +$sc_style['EC_EVENT_DETAILS']['post'] = "\n"; + +$sc_style['EC_EVENT_LOCATION']['pre'] = "".EC_LAN_32." "; +$sc_style['EC_EVENT_LOCATION']['post'] = ""; + +$sc_style['EC_EVENT_AUTHOR']['pre'] = "".EC_LAN_31." "; +$sc_style['EC_EVENT_AUTHOR']['post'] = " "; + +$sc_style['EC_EVENT_CONTACT']['pre'] = "".EC_LAN_33." "; +$sc_style['EC_EVENT_CONTACT']['post'] = " "; + +$sc_style['EC_EVENT_THREAD']['pre'] = ""; +$sc_style['EC_EVENT_THREAD']['post'] = "\n"; + +$sc_style['EC_EVENT_CATEGORY']['pre'] = "".EC_LAN_30." "; +$sc_style['EC_EVENT_CATEGORY']['post'] = " "; + +$sc_style['EC_EVENT_DATE_START']['pre'] = ''; +$sc_style['EC_EVENT_DATE_START']['post'] = ''; + +$sc_style['EC_EVENT_TIME_START']['pre'] = ''; +$sc_style['EC_EVENT_TIME_START']['post'] = ''; + +$sc_style['EC_EVENT_DATE_END']['pre'] = ''; +$sc_style['EC_EVENT_DATE_END']['post'] = ''; + +$sc_style['EC_EVENT_TIME_END']['pre'] = ''; +$sc_style['EC_EVENT_TIME_END']['post'] = ''; + +$sc_style['EC_EVENT_EVENT_DATE_TIME']['pre'] = "".EC_LAN_29." "; +$sc_style['EC_EVENT_EVENT_DATE_TIME']['post'] = ''; + +$sc_style['EC_IFNOT_ALLDAY']['pre'] = EC_LAN_144; +$sc_style['EC_IFNOT_ALLDAY']['post'] = ""; + +// The $EVENT_EVENT_DATETIME strings are used with the EC_EVENT_EVENT_DATE_TIME shortcode. +// There are four cases, each with a corresponding index into $EVENT_EVENT_DATETIME: +// 0 - Normal event, starting and finishing on different dates (the 'original' default) +// 1 - Normal event, starting and finishing on the same day +// 2 - All-day event, starting and finishing on different days +// 3 - All-day event, starting and finishing on the same day +$EVENT_EVENT_DATETIME[0] = "{EC_EVENT_DATE_START}".EC_LAN_144."{EC_EVENT_TIME_START} ".EC_LAN_69." {EC_EVENT_DATE_END}{EC_IFNOT_ALLDAY=EC_EVENT_TIME_END}"; +$EVENT_EVENT_DATETIME[1] = "{EC_EVENT_DATE_START} ".EC_LAN_84." {EC_EVENT_TIME_START}".EC_LAN_85."{EC_EVENT_TIME_END}"; +$EVENT_EVENT_DATETIME[2] = "{EC_EVENT_DATE_START} ".EC_LAN_69." {EC_EVENT_DATE_END}"; +$EVENT_EVENT_DATETIME[3] = "{EC_EVENT_DATE_START}"; + + +$EVENT_EVENT_TABLE = " + + + {EC_EVENT_RECENT_ICON}{EC_EVENT_CAT_ICON}{EC_EVENT_HEADING_DATE}{EC_IFNOT_ALLDAY=EC_EVENT_TIME_START} - {EC_EVENT_TITLE} +
+ + + \n + {EC_EVENT_LOCATION} + {EC_EVENT_DETAILS} + {EC_EVENT_THREAD} +
{EC_EVENT_AUTHOR} {EC_EVENT_CAT_ICON} {EC_EVENT_CATEGORY} {EC_EVENT_CONTACT} {EC_EVENT_OPTIONS}
{EC_EVENT_EVENT_DATE_TIME}
+
+ +\n +"; + +//------------------------------------------ +// CALENDAR CALENDAR - 'Big' calendar +//------------------------------------------ +$CALENDAR_CALENDAR_START = " +
+ +++++++++"; + +$CALENDAR_CALENDAR_END = " +\n
"; + +// 'Empty' cells where there's not a day at all +$CALENDAR_CALENDAR_DAY_NON = ""; + +//header row +$CALENDAR_CALENDAR_HEADER_START = ""; +$CALENDAR_CALENDAR_HEADER = "{EC_CALENDAR_CALENDAR_HEADER_DAY}"; +$CALENDAR_CALENDAR_HEADER_END = "\n"; + + +$CALENDAR_CALENDAR_WEEKSWITCH = "\n"; + +//today +$CALENDAR_CALENDAR_DAY_TODAY = " + +{EC_CALENDAR_CALENDAR_DAY_TODAY_HEADING}"; + +//day has events +$CALENDAR_CALENDAR_DAY_EVENT = " + +{EC_CALENDAR_CALENDAR_DAY_EVENT_HEADING}"; + +// no events and not today +$CALENDAR_CALENDAR_DAY_EMPTY = " + +{EC_CALENDAR_CALENDAR_DAY_EMPTY_HEADING}"; + +$CALENDAR_CALENDAR_DAY_END = ""; + +// CALENDAR SHOW EVENT +$sc_style['EC_CALENDAR_CALENDAR_RECENT_ICON']['pre'] = ""; +$sc_style['EC_CALENDAR_CALENDAR_RECENT_ICON']['post'] = ""; +$CALENDAR_SHOWEVENT = "{EC_CALENDAR_CALENDAR_RECENT_ICON}\n
{EC_SHOWEVENT_IMAGE}{EC_SHOWEVENT_INDICAT}{EC_SHOWEVENT_HEADING}
"; + + +//------------------------------------------ +// Calendar menu - 'Small' calendar +//------------------------------------------ +$CALENDAR_MENU_HDG_LINK_CLASS = "class='forumlink'"; // Class, and optional style, for menu heading if its a clickable link +$CALENDAR_MENU_START = "
"; +$CALENDAR_MENU_TABLE_START = ""; // colgroup doesn't work! + +$CALENDAR_MENU_END = "
"; + +// Blank cells at beginning and end +$CALENDAR_MENU_DAY_NON = "
"; + +//header row +$CALENDAR_MENU_HEADER_START = "\n"; +$CALENDAR_MENU_HEADER_FRONT = ""; +$CALENDAR_MENU_HEADER_BACK = ""; +$CALENDAR_MENU_HEADER_END = "\n"; + + +$CALENDAR_MENU_WEEKSWITCH = "\n"; + +// Start and end CSS for date cells - six cases to decode, determined by array index: +// 1 - Today, no events +// 2 - Some other day, no events +// 3 - Today with events +// 4 - Some other day with events +// 5 - today with events, one or more of which has recently been added/updated +// 6 - Some other day with events, one or more of which has recently been added/updated + + +//today, no events +$CALENDAR_MENU_DAY_START['1'] = ""; + +// no events and not today +$CALENDAR_MENU_DAY_START['2'] = ""; + +//day has events - same whether its today or not +$CALENDAR_MENU_DAY_START['3'] = ""; +$CALENDAR_MENU_DAY_START['4'] = ""; +// day has events, one which is recently added/updated +$CALENDAR_MENU_DAY_START['5'] = ""; +$CALENDAR_MENU_DAY_START['6'] = ""; +// Example highlight using background colour: +//$CALENDAR_MENU_DAY_START['5'] = ""; +//$CALENDAR_MENU_DAY_START['6'] = ""; + + +$CALENDAR_MENU_DAY_END['1'] = ""; +$CALENDAR_MENU_DAY_END['2'] = ""; +$CALENDAR_MENU_DAY_END['3'] = ""; +$CALENDAR_MENU_DAY_END['4'] = ""; +$CALENDAR_MENU_DAY_END['5'] = ""; +$CALENDAR_MENU_DAY_END['6'] = ""; + +//============================================================================ +// Next event menu template +$sc_style['EC_NEXT_EVENT_TIME']['pre'] = EC_LAN_144; +$sc_style['EC_NEXT_EVENT_TIME']['post'] = ""; +// Following are original styles +//$sc_style['NEXT_EVENT_ICON']['pre'] = " \ No newline at end of file diff --git a/e107_plugins/calendar_menu/e_bb.php b/e107_plugins/calendar_menu/e_bb.php index 977b06778..26f6d5f44 100644 --- a/e107_plugins/calendar_menu/e_bb.php +++ b/e107_plugins/calendar_menu/e_bb.php @@ -1,35 +1,37 @@ - - {BB=link}{BB=b}{BB=i}{BB=u}{BB=img}{BB=center}{BB=left}{BB=right} - {BB=bq}{BB=list}{BB=fontcol}{BB=fontsize}{BB=emotes} - {BB_PREIMAGEDIR=".e_IMAGE."newspost_images/} - {BB=preimage}{BB=prefile} -"; - - - + + {BB=link}{BB=b}{BB=i}{BB=u}{BB=img}{BB=center}{BB=left}{BB=right} + {BB=bq}{BB=list}{BB=fontcol}{BB=fontsize}{BB=emotes} + {BB_PREIMAGEDIR=".e_IMAGE."newspost_images/} + {BB=preimage}{BB=prefile} +"; + + + ?> \ No newline at end of file diff --git a/e107_plugins/calendar_menu/e_cron.php b/e107_plugins/calendar_menu/e_cron.php index 14c3b28cd..43e314aa7 100644 --- a/e107_plugins/calendar_menu/e_cron.php +++ b/e107_plugins/calendar_menu/e_cron.php @@ -1,413 +1,411 @@ -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, 'category' => 'plugin', '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_LOG.'calendar_mail.txt'; - if ($this->logHandle == NULL) - { - if (!($this->logHandle = fopen($logFilename, "a"))) - { // Problem creating file? - echo "File open failed!
"; - $this->logRequirement = 0; - return; - } - } - - if (fwrite($this->logHandle,($addTimeDate ? date('D j M Y G:i:s').': ' : '').$logText."\r\n") == FALSE) - { - $this->logRequirement = 0; - echo 'File write failed!
'; - } - - if ($closeAfter) - { - fclose($this->logHandle); - $this->logHandle = NULL; - } - } - - - - /** - * Called to process the calendar menu subscriptions list - the cron task must be set to call us once/day (typically at about 0100) - * - * Emails are added to the queue. - * Various events are logged in a text file - * - * @return none - */ - public function processSubs() - { - global $pref; - - require_once(e_PLUGIN.'calendar_menu/ecal_class.php'); - $this->ecalClass = new ecal_class; - - e107::getScParser(); - require_once(e_PLUGIN.'calendar_menu/calendar_shortcodes.php'); - if (is_readable(THEME.'ec_mailout_template.php')) - { // Has to be require - require(THEME.'ec_mailout_template.php'); - } - else - { - require(e_PLUGIN.'calendar_menu/ec_mailout_template.php'); - } - - - $this->startTime = mktime(0, 0, 0, date('n'), date('d'), date('Y')); // Date for start processing - setScVar('event_calendar_shortcodes', 'ecalClass', &$this->ecalClass); // Give shortcode a pointer to calendar class - - - $this->logRequirement = varset($pref['eventpost_emaillog'], 0); - if ($this->debugLevel >= 2) $this->logRequirement = 2; // Force full logging if debug - - - // Start of the 'real' code - $this->logLine("\r\n\r\n".LAN_EC_MAIL_06.date('D j M Y G:i:s')); - - - // Start with the 'in advance' emails - $cal_args = "select * from #event left join #event_cat on event_category=event_cat_id where (event_cat_subs>0 OR event_cat_force_class>0) and - event_cat_last < " . intval($this->startTime) . " and - event_cat_ahead > 0 and - event_start >= (" . intval($this->startTime) . "+(86400*(event_cat_ahead))) and - event_start < (" . intval($this->startTime) . "+(86400*(event_cat_ahead+1))) and - find_in_set(event_cat_notify,'1,3,5,7')"; - - $this->sendMailshot($cal_args, 'Advance',1, $calendar_shortcodes); - - - $insertString = 'event_cat_today < '.intval($this->startTime).' and'; - if ($this->debugLevel > 0) $insertString = ''; // Allows us to so a mailshot every call of cron tick - - // then for today - $cal_args = "select * from #event left join #event_cat on event_category=event_cat_id where (event_cat_subs>0 OR event_cat_force_class>0) and - {$insertString} event_start >= (" . intval($this->startTime) . ") and - event_start < (86400+" . intval($this->startTime) . ") and - find_in_set(event_cat_notify,'2,3,6,7')"; - - $this->sendMailshot($cal_args, 'today',2, $calendar_shortcodes); - - - // Finally do 'day before' emails (its an alternative to 'today' emails) - $cal_args = "select * from #event left join #event_cat on event_category=event_cat_id where (event_cat_subs>0 OR event_cat_force_class>0) and - {$insertString} event_start >= (" . intval($this->startTime) ." + 86400 ) and - event_start < (" . intval($this->startTime) ." + 172800) and - find_in_set(event_cat_notify,'4,5,6,7')"; - - $this->sendMailshot($cal_args, 'tomorrow',2, $calendar_shortcodes); - - - $this->logLine(' .. Run completed',TRUE, TRUE); - return TRUE; - } - - - // Function called to load in default templates (messages) if required - only accesses database once - function loadDefaultMessages() - { - if (($this->defaultMessage[1] != '') && ($this->defaultMessage[2] != '')) return; - $this->checkDB(); - if ($this->ourDB->db_Select('event_cat', 'event_cat_msg1,event_cat_msg2', "event_cat_name = '".EC_DEFAULT_CATEGORY."' ")) - { - if ($row = $this->ourDB->db_Fetch()) - { - $this->defaultMessage[1] = $row['event_cat_msg1']; - $this->defaultMessage[2] = $row['event_cat_msg2']; - } - } - // Put in generic message rather than nothing - will help flag omission - if ($this->defaultMessage[1] == '') $this->defaultMessage[1] = EC_LAN_146; - if ($this->defaultMessage[2] == '') $this->defaultMessage[2] = EC_LAN_147; - } - - - private function checkMailManager() - { - if ($this->mailManager == NULL) - { - require_once(e_HANDLER .'mail_manager_class.php'); - $this->mailManager = new e107MailManager(); - } - } - - - /* - Function to actually send a mailshot - */ - function sendMailshot($cal_query, $shot_type, $msg_num, $calendar_shortcodes) - { - global $pref; - - if ($this->logRequirement > 1) - { - $this->logLine(' Starting emails for '.$shot_type, FALSE, TRUE); - if ($this->debugLevel >= 2) $this->logLine("\r\n Query is: ".$cal_query); - } - - if ($num_cat_proc = $this->e107->sql->db_Select_gen($cal_query)) - { // Got at least one event to process here - if ($this->logRequirement > 1) - $this->logLine(' - '.$num_cat_proc.' categories found to process'); - - $this->checkDB(); // Make sure we've got another DB object - while ($thisevent = $this->e107->sql->db_Fetch()) - { // Process one event at a time - - $this->logLine(' Processing event: '.$event_title); - setScVar('event_calendar_shortcodes', 'event', $thisevent); // Save current values in shortcode - - // Note that event processed, and generate the email - if ($msg_num == 1) - { - $this->ourDB->db_Update('event_cat', 'event_cat_last='.time().' where event_cat_id='.intval($event_cat_id)); - $cal_msg = $thisevent['event_cat_msg1']; - } - else - { - $this->ourDB->db_Update('event_cat', 'event_cat_today='.time().' where event_cat_id='.intval($event_cat_id)); - $cal_msg = $thisevent['event_cat_msg2']; - } - - if (trim($cal_msg) == '') - { - $this->loadDefaultMessages(); - $cal_msg = $this->defaultMessage[$msg_num]; - } - - - // Parsing the template here means we can't use USER-related shortcodes - // Main ones which are relevant: MAIL_DATE_START, MAIL_TIME_START, MAIL_DATE_END, - // MAIL_TIME_END, MAIL_TITLE, MAIL_DETAILS, MAIL_CATEGORY, MAIL_LOCATION, - // MAIL_CONTACT, MAIL_THREAD (maybe). Also MAIL_LINK, MAIL_SHORT_DATE - // Best to strip entities here rather than at entry - handles old events as well - // Note that certain user-related substitutions will work, however - |USERID|, |USERNAME|, |DISPLAYNAME| - $cal_title = html_entity_decode($this->e107->tp->parseTemplate($pref['eventpost_mailsubject'], TRUE),ENT_QUOTES,CHARSET); - $cal_msg = html_entity_decode($this->e107->tp->parseTemplate($cal_msg, TRUE),ENT_QUOTES,CHARSET); - - // Four cases for the query: - // 1. No forced mailshots - based on event_subs table only Need INNER JOIN - // 2. Forced mailshot to members - send to all users (don't care about subscriptions) Don't need JOIN - // 3. Forced mailshot to group of members - based on user table only Don't need JOIN - // 4. Forced mailshot to group, plus optional subscriptions - use the lot! Need LEFT JOIN - // (Always block sent to banned members) - $manual_subs = (isset($pref['eventpost_asubs']) && ($pref['eventpost_asubs'] == '1')); - $subs_fields = ''; - $subs_join = ''; - $whereClause = ''; - $group_clause = ''; - - if ($event_cat_force_class != e_UC_MEMBER) - { // Cases 1, 3, 4 (basic query does for case 2) - if ((!$thisevent['event_cat_force_class']) || ($manual_subs)) - { // Cases 1 & 4 - need to join with event_subs database - $subs_fields = ", es.* "; - if ($thisevent['event_cat_force_class']) $subs_join = 'LEFT'; else $subs_join = 'INNER'; - $subs_join .= ' join `#event_subs` AS es on u.`user_id`=es.`event_userid` '; - $whereClause = ' es.`event_cat`='.intval($thisevent['event_category']).' '; - $group_clause = ' GROUP BY u.`user_id`'; - } - - if ($event_cat_force_class) - { // cases 3 and 4 - ... and check for involuntary subscribers - if ($whereClause) $whereClause .= ' OR '; - if ($thisevent['event_cat_force_class'] == e_UC_ADMIN) - { - $whereClause .= '(u.`user_admin` = 1 )'; - } - else - { - $whereClause .= "find_in_set('".intval($thisevent['event_cat_force_class'])."', u.`user_class`)"; - $group_clause = ' GROUP BY u.`user_id`'; - } - } - - if ($whereClause) $whereClause = ' AND ('.$whereClause.' ) '; - } // End of cases 1, 3, 4 - - $cal_emilargs = "SELECT u.`user_id`, u.`user_class`, u.`user_email`, u.`user_name`, u.`user_ban`, u.`user_admin`{$subs_fields} - from `#user` AS u {$subs_join} - WHERE u.`user_ban` = 0 {$whereClause} {$group_clause}"; - - - if ($this->debugLevel >= 2) - { - $this->logLine("\r\n Email selection query is: ".$cal_emilargs); - } - if ($num_shots = $this->ourDB->db_Select_gen($cal_emilargs)) - { - $this->logLine(' - '.$num_shots.' emails found to send'); - - // Definitely got some emails to send here - $this->checkMailManager(); // Make sure our mail manager is loaded - - // Start by adding the email details - $email = array( - 'mail_create_app' => 'calendar_menu', - 'mail_title' => str_replace('--REF--', intval(time()/3600), LAN_EC_MAIL_07), - 'mail_subject' => $cal_title, - 'mail_body' => $cal_msg, - 'mail_sender_email' => $pref['eventpost_mailaddress'], - 'mail_sender_name' => $pref['eventpost_mailfrom'], - 'mail_send_style' => 'textonly' - ); - if (FALSE === ($mailMainID = $this->mailManager->saveEmail($email, TRUE))) - { - $this->logLine('Error adding mail body to database - run abandoned'); - break; - } - $this->mailManager->mailInitCounters($mailMainID); // Initialise counters for emails added - - - // Now loop through adding users - while ($row = $this->ourDB->db_Fetch()) - { - if ($this->debugLevel == 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 ($this->logRequirement > 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.'); - } - } -} - - - +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, 'category' => 'plugin', '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_LOG.'calendar_mail.txt'; + if ($this->logHandle == NULL) + { + if (!($this->logHandle = fopen($logFilename, "a"))) + { // Problem creating file? + echo "File open failed!
"; + $this->logRequirement = 0; + return; + } + } + + if (fwrite($this->logHandle,($addTimeDate ? date('D j M Y G:i:s').': ' : '').$logText."\r\n") == FALSE) + { + $this->logRequirement = 0; + echo 'File write failed!
'; + } + + if ($closeAfter) + { + fclose($this->logHandle); + $this->logHandle = NULL; + } + } + + + + /** + * Called to process the calendar menu subscriptions list - the cron task must be set to call us once/day (typically at about 0100) + * + * Emails are added to the queue. + * Various events are logged in a text file + * + * @return none + */ + public function processSubs() + { + 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($this->ecal_class->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) + { + 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($this->ecal_class->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($this->ecal_class->pref['eventpost_asubs']) && ($this->ecal_class->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' => $this->ecal_class->pref['eventpost_mailaddress'], + 'mail_sender_name' => $this->ecal_class->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 ($this->debugLevel == 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 ($this->logRequirement > 1) + { + $this->logLine(' Send to '.$user_id.':'.$user_email.' Name: '.$user_name.' Result = '.$send_result); + } + } + $this->mailManager->mailUpdateCounters($mailMainID); // Save counters to DB + if ($this->mailManager->activateEmail($mailMainID, FALSE, time() + 80000) === TRUE) + { + $this->logLine("Email {$mailMainID} activated"); + } + else + { + $this->logLine("Error activating email {$mailMainID}"); + } + } + elseif ($num_cat === FALSE) + { + $this->logLine(' User read error for '.$shot_type.': '.$this->ourDB->$mySQLlastErrNum.':'.$this->ourDB->$mySQLlastErrText); + } + elseif ($this->logRequirement > 1) + { + $this->logLine(' - no users found.'); + } + } // while + + if ($this->logRequirement > 1) + { + $this->logLine(' Completed emails for '.$shot_type.' at '.date('D j M Y G:i:s')); + } + } + elseif ($num_cat === FALSE) + { + $this->logLine(' DB read error for '.$shot_type.': '.$this->e107->sql->$mySQLlastErrNum.':'.$this->e107->sql->$mySQLlastErrText); + } + elseif ($this->logRequirement > 1) + { + $this->logLine(' - no records found.'); + } + } +} + + + ?> \ No newline at end of file diff --git a/e107_plugins/calendar_menu/e_frontpage.php b/e107_plugins/calendar_menu/e_frontpage.php index 1da1fb410..8fc1d9fca 100644 --- a/e107_plugins/calendar_menu/e_frontpage.php +++ b/e107_plugins/calendar_menu/e_frontpage.php @@ -1,37 +1,39 @@ - EC_ADLAN_1, - 'page' => array( - array('page' => e_PLUGIN_ABS.'calendar_menu/calendar.php', 'title' => EC_ADLAN_A09 ), - array('page' => e_PLUGIN_ABS.'calendar_menu/event.php', 'title' => EC_LAN_163 )) - ); - + EC_ADLAN_1, + 'page' => array( + array('page' => e_PLUGIN_ABS.'calendar_menu/calendar.php', 'title' => EC_ADLAN_A09 ), + array('page' => e_PLUGIN_ABS.'calendar_menu/event.php', 'title' => EC_LAN_163 )) + ); + ?> \ No newline at end of file diff --git a/e107_plugins/calendar_menu/e_list.php b/e107_plugins/calendar_menu/e_list.php index 2c0e5b9b6..bf699cc48 100644 --- a/e107_plugins/calendar_menu/e_list.php +++ b/e107_plugins/calendar_menu/e_list.php @@ -1,110 +1,112 @@ -parent = $parent; - } - - function getListData() - { - $list_caption = $this->parent->settings['caption']; - $list_display = ($this->parent->settings['open'] ? "" : "none"); - - require_once('ecal_class.php'); - $ecal_class = new ecal_class; - - $current_day = $ecal_class->cal_date['mday']; - $current_month = $ecal_class->cal_date['mon']; - $current_year = $ecal_class->cal_date['year']; - - $current = mktime(0,0,0,$current_month, $current_day, $current_year); - - if($this->parent->mode == "new_page" || $this->parent->mode == "new_menu" ) - { - $lvisit = $this->parent->getlvisit(); - $qry = " event_datestamp>".intval($lvisit)." AND "; - } - else - { - $qry = ""; - } - - $bullet = $this->parent->getBullet($this->parent->settings['icon']); - - $qry = " - SELECT e.*, c.event_cat_name - FROM #event AS e - LEFT JOIN #event_cat AS c ON c.event_cat_id = e.event_category - WHERE ".$qry." e.event_start>='$current' AND c.event_cat_class REGEXP '".e_CLASS_REGEXP."' - ORDER BY e.event_start ASC LIMIT 0,".intval($this->parent->settings['amount']); - - if(!$event_items = $this->parent->e107->sql->db_Select_gen($qry)) - { - $list_data = LIST_CALENDAR_2; - } - else - { - while($row = $this->parent->e107->sql->db_Fetch()) - { - $record = array(); - $tmp = explode(".", $row['event_author']); - if($tmp[0] == "0") - { - $record['author'] = $tmp[1]; - } - elseif(is_numeric($tmp[0]) && $tmp[0] != "0") - { - $record['author'] = (USER ? "".$tmp[1]."" : $tmp[1]); - } - else - { - $record['author'] = ""; - } - - $rowheading = $this->parent->parse_heading($row['event_title']); - $record['icon'] = $bullet; - $record['heading'] = "".$rowheading.""; - $record['category'] = $row['event_cat_name']; - $record['date'] = ($this->parent->settings['date'] ? ($row['event_start'] ? $this->parent->getListDate($row['event_start']) : "") : ""); - $record['info'] = ''; - - $list_data[] = $record; - } - } - //return array with 'records', (global)'caption', 'display' - return array( - 'records'=>$list_data, - 'caption'=>$list_caption, - 'display'=>$list_display - ); - } -} - +parent = $parent; + } + + function getListData() + { + $list_caption = $this->parent->settings['caption']; + $list_display = ($this->parent->settings['open'] ? "" : "none"); + + require_once('ecal_class.php'); + $ecal_class = new ecal_class; + + $current_day = $ecal_class->cal_date['mday']; + $current_month = $ecal_class->cal_date['mon']; + $current_year = $ecal_class->cal_date['year']; + + $current = mktime(0,0,0,$current_month, $current_day, $current_year); + + if($this->parent->mode == "new_page" || $this->parent->mode == "new_menu" ) + { + $lvisit = $this->parent->getlvisit(); + $qry = " event_datestamp>".intval($lvisit)." AND "; + } + else + { + $qry = ""; + } + + $bullet = $this->parent->getBullet($this->parent->settings['icon']); + + $qry = " + SELECT e.*, c.event_cat_name + FROM #event AS e + LEFT JOIN #event_cat AS c ON c.event_cat_id = e.event_category + WHERE ".$qry." e.event_start>='$current' AND c.event_cat_class REGEXP '".e_CLASS_REGEXP."' + ORDER BY e.event_start ASC LIMIT 0,".intval($this->parent->settings['amount']); + + if(!$event_items = $this->parent->e107->sql->db_Select_gen($qry)) + { + $list_data = LIST_CALENDAR_2; + } + else + { + while($row = $this->parent->e107->sql->db_Fetch()) + { + $record = array(); + $tmp = explode(".", $row['event_author']); + if($tmp[0] == "0") + { + $record['author'] = $tmp[1]; + } + elseif(is_numeric($tmp[0]) && $tmp[0] != "0") + { + $record['author'] = (USER ? "".$tmp[1]."" : $tmp[1]); + } + else + { + $record['author'] = ""; + } + + $rowheading = $this->parent->parse_heading($row['event_title']); + $record['icon'] = $bullet; + $record['heading'] = "".$rowheading.""; + $record['category'] = $row['event_cat_name']; + $record['date'] = ($this->parent->settings['date'] ? ($row['event_start'] ? $this->parent->getListDate($row['event_start']) : "") : ""); + $record['info'] = ''; + + $list_data[] = $record; + } + } + //return array with 'records', (global)'caption', 'display' + return array( + 'records'=>$list_data, + 'caption'=>$list_caption, + 'display'=>$list_display + ); + } +} + ?> \ No newline at end of file diff --git a/e107_plugins/calendar_menu/e_mailout.php b/e107_plugins/calendar_menu/e_mailout.php index 4ea538d0d..d8ef1a136 100644 --- a/e107_plugins/calendar_menu/e_mailout.php +++ b/e107_plugins/calendar_menu/e_mailout.php @@ -1,208 +1,210 @@ - $v) - { - $res[] = intval($v); - } - } - return implode(',',$res); - } - - - /** - * Called to initialise data selection routine. - * Needs to save any queries or other information into internal variables, do initial DB queries as appropriate. - * Could in principle read all addresses and buffer them for later routines, if this is more convenient - * - * @param string $selectVals - array of selection criteria as returned by returnSelectors() - * - * @return integer Return number of records available (or 1 if unknown) on success, FALSE on failure - */ - public function selectInit($selectVals = FALSE) - { - - $sql = e107::getDb(); - - if (($selectVals === FALSE) || ($selectVals == '')) - { - return 0; // No valid selector - so no valid records - } - - $where = array(); - $qry = 'SELECT u.user_id, u.user_name, u.user_email, u.user_loginname, u.user_sess, u.user_lastvisit FROM `#event_subs` AS es'; - $qry .= ' LEFT JOIN `#user` AS u ON es.`event_subid` = u.`user_id` WHERE es.`event_cat` IN (\''.$selectVals.'\') AND u.`user_id` IS NOT NULL'; - $qry .= ' GROUP BY u.`user_id`'; -// echo "Selector query: ".$qry.'
'; - if (!( $this->mail_count = $sql->db_Select_gen($qry))) return FALSE; - $this->selectorActive = TRUE; - $this->mail_read = 0; - return $this->mail_count; - } - - - - /** - * Return an email address to add to the recipients list. Return FALSE if no more addresses to add - * - * @return array|boolean FALSE if no more addresses available; else an array: - * 'mail_recipient_id' - non-zero if a registered user, zero if a non-registered user. (Always non-zero from this class) - * 'mail_recipient_name' - user name - * 'mail_recipient_email' - email address to use - * 'mail_target_info' - array of info which might be substituted into email, usually using the codes defined by the editor. - * Array key is the code within '|...|', value is the string for substitution - */ - public function selectAdd() - { - $sql = e107::getDb(); - - if (!$this->selectorActive) return FALSE; - if (!($row = $sql->db_Fetch(MYSQL_ASSOC))) return FALSE; - $ret = array('mail_recipient_id' => $row['user_id'], - 'mail_recipient_name' => $row['user_name'], // Should this use realname? - 'mail_recipient_email' => $row['user_email'], - 'mail_target_info' => array( - 'USERID' => $row['user_id'], - 'DISPLAYNAME' => $row['user_name'], - 'SIGNUP_LINK' => $row['user_sess'], - 'USERNAME' => $row['user_loginname'], - 'USERLASTVISIT' => $row['user_lastvisit'] - ) - ); - $this->mail_read++; - return $ret; - } - - - - /** - * Called once all email addresses read, to do any housekeeping needed - * - * @return none - */ - public function select_close() - { - // Nothing to do here - } - - - - /** - * Called to show current selection criteria, and optionally allow edit - * - * @param boolean $allow_edit is TRUE to allow user to change the selection; FALSE to just display current settings - * @param string $selectVals is the current selection information - in the same format as returned by returnSelectors() - * - * @return array Returns array which is displayed in a table cell. - */ - public function showSelect($allow_edit = FALSE, $selectVals = FALSE) - { - $sql = e107::getDb(); - $frm = e107::getForm(); - $var = array(); - // $ret = ""; - $selects = array_flip(explode(',', $selectVals)); - - if ($sql->db_Select('event_cat', 'event_cat_id, event_cat_name', "event_cat_name != 'Default'")) - { - $c=0; - while ($row = $sql->db_Fetch(MYSQL_ASSOC)) - { - $checked = (isset($selects[$row['event_cat_id']])) ? " checked='checked'" : ''; - if ($allow_edit) - { - $var[$c]['caption'] = $row['event_cat_name']; - $var[$c]['html'] = $frm->checkbox('ec_category_sel[]',$row['event_cat_id'],$checked); - - /*$ret .= "";*/ - } - elseif($checked) - { - $var[$c]['html'] = $row['event_cat_name']; - $var[$c]['caption'] = LAN_EC_MAIL_03; - - /*$ret .= "";*/ - } - $c++; - } - } - else - { - $var[0]['caption'] = LAN_EC_MAIL_02; - $var[0]['html'] = ''; - } - - return $var; - } -} - - - + $v) + { + $res[] = intval($v); + } + } + return implode(',',$res); + } + + + /** + * Called to initialise data selection routine. + * Needs to save any queries or other information into internal variables, do initial DB queries as appropriate. + * Could in principle read all addresses and buffer them for later routines, if this is more convenient + * + * @param string $selectVals - array of selection criteria as returned by returnSelectors() + * + * @return integer Return number of records available (or 1 if unknown) on success, FALSE on failure + */ + public function selectInit($selectVals = FALSE) + { + + $sql = e107::getDb(); + + if (($selectVals === FALSE) || ($selectVals == '')) + { + return 0; // No valid selector - so no valid records + } + + $where = array(); + $qry = 'SELECT u.user_id, u.user_name, u.user_email, u.user_loginname, u.user_sess, u.user_lastvisit FROM `#event_subs` AS es'; + $qry .= ' LEFT JOIN `#user` AS u ON es.`event_subid` = u.`user_id` WHERE es.`event_cat` IN (\''.$selectVals.'\') AND u.`user_id` IS NOT NULL'; + $qry .= ' GROUP BY u.`user_id`'; +// echo "Selector query: ".$qry.'
'; + if (!( $this->mail_count = $sql->db_Select_gen($qry))) return FALSE; + $this->selectorActive = TRUE; + $this->mail_read = 0; + return $this->mail_count; + } + + + + /** + * Return an email address to add to the recipients list. Return FALSE if no more addresses to add + * + * @return array|boolean FALSE if no more addresses available; else an array: + * 'mail_recipient_id' - non-zero if a registered user, zero if a non-registered user. (Always non-zero from this class) + * 'mail_recipient_name' - user name + * 'mail_recipient_email' - email address to use + * 'mail_target_info' - array of info which might be substituted into email, usually using the codes defined by the editor. + * Array key is the code within '|...|', value is the string for substitution + */ + public function selectAdd() + { + $sql = e107::getDb(); + + if (!$this->selectorActive) return FALSE; + if (!($row = $sql->db_Fetch(MYSQL_ASSOC))) return FALSE; + $ret = array('mail_recipient_id' => $row['user_id'], + 'mail_recipient_name' => $row['user_name'], // Should this use realname? + 'mail_recipient_email' => $row['user_email'], + 'mail_target_info' => array( + 'USERID' => $row['user_id'], + 'DISPLAYNAME' => $row['user_name'], + 'SIGNUP_LINK' => $row['user_sess'], + 'USERNAME' => $row['user_loginname'], + 'USERLASTVISIT' => $row['user_lastvisit'] + ) + ); + $this->mail_read++; + return $ret; + } + + + + /** + * Called once all email addresses read, to do any housekeeping needed + * + * @return none + */ + public function select_close() + { + // Nothing to do here + } + + + + /** + * Called to show current selection criteria, and optionally allow edit + * + * @param boolean $allow_edit is TRUE to allow user to change the selection; FALSE to just display current settings + * @param string $selectVals is the current selection information - in the same format as returned by returnSelectors() + * + * @return array Returns array which is displayed in a table cell. + */ + public function showSelect($allow_edit = FALSE, $selectVals = FALSE) + { + $sql = e107::getDb(); + $frm = e107::getForm(); + $var = array(); + // $ret = "
- ".$row['event_cat_name']."
".LAN_EC_MAIL_03." - ".$row['event_cat_name']."
"; + $selects = array_flip(explode(',', $selectVals)); + + if ($sql->db_Select('event_cat', 'event_cat_id, event_cat_name', "event_cat_name != 'Default'")) + { + $c=0; + while ($row = $sql->db_Fetch(MYSQL_ASSOC)) + { + $checked = (isset($selects[$row['event_cat_id']])) ? " checked='checked'" : ''; + if ($allow_edit) + { + $var[$c]['caption'] = $row['event_cat_name']; + $var[$c]['html'] = $frm->checkbox('ec_category_sel[]',$row['event_cat_id'],$checked); + + /*$ret .= "";*/ + } + elseif($checked) + { + $var[$c]['html'] = $row['event_cat_name']; + $var[$c]['caption'] = LAN_EC_MAIL_03; + + /*$ret .= "";*/ + } + $c++; + } + } + else + { + $var[0]['caption'] = LAN_EC_MAIL_02; + $var[0]['html'] = ''; + } + + return $var; + } +} + + + ?> \ No newline at end of file diff --git a/e107_plugins/calendar_menu/e_notify.php b/e107_plugins/calendar_menu/e_notify.php index 34dbcb3a7..3ded1b3c5 100644 --- a/e107_plugins/calendar_menu/e_notify.php +++ b/e107_plugins/calendar_menu/e_notify.php @@ -1,60 +1,62 @@ - NT_LAN_EC_7, 'ecaledit' => NT_LAN_EC_2); -} - -if (!function_exists('notify_ecalnew')) -{ - function notify_ecalnew($data) - { - global $nt; - include_lan(e_PLUGIN.'calendar_menu/languages/'.e_LANGUAGE.'.php'); - $message = NT_LAN_EC_3.': '.USERNAME.' ('.NT_LAN_EC_4.': '.$data['ip'].' )
'; - $message .= NT_LAN_EC_5.':
'.$data['cmessage'].'

'; - $nt -> send('ecaledit', NT_LAN_EC_6, $message); - } -} - -if (!function_exists('notify_ecaledit')) -{ - function notify_ecaledit($data) - { - global $nt; - include_lan(e_PLUGIN.'calendar_menu/languages/'.e_LANGUAGE.'.php'); - $message = NT_LAN_EC_3.': '.USERNAME.' ('.NT_LAN_EC_4.': '.$data['ip'].' )
'; - $message .= NT_LAN_EC_5.':
'.$data['cmessage'].'

'; - $nt -> send('ecaledit', NT_LAN_EC_8, $message); - } -} - - - + NT_LAN_EC_7, 'ecaledit' => NT_LAN_EC_2); +} + +if (!function_exists('notify_ecalnew')) +{ + function notify_ecalnew($data) + { + global $nt; + include_lan(e_PLUGIN.'calendar_menu/languages/'.e_LANGUAGE.'.php'); + $message = NT_LAN_EC_3.': '.USERNAME.' ('.NT_LAN_EC_4.': '.$data['ip'].' )
'; + $message .= NT_LAN_EC_5.':
'.$data['cmessage'].'

'; + $nt -> send('ecaledit', NT_LAN_EC_6, $message); + } +} + +if (!function_exists('notify_ecaledit')) +{ + function notify_ecaledit($data) + { + global $nt; + include_lan(e_PLUGIN.'calendar_menu/languages/'.e_LANGUAGE.'.php'); + $message = NT_LAN_EC_3.': '.USERNAME.' ('.NT_LAN_EC_4.': '.$data['ip'].' )
'; + $message .= NT_LAN_EC_5.':
'.$data['cmessage'].'

'; + $nt -> send('ecaledit', NT_LAN_EC_8, $message); + } +} + + + ?> \ No newline at end of file diff --git a/e107_plugins/calendar_menu/e_rss.php b/e107_plugins/calendar_menu/e_rss.php index 34c8bd440..fe1dc22b7 100644 --- a/e107_plugins/calendar_menu/e_rss.php +++ b/e107_plugins/calendar_menu/e_rss.php @@ -1,87 +1,89 @@ -cal_date['mday']; -$current_month = $ecal_class->cal_date['mon']; -$current_year = $ecal_class->cal_date['year']; -$current = mktime(0,0,0,$current_month, $current_day, $current_year); - -$qry = " -SELECT e.*, c.event_cat_name -FROM `#event` AS e -LEFT JOIN `#event_cat` AS c ON c.event_cat_id = e.event_category -WHERE e.event_start>='{$current}' AND c.event_cat_class REGEXP '".e_CLASS_REGEXP."' -ORDER BY e.event_start ASC LIMIT 0,".$this->limit; - -$rss = array(); -$sqlrss = new db; -if($items = $sqlrss->db_Select_gen($qry)) -{ - $i=0; - while($rowrss = $sqlrss -> db_Fetch()) - { - $tmp = explode(".", $rowrss['event_author']); - $rss[$i]['author'] = $tmp[1]; - $rss[$i]['author_email'] = ''; - $rss[$i]['link'] = $e107->base_path.$PLUGINS_DIRECTORY."calendar_menu/event.php?".$rowrss['event_start'].".event.".$rowrss['event_id']; - $rss[$i]['linkid'] = $rowrss['event_id']; - $rss[$i]['title'] = $rowrss['event_title']; - $rss[$i]['description'] = ''; - $rss[$i]['category_name'] = $rowrss['event_cat_name']; - $rss[$i]['category_link'] = ''; - $rss[$i]['datestamp'] = $rowrss['event_start']; - $rss[$i]['enc_url'] = ""; - $rss[$i]['enc_leng'] = ""; - $rss[$i]['enc_type'] = ""; - $i++; - } -} -//##### ------------------------------------------------------------------------------------ - -$eplug_rss_feed[] = $feed; -$eplug_rss_data[] = $rss; - +cal_date['mday']; +$current_month = $ecal_class->cal_date['mon']; +$current_year = $ecal_class->cal_date['year']; +$current = mktime(0,0,0,$current_month, $current_day, $current_year); + +$qry = " +SELECT e.*, c.event_cat_name +FROM `#event` AS e +LEFT JOIN `#event_cat` AS c ON c.event_cat_id = e.event_category +WHERE e.event_start>='{$current}' AND c.event_cat_class REGEXP '".e_CLASS_REGEXP."' +ORDER BY e.event_start ASC LIMIT 0,".$this->limit; + +$rss = array(); +$sqlrss = new db; +if($items = $sqlrss->db_Select_gen($qry)) +{ + $i=0; + while($rowrss = $sqlrss -> db_Fetch()) + { + $tmp = explode(".", $rowrss['event_author']); + $rss[$i]['author'] = $tmp[1]; + $rss[$i]['author_email'] = ''; + $rss[$i]['link'] = $e107->base_path.$PLUGINS_DIRECTORY."calendar_menu/event.php?".$rowrss['event_start'].".event.".$rowrss['event_id']; + $rss[$i]['linkid'] = $rowrss['event_id']; + $rss[$i]['title'] = $rowrss['event_title']; + $rss[$i]['description'] = ''; + $rss[$i]['category_name'] = $rowrss['event_cat_name']; + $rss[$i]['category_link'] = ''; + $rss[$i]['datestamp'] = $rowrss['event_start']; + $rss[$i]['enc_url'] = ""; + $rss[$i]['enc_leng'] = ""; + $rss[$i]['enc_type'] = ""; + $i++; + } +} +//##### ------------------------------------------------------------------------------------ + +$eplug_rss_feed[] = $feed; +$eplug_rss_data[] = $rss; + ?> \ No newline at end of file diff --git a/e107_plugins/calendar_menu/e_search.php b/e107_plugins/calendar_menu/e_search.php index 31f3e679d..4f3d0876a 100644 --- a/e107_plugins/calendar_menu/e_search.php +++ b/e107_plugins/calendar_menu/e_search.php @@ -1,30 +1,32 @@ - e_PLUGIN.'calendar_menu/search/search_parser.php', 'qtype' => CM_SCH_LAN_1, 'refpage' => 'calendar.php'); - + e_PLUGIN.'calendar_menu/search/search_parser.php', 'qtype' => CM_SCH_LAN_1, 'refpage' => 'calendar.php'); + diff --git a/e107_plugins/calendar_menu/e_tagwords.php b/e107_plugins/calendar_menu/e_tagwords.php index 2e8fafe4e..4d7b26b92 100644 --- a/e107_plugins/calendar_menu/e_tagwords.php +++ b/e107_plugins/calendar_menu/e_tagwords.php @@ -1,69 +1,71 @@ -settings = array(); - - $this->settings['plugin'] = 'calendar_menu'; - $this->settings['table'] = 'event'; - $this->settings['db_id'] = 'event_id'; - $this->settings['caption'] = 'calendar'; - } - - function getLink($id) - { - if($this->row=='') - { - if ($this->row = $this->getRecord($id)) - { - $url = e_PLUGIN."calendar_menu/event.php?{$this->row['event_start']}.event.{$this->row['event_id']}"; - return "".e107::getParser()->toHTML($this->row['event_title'], TRUE, '').""; - } - } - return ''; - } - - - function getRecord($id) - { - $sql = e107::getDb(); - - $this->row = ''; - $qry = "SELECT * FROM #event as e WHERE e.event_id='{$id}'"; - - if($sql->db_Select_gen($qry)) - { - $this->row=$sql->db_Fetch(); - return $this->row; - } - return FALSE; - } -} - +settings = array(); + + $this->settings['plugin'] = 'calendar_menu'; + $this->settings['table'] = 'event'; + $this->settings['db_id'] = 'event_id'; + $this->settings['caption'] = 'calendar'; + } + + function getLink($id) + { + if($this->row=='') + { + if ($this->row = $this->getRecord($id)) + { + $url = e_PLUGIN."calendar_menu/event.php?{$this->row['event_start']}.event.{$this->row['event_id']}"; + return "".e107::getParser()->toHTML($this->row['event_title'], TRUE, '').""; + } + } + return ''; + } + + + function getRecord($id) + { + $sql = e107::getDb(); + + $this->row = ''; + $qry = "SELECT * FROM #event as e WHERE e.event_id='{$id}'"; + + if($sql->db_Select_gen($qry)) + { + $this->row=$sql->db_Fetch(); + return $this->row; + } + return FALSE; + } +} + ?> \ No newline at end of file diff --git a/e107_plugins/calendar_menu/ec_mailout_template.php b/e107_plugins/calendar_menu/ec_mailout_template.php index b2a25079d..01b79ee74 100644 --- a/e107_plugins/calendar_menu/ec_mailout_template.php +++ b/e107_plugins/calendar_menu/ec_mailout_template.php @@ -1,89 +1,91 @@ - + diff --git a/e107_plugins/calendar_menu/ec_pf_page.php b/e107_plugins/calendar_menu/ec_pf_page.php index 90645af02..ec13e3a67 100644 --- a/e107_plugins/calendar_menu/ec_pf_page.php +++ b/e107_plugins/calendar_menu/ec_pf_page.php @@ -1,469 +1,471 @@ -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'); -$calSc = new event_calendar_shortcodes(); -$calSc->ecalClass = &$ecal_class; // Give shortcodes a pointer to calendar class - -$message = ''; -unset($ec_qs); -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 -} - -if (isset($_POST['set_dates']) && isset($_POST['start_date']) && (isset($_POST['end_date']))) -{ - $ec_qs[0] = $_POST['start_date']; - $ec_qs[1] = $_POST['end_date']; - if (isset($_POST['event_cat_ids'])) - { - $ec_qs[2] = $_POST['event_cat_ids']; - if ($ec_qs[2] == 'all') $ec_qs[2] = '*'; - } - if (isset($_POST['template_choice'])) $ec_qs[3] = $_POST['template_choice']; -} - -if (!isset($ec_qs[3])) $ec_qs[3] = 'default'; // Template - -if (isset($_POST['output_type'])) $ec_qs[4] = $_POST['output_type']; -if (!isset($ec_qs[4]) || (($ec_qs[4]) != 'print') && ($ec_qs[4] != 'pdf') ) $ec_qs[4] = 'display'; - - - -$cal_super = $ecal_class->cal_super; - -// Get templates, since we may have to give a choice if we're displaying something -// Actually load three in order so they can accumulate, and give the option of overriding other settings -$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'); - -// Hard-coded alternatives -if (!count($EVENT_CAL_PDF_HEADER)) $EVENT_CAL_PDF_HEADER['default'] = '
'; -if (!count($EVENT_CAL_PDF_BODY)) $EVENT_CAL_PDF_BODY['default'] = '{EC_MAIL_DATE_START} {EC_MAIL_TIME_START} {EC_MAIL_TITLE}
'; -if (!count($EVENT_CAL_PDF_FOOTER)) $EVENT_CAL_PDF_FOOTER['default'] = '
'; -if (!count($EVENT_CAL_PDF_NAMES)) $ec_pdf_template = 'default'; -// If one name only, we just assign that -if (count($EVENT_CAL_PDF_NAMES) == 1) -{ - $ec_pdf_template = array_pop(array_keys($EVENT_CAL_PDF_NAMES)); -// echo "Assign template: ".$ec_pdf_template."
"; -} - -$ec_enable_pdf = ($pref['eventpost_printlists'] > 1) && is_readable(e_PLUGIN."pdf/e107pdf.php"); - -if (!isset($ec_qs[0]) || !isset($ec_qs[1])) -{ -// Put up a prompt to get the view period - require_once(HEADERF); - $cal_text = "
-
-
+ ".$row['event_cat_name']."
".LAN_EC_MAIL_03." + ".$row['event_cat_name']."
- - - - "; - $cal_text .= " - - - - - - - - - "; - if (isset($EVENT_CAL_PDF_NAMES) && is_array($EVENT_CAL_PDF_NAMES) && (count($EVENT_CAL_PDF_NAMES) > 1)) - { // Offer choice of templates - $cal_text .= " - - - \n"; - } - // Radio buttons to select output type - $cal_text .= " - - "; - - $cal_text .= ""; - - $cal_text .= "
".EC_LAN_153.""; - $cal_text .= gen_drop(FALSE)."
".EC_LAN_154."".gen_drop(TRUE)."
".EC_LAN_155.""; - $cal_text .= $e107->tp->parseTemplate('{EC_NAV_CATEGORIES=nosubmit}', FALSE, $calSc); - $cal_text .= "
".EC_LAN_157."
".EC_LAN_158.""; - $cal_text .= " - ".EC_LAN_159."
- ".EC_LAN_160."
"; - if ($ec_enable_pdf) - { - $cal_text .= " ".EC_LAN_161; - } - $cal_text .="
"; - $ns->tablerender(EC_LAN_150, $cal_text); - require_once(FOOTERF); - exit; -} - - -if (!is_numeric($ec_start_date = decode_date($ec_qs[0],FALSE))) -{ - $message = $ec_start_date; -} -elseif (!is_numeric($ec_end_date = decode_date($ec_qs[1],TRUE))) -{ - $message = $ec_end_date; -} -elseif ($ec_start_date >= $ec_end_date) -{ - $message = EC_LAN_151; -} -elseif (($ec_end_date - $ec_start_date) > 366*86400) -{ - $message = EC_LAN_152; -} - -// That's the vetting of the query done (as much as we'll do) -if ($message !== "") -{ - require_once(HEADERF); - $ns->tablerender(EC_LAN_80, $message); - require_once(FOOTERF); - exit; -} - -$calSc->catFilter = $cat_filter; // Category filter - -$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); - -if (($ec_output_type == 'pdf') && !$ec_enable_pdf) $ec_output_type = 'display'; -if ($ec_output_type == 'display') require_once(HEADERF); - - -// Allow a number of categories separated by a '&' -$cat_filter = 0; -$ec_category_list = EC_LAN_97; // Displayable version of categories - default to 'all' -if (isset($ec_qs[2]) && ($ec_qs[2] != '*')) -{ - $ec_category_list = array(); - $temp = explode('&',$ec_qs[2]); - foreach($temp as $t1) - { - if (!is_numeric($t1)) unset($t1); - } - - // Now look up the category names in the database - check access rights at the same time - $temp = array(); // Accumulate valid category IDs - $cal_qry = "SELECT event_cat_id, event_cat_name FROM #event_cat WHERE find_in_set(event_cat_id, '{$ec_qs[2]}') ".$ecal_class->extra_query; - if ($sql->db_Select_gen($cal_qry)) - { - while ($thiscat = $sql->db_Fetch()) - { - $temp [] = $thiscat['event_cat_id']; - $ec_category_list[] = $thiscat['event_cat_name']; - } - $cat_filter = implode(',',$temp); // Gives us a comma separated numeric set of categories - } - else - { - echo EC_LAN_100."

"; - exit; - } -} - -// $ec_start_date - earliest date of period -// $ec_end_date - latest date of period - -// We'll potentially need virtually all of the event-related fields, so get them regardless. Just cut back on category fields -$ev_list = $ecal_class->get_events($ec_start_date, $ec_end_date, FALSE, $cat_filter, TRUE, '*', 'event_cat_name,event_cat_icon'); -// Now go through and multiply up any recurring records - $tim_arr = array(); - foreach ($ev_list as $k=>$event) - { - if (is_array($event['event_start'])) - { - foreach ($event['event_start'] as $t) - { - $tim_arr[$t] = $k; - } - } - else - { - $tim_arr[$event['event_start']] = $k; - } - } - - ksort($tim_arr); // Sort into time order - - - -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 ; -*/ - -$calSc->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; - -$cal_text = ''; -$cal_totev = count($ev_list); -if ($cal_totev > 0) -{ - if (isset($ec_template_styles[$ec_pdf_template]) && is_array($ec_template_styles[$ec_pdf_template])) - { - $ec_current_overrides = $ec_template_styles[$ec_pdf_template]; // Possible array of codes to override standard $sc_style - $sc_style = array_merge($sc_style,$ec_current_overrides); // Override as necessary - } - - // If printing, wrap in a form so the button works - if ($ec_output_type == 'print') $cal_text .= "
\n"; - // Add header - $cal_text .= $e107->tp->parseTemplate($EVENT_CAL_PDF_HEADER[$ec_pdf_template], FALSE, $calSc); - // Debug code - // echo "Start date: ".strftime("%d-%m-%Y %H:%M:%S",$ec_start_date)."
"; - // echo "End date: ".strftime("%d-%m-%Y %H:%M:%S",$ec_end_date)."
"; - // echo "Template: ".$ec_pdf_template,"
"; - // echo "Header: ".$EVENT_CAL_PDF_HEADER[$ec_pdf_template]."
"; - // echo "Body: ".$EVENT_CAL_PDF_BODY[$ec_pdf_template]."
"; - // echo "Footer: ".$EVENT_CAL_PDF_FOOTER[$ec_pdf_template]."
"; - - foreach ($tim_arr as $tim => $ptr) - { - $ev_list[$ptr]['event_start'] = $tim; - $thisevent = $ev_list[$ptr]; - // 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']); - - $ec_year_change = ($ec_last_year != $thisevent_start_date['year']); - $ec_month_change = ($ec_last_month != $thisevent_start_date['mon']); - $ec_day_change = ($ec_last_day != $thisevent_start_date['mday']); - - $cal_totev --; // Can use this to modify inter-event gap - $calSc->numEvents = $cal_totev; // Number of events to display - $calSc->event = $thisevent; // Give shortcodes the event data - $calSc->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], FALSE, $calSc); - - $ec_last_year = $thisevent_start_date['year']; - $ec_last_month = $thisevent_start_date['mon']; - $ec_last_day = $thisevent_start_date['mday']; - } - -// Add footer - $cal_text .= $e107->tp->parseTemplate($EVENT_CAL_PDF_FOOTER[$ec_pdf_template], FALSE, $calSc); - if ($ec_output_type == 'print') $cal_text .= "
\n"; -} -else -{ - $cal_text.= EC_LAN_148; -} - -switch($ec_output_type) -{ - case 'display': - $e107->ns->tablerender(EC_LAN_80, $cal_text, 'ec_pf_page'); - require_once (FOOTERF); - break; - - case 'print': - echo $cal_text; - break; - - case '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'); - $pdf = new e107PDF(); - // $text = array($text, $creator, $author, $title, $subject, $keywords, $url); - $text = array( - $cal_text, - '', - '', - EC_LAN_163, // Title - '', - '', - e_SELF.'?'.e_QUERY, // URL - '' // Page orientation - ); - $pdf->makePDF($text); - break; - -} - - - -// We're assuming $date_string is a string of digits -// Which could begin with 'now' or 'now+' -function decode_date($date_string, $last_day = FALSE) -{ // Decode a date string - if (strpos($date_string, 'now') === 0) - { - // decode special dates - $today = getdate(); - // Knock off the 'now' - $date_string = trim(substr($date_string, 3)); - if (($date_string != '') && ($date_string[0] == '+')) - { - // Knock off the '+' - $date_string = trim(substr($date_string, 1)); - if (is_numeric($date_string) && ($date_string >= 0) && ($date_string <= 12)) - { - $today['mon'] += $date_string; - if ($today['mon'] > 12) - { - $today['mon'] -= 12; - $today['year'] += 1; - } - } - else - { - return EC_LAN_149; - } - } - $date_string = $today['year'].$today['mon']; - } - - // Here, $date_string is a string of 5, 6 or 8 digits - // use preg_match() - if(preg_match('/^\d{5,8}$/D', $date_string)) - { - $month = 0; - $day = 1; - if (strlen($date_string) == 5) - $date_string = substr_replace($date_string, '0', -1, 0); - if (strlen($date_string) == 8) - { - $day = substr($date_string, -2, 2); - if ($last_day) - $day += 1; - } - elseif (strlen($date_string) == 6) - { - if ($last_day) - $month = 1; - } - else - { - // Error - return EC_LAN_149; - } - $month += substr($date_string, 4, 2); - $year = substr($date_string, 0, 4); - $temp = mktime(0, 0, 0, $month, $day, $year); - // Always do this to get whole of last day - if ($last_day) - $temp -= 1; - return $temp; - } - else - { // Error - return EC_LAN_149; - } -} - - -// Generate monthly drop-down - FALSE = first, TRUE = last -// For the first date we want beginning of previous year to end of current year -// For the last date we want end of next -function gen_drop($drop_type) -{ - $text = "\n"; - return $text; -} -?> +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'); +$calSc = new event_calendar_shortcodes(); +$calSc->ecalClass = &$ecal_class; // Give shortcodes a pointer to calendar class + +$message = ''; +unset($ec_qs); +if (e_QUERY) $ec_qs = explode('.', e_QUERY); +else +{ + if (!isset($ecal_class->pref['eventpost_printlists']) || ($ecal_class->pref['eventpost_printlists'] == 0)) + header('location:'.SITEURL); // If disabled, just go back to index page +} + +if (isset($_POST['set_dates']) && isset($_POST['start_date']) && (isset($_POST['end_date']))) +{ + $ec_qs[0] = $_POST['start_date']; + $ec_qs[1] = $_POST['end_date']; + if (isset($_POST['event_cat_ids'])) + { + $ec_qs[2] = $_POST['event_cat_ids']; + if ($ec_qs[2] == 'all') $ec_qs[2] = '*'; + } + if (isset($_POST['template_choice'])) $ec_qs[3] = $_POST['template_choice']; +} + +if (!isset($ec_qs[3])) $ec_qs[3] = 'default'; // Template + +if (isset($_POST['output_type'])) $ec_qs[4] = $_POST['output_type']; +if (!isset($ec_qs[4]) || (($ec_qs[4]) != 'print') && ($ec_qs[4] != 'pdf') ) $ec_qs[4] = 'display'; + + + +$cal_super = $ecal_class->cal_super; + +// Get templates, since we may have to give a choice if we're displaying something +// Actually load three in order so they can accumulate, and give the option of overriding other settings +$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'); + +// Hard-coded alternatives +if (!count($EVENT_CAL_PDF_HEADER)) $EVENT_CAL_PDF_HEADER['default'] = '
'; +if (!count($EVENT_CAL_PDF_BODY)) $EVENT_CAL_PDF_BODY['default'] = '{EC_MAIL_DATE_START} {EC_MAIL_TIME_START} {EC_MAIL_TITLE}
'; +if (!count($EVENT_CAL_PDF_FOOTER)) $EVENT_CAL_PDF_FOOTER['default'] = '
'; +if (!count($EVENT_CAL_PDF_NAMES)) $ec_pdf_template = 'default'; +// If one name only, we just assign that +if (count($EVENT_CAL_PDF_NAMES) == 1) +{ + $ec_pdf_template = array_pop(array_keys($EVENT_CAL_PDF_NAMES)); +// echo "Assign template: ".$ec_pdf_template."
"; +} + +$ec_enable_pdf = ($ecal_class->pref['eventpost_printlists'] > 1) && is_readable(e_PLUGIN."pdf/e107pdf.php"); + +if (!isset($ec_qs[0]) || !isset($ec_qs[1])) +{ +// Put up a prompt to get the view period + require_once(HEADERF); + $cal_text = "
+
+ + + + + "; + $cal_text .= " + + + + + + + + + "; + if (isset($EVENT_CAL_PDF_NAMES) && is_array($EVENT_CAL_PDF_NAMES) && (count($EVENT_CAL_PDF_NAMES) > 1)) + { // Offer choice of templates + $cal_text .= " + + + \n"; + } + // Radio buttons to select output type + $cal_text .= " + + "; + + $cal_text .= ""; + + $cal_text .= "
".EC_LAN_153.""; + $cal_text .= gen_drop(FALSE)."
".EC_LAN_154."".gen_drop(TRUE)."
".EC_LAN_155.""; + $cal_text .= $e107->tp->parseTemplate('{EC_NAV_CATEGORIES=nosubmit}', FALSE, $calSc); + $cal_text .= "
".EC_LAN_157."
".EC_LAN_158.""; + $cal_text .= " + ".EC_LAN_159."
+ ".EC_LAN_160."
"; + if ($ec_enable_pdf) + { + $cal_text .= " ".EC_LAN_161; + } + $cal_text .="
"; + $ns->tablerender(EC_LAN_150, $cal_text); + require_once(FOOTERF); + exit; +} + + +if (!is_numeric($ec_start_date = decode_date($ec_qs[0],FALSE))) +{ + $message = $ec_start_date; +} +elseif (!is_numeric($ec_end_date = decode_date($ec_qs[1],TRUE))) +{ + $message = $ec_end_date; +} +elseif ($ec_start_date >= $ec_end_date) +{ + $message = EC_LAN_151; +} +elseif (($ec_end_date - $ec_start_date) > 366*86400) +{ + $message = EC_LAN_152; +} + +// That's the vetting of the query done (as much as we'll do) +if ($message !== "") +{ + require_once(HEADERF); + $ns->tablerender(EC_LAN_80, $message); + require_once(FOOTERF); + exit; +} + +$calSc->catFilter = $cat_filter; // Category filter + +$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); + +if (($ec_output_type == 'pdf') && !$ec_enable_pdf) $ec_output_type = 'display'; +if ($ec_output_type == 'display') require_once(HEADERF); + + +// Allow a number of categories separated by a '&' +$cat_filter = 0; +$ec_category_list = EC_LAN_97; // Displayable version of categories - default to 'all' +if (isset($ec_qs[2]) && ($ec_qs[2] != '*')) +{ + $ec_category_list = array(); + $temp = explode('&',$ec_qs[2]); + foreach($temp as $t1) + { + if (!is_numeric($t1)) unset($t1); + } + + // Now look up the category names in the database - check access rights at the same time + $temp = array(); // Accumulate valid category IDs + $cal_qry = "SELECT event_cat_id, event_cat_name FROM #event_cat WHERE find_in_set(event_cat_id, '{$ec_qs[2]}') ".$ecal_class->extra_query; + if ($sql->db_Select_gen($cal_qry)) + { + while ($thiscat = $sql->db_Fetch()) + { + $temp [] = $thiscat['event_cat_id']; + $ec_category_list[] = $thiscat['event_cat_name']; + } + $cat_filter = implode(',',$temp); // Gives us a comma separated numeric set of categories + } + else + { + echo EC_LAN_100."

"; + exit; + } +} + +// $ec_start_date - earliest date of period +// $ec_end_date - latest date of period + +// We'll potentially need virtually all of the event-related fields, so get them regardless. Just cut back on category fields +$ev_list = $ecal_class->get_events($ec_start_date, $ec_end_date, FALSE, $cat_filter, TRUE, '*', 'event_cat_name,event_cat_icon'); +// Now go through and multiply up any recurring records + $tim_arr = array(); + foreach ($ev_list as $k=>$event) + { + if (is_array($event['event_start'])) + { + foreach ($event['event_start'] as $t) + { + $tim_arr[$t] = $k; + } + } + else + { + $tim_arr[$event['event_start']] = $k; + } + } + + ksort($tim_arr); // Sort into time order + + + +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 ; +*/ + +$calSc->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; + +$cal_text = ''; +$cal_totev = count($ev_list); +if ($cal_totev > 0) +{ + if (isset($ec_template_styles[$ec_pdf_template]) && is_array($ec_template_styles[$ec_pdf_template])) + { + $ec_current_overrides = $ec_template_styles[$ec_pdf_template]; // Possible array of codes to override standard $sc_style + $sc_style = array_merge($sc_style,$ec_current_overrides); // Override as necessary + } + + // If printing, wrap in a form so the button works + if ($ec_output_type == 'print') $cal_text .= "
\n"; + // Add header + $cal_text .= $e107->tp->parseTemplate($EVENT_CAL_PDF_HEADER[$ec_pdf_template], FALSE, $calSc); + // Debug code + // echo "Start date: ".strftime("%d-%m-%Y %H:%M:%S",$ec_start_date)."
"; + // echo "End date: ".strftime("%d-%m-%Y %H:%M:%S",$ec_end_date)."
"; + // echo "Template: ".$ec_pdf_template,"
"; + // echo "Header: ".$EVENT_CAL_PDF_HEADER[$ec_pdf_template]."
"; + // echo "Body: ".$EVENT_CAL_PDF_BODY[$ec_pdf_template]."
"; + // echo "Footer: ".$EVENT_CAL_PDF_FOOTER[$ec_pdf_template]."
"; + + foreach ($tim_arr as $tim => $ptr) + { + $ev_list[$ptr]['event_start'] = $tim; + $thisevent = $ev_list[$ptr]; + // 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']); + + $ec_year_change = ($ec_last_year != $thisevent_start_date['year']); + $ec_month_change = ($ec_last_month != $thisevent_start_date['mon']); + $ec_day_change = ($ec_last_day != $thisevent_start_date['mday']); + + $cal_totev --; // Can use this to modify inter-event gap + $calSc->numEvents = $cal_totev; // Number of events to display + $calSc->event = $thisevent; // Give shortcodes the event data + $calSc->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], FALSE, $calSc); + + $ec_last_year = $thisevent_start_date['year']; + $ec_last_month = $thisevent_start_date['mon']; + $ec_last_day = $thisevent_start_date['mday']; + } + +// Add footer + $cal_text .= $e107->tp->parseTemplate($EVENT_CAL_PDF_FOOTER[$ec_pdf_template], FALSE, $calSc); + if ($ec_output_type == 'print') $cal_text .= "
\n"; +} +else +{ + $cal_text.= EC_LAN_148; +} + +switch($ec_output_type) +{ + case 'display': + $e107->ns->tablerender(EC_LAN_80, $cal_text, 'ec_pf_page'); + require_once (FOOTERF); + break; + + case 'print': + echo $cal_text; + break; + + case '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'); + $pdf = new e107PDF(); + // $text = array($text, $creator, $author, $title, $subject, $keywords, $url); + $text = array( + $cal_text, + '', + '', + EC_LAN_163, // Title + '', + '', + e_SELF.'?'.e_QUERY, // URL + '' // Page orientation + ); + $pdf->makePDF($text); + break; + +} + + + +// We're assuming $date_string is a string of digits +// Which could begin with 'now' or 'now+' +function decode_date($date_string, $last_day = FALSE) +{ // Decode a date string + if (strpos($date_string, 'now') === 0) + { + // decode special dates + $today = getdate(); + // Knock off the 'now' + $date_string = trim(substr($date_string, 3)); + if (($date_string != '') && ($date_string[0] == '+')) + { + // Knock off the '+' + $date_string = trim(substr($date_string, 1)); + if (is_numeric($date_string) && ($date_string >= 0) && ($date_string <= 12)) + { + $today['mon'] += $date_string; + if ($today['mon'] > 12) + { + $today['mon'] -= 12; + $today['year'] += 1; + } + } + else + { + return EC_LAN_149; + } + } + $date_string = $today['year'].$today['mon']; + } + + // Here, $date_string is a string of 5, 6 or 8 digits + // use preg_match() + if(preg_match('/^\d{5,8}$/D', $date_string)) + { + $month = 0; + $day = 1; + if (strlen($date_string) == 5) + $date_string = substr_replace($date_string, '0', -1, 0); + if (strlen($date_string) == 8) + { + $day = substr($date_string, -2, 2); + if ($last_day) + $day += 1; + } + elseif (strlen($date_string) == 6) + { + if ($last_day) + $month = 1; + } + else + { + // Error + return EC_LAN_149; + } + $month += substr($date_string, 4, 2); + $year = substr($date_string, 0, 4); + $temp = mktime(0, 0, 0, $month, $day, $year); + // Always do this to get whole of last day + if ($last_day) + $temp -= 1; + return $temp; + } + else + { // Error + return EC_LAN_149; + } +} + + +// Generate monthly drop-down - FALSE = first, TRUE = last +// For the first date we want beginning of previous year to end of current year +// For the last date we want end of next +function gen_drop($drop_type) +{ + $text = "\n"; + return $text; +} +?> diff --git a/e107_plugins/calendar_menu/ec_pf_template.php b/e107_plugins/calendar_menu/ec_pf_template.php index e595ba4f9..54c41ef4b 100644 --- a/e107_plugins/calendar_menu/ec_pf_template.php +++ b/e107_plugins/calendar_menu/ec_pf_template.php @@ -1,108 +1,110 @@ -'; -$sc_style['EC_PR_CHANGE_YEAR']['post'] = ''; -$sc_style['EC_PR_CHANGE_MONTH']['pre'] = '
'; -$sc_style['EC_PR_CHANGE_MONTH']['post'] = '
'; -$sc_style['EC_PRINT_BUTTON']['pre'] = "
"; -$sc_style['EC_PRINT_BUTTON']['post'] = "
"; -$sc_style['EC_NOW_DATE']['pre'] = EC_LAN_170; -$sc_style['EC_NOW_DATE']['post'] = ""; -$sc_style['EC_NOW_TIME']['pre'] = EC_LAN_144; -$sc_style['EC_NOW_TIME']['post'] = ""; -$sc_style['EC_PR_CAT_LIST']['pre'] = EC_LAN_172; -$sc_style['EC_PR_CAT_LIST']['post'] = ""; -$sc_style['EC_PR_LIST_TITLE']['pre'] = "

"; -$sc_style['EC_PR_LIST_TITLE']['post'] = "

"; - -// - Default style - very basic -$EVENT_CAL_PDF_NAMES['default'] = EC_LAN_165; -$EVENT_CAL_PDF_HEADER['default'] = "{EC_PR_LIST_TITLE}
{EC_PR_CAT_LIST}
".EC_LAN_168."{EC_PR_LIST_START=%d-%m-%Y}
".EC_LAN_169."{EC_PR_LIST_END=%d-%m-%Y}
"; -$EVENT_CAL_PDF_BODY['default'] = "{EC_PR_CHANGE_YEAR}{EC_PR_CHANGE_MONTH}{EC_MAIL_SHORT_DATE} {EC_MAIL_TIME_START} {EC_MAIL_TITLE}
\n"; -$EVENT_CAL_PDF_FOOTER['default'] = "---End of List---

{EC_IFNOT_DISPLAY=EC_NOW_DATE}{EC_IFNOT_DISPLAY=EC_NOW_TIME}
{EC_PRINT_BUTTON}"; - - -// - A simple tabular style -$ec_template_styles['simple']['EC_PR_CHANGE_YEAR']['pre'] = "
"; -$ec_template_styles['simple']['EC_PR_CHANGE_YEAR']['post'] = '
'; -$ec_template_styles['simple']['EC_PR_CHANGE_MONTH']['pre'] = ''; -$ec_template_styles['simple']['EC_PR_CHANGE_MONTH']['post'] = ''; - -$EVENT_CAL_PDF_NAMES['simple'] = EC_LAN_166; -$EVENT_CAL_PDF_HEADER['simple'] = "{EC_IF_PRINT=LOGO} - - "; -$EVENT_CAL_PDF_BODY['simple'] = "{EC_PR_CHANGE_YEAR} - \n"; -$EVENT_CAL_PDF_FOOTER['simple'] = "
".EC_LAN_163."
".EC_LAN_168."{EC_PR_LIST_START=%d-%m-%Y}
".EC_LAN_169."{EC_PR_LIST_END=%d-%m-%Y}
{EC_PR_CHANGE_MONTH} {EC_MAIL_DATE_START=%a %d}{EC_MAIL_TIME_START}{EC_MAIL_TITLE}


{EC_IFNOT_DISPLAY=EC_NOW_DATE}{EC_IFNOT_DISPLAY=EC_NOW_TIME}
{EC_PRINT_BUTTON}"; - - -// - A tabular style with lines round the cells -$ec_template_styles['tlinclines']['EC_PR_CHANGE_YEAR']['pre'] = "
"; -$ec_template_styles['tlinclines']['EC_PR_CHANGE_YEAR']['post'] = '
'; - -$EVENT_CAL_PDF_NAMES['tlinclines'] = EC_LAN_167; -$EVENT_CAL_PDF_HEADER['tlinclines'] = " - - "; -$EVENT_CAL_PDF_BODY['tlinclines'] = "{EC_PR_CHANGE_YEAR} - \n"; -$EVENT_CAL_PDF_FOOTER['tlinclines'] = "
".EC_LAN_163."
".EC_LAN_168."{EC_PR_LIST_START=%d-%m-%Y}
".EC_LAN_169."{EC_PR_LIST_END=%d-%m-%Y}
{EC_MAIL_DATE_START}{EC_MAIL_TIME_START}{EC_MAIL_TITLE}


{EC_IFNOT_DISPLAY=EC_NOW_DATE=%d-%m-%y}{EC_IFNOT_DISPLAY=EC_NOW_TIME}{EC_PRINT_BUTTON}"; - -// - A tabular style with lines round the cells and categories -$ec_template_styles['tlinccatlines']['EC_PR_CHANGE_YEAR']['pre'] = "
"; -$ec_template_styles['tlinccatlines']['EC_PR_CHANGE_YEAR']['post'] = '
'; - -$EVENT_CAL_PDF_NAMES['tlinccatlines'] = EC_LAN_171; -$EVENT_CAL_PDF_HEADER['tlinccatlines'] = " - - "; -$EVENT_CAL_PDF_BODY['tlinccatlines'] = "{EC_PR_CHANGE_YEAR} - \n"; -$EVENT_CAL_PDF_FOOTER['tlinccatlines'] = "
".EC_LAN_163."
".EC_LAN_168."{EC_PR_LIST_START=%d-%m-%Y}
".EC_LAN_169."{EC_PR_LIST_END=%d-%m-%Y}
{EC_MAIL_DATE_START=%D %d %b}{EC_MAIL_TIME_START}{EC_MAIL_CATEGORY}{EC_MAIL_TITLE}


{EC_IFNOT_DISPLAY=EC_NOW_DATE=%d-%m-%y}{EC_IFNOT_DISPLAY=EC_NOW_TIME}{EC_PRINT_BUTTON}"; - +'; +$sc_style['EC_PR_CHANGE_YEAR']['post'] = ''; +$sc_style['EC_PR_CHANGE_MONTH']['pre'] = '
'; +$sc_style['EC_PR_CHANGE_MONTH']['post'] = '
'; +$sc_style['EC_PRINT_BUTTON']['pre'] = "
"; +$sc_style['EC_PRINT_BUTTON']['post'] = "
"; +$sc_style['EC_NOW_DATE']['pre'] = EC_LAN_170; +$sc_style['EC_NOW_DATE']['post'] = ""; +$sc_style['EC_NOW_TIME']['pre'] = EC_LAN_144; +$sc_style['EC_NOW_TIME']['post'] = ""; +$sc_style['EC_PR_CAT_LIST']['pre'] = EC_LAN_172; +$sc_style['EC_PR_CAT_LIST']['post'] = ""; +$sc_style['EC_PR_LIST_TITLE']['pre'] = "

"; +$sc_style['EC_PR_LIST_TITLE']['post'] = "

"; + +// - Default style - very basic +$EVENT_CAL_PDF_NAMES['default'] = EC_LAN_165; +$EVENT_CAL_PDF_HEADER['default'] = "{EC_PR_LIST_TITLE}
{EC_PR_CAT_LIST}
".EC_LAN_168."{EC_PR_LIST_START=%d-%m-%Y}
".EC_LAN_169."{EC_PR_LIST_END=%d-%m-%Y}
"; +$EVENT_CAL_PDF_BODY['default'] = "{EC_PR_CHANGE_YEAR}{EC_PR_CHANGE_MONTH}{EC_MAIL_SHORT_DATE} {EC_MAIL_TIME_START} {EC_MAIL_TITLE}
\n"; +$EVENT_CAL_PDF_FOOTER['default'] = "---End of List---

{EC_IFNOT_DISPLAY=EC_NOW_DATE}{EC_IFNOT_DISPLAY=EC_NOW_TIME}
{EC_PRINT_BUTTON}"; + + +// - A simple tabular style +$ec_template_styles['simple']['EC_PR_CHANGE_YEAR']['pre'] = "
"; +$ec_template_styles['simple']['EC_PR_CHANGE_YEAR']['post'] = '
'; +$ec_template_styles['simple']['EC_PR_CHANGE_MONTH']['pre'] = ''; +$ec_template_styles['simple']['EC_PR_CHANGE_MONTH']['post'] = ''; + +$EVENT_CAL_PDF_NAMES['simple'] = EC_LAN_166; +$EVENT_CAL_PDF_HEADER['simple'] = "{EC_IF_PRINT=LOGO} + + "; +$EVENT_CAL_PDF_BODY['simple'] = "{EC_PR_CHANGE_YEAR} + \n"; +$EVENT_CAL_PDF_FOOTER['simple'] = "
".EC_LAN_163."
".EC_LAN_168."{EC_PR_LIST_START=%d-%m-%Y}
".EC_LAN_169."{EC_PR_LIST_END=%d-%m-%Y}
{EC_PR_CHANGE_MONTH} {EC_MAIL_DATE_START=%a %d}{EC_MAIL_TIME_START}{EC_MAIL_TITLE}


{EC_IFNOT_DISPLAY=EC_NOW_DATE}{EC_IFNOT_DISPLAY=EC_NOW_TIME}
{EC_PRINT_BUTTON}"; + + +// - A tabular style with lines round the cells +$ec_template_styles['tlinclines']['EC_PR_CHANGE_YEAR']['pre'] = "
"; +$ec_template_styles['tlinclines']['EC_PR_CHANGE_YEAR']['post'] = '
'; + +$EVENT_CAL_PDF_NAMES['tlinclines'] = EC_LAN_167; +$EVENT_CAL_PDF_HEADER['tlinclines'] = " + + "; +$EVENT_CAL_PDF_BODY['tlinclines'] = "{EC_PR_CHANGE_YEAR} + \n"; +$EVENT_CAL_PDF_FOOTER['tlinclines'] = "
".EC_LAN_163."
".EC_LAN_168."{EC_PR_LIST_START=%d-%m-%Y}
".EC_LAN_169."{EC_PR_LIST_END=%d-%m-%Y}
{EC_MAIL_DATE_START}{EC_MAIL_TIME_START}{EC_MAIL_TITLE}


{EC_IFNOT_DISPLAY=EC_NOW_DATE=%d-%m-%y}{EC_IFNOT_DISPLAY=EC_NOW_TIME}{EC_PRINT_BUTTON}"; + +// - A tabular style with lines round the cells and categories +$ec_template_styles['tlinccatlines']['EC_PR_CHANGE_YEAR']['pre'] = "
"; +$ec_template_styles['tlinccatlines']['EC_PR_CHANGE_YEAR']['post'] = '
'; + +$EVENT_CAL_PDF_NAMES['tlinccatlines'] = EC_LAN_171; +$EVENT_CAL_PDF_HEADER['tlinccatlines'] = " + + "; +$EVENT_CAL_PDF_BODY['tlinccatlines'] = "{EC_PR_CHANGE_YEAR} + \n"; +$EVENT_CAL_PDF_FOOTER['tlinccatlines'] = "
".EC_LAN_163."
".EC_LAN_168."{EC_PR_LIST_START=%d-%m-%Y}
".EC_LAN_169."{EC_PR_LIST_END=%d-%m-%Y}
{EC_MAIL_DATE_START=%D %d %b}{EC_MAIL_TIME_START}{EC_MAIL_CATEGORY}{EC_MAIL_TITLE}


{EC_IFNOT_DISPLAY=EC_NOW_DATE=%d-%m-%y}{EC_IFNOT_DISPLAY=EC_NOW_TIME}{EC_PRINT_BUTTON}"; + ?> \ No newline at end of file diff --git a/e107_plugins/calendar_menu/ecal_class.php b/e107_plugins/calendar_menu/ecal_class.php index a8b076d6d..c67bf4975 100644 --- a/e107_plugins/calendar_menu/ecal_class.php +++ b/e107_plugins/calendar_menu/ecal_class.php @@ -1,756 +1,807 @@ - 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' - ); - - - public function __construct() - { // Constructor - global $pref; - - // Get all the times in terms of 'clock time' - i.e. allowing for TZ, DST, etc - // All the times in the DB should be 'absolute' - so if we compare with 'clock time' it should work out. - $this->time_now = time(); - $this->site_timedate = $this->time_now + ($pref['time_offset'] * 3600); // Check sign of offset - $this->user_timedate = $this->time_now + TIMEOFFSET; - switch ($pref['eventpost_caltime']) - { - case 1 : - $this->cal_timedate = $this->site_timedate; // Site time - break; - case 2 : - $this->cal_timedate = $this->user_timedate; // User - break; - default : - $this->cal_timedate = $this->time_now; // Server time - default - } - $this->now_date = getdate($this->time_now); - $this->site_date = getdate($this->site_timedate); // Array with h,m,s, day, month year etc - $this->cal_date = getdate($this->cal_timedate); - - $this->max_cache_time = $this->site_date['minutes'] + 60*$this->site_date['hours']; - - $this->cal_super = check_class($pref['eventpost_super']); - if ($this->cal_super) $this->extra_query = ""; else $this->extra_query = " AND find_in_set(event_cat_class,'".USERCLASS_LIST."')"; - - $this->max_recent_show = 0; - if (isset($pref['eventpost_recentshow'])) - { - if ($pref['eventpost_recentshow'] == 'LV') - { - if (USER) $this->max_recent_show = time() - USERLV; - } - else - { - $this->max_recent_show = 3600 * $pref['eventpost_recentshow']; - } - } - - switch ($pref['eventpost_timedisplay']) - { - case 2 : - $this->time_format_string = "%I:%M %p"; // 12-hour display - break; - case 3 : - $this->time_format_string = $pref['eventpost_timecustom']; // custom display - if (isset($this->time_format_string)) break; - case 4 : - $this->time_format_string = "%H:%M"; // 24-hour display with separator - break; - default : - $this->time_format_string = "%H%M"; // default to 24-hour display - } - - if (!isset($pref['eventpost_datedisplay'])) $pref['eventpost_datedisplay'] = 1; - $temp = $pref['eventpost_datedisplay']; - if ($temp >3) - { - $temp-= 3; - $this->date_separator = '.'; - if ($temp > 3) - { - $temp -= 3; - $this->date_separator = '/'; - } - } - switch ($temp) - { // Event entry calendar - case 2 : - $this->cal_format_string = "d".$this->date_separator."m".$this->date_separator."Y"; - $this->dcal_format_string = "%d".$this->date_separator."%m".$this->date_separator."%Y"; - $this->java_format_code = 2; - break; - case 3 : - $this->cal_format_string = "m".$this->date_separator."d".$this->date_separator."Y"; - $this->dcal_format_string = "%m".$this->date_separator."%d".$this->date_separator."%Y"; - $this->java_format_code = 3; - break; - default : // 'original' defaults - $this->cal_format_string = "Y".$this->date_separator."m".$this->date_separator."d"; - $this->dcal_format_string = "%Y".$this->date_separator."%m".$this->date_separator."%d"; - $this->java_format_code = 1; - } - - if (!isset($pref['eventpost_dateevent'])) $pref['eventpost_dateevent'] = 1; - switch ($pref['eventpost_dateevent']) - { // Event list date display - case 0 : - $this->event_date_format_string = $pref['eventpost_eventdatecustom']; - break; - case 2 : - $this->event_date_format_string = "%a %d %b %Y"; - break; - case 3 : - $this->event_date_format_string = "%a %d-%m-%y"; - break; - default : - $this->event_date_format_string = "%A %d %B %Y"; - } - - if (!isset($pref['eventpost_datenext'])) $pref['eventpost_datenext'] = 1; - switch ($pref['eventpost_datenext']) - { // Forthcoming event date display - case 0 : - $this->next_date_format_string = $pref['eventpost_nextdatecustom']; - break; - case 2 : - $this->next_date_format_string = "%d %b"; - break; - case 3 : - $this->next_date_format_string = "%B %d"; - break; - case 4 : - $this->next_date_format_string = "%b %d"; - break; - default : - $this->next_date_format_string = "%d %B"; - } - - switch (varset($pref['eventpost_weekstart'],'sun')) - { - case 'sun' : $this->ec_first_day_of_week = 0; break; - case 'mon' : $this->ec_first_day_of_week = 1; break; - case 0 : - case 1 : - case 2 : - case 3 : - case 4 : - case 5 : - case 6 : - $this->ec_first_day_of_week = $pref['eventpost_weekstart']; break; - default : - $this->ec_first_day_of_week = 1; - } - - } - - - 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); - } - - - 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); - } - - - 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); - } - - - 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); - } - - - public function make_date($new_hour, $new_minute, $date_string) - { // Turns a date as entered in the calendar into a time stamp (for event entry) - $tmp = explode($this->date_separator, $date_string); - switch ($this->java_format_code) - { - case 2 : - return gmmktime($new_hour, $new_minute, 0, $tmp[1], $tmp[0], $tmp[2]); // dd-mm-yyyy - case 3 : - return gmmktime($new_hour, $new_minute, 0, $tmp[0], $tmp[1], $tmp[2]); // mm-dd-yyyy - default : - return gmmktime($new_hour, $new_minute, 0, $tmp[1], $tmp[2], $tmp[0]); // yyyy-mm-dd - } - } - - - // Return day of week string relative to the start of the week - public function day_offset_string($doff) - { - return $this->days[($doff+$this->ec_first_day_of_week) % 7]; - } - - - 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: - // 1 - add event - // 2 - edit event - // 3 - delete event - // 4 - Bulk delete - // 5 - add multiple events - 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]."
"; - if ($event_start > 0) - { - $cmessage .= 'Event Start: '.strftime("%d-%B-%Y",$event_start)."
"; - $cmessage .= 'Event Link: '.SITEURL.e_PLUGIN_ABS. 'calendar_menu/event.php?'.$event_start."
"; - } - else - $cmessage .= "Event Start unknown
"; - $edata_ec = array('cmessage' => $cmessage, 'ip' => e107::getIPHandler()->getIP(FALSE)); - switch ($event_type) - { - case 5 : - case 1 : $e107->e_event -> trigger('ecalnew', $edata_ec); - break; - case 2 : - case 3 : - case 4 : $e107->e_event -> trigger('ecaledit', $edata_ec); - break; - } - - switch ($pref['eventpost_adminlog']) - { - case 1 : if ($event_type == '1') return; - case 2 : break; // Continue - default : return; // Invalid or undefined option - } - $log_detail = array( '1' => 'Event Calendar - add event '.strftime("%d-%B-%Y",$event_start), - '2' => 'Event Calendar - edit event '.strftime("%d-%B-%Y",$event_start), - '3' => 'Event Calendar - delete event '.strftime("%d-%B-%Y",$event_start), - '4' => 'Event Calendar - Bulk Delete', - '5' => 'Event Calendar - multiple add '.strftime("%d-%B-%Y",$event_start) - ); - $e107->admin_log->log_event($log_titles[$event_type],$event_title." \n".$log_detail[$event_type]."\n".$event_string,''); - } - - - - function get_category_text($ev_cat) - { - global $sql; - if (!isset($this->cat_text_cache[$ev_cat])) - { - $sql->db_Select('event_cat','event_cat_name',"event_cat_id='{$ev_cat}'"); - $row = $sql->db_Fetch(); - $this->cat_text_cache[$ev_cat] = $row['event_cat_name']; - } - return $this->cat_text_cache[$ev_cat]; - } - - - // Implements a version of getdate that expects a GMT date and doesn't do TZ/DST adjustments - // time() -date('Z') gives the correction to 'null out' the TZ and DST adjustments that getdate() does - function gmgetdate($date) - { - return getdate($date-date('Z')); - } - -//------------------------------------------------ -// Recurring event handling -//------------------------------------------------ - - /** - * Internal utility - Generate a list of time/date based on a 'first event' date, an interval and start/finish times - * All fields are Unix-style time/date stamps - * @param int $first_event - * @param int $last_event - * @param int $interval - interval between events (in seconds) - * @param int $start_time - * @param int $end_time - last date in time window - * - * @return array of start date/time entries - */ - protected function gen_recur_regular($first_event, $last_event, $interval, $start_time, $end_time) - { - if ($last_event < $end_time) $end_time = $last_event; - $ret = array(); - $first_event = $first_event + ceil(($start_time-$first_event)/$interval)*$interval; - while ($first_event <= $end_time) - { - $ret[] = $first_event; - $first_event += $interval; - } - return $ret; - } - - - /** - * 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']; - if ($main_date['mon'] > 12) - { - $main_date['mon'] -= 12; - $main_date['year']++; - } - } - if ($adder['year']) $main_date['year'] += $adder['year']; - return $main_date; - } - - - /** - * 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(); - $week_offset = 0; - if ($interval_type >= 100) - { - $week_offset = intval($interval_type /100); - $day_number = $interval_type % 10; // Gives 0..6 in practice; potentially 0..9 - $interval_type = 100; - } - if ($first_event > $end_time) return $ret; - - $interval = array('5' => 28*86400, '6' => 14*86400, '7' => 7*86400, '8' => 86400); - // Do the easy ones first - if (array_key_exists($interval_type, $interval)) return $this->gen_recur_regular($first_event, $last_event, $interval[$interval_type], $start_time, $end_time); - -// We're messing around with months and years here - $inc_array['year'] = 0; - $inc_array['mon'] = 0; - - // Find the first date which is within, or close to, scope (N.B. may not be one) - $event = $this->gmgetdate($first_event); - $temp = $this->gmgetdate($start_time); - $event['year'] = $temp['year']; // Use the year from the start window - if ($event['mon'] > $temp['mon']) $event['year']--; // Handle situation where event later in year than desired window - - switch ($interval_type) - { - case 1 : // Annual - $inc_array['year'] = 1; - break; - case 2 : // Biannual - $inc_array['mon'] = 6; - break; - case 3 : // Quarterly - $inc_array['mon'] = 3; - break; - case 4 : // Monthly - $inc_array['mon'] = 1; - break; - case 100 : // Monthly on nth Sunday in month - case 101 : // Monthly on nth Monday in month - case 102 : // Monthly on nth Tuesday in month - case 103 : // Monthly on nth Wednesday in month - case 104 : // Monthly on nth Thursday in month - case 105 : // Monthly on nth Friday in month - case 106 : // Monthly on nth Saturday in month -// echo "Specific day of month: ".$day_number."
"; - $inc_array['mon'] = 1; - $event['mon'] = $temp['mon']; - $event['year'] = $temp['year']; - $event['mday'] = 1; // Start calculating from first day of each month - break; - default : - return FALSE; // Invalid interval type - } - -// echo "First date: ".$event['mon']."-".$event['year']."
"; - // Now loop through using the increment - we may discard a few, but getting clever may be worse! - $cont = TRUE; - - do { - $tstamp = gmmktime($event['hours'],$event['minutes'],$event['seconds'],$event['mon'],$event['mday'],$event['year']); - if ($interval_type >= 100) - { // $tstamp has the first of the month -// $dofwk = gmdate('w',$tstamp); - $day_diff = $day_number - gmdate('w',$tstamp); - if ($day_diff <0) $day_diff += 7; - $day_diff += (7 * $week_offset) - 7; -// echo "Day difference = ".$day_diff." Stamp=".$tstamp." Week day: ".$dofwk."
"; - $tstamp += $day_diff*86400; - } - if ($tstamp >= $start_time) - { - if ($tstamp <= $end_time) - { - $ret[] = $tstamp; - } - else - { - $cont = FALSE; - } - } - $event = $this->add_dates($event,$inc_array); - } while ($cont); - - return $ret; - } - - - // Generate comma separated list of fields for table, with optional alias prefix. - function gen_field_list($table, $list, $must_have = '') - { - if ($list == '*') return $table ? $table.".*" : '*'; - $ret = ''; - $pad = ''; - $temp = explode(',',$list); - for ($i = 0; $i < count($temp); $i++) $temp[$i] = trim($temp[$i]); - if ($must_have) - { - $mharr = explode(',',$must_have); - foreach ($mharr as $mh) - { - if (!in_array(trim($mh), $temp)) $temp[] = trim($mh); - } - } - foreach ($temp as $fld) - { - if ($fld) - { - if ($table) $fld = $table.'.'.$fld; - $ret .= $pad.$fld; - $pad = ', '; - } - } - return $ret; - } - - - /** - * 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; - - $ret = array(); - if ($cat_filter === FALSE) return $ret; - $cat_lj = ''; - $category_filter = ''; - $extra = ''; - $so = ''; - - $event_fields = $this->gen_field_list('e',$event_fields,'event_start,event_end,event_datestamp'); - if ($cat_fields) - { - $cat_fields = ', '.$this->gen_field_list('ec',$cat_fields); - $cat_lj = ' LEFT JOIN #event_cat as ec ON e.event_category = ec.event_cat_id '; - } - - if ($cat_filter && ($cat_filter != '*')) $category_filter = " AND find_in_set(e.event_category, '".$cat_filter."') "; - if ($inc_recur) $extra = " OR (e.event_recurring >'0' AND (e.event_start < ".intval($end_time)." AND e.event_end >= ".intval($start_time).")) "; - - $so = $start_only ? 'start' : 'end'; - $qry = "SELECT {$event_fields}{$cat_fields} FROM #event as e {$cat_lj} - WHERE ( - (e.event_recurring = '0' AND ((e.event_{$so} >= ".intval($start_time)." AND e.event_start < ".intval($end_time)."))) - {$extra}) - {$category_filter} - {$this->extra_query} - ORDER BY e.event_start ASC - "; - - if ($sql->db_Select_gen($qry)) - { - while ($row = $sql->db_Fetch()) - { - // Always add the 'is_recent' marker if required - if ((($this->max_recent_show != 0) && (time() - $row['event_datestamp']) <= $this->max_recent_show)) $row['is_recent'] = TRUE; - if ($row['event_recurring'] == 0) - { - $ret[] = $row; - } - else - { // Recurring events to handle - $temp = $this->gen_recur($row['event_start'],$row['event_end'],$row['event_recurring'],$start_time,$end_time); - if (count($temp)) - { - $row['event_start'] = $temp; // Have an array of start times - $ret[] = $row; - } - } - } - } - return $ret; - } - - - /** - * 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; - - $ret = array(); - if ($cat_filter === FALSE) return $ret; // Empty category - - $cat_lj = ''; - $category_filter = ''; - $extra = ''; - - $event_fields = $this->gen_field_list('e',$event_fields,'event_start,event_end,event_datestamp,event_recurring'); - if ($cat_fields) - { - $cat_fields = ', '.$this->gen_field_list('ec',$cat_fields); - $cat_lj = ' LEFT JOIN #event_cat as ec ON e.event_category = ec.event_cat_id '; - } - - if ($cat_filter != '*') $category_filter = " AND find_in_set(e.event_category, '".$cat_filter."') "; - if ($inc_recur) $extra = " OR (e.event_recurring >'0' AND (e.event_start <= ".intval($end_time)." AND e.event_end >= ".intval($start_time).")) "; - - $qry = "SELECT {$event_fields}{$cat_fields} FROM #event as e {$cat_lj} - WHERE ( - (e.event_recurring = '0' AND (e.event_start >= ".intval($start_time)." AND e.event_start <= ".intval($end_time).") ) - {$extra}) - {$category_filter} - {$this->extra_query} - ORDER BY e.event_start ASC - "; - -// echo "get_n_events Query: ".$qry."
"; - - if ($sql->db_Select_gen($qry)) - { - while ($row = $sql->db_Fetch()) - { - // Always add the 'is_recent' marker if required - if ((($this->max_recent_show != 0) && (time() - $row['event_datestamp']) <= $this->max_recent_show)) $row['is_recent'] = TRUE; - unset($temp); - if ($row['event_recurring'] == 0) - { -// echo "Standard: ".$row['event_start']." ".$row['event_title']."
"; - $temp = array($row['event_start']); - } - else - { // Recurring events to handle -// echo "Recurring: ".$row['event_start']." ".$row['event_title']." - ".$row['event_recurring']." - "; - $temp = $this->gen_recur($row['event_start'],$row['event_end'],$row['event_recurring'],$start_time,$end_time); -// echo count($temp)."results generated
"; - } - - if (count($temp)) - { // We have one or more events to add to the array - foreach ($temp as $ts) - { -// echo "Process: ".$ts." ".$row['event_start']." ".$row['event_title']." ".$end_time."
"; - if ($ts <= $end_time) // We may have pulled in $end_time from the value passed initially - { - $row['event_start'] = $ts; // Fill this in - may be a recurring event -// echo "Add: ".$row['event_start']." ".$row['event_title']."
"; - - if ((count($ret) == 0) || ($ts > $ret[count($ret)-1]['event_start'])) - { // Can just add on end -// echo "Add at end
"; - $ret[] = $row; - } - else - { // Find a slot - $i = count($ret); - while (($i > 0) && ($ret[$i-1]['event_start'] > $ts)) $i--; - // $i has the number of the event before which to insert this new event. - if ($i == 0) - { - array_unshift($ret,$row); // Just insert at beginning -// echo "Insert at front
"; - } - else - { // Proper insert needed just before element $i -// $tmp = array_unshift(array_slice($ret, $i),$row); -// array_splice($ret, $i, count($ret), $tmp); - array_splice($ret, $i, count($ret), array_merge(array($row),array_slice($ret, $i))); -// echo "Insert at ".$i."
"; - } - } - } - if (count($ret) > $num_event) - { // Knock one off the end -// echo "Delete, count is ".count($ret)."
"; - if ($ret[count($ret)-1]['event_start'] < $end_time) $end_time = $ret[count($ret)-1]['event_start']; // Pull in end time if we can - array_pop($ret); - } - } - } - } - } - return $ret; - } // End - function get_n_events() - - - /** - * Get text relating to recurring item - * @param int numeric code for type of recurring item - * - * @return string corresponding text description - */ - public function get_recur_text($recurring) - { - if ($recurring >= 100) - { - return $this->recur_week[100*intval($recurring/100)].' '.$this->recur_type[100+($recurring % 10)]; - } - else - { - return $this->recur_type[$recurring]; - } - } - -}// End - class definition - -?> + 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' + ); + + + public function __construct() + { // Constructor + $this->pref = e107::pref('calendar_menu'); // retrieve calendar_menu pref array. + + + // Get all the times in terms of 'clock time' - i.e. allowing for TZ, DST, etc + // All the times in the DB should be 'absolute' - so if we compare with 'clock time' it should work out. + $this->time_now = time(); + $this->site_timedate = $this->time_now + ($this->pref['time_offset'] * 3600); // Check sign of offset + $this->user_timedate = $this->time_now + TIMEOFFSET; + switch ($this->pref['eventpost_caltime']) + { + case 1 : + $this->cal_timedate = $this->site_timedate; // Site time + break; + case 2 : + $this->cal_timedate = $this->user_timedate; // User + break; + default : + $this->cal_timedate = $this->time_now; // Server time - default + } + $this->now_date = getdate($this->time_now); + $this->site_date = getdate($this->site_timedate); // Array with h,m,s, day, month year etc + $this->cal_date = getdate($this->cal_timedate); + + $this->max_cache_time = $this->site_date['minutes'] + 60*$this->site_date['hours']; + + $this->cal_super = check_class($this->pref['eventpost_super']); + if ($this->cal_super) $this->extra_query = ""; else $this->extra_query = " AND find_in_set(event_cat_class,'".USERCLASS_LIST."')"; + + $this->max_recent_show = 0; + if (isset($this->pref['eventpost_recentshow'])) + { + if ($this->pref['eventpost_recentshow'] == 'LV') + { + if (USER) $this->max_recent_show = time() - USERLV; + } + else + { + $this->max_recent_show = 3600 * $this->pref['eventpost_recentshow']; + } + } + + switch ($this->pref['eventpost_timedisplay']) + { + case 2 : + $this->time_format_string = "%I:%M %p"; // 12-hour display + break; + case 3 : + $this->time_format_string = $this->pref['eventpost_timecustom']; // custom display + if (isset($this->time_format_string)) break; + case 4 : + $this->time_format_string = "%H:%M"; // 24-hour display with separator + break; + default : + $this->time_format_string = "%H%M"; // default to 24-hour display + } + + if (!isset($this->pref['eventpost_datedisplay'])) $this->pref['eventpost_datedisplay'] = 1; + $temp = $this->pref['eventpost_datedisplay']; + if ($temp >3) + { + $temp-= 3; + $this->date_separator = '.'; + if ($temp > 3) + { + $temp -= 3; + $this->date_separator = '/'; + } + } + switch ($temp) + { // Event entry calendar + case 2 : + $this->cal_format_string = "d".$this->date_separator."m".$this->date_separator."Y"; + $this->dcal_format_string = "%d".$this->date_separator."%m".$this->date_separator."%Y"; + $this->java_format_code = 2; + break; + case 3 : + $this->cal_format_string = "m".$this->date_separator."d".$this->date_separator."Y"; + $this->dcal_format_string = "%m".$this->date_separator."%d".$this->date_separator."%Y"; + $this->java_format_code = 3; + break; + default : // 'original' defaults + $this->cal_format_string = "Y".$this->date_separator."m".$this->date_separator."d"; + $this->dcal_format_string = "%Y".$this->date_separator."%m".$this->date_separator."%d"; + $this->java_format_code = 1; + } + + if (!isset($this->pref['eventpost_dateevent'])) $this->pref['eventpost_dateevent'] = 1; + switch ($this->pref['eventpost_dateevent']) + { // Event list date display + case 0 : + $this->event_date_format_string = $this->pref['eventpost_eventdatecustom']; + break; + case 2 : + $this->event_date_format_string = "%a %d %b %Y"; + break; + case 3 : + $this->event_date_format_string = "%a %d-%m-%y"; + break; + default : + $this->event_date_format_string = "%A %d %B %Y"; + } + + if (!isset($this->pref['eventpost_datenext'])) $this->pref['eventpost_datenext'] = 1; + switch ($this->pref['eventpost_datenext']) + { // Forthcoming event date display + case 0 : + $this->next_date_format_string = $this->pref['eventpost_nextdatecustom']; + break; + case 2 : + $this->next_date_format_string = "%d %b"; + break; + case 3 : + $this->next_date_format_string = "%B %d"; + break; + case 4 : + $this->next_date_format_string = "%b %d"; + break; + default : + $this->next_date_format_string = "%d %B"; + } + + switch (varset($this->pref['eventpost_weekstart'],'sun')) + { + case 'sun' : $this->ec_first_day_of_week = 0; break; + case 'mon' : $this->ec_first_day_of_week = 1; break; + case 0 : + case 1 : + case 2 : + case 3 : + case 4 : + case 5 : + case 6 : + $this->ec_first_day_of_week = $this->pref['eventpost_weekstart']; break; + default : + $this->ec_first_day_of_week = 1; + } + } + + + + /** + * Returns a time string from a time stamp, formatted as 24-hour, 12-hour or custom as set in prefs + */ + public function time_string($convtime) + { + return gmstrftime($this->time_format_string, $convtime); + } + + + /** + * Returns a date string from a date stamp, formatted for display in event list + */ + public function event_date_string($convdate) + { + return gmstrftime($this->event_date_format_string,$convdate); + } + + + /** + * Returns a date string from a date stamp, formatted for display in forthcoming event menu + */ + public function next_date_string($convdate) + { + return gmstrftime($this->next_date_format_string,$convdate); + } + + + /** + * Returns a date as dd-mm-yyyy or yyyy-mm-dd according to prefs (for event entry) + */ + public function full_date($convdate) + { + return gmdate($this->cal_format_string, $convdate); + } + + + /** + * Turns a date as entered in the calendar into a time stamp (for event entry) + */ + public function make_date($new_hour, $new_minute, $date_string) + { + $tmp = explode($this->date_separator, $date_string); + switch ($this->java_format_code) + { + case 2 : + return gmmktime($new_hour, $new_minute, 0, $tmp[1], $tmp[0], $tmp[2]); // dd-mm-yyyy + case 3 : + return gmmktime($new_hour, $new_minute, 0, $tmp[0], $tmp[1], $tmp[2]); // mm-dd-yyyy + default : + return gmmktime($new_hour, $new_minute, 0, $tmp[1], $tmp[2], $tmp[0]); // yyyy-mm-dd + } + } + + + + /** + * Return day of week string relative to the start of the week + */ + public function day_offset_string($doff) + { + return $this->days[($doff+$this->ec_first_day_of_week) % 7]; + } + + + /** + * Single entry point for all calendar-related logging. + * + * Also triggers a 'notify' event: + * 'ecalnew' when single or multiple events added + * 'ecaledit' when an event changed or deleted + * + * @param integer $event_type - type of event being logged: + * 1 - add event + * 2 - edit event + * 3 - delete event + * 4 - Bulk delete + * 5 - add multiple events + * @param string $event_title - included in logged message + * @param string $event_string - included in logged message + * @param integer $event_start - start time of event where appropriate + * + * @return - none + */ + public function cal_log($event_type, $event_title = '', $event_string='', $event_start=0) + { + $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]."
"; + if ($event_start > 0) + { + $cmessage .= 'Event Start: '.strftime("%d-%B-%Y",$event_start)."
"; + $cmessage .= 'Event Link: '.SITEURL.e_PLUGIN_ABS. 'calendar_menu/event.php?'.$event_start."
"; + } + else + $cmessage .= "Event Start unknown
"; + $edata_ec = array('cmessage' => $cmessage, 'ip' => e107::getIPHandler()->getIP(FALSE)); + switch ($event_type) + { + case 5 : + case 1 : $e107->e_event->trigger('ecalnew', $edata_ec); + break; + case 2 : + case 3 : + case 4 : $e107->e_event->trigger('ecaledit', $edata_ec); + break; + } + + switch ($this->pref['eventpost_adminlog']) + { + case 1 : if ($event_type == '1') return; + case 2 : break; // Continue + default : return; // Invalid or undefined option + } + $log_detail = array( '1' => EC_ADLAN_A221.strftime("%d-%B-%Y",$event_start), // Add event + '2' => EC_ADLAN_A222.strftime("%d-%B-%Y",$event_start), // Edit event + '3' => EC_ADLAN_A223.strftime("%d-%B-%Y",$event_start), // Delete event + '4' => EC_ADLAN_A224, // Bulk delete events + '5' => EC_ADLAN_A225.strftime("%d-%B-%Y",$event_start) // Multiple add events + ); + $e107->admin_log->log_event($log_titles[$event_type],$event_title." \n".$log_detail[$event_type]."\n".$event_string,''); + } + + + + /** + * Get text related to a numeric event category + */ + function get_category_text($ev_cat) + { + $sql = e107::getDb(); + if (!isset($this->cat_text_cache[$ev_cat])) + { + $sql->db_Select('event_cat','event_cat_name',"event_cat_id='{$ev_cat}'"); + $row = $sql->db_Fetch(); + $this->cat_text_cache[$ev_cat] = $row['event_cat_name']; + } + return $this->cat_text_cache[$ev_cat]; + } + + + + + /** + * Implements a version of getdate that expects a GMT date and doesn't do TZ/DST adjustments + * time() -date('Z') gives the correction to 'null out' the TZ and DST adjustments that getdate() does + */ + function gmgetdate($date) + { + return getdate($date-date('Z')); + } + + + +//------------------------------------------------ +// Recurring event handling +//------------------------------------------------ + + /** + * Internal utility - Generate a list of time/date based on a 'first event' date, an interval and start/finish times + * All fields are Unix-style time/date stamps + * @param int $first_event + * @param int $last_event + * @param int $interval - interval between events (in seconds) + * @param int $start_time + * @param int $end_time - last date in time window + * + * @return array of start date/time entries + */ + protected function gen_recur_regular($first_event, $last_event, $interval, $start_time, $end_time) + { + if ($last_event < $end_time) $end_time = $last_event; + $ret = array(); + $first_event = $first_event + ceil(($start_time-$first_event)/$interval)*$interval; + while ($first_event <= $end_time) + { + $ret[] = $first_event; + $first_event += $interval; + } + return $ret; + } + + + /** + * 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']; + if ($main_date['mon'] > 12) + { + $main_date['mon'] -= 12; + $main_date['year']++; + } + } + if ($adder['year']) $main_date['year'] += $adder['year']; + return $main_date; + } + + + /** + * 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(); + $week_offset = 0; + if ($interval_type >= 100) + { + $week_offset = intval($interval_type /100); + $day_number = $interval_type % 10; // Gives 0..6 in practice; potentially 0..9 + $interval_type = 100; + } + if ($first_event > $end_time) return $ret; + + $interval = array('5' => 28*86400, '6' => 14*86400, '7' => 7*86400, '8' => 86400); + // Do the easy ones first + if (array_key_exists($interval_type, $interval)) return $this->gen_recur_regular($first_event, $last_event, $interval[$interval_type], $start_time, $end_time); + + // We're messing around with months and years here + $inc_array['year'] = 0; + $inc_array['mon'] = 0; + + // Find the first date which is within, or close to, scope (N.B. may not be one) + $event = $this->gmgetdate($first_event); + $temp = $this->gmgetdate($start_time); + $event['year'] = $temp['year']; // Use the year from the start window + if ($event['mon'] > $temp['mon']) $event['year']--; // Handle situation where event later in year than desired window + + switch ($interval_type) + { + case 1 : // Annual + $inc_array['year'] = 1; + break; + case 2 : // Biannual + $inc_array['mon'] = 6; + break; + case 3 : // Quarterly + $inc_array['mon'] = 3; + break; + case 4 : // Monthly + $inc_array['mon'] = 1; + break; + case 100 : // Monthly on nth Sunday in month + case 101 : // Monthly on nth Monday in month + case 102 : // Monthly on nth Tuesday in month + case 103 : // Monthly on nth Wednesday in month + case 104 : // Monthly on nth Thursday in month + case 105 : // Monthly on nth Friday in month + case 106 : // Monthly on nth Saturday in month + // echo "Specific day of month: ".$day_number."
"; + $inc_array['mon'] = 1; + $event['mon'] = $temp['mon']; + $event['year'] = $temp['year']; + $event['mday'] = 1; // Start calculating from first day of each month + break; + default : + return FALSE; // Invalid interval type + } + + // echo "First date: ".$event['mon']."-".$event['year']."
"; + // Now loop through using the increment - we may discard a few, but getting clever may be worse! + $cont = TRUE; + + do { + $tstamp = gmmktime($event['hours'],$event['minutes'],$event['seconds'],$event['mon'],$event['mday'],$event['year']); + if ($interval_type >= 100) + { // $tstamp has the first of the month + $day_diff = $day_number - gmdate('w',$tstamp); + if ($day_diff <0) $day_diff += 7; + $day_diff += (7 * $week_offset) - 7; + // echo "Day difference = ".$day_diff." Stamp=".$tstamp." Week day: ".$dofwk."
"; + $tstamp += $day_diff*86400; + } + if ($tstamp >= $start_time) + { + if ($tstamp <= $end_time) + { + $ret[] = $tstamp; + } + else + { + $cont = FALSE; + } + } + $event = $this->add_dates($event,$inc_array); + } while ($cont); + + return $ret; + } + + + + /** + * Generate comma separated list of fields for table, with optional alias prefix. + */ + function gen_field_list($table, $list, $must_have = '') + { + if ($list == '*') return $table ? $table.".*" : '*'; + $ret = ''; + $pad = ''; + $temp = explode(',',$list); + for ($i = 0; $i < count($temp); $i++) $temp[$i] = trim($temp[$i]); + if ($must_have) + { + $mharr = explode(',',$must_have); + foreach ($mharr as $mh) + { + if (!in_array(trim($mh), $temp)) $temp[] = trim($mh); + } + } + foreach ($temp as $fld) + { + if ($fld) + { + if ($table) $fld = $table.'.'.$fld; + $ret .= $pad.$fld; + $pad = ', '; + } + } + return $ret; + } + + + + + /** + * 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='*') + { + $sql = e107::getDb(); + + $ret = array(); + if ($cat_filter === FALSE) return $ret; + $cat_lj = ''; + $category_filter = ''; + $extra = ''; + $so = ''; + + $event_fields = $this->gen_field_list('e',$event_fields,'event_start,event_end,event_datestamp'); + if ($cat_fields) + { + $cat_fields = ', '.$this->gen_field_list('ec',$cat_fields); + $cat_lj = ' LEFT JOIN #event_cat as ec ON e.event_category = ec.event_cat_id '; + } + + if ($cat_filter && ($cat_filter != '*')) $category_filter = " AND find_in_set(e.event_category, '".$cat_filter."') "; + if ($inc_recur) $extra = " OR (e.event_recurring >'0' AND (e.event_start < ".intval($end_time)." AND e.event_end >= ".intval($start_time).")) "; + + $so = $start_only ? 'start' : 'end'; + $qry = "SELECT {$event_fields}{$cat_fields} FROM #event as e {$cat_lj} + WHERE ( + (e.event_recurring = '0' AND ((e.event_{$so} >= ".intval($start_time)." AND e.event_start < ".intval($end_time)."))) + {$extra}) + {$category_filter} + {$this->extra_query} + ORDER BY e.event_start ASC + "; + + if ($sql->db_Select_gen($qry)) + { + while ($row = $sql->db_Fetch()) + { + // Always add the 'is_recent' marker if required + if ((($this->max_recent_show != 0) && (time() - $row['event_datestamp']) <= $this->max_recent_show)) $row['is_recent'] = TRUE; + if ($row['event_recurring'] == 0) + { + $ret[] = $row; + } + else + { // Recurring events to handle + $temp = $this->gen_recur($row['event_start'],$row['event_end'],$row['event_recurring'],$start_time,$end_time); + if (count($temp)) + { + $row['event_start'] = $temp; // Have an array of start times + $ret[] = $row; + } + } + } + } + return $ret; + } + + + + + /** + * 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='*') + { + $sql = e107::getDb(); + + $ret = array(); + if ($cat_filter === FALSE) return $ret; // Empty category + + $cat_lj = ''; + $category_filter = ''; + $extra = ''; + + $event_fields = $this->gen_field_list('e',$event_fields,'event_start,event_end,event_datestamp,event_recurring'); + if ($cat_fields) + { + $cat_fields = ', '.$this->gen_field_list('ec',$cat_fields); + $cat_lj = ' LEFT JOIN #event_cat as ec ON e.event_category = ec.event_cat_id '; + } + + if ($cat_filter != '*') $category_filter = " AND find_in_set(e.event_category, '".$cat_filter."') "; + if ($inc_recur) $extra = " OR (e.event_recurring >'0' AND (e.event_start <= ".intval($end_time)." AND e.event_end >= ".intval($start_time).")) "; + + $qry = "SELECT {$event_fields}{$cat_fields} FROM #event as e {$cat_lj} + WHERE ( + (e.event_recurring = '0' AND (e.event_start >= ".intval($start_time)." AND e.event_start <= ".intval($end_time).") ) + {$extra}) + {$category_filter} + {$this->extra_query} + ORDER BY e.event_start ASC + "; + + // echo "get_n_events Query: ".$qry."
"; + + if ($sql->db_Select_gen($qry)) + { + while ($row = $sql->db_Fetch()) + { + // Always add the 'is_recent' marker if required + if ((($this->max_recent_show != 0) && (time() - $row['event_datestamp']) <= $this->max_recent_show)) $row['is_recent'] = TRUE; + unset($temp); + if ($row['event_recurring'] == 0) + { + // echo "Standard: ".$row['event_start']." ".$row['event_title']."
"; + $temp = array($row['event_start']); + } + else + { // Recurring events to handle + // echo "Recurring: ".$row['event_start']." ".$row['event_title']." - ".$row['event_recurring']." - "; + $temp = $this->gen_recur($row['event_start'],$row['event_end'],$row['event_recurring'],$start_time,$end_time); + // echo count($temp)."results generated
"; + } + + if (count($temp)) + { // We have one or more events to add to the array + foreach ($temp as $ts) + { + // echo "Process: ".$ts." ".$row['event_start']." ".$row['event_title']." ".$end_time."
"; + if ($ts <= $end_time) // We may have pulled in $end_time from the value passed initially + { + $row['event_start'] = $ts; // Fill this in - may be a recurring event + // echo "Add: ".$row['event_start']." ".$row['event_title']."
"; + + if ((count($ret) == 0) || ($ts > $ret[count($ret)-1]['event_start'])) + { // Can just add on end + // echo "Add at end
"; + $ret[] = $row; + } + else + { // Find a slot + $i = count($ret); + while (($i > 0) && ($ret[$i-1]['event_start'] > $ts)) $i--; + // $i has the number of the event before which to insert this new event. + if ($i == 0) + { + array_unshift($ret,$row); // Just insert at beginning + // echo "Insert at front
"; + } + else + { // Proper insert needed just before element $i + // $tmp = array_unshift(array_slice($ret, $i),$row); + // array_splice($ret, $i, count($ret), $tmp); + array_splice($ret, $i, count($ret), array_merge(array($row),array_slice($ret, $i))); + // echo "Insert at ".$i."
"; + } + } + } + if (count($ret) > $num_event) + { // Knock one off the end + // echo "Delete, count is ".count($ret)."
"; + if ($ret[count($ret)-1]['event_start'] < $end_time) $end_time = $ret[count($ret)-1]['event_start']; // Pull in end time if we can + array_pop($ret); + } + } + } + } + } + return $ret; + } // End - function get_n_events() + + + + + /** + * Get text relating to recurring item + * @param int numeric code for type of recurring item + * + * @return string corresponding text description + */ + public function get_recur_text($recurring) + { + if ($recurring >= 100) + { + return $this->recur_week[100*intval($recurring/100)].' '.$this->recur_type[100+($recurring % 10)]; + } + else + { + return $this->recur_type[$recurring]; + } + } + +}// End - class definition + +?> diff --git a/e107_plugins/calendar_menu/event.php b/e107_plugins/calendar_menu/event.php index e9397f776..99d907aa5 100644 --- a/e107_plugins/calendar_menu/event.php +++ b/e107_plugins/calendar_menu/event.php @@ -1,939 +1,926 @@ -isInstalled('calendar_menu')) -{ - header('Location: '.e_BASE.'index.php'); - exit(); -} - -if (isset($_POST['viewallevents'])) -{ // Triggered from NAV_BUT_ALLEVENTS - 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(); -} - -if (isset($_POST['subs'])) -{ - Header('Location: '.e_PLUGIN.'calendar_menu/subscribe.php'); - exit(); -} - -if (isset($_POST['printlists'])) -{ - 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); - -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; - - -//e107::getScParser(); -require_once(e_PLUGIN.'calendar_menu/calendar_shortcodes.php'); -$calSc = new event_calendar_shortcodes(); - -// require_once(e_HANDLER.'calendar/calendar_class.ph_'); -// $cal = new DHTML_Calendar(true); - -$cat_filter = intval(varset($_POST['event_cat_ids'],-1)); -if ($cat_filter == -1) $cat_filter = '*'; -$mult_count = 0; - - - -// Array links db field names to internal variables -$ev_fields = array( - 'event_id' => 'id', - 'event_start' => 'ev_start', - 'event_end' => 'ev_end', - 'event_allday' => 'ev_allday', - 'event_recurring' => 'recurring', - 'event_title' => 'ev_title', - 'event_location' => 'ev_location', - 'event_details' => 'ev_event', -// 'event_author' => 'ne_author', - not needed - its always the user creating the event - 'event_contact' => 'ev_email', - 'event_category' => 'ev_category', - 'event_thread' => 'ev_thread' -); - -//-------------------------------------- -// Event to add or update -//-------------------------------------- -if ((isset($_POST['ne_insert']) || isset($_POST['ne_update'])) && ($cal_super || check_class($pref['eventpost_admin']))) -{ - $ev_start = $ecal_class->make_date($_POST['ne_hour'], $_POST['ne_minute'],$_POST['start_date']); - if (($_POST['ne_event'] == '') || !isset($_POST['qs'])) - { // Problem - tell user to go away - fields are blank (mostly checked by JS) - header('location:event.php?'.$ev_start.'.0.m3'); - } - elseif (!isset($_POST['ne_category']) || (($ev_category = intval($_POST['ne_category'])) == 0)) - { - header('location:event.php?'.$ev_start.'.0.m6'); - } - else - { - if (!$cal_super) - { - if ($sql->db_Select('event_cat', 'event_cat_addclass', 'event_cat_id = '.$ev_category)) - { - $row = $sql->db_Fetch(MYSQL_ASSOC); - if (!check_class($row['event_cat_addclass'])) - { - header('location:event.php?'.$ev_start.'.0.m8'); - exit; - } - } - else - { // Invalid category - definitely go away! - header('location:'.e_BASE.'index.php'); - exit; - } - } - - $ev_end = $ecal_class->make_date($_POST['end_hour'], $_POST['end_minute'],$_POST['end_date']); - $ev_title = $e107->tp->toDB($_POST['ne_title']); - $ev_location = $e107->tp->toDB($_POST['ne_location']); - $ev_event = $e107->tp->toDB($_POST['ne_event']); - $ev_email = $e107->tp -> toDB($_POST['ne_email']); - $ev_thread = $e107->tp->toDB($_POST['ne_thread']); - $temp_date = getdate($ecal_class->make_date(0,0,$_POST['start_date'])); - $ev_allday = intval($_POST['allday']); - $recurring = intval($_POST['ec_recur_type']); - if ($recurring >= 100) $recurring += intval($_POST['ec_recur_week']) - 100; - // - if ($_POST['recurring'] == 1) - { - $rec_m = $temp_date['mday']; // Day of month - $rec_y = $temp_date['mon']; // Month number - } - else - { - $rec_m = ''; - $rec_y = ''; - } - - $report_msg = '.m3'; - if (isset($_POST['ne_insert'])) - { // Bits specific to inserting a new event - $qs = preg_replace("/ne./i", "", $_POST['qs']); - if ($_POST['ec_gen_multiple']) - { - $mult_count = $ecal_class->gen_recur($ev_start,$ev_end,$recurring,$ev_start,$ev_end); - } - if ($mult_count <= 1) - { - $qry = " 0, '".intval($ev_start)."', '".intval($ev_end)."', '".$ev_allday."', '".$recurring."', '".time()."', '$ev_title', '$ev_location', '$ev_event', '".USERID.".".USERNAME."', '".$ev_email."', '".$ev_category."', '".$ev_thread."', '".intval($rec_m)."', '".intval($rec_y)."' "; - $sql->db_Insert('event', $qry); - - $id = mysql_insert_id(); - $data = array('method'=>'create', 'table'=>'event', 'id'=>$id, 'plugin'=>'calendar_menu', 'function'=>'dbCalendarCreate'); - $e_event->triggerHook($data); - - $ecal_class->cal_log(1,'db_Insert',$qry, $ev_start); - $report_msg = '.m4'; - } - } - - if (isset($_POST['ne_update'])) - { // Bits specific to updating an existing event - $qry = "event_start='".intval($ev_start)."', event_end='".intval($ev_end)."', event_allday='".$ev_allday."', event_recurring='".$recurring."', event_datestamp= '".time()."', event_title= '$ev_title', event_location='$ev_location', event_details='$ev_event', event_contact='".$ev_email."', event_category='".$ev_category."', event_thread='".$ev_thread."', event_rec_m='".intval($rec_m)."', event_rec_y='".intval($rec_y)."' WHERE event_id='".intval($_POST['id'])."' "; - $sql->db_Update("event", $qry); - - $data = array('method'=>'update', 'table'=>'event', 'id'=>intval($_POST['id']), 'plugin'=>'calendar_menu', 'function'=>'dbCalendarUpdate'); - $e_event->triggerHook($data); - - $ecal_class->cal_log(2,'db_Update',$qry, $ev_start); - $qs = preg_replace("/ed./i", "", $_POST['qs']); - $report_msg = '.m5'; - } - if ($mult_count <= 1) - { - // Now clear cache - just do the lot for now - get clever later - $e107cache->clear('nq_event_cal'); - header('location:event.php?'.$ev_start.'.'.$qs.$report_msg); - } - } -} - - - -$action = ''; - -require_once(HEADERF); - -if ($mult_count > 1) -{ // Need to handle writing of multiple events - display confirmation form - $message = str_replace('-NUM-', count($mult_count), EC_LAN_88); - $text = " -
- - "; - if ($ev_allday) - { - $text .= " - - "; - } - else - { - $text .= " - - "; - } - $text .= " - - - - - "; - - // Only display for forum thread/link if required. No point if not wanted - if (isset($pref['eventpost_forum']) && $pref['eventpost_forum'] == 1) - { - $text .= ""; - } - $text .= " -
".$message."
".EC_LAN_89."
".EC_LAN_173." ".$ecal_class->event_date_string($ev_start)." ".EC_LAN_175."
".EC_LAN_174." ".$ecal_class->event_date_string($ev_end)." ".EC_LAN_175."
".EC_LAN_173." ".$ecal_class->event_date_string($ev_start)." ".$ecal_class->time_string($ev_start)." "."
".EC_LAN_174." ".$ecal_class->event_date_string($ev_end)." ".$ecal_class->time_string($ev_end)." "."
".EC_LAN_176."".$ecal_class->get_recur_text($recurring)."
".EC_LAN_70."".$ev_title."
".EC_LAN_52."".$ecal_class->get_category_text($ev_category)."
".EC_LAN_32."".$ev_location."
".EC_LAN_57."".$ev_event."
".EC_LAN_58." ".$ev_thread."
".EC_LAN_59."".$ev_email."
- - - "; - foreach ($ev_fields as $k => $v) - { - $text .= ""; - } - $text .= "
"; - - $ns->tablerender(EC_LAN_179, $text); - require_once(FOOTERF); - exit; -} - - -// Calculate any action, plus start date/number of events, from query -unset($dateArray); -$ds = ''; // Gets set if viewing a single day -if (isset($_POST['jump'])) -{ - $dateArray = getdate(mktime(0, 0, 0, $_POST['jumpmonth'], 1, $_POST['jumpyear'])); -} -else -{ - if (e_QUERY) - { - $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 == '') - { - $dateArray = $ecal_class->cal_date; // Use todays date - } - else - { - if (is_numeric($action)) - { - $dateArray = getdate($action); - } - else - { - $dateArray = getdate($ds); - } - } -} - -$dateArray['ds'] = $ds; // Way to pass to shortcodes. -$month = $dateArray['mon']; // Number of month being shown -$year = $dateArray['year']; // Number of year being shown - - -if ($cal_super || check_class($pref['eventpost_admin'])) -{ // Bits relating to 'delete event', and generation of multiple events - if ($action == 'mc') - { - if (isset($_POST['mc_cancel'])) - { - $message = EC_LAN_179; - } - elseif (isset($_POST['mc_accept'])) - { // Go for it! Write lots of events - // Start by reading all the info from the hidden fields - $wr_record = array(); - foreach ($ev_fields as $k => $v) - { - $wr_record[$k] = $e107->tp->toDB($_POST['ev_'.$k]); - } - $wr_record['event_author'] = USERID.".".USERNAME; - $wr_record['event_datestamp'] = time(); - $mult_count = $ecal_class->gen_recur($wr_record['event_start'],$wr_record['event_end'],$wr_record['event_recurring'],$wr_record['event_start'],$wr_record['event_end']); - $wr_record['event_recurring'] = 0; // Individual events are non-recurring! - - // Now write all the entries - $wc = 0; - foreach ($mult_count as $mc) - { - $wr_record['event_start'] = $mc; - $wr_record['event_end'] = merge_date_time($mc,$wr_record['event_end']); -// echo "Write record: ".$wr_record['event_start']." to ".$wr_record['event_end']."
"; - if ($sql->db_Insert("event", $wr_record)) $wc++; - } - $ecal_class->cal_log(5,'db_Insert',$qry, $ev_start); - - $message = str_replace('-NUM-',$wc,EC_LAN_41); - if ($wc != count($mult_count)) $message .= "

".(count($mult_count)-$wc)." ".EC_LAN_180; - } - $action = ''; - } - - - if (isset($_POST['confirm'])) - { - $qry = "event_id='".intval($_POST['existing'])."' "; - if ($sql->db_Delete("event", $qry)) - { - $message = EC_LAN_51; //Event Deleted - - $data = array('method'=>'delete', 'table'=>'event', 'id'=>$_POST['existing'], 'plugin'=>'calendar_menu', 'function'=>'dbEventDelete'); - $message .= $e_event->triggerHook($data); - - $ecal_class->cal_log(3,'db_Delete',$qry,$ev_start); - } - else - { - $message = EC_LAN_109; //Unable to Delete event for some mysterious reason - } - } - - - if ($action == "de") - { // Delete event - show confirmation form - $text = "
- ".EC_LAN_48." -

-
- - - - -
-
"; - $ns->tablerender(EC_LAN_46, $text); // Confirm Delete Event - require_once(FOOTERF); - exit; - } - - - - if (isset($_POST['cancel'])) - { // Delete Cancelled - $message = EC_LAN_47; - } -} // End - if ($cal_super) - - - -// Messages acknowledging actions -$poss_message = array('m1' => EC_LAN_41, 'm2' => EC_LAN_42, 'm3' => EC_LAN_43, 'm4' => EC_LAN_44, 'm5' => EC_LAN_45, - 'm6' => EC_LAN_145, 'm7' => 'Could have saved -NUM- events', 'm8' => EC_LAN_181); -if (isset($qs[2])) if (isset($poss_message[$qs[2]])) -{ - $message = $poss_message[$qs[2]]; - $ec = varset($qs[3],0); - if ($ec) $message = str_replace('-NUM-',$ec,$message); -} - - -if (isset($message)) -{ - $ns->tablerender("", "
".$message."
"); -} - - -function merge_date_time($date, $time) -{ - return ((86400*intval($date/86400)) + ($time % 86400)); -} - -//------------------------------------- -// enter new event form -//------------------------------------- -if ($action == 'ne' || $action == 'ed') -{ - if ($ecal_class->cal_super || check_class($pref['eventpost_admin'])) - { - function make_calendar($boxname, $boxvalue) - { - global $ecal_class; - // global $cal; - $frm = e107::getForm(); - - unset($cal_options); - unset($cal_attrib); - /* - DHTML Calendar is deprecated in v2+ - $cal_options['firstDay'] = $ecal_class->ec_first_day_of_week; - $cal_options['showsTime'] = false; - $cal_options['showOthers'] = true; - $cal_options['weekNumbers'] = false; - $cal_options['ifFormat'] = $ecal_class->dcal_format_string; - $cal_attrib['class'] = "tbox"; - $cal_attrib['size'] = "12"; - $cal_attrib['name'] = $boxname; - $cal_attrib['value'] = $boxvalue; - */ - - $opt = array('size' => 12); - return $frm->datepicker($boxname,$boxvalue,$opt); - // return $cal->make_input_field($cal_options, $cal_attrib); - } - - - function make_hourmin($boxname,$cur_hour,$cur_minute) - { - global $pref; - if (isset($pref['eventpost_fivemins'])) $incval = 5; else $incval = 1; - $retval = " \n - \n"; - return $retval; - } - - function recur_select($curval) - { - global $ecal_class; - while ($curval > 150) { $curval -= 100; } // Could have values up to about 406 - $ret = "\n"; - return $ret; - } - - - function recur_week_select($curval) - { - global $ecal_class; - $disp = $curval < 100 ? " style='display:none;'" : ""; - $curval -= intval($curval % 10); // Should make it an exact multiple of 100 - $ret = "\n"; - return $ret; - } - - - switch ($action) - { - 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']; - $ne_minute = $smarray['minutes']; - $ne_startdate = $ecal_class->full_date($ne_start); - - $smarray = $ecal_class->gmgetdate($ne_end); - $end_hour = $smarray['hours']; - $end_minute = $smarray['minutes']; - $ne_enddate = $ecal_class->full_date($ne_end); - - $caption = EC_LAN_66; // edit Event - break; - - case 'ne' : // New event - initialise everything - $smarray = $ecal_class->gmgetdate($qs[1]); - $month = $smarray['mon']; - $year = $smarray['year']; - $ne_startdate = $ecal_class->full_date($qs[1]); - - $ne_hour = $smarray['hours']; - $ne_minute = $smarray['minutes']; - - $end_hour = $smarray['hours']; - $end_minute = $smarray['minutes']; - $ne_enddate = $ecal_class->full_date($qs[1]); - $recurring = 0; - $caption = EC_LAN_28; // Enter New Event - - default : - $caption = EC_LAN_83; - } - - - $text = " - "; - - $text .= " -
- "; - - $text .= " - - - - - - - "; - - switch ($pref['eventpost_editmode']) - { - case 1 : - $insertjs = "rows='15' onselect='storeCaret(this);' onclick='storeCaret(this);' onkeyup='storeCaret(this);'"; - break; - case 2 : - $insertjs = "rows='25' "; - break; - default : $insertjs = "rows='15' "; - } - - $text .= " - - - "; - - // Only display for forum thread/link if required. No point if not wanted - if (isset($pref['eventpost_forum']) && $pref['eventpost_forum'] == 1) - { - $text .= " - "; - } - - // If the user is logged in and has their email set plus the field is empty then put in - // their email address. They can always take it out if they want, its not a required field - if (empty($ne_email) && ($action == "ne") && defined('USEREMAIL')) - { - $ne_email = USEREMAIL; - } - $text .= " - "; - - //triggerHook - $hid = ($action=='ed' ? intval($qs[1]) : ''); - $data = array('method'=>'form', 'table'=>'event', 'id'=>$hid, 'plugin'=>'calendar_menu', 'function'=>'CalendarCreate'); - $text .= $frm->renderHooks($data); - - - $text .= " - - - - - - - -
".EC_LAN_72." ".EC_LAN_67." "; - - $text .= make_calendar("start_date",$ne_startdate)."   ".EC_LAN_73." ".make_calendar("end_date",$ne_enddate); - $text .= "
".EC_LAN_71." ".EC_LAN_67; - - $text .= make_hourmin("ne_",$ne_hour,$ne_minute)."  ".EC_LAN_73.make_hourmin('end_',$end_hour,$end_minute); - $text .= "
"; - $text .= EC_LAN_64." -
".EC_LAN_65.""; - $text .= recur_week_select($recurring)."  ".recur_select($recurring); - $disp = $recurring && ($action == 'ne') ? '' : " style='display:none;'"; - $text .= "".EC_LAN_86.""; - $text .= "
".EC_LAN_63." -
".EC_LAN_70." * - -
".EC_LAN_52." - -
".EC_LAN_32." - -
".EC_LAN_57." * - "; - if ($pref['eventpost_editmode'] == 1) - { - // Show help - require_once(e_HANDLER."ren_help.php"); - $text .= "
".display_help("helpb", 'event'); - } - - $text .= "
".EC_LAN_58." - -
".EC_LAN_59." - -
".EC_LAN_105."
"; - if ($action == "ed") - { - $text .= " - "; - } - else - { - $text .= ""; - } - $text .= "
-
"; - - $ns->tablerender($caption, $text); - require_once(FOOTERF); - exit; - } - else - { - header('location:'.e_PLUGIN.'calendar_menu/event.php'); - exit; - } -} // End of "Enter New Event" - - -//----------------------------------------------- -// show events -// $month, $year have the month required -//----------------------------------------------- -if (is_readable(THEME.'calendar_template.php')) -{ // Has to be require - require(THEME.'calendar_template.php'); -} -else -{ - require(e_PLUGIN.'calendar_menu/calendar_template.php'); -} - -$calSc->ecalClass = &$ecal_class; // Give shortcodes a pointer to calendar class -$calSc->setCalDate($dateArray); // Tell shortcodes the date to display -$calSc->catFilter = $cat_filter; // Category filter -$calSc->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 .= $e107->tp->parseTemplate($CALENDAR_TIME_TABLE, FALSE, $calSc); - -// navigation buttons -$text2 .= $e107->tp->parseTemplate($CALENDAR_NAVIGATION_TABLE, FALSE, $calSc); - - -// ****** CAUTION - the category dropdown also used $sql object - take care to avoid interference! - -$ev_list = array(); - - -if ($ds == 'event') -{ // Show single event - bit of a special case - $ec_err = FALSE; - $qry = " - SELECT e.*, ec.event_cat_name,ec.event_cat_icon - FROM #event as e - LEFT JOIN #event_cat as ec ON e.event_category = ec.event_cat_id - WHERE e.event_id='".intval($eveid)."' - {$ecal_class->extra_query} - "; - $sql2->db_Select_gen($qry); - $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 - { - $temp_arr = $ecal_class->gen_recur($thisEvent['event_start'],$thisEvent['event_end'],$thisEvent['event_recurring'],$action,$action+86400); // Array of start times - hopefully just one! - if (count($temp_arr) == 1) - { - $thisEvent['event_start'] = $temp_arr[0]; - $thisEvent['event_end'] = merge_date_time($action,$thisEvent['event_end']); - } - else - { // Error - $ec_err = TRUE; - } - } - $next10_start = $thisEvent['event_start'] +1; - $calSc->event = $thisEvent; // Give shortcodes the event data - $text2 .= $e107->tp->parseTemplate($EVENT_EVENT_TABLE_START, FALSE, $calSc); - if ($ec_err) $text2.= "Software Error
"; else $text2 .= $e107->tp->parseTemplate($EVENT_EVENT_TABLE, FALSE, $calSc); - $text2 .= $e107->tp->parseTemplate($EVENT_EVENT_TABLE_END, FALSE, $calSc); -} -else -{ - if ($ds == 'one') - { // Show events from one day -// $tmp = getdate($action); -// $selected_day = $tmp['mday']; -// $selected_mon = $tmp['mon']; - $start_time = intval($action); - $end_time = $action + 86399; - $next10_start = $end_time + 1; - } - else - { // Display whole of selected month - $start_time = $monthstart; - $end_time = $monthend; - $next10_start = $end_time + 1; - } - - // echo "Start: ".$start_time." End: ".$end_time." Cat_filter: ".$cat_filter."
"; - // We'll need virtually all of the event-related fields, so get them regardless - $ev_list = $ecal_class->get_events($start_time, $end_time, FALSE, $cat_filter, TRUE, '*', 'event_cat_name,event_cat_icon'); - - - // Now go through and multiply up any recurring records - $tim_arr = array(); - foreach ($ev_list as $k=>$event) - { - if (is_array($event['event_start'])) - { - foreach ($event['event_start'] as $t) - { - $tim_arr[$t] = $k; - } - } - else - { - $tim_arr[$event['event_start']] = $k; - } - } - - // Add a sort in here - time/date order - ksort($tim_arr); - - // display event list for current month - if(count($tim_arr)) - { - $text2 .= $e107->tp->parseTemplate($EVENT_EVENTLIST_TABLE_START, FALSE, $calSc); - foreach ($tim_arr as $tim => $ptr) - { - $ev_list[$ptr]['event_start'] = $tim; - $calSc->event = $ev_list[$ptr]; // Give shortcodes the event data - $text2 .= $e107->tp->parseTemplate($EVENT_EVENT_TABLE, FALSE, $calSc); - } - $text2 .= $e107->tp->parseTemplate($EVENT_EVENTLIST_TABLE_END, FALSE, $calSc); - } -} - - -// Now display next 10 events -//echo "Next 10 start: ".$next10_start."
"; -$ev_list = $ecal_class->get_n_events(10, $next10_start, $next10_start+86400000, $cat_filter, TRUE, - 'event_id,event_start, event_title', 'event_cat_name, event_cat_icon'); - - -$num = count($ev_list); -if ($num != 0) -{ - $calSc->numEvents = $num; // Give shortcodes the number of events to expect - $archive_events = ''; - foreach ($ev_list as $thisEvent) - { - $calSc->event = $thisEvent; // Give shortcodes the event data - $archive_events .= $e107->tp->parseTemplate($EVENT_ARCHIVE_TABLE, FALSE, $calSc); - } -} -else -{ - $archive_events = $e107->tp->parseTemplate($EVENT_ARCHIVE_TABLE_EMPTY, FALSE, $calSc); -} - -$text2 .= $e107->tp->parseTemplate($EVENT_ARCHIVE_TABLE_START, FALSE, $calSc); -$text2 .= $archive_events; -$text2 .= $e107->tp->parseTemplate($EVENT_ARCHIVE_TABLE_END, FALSE, $calSc); - - -$e107->ns->tablerender($e107->tp->ParseTemplate('{EC_EVENT_PAGE_TITLE}', FALSE, $calSc), $text2); - -// Claim back memory no longer required -unset($ev_list); -unset($text2); -unset($tim_arr); - -require_once(FOOTERF); - - -/* -function headerjs() -{ - global $cal; - $script = $cal->load_files(); - return $script; -} -*/ - -?> +isInstalled('calendar_menu')) +{ + header('Location: '.e_BASE.'index.php'); + exit(); +} + +if (isset($_POST['viewallevents'])) +{ // Triggered from NAV_BUT_ALLEVENTS + 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(); +} + +if (isset($_POST['subs'])) +{ + Header('Location: '.e_PLUGIN.'calendar_menu/subscribe.php'); + exit(); +} + +if (isset($_POST['printlists'])) +{ + 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); + +require_once(e_PLUGIN.'calendar_menu/ecal_class.php'); +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'); +$calSc = new event_calendar_shortcodes(); + + +$cat_filter = intval(varset($_POST['event_cat_ids'],-1)); +if ($cat_filter == -1) $cat_filter = '*'; +$mult_count = 0; + + + +// Array links db field names to internal variables +$ev_fields = array( + 'event_id' => 'id', + 'event_start' => 'ev_start', + 'event_end' => 'ev_end', + 'event_allday' => 'ev_allday', + 'event_recurring' => 'recurring', + 'event_title' => 'ev_title', + 'event_location' => 'ev_location', + 'event_details' => 'ev_event', +// 'event_author' => 'ne_author', - not needed - its always the user creating the event + 'event_contact' => 'ev_email', + 'event_category' => 'ev_category', + 'event_thread' => 'ev_thread' +); + +//-------------------------------------- +// Event to add or update +//-------------------------------------- +if ((isset($_POST['ne_insert']) || isset($_POST['ne_update'])) && ($cal_super || check_class($ecal_class->pref['eventpost_admin']))) +{ + $ev_start = $ecal_class->make_date($_POST['ne_hour'], $_POST['ne_minute'],$_POST['start_date']); + if (($_POST['ne_event'] == '') || !isset($_POST['qs'])) + { // Problem - tell user to go away - fields are blank (mostly checked by JS) + header('location:event.php?'.$ev_start.'.0.m3'); + } + elseif (!isset($_POST['ne_category']) || (($ev_category = intval($_POST['ne_category'])) == 0)) + { + header('location:event.php?'.$ev_start.'.0.m6'); + } + else + { + if (!$cal_super) + { + if ($sql->db_Select('event_cat', 'event_cat_addclass', 'event_cat_id = '.$ev_category)) + { + $row = $sql->db_Fetch(MYSQL_ASSOC); + if (!check_class($row['event_cat_addclass'])) + { + header('location:event.php?'.$ev_start.'.0.m8'); + exit; + } + } + else + { // Invalid category - definitely go away! + header('location:'.e_BASE.'index.php'); + exit; + } + } + + $ev_end = $ecal_class->make_date($_POST['end_hour'], $_POST['end_minute'],$_POST['end_date']); + $ev_title = $e107->tp->toDB($_POST['ne_title']); + $ev_location = $e107->tp->toDB($_POST['ne_location']); + $ev_event = $e107->tp->toDB($_POST['ne_event']); + $ev_email = $e107->tp -> toDB($_POST['ne_email']); + $ev_thread = $e107->tp->toDB($_POST['ne_thread']); + $temp_date = getdate($ecal_class->make_date(0,0,$_POST['start_date'])); + $ev_allday = intval($_POST['allday']); + $recurring = intval($_POST['ec_recur_type']); + if ($recurring >= 100) $recurring += intval($_POST['ec_recur_week']) - 100; + // + if ($_POST['recurring'] == 1) + { + $rec_m = $temp_date['mday']; // Day of month + $rec_y = $temp_date['mon']; // Month number + } + else + { + $rec_m = ''; + $rec_y = ''; + } + + $report_msg = '.m3'; + if (isset($_POST['ne_insert'])) + { // Bits specific to inserting a new event + $qs = preg_replace("/ne./i", "", $_POST['qs']); + if ($_POST['ec_gen_multiple']) + { + $mult_count = $ecal_class->gen_recur($ev_start,$ev_end,$recurring,$ev_start,$ev_end); + } + if ($mult_count <= 1) + { + $qry = " 0, '".intval($ev_start)."', '".intval($ev_end)."', '".$ev_allday."', '".$recurring."', '".time()."', '$ev_title', '$ev_location', '$ev_event', '".USERID.".".USERNAME."', '".$ev_email."', '".$ev_category."', '".$ev_thread."', '".intval($rec_m)."', '".intval($rec_y)."' "; + $sql->db_Insert('event', $qry); + + $id = mysql_insert_id(); + $data = array('method'=>'create', 'table'=>'event', 'id'=>$id, 'plugin'=>'calendar_menu', 'function'=>'dbCalendarCreate'); + $e_event->triggerHook($data); + + $ecal_class->cal_log(1,'db_Insert',$qry, $ev_start); + $report_msg = '.m4'; + } + } + + if (isset($_POST['ne_update'])) + { // Bits specific to updating an existing event + $qry = "event_start='".intval($ev_start)."', event_end='".intval($ev_end)."', event_allday='".$ev_allday."', event_recurring='".$recurring."', event_datestamp= '".time()."', event_title= '$ev_title', event_location='$ev_location', event_details='$ev_event', event_contact='".$ev_email."', event_category='".$ev_category."', event_thread='".$ev_thread."', event_rec_m='".intval($rec_m)."', event_rec_y='".intval($rec_y)."' WHERE event_id='".intval($_POST['id'])."' "; + $sql->db_Update("event", $qry); + + $data = array('method'=>'update', 'table'=>'event', 'id'=>intval($_POST['id']), 'plugin'=>'calendar_menu', 'function'=>'dbCalendarUpdate'); + $e_event->triggerHook($data); + + $ecal_class->cal_log(2,'db_Update',$qry, $ev_start); + $qs = preg_replace("/ed./i", "", $_POST['qs']); + $report_msg = '.m5'; + } + if ($mult_count <= 1) + { + // Now clear cache - just do the lot for now - get clever later + $e107cache->clear('nq_event_cal'); + header('location:event.php?'.$ev_start.'.'.$qs.$report_msg); + } + } +} + + + +$action = ''; + +require_once(HEADERF); + +if ($mult_count > 1) +{ // Need to handle writing of multiple events - display confirmation form + $message = str_replace('-NUM-', count($mult_count), EC_LAN_88); + $text = " +
+ + "; + if ($ev_allday) + { + $text .= " + + "; + } + else + { + $text .= " + + "; + } + $text .= " + + + + + "; + + // Only display for forum thread/link if required. No point if not wanted + if (isset($ecal_class->pref['eventpost_forum']) && $ecal_class->pref['eventpost_forum'] == 1) + { + $text .= ""; + } + $text .= " +
".$message."
".EC_LAN_89."
".EC_LAN_173." ".$ecal_class->event_date_string($ev_start)." ".EC_LAN_175."
".EC_LAN_174." ".$ecal_class->event_date_string($ev_end)." ".EC_LAN_175."
".EC_LAN_173." ".$ecal_class->event_date_string($ev_start)." ".$ecal_class->time_string($ev_start)." "."
".EC_LAN_174." ".$ecal_class->event_date_string($ev_end)." ".$ecal_class->time_string($ev_end)." "."
".EC_LAN_176."".$ecal_class->get_recur_text($recurring)."
".EC_LAN_70."".$ev_title."
".EC_LAN_52."".$ecal_class->get_category_text($ev_category)."
".EC_LAN_32."".$ev_location."
".EC_LAN_57."".$ev_event."
".EC_LAN_58." ".$ev_thread."
".EC_LAN_59."".$ev_email."
+ + + "; + foreach ($ev_fields as $k => $v) + { + $text .= ""; + } + $text .= "
"; + + $ns->tablerender(EC_LAN_179, $text); + require_once(FOOTERF); + exit; +} + + +// Calculate any action, plus start date/number of events, from query +unset($dateArray); +$ds = ''; // Gets set if viewing a single day +if (isset($_POST['jump'])) +{ + $dateArray = getdate(mktime(0, 0, 0, $_POST['jumpmonth'], 1, $_POST['jumpyear'])); +} +else +{ + if (e_QUERY) + { + $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 == '') + { + $dateArray = $ecal_class->cal_date; // Use todays date + } + else + { + 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($ecal_class->pref['eventpost_admin'])) +{ // Bits relating to 'delete event', and generation of multiple events + if ($action == 'mc') + { + if (isset($_POST['mc_cancel'])) + { + $message = EC_LAN_179; + } + elseif (isset($_POST['mc_accept'])) + { // Go for it! Write lots of events + // Start by reading all the info from the hidden fields + $wr_record = array(); + foreach ($ev_fields as $k => $v) + { + $wr_record[$k] = $e107->tp->toDB($_POST['ev_'.$k]); + } + $wr_record['event_author'] = USERID.".".USERNAME; + $wr_record['event_datestamp'] = time(); + $mult_count = $ecal_class->gen_recur($wr_record['event_start'],$wr_record['event_end'],$wr_record['event_recurring'],$wr_record['event_start'],$wr_record['event_end']); + $wr_record['event_recurring'] = 0; // Individual events are non-recurring! + + // Now write all the entries + $wc = 0; + foreach ($mult_count as $mc) + { + $wr_record['event_start'] = $mc; + $wr_record['event_end'] = merge_date_time($mc,$wr_record['event_end']); +// echo "Write record: ".$wr_record['event_start']." to ".$wr_record['event_end']."
"; + if ($sql->db_Insert("event", $wr_record)) $wc++; + } + $ecal_class->cal_log(5,'db_Insert',$qry, $ev_start); + + $message = str_replace('-NUM-',$wc,EC_LAN_41); + if ($wc != count($mult_count)) $message .= "

".(count($mult_count)-$wc)." ".EC_LAN_180; + } + $action = ''; + } + + + if (isset($_POST['confirm'])) + { + $qry = "event_id='".intval($_POST['existing'])."' "; + if ($sql->db_Delete("event", $qry)) + { + $message = EC_LAN_51; //Event Deleted + + $data = array('method'=>'delete', 'table'=>'event', 'id'=>$_POST['existing'], 'plugin'=>'calendar_menu', 'function'=>'dbEventDelete'); + $message .= $e_event->triggerHook($data); + + $ecal_class->cal_log(3,'db_Delete',$qry,$ev_start); + } + else + { + $message = EC_LAN_109; //Unable to Delete event for some mysterious reason + } + } + + + if ($action == "de") + { // Delete event - show confirmation form + $text = "
+ ".EC_LAN_48." +

+
+ + + + +
+
"; + $ns->tablerender(EC_LAN_46, $text); // Confirm Delete Event + require_once(FOOTERF); + exit; + } + + + + if (isset($_POST['cancel'])) + { // Delete Cancelled + $message = EC_LAN_47; + } +} // End - if ($cal_super) + + + +// Messages acknowledging actions +$poss_message = array('m1' => EC_LAN_41, 'm2' => EC_LAN_42, 'm3' => EC_LAN_43, 'm4' => EC_LAN_44, 'm5' => EC_LAN_45, + 'm6' => EC_LAN_145, 'm7' => 'Could have saved -NUM- events', 'm8' => EC_LAN_181); +if (isset($qs[2])) if (isset($poss_message[$qs[2]])) +{ + $message = $poss_message[$qs[2]]; + $ec = varset($qs[3],0); + if ($ec) $message = str_replace('-NUM-',$ec,$message); +} + + +if (isset($message)) +{ + $ns->tablerender("", "
".$message."
"); +} + + +function merge_date_time($date, $time) +{ + return ((86400*intval($date/86400)) + ($time % 86400)); +} + +//------------------------------------- +// enter new event form +//------------------------------------- +if ($action == 'ne' || $action == 'ed') +{ + if ($ecal_class->cal_super || check_class($ecal_class->pref['eventpost_admin'])) + { + function make_calendar($boxname, $boxvalue) + { + global $ecal_class; + $frm = e107::getForm(); + + $opt = array( + 'type' => 'date', + 'dateformat' => $ecal_class->dcal_format_string, + 'firstDay' => $ecal_class->ec_first_day_of_week, // 0 = Sunday. @TODO: Can't change firstday ATM! + 'size' => 12 + ); + return $frm->datepicker($boxname,$boxvalue,$opt); + } + + + function make_hourmin($boxname,$cur_hour,$cur_minute) + { + global $ecal_class; // @TODO: + if (isset($ecal_class->pref['eventpost_fivemins'])) $incval = 5; else $incval = 1; + // @TODO: Need to restrict width of select box + $retval = " \n + \n"; + return $retval; + } + + function recur_select($curval) + { + global $ecal_class; // @TODO: + while ($curval > 150) { $curval -= 100; } // Could have values up to about 406 + $ret = "\n"; + return $ret; + } + + + function recur_week_select($curval) + { + global $ecal_class; // @TODO: + $disp = $curval < 100 ? " style='display:none;'" : ""; + $curval -= intval($curval % 10); // Should make it an exact multiple of 100 + $ret = "\n"; + return $ret; + } + + + switch ($action) + { + 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']; + $ne_minute = $smarray['minutes']; + $ne_startdate = $ecal_class->full_date($ne_start); + + $smarray = $ecal_class->gmgetdate($ne_end); + $end_hour = $smarray['hours']; + $end_minute = $smarray['minutes']; + $ne_enddate = $ecal_class->full_date($ne_end); + + $caption = EC_LAN_66; // edit Event + break; + + case 'ne' : // New event - initialise everything + $smarray = $ecal_class->gmgetdate($qs[1]); + $month = $smarray['mon']; + $year = $smarray['year']; + $ne_startdate = $ecal_class->full_date($qs[1]); + + $ne_hour = $smarray['hours']; + $ne_minute = $smarray['minutes']; + + $end_hour = $smarray['hours']; + $end_minute = $smarray['minutes']; + $ne_enddate = $ecal_class->full_date($qs[1]); + $recurring = 0; + $caption = EC_LAN_28; // Enter New Event + + default : + $caption = EC_LAN_83; + } + + + $text = " + "; + + $text .= " +
+ "; + + $text .= " + + + + + + + "; + + switch ($ecal_class->pref['eventpost_editmode']) + { + case 1 : + $insertjs = "rows='15' onselect='storeCaret(this);' onclick='storeCaret(this);' onkeyup='storeCaret(this);'"; + break; + case 2 : + $insertjs = "rows='25' "; + break; + default : $insertjs = "rows='15' "; + } + + $text .= " + + + "; + + // Only display for forum thread/link if required. No point if not wanted + if (isset($ecal_class->pref['eventpost_forum']) && $ecal_class->pref['eventpost_forum'] == 1) + { + $text .= " + "; + } + + // If the user is logged in and has their email set plus the field is empty then put in + // their email address. They can always take it out if they want, its not a required field + if (empty($ne_email) && ($action == "ne") && defined('USEREMAIL')) + { + $ne_email = USEREMAIL; + } + $text .= " + "; + + //triggerHook + $hid = ($action=='ed' ? intval($qs[1]) : ''); + $data = array('method'=>'form', 'table'=>'event', 'id'=>$hid, 'plugin'=>'calendar_menu', 'function'=>'CalendarCreate'); + $text .= $frm->renderHooks($data); + + + $text .= " + + + + + + + +
".EC_LAN_72." ".EC_LAN_67." "; + + $text .= make_calendar("start_date",$ne_startdate)."   ".EC_LAN_73." ".make_calendar("end_date",$ne_enddate); + $text .= "
".EC_LAN_71." ".EC_LAN_67; + + $text .= make_hourmin("ne_",$ne_hour,$ne_minute)."  ".EC_LAN_73.make_hourmin('end_',$end_hour,$end_minute); + $text .= "
"; + $text .= EC_LAN_64." +
".EC_LAN_65.""; + $text .= recur_week_select($recurring)."  ".recur_select($recurring); + $disp = $recurring && ($action == 'ne') ? '' : " style='display:none;'"; + $text .= "".EC_LAN_86.""; + $text .= "
".EC_LAN_63." +
".EC_LAN_70." * + +
".EC_LAN_52." + +
".EC_LAN_32." + +
".EC_LAN_57." * + "; + if ($ecal_class->pref['eventpost_editmode'] == 1) + { + // Show help + require_once(e_HANDLER."ren_help.php"); + $text .= "
".display_help("helpb", 'event'); + } + + $text .= "
".EC_LAN_58." + +
".EC_LAN_59." + +
".EC_LAN_105."
"; + if ($action == "ed") + { + $text .= " + "; + } + else + { + $text .= ""; + } + $text .= "
+
"; + + $ns->tablerender($caption, $text); + require_once(FOOTERF); + exit; + } + else + { + header('location:'.e_PLUGIN.'calendar_menu/event.php'); + exit; + } +} // End of "Enter New Event" + + +//----------------------------------------------- +// show events +// $month, $year have the month required +//----------------------------------------------- +if (is_readable(THEME.'calendar_template.php')) +{ // Has to be require + require(THEME.'calendar_template.php'); +} +else +{ + require(e_PLUGIN.'calendar_menu/calendar_template.php'); +} + +$calSc->ecalClass = &$ecal_class; // Give shortcodes a pointer to calendar class +$calSc->setCalDate($dateArray); // Tell shortcodes the date to display +$calSc->catFilter = $cat_filter; // Category filter +$calSc->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 .= $e107->tp->parseTemplate($CALENDAR_TIME_TABLE, FALSE, $calSc); + +// navigation buttons +$text2 .= $e107->tp->parseTemplate($CALENDAR_NAVIGATION_TABLE, FALSE, $calSc); + + +// ****** CAUTION - the category dropdown also used $sql object - take care to avoid interference! + +$ev_list = array(); + + +if ($ds == 'event') +{ // Show single event - bit of a special case + $ec_err = FALSE; + $qry = " + SELECT e.*, ec.event_cat_name,ec.event_cat_icon + FROM #event as e + LEFT JOIN #event_cat as ec ON e.event_category = ec.event_cat_id + WHERE e.event_id='".intval($eveid)."' + {$ecal_class->extra_query} + "; + $sql2->db_Select_gen($qry); + $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 + { + $temp_arr = $ecal_class->gen_recur($thisEvent['event_start'],$thisEvent['event_end'],$thisEvent['event_recurring'],$action,$action+86400); // Array of start times - hopefully just one! + if (count($temp_arr) == 1) + { + $thisEvent['event_start'] = $temp_arr[0]; + $thisEvent['event_end'] = merge_date_time($action,$thisEvent['event_end']); + } + else + { // Error + $ec_err = TRUE; + } + } + $next10_start = $thisEvent['event_start'] +1; + $calSc->event = $thisEvent; // Give shortcodes the event data + $text2 .= $e107->tp->parseTemplate($EVENT_EVENT_TABLE_START, FALSE, $calSc); + if ($ec_err) $text2.= "Software Error
"; else $text2 .= $e107->tp->parseTemplate($EVENT_EVENT_TABLE, FALSE, $calSc); + $text2 .= $e107->tp->parseTemplate($EVENT_EVENT_TABLE_END, FALSE, $calSc); +} +else +{ + if ($ds == 'one') + { // Show events from one day +// $tmp = getdate($action); +// $selected_day = $tmp['mday']; +// $selected_mon = $tmp['mon']; + $start_time = intval($action); + $end_time = $action + 86399; + $next10_start = $end_time + 1; + } + else + { // Display whole of selected month + $start_time = $monthstart; + $end_time = $monthend; + $next10_start = $end_time + 1; + } + + // echo "Start: ".$start_time." End: ".$end_time." Cat_filter: ".$cat_filter."
"; + // We'll need virtually all of the event-related fields, so get them regardless + $ev_list = $ecal_class->get_events($start_time, $end_time, FALSE, $cat_filter, TRUE, '*', 'event_cat_name,event_cat_icon'); + + + // Now go through and multiply up any recurring records + $tim_arr = array(); + foreach ($ev_list as $k=>$event) + { + if (is_array($event['event_start'])) + { + foreach ($event['event_start'] as $t) + { + $tim_arr[$t] = $k; + } + } + else + { + $tim_arr[$event['event_start']] = $k; + } + } + + // Add a sort in here - time/date order + ksort($tim_arr); + + // display event list for current month + if(count($tim_arr)) + { + $text2 .= $e107->tp->parseTemplate($EVENT_EVENTLIST_TABLE_START, FALSE, $calSc); + foreach ($tim_arr as $tim => $ptr) + { + $ev_list[$ptr]['event_start'] = $tim; + $calSc->event = $ev_list[$ptr]; // Give shortcodes the event data + $text2 .= $e107->tp->parseTemplate($EVENT_EVENT_TABLE, FALSE, $calSc); + } + $text2 .= $e107->tp->parseTemplate($EVENT_EVENTLIST_TABLE_END, FALSE, $calSc); + } +} + + +// Now display next 10 events +//echo "Next 10 start: ".$next10_start."
"; +$ev_list = $ecal_class->get_n_events(10, $next10_start, $next10_start+86400000, $cat_filter, TRUE, + 'event_id,event_start, event_title', 'event_cat_name, event_cat_icon'); + + +$num = count($ev_list); +if ($num != 0) +{ + $calSc->numEvents = $num; // Give shortcodes the number of events to expect + $archive_events = ''; + foreach ($ev_list as $thisEvent) + { + $calSc->event = $thisEvent; // Give shortcodes the event data + $archive_events .= $e107->tp->parseTemplate($EVENT_ARCHIVE_TABLE, FALSE, $calSc); + } +} +else +{ + $archive_events = $e107->tp->parseTemplate($EVENT_ARCHIVE_TABLE_EMPTY, FALSE, $calSc); +} + +$text2 .= $e107->tp->parseTemplate($EVENT_ARCHIVE_TABLE_START, FALSE, $calSc); +$text2 .= $archive_events; +$text2 .= $e107->tp->parseTemplate($EVENT_ARCHIVE_TABLE_END, FALSE, $calSc); + + +$e107->ns->tablerender($e107->tp->ParseTemplate('{EC_EVENT_PAGE_TITLE}', FALSE, $calSc), $text2); + +// Claim back memory no longer required +unset($ev_list); +unset($text2); +unset($tim_arr); + +require_once(FOOTERF); + + +/* +function headerjs() +{ + global $cal; + $script = $cal->load_files(); + return $script; +} +*/ + +?> diff --git a/e107_plugins/calendar_menu/languages/English.php b/e107_plugins/calendar_menu/languages/English.php index 2fc741d7a..f846d1f23 100644 --- a/e107_plugins/calendar_menu/languages/English.php +++ b/e107_plugins/calendar_menu/languages/English.php @@ -1,302 +1,304 @@ - \ No newline at end of file diff --git a/e107_plugins/calendar_menu/languages/English_admin_calendar_menu.php b/e107_plugins/calendar_menu/languages/English_admin_calendar_menu.php index 8646259d8..8759d2f12 100644 --- a/e107_plugins/calendar_menu/languages/English_admin_calendar_menu.php +++ b/e107_plugins/calendar_menu/languages/English_admin_calendar_menu.php @@ -1,395 +1,228 @@ - \ No newline at end of file diff --git a/e107_plugins/calendar_menu/languages/English_install.php b/e107_plugins/calendar_menu/languages/English_install.php index 15735373f..2593426b1 100644 --- a/e107_plugins/calendar_menu/languages/English_install.php +++ b/e107_plugins/calendar_menu/languages/English_install.php @@ -1,27 +1,41 @@ - + diff --git a/e107_plugins/calendar_menu/languages/English_search.php b/e107_plugins/calendar_menu/languages/English_search.php index 8fbd91bad..1fb8081ca 100644 --- a/e107_plugins/calendar_menu/languages/English_search.php +++ b/e107_plugins/calendar_menu/languages/English_search.php @@ -1,5 +1,5 @@ - \ No newline at end of file diff --git a/e107_plugins/calendar_menu/next_event_menu.php b/e107_plugins/calendar_menu/next_event_menu.php index 8df505204..b5d0d7788 100644 --- a/e107_plugins/calendar_menu/next_event_menu.php +++ b/e107_plugins/calendar_menu/next_event_menu.php @@ -1,112 +1,113 @@ -isInstalled('calendar_menu')) return ''; - - -if (!isset($ecal_class) || !is_object($ecal_class)) -{ - require_once(e_PLUGIN.'calendar_menu/ecal_class.php'); - $ecal_class = new ecal_class; -} - -// 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; -} - - -include_lan(e_PLUGIN.'calendar_menu/languages/'.e_LANGUAGE.'.php'); - -require_once(e_PLUGIN.'calendar_menu/calendar_shortcodes.php'); -$calSc = new event_calendar_shortcodes(); - -if (is_readable(THEME.'calendar_template.php')) -{ // Has to be require - require(THEME.'calendar_template.php'); -} -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_text = ''; - -$calSc->ecalClass = &$ecal_class; // Give shortcodes a pointer to calendar class - -$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'); - -$cal_totev = count($ev_list); -if ($cal_totev > 0) -{ - foreach ($ev_list as $thisEvent) - { - $cal_totev --; // Can use this to modify inter-event gap - $calSc->numEvents = $cal_totev; // Number of events to display - $calSc->event = $thisEvent; // Give shortcodes the event data - $cal_text .= $e107->tp->parseTemplate($EVENT_CAL_FE_LINE,FALSE, $calSc); - } -} -else -{ - if ($pref['eventpost_fe_hideifnone']) return ''; - $cal_text.= EC_LAN_141; -} - -$calendar_title = $e107->tp->toHTML($menu_title,FALSE,'TITLE'); // Allows multi-language title, shortcodes -if ($link_in_heading == 1) -{ - $calendar_title = "".$calendar_title.""; -} - -// Now handle the data, cache as well -ob_start(); // Set up a new output buffer -$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 - -unset($ev_list); - +isInstalled('calendar_menu')) return ''; + + +if (!isset($ecal_class) || !is_object($ecal_class)) +{ + require_once(e_PLUGIN.'calendar_menu/ecal_class.php'); + $ecal_class = new ecal_class; +} + +// 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; +} + + +include_lan(e_PLUGIN.'calendar_menu/languages/'.e_LANGUAGE.'.php'); + +require_once(e_PLUGIN.'calendar_menu/calendar_shortcodes.php'); +$calSc = new event_calendar_shortcodes(); + +if (is_readable(THEME.'calendar_template.php')) +{ // Has to be require + require(THEME.'calendar_template.php'); +} +else +{ + require(e_PLUGIN.'calendar_menu/calendar_template.php'); +} + + +// Values defined through admin pages +$menu_title = varset($this->ecal_class->pref['eventpost_menuheading'],EC_LAN_140); +$days_ahead = varset($this->ecal_class->pref['eventpost_daysforward'],30); // Number of days ahead to go +$show_count = varset($this->ecal_class->pref['eventpost_numevents'],3); // Number of events to show +$show_recurring = varset($this->ecal_class->pref['eventpost_checkrecur'],1); // Zero to exclude recurring events +$link_in_heading = varset($this->ecal_class->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_text = ''; + +$calSc->ecalClass = &$ecal_class; // Give shortcodes a pointer to calendar class + +$ev_list = $ecal_class->get_n_events($show_count, $start_time, $end_time, varset($this->ecal_class->pref['eventpost_fe_set'],FALSE), $show_recurring, + 'event_id,event_start, event_thread, event_title, event_recurring, event_allday, event_category', 'event_cat_icon'); + +$cal_totev = count($ev_list); +if ($cal_totev > 0) +{ + foreach ($ev_list as $thisEvent) + { + $cal_totev --; // Can use this to modify inter-event gap + $calSc->numEvents = $cal_totev; // Number of events to display + $calSc->event = $thisEvent; // Give shortcodes the event data + $cal_text .= $e107->tp->parseTemplate($EVENT_CAL_FE_LINE,FALSE, $calSc); + } +} +else +{ + if ($this->ecal_class->pref['eventpost_fe_hideifnone']) return ''; + $cal_text.= EC_LAN_141; +} + +$calendar_title = $e107->tp->toHTML($menu_title,FALSE,'TITLE'); // Allows multi-language title, shortcodes +if ($link_in_heading == 1) +{ + $calendar_title = "".$calendar_title.""; +} + +// Now handle the data, cache as well +ob_start(); // Set up a new output buffer +$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 + +unset($ev_list); + ?> \ No newline at end of file diff --git a/e107_plugins/calendar_menu/plugin.xml b/e107_plugins/calendar_menu/plugin.xml index bc72af44c..49725fb1c 100644 --- a/e107_plugins/calendar_menu/plugin.xml +++ b/e107_plugins/calendar_menu/plugin.xml @@ -22,7 +22,7 @@ 0 1 1 - 0 + LV sun 1 1 diff --git a/e107_plugins/calendar_menu/search/search_parser.php b/e107_plugins/calendar_menu/search/search_parser.php index 992c5f0ec..3faf68054 100644 --- a/e107_plugins/calendar_menu/search/search_parser.php +++ b/e107_plugins/calendar_menu/search/search_parser.php @@ -1,39 +1,51 @@ - DESC); - -$ps = $sch -> parsesearch('event', $return_fields, $search_fields, $weights, 'search_events', $no_results, $where, $order); -$text .= $ps['text']; -$results = $ps['results']; - -function search_events($row) { - global $con; - $res['link'] = e_PLUGIN."calendar_menu/event.php?".time().".event.".$row['event_id']; - $res['title'] = $row['event_title']; - $res['summary'] = $row['event_details']; - $res['detail'] = $row['event_location']." | ".$con -> convert_date($row['event_start'], "long"); - return $res; -} - + DESC); + +$ps = $sch -> parsesearch('event', $return_fields, $search_fields, $weights, 'search_events', $no_results, $where, $order); +$text .= $ps['text']; +$results = $ps['results']; + +function search_events($row) +{ + global $con; + $res['link'] = e_PLUGIN."calendar_menu/event.php?".time().".event.".$row['event_id']; + $res['title'] = $row['event_title']; + $res['summary'] = $row['event_details']; + $res['detail'] = $row['event_location']." | ".$con -> convert_date($row['event_start'], "long"); + return $res; +} + ?> \ No newline at end of file diff --git a/e107_plugins/calendar_menu/subscribe.php b/e107_plugins/calendar_menu/subscribe.php index 1d70b7b46..3078fa401 100644 --- a/e107_plugins/calendar_menu/subscribe.php +++ b/e107_plugins/calendar_menu/subscribe.php @@ -1,117 +1,123 @@ -isInstalled('calendar_menu')) -{ - header('Location: '.e_BASE.'index.php'); - exit(); -} - -include_lan(e_PLUGIN .'calendar_menu/languages/'.e_LANGUAGE.'.php'); -global $pref; -define('PAGE_NAME', EC_LAN_80); -require_once(HEADERF); - - -if ((USER) && (isset($pref['eventpost_asubs']) && ($pref['eventpost_asubs'] == '1'))) -{ - $cal_db = new db; // Probably best to keep this - - if (isset($_POST['upsubs'])) - { - $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); - } - // print $cal_row . $cal_subs[$cal_row] . "
"; - } - $caltext = " - - -
" . EC_LAN_130 . "
" . EC_LAN_131 . "
 
"; - } - else - { - $caltext = "
- - - "; - // Get list of currently subscribed - $cal_db->db_Select('event_subs', 'event_cat', "where event_userid='" . USERID . "'", "nowhere"); - while ($cal_s = $cal_db->db_Fetch()) - { - extract($cal_s); - $cal_array[] = $event_cat; - } // while - - // Get list of categories that have subscriptions and are visible to this member - $cal_args = "select * from #event_cat - where event_cat_subs>0 and (find_in_set(event_cat_class,'".USERCLASS_LIST."') OR find_in_set(event_cat_force_class,'".USERCLASS_LIST."'))"; - if ($cal_db->db_Select_gen($cal_args)) - { - // echo $cal_args."
"; - while ($cal_row = $cal_db->db_Fetch()) - { - extract($cal_row); - $caltext .= ""; - } - $caltext .= ""; - } - } - else - { - $caltext .= ""; - } - $caltext .= ""; - $caltext .= "
" . EC_LAN_125 . "
" . EC_LAN_126 . "" . EC_LAN_127 . "" . EC_LAN_136 . "
"; - if (check_class($event_cat_force_class)) - { - $caltext .= EC_LAN_126; - } - else - { - $caltext .= " - {$event_cat_name}{$event_cat_description}
" . EC_LAN_128 . "
"; - } -} -else -{ - if (isset($pref['eventpost_asubs']) && ($pref['eventpost_asubs'] == '1')) - $caltext = EC_LAN_142; // Register or log in - else - $caltext = EC_LAN_143; // No facility -} -$e107->ns->tablerender(EC_LAN_124, $caltext); -require_once(FOOTERF); - +isInstalled('calendar_menu')) +{ + header('Location: '.e_BASE.'index.php'); + exit(); +} + +require_once(e_PLUGIN.'calendar_menu/ecal_class.php'); + +if (!is_object($ecal_class)) $ecal_class = new ecal_class; + +include_lan(e_PLUGIN .'calendar_menu/languages/'.e_LANGUAGE.'.php'); +define('PAGE_NAME', EC_LAN_80); +require_once(HEADERF); + + +if ((USER) && (isset($ecal_class->pref['eventpost_asubs']) && ($ecal_class->pref['eventpost_asubs'] == '1'))) +{ + $cal_db = new db; // Probably best to keep this + + if (isset($_POST['upsubs'])) + { + $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); + } + // print $cal_row . $cal_subs[$cal_row] . "
"; + } + $caltext = " + + +
" . EC_LAN_130 . "
" . EC_LAN_131 . "
 
"; + } + else + { + $caltext = "
+ + + "; + + // Get list of currently subscribed + $cal_db->db_Select('event_subs', 'event_cat', "where event_userid='" . USERID . "'", "nowhere"); + while ($cal_s = $cal_db->db_Fetch()) + { + extract($cal_s); + $cal_array[] = $event_cat; + } // while + + // Get list of categories that have subscriptions and are visible to this member + $cal_args = "select * from #event_cat + where event_cat_subs>0 and (find_in_set(event_cat_class,'".USERCLASS_LIST."') OR find_in_set(event_cat_force_class,'".USERCLASS_LIST."'))"; + if ($cal_db->db_Select_gen($cal_args)) + { + // echo $cal_args."
"; + while ($cal_row = $cal_db->db_Fetch()) + { + extract($cal_row); + $caltext .= ""; + } + $caltext .= ""; + } + } + else + { + $caltext .= ""; + } + $caltext .= ""; + $caltext .= "
" . EC_LAN_125 . "
" . EC_LAN_126 . "" . EC_LAN_127 . "" . EC_LAN_136 . "
"; + if (check_class($event_cat_force_class)) + { + $caltext .= EC_LAN_126; + } + else + { + $caltext .= " + {$event_cat_name}{$event_cat_description}
" . EC_LAN_128 . "
"; + } +} +else +{ + if (isset($ecal_class->pref['eventpost_asubs']) && ($ecal_class->pref['eventpost_asubs'] == '1')) + $caltext = EC_LAN_142; // Register or log in + else + $caltext = EC_LAN_143; // No facility +} +$e107->ns->tablerender(EC_LAN_124, $caltext); +require_once(FOOTERF); + ?> \ No newline at end of file