Merge branch 'seeddms-5.1.x' into seeddms-6.0.x

This commit is contained in:
Uwe Steinmann 2020-12-17 13:43:22 +01:00
commit 77a59e008b
19 changed files with 104 additions and 49 deletions

View File

@ -60,6 +60,11 @@ class SeedDMS_Controller_AddDocument extends SeedDMS_Controller_Common {
if($attrdef = $dms->getAttributeDefinition($attrdefid)) { if($attrdef = $dms->getAttributeDefinition($attrdefid)) {
if(null === ($ret = $this->callHook('validateAttribute', $attrdef, $attribute))) { if(null === ($ret = $this->callHook('validateAttribute', $attrdef, $attribute))) {
if($attribute) { if($attribute) {
switch($attrdef->getType()) {
case SeedDMS_Core_AttributeDefinition::type_date:
$attribute = date('Y-m-d', makeTsFromDate($attribute));
break;
}
if(!$attrdef->validate($attribute)) { if(!$attrdef->validate($attribute)) {
$this->errormsg = getAttributeValidationError($attrdef->getValidationError(), $attrdef->getName(), $attribute); $this->errormsg = getAttributeValidationError($attrdef->getValidationError(), $attrdef->getName(), $attribute);
return false; return false;
@ -79,6 +84,11 @@ class SeedDMS_Controller_AddDocument extends SeedDMS_Controller_Common {
if($attrdef = $dms->getAttributeDefinition($attrdefid)) { if($attrdef = $dms->getAttributeDefinition($attrdefid)) {
if(null === ($ret = $this->callHook('validateAttribute', $attrdef, $attribute))) { if(null === ($ret = $this->callHook('validateAttribute', $attrdef, $attribute))) {
if($attribute) { if($attribute) {
switch($attrdef->getType()) {
case SeedDMS_Core_AttributeDefinition::type_date:
$attribute = date('Y-m-d', makeTsFromDate($attribute));
break;
}
if(!$attrdef->validate($attribute)) { if(!$attrdef->validate($attribute)) {
$this->errormsg = getAttributeValidationError($attrdef->getValidationError(), $attrdef->getName(), $attribute); $this->errormsg = getAttributeValidationError($attrdef->getValidationError(), $attrdef->getName(), $attribute);
return false; return false;

View File

@ -120,6 +120,11 @@ class SeedDMS_Controller_EditDocument extends SeedDMS_Controller_Common {
if($attrdef = $dms->getAttributeDefinition($attrdefid)) { if($attrdef = $dms->getAttributeDefinition($attrdefid)) {
if(null === ($ret = $this->callHook('validateAttribute', $attrdef, $attribute))) { if(null === ($ret = $this->callHook('validateAttribute', $attrdef, $attribute))) {
if($attribute) { if($attribute) {
switch($attrdef->getType()) {
case SeedDMS_Core_AttributeDefinition::type_date:
$attribute = date('Y-m-d', makeTsFromDate($attribute));
break;
}
if(!$attrdef->validate($attribute, $document, true)) { if(!$attrdef->validate($attribute, $document, true)) {
$this->errormsg = getAttributeValidationError($attrdef->getValidationError(), $attrdef->getName(), $attribute); $this->errormsg = getAttributeValidationError($attrdef->getValidationError(), $attrdef->getName(), $attribute);
return false; return false;

View File

@ -26,9 +26,26 @@ function formatted_size($size_bytes) { /* {{{ */
return number_format($size_bytes,0,"","")." Bytes"; return number_format($size_bytes,0,"","")." Bytes";
} /* }}} */ } /* }}} */
function getReadableDate($timestamp) { /* {{{ */ /* Date picker needs a different syntax for date formats using
* yyyy for %Y
* yy for %y
* mm for %m
* dd for %d
* This functions returns the converted format
*/
function getConvertDateFormat() {
global $settings; global $settings;
if(!is_numeric($timestamp)) if($settings->_dateformat) {
return str_replace(['y', 'Y', 'm', 'M', 'F', 'd', 'l', 'D'], ['yy', 'yyyy', 'mm', 'M', 'MM', 'dd', 'DD', 'D'], $settings->_dateformat);
} else
return 'yyyy-mm-dd';
}
function getReadableDate($timestamp=0) { /* {{{ */
global $settings;
if(!$timestamp)
$timestamp = time();
elseif(!is_numeric($timestamp))
$timestamp = strtotime($timestamp); $timestamp = strtotime($timestamp);
if($settings->_dateformat) if($settings->_dateformat)
return date($settings->_dateformat, $timestamp); return date($settings->_dateformat, $timestamp);
@ -69,6 +86,16 @@ function getPeriodOfTime($timestamp) { /* {{{ */
} }
} /* }}} */ } /* }}} */
/*
* Converts a date string into a timestamp
*
* @param $date string date in format understood by strftime
* @return integer/boolean unix timestamp or false in case of an error
*/
function makeTsFromDate($date) { /* {{{ */
return strtotime($date);
} /* }}} */
/* /*
* Converts a date/time string into a timestamp * Converts a date/time string into a timestamp
* *
@ -76,6 +103,7 @@ function getPeriodOfTime($timestamp) { /* {{{ */
* @return integer/boolean unix timestamp or false in case of an error * @return integer/boolean unix timestamp or false in case of an error
*/ */
function makeTsFromLongDate($date) { /* {{{ */ function makeTsFromLongDate($date) { /* {{{ */
return strtotime($date);
$tmp = explode(' ', $date); $tmp = explode(' ', $date);
if(count($tmp) != 2) if(count($tmp) != 2)
return false; return false;

View File

@ -136,10 +136,11 @@ if (!is_numeric($sequence)) {
switch($_POST["presetexpdate"]) { switch($_POST["presetexpdate"]) {
case "date": case "date":
$tmp = explode('-', $_POST["expdate"]); $expires = makeTsFromDate($_POST["expdate"]);
if(count($tmp) != 3) // $tmp = explode('-', $_POST["expdate"]);
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("malformed_expiration_date")); // if(count($tmp) != 3)
$expires = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]); // UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("malformed_expiration_date"));
// $expires = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]);
break; break;
case "1w": case "1w":
$tmp = explode('-', date('Y-m-d')); $tmp = explode('-', date('Y-m-d'));

View File

@ -49,14 +49,16 @@ if (!isset($_POST["name"]) || !isset($_POST["comment"]) ) {
$name = $_POST["name"]; $name = $_POST["name"];
$comment = $_POST["comment"]; $comment = $_POST["comment"];
if(isset($_POST["from"])) { if(isset($_POST["from"])) {
$tmp = explode('-', $_POST["from"]); $from = makeTsFromDate($_POST["from"]);
$from = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]); // $tmp = explode('-', $_POST["from"]);
// $from = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]);
} else { } else {
$from = mktime(0,0,0, intval($_POST["frommonth"]), intval($_POST["fromday"]), intval($_POST["fromyear"])); $from = mktime(0,0,0, intval($_POST["frommonth"]), intval($_POST["fromday"]), intval($_POST["fromyear"]));
} }
if(isset($_POST["to"])) { if(isset($_POST["to"])) {
$tmp = explode('-', $_POST["to"]); $to = makeTsFromDate($_POST["to"])+86400;
$to = mktime(23,59,59, $tmp[1], $tmp[2], $tmp[0]); // $tmp = explode('-', $_POST["to"]);
// $to = mktime(23,59,59, $tmp[1], $tmp[2], $tmp[0]);
} else { } else {
$to = mktime(23,59,59, intval($_POST["tomonth"]), intval($_POST["today"]), intval($_POST["toyear"])); $to = mktime(23,59,59, intval($_POST["tomonth"]), intval($_POST["today"]), intval($_POST["toyear"]));
} }

View File

@ -71,6 +71,11 @@ if($attributes) {
foreach($attributes as $attrdefid=>$attribute) { foreach($attributes as $attrdefid=>$attribute) {
$attrdef = $dms->getAttributeDefinition($attrdefid); $attrdef = $dms->getAttributeDefinition($attrdefid);
if($attribute) { if($attribute) {
switch($attrdef->getType()) {
case SeedDMS_Core_AttributeDefinition::type_date:
$attribute = date('Y-m-d', makeTsFromDate($attribute));
break;
}
if(!$attrdef->validate($attribute, $version, true)) { if(!$attrdef->validate($attribute, $version, true)) {
$errmsg = getAttributeValidationText($attrdef->getValidationError(), $attrdef->getName(), $attribute); $errmsg = getAttributeValidationText($attrdef->getValidationError(), $attrdef->getName(), $attribute);
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())), $errmsg); UI::exitError(getMLText("document_title", array("documentname" => $document->getName())), $errmsg);

View File

@ -79,8 +79,9 @@ else
if(isset($_POST['presetexpdate'])) { if(isset($_POST['presetexpdate'])) {
switch($_POST["presetexpdate"]) { switch($_POST["presetexpdate"]) {
case "date": case "date":
$tmp = explode('-', $_POST["expdate"]); $expires = makeTsFromDate($_POST["expdate"]);
$expires = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]); // $tmp = explode('-', $_POST["expdate"]);
// $expires = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]);
break; break;
case "1w": case "1w":
$tmp = explode('-', date('Y-m-d')); $tmp = explode('-', date('Y-m-d'));

View File

@ -61,15 +61,17 @@ else
$comment = $_POST["comment"]; $comment = $_POST["comment"];
if(isset($_POST["from"])) { if(isset($_POST["from"])) {
$from = explode('T', $_POST["from"]); $from = makeTsFromDate($_POST["from"]);
$tmp = explode('-', $from[0]); // $from = explode('T', $_POST["from"]);
$from = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]); // $tmp = explode('-', $from[0]);
// $from = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]);
} else { } else {
UI::exitError(getMLText("edit_event"),getMLText("error_occured")); UI::exitError(getMLText("edit_event"),getMLText("error_occured"));
} }
if(isset($_POST["to"])) { if(isset($_POST["to"])) {
$tmp = explode('-', $_POST["to"]); $to = makeTsFromDate($_POST["to"])+86400;
$to = mktime(23,59,59, $tmp[1], $tmp[2], $tmp[0]); // $tmp = explode('-', $_POST["to"]);
// $to = mktime(23,59,59, $tmp[1], $tmp[2], $tmp[0]);
} else { } else {
$to = $event['stop'] - $event['start'] + $from;; $to = $event['stop'] - $event['start'] + $from;;
} }

View File

@ -49,8 +49,9 @@ if (!isset($_POST["presetexpdate"]) || $_POST["presetexpdate"] == "") {
switch($_POST["presetexpdate"]) { switch($_POST["presetexpdate"]) {
case "date": case "date":
$tmp = explode('-', $_POST["expdate"]); $expires = makeTsFromDate($_POST["expdate"]);
$expires = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]); // $tmp = explode('-', $_POST["expdate"]);
// $expires = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]);
break; break;
case "1w": case "1w":
$tmp = explode('-', date('Y-m-d')); $tmp = explode('-', date('Y-m-d'));
@ -88,6 +89,11 @@ if(isset($GLOBALS['SEEDDMS_HOOKS']['setExpires'])) {
if (!$document->setExpires($expires)){ if (!$document->setExpires($expires)){
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured")); UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured"));
} else {
if($expires)
$session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_expiration_date_set', array('date'=>getReadableDate($expires)))));
else
$session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_expiration_date_cleared')));
} }
$document->verifyLastestContentExpriry(); $document->verifyLastestContentExpriry();

View File

@ -141,8 +141,9 @@ else
$oldexpires = $document->getExpires(); $oldexpires = $document->getExpires();
switch($_POST["presetexpdate"]) { switch($_POST["presetexpdate"]) {
case "date": case "date":
$tmp = explode('-', $_POST["expdate"]); $expires = makeTsFromDate($_POST["expdate"]);
$expires = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]); // $tmp = explode('-', $_POST["expdate"]);
// $expires = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]);
break; break;
case "1w": case "1w":
$tmp = explode('-', date('Y-m-d')); $tmp = explode('-', date('Y-m-d'));
@ -328,6 +329,11 @@ default:
foreach($attributes as $attrdefid=>$attribute) { foreach($attributes as $attrdefid=>$attribute) {
$attrdef = $dms->getAttributeDefinition($attrdefid); $attrdef = $dms->getAttributeDefinition($attrdefid);
if($attribute) { if($attribute) {
switch($attrdef->getType()) {
case SeedDMS_Core_AttributeDefinition::type_date:
$attribute = date('Y-m-d', makeTsFromDate($attribute));
break;
}
if(!$attrdef->validate($attribute)) { if(!$attrdef->validate($attribute)) {
$errmsg = getAttributeValidationText($attrdef->getValidationError(), $attrdef->getName(), $attribute); $errmsg = getAttributeValidationText($attrdef->getValidationError(), $attrdef->getName(), $attribute);
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())), $errmsg); UI::exitError(getMLText("document_title", array("documentname" => $document->getName())), $errmsg);

View File

@ -63,7 +63,7 @@ $(document).ready( function() {
$('body').on('touchstart.dropdown', '.dropdown-menu', function (e) { e.stopPropagation(); }); $('body').on('touchstart.dropdown', '.dropdown-menu', function (e) { e.stopPropagation(); });
$('.datepicker, #expirationdate, #fromdate, #todate, #createstartdate, #createenddate, #expirationstartdate, #expirationenddate, #revisionstartdate') $('.datepicker, #expirationdate, #createstartdate, #createenddate, #expirationstartdate, #expirationenddate, #revisionstartdate')
.datepicker({todayHighlight: true, toggleActive: true}) .datepicker({todayHighlight: true, toggleActive: true})
.on('changeDate', function(ev){ .on('changeDate', function(ev){
if(ev.date && $(ev.target).data('selectmenu')) { if(ev.date && $(ev.target).data('selectmenu')) {

View File

@ -300,7 +300,7 @@ $(document).ready(function() {
); );
$this->formField( $this->formField(
getMLText("expires"), getMLText("expires"),
$this->getDateChooser(($expts ? date('Y-m-d', $expts) : ''), "expdate", $this->params['session']->getLanguage()) $this->getDateChooser(($expts ? getReadableDate($expts) : ''), "expdate", $this->params['session']->getLanguage())
); );
} }
if($accessop->check_controller_access('AddDocument', array('action'=>'setOwner'))) { if($accessop->check_controller_access('AddDocument', array('action'=>'setOwner'))) {

View File

@ -80,7 +80,7 @@ $(document).ready(function() {
$this->contentHeading(getMLText("add_event")); $this->contentHeading(getMLText("add_event"));
$this->contentContainerStart(); $this->contentContainerStart();
$expdate = date('Y-m-d'); $expdate = getReadableDate();
?> ?>
<form class="form-horizontal" action="../op/op.AddEvent.php" id="form1" name="form1" method="post"> <form class="form-horizontal" action="../op/op.AddEvent.php" id="form1" name="form1" method="post">

View File

@ -1377,11 +1377,13 @@ $(document).ready(function() {
echo self::getFileChooserHtml($varname, $multiple, $accept); echo self::getFileChooserHtml($varname, $multiple, $accept);
} /* }}} */ } /* }}} */
function printDateChooser($defDate = '', $varName, $lang='', $dateformat='yyyy-mm-dd', $startdate='', $enddate='') { /* {{{ */ function printDateChooser($defDate = '', $varName, $lang='', $dateformat='', $startdate='', $enddate='') { /* {{{ */
echo self::getDateChooser($defDate, $varName, $lang, $dateformat, $startdate, $enddate); echo self::getDateChooser($defDate, $varName, $lang, $dateformat, $startdate, $enddate);
} /* }}} */ } /* }}} */
function getDateChooser($defDate = '', $varName, $lang='', $dateformat='yyyy-mm-dd', $startdate='', $enddate='') { /* {{{ */ function getDateChooser($defDate = '', $varName, $lang='', $dateformat='', $startdate='', $enddate='') { /* {{{ */
if(!$dateformat)
$dateformat = getConvertDateFormat();
$content = ' $content = '
<span class="input-append date span12 datepicker" id="'.$varName.'date" data-date="'.$defDate.'" data-selectmenu="presetexpdate" data-date-format="'.$dateformat.'"'.($lang ? ' data-date-language="'.str_replace('_', '-', $lang).'"' : '').($startdate ? ' data-date-start-date="'.$startdate.'"' : '').($enddate ? ' data-date-end-date="'.$enddate.'"' : '').'> <span class="input-append date span12 datepicker" id="'.$varName.'date" data-date="'.$defDate.'" data-selectmenu="presetexpdate" data-date-format="'.$dateformat.'"'.($lang ? ' data-date-language="'.str_replace('_', '-', $lang).'"' : '').($startdate ? ' data-date-start-date="'.$startdate.'"' : '').($enddate ? ' data-date-end-date="'.$enddate.'"' : '').'>
<input class="span6" size="16" name="'.$varName.'" id="'.$varName.'" type="text" value="'.$defDate.'" autocomplete="off"> <input class="span6" size="16" name="'.$varName.'" id="'.$varName.'" type="text" value="'.$defDate.'" autocomplete="off">
@ -1746,7 +1748,9 @@ $(document).ready(function() {
break; break;
case SeedDMS_Core_AttributeDefinition::type_date: case SeedDMS_Core_AttributeDefinition::type_date:
$objvalue = $attribute ? (is_object($attribute) ? $attribute->getValue() : $attribute) : ''; $objvalue = $attribute ? (is_object($attribute) ? $attribute->getValue() : $attribute) : '';
$content .= '<span class="input-append date datepicker" data-date="'.date('Y-m-d').'" data-date-format="yyyy-mm-dd" data-date-language="'.str_replace('_', '-', $this->params['session']->getLanguage()).'"> if(!$dateformat)
$dateformat = getConvertDateFormat();
$content .= '<span class="input-append date datepicker" data-date="'.getReadableDate().'" data-date-format="'.$dateformat.'" data-date-language="'.str_replace('_', '-', $this->params['session']->getLanguage()).'">
<input id="'.$fieldname.'_'.$attrdef->getId().'" class="span9" size="16" name="'.$fieldname.'['.$attrdef->getId().']" type="text" value="'.($objvalue ? $objvalue : '').'"> <input id="'.$fieldname.'_'.$attrdef->getId().'" class="span9" size="16" name="'.$fieldname.'['.$attrdef->getId().']" type="text" value="'.($objvalue ? $objvalue : '').'">
<span class="add-on"><i class="fa fa-calendar"></i></span> <span class="add-on"><i class="fa fa-calendar"></i></span>
</span>'; </span>';

View File

@ -74,11 +74,11 @@ class SeedDMS_View_Calendar extends SeedDMS_Bootstrap_Style {
<?php <?php
$this->formField( $this->formField(
getMLText("from"), getMLText("from"),
$this->getDateChooser(date('Y-m-d', $event["start"]), "from") $this->getDateChooser(getReadableDate($event["start"]), "from")
); );
$this->formField( $this->formField(
getMLText("to"), getMLText("to"),
$this->getDateChooser(date('Y-m-d', $event["stop"]), "to") $this->getDateChooser(getReadableDate($event["stop"]-86400), "to")
); );
$this->formField( $this->formField(
getMLText("name"), getMLText("name"),

View File

@ -85,7 +85,7 @@ $(document).ready( function() {
$this->contentContainerStart(); $this->contentContainerStart();
if($document->expires()) if($document->expires())
$expdate = date('Y-m-d', $document->getExpires()); $expdate = getReadableDate($document->getExpires());
else else
$expdate = ''; $expdate = '';
?> ?>

View File

@ -59,7 +59,7 @@ $(document).ready( function() {
$this->contentContainerStart(); $this->contentContainerStart();
if($document->expires()) if($document->expires())
$expdate = date('Y-m-d', $document->getExpires()); $expdate = getReadableDate($document->getExpires());
else else
$expdate = ''; $expdate = '';
?> ?>

View File

@ -239,28 +239,13 @@ div.timeline-event-selected {
?> ?>
<form action="../out/out.Timeline.php" class="form form-inline" name="form1" id="form1"> <form action="../out/out.Timeline.php" class="form form-inline" name="form1" id="form1">
<?php <?php
/*
$html = '
<span class="input-append date" style="display: inline;" id="fromdate" data-date="'.date('Y-m-d', $from).'" data-date-format="yyyy-mm-dd" data-date-language="'.str_replace('_', '-', $this->params['session']->getLanguage()).'">
<input type="text" class="input-small" name="fromdate" value="'.date('Y-m-d', $from).'"/>
<span class="add-on"><i class="fa fa-calendar"></i></span>
</span> -
<span class="input-append date" style="display: inline;" id="todate" data-date="'.date('Y-m-d', $to).'" data-date-format="yyyy-mm-dd" data-date-language="'.str_replace('_', '-', $this->params['session']->getLanguage()).'">
<input type="text" class="input-small" name="todate" value="'.date('Y-m-d', $to).'"/>
<span class="add-on"><i class="fa fa-calendar"></i></span>
</span>';
$this->formField(
getMLText("date"),
$html
);
*/
$this->formField( $this->formField(
getMLText("from"), getMLText("from"),
$this->getDateChooser(date('Y-m-d', $from), 'fromdate', $this->params['session']->getLanguage()) $this->getDateChooser(getReadableDate($from), 'fromdate', $this->params['session']->getLanguage())
); );
$this->formField( $this->formField(
getMLText("to"), getMLText("to"),
$this->getDateChooser(date('Y-m-d', $to), 'todate', $this->params['session']->getLanguage()) $this->getDateChooser(getReadableDate($to), 'todate', $this->params['session']->getLanguage())
); );
$html = ' $html = '
<input type="checkbox" name="skip[]" value="add_file" '.(($skip && in_array('add_file', $skip)) ? 'checked' : '').'> '.getMLText('timeline_skip_add_file').'<br /> <input type="checkbox" name="skip[]" value="add_file" '.(($skip && in_array('add_file', $skip)) ? 'checked' : '').'> '.getMLText('timeline_skip_add_file').'<br />

View File

@ -282,7 +282,7 @@ console.log(element);
); );
$this->formField( $this->formField(
getMLText("expires"), getMLText("expires"),
$this->getDateChooser(($expts ? date('Y-m-d', $expts) : ''), "expdate", $this->params['session']->getLanguage()) $this->getDateChooser(($expts ? getReadableDate($expts) : ''), "expdate", $this->params['session']->getLanguage())
); );
} }
$attrdefs = $dms->getAllAttributeDefinitions(array(SeedDMS_Core_AttributeDefinition::objtype_documentcontent, SeedDMS_Core_AttributeDefinition::objtype_all)); $attrdefs = $dms->getAllAttributeDefinitions(array(SeedDMS_Core_AttributeDefinition::objtype_documentcontent, SeedDMS_Core_AttributeDefinition::objtype_all));