forked from horde/kronolith
-
Notifications
You must be signed in to change notification settings - Fork 0
/
new.php
92 lines (80 loc) · 2.91 KB
/
new.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
<?php
/**
* Copyright 1999-2017 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (GPL). If you
* did not receive this file, see http://www.horde.org/licenses/gpl.
*
* @author Chuck Hagenbuch <chuck@horde.org>
*/
require_once __DIR__ . '/lib/Application.php';
Horde_Registry::appInit('kronolith');
if (Kronolith::showAjaxView()) {
Horde::url('', true)->setAnchor('event')->redirect();
}
/* Check permissions. */
$url = Horde::url($prefs->getValue('defaultview') . '.php', true)
->add(array('month' => Horde_Util::getFormData('month'),
'year' => Horde_Util::getFormData('year')));
$perms = $GLOBALS['injector']->getInstance('Horde_Core_Perms');
if ($perms->hasAppPermission('max_events') !== true &&
$perms->hasAppPermission('max_events') <= Kronolith::countEvents()) {
Horde::permissionDeniedError(
'kronolith',
'max_events',
sprintf(_("You are not allowed to create more than %d events."), $perms->hasAppPermission('max_events'))
);
$url->redirect();
}
$display_resource = $GLOBALS['calendar_manager']->get(Kronolith::DISPLAY_RESOURCE_CALENDARS);
$calendar_id = Horde_Util::getFormData(
'calendar',
empty($display_resource) ?
'internal_' . Kronolith::getDefaultCalendar(Horde_Perms::EDIT) :
'resource_' . $display_resource[0]
);
if ($calendar_id == 'internal_' || $calendar_id == 'resource_') {
$url->redirect();
}
$event = Kronolith::getDriver()->getEvent();
$session->set('kronolith', 'attendees', $event->attendees);
$session->set('kronolith', 'resources', $event->getResources());
$date = Horde_Util::getFormData('datetime');
if ($date) {
$event->start = new Horde_Date($date);
} else {
$date = Horde_Util::getFormData('date', date('Ymd')) . '000600';
$event->start = new Horde_Date($date);
if ($prefs->getValue('twentyFour')) {
$event->start->hour = 12;
}
}
$event->end = new Horde_Date($event->start);
if (Horde_Util::getFormData('allday')) {
$event->end->mday++;
} else {
// Default to a 1 hour duration.
$event->end->hour++;
}
$month = $event->start->month;
$year = $event->start->year;
$buttons = array('<input type="submit" class="horde-default" name="save" value="' . _("Save Event") . '" />');
$url = Horde_Util::getFormData('url');
if (isset($url)) {
$cancelurl = new Horde_Url($url);
} else {
$cancelurl = Horde::url('month.php', true)->add('month', $month);
}
$calendars = Kronolith::listCalendars(Horde_Perms::EDIT | Kronolith::PERMS_DELEGATE, true);
Horde_Core_Ui_JsCalendar::init(array(
'full_weekdays' => true
));
$page_output->addScriptFile('edit.js');
$page_output->addScriptFile('popup.js', 'horde');
$page_output->header(array(
'title' => _("Add a new event")
));
require KRONOLITH_TEMPLATES . '/javascript_defs.php';
$notification->notify(array('listeners' => 'status'));
require KRONOLITH_TEMPLATES . '/edit/edit.inc';
$page_output->footer();