mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-06 15:14:58 +00:00
Merge branch 'seeddms-5.0.x' into seeddms-5.1.x
This commit is contained in:
commit
706465a971
|
@ -1,95 +0,0 @@
|
||||||
<?php
|
|
||||||
// Copyright (C) 2010 Matteo Lucarelli
|
|
||||||
//
|
|
||||||
// Some code from PHP Calendar Class Version 1.4 (5th March 2001)
|
|
||||||
// (C)2000-2001 David Wilkinson
|
|
||||||
// URL: http://www.cascade.org.uk/software/php/calendar/
|
|
||||||
// Email: davidw@cascade.org.uk
|
|
||||||
//
|
|
||||||
// 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.
|
|
||||||
|
|
||||||
// DB //////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
function getEvents($day, $month, $year){
|
|
||||||
|
|
||||||
global $db;
|
|
||||||
|
|
||||||
$date = mktime(12,0,0, $month, $day, $year);
|
|
||||||
|
|
||||||
$queryStr = "SELECT * FROM `tblEvents` WHERE `start` <= " . $date . " AND `stop` >= " . $date;
|
|
||||||
$ret = $db->getResultArray($queryStr);
|
|
||||||
return $ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getEventsInInterval($start, $stop){
|
|
||||||
|
|
||||||
global $db;
|
|
||||||
|
|
||||||
$queryStr = "SELECT * FROM `tblEvents` WHERE ( `start` <= " . (int) $start . " AND `stop` >= " . (int) $start . " ) ".
|
|
||||||
"OR ( `start` <= " . (int) $stop . " AND `stop` >= " . (int) $stop . " ) ".
|
|
||||||
"OR ( `start` >= " . (int) $start . " AND `stop` <= " . (int) $stop . " )";
|
|
||||||
$ret = $db->getResultArray($queryStr);
|
|
||||||
return $ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
function addEvent($from, $to, $name, $comment ){
|
|
||||||
|
|
||||||
global $db,$user;
|
|
||||||
|
|
||||||
$queryStr = "INSERT INTO `tblEvents` (`name`, `comment`, `start`, `stop`, `date`, `userID`) VALUES ".
|
|
||||||
"(".$db->qstr($name).", ".$db->qstr($comment).", ".(int) $from.", ".(int) $to.", ".$db->getCurrentTimestamp().", ".$user->getID().")";
|
|
||||||
|
|
||||||
$ret = $db->getResult($queryStr);
|
|
||||||
return $ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getEvent($id){
|
|
||||||
|
|
||||||
if (!is_numeric($id)) return false;
|
|
||||||
|
|
||||||
global $db;
|
|
||||||
|
|
||||||
$queryStr = "SELECT * FROM `tblEvents` WHERE `id` = " . (int) $id;
|
|
||||||
$ret = $db->getResultArray($queryStr);
|
|
||||||
|
|
||||||
if (is_bool($ret) && $ret == false) return false;
|
|
||||||
else if (count($ret) != 1) return false;
|
|
||||||
|
|
||||||
return $ret[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
function editEvent($id, $from, $to=null, $name=null, $comment=null ){
|
|
||||||
|
|
||||||
if (!is_numeric($id)) return false;
|
|
||||||
|
|
||||||
global $db;
|
|
||||||
|
|
||||||
$queryStr = "UPDATE `tblEvents` SET `start` = " . (int) $from . ($to !== null ? ", `stop` = " . (int) $to : '') . ($name !== null ? ", `name` = " . $db->qstr($name) : '') . ($comment !== null ? ", `comment` = " . $db->qstr($comment) : '') . ", `date` = " . $db->getCurrentTimestamp() . " WHERE `id` = ". (int) $id;
|
|
||||||
$ret = $db->getResult($queryStr);
|
|
||||||
return $ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
function delEvent($id){
|
|
||||||
|
|
||||||
if (!is_numeric($id)) return false;
|
|
||||||
|
|
||||||
global $db;
|
|
||||||
|
|
||||||
$queryStr = "DELETE FROM `tblEvents` WHERE `id` = " . (int) $id;
|
|
||||||
$ret = $db->getResult($queryStr);
|
|
||||||
return $ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
93
inc/inc.ClassCalendar.php
Normal file
93
inc/inc.ClassCalendar.php
Normal file
|
@ -0,0 +1,93 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Implementation of calendar
|
||||||
|
*
|
||||||
|
* @category DMS
|
||||||
|
* @package SeedDMS
|
||||||
|
* @license GPL 2
|
||||||
|
* @version @version@
|
||||||
|
* @author Uwe Steinmann <uwe@steinmann.cx>
|
||||||
|
* @copyright Copyright (C) 2010 Matteo Lucarelli,
|
||||||
|
* 2017 Uwe Steinmann
|
||||||
|
* @version Release: @package_version@
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Include parent class
|
||||||
|
*/
|
||||||
|
require_once("inc.ClassNotify.php");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class to manage events
|
||||||
|
*
|
||||||
|
* @category DMS
|
||||||
|
* @package SeedDMS
|
||||||
|
* @author Markus Westphal, Malcolm Cowe, Uwe Steinmann <uwe@steinmann.cx>
|
||||||
|
* @copyright Copyright (C) 2010 Matteo Lucarelli,
|
||||||
|
* 2017 Uwe Steinmann
|
||||||
|
* @version Release: @package_version@
|
||||||
|
*/
|
||||||
|
class SeedDMS_Calendar {
|
||||||
|
/**
|
||||||
|
* Instanz of database
|
||||||
|
*/
|
||||||
|
protected $db;
|
||||||
|
|
||||||
|
function __construct($db, $user) {
|
||||||
|
$this->db = $db;
|
||||||
|
$this->user = $user;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getEvents($day, $month, $year) { /* {{{ */
|
||||||
|
$date = mktime(12,0,0, $month, $day, $year);
|
||||||
|
|
||||||
|
$queryStr = "SELECT * FROM `tblEvents` WHERE `start` <= " . $date . " AND `stop` >= " . $date;
|
||||||
|
$ret = $this->db->getResultArray($queryStr);
|
||||||
|
return $ret;
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
|
function getEventsInInterval($start, $stop) { /* {{{ */
|
||||||
|
$queryStr = "SELECT * FROM `tblEvents` WHERE ( `start` <= " . (int) $start . " AND `stop` >= " . (int) $start . " ) ".
|
||||||
|
"OR ( `start` <= " . (int) $stop . " AND `stop` >= " . (int) $stop . " ) ".
|
||||||
|
"OR ( `start` >= " . (int) $start . " AND `stop` <= " . (int) $stop . " )";
|
||||||
|
$ret = $this->db->getResultArray($queryStr);
|
||||||
|
return $ret;
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
|
function addEvent($from, $to, $name, $comment ) { /* {{{ */
|
||||||
|
$queryStr = "INSERT INTO `tblEvents` (`name`, `comment`, `start`, `stop`, `date`, `userID`) VALUES ".
|
||||||
|
"(".$this->db->qstr($name).", ".$this->db->qstr($comment).", ".(int) $from.", ".(int) $to.", ".$this->db->getCurrentTimestamp().", ".$this->user->getID().")";
|
||||||
|
|
||||||
|
$ret = $this->db->getResult($queryStr);
|
||||||
|
return $ret;
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
|
function getEvent($id) { /* {{{ */
|
||||||
|
if (!is_numeric($id)) return false;
|
||||||
|
|
||||||
|
$queryStr = "SELECT * FROM `tblEvents` WHERE `id` = " . (int) $id;
|
||||||
|
$ret = $this->db->getResultArray($queryStr);
|
||||||
|
|
||||||
|
if (is_bool($ret) && $ret == false) return false;
|
||||||
|
else if (count($ret) != 1) return false;
|
||||||
|
|
||||||
|
return $ret[0];
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
|
function editEvent($id, $from, $to=null, $name=null, $comment=null) { /* {{{ */
|
||||||
|
if (!is_numeric($id)) return false;
|
||||||
|
|
||||||
|
$queryStr = "UPDATE `tblEvents` SET `start` = " . (int) $from . ($to !== null ? ", `stop` = " . (int) $to : '') . ($name !== null ? ", `name` = " . $this->db->qstr($name) : '') . ($comment !== null ? ", `comment` = " . $this->db->qstr($comment) : '') . ", `date` = " . $this->db->getCurrentTimestamp() . " WHERE `id` = ". (int) $id;
|
||||||
|
$ret = $this->db->getResult($queryStr);
|
||||||
|
return $ret;
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
|
function delEvent($id) { /* {{{ */
|
||||||
|
if (!is_numeric($id)) return false;
|
||||||
|
|
||||||
|
$queryStr = "DELETE FROM `tblEvents` WHERE `id` = " . (int) $id;
|
||||||
|
$ret = $this->db->getResult($queryStr);
|
||||||
|
return $ret;
|
||||||
|
} /* }}} */
|
||||||
|
}
|
||||||
|
?>
|
|
@ -27,7 +27,7 @@ include("../inc/inc.Extension.php");
|
||||||
include("../inc/inc.DBInit.php");
|
include("../inc/inc.DBInit.php");
|
||||||
include("../inc/inc.Language.php");
|
include("../inc/inc.Language.php");
|
||||||
include("../inc/inc.ClassUI.php");
|
include("../inc/inc.ClassUI.php");
|
||||||
include("../inc/inc.Calendar.php");
|
include("../inc/inc.ClassCalendar.php");
|
||||||
include("../inc/inc.Authentication.php");
|
include("../inc/inc.Authentication.php");
|
||||||
|
|
||||||
if ($user->isGuest()) {
|
if ($user->isGuest()) {
|
||||||
|
@ -66,7 +66,9 @@ if ($to<=$from){
|
||||||
UI::exitError(getMLText("add_event"),getMLText("to_before_from"));
|
UI::exitError(getMLText("add_event"),getMLText("to_before_from"));
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = addEvent($from, $to, $name, $comment);
|
$calendar = new SeedDMS_Calendar($dms->getDB(), $user);
|
||||||
|
|
||||||
|
$res = $calendar->addEvent($from, $to, $name, $comment);
|
||||||
|
|
||||||
if (is_bool($res) && !$res) {
|
if (is_bool($res) && !$res) {
|
||||||
UI::exitError(getMLText("add_event"),getMLText("error_occured"));
|
UI::exitError(getMLText("add_event"),getMLText("error_occured"));
|
||||||
|
|
|
@ -27,7 +27,7 @@ include("../inc/inc.Init.php");
|
||||||
include("../inc/inc.Extension.php");
|
include("../inc/inc.Extension.php");
|
||||||
include("../inc/inc.DBInit.php");
|
include("../inc/inc.DBInit.php");
|
||||||
include("../inc/inc.ClassUI.php");
|
include("../inc/inc.ClassUI.php");
|
||||||
include("../inc/inc.Calendar.php");
|
include("../inc/inc.ClassCalendar.php");
|
||||||
include("../inc/inc.Authentication.php");
|
include("../inc/inc.Authentication.php");
|
||||||
|
|
||||||
if ($user->isGuest()) {
|
if ($user->isGuest()) {
|
||||||
|
@ -43,7 +43,9 @@ if (!isset($_POST["from"]) && !(isset($_POST["frommonth"]) && isset($_POST["from
|
||||||
UI::exitError(getMLText("edit_event"),getMLText("error_occured"));
|
UI::exitError(getMLText("edit_event"),getMLText("error_occured"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($_POST["eventid"]) || !($event = getEvent($_POST["eventid"]))) {
|
$calendar = new SeedDMS_Calendar($dms->getDB(), $user);
|
||||||
|
|
||||||
|
if (!isset($_POST["eventid"]) || !($event = $calendar->getEvent($_POST["eventid"]))) {
|
||||||
UI::exitError(getMLText("edit_event"),getMLText("error_occured"));
|
UI::exitError(getMLText("edit_event"),getMLText("error_occured"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +77,7 @@ if ($to !== null && $to<=$from){
|
||||||
$to = $from + 86400 -1;
|
$to = $from + 86400 -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = editEvent($_POST["eventid"], $from, $to, $name, $comment );
|
$res = $calendar->editEvent($_POST["eventid"], $from, $to, $name, $comment );
|
||||||
|
|
||||||
if(isset($_POST["ajax"]) && $_POST["ajax"]) {
|
if(isset($_POST["ajax"]) && $_POST["ajax"]) {
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
|
|
|
@ -27,7 +27,7 @@ include("../inc/inc.Init.php");
|
||||||
include("../inc/inc.Extension.php");
|
include("../inc/inc.Extension.php");
|
||||||
include("../inc/inc.DBInit.php");
|
include("../inc/inc.DBInit.php");
|
||||||
include("../inc/inc.ClassUI.php");
|
include("../inc/inc.ClassUI.php");
|
||||||
include("../inc/inc.Calendar.php");
|
include("../inc/inc.ClassCalendar.php");
|
||||||
include("../inc/inc.Authentication.php");
|
include("../inc/inc.Authentication.php");
|
||||||
|
|
||||||
/* Check if the form data comes from a trusted request */
|
/* Check if the form data comes from a trusted request */
|
||||||
|
@ -39,13 +39,14 @@ if (!isset($_POST["eventid"]) || !is_numeric($_POST["eventid"]) || intval($_POST
|
||||||
UI::exitError(getMLText("edit_event"),getMLText("error_occured"));
|
UI::exitError(getMLText("edit_event"),getMLText("error_occured"));
|
||||||
}
|
}
|
||||||
|
|
||||||
$event=getEvent($_POST["eventid"]);
|
$calendar = new SeedDMS_Calendar($dms->getDB(), $user);
|
||||||
|
$event=$calendar->getEvent($_POST["eventid"]);
|
||||||
|
|
||||||
if (($user->getID()!=$event["userID"])&&(!$user->isAdmin())){
|
if (($user->getID()!=$event["userID"])&&(!$user->isAdmin())){
|
||||||
UI::exitError(getMLText("edit_event"),getMLText("access_denied"));
|
UI::exitError(getMLText("edit_event"),getMLText("access_denied"));
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = delEvent($_POST["eventid"]);
|
$res = $calendar->delEvent($_POST["eventid"]);
|
||||||
|
|
||||||
if (is_bool($res) && !$res) {
|
if (is_bool($res) && !$res) {
|
||||||
UI::exitError(getMLText("edit_event"),getMLText("error_occured"));
|
UI::exitError(getMLText("edit_event"),getMLText("error_occured"));
|
||||||
|
|
|
@ -18,7 +18,8 @@
|
||||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
|
||||||
include("../inc/inc.Settings.php");
|
include("../inc/inc.Settings.php");
|
||||||
include("../inc/inc.Calendar.php");
|
include("../inc/inc.ClassCalendar.php");
|
||||||
|
include("../inc/inc.DBInit.php");
|
||||||
include("../inc/inc.Language.php");
|
include("../inc/inc.Language.php");
|
||||||
include("../inc/inc.Init.php");
|
include("../inc/inc.Init.php");
|
||||||
include("../inc/inc.Extension.php");
|
include("../inc/inc.Extension.php");
|
||||||
|
@ -39,8 +40,10 @@ if(isset($_GET['documentid']) && $_GET['documentid'] && is_numeric($_GET['docume
|
||||||
} else
|
} else
|
||||||
$document = null;
|
$document = null;
|
||||||
|
|
||||||
|
$calendar = new SeedDMS_Calendar($dms->getDB(), $user);
|
||||||
|
|
||||||
if(isset($_GET['eventid']) && $_GET['eventid'] && is_numeric($_GET['eventid'])) {
|
if(isset($_GET['eventid']) && $_GET['eventid'] && is_numeric($_GET['eventid'])) {
|
||||||
$event = getEvent($_GET["eventid"]);
|
$event = $calendar->getEvent($_GET["eventid"]);
|
||||||
} else
|
} else
|
||||||
$event = null;
|
$event = null;
|
||||||
|
|
||||||
|
@ -57,6 +60,7 @@ if(isset($_GET['eventtype']) && $_GET['eventtype']) {
|
||||||
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
|
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
|
||||||
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user));
|
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user));
|
||||||
if($view) {
|
if($view) {
|
||||||
|
$view->setParam('calendar', $calendar);
|
||||||
$view->setParam('start', $start);
|
$view->setParam('start', $start);
|
||||||
$view->setParam('end', $end);
|
$view->setParam('end', $end);
|
||||||
$view->setParam('document', $document);
|
$view->setParam('document', $document);
|
||||||
|
|
|
@ -3,6 +3,7 @@ define('USE_PHP_SESSION', 0);
|
||||||
|
|
||||||
include("../inc/inc.Settings.php");
|
include("../inc/inc.Settings.php");
|
||||||
require_once "SeedDMS/Core.php";
|
require_once "SeedDMS/Core.php";
|
||||||
|
require_once "SeedDMS/Preview.php";
|
||||||
|
|
||||||
$db = new SeedDMS_Core_DatabaseAccess($settings->_dbDriver, $settings->_dbHostname, $settings->_dbUser, $settings->_dbPass, $settings->_dbDatabase);
|
$db = new SeedDMS_Core_DatabaseAccess($settings->_dbDriver, $settings->_dbHostname, $settings->_dbUser, $settings->_dbPass, $settings->_dbDatabase);
|
||||||
$db->connect() or die ("Could not connect to db-server \"" . $settings->_dbHostname . "\"");
|
$db->connect() or die ("Could not connect to db-server \"" . $settings->_dbHostname . "\"");
|
||||||
|
@ -52,8 +53,9 @@ if(USE_PHP_SESSION) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
require 'Slim/Slim.php';
|
#require 'Slim/Slim.php';
|
||||||
\Slim\Slim::registerAutoloader();
|
require "vendor/autoload.php";
|
||||||
|
#\Slim\Slim::registerAutoloader();
|
||||||
|
|
||||||
function doLogin() { /* {{{ */
|
function doLogin() { /* {{{ */
|
||||||
global $app, $dms, $userobj, $session, $settings;
|
global $app, $dms, $userobj, $session, $settings;
|
||||||
|
|
|
@ -142,14 +142,14 @@ function insert_user($user) { /* {{{ */
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
function set_homefolders() { /* {{{ */
|
function set_homefolders() { /* {{{ */
|
||||||
global $dms, $debug, $defaultUser, $users, $objmap;
|
global $logger, $dms, $debug, $defaultUser, $users, $objmap;
|
||||||
|
|
||||||
foreach($users as $user) {
|
foreach($users as $user) {
|
||||||
if(isset($user['attributes']['homefolder']) && $user['attributes']['homefolder']) {
|
if(isset($user['attributes']['homefolder']) && $user['attributes']['homefolder']) {
|
||||||
if(array_key_exists($user['id'], $objmap['users'])) {
|
if(array_key_exists($user['id'], $objmap['users'])) {
|
||||||
$userobj = $dms->getUser($objmap['users'][$user['id']]);
|
$userobj = $dms->getUser($objmap['users'][$user['id']]);
|
||||||
if(!array_key_exists((int) $user['attributes']['homefolder'], $objmap['folders'])) {
|
if(!array_key_exists((int) $user['attributes']['homefolder'], $objmap['folders'])) {
|
||||||
echo "Warning: homefolder ".$user['attributes']['homefolder']." cannot be found\n";
|
$logger->warning("homefolder ".$user['attributes']['homefolder']." cannot be found");
|
||||||
} else {
|
} else {
|
||||||
$userobj->setHomeFolder($objmap['folders'][(int) $user['attributes']['homefolder']]);
|
$userobj->setHomeFolder($objmap['folders'][(int) $user['attributes']['homefolder']]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,6 +164,7 @@ class SeedDMS_View_Calendar extends SeedDMS_Bootstrap_Style {
|
||||||
function events() { /* {{{ */
|
function events() { /* {{{ */
|
||||||
$dms = $this->params['dms'];
|
$dms = $this->params['dms'];
|
||||||
$user = $this->params['user'];
|
$user = $this->params['user'];
|
||||||
|
$calendar = $this->params['calendar'];
|
||||||
$eventtype = $this->params['eventtype'];
|
$eventtype = $this->params['eventtype'];
|
||||||
$start = explode('-', $this->params['start']);
|
$start = explode('-', $this->params['start']);
|
||||||
$end = explode('-', $this->params['end']);
|
$end = explode('-', $this->params['end']);
|
||||||
|
@ -171,7 +172,7 @@ class SeedDMS_View_Calendar extends SeedDMS_Bootstrap_Style {
|
||||||
$arr = array();
|
$arr = array();
|
||||||
switch($eventtype) {
|
switch($eventtype) {
|
||||||
case 'regular':
|
case 'regular':
|
||||||
$events = getEventsInInterval(mktime(0,0,0, $start[1], $start[2], $start[0]), mktime(23,59,59, $end[1], $end[2], $end[0]));
|
$events = $calendar->getEventsInInterval(mktime(0,0,0, $start[1], $start[2], $start[0]), mktime(23,59,59, $end[1], $end[2], $end[0]));
|
||||||
foreach ($events as $event){
|
foreach ($events as $event){
|
||||||
$arr[] = array('start'=>date('Y-m-d', $event["start"]), 'end'=>date('Y-m-d', $event["stop"]), 'title'=>$event["name"].($event['comment'] ? "\n".$event['comment'] : ''), 'eventid'=>$event["id"]);
|
$arr[] = array('start'=>date('Y-m-d', $event["start"]), 'end'=>date('Y-m-d', $event["stop"]), 'title'=>$event["name"].($event['comment'] ? "\n".$event['comment'] : ''), 'eventid'=>$event["id"]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user