forked from castlamp/zenbership
-
Notifications
You must be signed in to change notification settings - Fork 0
/
calendar.php
125 lines (114 loc) · 3.23 KB
/
calendar.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<?php
/**
*
*
* Zenbership Membership Software
* Copyright (C) 2013-2016 Castlamp, LLC
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*
* @author Castlamp
* @link http://www.castlamp.com/
* @link http://www.zenbership.com/
* @copyright (c) 2013-2016 Castlamp
* @license http://www.gnu.org/licenses/gpl-3.0.en.html
* @project Zenbership Membership Software
*/
// Load the basics
require "admin/sd-system/config.php";
// Check a user's session
$session = new session;
$ses = $session->check_session();
// Calendar ID
if (empty($_GET['id'])) {
$calendar_id = '1';
} else {
$calendar_id = $_GET['id'];
}
// Generate the calendar
$empty_date = 0;
if (empty($_GET['year'])) {
$year = date('Y');
$empty_date++;
} else {
if (is_numeric($_GET['year'])) {
$year = $_GET['year'];
} else {
$year = date('Y');
}
}
if (empty($_GET['month'])) {
$month = date('m');
$empty_date++;
} else {
if ($_GET['month'] > 0 && $_GET['month'] <= 12) {
$month = $_GET['month'];
} else {
$month = date('m');
}
}
if (empty($_GET['day'])) {
$day = '';
} else {
if ($_GET['day'] > 0 && $_GET['day'] <= 31) {
$day = $_GET['day'];
} else {
$day = '';
}
}
if (empty($_GET['tags'])) {
$tags = '';
} else {
$tags = $_GET['tags'];
}
$event = new event($year, $month, $calendar_id, $day, $tags);
// Find first available event
if ($empty_date == 2) {
$next_event = $event->next_event_on_calendar($calendar_id);
if (! empty($next_event)) {
$blowup = explode(' ', $next_event['starts']);
$blowupdate = explode('-', $blowup['0']);
$year = $blowupdate['0'];
$month = $blowupdate['1'];
$event->setYear($year);
$event->setMonth($month);
}
}
// Accessible?
$get_calendar = $event->get_calendar($calendar_id);
if ($get_calendar['members_only'] == '1' && $ses['error'] == '1') {
$session->reject('login', 'L004');
exit;
}
if (!empty($_GET['export'])) {
$event->export_calendar($year, $month, $day);
exit;
} else {
if (! empty($day)) {
$calendar = $event->generate_day_calendar($year, $month, $day, $calendar_id, $tags);
} else {
$calendar = $event->generate_calendar($year, $month, $calendar_id, $tags);
}
}
$calendar['label_legend'] = $event->build_label_legend();
$calendar['month'] = $month;
$calendar['year'] = $year;
$calendar['calendar_id'] = $calendar_id;
if ($get_calendar['style'] == '2') {
$template = new template('calendar_long', $calendar, '1');
} else {
$template = new template('calendar', $calendar, '1');
}
echo $template;
exit;