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

This commit is contained in:
Uwe Steinmann 2017-06-13 14:48:55 +02:00
commit 652e7a82af
14 changed files with 223 additions and 93 deletions

View File

@ -30,10 +30,13 @@ class SeedDMS_Controller_AddDocument extends SeedDMS_Controller_Common {
* of the parameters.
*/
if(false === $this->callHook('preAddDocument', array('name'=>&$name, 'comment'=>&$comment))) {
if(empty($this->errormsg))
$this->errormsg = 'hook_preAddDocument_failed';
return null;
}
$name = $this->getParam('name');
$comment = $this->getParam('comment');
$dms = $this->params['dms'];
$user = $this->params['user'];
$settings = $this->params['settings'];

View File

@ -29,7 +29,8 @@ class SeedDMS_Controller_UpdateDocument extends SeedDMS_Controller_Common {
/* Call preUpdateDocument early, because it might need to modify some
* of the parameters.
*/
if(false === $this->callHook('preUpdateDocument')) {
if(false === $this->callHook('preUpdateDocument', $this->params['document'])) {
if(empty($this->errormsg))
$this->errormsg = 'hook_preUpdateDocument_failed';
return null;
}

View File

@ -122,6 +122,15 @@ class SeedDMS_Controller_Common {
return $this->errormsg;
} /* }}} */
/**
* Set error message
*
* @param string $msg error message
*/
public function setErrorMsg($msg) { /* {{{ */
$this->errormsg = $msg;
} /* }}} */
/**
* Call a controller hook
*

View File

@ -109,12 +109,12 @@ class SeedDMS_View_Common {
$tmpret = $hookObj->$hook($this, func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
break;
}
if($tmpret) {
if($tmpret !== null) {
if(is_string($tmpret))
$ret .= $tmpret;
elseif(is_array($tmpret) || is_object($tmpret))
elseif(is_array($tmpret) || is_object($tmpret)) {
$ret = ($ret === null) ? $tmpret : array_merge($ret, $tmpret);
else
} else
$ret = $tmpret;
}
}

View File

@ -27,6 +27,7 @@ include("../inc/inc.DBInit.php");
include("../inc/inc.ClassNotificationService.php");
include("../inc/inc.ClassEmailNotify.php");
include("../inc/inc.ClassUI.php");
include("../inc/inc.ClassController.php");
require_once("../inc/inc.ClassSession.php");
include("../inc/inc.ClassPasswordStrength.php");
@ -636,73 +637,54 @@ switch($command) {
$cats = array();
$filesize = SeedDMS_Core_File::fileSize($userfiletmp);
$res = $folder->addDocument($name, '', $expires, $user, '',
array(), $userfiletmp, utf8_basename($userfilename),
$fileType, $userfiletype, 0,
$reviewers, $approvers, 1,
'', array(), array(), $workflow);
if (is_bool($res) && !$res) {
header('Content-Type: application/json');
echo json_encode(array('success'=>false, 'message'=>getMLText("error_occured")));
exit;
} else {
$document = $res[0];
/* Set access as specified in settings. */
if($settings->_defaultAccessDocs) {
if($settings->_defaultAccessDocs > 0 && $settings->_defaultAccessDocs < 4) {
$document->setInheritAccess(0, true);
$document->setDefaultAccess($settings->_defaultAccessDocs, true);
}
}
if(isset($GLOBALS['SEEDDMS_HOOKS']['addDocument'])) {
foreach($GLOBALS['SEEDDMS_HOOKS']['addDocument'] as $hookObj) {
if (method_exists($hookObj, 'postAddDocument')) {
$hookObj->postAddDocument(null, $document);
}
}
}
if($settings->_enableFullSearch) {
$index = $indexconf['Indexer']::open($settings->_luceneDir);
if($index) {
$indexconf['Indexer']::init($settings->_stopWordsFile);
$idoc = new $indexconf['IndexedDocument']($dms, $document, isset($settings->_converters['fulltext']) ? $settings->_converters['fulltext'] : null, !($filesize < $settings->_maxSizeForFullText));
if(isset($GLOBALS['SEEDDMS_HOOKS']['addDocument'])) {
foreach($GLOBALS['SEEDDMS_HOOKS']['addDocument'] as $hookObj) {
if (method_exists($hookObj, 'preIndexDocument')) {
$hookObj->preIndexDocument(null, $document, $idoc);
}
}
}
$index->addDocument($idoc);
}
} else {
$index = null;
}
/* Add a default notification for the owner of the document */
if($settings->_enableOwnerNotification) {
$res = $document->addNotify($user->getID(), true);
}
$controller = Controller::factory('AddDocument');
$controller->setParam('documentsource', 'upload');
$controller->setParam('folder', $folder);
$controller->setParam('index', $index);
$controller->setParam('indexconf', $indexconf);
$controller->setParam('name', $name);
$controller->setParam('comment', '');
$controller->setParam('expires', $expires);
$controller->setParam('keywords', '');
$controller->setParam('categories', $cats);
$controller->setParam('owner', $user);
$controller->setParam('userfiletmp', $userfiletmp);
$controller->setParam('userfilename', $userfilename);
$controller->setParam('filetype', $fileType);
$controller->setParam('userfiletype', $userfiletype);
$controller->setParam('sequence', 0);
$controller->setParam('reviewers', $reviewers);
$controller->setParam('approvers', $approvers);
$controller->setParam('reqversion', 1);
$controller->setParam('versioncomment', '');
$controller->setParam('attributes', array());
$controller->setParam('attributesversion', array());
$controller->setParam('workflow', $workflow);
$controller->setParam('notificationgroups', array());
$controller->setParam('notificationusers', array());
$controller->setParam('maxsizeforfulltext', $settings->_maxSizeForFullText);
$controller->setParam('defaultaccessdocs', $settings->_defaultAccessDocs);
if(!$document = $controller->run()) {
header('Content-Type: application/json');
echo json_encode(array('success'=>false, 'message'=>getMLText($controller->getErrorMsg())));
exit;
} else {
// Send notification to subscribers of folder.
if($notifier) {
$notifyList = $folder->getNotifyList();
if($settings->_enableNotificationAppRev) {
/* Reviewers and approvers will be informed about the new document */
foreach($reviewers['i'] as $reviewerid) {
$notifyList['users'][] = $dms->getUser($reviewerid);
}
foreach($approvers['i'] as $approverid) {
$notifyList['users'][] = $dms->getUser($approverid);
}
foreach($reviewers['g'] as $reviewergrpid) {
$notifyList['groups'][] = $dms->getGroup($reviewergrpid);
}
foreach($approvers['g'] as $approvergrpid) {
$notifyList['groups'][] = $dms->getGroup($approvergrpid);
}
}
$fnl = $folder->getNotifyList();
$dnl = $document->getNotifyList();
$nl = array(
'users'=>array_merge($dnl['users'], $fnl['users']),
'groups'=>array_merge($dnl['groups'], $fnl['groups'])
);
$subject = "new_document_email_subject";
$message = "new_document_email_body";
@ -716,11 +698,80 @@ switch($command) {
$params['url'] = "http".((isset($_SERVER['HTTPS']) && (strcmp($_SERVER['HTTPS'],'off')!=0)) ? "s" : "")."://".$_SERVER['HTTP_HOST'].$settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID();
$params['sitename'] = $settings->_siteName;
$params['http_root'] = $settings->_httpRoot;
$notifier->toList($user, $notifyList["users"], $subject, $message, $params);
foreach ($notifyList["groups"] as $grp) {
$notifier->toList($user, $nl["users"], $subject, $message, $params);
foreach ($nl["groups"] as $grp) {
$notifier->toGroup($user, $grp, $subject, $message, $params);
}
if($workflow && $settings->_enableNotificationWorkflow) {
$subject = "request_workflow_action_email_subject";
$message = "request_workflow_action_email_body";
$params = array();
$params['name'] = $document->getName();
$params['version'] = 1;
$params['workflow'] = $workflow->getName();
$params['folder_path'] = $folder->getFolderPathPlain();
$params['current_state'] = $workflow->getInitState()->getName();
$params['username'] = $user->getFullName();
$params['sitename'] = $settings->_siteName;
$params['http_root'] = $settings->_httpRoot;
$params['url'] = "http".((isset($_SERVER['HTTPS']) && (strcmp($_SERVER['HTTPS'],'off')!=0)) ? "s" : "")."://".$_SERVER['HTTP_HOST'].$settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID();
foreach($workflow->getNextTransitions($workflow->getInitState()) as $ntransition) {
foreach($ntransition->getUsers() as $tuser) {
$notifier->toIndividual($user, $tuser->getUser(), $subject, $message, $params);
}
foreach($ntransition->getGroups() as $tuser) {
$notifier->toGroup($user, $tuser->getGroup(), $subject, $message, $params);
}
}
}
if($settings->_enableNotificationAppRev) {
/* Reviewers and approvers will be informed about the new document */
if($reviewers['i'] || $reviewers['g']) {
$subject = "review_request_email_subject";
$message = "review_request_email_body";
$params = array();
$params['name'] = $document->getName();
$params['folder_path'] = $folder->getFolderPathPlain();
$params['version'] = 1;
$params['comment'] = '';
$params['username'] = $user->getFullName();
$params['url'] = "http".((isset($_SERVER['HTTPS']) && (strcmp($_SERVER['HTTPS'],'off')!=0)) ? "s" : "")."://".$_SERVER['HTTP_HOST'].$settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID();
$params['sitename'] = $settings->_siteName;
$params['http_root'] = $settings->_httpRoot;
foreach($reviewers['i'] as $reviewerid) {
$notifier->toIndividual($user, $dms->getUser($reviewerid), $subject, $message, $params);
}
foreach($reviewers['g'] as $reviewergrpid) {
$notifier->toGroup($user, $dms->getGroup($reviewergrpid), $subject, $message, $params);
}
}
elseif($approvers['i'] || $approvers['g']) {
$subject = "approval_request_email_subject";
$message = "approval_request_email_body";
$params = array();
$params['name'] = $document->getName();
$params['folder_path'] = $folder->getFolderPathPlain();
$params['version'] = 1;
$params['comment'] = '';
$params['username'] = $user->getFullName();
$params['url'] = "http".((isset($_SERVER['HTTPS']) && (strcmp($_SERVER['HTTPS'],'off')!=0)) ? "s" : "")."://".$_SERVER['HTTP_HOST'].$settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID();
$params['sitename'] = $settings->_siteName;
$params['http_root'] = $settings->_httpRoot;
foreach($approvers['i'] as $approverid) {
$notifier->toIndividual($user, $dms->getUser($approverid), $subject, $message, $params);
}
foreach($approvers['g'] as $approvergrpid) {
$notifier->toGroup($user, $dms->getGroup($approvergrpid), $subject, $message, $params);
}
}
}
}
}
header('Content-Type: application/json');

View File

@ -366,7 +366,7 @@ $(document).ready( function() {
var action = element.data('action');
var query = element.data('query');
if(view && action) {
url = "out."+view+".php?action="+action;
url = seeddms_webroot+"out/out."+view+".php?action="+action;
if(query) {
url += "&"+query;
}

View File

@ -283,12 +283,14 @@ $(document).ready(function() {
$attrdefs = $dms->getAllAttributeDefinitions(array(SeedDMS_Core_AttributeDefinition::objtype_document, SeedDMS_Core_AttributeDefinition::objtype_all));
if($attrdefs) {
foreach($attrdefs as $attrdef) {
$arr = $this->callHook('editDocumentAttribute', null, $attrdef);
$arr = $this->callHook('addDocumentAttribute', null, $attrdef);
if(is_array($arr)) {
if($arr) {
echo "<tr>";
echo "<td>".$arr[0].":</td>";
echo "<td>".$arr[1]."</td>";
echo "</tr>";
}
} else {
?>
<tr>
@ -356,7 +358,7 @@ $(document).ready(function() {
$attrdefs = $dms->getAllAttributeDefinitions(array(SeedDMS_Core_AttributeDefinition::objtype_documentcontent, SeedDMS_Core_AttributeDefinition::objtype_all));
if($attrdefs) {
foreach($attrdefs as $attrdef) {
$arr = $this->callHook('editDocumentContentAttribute', null, $attrdef);
$arr = $this->callHook('addDocumentContentAttribute', null, $attrdef);
if(is_array($arr)) {
echo "<tr>";
echo "<td>".$arr[0].":</td>";

View File

@ -126,6 +126,15 @@ $(document).ready( function() {
$attrdefs = $dms->getAllAttributeDefinitions(array(SeedDMS_Core_AttributeDefinition::objtype_folder, SeedDMS_Core_AttributeDefinition::objtype_all));
if($attrdefs) {
foreach($attrdefs as $attrdef) {
$arr = $this->callHook('addFolderAttribute', null, $attrdef);
if(is_array($arr)) {
if($arr) {
echo "<div class=\"control-group\">";
echo " <label class=\"control-label\">".$arr[0].":</label>";
echo " <div class=\"controls\">".$arr[1]."</div>";
echo "</div>";
}
} else {
?>
<div class="control-group">
<label class="control-label"><?php echo htmlspecialchars($attrdef->getName()); ?>:</label>
@ -134,6 +143,7 @@ $(document).ready( function() {
<?php
}
}
}
?>
<div class="controls">

View File

@ -31,6 +31,14 @@ require_once("class.Bootstrap.php");
*/
class SeedDMS_View_AdminTools extends SeedDMS_Bootstrap_Style {
static function wrapRow($content) { /* {{{ */
return '<div class="row-fluid">'.$content.'</div>';
} /* }}} */
static function rowButton($link, $icon, $label) { /* {{{ */
return '<a href="'.$link.'" class="span3 btn btn-medium"><i class="icon-'.$icon.'"></i><br />'.getMLText($label).'</a>';
} /* }}} */
function show() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
@ -46,6 +54,7 @@ class SeedDMS_View_AdminTools extends SeedDMS_Bootstrap_Style {
$this->contentContainerStart();
?>
<div id="admin-tools">
<?php echo $this->callHook('beforeRows'); ?>
<div class="row-fluid">
<?php if($accessop->check_view_access('UsrMgr')) { ?>
<a href="../out/out.UsrMgr.php" class="span3 btn btn-medium"><i class="icon-user"></i><br /><?php echo getMLText("user_management")?></a>
@ -56,6 +65,7 @@ class SeedDMS_View_AdminTools extends SeedDMS_Bootstrap_Style {
<?php if($accessop->check_view_access('RoleMgr')) { ?>
<a href="../out/out.RoleMgr.php" class="span3 btn btn-medium"><i class="icon-bullseye"></i><br /><?php echo getMLText("role_management")?></a>
<?php } ?>
<?php echo $this->callHook('endOfRow', 1); ?>
</div>
<div class="row-fluid">
<?php if($accessop->check_view_access('BackupTools')) { ?>
@ -65,6 +75,7 @@ class SeedDMS_View_AdminTools extends SeedDMS_Bootstrap_Style {
if ($logfileenable && ($accessop->check_view_access('LogManagement')))
echo "<a href=\"../out/out.LogManagement.php\" class=\"span3 btn btn-medium\"><i class=\"icon-list\"></i><br />".getMLText("log_management")."</a>";
?>
<?php echo $this->callHook('endOfRow', 2); ?>
</div>
<div class="row-fluid">
<?php if($accessop->check_view_access('DefaultKeywords')) { ?>
@ -75,7 +86,11 @@ class SeedDMS_View_AdminTools extends SeedDMS_Bootstrap_Style {
<?php } ?>
<?php if($accessop->check_view_access('AttributeMgr')) { ?>
<a href="../out/out.AttributeMgr.php" class="span3 btn btn-medium"><i class="icon-tags"></i><br /><?php echo getMLText("global_attributedefinitions")?></a>
<<<<<<< HEAD
<?php } ?>
=======
<?php echo $this->callHook('endOfRow', 3); ?>
>>>>>>> seeddms-5.1.x
</div>
<?php
if($this->params['workflowmode'] == 'advanced') {
@ -89,7 +104,11 @@ class SeedDMS_View_AdminTools extends SeedDMS_Bootstrap_Style {
<?php } ?>
<?php if($accessop->check_view_access('WorkflowActionsMgr')) { ?>
<a href="../out/out.WorkflowActionsMgr.php" class="span3 btn btn-medium"><i class="icon-bolt"></i><br /><?php echo getMLText("global_workflow_actions"); ?></a>
<<<<<<< HEAD
<?php } ?>
=======
<?php echo $this->callHook('endOfRow', 4); ?>
>>>>>>> seeddms-5.1.x
</div>
<?php
}
@ -104,7 +123,11 @@ class SeedDMS_View_AdminTools extends SeedDMS_Bootstrap_Style {
<?php } ?>
<?php if($accessop->check_view_access('IndexInfo')) { ?>
<a href="../out/out.IndexInfo.php" class="span3 btn btn-medium"><i class="icon-info-sign"></i><br /><?php echo getMLText("fulltext_info")?></a>
<<<<<<< HEAD
<?php } ?>
=======
<?php echo $this->callHook('endOfRow', 5); ?>
>>>>>>> seeddms-5.1.x
</div>
<?php
}
@ -121,7 +144,11 @@ class SeedDMS_View_AdminTools extends SeedDMS_Bootstrap_Style {
<?php } ?>
<?php if($accessop->check_view_access('Timeline')) { ?>
<a href="../out/out.Timeline.php" class="span3 btn btn-medium"><i class="icon-time"></i><br /><?php echo getMLText("timeline")?></a>
<<<<<<< HEAD
<?php } ?>
=======
<?php echo $this->callHook('endOfRow', 6); ?>
>>>>>>> seeddms-5.1.x
</div>
<div class="row-fluid">
<?php if($accessop->check_view_access('Settings')) { ?>
@ -132,8 +159,13 @@ class SeedDMS_View_AdminTools extends SeedDMS_Bootstrap_Style {
<?php } ?>
<?php if($accessop->check_view_access('Info')) { ?>
<a href="../out/out.Info.php" class="span3 btn btn-medium"><i class="icon-info-sign"></i><br /><?php echo getMLText("version_info")?></a>
<<<<<<< HEAD
<?php } ?>
=======
<?php echo $this->callHook('endOfRow', 7); ?>
>>>>>>> seeddms-5.1.x
</div>
<?php echo $this->callHook('afterRows'); ?>
</div>
<?php
$this->contentContainerEnd();

View File

@ -144,6 +144,9 @@ background-image: linear-gradient(to bottom, #882222, #111111);;
echo '<script src="../styles/'.$this->theme.'/datepicker/js/locales/bootstrap-datepicker.'.$lang.'.js"></script>'."\n";
echo '<script src="../styles/'.$this->theme.'/chosen/js/chosen.jquery.min.js"></script>'."\n";
echo '<script src="../styles/'.$this->theme.'/select2/js/select2.min.js"></script>'."\n";
parse_str($_SERVER['QUERY_STRING'], $tmp);
$tmp['action'] = 'webrootjs';
echo '<script src="'.$this->params['absbaseprefix'].'out/out.'.$this->params['class'].'.php?'.http_build_query($tmp).'"></script>'."\n";
echo '<script src="../styles/'.$this->theme.'/application.js"></script>'."\n";
if(isset($this->params['user']) && $this->params['user']) {
$this->addFooterJS('checkTasks();');
@ -161,7 +164,6 @@ background-image: linear-gradient(to bottom, #882222, #111111);;
if(is_dir($this->params['cachedir'].'/js')) {
file_put_contents($this->params['cachedir'].'/js/'.$hashjs.'.js', $jscode);
}
parse_str($_SERVER['QUERY_STRING'], $tmp);
$tmp['action'] = 'footerjs';
$tmp['hash'] = $hashjs;
echo '<script src="'.$this->params['absbaseprefix'].'out/out.'.$this->params['class'].'.php?'.http_build_query($tmp).'"></script>'."\n";
@ -174,6 +176,12 @@ background-image: linear-gradient(to bottom, #882222, #111111);;
echo "</body>\n</html>\n";
} /* }}} */
function webrootjs() { /* {{{ */
header('Content-Type: application/javascript');
echo "var seeddms_absbaseprefix=\"".$this->params['absbaseprefix']."\";\n";
echo "var seeddms_webroot=\"".$this->params['settings']->_httpRoot."\";\n";
} /* }}} */
function footerjs() { /* {{{ */
header('Content-Type: application/javascript');
if(file_exists($this->params['cachedir'].'/js/'.$_GET['hash'].'.js')) {

View File

@ -55,6 +55,15 @@ class SeedDMS_View_EditAttributes extends SeedDMS_Bootstrap_Style {
<?php
if($attrdefs) {
foreach($attrdefs as $attrdef) {
$arr = $this->callHook('editDocumentContentAttribute', $version, $attrdef);
if(is_array($arr)) {
if($arr) {
echo "<div class=\"control-group\">";
echo "<label class=\"control-label\">".$arr[0].":</label>";
echo "<div class=\"controls\">".$arr[1]."</div>";
echo "</div>";
}
} else {
?>
<div class="control-group">
<label class="control-label"><?php echo htmlspecialchars($attrdef->getName()); ?></label>
@ -65,6 +74,7 @@ class SeedDMS_View_EditAttributes extends SeedDMS_Bootstrap_Style {
<?php
}
}
}
?>
<div class="controls">
<button type="submit" class="btn"><i class="icon-save"></i> <?php printMLText("save") ?></button>

View File

@ -192,10 +192,12 @@ $(document).ready( function() {
foreach($attrdefs as $attrdef) {
$arr = $this->callHook('editDocumentAttribute', $document, $attrdef);
if(is_array($arr)) {
if($arr) {
echo "<tr>";
echo "<td>".$arr[0].":</td>";
echo "<td>".$arr[1]."</td>";
echo "</tr>";
}
} else {
?>
<tr>

View File

@ -132,13 +132,14 @@ $(document).ready(function() {
if($attrdefs) {
foreach($attrdefs as $attrdef) {
$arr = $this->callHook('folderEditAttribute', $folder, $attrdef);
$arr = $this->callHook('editFolderAttribute', $folder, $attrdef);
if(is_array($arr)) {
echo $txt;
if($arr) {
echo "<div class=\"control-group\">";
echo "<label class=\"control-label\">".$arr[0]."</label>";
echo "<div class=\"controls\">".$arr[1]."</div>";
echo "</div>";
}
} else {
?>
<div class="control-group">

View File

@ -283,13 +283,14 @@ console.log(element);
$attrdefs = $dms->getAllAttributeDefinitions(array(SeedDMS_Core_AttributeDefinition::objtype_documentcontent, SeedDMS_Core_AttributeDefinition::objtype_all));
if($attrdefs) {
foreach($attrdefs as $attrdef) {
$arr = $this->callHook('editDocumentContentAttribute', null, $attrdef);
$arr = $this->callHook('editDocumentContentAttribute', $document, $attrdef);
if(is_array($arr)) {
echo $txt;
if($arr) {
echo "<tr>";
echo "<td>".$arr[0].":</td>";
echo "<td>".$arr[1]."</td>";
echo "</tr>";
}
} else {
?>
<tr>