2011-12-01 21:31:17 +00:00
|
|
|
<?php
|
|
|
|
// MyDMS. Document Management System
|
|
|
|
// Copyright (C) 2002-2005 Markus Westphal
|
|
|
|
// Copyright (C) 2006-2008 Malcolm Cowe
|
|
|
|
// Copyright (C) 2010 Matteo Lucarelli
|
2016-08-09 05:34:30 +00:00
|
|
|
// Copyright (C) 2010-2106 Uwe Steinmann
|
2011-12-01 21:31:17 +00:00
|
|
|
//
|
|
|
|
// 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
include("../inc/inc.Settings.php");
|
|
|
|
include("../inc/inc.Utils.php");
|
2022-11-09 05:40:50 +00:00
|
|
|
include("../inc/inc.LogInit.php");
|
2014-12-08 13:47:32 +00:00
|
|
|
include("../inc/inc.Init.php");
|
|
|
|
include("../inc/inc.Extension.php");
|
2010-10-29 13:19:51 +00:00
|
|
|
include("../inc/inc.DBInit.php");
|
2011-12-01 21:31:17 +00:00
|
|
|
include("../inc/inc.Language.php");
|
2010-10-29 13:19:51 +00:00
|
|
|
include("../inc/inc.ClassUI.php");
|
2017-02-21 16:26:16 +00:00
|
|
|
include("../inc/inc.ClassCalendar.php");
|
2011-12-01 21:31:17 +00:00
|
|
|
include("../inc/inc.Authentication.php");
|
2010-10-29 13:19:51 +00:00
|
|
|
|
2010-12-03 07:22:56 +00:00
|
|
|
if ($user->isGuest()) {
|
2010-11-05 21:44:05 +00:00
|
|
|
UI::exitError(getMLText("edit_event"),getMLText("access_denied"));
|
|
|
|
}
|
|
|
|
|
2021-01-25 08:00:03 +00:00
|
|
|
/* Check if the form data comes from a trusted request */
|
|
|
|
if(!checkFormKey('addevent')) {
|
|
|
|
UI::exitError(getMLText("folder_title", array("foldername" => getMLText("invalid_request_token"))),getMLText("invalid_request_token"));
|
|
|
|
}
|
|
|
|
|
2012-12-14 08:25:02 +00:00
|
|
|
if (!isset($_POST["from"]) && !(isset($_POST["frommonth"]) && isset($_POST["fromday"]) && isset($_POST["fromyear"])) ) {
|
2011-12-01 21:31:17 +00:00
|
|
|
UI::exitError(getMLText("add_event"),getMLText("error_occured"));
|
2010-10-29 13:19:51 +00:00
|
|
|
}
|
2011-12-01 21:31:17 +00:00
|
|
|
|
2012-12-14 08:25:02 +00:00
|
|
|
if (!isset($_POST["to"]) && !(isset($_POST["tomonth"]) && isset($_POST["today"]) && isset($_POST["toyear"])) ) {
|
2011-12-01 21:31:17 +00:00
|
|
|
UI::exitError(getMLText("add_event"),getMLText("error_occured"));
|
2010-10-29 13:19:51 +00:00
|
|
|
}
|
2011-12-01 21:31:17 +00:00
|
|
|
|
|
|
|
if (!isset($_POST["name"]) || !isset($_POST["comment"]) ) {
|
|
|
|
UI::exitError(getMLText("add_event"),getMLText("error_occured"));
|
2010-10-29 13:19:51 +00:00
|
|
|
}
|
2011-12-01 21:31:17 +00:00
|
|
|
|
2011-12-02 18:44:42 +00:00
|
|
|
$name = $_POST["name"];
|
|
|
|
$comment = $_POST["comment"];
|
2012-12-14 08:25:02 +00:00
|
|
|
if(isset($_POST["from"])) {
|
2020-12-17 12:41:00 +00:00
|
|
|
$from = makeTsFromDate($_POST["from"]);
|
|
|
|
// $tmp = explode('-', $_POST["from"]);
|
|
|
|
// $from = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]);
|
2012-12-14 08:25:02 +00:00
|
|
|
} else {
|
|
|
|
$from = mktime(0,0,0, intval($_POST["frommonth"]), intval($_POST["fromday"]), intval($_POST["fromyear"]));
|
|
|
|
}
|
|
|
|
if(isset($_POST["to"])) {
|
2020-12-17 12:41:00 +00:00
|
|
|
$to = makeTsFromDate($_POST["to"])+86400;
|
|
|
|
// $tmp = explode('-', $_POST["to"]);
|
|
|
|
// $to = mktime(23,59,59, $tmp[1], $tmp[2], $tmp[0]);
|
2012-12-14 08:25:02 +00:00
|
|
|
} else {
|
|
|
|
$to = mktime(23,59,59, intval($_POST["tomonth"]), intval($_POST["today"]), intval($_POST["toyear"]));
|
|
|
|
}
|
2010-10-29 13:19:51 +00:00
|
|
|
|
2012-12-14 08:25:02 +00:00
|
|
|
if ($to<=$from){
|
2014-04-01 09:12:54 +00:00
|
|
|
// $to = $from + 86400 -1;
|
|
|
|
UI::exitError(getMLText("add_event"),getMLText("to_before_from"));
|
2010-10-29 13:19:51 +00:00
|
|
|
}
|
2011-12-01 21:31:17 +00:00
|
|
|
|
2017-02-21 16:29:38 +00:00
|
|
|
$calendar = new SeedDMS_Calendar($dms->getDB(), $user);
|
2017-02-21 16:26:16 +00:00
|
|
|
|
|
|
|
$res = $calendar->addEvent($from, $to, $name, $comment);
|
2011-12-01 21:31:17 +00:00
|
|
|
|
2010-10-29 13:19:51 +00:00
|
|
|
if (is_bool($res) && !$res) {
|
|
|
|
UI::exitError(getMLText("add_event"),getMLText("error_occured"));
|
|
|
|
}
|
|
|
|
|
2011-12-01 21:31:17 +00:00
|
|
|
add_log_line("?name=".$name."&from=".$from."&to=".$to);
|
|
|
|
|
2013-03-12 07:57:18 +00:00
|
|
|
header("Location:../out/out.Calendar.php?mode=w&day=".date('d', $from)."&year=".date('Y', $from)."&month=".date('m', $from));
|
2011-12-01 21:31:17 +00:00
|
|
|
|
|
|
|
?>
|