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

This commit is contained in:
Uwe Steinmann 2021-12-03 20:39:13 +01:00
commit fa946be140
14 changed files with 118 additions and 95 deletions

View File

@ -223,6 +223,7 @@
- send mails to owner of document/folder only if not logged in or already
in list of notifiers
- improve fulltext search
- improve validation of change password form
--------------------------------------------------------------------------------
Changes in version 5.1.23

View File

@ -2469,15 +2469,15 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
$this->_dms->lasterror = '';
$db = $this->_dms->getDB();
/* Make sure the version exists */
$queryStr = "SELECT * FROM `tblDocumentContent` WHERE `document` = " . $this->getID() . " AND `version` = " . $version->getVersion();
/* Make sure the version exists */
$queryStr = "SELECT * FROM `tblDocumentContent` WHERE `document` = " . $this->getID() . " AND `version` = " . $version->getVersion();
$resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) && !$resArr)
return false;
if (count($resArr)==0)
return false;
/* Make sure this is not the last version */
/* Make sure this is not the last version */
$queryStr = "SELECT * FROM `tblDocumentContent` WHERE `document` = " . $this->getID();
$resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) && !$resArr)

View File

@ -386,16 +386,41 @@ class SeedDMS_NotificationService {
$this->toList($user, $nl["users"], $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION);
foreach ($nl["groups"] as $grp) {
$this->toGroup($user, $grp, $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION);
// if user is not owner and owner not already in list of notifiers, then
// send notification to owner
if($user->getID() != $document->getOwner()->getID() &&
false === SeedDMS_Core_DMS::inList($document->getOwner(), $nl['users']))
$this->toIndividual($user, $document->getOwner(), $subject, $message, $params, SeedDMS_NotificationService::RECV_OWNER);
}
} /* }}} */
/**
* This notification is sent when a document version is deleted.
* Keep in mind that $document refers to a document which has just been
* Keep in mind that $version refers to a version which has just been
* deleted from the database, but all the data needed is still in the
* object.
*/
public function sendDeleteDocumentVersionMail($document, $user) { /* {{{ */
public function sendDeleteDocumentVersionMail($document, $version, $user) { /* {{{ */
$nl = $document->getNotifyList();
$subject = "version_deleted_email_subject";
$message = "version_deleted_email_body";
$params = array();
$params['name'] = $document->getName();
$params['version'] = $version->getVersion();
$params['folder_path'] = $document->getFolder()->getFolderPathPlain();
$params['username'] = $user->getFullName();
$params['sitename'] = $this->settings->_siteName;
$params['http_root'] = $this->settings->_httpRoot;
$params['url'] = getBaseUrl().$this->settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID();
$this->toList($user, $nl["users"], $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION);
foreach ($nl["groups"] as $grp) {
$this->toGroup($user, $grp, $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION);
}
// if user is not owner and owner not already in list of notifiers, then
// send notification to owner
if($user->getID() != $document->getOwner()->getID() &&
false === SeedDMS_Core_DMS::inList($document->getOwner(), $nl['users']))
$this->toIndividual($user, $document->getOwner(), $subject, $message, $params, SeedDMS_NotificationService::RECV_OWNER);
} /* }}} */
/**

View File

@ -66,7 +66,5 @@ if($user) {
exit;
}
UI::exitError(getMLText("password_mismatch_error_title"),getMLText("password_mismatch_error"));
?>
UI::exitError(getMLText("password_forgotten_invalid_hash_title"),getMLText("password_forgotten_invalid_hash"));

View File

@ -142,13 +142,14 @@ else {
if($hit = $lucenesearch->getDocument($document->getID())) {
$index->delete($hit->id);
}
$version = $document->getLatestContent();
$index->addDocument($fulltextservice->IndexedDocument($document));
$index->commit();
}
// Notify affected users.
if ($notifier){
$notifier->sendDeleteDocumentVersionMail($document, $version, $user);
/*
$nl=$document->getNotifyList();
$userrecipientsR = array();
foreach ($emailUserListR as $eID) {
@ -195,6 +196,7 @@ else {
foreach ($nl["groups"] as $grp) {
$notifier->toGroup($user, $grp, $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION);
}
*/
}
}
}

View File

@ -106,5 +106,7 @@ if($ret = $version->triggerWorkflowTransition($user, $transition, $_POST["commen
add_log_line("?documentid=".$documentid."&version".$version_num);
header("Location:../out/out.ViewDocument.php?documentid=".$documentid."&currenttab=workflow");
?>
if($version->getStatus()['status'] == S_IN_WORKFLOW)
header("Location:../out/out.ViewDocument.php?documentid=".$documentid."&currenttab=workflow");
else
header("Location:../out/out.ViewDocument.php?documentid=".$documentid);

View File

@ -31,16 +31,11 @@ require_once("inc/inc.Init.php");
require_once("inc/inc.Extension.php");
require_once("inc/inc.DBInit.php");
require_once("inc/inc.ClassUI.php");
require_once("inc/inc.ClassAccessOperation.php");
require_once("inc/inc.Authentication.php");
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user));
$accessop = new SeedDMS_AccessOperation($dms, null, $user, $settings);
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms));
if($view) {
$view->setParam('accessobject', $accessop);
$view($_GET);
exit;
}

