codes****@googl*****
codes****@googl*****
2009年 4月 6日 (月) 10:26:21 JST
Author: tacahi Date: Sun Apr 5 18:12:05 2009 New Revision: 1428 Added: externals/geeklog-1.5.2sr2/public_html/calendar/ externals/geeklog-1.5.2sr2/public_html/calendar/event.php externals/geeklog-1.5.2sr2/public_html/calendar/images/ externals/geeklog-1.5.2sr2/public_html/calendar/images/calendar.png (contents, props changed) externals/geeklog-1.5.2sr2/public_html/calendar/images/delete_event.gif (contents, props changed) externals/geeklog-1.5.2sr2/public_html/calendar/images/delete_event.png (contents, props changed) externals/geeklog-1.5.2sr2/public_html/calendar/index.php externals/geeklog-1.5.2sr2/public_html/calendar/style.css Log: Geeklog 1.5.2sr1を externals/geeklog-1.5.2sr2 に取り込みます。 Added: externals/geeklog-1.5.2sr2/public_html/calendar/event.php ============================================================================== --- (empty file) +++ externals/geeklog-1.5.2sr2/public_html/calendar/event.php Sun Apr 5 18:12:05 2009 @@ -0,0 +1,726 @@ +<?php + +/* Reminder: always indent with 4 spaces (no tabs). */ +// +---------------------------------------------------------------------------+ +// | Calendar Plugin 1.0 | +// +---------------------------------------------------------------------------+ +// | event.php | +// | | +// | Shows details of an event or events | +// +---------------------------------------------------------------------------+ +// | Copyright (C) 2000-2008 by the following authors: | +// | | +// | Authors: Tony Bibbs - tony AT tonybibbs DOT com | +// | Mark Limburg - mlimburg AT users DOT sourceforge DOT net | +// | Jason Whittenburg - jwhitten AT securitygeeks DOT com | +// | Dirk Haun - dirk AT haun-online DOT de | +// +---------------------------------------------------------------------------+ +// | | +// | 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, or (at your option) any later version. | +// | | +// | This program is distributed in the hope that it will be useful, | +// | but WITHOUT ANY WARRANTY; without even the implied warranty of | +// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | +// | GNU General Public License for more details. | +// | | +// | You should have received a copy of the GNU General Public License | +// | along with this program; if not, write to the Free Software Foundation, | +// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | +// | | +// +---------------------------------------------------------------------------+ +// +// $Id: event.php,v 1.31 2008/05/24 08:28:17 dhaun Exp $ + +require_once '../lib-common.php'; + +if (!in_array('calendar', $_PLUGINS)) { + echo COM_refresh($_CONF['site_url'] . '/index.php'); + exit; +} + +require_once $_CONF['path_system'] . 'classes/calendar.class.php'; + +/** +* Adds an event to the user's calendar +* +* The user has asked that an event be added to their personal +* calendar. Show a confirmation screen. +* +* @param string $eid event ID to add to user's calendar +* @return string HTML for confirmation form +* +*/ +function adduserevent ($eid) +{ + global $_CONF, $_TABLES, $LANG_CAL_1; + + $retval = ''; + + $eventsql = "SELECT * FROM {$_TABLES['events']} WHERE eid='$eid'" . COM_getPermSql ('AND'); + $result = DB_query($eventsql); + $nrows = DB_numRows($result); + if ($nrows == 1) { + $retval .= COM_startBlock (sprintf ($LANG_CAL_1[11], + COM_getDisplayName())); + $A = DB_fetchArray($result); + $cal_template = new Template($_CONF['path'] . 'plugins/calendar/templates/'); + $cal_template->set_file(array('addevent' => 'addevent.thtml')); + $cal_template->set_var('xhtml', XHTML); + $cal_template->set_var('site_url', $_CONF['site_url']); + $cal_template->set_var('site_admin_url', $_CONF['site_admin_url']); + $cal_template->set_var('layout_url', $_CONF['layout_url']); + $cal_template->set_var('intro_msg', $LANG_CAL_1[8]); + $cal_template->set_var('lang_event', $LANG_CAL_1[12]); + $event_title = stripslashes($A['title']); + + if (!empty ($A['url']) && ($A['url'] != 'http://')) { + $cal_template->set_var ('event_url', $A['url']); + $event_title = COM_createLink($event_title, $A['url']); + } else { + $cal_template->set_var ('event_url', ''); + } + $cal_template->set_var ('event_title', $event_title); + $cal_template->set_var('lang_starts', $LANG_CAL_1[13]); + $cal_template->set_var('lang_ends', $LANG_CAL_1[14]); + + $thestart = COM_getUserDateTimeFormat($A['datestart'] . ' ' . $A['timestart']); + $theend = COM_getUserDateTimeFormat($A['dateend'] . ' ' . $A['timeend']); + if ($A['allday'] == 0) { + $cal_template->set_var('event_start', $thestart[0]); + $cal_template->set_var('event_end', $theend[0]); + } else { + $cal_template->set_var('event_start', strftime($_CONF['shortdate'], $thestart[1])); + $cal_template->set_var('event_end', strftime($_CONF['shortdate'], $theend[1])); + } + + $cal_template->set_var('lang_where',$LANG_CAL_1[4]); + $location = stripslashes($A['location']) . '<br' . XHTML . '>' + . stripslashes ($A['address1']) . '<br' . XHTML . '>' + . stripslashes ($A['address2']) . '<br' . XHTML . '>' + . stripslashes ($A['city']) + . ', ' . stripslashes($A['state']) . ' ' . $A['zipcode']; + $cal_template->set_var('event_location', $location); + $cal_template->set_var('lang_description', $LANG_CAL_1[5]); + $description = stripslashes ($A['description']); + if (empty($A['postmode']) || ($A['postmode'] == 'plaintext')) { + $description = nl2br ($description); + } + $cal_template->set_var ('event_description', + PLG_replaceTags ($description)); + $cal_template->set_var('event_id', $eid); + $cal_template->set_var('lang_addtomycalendar', $LANG_CAL_1[9]); + $cal_template->set_var('gltoken_name', CSRF_TOKEN); + $cal_template->set_var('gltoken', SEC_createToken()); + $cal_template->parse('output', 'addevent'); + $retval .= $cal_template->finish($cal_template->get_var('output')); + $retval .= COM_endBlock (); + } else { + $retval .= COM_showMessage(23); + } + + return $retval; +} + +/** +* Save an event to user's personal calendar +* +* User has seen the confirmation screen and they still wants to +* add this event to their calendar. Actually save it now. +* +* @param string $eid ID of event to save +* @return string HTML refresh +* +*/ +function saveuserevent ($eid) +{ + global $_CONF, $_TABLES, $_USER; + + if (isset ($_USER['uid']) && ($_USER['uid'] > 1)) { + + // Try to delete the event first in case it has already been added + DB_query ("DELETE FROM {$_TABLES['personal_events']} WHERE uid={$_USER['uid']} AND eid='$eid'"); + + $result = DB_query ("SELECT eid FROM {$_TABLES['events']} WHERE (eid = '$eid')" . COM_getPermSql ('AND')); + if (DB_numRows ($result) == 1) { + + $savesql = "INSERT INTO {$_TABLES['personal_events']} " + . "(eid,uid,title,event_type,datestart,dateend,timestart,timeend,allday,location,address1,address2,city,state," + . "zipcode,url,description,group_id,owner_id,perm_owner,perm_group,perm_members,perm_anon) SELECT eid," + . $_USER['uid'] . ",title,event_type,datestart,dateend,timestart,timeend,allday,location,address1,address2," + . "city,state,zipcode,url,description,group_id,owner_id,perm_owner,perm_group,perm_members,perm_anon FROM " + . "{$_TABLES['events']} WHERE eid = '{$eid}'"; + + DB_query ($savesql); + + return COM_refresh ($_CONF['site_url'] + . '/calendar/index.php?mode=personal&msg=24'); + } + } + + return COM_refresh ($_CONF['site_url'] . '/index.php'); +} + +/** +* Allows user to edit a personal calendar event +* +* @param array $A Record to display +* @return string HTML for event editor +* +*/ +function editpersonalevent ($A) +{ + global $_CONF, $_CA_CONF, $LANG_CAL_1; + + $cal_templates = new Template($_CONF['path'] . 'plugins/calendar/templates/'); + $cal_templates->set_file('form','editpersonalevent.thtml'); + $cal_templates->set_var( 'xhtml', XHTML ); + $cal_templates->set_var('site_url', $_CONF['site_url']); + $cal_templates->set_var('site_admin_url', $_CONF['site_admin_url']); + $cal_templates->set_var('layout_url', $_CONF['layout_url']); + + $cal_templates->set_var ('lang_title', $LANG_CAL_1[28]); + $title = stripslashes ($A['title']); + $title = str_replace ('{', '{', $title); + $title = str_replace ('}', '}', $title); + $title = str_replace ('"', '"', $title); + $cal_templates->set_var ('event_title', $title); + + $cal_templates->set_var('lang_eventtype', $LANG_CAL_1[37]); + $type_options = CALENDAR_eventTypeList($A['event_type']); + $cal_templates->set_var('type_options', $type_options); + + // Handle start date/time + $cal_templates->set_var('lang_startdate', $LANG_CAL_1[21]); + $cal_templates->set_var('lang_starttime', $LANG_CAL_1[30]); + $A['startdate'] = $A['datestart'] . ' ' . $A['timestart']; + + $start_month = date ('n', strtotime ($A['startdate'])); + $month_options = COM_getMonthFormOptions ($start_month); + $cal_templates->set_var ('startmonth_options', $month_options); + + $start_day = date ('j', strtotime ($A['startdate'])); + $day_options = COM_getDayFormOptions ($start_day); + $cal_templates->set_var('startday_options', $day_options); + + $start_year = date ('Y', strtotime ($A['startdate'])); + $year_options = COM_getYearFormOptions ($start_year); + $cal_templates->set_var('startyear_options', $year_options); + + if (isset ($_CA_CONF['hour_mode']) && ($_CA_CONF['hour_mode'] == 24)) { + $start_hour = date ('H', strtotime ($A['startdate'])); + $hour_options = COM_getHourFormOptions ($start_hour, 24); + $cal_templates->set_var ('starthour_options', $hour_options); + } else { + $start_hour = date ('g', strtotime ($A['startdate'])); + $hour_options = COM_getHourFormOptions ($start_hour); + $cal_templates->set_var ('starthour_options', $hour_options); + } + + $startmin = intval (date ('i', strtotime ($A['startdate'])) / 15) * 15; + $cal_templates->set_var ('startminute_options', + COM_getMinuteFormOptions ($startmin, 15)); + + $ampm = date ('a', strtotime ($A['startdate'])); + $cal_templates->set_var ('startampm_selection', + COM_getAmPmFormSelection ('startampm_selection', $ampm)); + + // Handle end date/time + $cal_templates->set_var('lang_enddate', $LANG_CAL_1[18]); + $cal_templates->set_var('lang_endtime', $LANG_CAL_1[29]); + $A['enddate'] = $A['dateend'] . ' ' . $A['timeend']; + + $end_month = date ('n', strtotime ($A['enddate'])); + $month_options = COM_getMonthFormOptions ($end_month); + $cal_templates->set_var ('endmonth_options', $month_options); + + $end_day = date ('j', strtotime ($A['enddate'])); + $day_options = COM_getDayFormOptions ($end_day); + $cal_templates->set_var ('endday_options', $day_options); + + $end_year = date ('Y', strtotime ($A['enddate'])); + $year_options = COM_getYearFormOptions ($end_year); + $cal_templates->set_var ('endyear_options', $year_options); + + if (isset ($_CA_CONF['hour_mode']) && ($_CA_CONF['hour_mode'] == 24)) { + $end_hour = date ('H', strtotime ($A['enddate'])); + $hour_options = COM_getHourFormOptions ($end_hour, 24); + $cal_templates->set_var ('endhour_options', $hour_options); + } else { + $end_hour = date ('g', strtotime ($A['enddate'])); + $hour_options = COM_getHourFormOptions ($end_hour); + $cal_templates->set_var ('endhour_options', $hour_options); + } + + $endmin = intval (date ('i', strtotime ($A['enddate'])) / 15) * 15; + $cal_templates->set_var ('endminute_options', + COM_getMinuteFormOptions ($endmin, 15)); + + $ampm = date ('a', strtotime ($A['enddate'])); + $cal_templates->set_var ('endampm_selection', + COM_getAmPmFormSelection ('endampm_selection', $ampm)); + + $cal_templates->set_var ('lang_alldayevent', $LANG_CAL_1[31]); + if ($A['allday'] == 1) { + $cal_templates->set_var ('allday_checked', 'checked="checked"'); + } else { + $cal_templates->set_var ('allday_checked', ''); + } + + $cal_templates->set_var('lang_location',$LANG_CAL_1[39]); + $cal_templates->set_var('event_location', stripslashes ($A['location'])); + + $cal_templates->set_var('lang_addressline1', $LANG_CAL_1[32]); + $cal_templates->set_var('event_address1', stripslashes ($A['address1'])); + $cal_templates->set_var('lang_addressline2', $LANG_CAL_1[33]); + $cal_templates->set_var('event_address2', stripslashes ($A['address2'])); + + $cal_templates->set_var('lang_city', $LANG_CAL_1[34]); + $cal_templates->set_var('event_city', stripslashes ($A['city'])); + + $cal_templates->set_var('lang_state', $LANG_CAL_1[35]); + $cal_templates->set_var('state_options', ''); + $cal_templates->set_var('event_state', stripslashes ($A['state'])); + + $cal_templates->set_var('lang_zipcode', $LANG_CAL_1[36]); + $cal_templates->set_var('event_zipcode', $A['zipcode']); + + $cal_templates->set_var('lang_link', $LANG_CAL_1[43]); + $cal_templates->set_var('event_url', $A['url']); + + $cal_templates->set_var('lang_description', $LANG_CAL_1[5]); + $cal_templates->set_var('event_description', + nl2br (stripslashes ($A['description']))); + + $cal_templates->set_var('lang_htmlnotallowed', $LANG_CAL_1[44]); + $cal_templates->set_var('lang_submit', $LANG_CAL_1[45]); + $cal_templates->set_var('lang_delete', $LANG_CAL_1[51]); + $cal_templates->set_var('eid', $A['eid']); + $cal_templates->set_var('uid', $A['uid']); + if (isset ($_CA_CONF['hour_mode']) && ($_CA_CONF['hour_mode'] == 24)) { + $cal_templates->set_var ('hour_mode', 24); + } else { + $cal_templates->set_var ('hour_mode', 12); + } + $cal_templates->set_var('gltoken_name', CSRF_TOKEN); + $cal_templates->set_var('gltoken', SEC_createToken()); + + return $cal_templates->parse ('output', 'form'); +} + +/** +* Set localised day and month names. +* +* @param object $aCalendar reference(!) to a Calendar object +* +*/ +function setCalendarLanguage (&$aCalendar) +{ + global $LANG_WEEK, $LANG_MONTH, $LANG_CAL_2; + + $lang_days = array ('sunday' => $LANG_WEEK[1], + 'monday' => $LANG_WEEK[2], + 'tuesday' => $LANG_WEEK[3], + 'wednesday' => $LANG_WEEK[4], + 'thursday' => $LANG_WEEK[5], + 'friday' => $LANG_WEEK[6], + 'saturday' => $LANG_WEEK[7]); + $lang_months = array ('january' => $LANG_MONTH[1], + 'february' => $LANG_MONTH[2], + 'march' => $LANG_MONTH[3], + 'april' => $LANG_MONTH[4], + 'may' => $LANG_MONTH[5], + 'june' => $LANG_MONTH[6], + 'july' => $LANG_MONTH[7], + 'august' => $LANG_MONTH[8], + 'september' => $LANG_MONTH[9], + 'october' => $LANG_MONTH[10], + 'november' => $LANG_MONTH[11], + 'december' => $LANG_MONTH[12]); + $aCalendar->setLanguage ($lang_days, $lang_months); +} + + +// MAIN + +$display = ''; + +$action = ''; +if (isset ($_REQUEST['action'])) { + $action = COM_applyFilter ($_REQUEST['action']); +} + +switch ($action) { +case 'addevent': + if (($_CA_CONF['personalcalendars'] == 1) && !COM_isAnonUser()) { + $display .= COM_siteHeader (); + + $eid = COM_applyFilter ($_GET['eid']); + if (!empty ($eid)) { + $display .= adduserevent ($eid); + } else { + $display .= COM_showMessage (23); + } + + $display .= COM_siteFooter (); + } else { + $display = COM_refresh ($_CONF['site_url'] . '/index.php'); + } + break; + +case 'saveuserevent': + if (($_CA_CONF['personalcalendars'] == 1) && SEC_checkToken()) { + $eid = COM_applyFilter ($_POST['eid']); + if (!empty ($eid)) { + $display .= saveuserevent ($eid); + } else { + $display .= COM_siteHeader (); + $display .= COM_showMessage (23); + $display .= COM_siteFooter (); + } + } else { + $display = COM_refresh ($_CONF['site_url'] . '/index.php'); + } + break; + +case $LANG_CAL_1[45]: // save edited personal event + if (!empty($LANG_CAL_1[45]) && ($_CA_CONF['personalcalendars'] == 1) && + (!empty ($_USER['uid']) && ($_USER['uid'] > 1)) && + (isset ($_POST['calendar_type']) && + ($_POST['calendar_type'] == 'personal')) && SEC_checkToken()) { + $display = plugin_savesubmission_calendar ($_POST); + } else { + $display = COM_refresh ($_CONF['site_url'] . '/index.php'); + } + break; + +case 'deleteevent': +case $LANG_CAL_1[51]: + if (($_CA_CONF['personalcalendars'] == 1) && SEC_checkToken()) { + $eid = COM_applyFilter ($_REQUEST['eid']); + if (!empty ($eid) && (isset ($_USER['uid']) && ($_USER['uid'] > 1))) { + DB_query ("DELETE FROM {$_TABLES['personal_events']} WHERE uid={$_USER['uid']} AND eid='$eid'"); + $display .= COM_refresh ($_CONF['site_url'] + . '/calendar/index.php?mode=personal&msg=26'); + } else { + $display = COM_refresh ($_CONF['site_url'] . '/index.php'); + } + } else { + $display = COM_refresh ($_CONF['site_url'] . '/index.php'); + } + break; + +case 'edit': + if ($_CA_CONF['personalcalendars'] == 1) { + $eid = COM_applyFilter ($_GET['eid']); + if (!empty ($eid) && (isset ($_USER['uid']) && ($_USER['uid'] > 1))) { + $result = DB_query ("SELECT * FROM {$_TABLES['personal_events']} WHERE (eid = '$eid') AND (uid = {$_USER['uid']})"); + if (DB_numRows ($result) == 1) { + $A = DB_fetchArray ($result); + $display .= COM_siteHeader ('menu', $LANG_CAL_2[38]) + . COM_startBlock ($LANG_CAL_2[38]) + . editpersonalevent ($A) + . COM_endBlock () + . COM_siteFooter (); + } else { + $display = COM_refresh ($_CONF['site_url'] . '/index.php'); + } + } else { + $display = COM_refresh ($_CONF['site_url'] . '/index.php'); + } + } else { + $display = COM_refresh ($_CONF['site_url'] . '/index.php'); + } + break; + +default: + $mode = ''; + if (isset ($_GET['mode'])) { + $mode = COM_applyFilter ($_GET['mode']); + } + $eid = ''; + if (isset ($_GET['eid'])) { + $eid = COM_applyFilter ($_GET['eid']); + } + $query = ''; + if (isset($_GET['query'])) { + $query = COM_applyFilter($_GET['query']); + } + if (!empty ($eid)) { + if (($mode == 'personal') && ($_CA_CONF['personalcalendars'] == 1) && + (isset ($_USER['uid']) && ($_USER['uid'] > 1))) { + $datesql = "SELECT * FROM {$_TABLES['personal_events']} " + . "WHERE (eid = '$eid') AND (uid = {$_USER['uid']})"; + $pagetitle = $LANG_CAL_2[28] . ' ' . COM_getDisplayName(); + } else { + $datesql = "SELECT * FROM {$_TABLES['events']} WHERE eid = '$eid'"; + if (strpos ($LANG_CAL_2[9], '%') === false) { + $pagetitle = $LANG_CAL_2[9]; + } else { + $pagetitle = sprintf ($LANG_CAL_2[9], $_CONF['site_name']); + } + DB_query ("UPDATE {$_TABLES['events']} SET hits = hits + 1 WHERE eid = '$eid'"); + } + + $display .= COM_siteHeader('menu', $pagetitle); + if (isset($_GET['msg'])) { + $msg = COM_applyFilter($_GET['msg'], true); + if ($msg > 0) { + $display .= COM_showMessage($msg, 'calendar'); + } + } + $display .= COM_startBlock($pagetitle); + + } else { + $year = 0; + if (isset ($_GET['year'])) { + $year = COM_applyFilter ($_GET['year'], true); + } + $month = 0; + if (isset ($_GET['month'])) { + $month = COM_applyFilter ($_GET['month'], true); + } + $day = 0; + if (isset ($_GET['day'])) { + $day = COM_applyFilter ($_GET['day'], true); + } + if (($year == 0) || ($month == 0) || ($day == 0)) { + $year = date ('Y'); + $month = date ('n'); + $day = date ('j'); + } + + $pagetitle = $LANG_CAL_2[10] . ' ' . strftime ($_CONF['shortdate'], + mktime (0, 0, 0, $month, $day, $year)); + $display .= COM_siteHeader ('menu', $pagetitle); + $display .= COM_startBlock ($pagetitle); + + $thedate = sprintf ('%4d-%02d-%02d', $year, $month, $day); + $datesql = "SELECT * FROM {$_TABLES['events']} " + . "WHERE \"$thedate\" BETWEEN DATE_FORMAT(datestart,'%Y-%m-%d') " + . "and DATE_FORMAT(dateend,'%Y-%m-%d') " + . "ORDER BY datestart ASC,timestart ASC,title"; + } + $cal_templates = new Template($_CONF['path'] . 'plugins/calendar/templates/'); + $cal_templates->set_file (array ( + 'events' => 'events.thtml', + 'details' => 'eventdetails.thtml', + 'addremove' => 'addremoveevent.thtml' + )); + + $cal_templates->set_var ( 'xhtml', XHTML ); + $cal_templates->set_var ('lang_addevent', $LANG_CAL_1[6]); + $cal_templates->set_var ('lang_backtocalendar', $LANG_CAL_1[15]); + if ($mode == 'personal') { + $cal_templates->set_var ('calendar_mode', '?mode=personal'); + } else { + $cal_templates->set_var ('calendar_mode', ''); + } + + $result = DB_query($datesql); + $nrows = DB_numRows($result); + if ($nrows == 0) { + $cal_templates->set_var('lang_month',''); + $cal_templates->set_var('event_year',''); + $cal_templates->set_var('event_details',''); + $cal_templates->set_var('site_url', $_CONF['site_url']); + $cal_templates->set_var('site_admin_url', $_CONF['site_admin_url']); + $cal_templates->set_var('layout_url', $_CONF['layout_url']); + $cal_templates->parse('output','events'); + $display .= $cal_templates->finish($cal_templates->get_var('output')); + $display .= $LANG_CAL_1[2]; + } else { + $cal = new Calendar(); + setCalendarLanguage ($cal); + + $currentmonth = ''; + for ($i = 0; $i < $nrows; $i++) { + $A = DB_fetchArray($result); + if (SEC_hasAccess($A['owner_id'],$A['group_id'],$A['perm_owner'], + $A['perm_group'],$A['perm_members'],$A['perm_anon']) > 0) { + if (strftime('%B',strtotime($A['datestart'])) != $currentmonth) { + $str_month = $cal->getMonthName(strftime('%m',strtotime($A['datestart']))); + $cal_templates->set_var('lang_month', $str_month); + $cal_templates->set_var('event_year', strftime('%Y',strtotime($A['datestart']))); + $currentmonth = strftime('%B',strtotime($A['datestart'])); + } + $cal_templates->set_var('event_title', stripslashes($A['title'])); + $cal_templates->set_var('site_url', $_CONF['site_url']); + $cal_templates->set_var('site_admin_url', $_CONF['site_admin_url']); + $cal_templates->set_var('layout_url', $_CONF['layout_url']); + $event_title = stripslashes($A['title']); + if (!empty($A['url'])) { + $event_title = COM_createLink($event_title, $A['url']); + $cal_templates->set_var('event_url', $A['url']); + } + $cal_templates->set_var('event_title', $event_title); + if (($_CA_CONF['personalcalendars'] == 1) + && !COM_isAnonUser()) { + $tmpresult = DB_query("SELECT * FROM {$_TABLES['personal_events']} WHERE eid='{$A['eid']}' AND uid={$_USER['uid']}"); + $tmpnrows = DB_numRows($tmpresult); + if ($tmpnrows > 0) { + $token = SEC_createToken(); + $addremovelink = $_CONF['site_url'] + . '/calendar/event.php?eid=' . $A['eid'] + . '&mode=personal&action=deleteevent&' + . CSRF_TOKEN . '=' . $token; + $addremovetxt = $LANG_CAL_1[10]; + } else { + $addremovelink = $_CONF['site_url'] + . '/calendar/event.php?eid=' . $A['eid'] + . '&mode=personal&action=addevent'; + $addremovetxt = $LANG_CAL_1[9]; + } + $cal_templates->set_var('lang_addremovefromcal', + COM_createLink($addremovetxt, $addremovelink)); + $cal_templates->parse('addremove_event','addremove'); + } + $cal_templates->set_var('lang_when', $LANG_CAL_1[3]); + if ($A['allday'] == 0) { + $thedatetime = COM_getUserDateTimeFormat ($A['datestart'] . + ' ' . $A['timestart']); + $cal_templates->set_var ('event_start', $thedatetime[0]); + + if ($A['datestart'] == $A['dateend']) { + $thedatetime[0] = strftime ($_CONF['timeonly'], + strtotime ($A['dateend'] . ' ' . $A['timeend'])); + } else { + $thedatetime = COM_getUserDateTimeFormat ($A['dateend'] + . ' ' . $A['timeend']); + } + $cal_templates->set_var ('event_end', $thedatetime[0]); + } else if ($A['allday'] == 1 AND $A['datestart'] <> $A['dateend']) { + $thedatetime1 = strftime ('%A, ' . $_CONF['shortdate'], + strtotime ($A['datestart'])); + $cal_templates->set_var ('event_start', $thedatetime1); + $thedatetime2 = strftime ('%A, ' . $_CONF['shortdate'], + strtotime ($A['dateend'])); + $cal_templates->set_var ('event_end', $thedatetime2 + . ' ' . $LANG_CAL_2[26]); + } else { + $thedatetime = strftime ('%A, ' . $_CONF['shortdate'], + strtotime ($A['datestart'])); + $cal_templates->set_var ('event_start', $thedatetime); + $cal_templates->set_var ('event_end', $LANG_CAL_2[26]); + } + + // set the location variables + $cal_templates->set_var ('lang_where', $LANG_CAL_1[4]); + $cal_templates->set_var ('event_location', + stripslashes ($A['location'])); + $cal_templates->set_var ('event_address1', + stripslashes ($A['address1'])); + $cal_templates->set_var ('event_address2', + stripslashes ($A['address2'])); + $cal_templates->set_var ('event_zip', $A['zipcode']); + $cal_templates->set_var ('event_city', + stripslashes ($A['city'])); + $cal_templates->set_var ('event_state_only', $A['state']); + if (empty ($A['state']) || ($A['state'] == '--')) { + $cal_templates->set_var ('event_state', ''); + $cal_templates->set_var ('event_state_name', ''); + $cal_templates->set_var ('event_state_name_only', ''); + } else { + $cal_templates->set_var ('event_state', ', ' . $A['state']); + $cal_templates->set_var ('event_state_name', $A['state']); + $cal_templates->set_var ('event_state_name_only', + $A['state']); + } + + // now figure out which of the {brX} variables to set ... + $hasCityEtc = (!empty ($A['city']) || !empty ($A['zip']) || + !empty ($A['state'])); + if (empty ($A['location']) && empty ($A['address1']) && + empty ($A['address2']) && !$hasCityEtc) { + $cal_templates->set_var ('br0', ''); + $cal_templates->set_var ('br1', ''); + $cal_templates->set_var ('br2', ''); + } else { + if (empty ($A['location']) || (empty ($A['address1']) && + empty ($A['address2']) && !$hasCityEtc)) { + $cal_templates->set_var ('br0', ''); + } else { + $cal_templates->set_var ('br0', '<br' . XHTML . '>'); + } + if (empty ($A['address1']) || (empty ($A['address2']) && + !$hasCityEtc)) { + $cal_templates->set_var ('br1', ''); + } else { + $cal_templates->set_var ('br1', '<br' . XHTML . '>'); + } + if (empty ($A['address2']) || !$hasCityEtc) { + $cal_templates->set_var ('br2', ''); + } else { + $cal_templates->set_var ('br2', '<br' . XHTML . '>'); + } + } + + $cal_templates->set_var('lang_description', $LANG_CAL_1[5]); + $description = stripslashes($A['description']); + if (empty($A['postmode']) || ($A['postmode'] == 'plaintext')) { + $description = nl2br($description); + } + $description = PLG_replaceTags($description); + if (!empty($query)) { + $description = COM_highlightQuery($description, $query); + } + $cal_templates->set_var ('event_description', $description); + $cal_templates->set_var ('lang_event_type', $LANG_CAL_1[37]); + $cal_templates->set_var ('event_type', $A['event_type']); + + if ($mode == 'personal') { + $editurl = $_CONF['site_url'] + . '/calendar/event.php?action=edit' . '&eid=' + . $A['eid']; + $cal_templates->set_var('event_edit', + COM_createLink($LANG01[4], $editurl)); + $img = '<img src="' . $_CONF['layout_url'] . '/images/edit.' + . $_IMAGE_TYPE . '" alt="' . $LANG01[4] . '" title="' + . $LANG01[4] . '"' . XHTML . '>'; + $cal_templates->set_var('edit_icon', + COM_createLink($img, $editurl)); + } else if ((SEC_hasAccess ($A['owner_id'], $A['group_id'], + $A['perm_owner'], $A['perm_group'], $A['perm_members'], + $A['perm_anon']) == 3) && SEC_hasRights ('calendar.edit')) { + $editurl = $_CONF['site_admin_url'] + . '/plugins/calendar/index.php?mode=edit&eid=' + . $A['eid']; + $cal_templates->set_var('event_edit', + COM_createLink($LANG01[4], $editurl)); + $img = '<img src="' . $_CONF['layout_url'] . '/images/edit.' + . $_IMAGE_TYPE . '" alt="' . $LANG01[4] . '" title="' + . $LANG01[4] . '"' . XHTML . '>'; + $cal_templates->set_var('edit_icon', + COM_createLink($img, $editurl)); + $cal_templates->set_var('hits_admin', + COM_numberFormat($A['hits'])); + $cal_templates->set_var('lang_hits_admin', $LANG10[30]); + } else { + $cal_templates->set_var('event_edit', ''); + $cal_templates->set_var('edit_icon', ''); + } + if ($mode == 'personal') { + // personal events don't have a hits counter + $cal_templates->set_var('lang_hits', ''); + $cal_templates->set_var('hits', ''); + } else { + $cal_templates->set_var('lang_hits', $LANG10[30]); + $cal_templates->set_var('hits', COM_numberFormat($A['hits'])); + } + $cal_templates->parse ('event_details', 'details', true); + } + } + + $cal_templates->parse ('output', 'events'); + $display .= $cal_templates->finish ($cal_templates->get_var ('output')); + } + + $display .= COM_endBlock() . COM_siteFooter(); + +} // end switch + +echo $display; + +?> Added: externals/geeklog-1.5.2sr2/public_html/calendar/images/calendar.png ============================================================================== Binary file. No diff available. Added: externals/geeklog-1.5.2sr2/public_html/calendar/images/delete_event.gif ============================================================================== Binary file. No diff available. Added: externals/geeklog-1.5.2sr2/public_html/calendar/images/delete_event.png ============================================================================== Binary file. No diff available. Added: externals/geeklog-1.5.2sr2/public_html/calendar/index.php ============================================================================== --- (empty file) +++ externals/geeklog-1.5.2sr2/public_html/calendar/index.php Sun Apr 5 18:12:05 2009 @@ -0,0 +1,1087 @@ +<?php + +/* Reminder: always indent with 4 spaces (no tabs). */ +// +---------------------------------------------------------------------------+ +// | Calendar Plugin 1.0 | +// +---------------------------------------------------------------------------+ +// | index.php | +// | | +// | Geeklog calendar plugin | +// +---------------------------------------------------------------------------+ +// | Copyright (C) 2000-2008 by the following authors: | +// | | +// | Authors: Tony Bibbs - tony AT tonybibbs DOT com | +// | Mark Limburg - mlimburg AT users DOT sourceforge DOT net | +// | Jason Whittenburg - jwhitten AT securitygeeks DOT com | +// | Dirk Haun - dirk AT haun-online DOT de | +// +---------------------------------------------------------------------------+ +// | | +// | 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, or (at your option) any later version. | +// | | +// | This program is distributed in the hope that it will be useful, | +// | but WITHOUT ANY WARRANTY; without even the implied warranty of | +// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | +// | GNU General Public License for more details. | +// | | +// | You should have received a copy of the GNU General Public License | +// | along with this program; if not, write to the Free Software Foundation, | +// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | +// | | +// +---------------------------------------------------------------------------+ +// +// $Id: index.php,v 1.27 2008/07/06 20:15:10 dhaun Exp $ + +require_once '../lib-common.php'; + +if (!in_array('calendar', $_PLUGINS)) { + echo COM_refresh($_CONF['site_url'] . '/index.php'); + exit; +} + +require_once $_CONF['path_system'] . 'classes/calendar.class.php'; + +$display = ''; + +if (empty ($_USER['username']) && + (($_CONF['loginrequired'] == 1) || ($_CA_CONF['calendarloginrequired'] == 1))) { + $display .= COM_siteHeader(''); + $display .= COM_startBlock ($LANG_LOGIN[1], '', + COM_getBlockTemplate ('_msg_block', 'header')); + $login = new Template($_CONF['path_layout'] . 'submit'); + $login->set_file (array ('login'=>'submitloginrequired.thtml')); + $login->set_var ( 'xhtml', XHTML ); + $login->set_var ('login_message', $LANG_LOGIN[2]); + $login->set_var ('site_url', $_CONF['site_url']); + $login->set_var ('site_admin_url', $_CONF['site_admin_url']); + $login->set_var ('layout_url', $_CONF['layout_url']); + $login->set_var ('lang_login', $LANG_LOGIN[3]); + $login->set_var ('lang_newuser', $LANG_LOGIN[4]); + $login->parse ('output', 'login'); + $display .= $login->finish ($login->get_var('output')); + $display .= COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer')); + $display .= COM_siteFooter(); + echo $display; + exit; +} + +function getDayViewData($result, $cur_time = '') +{ + $max = 0; + + // If no date/time passed used current timestamp + if (empty($cur_time)) { + $cur_time = time(); + } + + // Initialize array + $hourcols = array(); + for ($i = 0; $i <= 23; $i++) { + $hourcols[$i] = 0; + } + + // Get data and increment counters + $thedata = array(); + $nrows = DB_numRows($result); + + $alldaydata = array (); + for ($i = 1; $i <= $nrows; $i++) { + $A = DB_fetchArray($result); + if ($A['allday'] == 1 OR (($A['datestart'] < date('Y-m-d',$cur_time)) AND ($A['dateend'] > date('Y-m-d',$cur_time)))) { + // This is an all day event + $alldaydata[$i] = $A; + } else { + // This is an event with start/end times + if ($A['datestart'] < date('Y-m-d', $cur_time) AND $A['dateend'] >= date('Y-m-d', $cur_time)) { + $starthour = '00'; + } else { + $starthour = date('G', strtotime($A['datestart'] . ' ' . $A['timestart'])); + } + $endhour = date('G', strtotime($A['dateend'] . ' ' . $A['timeend'])); + if (date('i', strtotime($A['dateend'] . ' ' . $A['timeend'])) == '00') { + $endhour = $endhour - 1; + } + $hourcols[$starthour] = $hourcols[$starthour] + 1; + if ($hourcols[$starthour] > $max) { + $max = $hourcols[$starthour]; + } + $thedata[$i] = $A; + } + } + + return array($hourcols, $thedata, $max, $alldaydata); +} + +function setCalendarLanguage (&$aCalendar) +{ + global $_CONF, $LANG_WEEK, $LANG_MONTH; + + $lang_days = array ('sunday' => $LANG_WEEK[1], + 'monday' => $LANG_WEEK[2], + 'tuesday' => $LANG_WEEK[3], + 'wednesday' => $LANG_WEEK[4], + 'thursday' => $LANG_WEEK[5], + 'friday' => $LANG_WEEK[6], + 'saturday' => $LANG_WEEK[7]); + + $lang_months = array ('january' => $LANG_MONTH[1], + 'february' => $LANG_MONTH[2], + 'march' => $LANG_MONTH[3], + 'april' => $LANG_MONTH[4], + 'may' => $LANG_MONTH[5], + 'june' => $LANG_MONTH[6], + 'july' => $LANG_MONTH[7], + 'august' => $LANG_MONTH[8], + 'september' => $LANG_MONTH[9], + 'october' => $LANG_MONTH[10], + 'november' => $LANG_MONTH[11], + 'december' => $LANG_MONTH[12]); + + $aCalendar->setLanguage ($lang_days, $lang_months, $_CONF['week_start']); +} + +/** +* Returns an abbreviated day's name +* +* @param int $day 1 = Sunday, 2 = Monday, ... +* @return string abbreviated day's name (2 characters) +* +* +*/ +function shortDaysName ($day) +{ + global $LANG_WEEK; + + return MBYTE_substr ($LANG_WEEK[$day], 0, 2); +} + +function makeDaysHeadline () +{ + global $_CONF; + + $retval = '<tr><th>'; + if ($_CONF['week_start'] == 'Mon') { + $retval .= shortDaysName (2) . '</th><th>' + . shortDaysName (3) . '</th><th>' + . shortDaysName (4) . '</th><th>' + . shortDaysName (5) . '</th><th>' + . shortDaysName (6) . '</th><th>' + . shortDaysName (7) . '</th><th>' + . shortDaysName (1) . '</th></tr>'; + } else { + $retval .= shortDaysName (1) . '</th><th>' + . shortDaysName (2) . '</th><th>' + . shortDaysName (3) . '</th><th>' + . shortDaysName (4) . '</th><th>' + . shortDaysName (5) . '</th><th>' + . shortDaysName (6) . '</th><th>' + . shortDaysName (7) . '</th></tr>'; + } + + return $retval; +} + +/** +* Add the 'mode=' parameter to a URL +* +* @param string $mode the mode ('personal' or empty string) +* @param boolean $more whether there are more parameters in the URL or not +* @param string 'mode' parameter for the URL or an empty string +* +*/ +function addMode ($mode, $more = true) +{ + $retval = ''; + + if (!empty ($mode)) { + $retval .= 'mode=' . $mode; + if ($more) { + $retval .= '&'; + } + } + + return $retval; +} + +/** +* Return link to "delete event" image +* +* Note: Personal events can be deleted if the current user is the owner of the +* calendar and has _read_ access to them. +* +* @param string $mode 'personal' for personal events +* @param array $A event permissions and id +* @param string $token security token +* @return string link or empty string +* +*/ +function getDeleteImageLink($mode, $A, $token) +{ + global $_CONF, $LANG_ADMIN, $LANG_CAL_2, $_IMAGE_TYPE; + + $retval = ''; + $img = '<img src="' . $_CONF['site_url'] + . '/calendar/images/delete_event.' . $_IMAGE_TYPE + . '" alt="' . $LANG_CAL_2[30] . '" title="' + . $LANG_CAL_2[30] . '"' . XHTML . '>'; + + if ($mode == 'personal') { + if (SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], + $A['perm_group'], $A['perm_members'], $A['perm_anon']) > 0) { + $retval = COM_createLink($img, $_CONF['site_url'] + . '/calendar/event.php?action=deleteevent&eid=' + . $A['eid'] . '&' . CSRF_TOKEN . '=' . $token); + } + } else if (SEC_hasRights('calendar.edit')) { + if (SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], + $A['perm_group'], $A['perm_members'], $A['perm_anon']) == 3) { + $retval = COM_createLink($img, $_CONF['site_admin_url'] + . '/plugins/calendar/index.php?mode=' + . $LANG_ADMIN['delete'] . '&eid=' . $A['eid'] . '&' + . CSRF_TOKEN . '=' . $token); + } + } + + return $retval; +} + +/** +* Gets a small, text-only version of a calendar +* +* @param int $m Month to display +* @param int $y Year to display +* @return string HTML for small calendar +* +*/ +function getSmallCalendar ($m, $y, $mode = '') +{ + global $_CONF; + + $retval = ''; + $mycal = new Calendar (); + setCalendarLanguage ($mycal); + $mycal->setCalendarMatrix ($m, $y); + + if (!empty ($mode)) { + $mode = '&mode=' . $mode; + } + + $retval .= '<table class="smallcal">' . LB + . '<tr class="smallcal-headline"><td align="center" colspan="7">' + . COM_createLink($mycal->getMonthName ($m), $_CONF['site_url'] + . '/calendar/index.php?month=' . $m . '&year=' . $y . $mode) + . '</td></tr>' . makeDaysHeadline () . LB; + + for ($i = 1; $i <= 6; $i++) { + if ($i % 2 == 0) { + $tr = '<tr class="smallcal-week-even">' . LB; + } else { + $tr = '<tr class="smallcal-week-odd">' . LB; + } + $tr_sent = false; + for ($j = 1; $j <= 7; $j++) { + $curday = $mycal->getDayData ($i, $j); + if (!$tr_sent) { + if (empty ($curday)) { + $retval .= '<tr class="smallcal-week-empty">' . LB; + } else { + $retval .= $tr; + } + $tr_sent = true; + } + $retval .= '<td align="right"'; + if (!empty ($curday)) { + if ($j % 2 == 0) { + $retval .= ' class="smallcal-day-even">' . LB; + } else { + $retval .= ' class="smallcal-day-odd">' . LB; + } + $retval .= $curday->daynumber; + } else { + $retval .= ' class="smallcal-day-empty"> '; + } + $retval .= '</td>' . LB; + } + $retval .= '</tr>' . LB; + } + + $retval .= '</table>' . LB; + + return $retval; +} + +/** +* Builds Quick Add form +* +*/ +function getQuickAdd($tpl, $month, $day, $year, $token) +{ + global $_CA_CONF, $LANG_CAL_2; + + $tpl->set_var('month_options', COM_getMonthFormOptions($month)); + $tpl->set_var('day_options', COM_getDayFormOptions($day)); + $tpl->set_var('year_options', COM_getYearFormOptions($year)); + + $cur_hour = date('H', time ()); + if ($cur_hour >= 12) { + $ampm = 'pm'; + } else { + $ampm = 'am'; + } + $cur_hour_24 = $cur_hour % 24; + if ($cur_hour > 12) { + $cur_hour = $cur_hour - 12; + } else if ($cur_hour == 0) { + $cur_hour = 12; + } + if (isset($_CA_CONF['hour_mode']) && ($_CA_CONF['hour_mode'] == 24)) { + $tpl->set_var('hour_mode', 24); + $tpl->set_var('hour_options', + COM_getHourFormOptions($cur_hour_24, 24)); + } else { + $tpl->set_var('hour_mode', 12); + $tpl->set_var('hour_options', COM_getHourFormOptions($cur_hour)); + } + $tpl->set_var('startampm_selection', + COM_getAmPmFormSelection('start_ampm', $ampm)); + $cur_min = intval(date('i') / 15) * 15; + $tpl->set_var('minute_options', COM_getMinuteFormOptions($cur_min, 15)); + + $tpl->set_var('lang_event', $LANG_CAL_2[32]); + $tpl->set_var('lang_date', $LANG_CAL_2[33]); + $tpl->set_var('lang_time', $LANG_CAL_2[34]); + $tpl->set_var('lang_add', $LANG_CAL_2[31]); + $tpl->set_var('lang_quickadd', $LANG_CAL_2[35]); + $tpl->set_var('lang_submit', $LANG_CAL_2[36]); + $tpl->set_var('gltoken_name', CSRF_TOKEN); + $tpl->set_var('gltoken', $token); + $tpl->parse('quickadd_form', 'quickadd', true); + + return $tpl; +} + +/** +* Returns timestamp for the prior sunday of a given day +* +*/ +function getPriorSunday($month, $day, $year) +{ + $thestamp = mktime(0, 0, 0, $month, $day, $year); + $newday = $day - date('w', $thestamp); + $newstamp = mktime(0,0,0,$month,$newday,$year); + $newday = date('j',$newstamp); + $newmonth = date('n', $newstamp); + $newyear = date('Y',$newstamp); + + return array($newmonth, $newday, $newyear); +} + +// MAIN +$mode = ''; +if (isset ($_REQUEST['mode'])) { + $mode = COM_applyFilter ($_REQUEST['mode']); +} + +if ($mode != 'personal' && $mode != 'quickadd') { + $mode = ''; +} + +if ($mode == 'personal') { + $display .= COM_siteHeader ('menu', $LANG_CAL_1[42]); +} else { + $display .= COM_siteHeader ('menu', $LANG_CAL_1[41]); +} + +// Set mode back to master if user refreshes screen after their session expires +if (($mode == 'personal') && COM_isAnonUser()) { + $mode = ''; +} + +if ($mode == 'personal' AND $_CA_CONF['personalcalendars'] == 0) { + // User is trying to use the personal calendar feature even though it isn't + // turned on. + $display .= $LANG_CAL_2[37]; + $display .= COM_siteFooter(); + echo $display; + exit; +} + +// after this point, we can safely assume that if $mode == 'personal', +// the current user is actually allowed to use this personal calendar + +$msg = 0; +if (isset ($_REQUEST['msg'])) { + $msg = COM_applyFilter ($_REQUEST['msg'], true); +} +if ($msg > 0) { + $display .= COM_showMessage ($msg, 'calendar'); +} + +$view = ''; +if (isset ($_REQUEST['view'])) { + $view = COM_applyFilter ($_REQUEST['view']); +} + +if (!in_array ($view, array ('month', 'week', 'day', 'addentry', 'savepersonal'))) { + $view = ''; +} + +$year = 0; +if (isset ($_REQUEST['year'])) { + $year = COM_applyFilter ($_REQUEST['year'], true); +} +$month = 0; +if (isset ($_REQUEST['month'])) { + $month = COM_applyFilter ($_REQUEST['month'], true); +} +$day = 0; +if (isset ($_REQUEST['day'])) { + $day = COM_applyFilter ($_REQUEST['day'], true); +} + +$token = ''; +if ((($view == 'day') || ($view == 'week')) && + (($mode == 'personal') || SEC_hasRights('calendar.edit'))) { + $token = SEC_createToken(); +} + +// Create new calendar object +$cal = new Calendar(); + +if ($view == 'week' AND (empty($month) AND empty($day) AND empty($year))) { + list($month, $day, $year) = getPriorSunday(date('m', time()), date('j', time()), date('Y', time())); +} else { + // Get current month + $currentmonth = date('m', time()); + if (empty($month)) { + $month = $currentmonth; + } + + // Get current year + $currentyear = date('Y', time()); + if (empty($year)) { + $year = $currentyear; + } + + // Get current day + $currentday = date('j', time()); + if (empty($day)) { + $day = $currentday; + } +} + +// Get previous month and year +$prevmonth = $month - 1; +if ($prevmonth == 0) { + $prevmonth = 12; + $prevyear = $year - 1; +} else { + $prevyear = $year; +} + +// Get next month and year +$nextmonth = $month + 1; +if ($nextmonth == 13) { + $nextmonth = 1; + $nextyear = $year + 1; +} else { + $nextyear = $year; +} + +setCalendarLanguage ($cal); + +// Build calendar matrix +$cal->setCalendarMatrix ($month, $year); + +switch ($view) { +case 'day': + $cal_templates = new Template($_CONF['path'] . 'plugins/calendar/templates/dayview'); + $cal_templates->set_file(array('column'=>'column.thtml', + 'event'=>'singleevent.thtml', + 'dayview'=>'dayview.thtml', + 'quickadd'=>'quickaddform.thtml')); + $cal_templates->set_var ( 'xhtml', XHTML ); + $cal_templates->set_var ('site_url', $_CONF['site_url']); + $cal_templates->set_var ('site_admin_url', $_CONF['site_admin_url']); + $cal_templates->set_var ('layout_url', $_CONF['layout_url']); + $cal_templates->set_var('mode', $mode); + $cal_templates->set_var('lang_day', $LANG_CAL_2[39]); + $cal_templates->set_var('lang_week', $LANG_CAL_2[40]); + $cal_templates->set_var('lang_month', $LANG_CAL_2[41]); + list($wmonth, $wday, $wyear) = getPriorSunday($month, $day, $year); + $cal_templates->set_var('wmonth', $wmonth); + $cal_templates->set_var('wday', $wday); + $cal_templates->set_var('wyear', $wyear); + $cal_templates->set_var('month',$month); + $cal_templates->set_var('day', $day); + $cal_templates->set_var('year',$year); + $prevstamp = mktime(0, 0, 0,$month, $day - 1, $year); + $nextstamp = mktime(0, 0, 0,$month, $day + 1, $year); + $cal_templates->set_var('prevmonth', strftime('%m',$prevstamp)); + $cal_templates->set_var('prevday', strftime('%d',$prevstamp)); + $cal_templates->set_var('prevyear', strftime('%Y',$prevstamp)); + $cal_templates->set_var('nextmonth', strftime('%m',$nextstamp)); + $cal_templates->set_var('nextday', strftime('%d',$nextstamp)); + $cal_templates->set_var('nextyear', strftime('%Y',$nextstamp)); + + $cal_templates->set_var('currentday', strftime('%A, %x',mktime(0, 0, 0,$month, $day, $year))); + if ($mode == 'personal') { + $cal_templates->set_var('calendar_title', '[' . $LANG_CAL_2[28] . ' ' . COM_getDisplayName()); + $cal_templates->set_var('calendar_toggle', '| ' + . COM_createLink($LANG_CAL_2[11], $_CONF['site_url'] + . "/calendar/index.php?view=day&month=$month&day=$day&year=$year") . ']' + ); + } else { + $cal_templates->set_var('calendar_title', '[' . $_CONF['site_name'] . ' ' . $LANG_CAL_2[29]); + if (!empty($_USER['uid']) AND $_CA_CONF['personalcalendars'] == 1) { + $cal_templates->set_var('calendar_toggle', '| ' + . COM_createLink($LANG_CAL_2[12], $_CONF['site_url'] + . "/calendar/index.php?mode=personal&view=day&month=$month&day=$day&year=$year") . ']' + ); + } else { + $cal_templates->set_var('calendar_toggle', ']'); + } + } + $thedate = COM_getUserDateTimeFormat(mktime(0,0,0,$month,$day,$year)); + $cal_templates->set_var('week_num',strftime('%V',$thedate[1])); + if ($mode == 'personal') { + $calsql = "SELECT eid,title,datestart,dateend,timestart,timeend,allday,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon FROM {$_TABLES['personal_events']} " + . "WHERE (uid = {$_USER['uid']}) " + . "AND ((allday=1 AND datestart = \"$year-$month-$day\") " + . "OR (datestart >= \"$year-$month-$day 00:00:00\" AND datestart <= \"$year-$month-$day 23:59:59\") " + . "OR (dateend >= \"$year-$month-$day 00:00:00\" AND dateend <= \"$year-$month-$day 23:59:59\") " + . "OR (\"$year-$month-$day\" BETWEEN datestart AND dateend)) " + . "ORDER BY datestart,timestart"; + } else { + $calsql = "SELECT eid,title,datestart,dateend,timestart,timeend,allday,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon FROM {$_TABLES['events']} WHERE ((allday=1 " + . "AND datestart = \"$year-$month-$day\") " + . "OR (datestart >= \"$year-$month-$day 00:00:00\" AND datestart <= \"$year-$month-$day 23:59:59\") " + . "OR (dateend >= \"$year-$month-$day 00:00:00\" AND dateend <= \"$year-$month-$day 23:59:59\") " + . "OR (\"$year-$month-$day\" BETWEEN datestart AND dateend))" . COM_getPermSql ('AND') + . " ORDER BY datestart,timestart"; + } + $result = DB_query($calsql); + $nrows = DB_numRows($result); + list($hourcols, $thedata, $max, $alldaydata) = getDayViewData($result); + + // Get all day events + $alldaycount = count($alldaydata); + if ($alldaycount > 0) { + for ($i = 1; $i <= $alldaycount; $i++) { + $A = current($alldaydata); + $cal_templates->set_var('delete_imagelink', + getDeleteImageLink($mode, $A, $token)); + $cal_templates->set_var('event_time', $LANG_CAL_2[26]); + $cal_templates->set_var('eid', $A['eid']); + $cal_templates->set_var('event_title', stripslashes($A['title'])); + if ($i < $alldaycount) { + $cal_templates->set_var('br', '<br' . XHTML . '>'); + } else { + $cal_templates->set_var('br', ''); + } + $cal_templates->parse('allday_events', 'event', true); + next($alldaydata); + } + } else { + $cal_templates->set_var('allday_events', ' '); + } + + //$cal_templates->set_var('first_colspan', $maxcols); + //$cal_templates->set_var('title_colspan', $maxcols + 1); + for ($i = 0; $i <= 23; $i++) { + $numevents = $hourcols[$i]; + if ($numevents > 0) { + // $colsleft = $maxcols; + $cal_templates->set_var ('layout_url', $_CONF['path'] . 'plugins/calendar/templates/'); + for ($j = 1; $j <= $numevents; $j++) { + $A = current ($thedata); + $cal_templates->set_var ('event_time', + strftime ($_CONF['timeonly'], strtotime ($A['datestart'] + . ' ' . $A['timestart'])) . '-' + . strftime ($_CONF['timeonly'], strtotime ($A['dateend'] + . ' ' . $A['timeend']))); + $cal_templates->set_var('delete_imagelink', + getDeleteImageLink($mode, $A, $token)); + $cal_templates->set_var('eid', $A['eid']); + $cal_templates->set_var('event_title', stripslashes($A['title'])); + if ($j < $numevents) { + $cal_templates->set_var('br', '<br' . XHTML . '>'); + } else { + $cal_templates->set_var('br', ''); + } + $cal_templates->parse ('event_entry', 'event', + ($j == 1) ? false : true); + // $colsleft = $colsleft - 1; + next($thedata); + } + } else { + $cal_templates->set_var('event_entry',' '); + } + $cal_templates->set_var ($i . '_hour', + strftime ($_CONF['timeonly'], mktime ($i, 0))); + $cal_templates->parse ($i . '_cols', 'column', true); + } + + if ($mode == 'personal') { + $cal_templates = getQuickAdd($cal_templates, $month, $day, $year, $token); + } else { + $cal_templates->set_var('quickadd_form',''); + } + $display .= $cal_templates->parse('output', 'dayview'); + $display .= COM_siteFooter(); + break; + +case 'week': + $cal_templates = new Template($_CONF['path'] . 'plugins/calendar/templates'); + $cal_templates->set_file(array('week'=>'weekview/weekview.thtml', + 'events'=>'weekview/events.thtml', + 'quickadd'=>'dayview/quickaddform.thtml')); + $cal_templates->set_var ( 'xhtml', XHTML ); + $cal_templates->set_var ('site_url', $_CONF['site_url']); + $cal_templates->set_var ('site_admin_url', $_CONF['site_admin_url']); + $cal_templates->set_var ('layout_url', $_CONF['layout_url']); + $cal_templates->set_var('mode', $mode); + $cal_templates->set_var('lang_week', $LANG_CAL_2[27]); + if ($mode == 'personal') { + $cal_templates->set_var('calendar_title', '[' . $LANG_CAL_2[28] . ' ' . COM_getDisplayName()); + $cal_templates->set_var('calendar_toggle', '| ' + . COM_createLink($LANG_CAL_2[11], $_CONF['site_url'] + . "/calendar/index.php?view=week&month=$month&day=$day&year=$year") . ']' + ); + } else { + $cal_templates->set_var('calendar_title', '[' . $_CONF['site_name'] . ' ' . $LANG_CAL_2[29]); + if (!empty($_USER['uid']) AND $_CA_CONF['personalcalendars'] == 1) { + $cal_templates->set_var('calendar_toggle', '| ' + . COM_createLink($LANG_CAL_2[12], $_CONF['site_url'] + . "/calendar/index.php?mode=personal&view=week&month=$month&day=$day&year=$year") . ']' + ); + } else { + $cal_templates->set_var('calendar_toggle', ']'); + } + } + if ($mode == 'personal') { + $cal_templates = getQuickAdd($cal_templates, $month, $day, $year, $token); + } else { + $cal_templates->set_var('quickadd_form',''); + } + // Get data for previous week + $prevstamp = mktime(0,0,0,$month,$day-7,$year); + $nextstamp = mktime(0,0,0,$month,$day+7,$year); + $cal_templates->set_var('prevmonth',strftime('%m',$prevstamp)); + $cal_templates->set_var('prevday',date('j',$prevstamp)); + $cal_templates->set_var('prevyear',strftime('%Y',$prevstamp)); + $cal_templates->set_var('nextmonth',strftime('%m',$nextstamp)); + $cal_templates->set_var('nextday',date('j',$nextstamp)); + $cal_templates->set_var('nextyear',strftime('%Y',$nextstamp)); + $cal_templates->set_var ('lang_day', $LANG_CAL_2[39]); + $cal_templates->set_var ('lang_week', $LANG_CAL_2[40]); + $cal_templates->set_var ('lang_month', $LANG_CAL_2[41]); + if ($_CONF['week_start'] == 'Mon') { + $time_day1 = mktime (0, 0, 0, $month, $day + 1, $year); + $time_day7 = mktime (0, 0, 0, $month, $day + 7, $year); + $start_mname = strftime ('%B', $time_day1); + $eday = strftime ('%e', $time_day7); + $end_mname = strftime ('%B', $time_day7); + $end_ynum = strftime ('%Y', $time_day7); + $date_range = $start_mname . ' ' . strftime ('%e', $time_day1); + } else { + $start_mname = strftime ('%B', mktime (0, 0, 0, $month, $day, $year)); + $time_day6 = mktime (0, 0, 0, $month, $day + 6, $year); + $eday = strftime ('%e', $time_day6); + $end_mname = strftime ('%B', $time_day6); + $end_ynum = strftime ('%Y', $time_day6); + $date_range = $start_mname . ' ' . $day; + } + if ($year <> $end_ynum) { + $date_range .= ', ' . $year . ' - '; + } else { + $date_range .= ' - '; + } + if ($start_mname <> $end_mname) { + $date_range .= $end_mname . ' ' . $eday . ', ' . $end_ynum; + } else { + $date_range .= $eday . ', ' . $end_ynum; + } + $cal_templates->set_var('date_range', $date_range); + if ($_CONF['week_start'] == 'Mon') { + $thedate = COM_getUserDateTimeFormat (mktime (0, 0, 0, $month, $day + 1,$year)); + } else { + $thedate = COM_getUserDateTimeFormat (mktime (0, 0, 0, $month, $day, $year)); + } + $cal_templates->set_var('week_num',$thedate[1]); + for ($i = 1; $i <= 7; $i++) { + if ($_CONF['week_start'] == 'Mon') { + $dayname = (date ('w', $thedate[1]) == 0) + ? $cal->getDayName (7) + : $cal->getDayName (date ('w', $thedate[1])); + } else { + $dayname = $cal->getDayName (date ('w', $thedate[1]) + 1); + } + $monthnum = date('m', $thedate[1]); + $daynum = date('d', $thedate[1]); + $yearnum = date('Y', $thedate[1]); + if ($yearnum . '-' . $monthnum . '-' . $daynum == date('Y-m-d',time())) { + $cal_templates->set_var('class'.$i,'weekview-curday'); + } else { + $cal_templates->set_var('class'.$i,'weekview-offday'); + } + $monthname = $cal->getMonthName($monthnum); + $cal_templates->set_var ('day' . $i, $dayname . ', ' + . COM_createLink( strftime ('%x', $thedate[1]), + $_CONF['site_url'] . '/calendar/index.php?' . addMode ($mode) + . "view=day&day$daynum&month=$monthnum&year=$yearnum") + ); + if ($mode == 'personal') { + $add_str = $LANG_CAL_2[8]; + } else { + $add_str = $LANG_CAL_2[42]; + } + + $cal_templates->set_var ('langlink_addevent' . $i, + COM_createLink($add_str, $_CONF['site_url'] . '/submit.php?type=calendar&' + . addMode ($mode) . "day=$daynum&month=$monthnum&year=$yearnum") + ); + if ($mode == 'personal') { + $calsql = "SELECT eid,title,datestart,dateend,timestart,timeend,allday,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon FROM {$_TABLES['personal_events']} WHERE (uid = {$_USER['uid']}) AND ((allday=1 AND datestart = \"$yearnum-$monthnum-$daynum\") OR (datestart >= \"$yearnum-$monthnum-$daynum 00:00:00\" AND datestart <= \"$yearnum-$monthnum-$daynum 23:59:59\") OR (dateend >= \"$yearnum-$monthnum-$daynum 00:00:00\" AND dateend <= \"$yearnum-$monthnum-$daynum 23:59:59\") OR (\"$yearnum-$monthnum-$daynum\" BETWEEN datestart AND dateend)) ORDER BY datestart,timestart"; + } else { + $calsql = "SELECT eid,title,datestart,dateend,timestart,timeend,allday,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon FROM {$_TABLES['events']} WHERE ((allday=1 AND datestart = \"$yearnum-$monthnum-$daynum\") OR (datestart >= \"$yearnum-$monthnum-$daynum 00:00:00\" AND datestart <= \"$yearnum-$monthnum-$daynum 23:59:59\") OR (dateend >= \"$yearnum-$monthnum-$daynum 00:00:00\" AND dateend <= \"$yearnum-$monthnum-$daynum 23:59:59\") OR (\"$yearnum-$monthnum-$daynum\" BETWEEN datestart AND dateend))" . COM_getPermSql ('AND') . " ORDER BY datestart,timestart"; + } + $result = DB_query($calsql); + $nrows = DB_numRows($result); + for ($j = 1; $j <= $nrows; $j++) { + $A = DB_fetchArray($result); + if ($A['allday'] == 1) { + $cal_templates->set_var('event_starttime', $LANG_CAL_2[26]); + $cal_templates->set_var('event_endtime',''); + } else { + $startstamp = strtotime($A['datestart'] . ' ' . $A['timestart']); + $endstamp = strtotime($A['dateend'] . ' ' . $A['timeend']); + $startday = date('d',$startstamp); + $startmonth = date('n',$startstamp); + $endday = date('d', $endstamp); + $endmonth = date('n',$endstamp); + if (($startmonth == $monthnum && $daynum > $startday) OR ($startmonth <> $monthnum)) { + $starttime = date('n/j g:i a',$startstamp); + } else { + $starttime = date('g:i a', $startstamp); + } + if (($endmonth == $monthnum && $daynum < $endday) OR ($endmonth <> $monthnum)) { + $endtime = date('n/j g:i a', $endstamp); + } else { + $endtime = date('g:i a', $endstamp); + } + $cal_templates->set_var('event_starttime', $starttime); + $cal_templates->set_var('event_endtime', ' - ' . $endtime); + } + $cal_templates->set_var ('event_title_and_link', + COM_createLink(stripslashes($A['title']), $_CONF['site_url'] + . '/calendar/event.php?' . addMode ($mode) + . 'eid=' . $A['eid']) + ); + // Provide delete event link if user has access + $cal_templates->set_var('delete_imagelink', + getDeleteImageLink($mode, $A, $token)); + $cal_templates->parse ('events_day' . $i, 'events', true); + } + if ($nrows == 0) { + $cal_templates->set_var('event_starttime',' '); + $cal_templates->set_var('event_endtime',''); + $cal_templates->set_var('event_title_and_link',''); + $cal_templates->set_var('delete_imagelink',''); + $cal_templates->parse('events_day'.$i,'events',true); + } + // Go to next day + $thedate = COM_getUserDateTimeFormat(mktime(0,0,0,$monthnum, $daynum + 1, $yearnum)); + } + + $display .= $cal_templates->parse('output','week'); + $display .= COM_siteFooter(); + break; + +case 'addentry': + $display .= plugin_submit_calendar($mode); + $display .= COM_siteFooter(); + break; + +case 'savepersonal': + if (SEC_checkToken()) { + $display = plugin_savesubmission_calendar($_POST); + } else { + $display = COM_refresh($_CONF['site_url'] . '/calendar/index.php'); + } + break; + +default: // month view +// Load templates + +$cal_templates = new Template($_CONF['path'] . 'plugins/calendar/templates'); +$cal_templates->set_file (array ( + 'calendar' => 'calendar.thtml', + 'week' => 'calendarweek.thtml', + 'day' => 'calendarday.thtml', + 'event' => 'calendarevent.thtml', + 'mastercal' => 'mastercalendaroption.thtml', + 'personalcal' => 'personalcalendaroption.thtml', + 'addevent' => 'addeventoption.thtml' + )); + +$cal_templates->set_var ( 'xhtml', XHTML ); +$cal_templates->set_var ('site_url', $_CONF['site_url']); +$cal_templates->set_var ('site_admin_url', $_CONF['site_admin_url']); +$cal_templates->set_var ('layout_url', $_CONF['layout_url']); +$cal_templates->set_var ('mode', $mode); +if ($mode == 'personal') { + $cal_templates->set_var ('start_block', COM_startBlock ($LANG_CAL_2[12])); + $cal_templates->set_var ('end_block', COM_endBlock ()); +} else { + $cal_templates->set_var ('start_block', COM_startBlock ($LANG_CAL_2[11])); + $cal_templates->set_var ('end_block', COM_endBlock ()); +} + +$smallcal_prev = getSmallCalendar ($prevmonth, $prevyear, $mode); +$cal_templates->set_var ('previous_months_calendar', $smallcal_prev); +$cal_templates->set_var ('previous_months_cal', + '<font size="-2">' . LB . $smallcal_prev . '</font>'); + +$smallcal_next = getSmallCalendar ($nextmonth, $nextyear, $mode); +$cal_templates->set_var ('next_months_calendar', $smallcal_next); +$cal_templates->set_var ('next_months_cal', + '<font size="-2">' . LB . $smallcal_next . '</font>'); + +$cal_templates->set_var('cal_prevmo_num', $prevmonth); +$cal_templates->set_var('cal_prevyr_num', $prevyear); +$cal_templates->set_var('cal_month_and_year', $cal->getMonthName($month) . ' ' . $year); +$cal_templates->set_var('cal_nextmo_num', $nextmonth); +$cal_templates->set_var('cal_nextyr_num', $nextyear); + +if ($_CONF['week_start'] == 'Mon') { + $cal_templates->set_var('lang_sunday', $LANG_WEEK[2]); + $cal_templates->set_var('lang_monday', $LANG_WEEK[3]); + $cal_templates->set_var('lang_tuesday', $LANG_WEEK[4]); + $cal_templates->set_var('lang_wednesday', $LANG_WEEK[5]); + $cal_templates->set_var('lang_thursday', $LANG_WEEK[6]); + $cal_templates->set_var('lang_friday', $LANG_WEEK[7]); + $cal_templates->set_var('lang_saturday', $LANG_WEEK[1]); +} else { + $cal_templates->set_var('lang_sunday', $LANG_WEEK[1]); + $cal_templates->set_var('lang_monday', $LANG_WEEK[2]); + $cal_templates->set_var('lang_tuesday', $LANG_WEEK[3]); + $cal_templates->set_var('lang_wednesday', $LANG_WEEK[4]); + $cal_templates->set_var('lang_thursday', $LANG_WEEK[5]); + $cal_templates->set_var('lang_friday', $LANG_WEEK[6]); + $cal_templates->set_var('lang_saturday', $LANG_WEEK[7]); +} + +$cal_templates->set_var('lang_january', $LANG_MONTH[1]); +if ($month == 1) $cal_templates->set_var('selected_jan','selected="selected"'); +$cal_templates->set_var('lang_february', $LANG_MONTH[2]); +if ($month == 2) $cal_templates->set_var('selected_feb','selected="selected"'); +$cal_templates->set_var('lang_march', $LANG_MONTH[3]); +if ($month == 3) $cal_templates->set_var('selected_mar','selected="selected"'); +$cal_templates->set_var('lang_april', $LANG_MONTH[4]); +if ($month == 4) $cal_templates->set_var('selected_apr','selected="selected"'); +$cal_templates->set_var('lang_may', $LANG_MONTH[5]); +if ($month == 5) $cal_templates->set_var('selected_may','selected="selected"'); +$cal_templates->set_var('lang_june', $LANG_MONTH[6]); +if ($month == 6) $cal_templates->set_var('selected_jun','selected="selected"'); +$cal_templates->set_var('lang_july', $LANG_MONTH[7]); +if ($month == 7) $cal_templates->set_var('selected_jul','selected="selected"'); +$cal_templates->set_var('lang_august', $LANG_MONTH[8]); +if ($month == 8) $cal_templates->set_var('selected_aug','selected="selected"'); +$cal_templates->set_var('lang_september', $LANG_MONTH[9]); +if ($month == 9) $cal_templates->set_var('selected_sep','selected="selected"'); +$cal_templates->set_var('lang_october', $LANG_MONTH[10]); +if ($month == 10) $cal_templates->set_var('selected_oct','selected="selected"'); +$cal_templates->set_var('lang_november', $LANG_MONTH[11]); +if ($month == 11) $cal_templates->set_var('selected_nov','selected="selected"'); +$cal_templates->set_var('lang_december', $LANG_MONTH[12]); +if ($month == 12) $cal_templates->set_var('selected_dec','selected="selected"'); + +$cal_templates->set_var('lang_day', $LANG_CAL_2[39]); +$cal_templates->set_var('lang_week', $LANG_CAL_2[40]); +$cal_templates->set_var('lang_month', $LANG_CAL_2[41]); + +if ($mode == 'personal') { + $cal_templates->set_var ('calendar_title', + $LANG_CAL_2[28] . ' ' . COM_getDisplayName()); +} else { + $cal_templates->set_var ('calendar_title', + $_CONF['site_name'] . ' ' . $LANG_CAL_2[29]); +} + +$yroptions = ''; +for ($y = $currentyear - 5; $y <= $currentyear + 5; $y++) { + $yroptions .= '<option value="' . $y . '"'; + if ($y == $year) { + $yroptions .= ' selected="selected"'; + } + $yroptions .= '>' . $y . '</option>'.LB; +} +$cal_templates->set_var('year_options', $yroptions); + +for ($i = 1; $i <= 6; $i++) { + $wday = ''; + for ($j = 1; $j <= 7; $j++) { + $curday = $cal->getDayData($i, $j); + if (!empty($curday)) { + // Cache first actual day of the week to build week view link + if (empty($wday)) { + $wday = $curday->daynumber; + } + if (($currentyear > $year) OR + ($currentmonth > $month && $currentyear == $year) OR + ($currentmonth == $month && $currentday > $curday->daynumber && $currentyear == $year)) { + $cal_templates->set_var('cal_day_style', 'cal-oldday'); + } else { + if ($currentyear == $year && $currentmonth == $month && $currentday == $curday->daynumber) { + $cal_templates->set_var('cal_day_style','cal-today'); + } else { + $cal_templates->set_var('cal_day_style', 'cal-futureday'); + } + } + + if (strlen($curday->daynumber) == 1) { + $curday->daynumber = '0' . $curday->daynumber; + } + + $cal_templates->set_var ('cal_day_anchortags', + COM_createLink($curday->daynumber, $_CONF['site_url'] + . '/calendar/index.php?view=day&' . addMode ($mode) + . 'day=' . $curday->daynumber . "&month=$month&year=$year", + array('class'=>'cal-date')) + . '<hr' . XHTML . '>' + ); + + if (strlen($month) == 1) { + $month = '0' . $month; + } + + if ($mode == 'personal') { + $calsql_tbl = $_TABLES['personal_events']; + $calsql_filt = "AND (uid = {$_USER['uid']})"; + } else { + $calsql_tbl = $_TABLES['events']; + $calsql_filt = COM_getPermSql ('AND'); + } + + $calsql = "SELECT eid,title,datestart,dateend,timestart,timeend,allday,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon FROM $calsql_tbl WHERE " + . "((datestart >= \"$year-$month-$curday->daynumber 00:00:00\" " + . "AND datestart <= \"$year-$month-$curday->daynumber 23:59:59\") " + . "OR (dateend >= \"$year-$month-$curday->daynumber 00:00:00\" " + . "AND dateend <= \"$year-$month-$curday->daynumber 23:59:59\") " + . "OR (\"$year-$month-$curday->daynumber\" BETWEEN datestart AND dateend))" + . $calsql_filt . " ORDER BY datestart,timestart"; + + $query2 = DB_query($calsql); + $q2_numrows = DB_numRows($query2); + + if ($q2_numrows > 0) { + $entries = ''; + for ($z = 1; $z <= $q2_numrows; $z++) { + $results = DB_fetchArray ($query2); + if ($results['title']) { + $cal_templates->set_var ('cal_day_entries', ''); + $entries .= + COM_createLink( + stripslashes ($results['title']), + $_CONF['site_url'] . '/calendar/event.php?' . addMode ($mode) + . 'eid=' . $results['eid'], + array('class'=>'cal-event')) + . '<hr' . XHTML . '>'; + } + } + for ($z = $z; $z <= 4; $z++) { + $entries .= '<br' . XHTML . '>'; + } + + $cal_templates->set_var('event_anchortags', $entries); + + } else { + if ($q2_numrows < 4) { + for ($t=0; $t < (4 - $q2_numrows); $t++) { + $cal_templates->set_var('cal_day_entries','<br' . XHTML . '><br' . XHTML . '><br' . XHTML . '><br' . XHTML . '>'); + } + } + } + + $cal_templates->parse('cal_day_entries', 'event', true); + $cal_templates->set_var('event_anchortags',''); + } else { + if ($i > 1) { + // Close out calendar if needed + for ($k = $j; $k <= 7; $k++) { + $cal_templates->set_var('cal_day_style','cal-nullday'); + $cal_templates->set_var('cal_day_anchortags', ''); + $cal_templates->set_var('cal_day_entries',' '); + if ($k < 7) $cal_templates->parse('cal_days', 'day', true); + } + // for looping to stop...we are done now + $i = 7; + $j = 8; + } else { + // Print empty box for any days in the first week that occur + // before the first day + $cal_templates->set_var('cal_day_style','cal-nullday'); + $cal_templates->set_var('cal_day_anchortags', ''); + $cal_templates->set_var('cal_day_entries',' '); + } + } + $cal_templates->parse('cal_days','day',true); + } + list($wmonth, $wday, $wyear) = getPriorSunday($month, $wday, $year); + $cal_templates->set_var('wmonth', $wmonth); + $cal_templates->set_var('wday', $wday); + $cal_templates->set_var('wyear', $wyear); + $cal_templates->parse('cal_week', 'week',true); + $cal_templates->set_var('cal_days',''); + + // check if we need to render the following week at all + if ($i < 6) { + $data = $cal->getDayData ($i + 1, 1); + if (empty ($data)) { + break; + } + } +} + +if ($mode == 'personal') { + $cal_templates->set_var('lang_mastercal', $LANG_CAL_2[25] . $LANG_CAL_2[11]); + $cal_templates->parse('master_calendar_option','mastercal',true); +} else { + if (isset ($_USER['uid']) && ($_USER['uid'] > 1) && + ($_CA_CONF['personalcalendars'] == 1)) { + $cal_templates->set_var('lang_mycalendar', $LANG_CAL_2[12]); + $cal_templates->parse('personal_calendar_option','personalcal',true); + } else { + $cal_templates->set_var('personal_calendar_option',' '); + } +} + + +$cal_templates->set_var('lang_cal_curmo', $LANG_MONTH[$currentmonth + 0]); +$cal_templates->set_var('cal_curmo_num', $currentmonth); +$cal_templates->set_var('cal_curyr_num', $currentyear); +$cal_templates->set_var('lang_cal_displaymo', $LANG_MONTH[$month + 0]); +$cal_templates->set_var('cal_displaymo_num', $month); +$cal_templates->set_var('cal_displayyr_num', $year); +if ($mode == 'personal') { + $cal_templates->set_var('lang_addevent', $LANG_CAL_2[8]); + $cal_templates->set_var('addevent_formurl', '/calendar/index.php'); +} else { + $cal_templates->set_var('lang_addevent', $LANG_CAL_2[42]); + $cal_templates->set_var('addevent_formurl', '/submit.php?type=calendar'); +} +$cal_templates->parse('add_event_option','addevent',true); +$cal_templates->parse('output','calendar'); +$display .= $cal_templates->finish($cal_templates->get_var('output')); + +$display .= COM_siteFooter(); +break; + +} // end switch + +echo $display; + +?> Added: externals/geeklog-1.5.2sr2/public_html/calendar/style.css ============================================================================== --- (empty file) +++ externals/geeklog-1.5.2sr2/public_html/calendar/style.css Sun Apr 5 18:12:05 2009 @@ -0,0 +1,161 @@ +/* Calendar Plugin */ + +.cal-body { + background:#FFFFFF; + border-bottom:#E7E7E7 1px solid; + border-left:#E7E7E7 1px solid; + border-right:#E7E7E7 1px solid; + border-top:#E7E7E7 1px solid; + color:#000000; + font-weight:bold; +} +.cal-day, +.cal_day { + background:transparent; + border-bottom:#F7F7F7 1px dashed; + border-left:#F7F7F7 1px dashed; + border-top:#1A3955 2px solid; + color:#000000; + font-weight:bold; +} +.cal-dayview-times { + background:#F7F7F7; + border-bottom:#E7E7E7 1px solid; + border-left:#E7E7E7 1px solid; + border-right:#E7E7E7 1px solid; + border-top:#1A3955 1px dashed; + color:#000000; + font-weight:bold; + font-size:.8em; +} +.cal-dayx-body { + background:#E7E7E7 +} +.cal-dayx-cur { + background:#FFFFFF; + color:#000000; + font-weight:bold; + font-size:.8em; +} +.cal-dayx-subcur { + background:#FFFFFF; + color:#000000; + font-weight:bold; + font-size:.8em; + padding-top:4px; +} +.cal-dayx-times { + border-bottom:#FFFFFF 1px solid; + border-left:#FFFFFF 1px solid; + border-right:#FFFFFF 1px solid; +} +.cal-dayx-times2 { + background:#FFFFFF +} +.cal-dayx-weekevent { + border-bottom:#FFFFFF 1px solid; + border-left:#FFFFFF 1px dashed; + border-right:#FFFFFF 1px dashed; + border-top:#E7E7E7 1px solid; +} +.cal-futureday { + background:#F7F7F7 +} +.cal-header { + background:#FFFFFF; + border-bottom:#F7F7F7 1px solid; + border-left:#F7F7F7 1px solid; + border-right:#F7F7F7 1px solid; + border-top:#F7F7F7 1px solid; +} +.cal-hr { + background:#FFFFFF +} +.cal-month, +.cal_month { + background:#F7F7F7; + color:#000000; + font-size:.9em; +} +.cal-nullday { + background:#FFFFFF; + border-bottom:#F7F7F7 1px dashed; + border-left:#F7F7F7 1px dashed; + border-top:#F7F7F7 1px dashed; + color:#000000; +} +.cal-oldday { + background:#E7E7E7; + color:#000000; +} +.cal-quickadd, +.quickadd { + background:#F7F7F7; + border-bottom:#E7E7E7 1px solid; + border-left:#E7E7E7 1px solid; + border-right:#E7E7E7 1px solid; + border-top:#E7E7E7 1px solid; + padding:4px; +} +.cal-today { + background:#FFFFFF; + border-bottom:#1A3955 1px dashed; + border-left:#1A3955 1px dashed; + border-right:#1A3955 1px dashed; + border-top:#1A3955 1px dashed; +} +.cal-weekpointers { + border-bottom:#F7F7F7 1px dashed; + border-left:#F7F7F7 1px dashed; +} +.cal-weekview-addevent { + background:#FFFFFF; + border-right:#E7E7E7 1px solid; + border-top:#E7E7E7 1px solid; + color:#000000; + font-weight:bold; + font-size:.8em; + padding:4px; +} +.cal-weekview-caltitle { + background:#FFFFFF; + border-bottom:#E7E7E7 1px solid; + border-left:#E7E7E7 1px solid; + border-right:#E7E7E7 1px solid; + color:#000000; + font-weight:bold; + font-size:.8em; + padding:4px; +} +.cal-weekview-curday, +.weekview_curday { + background:#F7F7F7; + color:#000000; +} +.cal-weekview-daterange { + background:#FFFFFF; + border-left:#E7E7E7 1px solid; + border-right:#E7E7E7 1px solid; + border-top:#E7E7E7 1px solid; + color:#000000; + font-weight:bold; + font-size:.8em; + padding:4px; +} +.cal-weekview-dayformat { + background:#FFFFFF; + border-left:#E7E7E7 1px solid; + border-top:#E7E7E7 1px solid; + color:#000000; + font-weight:bold; + font-size:.8em; padding:4px; +} +.cal-weekview-offday, +.weekview_offday { + background:transparent; + color:#000000; +} +.smallcal-week-even { + background:#E7E7E7; + color:#000000; +} \ No newline at end of file