~sit-developers/sit/master

1 by Ivan Lucas
Initial commit (ported from sourceforge svn trunk)
1
<?php
2
// calendar.php
3
//
4
// SiT (Support Incident Tracker) - Support call tracking system
1239.1.66 by Paul Heaney
update copyright
5
// Copyright (C) 2010-2014 The Support Incident Tracker Project
1 by Ivan Lucas
Initial commit (ported from sourceforge svn trunk)
6
// Copyright (C) 2000-2009 Salford Software Ltd. and Contributors
7
//
8
// This software may be used and distributed according to the terms
9
// of the GNU General Public License, incorporated herein by reference.
10
//
11
12
// Author: Ivan Lucas <ivanlucas[at]users.sourceforge.net>
13
//         Tom Gerrard <tom.gerrard[at]salfordsoftware.co.uk>
14
762 by Ivan Lucas
Set $permission variable after including core.inc.php to fix Mantis 1632 page security no longer checked. Since we now use constants for permissions we need to include core first so that the constants are defined. (of course)
15
require ('core.php');
707.1.26 by Ivan Lucas
Use permissions constants
16
$permission = PERM_CALENDAR_VIEW; // View your calendar
1 by Ivan Lucas
Initial commit (ported from sourceforge svn trunk)
17
require (APPLICATION_LIBPATH . 'functions.inc.php');
18
19
// This page requires authentication
20
require (APPLICATION_LIBPATH . 'auth.inc.php');
21
include ('calendar/calendar.inc.php');
22
845 by Paul Heaney
allow viewing all for calendar Mantis 1726
23
$groupid = cleanvar($_REQUEST['gid']); // can be 'all'
158.1.8 by Ivan Lucas
Merge branch 'master' of gitorious.org:sit/sit into sit
24
if (empty($groupid)) $groupid = clean_int($_SESSION['groupid']);
1 by Ivan Lucas
Initial commit (ported from sourceforge svn trunk)
25
26
// External variables
158.1.8 by Ivan Lucas
Merge branch 'master' of gitorious.org:sit/sit into sit
27
$user = clean_int($_REQUEST['user']);
28
$nmonth = clean_int($_REQUEST['nmonth']);
29
$nyear = clean_int($_REQUEST['nyear']);
30
$type = clean_int($_REQUEST['type']);
31
$approved = clean_int($_REQUEST['approved']);
1059.1.1 by Paul Heaney
remove unused code in the year calendar which was never entered, this resolves a couple of fixmes, couple of the strings added yesterday are no longer required so removed
32
$length = clean_fixed_list($_REQUEST['length'], array('day', 'am', 'pm'));
33
$display = clean_fixed_list($_REQUEST['display'], array('month', 'list', 'year', 'week', 'day'));
158.1.8 by Ivan Lucas
Merge branch 'master' of gitorious.org:sit/sit into sit
34
$weeknumber = clean_int($weeknumber);
35
1 by Ivan Lucas
Initial commit (ported from sourceforge svn trunk)
36
$title = $strCalendar;
37
include (APPLICATION_INCPATH . 'htmlheader.inc.php');
38
159 by Paul Heaney
* Fix sql injection (Mantis 1395)
39
if (empty($user) || $user == 'current') $user = $sit[2];
1 by Ivan Lucas
Initial commit (ported from sourceforge svn trunk)
40
elseif ($user == 'all') $user = '';
41
if (empty($type)) $type = HOL_HOLIDAY;
707.1.27 by Ivan Lucas
Use permissions constants
42
if (user_permission($sit[2], PERM_HOLIDAY_APPROVE)) $approver = TRUE;
1 by Ivan Lucas
Initial commit (ported from sourceforge svn trunk)
43
else $approver = FALSE;
44
45
// Force user to 0 (SiT) when setting public holidays
46
if ($type == HOL_PUBLIC) $user = 0;
47
48
$gidurl = '';
49
if (!empty($groupid)) $gidurl = "&amp;gid={$groupid}";
50
51
// Defaults
52
if (empty($_REQUEST['year'])) $year = date('Y');
158.1.1 by Ivan Lucas
Input checking
53
else $year = intval($_REQUEST['year']);
1 by Ivan Lucas
Initial commit (ported from sourceforge svn trunk)
54
55
if (empty($_REQUEST['month'])) $month = date('m');
158.1.1 by Ivan Lucas
Input checking
56
else $month = intval($_REQUEST['month']);
1 by Ivan Lucas
Initial commit (ported from sourceforge svn trunk)
57
58
if (empty($_REQUEST['day'])) $day = date('d');
158.1.1 by Ivan Lucas
Input checking
59
else $day = intval($_REQUEST['day']);
1 by Ivan Lucas
Initial commit (ported from sourceforge svn trunk)
60
61
$calendarTypes = array('list','year','month','week','day');
62
63
// Prevent people from including any old file - this also handles any cases
64
// where $display == 'chart'
65
if (!in_array($display, $calendarTypes)) $display = 'month';
66
67
// Navigation (Don't show for public holidays)
68
if ($type != HOL_PUBLIC)
69
{
70
    echo "<p>{$strDisplay}: ";
71
    foreach ($calendarTypes as $navType)
72
    {
73
        $navHtml[$navType]  = "<a href='{$_SERVER['PHP_SELF']}?display={$navType}";
74
        $navHtml[$navType] .= "&amp;year={$year}&amp;month={$month}&amp;day={$day}";
75
        $navHtml[$navType] .= "&amp;type={$type}{$gidurl}'>";
76
        $navi18n = eval('return $str' . ucfirst($navType) . ';');
77
        if ($display == $navType) $navHtml[$navType] .= '<em>' . $navi18n . '</em>';
78
        else $navHtml[$navType] .= $navi18n;
79
        $navHtml[$navType] .= "</a>";
80
    }
81
    echo implode(' | ', $navHtml);
82
    echo "</p>";
83
}
84
include ("calendar/{$display}.inc.php");
85
86
include (APPLICATION_INCPATH . 'htmlfooter.inc.php');
555.1.3 by Ivan Lucas
Make forms more consistent. Add return without saving link to some forms where it was missing.
87
?>