home *** CD-ROM | disk | FTP | other *** search
- <?php
- /*
- Copyright Intermesh 2003
- Author: Merijn Schering <mschering@intermesh.nl>
- Version: 1.0 Release date: 08 July 2003
-
- 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.
- */
-
-
- //how many days does the user wants to see? (remember in cookie)
- $GO_CAL_SHOW_DAYS = isset($_COOKIE['GO_CAL_SHOW_DAYS']) ? $_COOKIE['GO_CAL_SHOW_DAYS'] : 7;
- $show_days = isset($_REQUEST['show_days']) ? $_REQUEST['show_days'] : $GO_CAL_SHOW_DAYS;
-
- SetCookie("GO_CAL_SHOW_DAYS",$show_days,time()+3600*24*30,"/",'',0);
-
- //are we in print view?
- $print = isset($_REQUEST['print']) ? true : false;
-
- require("../../Group-Office.php");
-
- $max_columns = 7;
-
- require_once($GO_CONFIG->class_path.'calendar.class.inc');
- $cal = new calendar();
-
- //get the local times
- $local_time = get_time();
- $year = isset($_REQUEST['year']) ? $_REQUEST['year'] : date("Y", $local_time);
- $month = isset($_REQUEST['month']) ? $_REQUEST['month'] : date("m", $local_time);
- $day = isset($_REQUEST['day']) ? $_REQUEST['day'] : date("j", $local_time);
- $hour = isset($_REQUEST['hour']) ? $_REQUEST['hour'] : date("H", $local_time);
- $min = isset($_REQUEST['min']) ? $_REQUEST['min'] : date("i", $local_time);
- $local_browse_time = mktime($hour, $min, 0, $month, $day, $year);
-
- //recalculate date
- $year = date("Y", $local_browse_time);
- $month = date("m", $local_browse_time);
- $day = date("j", $local_browse_time);
- $hour = date("H", $local_browse_time);
- $min = date("i", $local_browse_time);
-
-
- //get the current date properties
- $current_year = date("Y", $local_time);
- $current_month = date("m", $local_time);
- $current_day = date("j", $local_time);
- $current_hour = date("H", $local_time);
- $current_min = date("i", $local_time);
- $current_date = date(DB_DATE_FORMAT, $local_time);
-
- $hours = array("00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23");
- $mins = array("00","05","10","15","20","25","30","35","40","45","50","55");
-
- for ($i=1;$i<32;$i++)
- {
- $num_days[] = $i;
- }
-
- for ($i=1;$i<13;$i++)
- {
- $num_months[] = $i;
- }
-
-
- $years[0] = $year-4;
- $years[1] = $year-3;
- $years[2] = $year-2;
- $years[3] = $year-1;
- $years[4] = $year;
- $years[5] = $year+1;
- $years[6] = $year+2;
- $years[7] = $year+3;
- $years[8] = $year+4;
-
-
- $GO_SECURITY->authenticate();
- $GO_MODULES->authenticate('calendar');
- require($GO_LANGUAGE->get_language_file('calendar'));
-
- $task = isset($_REQUEST['task']) ? $_REQUEST['task'] : '';
- $return_to = isset($_POST['return_to']) ? $_POST['return_to'] : '';
-
- //get the calendar to display. If there isn't any create one
- $calendar_id = isset($_REQUEST['calendar_id']) ? $_REQUEST['calendar_id'] : $cal->get_default_calendar($GO_SECURITY->user_id);
-
- if (!$calendar_id)
- {
- require_once($GO_CONFIG->class_path.'users.class.inc');
- $users = new users();
- $user = $users->get_user($GO_SECURITY->user_id);
- $calendar_name = $user["first_name"].' '.$user['last_name'];
- $new_calendar_name = $calendar_name;
- $x = 1;
- while($cal->get_calendar_by_name($new_calendar_name))
- {
- $new_calendar_name = $calendar_name.' ('.$x.')';
- $x++;
- }
-
- if (!$calendar_id = $cal->add_calendar($GO_SECURITY->user_id, $user["first_name"].' '.$user['last_name'], '0', '23'))
- {
- $feedback = '<p class="Error">'.$strSaveError.'</p>';
- }
- }
-
- //get the calendar properties and check permissions
- if ($calendar = $cal->get_calendar($calendar_id))
- {
- $calendar['read_permission'] = $GO_SECURITY->has_permission($GO_SECURITY->user_id, $calendar['acl_read']);
- $calendar['write_permission'] = $GO_SECURITY->has_permission($GO_SECURITY->user_id, $calendar['acl_write']);
- if (!$calendar['read_permission'] && !$calendar['write_permission'] )
- {
- header('Location: '.$GO_CONFIG->host.'error_docs/401.php');
- exit();
- }
-
- }
- //automatically refresh this page
- //$auto_refresh_url = $GO_CONFIG->protocol.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
-
- if (!$print) {
- $datepicker = new date_picker();
- $GO_HEADER['head'] = $datepicker->get_header();
- require($GO_THEME->theme_path."header.inc");
- ?>
- <script type="text/javascript">
- function date_picker(calendar) {
- // Beware that this function is called even if the end-user only
- // changed the month/year. In order to determine if a date was
- // clicked you can use the dateClicked property of the calendar:
- if (calendar.dateClicked) {
- // OK, a date was clicked, redirect to /yyyy/mm/dd/index.php
- var y = calendar.date.getFullYear();
- var m = calendar.date.getMonth()+1; // integer, 0..11
- var d = calendar.date.getDate(); // integer, 1..31
- // redirect...
- window.location = "index.php?calendar_id=<?php echo $calendar_id; ?>&show_days=<?php echo $show_days; ?>&day="+d+"&month="+m+"&year="+y;
- }
- };
-
- function goto_date(day, month, year)
- {
- document.forms[0].day.value = day;
- document.forms[0].month.value = month;
- document.forms[0].year.value = year;
- document.forms[0].submit();
- }
- </script>
-
- <table border="0" cellpadding="0" cellspacing="0">
- <tr>
- <td class="ModuleIcons"><a href="event.php" class="small"><img src="<?php echo $GO_THEME->images['cal_compose']; ?>" border="0" width="32" height="32" /><br /><?php echo $sc_new_app; ?></a></td>
- <td class="ModuleIcons"><a href="<?php echo $_SERVER['PHP_SELF']; ?>?show_days=1&calendar_id=<?php echo $calendar_id; ?>&day=<?php echo $day; ?>&month=<?php echo $month; ?>&year=<?php echo $year; ?>" class="small"><img src="<?php echo $GO_THEME->images['cal_day']; ?>" border="0" width="32" height="32" /><br /><?php echo $sc_day_view; ?></a></td>
- <td class="ModuleIcons"><a href="<?php echo $_SERVER['PHP_SELF']; ?>?show_days=7&calendar_id=<?php echo $calendar_id; ?>&day=<?php echo $day; ?>&month=<?php echo $month; ?>&year=<?php echo $year; ?>" class="small"><img src="<?php echo $GO_THEME->images['cal_week']; ?>" border="0" width="32" height="32" /><br /><?php echo $sc_week_view; ?></a></td>
- <td class="ModuleIcons"><a href="<?php echo $_SERVER['PHP_SELF']; ?>?show_days=35&calendar_id=<?php echo $calendar_id; ?>&day=<?php echo $day; ?>&month=<?php echo $month; ?>&year=<?php echo $year; ?>" class="small"><img src="<?php echo $GO_THEME->images['cal_month']; ?>" border="0" width="32" height="32" /><br /><?php echo $sc_month_view; ?></a></td>
- <td class="ModuleIcons"><a href="<?php echo $_SERVER['PHP_SELF']; ?>?show_days=<?php echo $show_days; ?>&calendar_id=<?php echo $calendar_id; ?>&day=<?php echo $day; ?>&month=<?php echo $month; ?>&year=<?php echo $year; ?>&task=list_view" class="small"><img src="<?php echo $GO_THEME->images['cal_list']; ?>" border="0" width="32" height="32" /><br /><?php echo $sc_list_view; ?></a></td>
- <td class="ModuleIcons"><a href="calendars.php?return_to=<?php echo $_SERVER['REQUEST_URI']; ?>" class="small"><img src="<?php echo $GO_THEME->images['cal_calendar']; ?>" border="0" width="32" height="32" /><br /><?php echo $sc_calendars; ?></a></td>
- <td class="ModuleIcons"><a href="<?php echo $_SERVER['REQUEST_URI']; ?>" class="small"><img src="<?php echo $GO_THEME->images['cal_refresh']; ?>" border="0" width="32" height="32" /><br /><?php echo $sc_refresh; ?></a></td>
- <td class="ModuleIcons"><a href="javascript:popup('<?php echo $GO_MODULES->url; ?>index.php?print=true&show_days=<?php echo $show_days; ?>&calendar_id=<?php echo $calendar_id; ?>&day=<?php echo $day; ?>&month=<?php echo $month; ?>&year=<?php echo $year; ?>','','')" class="small"><img src="<?php echo $GO_THEME->images['cal_print']; ?>" border="0" width="32" height="32" /><br /><?php echo $cmdPrint; ?></a></td>
- </tr>
- </table>
- <form name="calendar_form" method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
- <input type="hidden" name="task" value="<?php echo $task; ?>" />
- <input type="hidden" name="year" value="<?php echo $year; ?>" />
- <input type="hidden" name="month" value="<?php echo $month; ?>" />
- <input type="hidden" name="day" value="<?php echo $day; ?>" />
-
- <table border="0" cellpadding="0" cellspacing="0" width="100%">
- </tr>
- <tr>
- <td valign="top" style="width: 18em;">
- <?php
- if ($cal->get_subscribed($GO_SECURITY->user_id) > 1)
- {
- echo '<table border="0"><tr><td><h3>'.$sc_calendar.':</h3></td><td>';
- $dropbox = new dropbox();
- $dropbox->add_sql_data("cal","id","name");
- $dropbox->print_dropbox("calendar_id", $calendar_id, 'onchange="javascript:document.forms[0].submit()"');
- echo '</td></tr></table>';
- }
- ?>
- <div id="date_picker1_container" style="margin-right: 1em;"></div>
- <div style="height: 2em;"></div>
- <div id="date_picker2_container" style="margin-right: 1em;"></div>
- </td>
- <td valign="top">
- <?php
-
- }else
- {
- require($GO_THEME->theme_path."simple_header.inc");
- }
-
- require_once($GO_CONFIG->class_path.'cal_holidays.class.inc');
- $holidays = new holidays($GO_LANGUAGE);
-
- if ($task == 'list_view')
- {
- require('list_view.inc');
- }else
- {
- require('calendar.inc');
- }
-
-
- if (!$print)
- {
- ?>
- </td>
- </tr>
- </table>
- </form>
- <?php
- require($GO_THEME->theme_path."footer.inc");
-
- $next_month = $month+1;
- $datepicker->print_date_picker('date_picker1', '',$month.'/'.$day.'/'.$year, 'date_picker1_container', 'date_picker');
- $datepicker->print_date_picker('date_picker2', '',$next_month.'/'.$day.'/'.$year, 'date_picker2_container', 'date_picker');
-
- }else
- {
- echo "\n<script type=\"text/javascript\">\nwindow.print();\n</script>\n";
- require($GO_THEME->theme_path."simple_footer.inc");
- }
- ?>
-