Code:
<?php
/************************************************************************/
/* NuCalendar */
/* =========================== */
/* */
/* Copyright (c) 2003 by Bill Smith */
/* http://www.vettesofthetropics.com */
/* */
/* Based on Web Calendar */
/* Copyright (c) 2001 by Proverbs, LLC */
/* http://www.proverbs.biz */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/************************************************************************/
/*
* ©2001 Proverbs, LLC. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it withthe following stipulations:
* Changes or modifications must retain all Copyright statements, including, but not limited to the Copyright statement
* and Proverbs, LLC homepage link provided at the bottom of this page.
*/
if (!defined('ADMIN_FILE')) {
die ("Access Denied");
}
global $prefix, $db, $admin_file;
$aid = substr("$aid", 0,25);
$row = $db->sql_fetchrow($db->sql_query("SELECT radminsuper FROM " . $prefix . "_authors WHERE aid='$aid'"));
if ($row['radminsuper'] == 1) {
require_once("modules/NuCalendar/dbaccess.inc.php");
require_once("modules/NuCalendar/datefuncs.php");
require_once("modules/NuCalendar/printevent.php");
get_lang("NuCalendar");
/*********************************************************/
/* Links Modified Web Links */
/*********************************************************/
function NuCalendar_Header()
{
include("header.php");
GraphicAdmin();
OpenTable();
echo "<center><font class=\"title\">"._ADMIN_TITLE."</font><br><br><a href=$admin_file?op=NuCalendar_Edit_Options>"._ADMIN_EDIT_OPTIONS."</a><br><a href=$admin_file?op=NuCalendar_Show_Categories>"._ADMIN_EDIT_CATEGORIES."</a><br><a href=$admin_file?op=NuCalendar>"._ADMIN_EDIT_EVENTS."</a></center>";
global $user_prefix, $dbi;
$result = $db->sql_query("SELECT * FROM ".$user_prefix."_nucal_bydate WHERE 1", $dbi);
$v010exists = 0;
if ($result) {
$v010exists = 1;
}
$result = $db->sql_query("SELECT * FROM ".$user_prefix."_nucal_recurring WHERE 1", $dbi);
if ($result) {
$v010exists = 1;
}
if ($v010exists) {
echo "<br><br><center><a href=$admin_file?op=NuCalendar_Import_From_v010>"._ADMIN_IMPORT_FROM_V010."</a></center>";
}
CloseTable();
}
function NuCalendar_Footer()
{
include("footer.php");
}
function NuCalendar_EditOptions()
{
NuCalendar_Header();
OpenTable();
global $dbi, $user_prefix;
$result = sql_query("SELECT * FROM ".$user_prefix."_nucal_options WHERE 1", $dbi);
$row = sql_fetch_array($result, $dbi);
echo "<form action=\"$admin_file?op=NuCalendar_Set_Options\" method=\"POST\">";
echo "<table width=100%><tbody><tr>";
echo "<td><font class=\"title\">"._ADMIN_OPTIONS_TITLE."</font></td><td></td><td></td></tr><tr>";
echo "<td>"._ADMIN_CAL_TITLE."</td><td></td>";
echo "<td><input type=\"text\" name=\"calendar_title\" value=\"".$row[calendar_title]."\" maxlength=128></td>";
echo "</tr><tr>";
echo "<td>"._ADMIN_CAL_IMAGE."</td><td></td>";
echo "<td><input type=\"text\" name=\"calendar_title_image\" value=\"".$row[calendar_title_image]."\" maxlength=255></td>";
echo "</tr><tr>";
echo "<td>"._ADMIN_ALLOW_USER_SUBMISSION."</td><td></td>";
echo "<td><select name=\"allow_user_submitted_events\">";
echo "<option value=\"0\"";
if ($row[allow_user_submitted_events] == 0)
echo " selected";
echo ">"._NO."</option>";
echo "<option value=\"1\"";
if ($row[allow_user_submitted_events]==1)
echo " selected";
echo ">"._YES."</option></select></td>";
echo "</tr><tr>";
echo "<td>"._ADMIN_MUST_APPROVE."</td>";
echo "<td></td>";
echo "</select></td>";
echo "<td><select name=\"user_submitted_events_need_admin_aproval\">";
echo "<option value=\"0\"";
if ($row[user_submitted_events_need_admin_aproval] == 0)
echo " selected";
echo ">"._NO."</option>";
echo "<option value=\"1\"";
if ($row[user_submitted_events_need_admin_aproval]==1)
echo " selected";
echo ">"._YES."</option></select></td>";
echo "</tr><tr>";
echo "<td>"._ADMIN_DATE_FORMAT."</td>";
echo "<td></td>";
echo "<td><select name=\"show_mdy\">";
echo "<option value=\"0\"";
if ($row[show_mdy] == 0)
echo " selected";
echo ">"._ADMIN_DATE_FORMAT_DMY."</option>";
echo "<option value=\"1\"";
if ($row[show_mdy]==1)
echo " selected";
echo ">"._ADMIN_DATE_FORMAT_MDY."</option></select></td>";
echo "</tr><tr><td></td><td></td><td></td><tr>";
echo "<td><font class=\"title\">"._ADMIN_BLOCK_OPTIONS."</font></td><td></td><td>"._ADMIN_TURN_OFF_FOR_PERFORMANCE."</td></tr><tr>";
echo "<td>"._ADMIN_SHOW_N_EVENTS."</td><td></td>";
echo "<td><input type=\"text\" name=\"show_n_events\" value=\"".$row[show_n_events]."\" maxlength=2></td>";
echo "</tr><tr>";
echo "<td>"._ADMIN_SCAN_N_DAYS."</td><td></td>";
echo "<td><input type=\"text\" name=\"in_n_days\" value=\"".$row[in_n_days]."\" maxlength=3></td>";
echo "</tr><tr>";
echo "<td>"._ADMIN_SHOW_ONE_TIME."</td>";
echo "<td></td>";
echo "<td><select name=\"show_bydate_in_block\">";
echo "<option value=\"0\"";
if ($row[show_bydate_in_block] == 0)
echo " selected";
echo ">"._NO."</option>";
echo "<option value=\"1\"";
if ($row[show_bydate_in_block]==1)
echo " selected";
echo ">"._YES."</option></select></td>";
echo "</tr><tr>";
echo "<td>"._ADMIN_SHOW_WEEKLY."</td>";
echo "<td></td>";
echo "<td><select name=\"show_weekly_in_block\">";
echo "<option value=\"0\"";
if ($row[show_weekly_in_block] == 0)
echo " selected";
echo ">"._NO."</option>";
echo "<option value=\"1\"";
if ($row[show_weekly_in_block]==1)
echo " selected";
echo ">"._YES."</option></select></td>";
echo "</tr><tr>";
echo "<td>"._ADMIN_SHOW_MONTHLY."</td>";
echo "<td></td>";
echo "<td><select name=\"show_monthly_in_block\">";
echo "<option value=\"0\"";
if ($row[show_monthly_in_block] == 0)
echo " selected";
echo ">"._NO."</option>";
echo "<option value=\"1\"";
if ($row[show_monthly_in_block]==1)
echo " selected";
echo ">"._YES."</option></select></td>";
echo "</tr><tr>";
echo "<td>"._ADMIN_SHOW_WEEKLY_RECUR."</td>";
echo "<td></td>";
echo "<td><select name=\"show_monthly_recurring_in_block\">";
echo "<option value=\"0\"";
if ($row[show_monthly_recurring_in_block] == 0)
echo " selected";
echo ">"._NO."</option>";
echo "<option value=\"1\"";
if ($row[show_monthly_recurring_in_block]==1)
echo " selected";
echo ">"._YES."</option></select></td>";
echo "</tr><tr>";
echo "<td>"._ADMIN_SHOW_YEARLY."</td>";
echo "<td></td>";
echo "<td><select name=\"show_yearly_in_block\">";
echo "<option value=\"0\"";
if ($row[show_yearly_in_block] == 0)
echo " selected";
echo ">"._NO."</option>";
echo "<option value=\"1\"";
if ($row[show_yearly_in_block]==1)
echo " selected";
echo ">"._YES."</option></select></td>";
echo "</tr><tr>";
echo "<td>"._ADMIN_SHOW_YEARLY_RECUR."</td>";
echo "<td></td>";
echo "<td><select name=\"show_yearly_recurring_in_block\">";
echo "<option value=\"0\"";
if ($row[show_yearly_recurring_in_block] == 0)
echo " selected";
echo ">"._NO."</option>";
echo "<option value=\"1\"";
if ($row[show_yearly_recurring_in_block]==1)
echo " selected";
echo ">"._YES."</option></select></td>";
echo "</tr><tr>";
echo "<td valign=\"top\">"._ADMIN_SHOW_CATS."</td>";
echo "<td></td>";
echo "<td><select name=\"showcats[]\" multiple>";
$resultcats = sql_query("SELECT * FROM ".$user_prefix."_nucal_categories WHERE 1 ORDER BY title", $dbi);
for ($x = 0; $x < sql_num_rows($resultcats, $dbi); $x++) {
$catrow = sql_fetch_array($resultcats, $dbi);
echo "<option value=\"".$catrow[id]."\" ";
if ($catrow[showinblock] == 1)
echo "selected";
echo ">".$catrow[title]."</option>";
}
echo "</select></td>";
echo "</tr><tr>";
echo "</tr><tr><td></td><td></td><td></td><tr>";
echo "<td><font class=\"title\">"._ADMIN_COLOR_TITLE."</font></td><td></td><td>"._ADMIN_COLORS_FOR_MONTH_VIEW."</td></tr><tr>";
echo "<td>"._ADMIN_COLOR_DAY."</td><td></td>";
echo "<td>#<input type=\"text\" name=\"month_day_color\" value=\"".$row[month_day_color]."\" maxlength=6></td>";
echo "</tr><tr>";
echo "<td>"._ADMIN_COLOR_TODAY."</td><td></td>";
echo "<td>#<input type=\"text\" name=\"month_today_color\" value=\"".$row[month_today_color]."\" maxlength=6></td>";
echo "<tr></tr>";
echo "<td>"._ADMIN_COLOR_MOUSE_HOVER."</td><td></td>";
echo "<td>#<input type=\"text\" name=\"month_hover_color\" value=\"".$row[month_hover_color]."\" maxlength=6></td>";
echo "</tr><tr><td></td><td></td><td></td><tr>";
echo "</tr></tbody></table>";
echo "<input type=\"submit\" value=\""._ADMIN_UPDATE_OPTIONS."\"><input type=\"reset\" value=\""._ADMIN_RESET."\"></form>";
CloseTable();
NuCalendar_Footer();
}
function NuCalendar_SetOptions($xcalendar_title, $xcalendar_title_image, $xallow_user_submitted_events, $xuser_submitted_events_need_admin_aproval, $xshow_n_events, $xin_n_days, $xmonth_day_color, $xmonth_today_color, $xmonth_hover_color, $xshow_bydate_in_block, $xshow_yearly_in_block, $xshow_yearly_recurring_in_block, $xshow_monthly_in_block, $xshow_monthly_recurring_in_block, $xshow_weekly_in_block, $showcats, $show_mdy)
{
global $dbi, $user_prefix;
$query = "UPDATE ".$user_prefix."_nucal_options SET calendar_title='$xcalendar_title', calendar_title_image='$xcalendar_title_image', allow_user_submitted_events='$xallow_user_submitted_events', user_submitted_events_need_admin_aproval='$xuser_submitted_events_need_admin_aproval', show_n_events='$xshow_n_events', in_n_days='$xin_n_days', month_day_color='$xmonth_day_color', month_today_color='$xmonth_today_color', month_hover_color='$xmonth_hover_color', show_bydate_in_block='$xshow_bydate_in_block', show_yearly_in_block='$xshow_yearly_in_block', show_yearly_recurring_in_block='$xshow_yearly_recurring_in_block', show_monthly_in_block='$xshow_monthly_in_block', show_monthly_recurring_in_block='$xshow_monthly_recurring_in_block', show_weekly_in_block='$xshow_weekly_in_block', show_mdy='$show_mdy' WHERE 1";
$resultID = sql_query($query, $dbi);
$query = "UPDATE ".$user_prefix."_nucal_categories SET showinblock=0 WHERE 1";
sql_query($query, $dbi);
for ($x = 0; $x < count($showcats); $x++) {
$query = "UPDATE ".$user_prefix."_nucal_categories SET showinblock=1 WHERE id='$showcats[$x]'";
sql_query($query, $dbi);
}
Header("Location: $admin_file?op=NuCalendar_Edit_Options");
}
function NuCalendar_Quick_Pick_Existing()
{
OpenTable();
echo "<center><font class=\"title\">"._ADMIN_EDIT_EXISTING."</font></center>";
echo "<form method=\"POST\" ACTION=\"$admin_file?op=NuCalendar_Edit\">";
echo _ADMIN_EDIT_ONE_TIME." <select name=\"eventid\">";
global $dbi, $user_prefix;
$chkdate = date("Y-m-d", mktime(0, 0, 0, $month, $day, $year));
$query = "SELECT * FROM ".$user_prefix."_nucal_events WHERE isrecurring=0 AND isapproved=1 ORDER BY onetime_date";
$resultID = sql_query($query, $dbi);
if ($resultID) {
$nr = sql_num_rows($resultID, $dbi);
$content = "";
for ($k=0;$k<$nr;$k++) {
$myrow = sql_fetch_array($resultID, $dbi);
$content = '<option value="' . $myrow[id] . '">';
$content .= $myrow[onetime_date] . " " . $myrow[title];
$content .= "</option>";
echo $content;
}
} else {
echo "<option value=-1>"._ADMIN_NO_EVENTS."</option>";
}
echo "</select>";
echo "<input type=\"submit\" value=\""._ADMIN_EDIT_EVENT."\">";
echo "</form>";
echo "<br>";
echo "<form method=\"POST\" ACTION=\"$admin_file?op=NuCalendar_Edit\">";
echo _ADMIN_EDIT_RECUR." <select name=\"eventid\">";
$query = "SELECT * FROM ".$user_prefix."_nucal_events WHERE isrecurring=1 AND isapproved=1 ORDER BY id";
$resultID = sql_query($query, $dbi);
if ($resultID) {
$nr = sql_num_rows($resultID, $dbi);
$content = "";
for ($k=0;$k<$nr;$k++) {
$myrow = sql_fetch_array($resultID, $dbi);
$content = '<option value="' . $myrow[id] . '">';
$content .= $myrow[eventdate] . " " . $myrow[title];
$content .= "</option>";
echo $content;
}
} else {
echo "<option value=-1>"._ADMIN_NO_EVENTS."</option>";
}
echo "</select>";
echo "<input type=\"submit\" value=\""._ADMIN_EDIT_EVENT."\">";
echo "</form>";
echo "</form>";
echo "<br>";
echo "<form method=\"POST\" ACTION=\"$admin_file?op=NuCalendar_Edit\">";
echo _ADMIN_EDIT_NEED_APPROVE." <select name=\"eventid\">";
$query = "SELECT * FROM ".$user_prefix."_nucal_events WHERE isapproved=0 ORDER BY id";
$resultID = sql_query($query, $dbi);
if ($resultID) {
$nr = sql_num_rows($resultID, $dbi);
$content = "";
for ($k=0;$k<$nr;$k++) {
$myrow = sql_fetch_array($resultID, $dbi);
$content = '<option value="' . $myrow[id] . '">';
$content .= $myrow[eventdate] . " " . $myrow[title];
$content .= "</option>";
echo $content;
}
if ($nr == 0) {
echo "<option value=-1>"._ADMIN_NO_EVENTS."</option>";
}
} else {
echo "<option value=-1>"._ADMIN_NO_EVENTS."</option>";
}
echo "</select>";
echo "<input type=\"submit\" value=\""._ADMIN_EDIT_EVENT."\">";
echo "</form>";
CloseTable();
}
function NuCalendar_Main()
{
NuCalendar_Header();
NuCalendar_Quick_Pick_Existing();
OpenTable();
echo "<center><font class=\"title\">"._ADMIN_ADD_EVENT."</font></center>";
$onetimeevent = 1;
$formaction = "$admin_file?op=NuCalendar_Add";
$formsubmitbutton = _ADMIN_ADD_EVENT;
ShowEventForm($formaction, "", "", $formsubmitbutton, $onetimeevent,"", "", "", "", 1);
CloseTable();
NuCalendar_Footer();
}
function NuCalendar_Edit($eventid)
{
NuCalendar_Header();
NuCalendar_Quick_Pick_Existing();
OpenTable();
echo "<center><font class=\"title\">"._ADMIN_EDIT_EVENT."</font></center>";
global $dbi, $user_prefix;
$query = "SELECT * FROM ".$user_prefix."_nucal_events WHERE id=" . $eventid;
$resultID = sql_query($query, $dbi);
if ($resultID) {
$mydatarow = sql_fetch_array($resultID, $dbi);
$onetimeevent=1;
if ($mydatarow[isrecurring] == "0") {
$ripdate = array();
$ripdate = explode("-", $mydatarow[onetime_date]);
$year = $ripdate[0];
$month = $ripdate[1];
$day = $ripdate[2];
} else {
$onetimeevent=0;
}
$formaction = "$admin_file?op=NuCalendar_Set_Values";
$formsubmitbutton = _ADMIN_EDIT_EVENT;
$formactiondelete = "$admin_file?op=NuCalendar_Delete_Confirm";
ShowEventForm($formaction, $mydatarow, $eventid, $formsubmitbutton, $onetimeevent, $month, $day, $year, $formactiondelete, 1);
} else {
echo _ADMIN_NO_EVENT_WITH_ID;
}
CloseTable();
NuCalendar_Footer();
}
function NuCalendar_Add($title, $location, $fulldesc, $start_hour, $start_min, $start_pm, $dur_hour, $dur_min, $isactive, $isrecurring, $categoryid, $isapproved, $onetime_date, $recur_weekday, $recur_schedule, $recur_period, $recur_month)
{
NuCalendar_Insert_Row($title, $location, $fulldesc, $start_hour, $start_min, $start_pm, $dur_hour, $dur_min, $isactive, $isrecurring, $categoryid, $isapproved, $onetime_date, $recur_weekday, $recur_schedule, $recur_period, $recur_month);
Header("Location: $admin_file?op=NuCalendar");
}
function NuCalendar_Set_Values($eventid, $title, $location, $fulldesc, $start_hour, $start_min, $start_pm, $dur_hour, $dur_min, $isactive, $isrecurring, $categoryid, $isapproved, $onetime_date, $recur_weekday, $recur_schedule, $recur_period, $recur_month)
{
global $dbi, $user_prefix;
$starttime = TimeToMilitaryTime($start_hour, $start_min, $start_pm);
$duration = TimeToMilitaryTime($dur_hour, $dur_min, 0);
$query = "UPDATE ".$user_prefix."_nucal_events SET title='$title', location='$location', fulldesc='$fulldesc', starttime='$starttime', duration='$duration', isactive='$isactive', isrecurring='$isrecurring', categoryid='$categoryid', isapproved='$isapproved', onetime_date='$onetime_date', recur_weekday='$recur_weekday', recur_schedule='$recur_schedule', recur_period='$recur_period', recur_month='$recur_month' WHERE id=$eventid";
$resultID = sql_query($query, $dbi);
Header("Location: $admin_file?op=NuCalendar");
}
function NuCalendar_Delete_Confirm($eventid)
{
NuCalendar_Header();
OpenTable();
echo "<form method=\"POST\" action=\"$admin_file?op=NuCalendar_Delete\">";
echo "<input type=\"hidden\" name=\"eventid\" value=\"". $eventid . "\">";
echo "<center><font class=\"title\">"._ADMIN_EVENT_DELETE_CONFIRM."</font></center><br>";
echo "<center><input type=\"submit\" value=\""._DELETE."\">";
echo "<input type=\"reset\" value=\""._CANCEL."\"></center>";
echo "</form>";
CloseTable();
NuCalendar_Footer();
}
function NuCalendar_Delete($eventid)
{
global $dbi, $user_prefix;
$query= "DELETE from ".$user_prefix."_nucal_events WHERE id='$eventid'";
$resultID = sql_query($query, $dbi);
Header("Location: $admin_file?op=NuCalendar");
}
function NuCalendar_Show_Categories()
{
NuCalendar_Header();
OpenTable();
global $dbi, $user_prefix;
$query = "SELECT * FROM ".$user_prefix."_nucal_categories WHERE 1";
echo "<center><font class=\"title\">"._ADMIN_EDIT_EXISTING_CATEGORY_TITLE."</font></center><br>";
echo "<form method=\"POST\" ACTION=\"$admin_file?op=NuCalendar_Edit_Category\">";
echo _ADMIN_CATEGORY_NAME." <select name=\"catid\">";
$resultID = sql_query($query, $dbi);
if ($resultID) {
$nr = sql_num_rows($resultID, $dbi);
$content = "";
for ($k=0;$k<$nr;$k++) {
$myrow = sql_fetch_array($resultID, $dbi);
$content = '<option value="' . $myrow[id] . '">';
$content .= $myrow[title];
$content .= "</option>";
echo $content;
}
} else {
echo "<option value=-1>"._ADMIN_NO_CATS_DEFINED."</option>";
}
echo "</select>";
echo "<input type=\"submit\" value=\""._ADMIN_EDIT_CATEGORY."\">";
echo "</form>";
CloseTable();
OpenTable();
echo "<center><font class=\"title\">"._ADMIN_ADD_CATEGORY."</font></center>";
NuCalendar_Show_Category_Form("$admin_file?op=NuCalendar_Add_Category", _ADMIN_ADD_CATEGORY_FORM, "");
CloseTable();
NuCalendar_Footer();
}
function NuCalendar_Add_Category($title, $description, $showinblock)
{
global $dbi, $user_prefix;
$query = "INSERT INTO ".$user_prefix."_nucal_categories (title, description, showinblock) VALUES ('$title', '$description', '$showinblock')";
$result = sql_query($query, $dbi);
Header("Location: $admin_file?op=NuCalendar_Show_Categories");
}
function NuCalendar_Edit_Category($catid, $title, $description, $showinblock)
{
NuCalendar_Header();
OpenTable();
global $dbi, $user_prefix;
$query = "SELECT * FROM ".$user_prefix."_nucal_categories WHERE id=".$catid;
$result = sql_query($query, $dbi);
$row = sql_fetch_array($result, $dbi);
echo "<center><font class=\"title\">"._ADMIN_EDIT_CATEGORY_TITLE."</font></center>";
$formactiondelete = "$admin_file?op=NuCalendar_Delete_Category_Confirm";
NuCalendar_Show_Category_Form("$admin_file?op=NuCalendar_Set_Category_Values", _ADMIN_EDIT_CATEGORY, $row, $formactiondelete);
CloseTable();
NuCalendar_Footer();
}
function NuCalendar_Show_Category_Form($formaction, $formsubmitbutton, $mydatarow, $formactiondelete="")
{
?>
<form action="<?php echo $formaction; ?>" method="POST">
<table width="100%" cellspacing=0 border=0 cellpadding=0>
<tr align="left">
<td width="30%"></td>
<td width="10"></td>
<td width="70%"></td>
</tr>
<tr align="left">
<td width="30%"><?php echo _ADMIN_CATEGORY_TITLE; ?></td>
<td width="10"></td>
<td width="70%"><input type="text" name="title" value="<?php echo $mydatarow[title]; ?>" size=30></td>
</tr>
<tr align="left">
<td width="30%" valign="top"><?php echo _ADMIN_CATEGORY_DESC; ?></td>
<td width="10"></td>
<td width="70%"><textarea rows="7" name="description" cols="45"><?php echo $mydatarow[description]; ?></textarea></td>
</tr>
<tr align="left">
<td width="30%" valign="top"><?php echo _ADMIN_SHOW_CAT_IN_BLOCK; ?></td>
<td width="10"></td>
<td width="70%">
<select name="showinblock">
<option value="0"
<?php
if ($mydatarow[showinblock] == 0)
echo " selected";
?>
><?php echo _NO; ?></option>
<option value="1"
<?php
if ($mydatarow[showinblock] == 1)
echo " selected";
?>
><?php echo _YES; ?></option>
</select></td>
</tr>
</table>
<input type="hidden" name="catid" value="<?php echo $mydatarow[id]; ?>">
<input type="submit" value="<?php echo $formsubmitbutton; ?>">
</form>
<?php
if ($formactiondelete != "") {
?>
<div align="right">
<form action="$admin_file?op=NuCalendar_Delete_Category_Confirm" method="POST">
<input type="hidden" name="catid" value="<?php echo $mydatarow[id]; ?>">
<input type="submit" value="<?php echo _ADMIN_DELETE_CATEGORY; ?>">
</form>
</div>
<?php
}
}
function NuCalendar_Set_Category_Values($catid, $title, $description, $showinblock)
{
global $dbi, $user_prefix;
$query = "UPDATE ".$user_prefix."_nucal_categories SET title='$title', description='$description', showinblock='$showinblock' WHERE id=$catid";
$resultID = sql_query($query, $dbi);
Header("Location: $admin_file?op=NuCalendar_Show_Categories");
}
function NuCalendar_Delete_Category_Confirm($catid)
{
NuCalendar_Header();
OpenTable();
echo "<form method=\"POST\" action=\"$admin_file?op=NuCalendar_Delete_Category\">";
echo "<input type=\"hidden\" name=\"catid\" value=\"". $catid . "\">";
echo "<center><font class=\"title\">Confirm Event Category Delete</font></center><br>";
echo "<center><input type=\"submit\" value=\""._DELETE."\">";
echo "<input type=\"reset\" value=\""._CANCEL."\"></center>";
echo "</form>";
CloseTable();
NuCalendar_Footer();
}
function NuCalendar_Delete_Category($catid)
{
global $dbi, $user_prefix;
$query= "DELETE from ".$user_prefix."_nucal_categories WHERE id='$catid'";
echo $query;
$resultID = sql_query($query, $dbi);
Header("Location: $admin_file?op=NuCalendar_Show_Categories");
}
function NuCalendar_Import_From_v010()
{
global $dbi, $user_prefix;
include("header.php");
GraphicAdmin();
OpenTable();
echo "<center><font class=\"title\">Updating DB from v0.10</font></center><br><br>";
echo "Importing from ".$user_prefix."_nucal_bydate ...";
$result = sql_query("SELECT * FROM ".$user_prefix."_nucal_bydate WHERE 1", $dbi);
$numrows = sql_num_rows($result, $dbi);
echo $numrows . " row(s) to update ... ";
$numrowsadded = 0;
for ($x = 0; $x < $numrows; $x++) {
$row = sql_fetch_array($result, $dbi);
list($start_hour, $start_min, $start_sec) = split(":", $row[eventtime]);
list($dur_hour, $dur_min, $dur_sec) = split(":", $row[eventlength]);
$addresult = NuCalendar_Insert_Row($row[shortevent], $row[location], $start_hour, $start_min, MilitaryTimeIsPM($row[eventtime]), $dur_hour, $dur_min, $row[longevent], $row[active], 0, 1, 1, $row[eventdate], 0, "weekly", 0, 0);
if ($addresult) {
$numrowsadded++;
}
}
echo $numrowsadded . " row(s) updated.<br>";
if ($numrows != $numrowsadded) {
echo "<b>WARNING: NOT ALL BYDATE ROWS COULD BE AUTOMATICALLY UPDADED. PLEASE RE-ENTER THEM BY HAND</b><br>";
}
echo "<br>Importing from ".$user_prefix."_nucal_recurring ...";
$result = sql_query("SELECT * FROM ".$user_prefix."_nucal_recurring WHERE 1", $dbi);
$numrows = sql_num_rows($result, $dbi);
echo $numrows . " row(s) to update ... ";
$numrowsadded = 0;
for ($x = 0; $x < $numrows; $x++) {
$row = sql_fetch_array($result, $dbi);
list($start_hour, $start_min, $start_sec) = split(":", $row[eventtime]);
list($dur_hour, $dur_min, $dur_sec) = split(":", $row[eventlength]);
$addresult = NuCalendar_Insert_Row($row[shortevent], $row[location], $start_hour, $start_min, MilitaryTimeIsPM($row[eventtime]), $dur_hour, $dur_min, $row[longevent], $row[active], 1, 1, 1, "0000-00-00", $row[weekday], $row[schedule], $row[period], $row[month]);
if ($addresult) {
$numrowsadded++;
}
}
echo $numrowsadded . " row(s) updated.<br>";
if ($numrows != $numrowsadded) {
echo "<b>WARNING: NOT ALL RECURRING ROWS COULD BE AUTOMATICALLY UPDADED. PLEASE RE-ENTER THEM BY HAND</b><br>";
}
echo "<br>You may now delete tables ".$user_prefix."_nucal_bydate and ".$user_prefix."_nucal_recurring after you are satsified with the update";
CloseTable();
NuCalendar_Footer();
}
switch ($op) {
case "NuCalendar":
NuCalendar_Main();
break;
case "NuCalendar_Add":
$isrecurring = 1;
if ($onetime == "onetime") {
$isrecurring = 0;
}
$onetime_date = $year."-".$month."-".$day;
NuCalendar_Add($title, $location, $fulldesc, $start_hour, $start_min, $start_pm, $dur_hour, $dur_min, $isactive, $isrecurring, $categoryid, 1, $onetime_date, $recur_weekday, $recur_schedule, $recur_period, $recur_month);
break;
case "NuCalendar_Set_Values":
$isrecurring = 1;
if ($onetime == "onetime") {
$isrecurring = 0;
}
$onetime_date = $year."-".$month."-".$day;
NuCalendar_Set_Values($eventid, $title, $location, $fulldesc, $start_hour, $start_min, $start_pm, $dur_hour, $dur_min, $isactive, $isrecurring, $categoryid, $isapproved, $onetime_date, $recur_weekday, $recur_schedule, $recur_period, $recur_month);
break;
case "NuCalendar_Edit":
NuCalendar_Edit($eventid);
break;
case "NuCalendar_Delete_Confirm":
NuCalendar_Delete_Confirm($eventid);
break;
case "NuCalendar_Delete":
NuCalendar_Delete($eventid);
break;
case "NuCalendar_Edit_Options":
NuCalendar_EditOptions();
break;
case "NuCalendar_Set_Options":
NuCalendar_SetOptions($calendar_title, $calendar_title_image, $allow_user_submitted_events, $user_submitted_events_need_admin_aproval, $show_n_events, $in_n_days, $month_day_color, $month_today_color, $month_hover_color, $show_bydate_in_block, $show_yearly_in_block, $show_yearly_recurring_in_block, $show_monthly_in_block, $show_monthly_recurring_in_block, $show_weekly_in_block, $showcats, $show_mdy);
break;
case "NuCalendar_Show_Categories":
NuCalendar_Show_Categories();
break;
case "NuCalendar_Add_Category":
NuCalendar_Add_Category($title, $description, $showinblock);
break;
case "NuCalendar_Edit_Category":
NuCalendar_Edit_Category($catid, $title, $description, $showinblock);
break;
case "NuCalendar_Set_Category_Values":
NuCalendar_Set_Category_Values($catid, $title, $description, $showinblock);
break;
case "NuCalendar_Delete_Category":
NuCalendar_Delete_Category($catid);
break;
case "NuCalendar_Delete_Category_Confirm":
NuCalendar_Delete_Category_Confirm($catid);
break;
case "NuCalendar_Import_From_v010":
NuCalendar_Import_From_v010();
break;
}
} else {
echo "Access Denied";
}
?>
|