View File

@ -626,7 +626,7 @@ if($settings->_showSingleSearchHit && count($entries) == 1) {
$view->setParam('revisiondate', isset($revisiondate) ? $revisiondate: '');
$view->setParam('statusdate', isset($statusdate) ? $statusdate: '');
$view->setParam('status', $status);
$view->setParam('recordtype', $record_type);
$view->setParam('recordtype', isset($record_type) ? $record_type : null);
$view->setParam('categories', isset($categories) ? $categories : '');
$view->setParam('category', $category);
$view->setParam('mimetype', isset($mimetype) ? $mimetype : '');

View File

@ -237,23 +237,25 @@ console.log(params);
getMLText("keywords"),
$this->getKeywordChooserHtml('adddocform')
);
if(!$nodocumentformfields || !in_array('categories', $nodocumentformfields)) {
$options = array();
$categories = $dms->getDocumentCategories();
foreach($categories as $category) {
$options[] = array($category->getID(), $category->getName());
}
$this->formField(
getMLText("categories"),
array(
'element'=>'select',
'class'=>'chzn-select',
'name'=>'categories[]',
'multiple'=>true,
'attributes'=>array(array('data-placeholder', getMLText('select_category'), array('data-no_results_text', getMLText('unknown_document_category')))),
'options'=>$options
)
);
if($categories) {
if(!$nodocumentformfields || !in_array('categories', $nodocumentformfields)) {
$options = array();
foreach($categories as $category) {
$options[] = array($category->getID(), $category->getName());
}
$this->formField(
getMLText("categories"),
array(
'element'=>'select',
'class'=>'chzn-select',
'name'=>'categories[]',
'multiple'=>true,
'attributes'=>array(array('data-placeholder', getMLText('select_category'), array('data-no_results_text', getMLText('unknown_document_category')))),
'options'=>$options
)
);
}
}
if(!$nodocumentformfields || !in_array('sequence', $nodocumentformfields)) {
$this->formField(getMLText("sequence"), $this->getSequenceChooser($folder->getDocuments('s')).($orderby != 's' ? "<br />".getMLText('order_by_sequence_off') : ''));

View File

@ -33,8 +33,22 @@ class SeedDMS_View_ChangePassword extends SeedDMS_Theme_Style {
function js() { /* {{{ */
header('Content-Type: application/javascript; charset=UTF-8');
parent::jsTranslations(array('js_form_error', 'js_form_errors'));
?>
document.form1.newpassword.focus();
$(document).ready(function() {
$("#form1").validate({
rules: {
newpasswordrepeat: {
equalTo: "#newpassword"
}
},
messages: {
newpassword: "<?php printMLText("js_no_pwd");?>",
newpasswordrepeat: "<?php printMLText("js_pwd_not_conf");?>",
},
});
});
<?php
} /* }}} */
@ -44,12 +58,15 @@ document.form1.newpassword.focus();
$hash = $this->params['hash'];
$passwordstrength = $this->params['passwordstrength'];
$this->htmlAddHeader('<script type="text/javascript" src="../views/'.$this->theme.'/vendors/jquery-validation/jquery.validate.js"></script>'."\n", 'js');
$this->htmlAddHeader('<script type="text/javascript" src="../views/'.$this->theme.'/styles/validation-default.js"></script>'."\n", 'js');
$this->htmlStartPage(getMLText("change_password"), "login");
$this->globalBanner();
$this->contentStart();
$this->pageNavigation(getMLText("change_password"));
?>
<form class="form-horizontal" action="../op/op.ChangePassword.php" method="post" name="form1">
<form class="form-horizontal" action="../op/op.ChangePassword.php" method="post" id="form1" name="form1">
<?php echo createHiddenFieldWithKey('changepassword'); ?>
<?php
if ($referuri) {
@ -61,7 +78,7 @@ document.form1.newpassword.focus();
$this->contentContainerStart();
$this->formField(
getMLText("password"),
'<input class="pwd form-control" type="password" rel="strengthbar" name="newpassword" id="password">'
'<input class="pwd form-control" type="password" rel="strengthbar" name="newpassword" id="newpassword" required="required">'
);
if($passwordstrength > 0) {
$this->formField(
@ -74,9 +91,10 @@ document.form1.newpassword.focus();
array(
'element'=>'input',
'type'=>'password',
'id'=>'passwordrepeat',
'id'=>'newpasswordrepeat',
'name'=>'newpasswordrepeat',
'autocomplete'=>'off',
'required'=>true
)
);
$this->contentContainerEnd();

View File

@ -134,35 +134,37 @@ $(document).ready( function() {
)
);
}
if(!$nodocumentformfields || !in_array('categories', $nodocumentformfields)) {
$options = array();
$categories = $dms->getDocumentCategories();
foreach($categories as $category) {
$options[] = array($category->getID(), $category->getName(), in_array($category, $document->getCategories()));
}
$this->formField(
getMLText("categories"),
array(
'element'=>'select',
'class'=>'chzn-select',
'name'=>'categories[]',
'multiple'=>true,
'attributes'=>array(array('data-placeholder', getMLText('select_category'), array('data-no_results_text', getMLText('unknown_document_category')))),
'options'=>$options
)
);
} else {
$categories = $document->getCategories();
foreach($categories as $category) {
if($categories) {
if(!$nodocumentformfields || !in_array('categories', $nodocumentformfields)) {
$options = array();
foreach($categories as $category) {
$options[] = array($category->getID(), $category->getName(), in_array($category, $document->getCategories()));
}
$this->formField(
null,
getMLText("categories"),
array(
'element'=>'input',
'type'=>'hidden',
'element'=>'select',
'class'=>'chzn-select',
'name'=>'categories[]',
'value'=>htmlspecialchars($category->getId()),
'multiple'=>true,
'attributes'=>array(array('data-placeholder', getMLText('select_category'), array('data-no_results_text', getMLText('unknown_document_category')))),
'options'=>$options
)
);
} else {
$categories = $document->getCategories();
foreach($categories as $category) {
$this->formField(
null,
array(
'element'=>'input',
'type'=>'hidden',
'name'=>'categories[]',
'value'=>htmlspecialchars($category->getId()),
)
);
}
}
}
if(!$nodocumentformfields || !in_array('expires', $nodocumentformfields)) {

View File

@ -55,35 +55,9 @@ function runValidation() {
}
});
}
runValidation();
function checkForm()
{
msg = new Array();
if($("#currentpwd").val() == "") msg.push("<?php printMLText("js_no_pwd");?>");
if($("#pwd").val() == "") msg.push("<?php printMLText("js_no_pwd");?>");
if($("#pwd").val() != $("#pwdconf").val()) msg.push("<?php printMLText("js_pwd_not_conf");?>");
if (msg != "") {
noty({
text: msg.join('<br />'),
type: 'error',
dismissQueue: true,
layout: 'topRight',
theme: 'defaultTheme',
_timeout: 1500,
});
return false;
}
else
return true;
}
$(document).ready( function() {
// $('body').on('submit', '#form', function(ev){
// if(checkForm()) return;
// ev.preventDefault();
// });
runValidation();
});
<?php
} /* }}} */

View File

@ -532,8 +532,11 @@ function typeahead() { /* {{{ */
}
}
$content = ob_get_clean();
$this->printAccordion(getMLText('filter_for_folders'), $content);
if($content)
$this->printAccordion(getMLText('filter_for_folders'), $content);
// }}}
$this->formSubmit("<i class=\"fa fa-search\"></i> ".getMLText('search'));
?>
</form>
</div>
@ -545,7 +548,7 @@ function typeahead() { /* {{{ */
if($enablefullsearch) {
echo "<div class=\"tab-pane ".(($fullsearch == true) ? 'active' : '')."\" id=\"fulltext\">\n";
?>
<form action="<?= $this->params['settings']->_httpRoot ?>out/out.Search.php" name="form2" style="min-height: 330px;">
<form class="form-horizontal" action="<?= $this->params['settings']->_httpRoot ?>out/out.Search.php" name="form2" style="min-height: 330px;">
<input type="hidden" name="fullsearch" value="1" />
<?php
$this->contentContainerStart();

View File

@ -1035,7 +1035,7 @@ $(document).ready( function() {
foreach($wkflogt as $wkflog) {
echo "<tr>";
echo "<td>".htmlspecialchars($wkflog->getWorkflow()->getName())."</td>";
echo "<td>".$wkflog->getDate()."</td>";
echo "<td>".getLongReadableDate($wkflog->getDate())."</td>";
echo "<td>".htmlspecialchars(getMLText('action_'.strtolower($wkflog->getTransition()->getAction()->getName()), array(), $wkflog->getTransition()->getAction()->getName()))."</td>";
$loguser = $wkflog->getUser();
echo "<td>".htmlspecialchars($loguser->getFullName())."</td>";
@ -1388,7 +1388,7 @@ $(document).ready( function() {
if($latestContent->executeWorkflowTransitionIsAllowed($transition)) {
/* If this is reached, then the transition should have been executed
* but for some reason the next state hasn't been reached. This can
* be causes, if a transition which was previously already executed
* be caused, if a transition which was previously already executed
* is about to be executed again. E.g. there was already a transition
* T1 from state S1 to S2 triggered by user U1.
* Then there was a second transition T2 from
@ -1402,14 +1402,15 @@ $(document).ready( function() {
$wkflogs = $latestContent->getWorkflowLog($transition);
foreach($wkflogs as $wkflog) {
$loguser = $wkflog->getUser();
echo htmlspecialchars($loguser->getFullName())." (";
echo htmlspecialchars($loguser->getFullName());
$names = array();
foreach($loguser->getGroups() as $loggroup) {
$names[] = htmlspecialchars($loggroup->getName());
}
echo implode(", ", $names);
echo ") - ";
echo $wkflog->getDate();
if($names)
echo " (".implode(", ", $names).")";
echo " - ";
echo getLongReadableDate($wkflog->getDate());
echo "<br />";
}
echo "</td>";