fix line indenting

This commit is contained in:
Uwe Steinmann 2024-04-23 18:19:51 +02:00
parent ce9be505fd
commit 3a1be1333d

View File

@ -717,94 +717,94 @@ class RestapiController { /* {{{ */
return $response->withJson(array('success'=>false, 'message'=>getMLText("document_duplicate_name"), 'data'=>''), 409);
}
}
// Get the list of reviewers and approvers for this document.
$reviewers = array();
$approvers = array();
$reviewers["i"] = array();
$reviewers["g"] = array();
$approvers["i"] = array();
$approvers["g"] = array();
$workflow = null;
if($settings->_workflowMode == 'traditional' || $settings->_workflowMode == 'traditional_only_approval') {
// add mandatory reviewers/approvers
if($settings->_workflowMode == 'traditional') {
$mreviewers = getMandatoryReviewers($mfolder, null, $userobj);
if($mreviewers['i'])
$reviewers['i'] = array_merge($reviewers['i'], $mreviewers['i']);
if($mreviewers['g'])
$reviewers['g'] = array_merge($reviewers['g'], $mreviewers['g']);
}
$mapprovers = getMandatoryApprovers($mfolder, null, $userobj);
if($mapprovers['i'])
$approvers['i'] = array_merge($approvers['i'], $mapprovers['i']);
if($mapprovers['g'])
$approvers['g'] = array_merge($approvers['g'], $mapprovers['g']);
} elseif($settings->_workflowMode == 'advanced') {
if($workflows = $userobj->getMandatoryWorkflows()) {
$workflow = array_shift($workflows);
}
}
// Get the list of reviewers and approvers for this document.
$reviewers = array();
$approvers = array();
$reviewers["i"] = array();
$reviewers["g"] = array();
$approvers["i"] = array();
$approvers["g"] = array();
$workflow = null;
if($settings->_workflowMode == 'traditional' || $settings->_workflowMode == 'traditional_only_approval') {
// add mandatory reviewers/approvers
if($settings->_workflowMode == 'traditional') {
$mreviewers = getMandatoryReviewers($mfolder, null, $userobj);
if($mreviewers['i'])
$reviewers['i'] = array_merge($reviewers['i'], $mreviewers['i']);
if($mreviewers['g'])
$reviewers['g'] = array_merge($reviewers['g'], $mreviewers['g']);
}
$mapprovers = getMandatoryApprovers($mfolder, null, $userobj);
if($mapprovers['i'])
$approvers['i'] = array_merge($approvers['i'], $mapprovers['i']);
if($mapprovers['g'])
$approvers['g'] = array_merge($approvers['g'], $mapprovers['g']);
} elseif($settings->_workflowMode == 'advanced') {
if($workflows = $userobj->getMandatoryWorkflows()) {
$workflow = array_shift($workflows);
}
}
$temp = $file_info->file;
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$userfiletype = finfo_file($finfo, $temp);
$fileType = ".".pathinfo($origfilename, PATHINFO_EXTENSION);
finfo_close($finfo);
$attributes_version = [];
$notusers = [];
$notgroups = [];
$controller = Controller::factory('AddDocument');
$controller->setParam('documentsource', 'restapi');
$controller->setParam('documentsourcedetails', null);
$controller->setParam('dms', $dms);
$controller->setParam('user', $userobj);
$controller->setParam('folder', $mfolder);
$controller->setParam('fulltextservice', $fulltextservice);
$controller->setParam('name', $docname);
$controller->setParam('comment', $comment);
$controller->setParam('expires', $expires);
$controller->setParam('keywords', $keywords);
$controller->setParam('categories', $cats);
$controller->setParam('owner', $owner ? $owner : $userobj);
$controller->setParam('userfiletmp', $temp);
$controller->setParam('userfilename', $origfilename ? $origfilename : basename($temp));
$controller->setParam('filetype', $fileType);
$controller->setParam('userfiletype', $userfiletype);
$controller->setParam('sequence', $sequence);
$controller->setParam('reviewers', $reviewers);
$controller->setParam('approvers', $approvers);
$controller->setParam('reqversion', $reqversion);
$controller->setParam('versioncomment', $version_comment);
$controller->setParam('attributes', $attributes);
$controller->setParam('attributesversion', $attributes_version);
$controller->setParam('workflow', $workflow);
$controller->setParam('notificationgroups', $notgroups);
$controller->setParam('notificationusers', $notusers);
$controller->setParam('maxsizeforfulltext', $settings->_maxSizeForFullText);
$controller->setParam('defaultaccessdocs', $settings->_defaultAccessDocs);
finfo_close($finfo);
$attributes_version = [];
$notusers = [];
$notgroups = [];
$controller = Controller::factory('AddDocument');
$controller->setParam('documentsource', 'restapi');
$controller->setParam('documentsourcedetails', null);
$controller->setParam('dms', $dms);
$controller->setParam('user', $userobj);
$controller->setParam('folder', $mfolder);
$controller->setParam('fulltextservice', $fulltextservice);
$controller->setParam('name', $docname);
$controller->setParam('comment', $comment);
$controller->setParam('expires', $expires);
$controller->setParam('keywords', $keywords);
$controller->setParam('categories', $cats);
$controller->setParam('owner', $owner ? $owner : $userobj);
$controller->setParam('userfiletmp', $temp);
$controller->setParam('userfilename', $origfilename ? $origfilename : basename($temp));
$controller->setParam('filetype', $fileType);
$controller->setParam('userfiletype', $userfiletype);
$controller->setParam('sequence', $sequence);
$controller->setParam('reviewers', $reviewers);
$controller->setParam('approvers', $approvers);
$controller->setParam('reqversion', $reqversion);
$controller->setParam('versioncomment', $version_comment);
$controller->setParam('attributes', $attributes);
$controller->setParam('attributesversion', $attributes_version);
$controller->setParam('workflow', $workflow);
$controller->setParam('notificationgroups', $notgroups);
$controller->setParam('notificationusers', $notusers);
$controller->setParam('maxsizeforfulltext', $settings->_maxSizeForFullText);
$controller->setParam('defaultaccessdocs', $settings->_defaultAccessDocs);
if(!($document = $controller())) {
$err = $controller->getErrorMsg();
if(is_string($err))
$errmsg = getMLText($err);
elseif(is_array($err)) {
$errmsg = getMLText($err[0], $err[1]);
} else {
$errmsg = $err;
}
unlink($temp);
return $response->withJson(array('success'=>false, 'message'=>'Upload failed', 'data'=>''), 500);
} else {
if($controller->hasHook('cleanUpDocument')) {
$controller->callHook('cleanUpDocument', $document, $file);
}
// Send notification to subscribers of folder.
if($notifier) {
$notifier->sendNewDocumentMail($document, $userobj);
}
unlink($temp);
return $response->withJson(array('success'=>true, 'message'=>'Upload succeded', 'data'=>$this->__getLatestVersionData($document->getLatestContent())), 201);
}
/*
if(!($document = $controller())) {
$err = $controller->getErrorMsg();
if(is_string($err))
$errmsg = getMLText($err);
elseif(is_array($err)) {
$errmsg = getMLText($err[0], $err[1]);
} else {
$errmsg = $err;
}
unlink($temp);
return $response->withJson(array('success'=>false, 'message'=>'Upload failed', 'data'=>''), 500);
} else {
if($controller->hasHook('cleanUpDocument')) {
$controller->callHook('cleanUpDocument', $document, $file);
}
// Send notification to subscribers of folder.
if($notifier) {
$notifier->sendNewDocumentMail($document, $userobj);
}
unlink($temp);
return $response->withJson(array('success'=>true, 'message'=>'Upload succeded', 'data'=>$this->__getLatestVersionData($document->getLatestContent())), 201);
}
/*
$res = $mfolder->addDocument($docname, $comment, $expires, $owner ? $owner : $userobj, $keywords, $cats, $temp, $origfilename ? $origfilename : basename($temp), $fileType, $userfiletype, $sequence, array(), array(), $reqversion, $version_comment, $attributes);
unlink($temp);
if($res) {
@ -815,8 +815,8 @@ class RestapiController { /* {{{ */
return $response->withJson(array('success'=>true, 'message'=>'Upload succeded', 'data'=>$this->__getLatestVersionData($doc->getLatestContent())), 201);
} else {
return $response->withJson(array('success'=>false, 'message'=>'Upload failed', 'data'=>''), 500);
}
*/
}
*/
} else {
return $response->withJson(array('success'=>false, 'message'=>'No access', 'data'=>''), 403);
}
@ -2768,17 +2768,17 @@ class RestapiAuth { /* {{{ */
$logger->log("Received preflight options request", PEAR_LOG_DEBUG);
} elseif(!in_array($request->getUri()->getPath(), array('login')) && substr($request->getUri()->getPath(), 0, 5) != 'echo/' && $request->getUri()->getPath() != 'version') {
$userobj = null;
if(!empty($this->container->environment['HTTP_AUTHORIZATION']) && !empty($settings->_apiKey) && !empty($settings->_apiUserId)) {
$logger->log("Authorization key: ".$this->container->environment['HTTP_AUTHORIZATION'], PEAR_LOG_DEBUG);
if($settings->_apiKey == $this->container->environment['HTTP_AUTHORIZATION']) {
if(!($userobj = $dms->getUser($settings->_apiUserId))) {
return $response->withJson(array('success'=>false, 'message'=>'Invalid user associated with api key', 'data'=>''), 403);
}
} else {
return $response->withJson(array('success'=>false, 'message'=>'Wrong api key', 'data'=>''), 403);
}
$logger->log("Login with apikey as '".$userobj->getLogin()."' successful", PEAR_LOG_INFO);
} else {
if(!empty($this->container->environment['HTTP_AUTHORIZATION']) && !empty($settings->_apiKey) && !empty($settings->_apiUserId)) {
$logger->log("Authorization key: ".$this->container->environment['HTTP_AUTHORIZATION'], PEAR_LOG_DEBUG);
if($settings->_apiKey == $this->container->environment['HTTP_AUTHORIZATION']) {
if(!($userobj = $dms->getUser($settings->_apiUserId))) {
return $response->withJson(array('success'=>false, 'message'=>'Invalid user associated with api key', 'data'=>''), 403);
}
} else {
return $response->withJson(array('success'=>false, 'message'=>'Wrong api key', 'data'=>''), 403);
}
$logger->log("Login with apikey as '".$userobj->getLogin()."' successful", PEAR_LOG_INFO);
} else {
require_once("../inc/inc.ClassSession.php");
$session = new SeedDMS_Session($dms->getDb());
if (isset($_COOKIE["mydms_session"])) {
@ -2788,7 +2788,7 @@ class RestapiAuth { /* {{{ */
/* Delete Cookie */
setcookie("mydms_session", $dms_session, time()-3600, $settings->_httpRoot);
$logger->log("Session for id '".$dms_session."' has gone", PEAR_LOG_ERR);
return $response->withJson(array('success'=>false, 'message'=>'Session has gone', 'data'=>''), 403);
return $response->withJson(array('success'=>false, 'message'=>'Session has gone', 'data'=>''), 403);
}
/* Load user data */
@ -2798,20 +2798,20 @@ class RestapiAuth { /* {{{ */
setcookie("mydms_session", $dms_session, time()-3600, $settings->_httpRoot);
if($settings->_enableGuestLogin) {
if(!($userobj = $dms->getUser($settings->_guestID)))
return $response->withJson(array('success'=>false, 'message'=>'Could not get guest login', 'data'=>''), 403);
return $response->withJson(array('success'=>false, 'message'=>'Could not get guest login', 'data'=>''), 403);
} else
return $response->withJson(array('success'=>false, 'message'=>'Login as guest disabled', 'data'=>''), 403);
return $response->withJson(array('success'=>false, 'message'=>'Login as guest disabled', 'data'=>''), 403);
}
if($userobj->isAdmin()) {
if($resArr["su"]) {
if(!($userobj = $dms->getUser($resArr["su"])))
return $response->withJson(array('success'=>false, 'message'=>'Cannot substitute user', 'data'=>''), 403);
return $response->withJson(array('success'=>false, 'message'=>'Cannot substitute user', 'data'=>''), 403);
}
}
// $logger->log("Login with user name '".$userobj->getLogin()."' successful", PEAR_LOG_INFO);
$dms->setUser($userobj);
} else {
return $response->withJson(array('success'=>false, 'message'=>'Missing session cookie', 'data'=>''), 403);
return $response->withJson(array('success'=>false, 'message'=>'Missing session cookie', 'data'=>''), 403);
}
}
$this->container['userobj'] = $userobj;