");
$message = "";
}
//category
$ecal_sendemail = 0;
if(isset($ec_qs[0]) && $ec_qs[0] == "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 .= "
";
}
}
// 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, FALSE, $calendar_shortcodes);
$cal_title = $tp -> parseTemplate($pref['eventpost_mailsubject'], FALSE, $calendar_shortcodes);
$user_email = USEREMAIL;
$user_name = USERNAME;
// $cal_msg = str_replace("\r","\n",$cal_msg);
// echo $cal_msg."
";
}
$calendarmenu_dodel = TRUE;
$calendarmenu_edit = FALSE;
}
}
if (!$calendarmenu_dodel)
{
require_once(e_HANDLER."file_class.php");
$calendarmenu_text .= "
";
}
}
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()){
//extract($calendarmenu_row);
$calendarmenu_catopt .= "";
}
}
else
{
$calendarmenu_catopt .= "";
}
$calendarmenu_text .= "
";
}
if(isset($calendarmenu_text))
{
$ns->tablerender("
".EC_ADLAN_1." - ".EC_ADLAN_A19."
", $calendarmenu_text);
}
}
// ====================================================
// FORTHCOMING EVENTS OPTIONS
// ====================================================
if((isset($ec_qs[0]) && $ec_qs[0] == "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 = "
";
$ns->tablerender("
".EC_ADLAN_1." - ".EC_ADLAN_A100."
", $text);
} // End of Forthcoming Events Menu Options
// ====================================================
// MAINTENANCE OPTIONS
// ====================================================
if((isset($ec_qs[0]) && $ec_qs[0] == "maint"))
{
$text = "
";
$ns->tablerender("
".EC_ADLAN_1." - ".EC_ADLAN_A141."
", $text);
$text = "
";
$ns->tablerender("
".EC_ADLAN_1." - ".EC_ADLAN_A159."
", $text);
}
// ====================================================
// SUBSCRIPTIONS OPTIONS
// ====================================================
if((isset($ec_qs[0]) && $ec_qs[0] == "subs"))
{
$from = 0;
$amount = 20; // Number per page - could make configurable later if required
if (isset($ec_qs[1])) $from = $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 = "