mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-06 07:04:57 +00:00
Merge branch 'seeddms-5.1.x' into seeddms-6.0.x
This commit is contained in:
commit
f0a3d7d60c
|
@ -629,6 +629,7 @@ class RestapiController { /* {{{ */
|
||||||
$dms = $this->container->dms;
|
$dms = $this->container->dms;
|
||||||
$userobj = $this->container->userobj;
|
$userobj = $this->container->userobj;
|
||||||
$settings = $this->container->config;
|
$settings = $this->container->config;
|
||||||
|
$notifier = $this->container->notifier;
|
||||||
|
|
||||||
if(!$userobj) {
|
if(!$userobj) {
|
||||||
return $response->withJson(array('success'=>false, 'message'=>'Not logged in', 'data'=>''), 403);
|
return $response->withJson(array('success'=>false, 'message'=>'Not logged in', 'data'=>''), 403);
|
||||||
|
@ -720,13 +721,12 @@ class RestapiController { /* {{{ */
|
||||||
$fileType = ".".pathinfo($origfilename, PATHINFO_EXTENSION);
|
$fileType = ".".pathinfo($origfilename, PATHINFO_EXTENSION);
|
||||||
finfo_close($finfo);
|
finfo_close($finfo);
|
||||||
$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);
|
$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);
|
||||||
// addDocumentCategories($res, $categories);
|
|
||||||
// setDocumentAttributes($res, $attributes);
|
|
||||||
|
|
||||||
unlink($temp);
|
unlink($temp);
|
||||||
if($res) {
|
if($res) {
|
||||||
$doc = $res[0];
|
$doc = $res[0];
|
||||||
// $rec = array('id'=>(int)$doc->getId(), 'name'=>$doc->getName(), 'version'=>$doc->getLatestContent()->getVersion());
|
if($notifier) {
|
||||||
|
$notifier->sendNewDocumentMail($doc, $userobj);
|
||||||
|
}
|
||||||
return $response->withJson(array('success'=>true, 'message'=>'Upload succeded', 'data'=>$this->__getLatestVersionData($doc->getLatestContent())), 201);
|
return $response->withJson(array('success'=>true, 'message'=>'Upload succeded', 'data'=>$this->__getLatestVersionData($doc->getLatestContent())), 201);
|
||||||
} else {
|
} else {
|
||||||
return $response->withJson(array('success'=>false, 'message'=>'Upload failed', 'data'=>''), 500);
|
return $response->withJson(array('success'=>false, 'message'=>'Upload failed', 'data'=>''), 500);
|
||||||
|
@ -747,6 +747,7 @@ class RestapiController { /* {{{ */
|
||||||
$dms = $this->container->dms;
|
$dms = $this->container->dms;
|
||||||
$userobj = $this->container->userobj;
|
$userobj = $this->container->userobj;
|
||||||
$settings = $this->container->config;
|
$settings = $this->container->config;
|
||||||
|
$notifier = $this->container->notifier;
|
||||||
|
|
||||||
if(!$userobj) {
|
if(!$userobj) {
|
||||||
return $response->withJson(array('success'=>false, 'message'=>'Not logged in', 'data'=>''), 403);
|
return $response->withJson(array('success'=>false, 'message'=>'Not logged in', 'data'=>''), 403);
|
||||||
|
@ -803,10 +804,20 @@ class RestapiController { /* {{{ */
|
||||||
$userfiletype = finfo_file($finfo, $temp);
|
$userfiletype = finfo_file($finfo, $temp);
|
||||||
$fileType = ".".pathinfo($origfilename, PATHINFO_EXTENSION);
|
$fileType = ".".pathinfo($origfilename, PATHINFO_EXTENSION);
|
||||||
finfo_close($finfo);
|
finfo_close($finfo);
|
||||||
|
$oldexpires = $document->getExpires();
|
||||||
$res=$document->addContent($comment, $userobj, $temp, $origfilename, $fileType, $userfiletype, array(), array(), 0, $attributes);
|
$res=$document->addContent($comment, $userobj, $temp, $origfilename, $fileType, $userfiletype, array(), array(), 0, $attributes);
|
||||||
|
|
||||||
unlink($temp);
|
unlink($temp);
|
||||||
if($res) {
|
if($res) {
|
||||||
|
if($notifier) {
|
||||||
|
$notifier->sendNewDocumentVersionMail($document, $userobj);
|
||||||
|
|
||||||
|
/* Actually there is not need to even try sending this mail
|
||||||
|
* because the expiration date cannot be set when calling
|
||||||
|
* this rest api endpoint.
|
||||||
|
*/
|
||||||
|
$notifier->sendChangedExpiryMail($document, $userobj, $oldexpires);
|
||||||
|
}
|
||||||
$rec = array('id'=>(int)$document->getId(), 'name'=>$document->getName(), 'version'=>$document->getLatestContent()->getVersion());
|
$rec = array('id'=>(int)$document->getId(), 'name'=>$document->getName(), 'version'=>$document->getLatestContent()->getVersion());
|
||||||
return $response->withJson(array('success'=>true, 'message'=>'Upload succeded', 'data'=>$rec), 200);
|
return $response->withJson(array('success'=>true, 'message'=>'Upload succeded', 'data'=>$rec), 200);
|
||||||
} else {
|
} else {
|
||||||
|
@ -827,6 +838,7 @@ class RestapiController { /* {{{ */
|
||||||
$dms = $this->container->dms;
|
$dms = $this->container->dms;
|
||||||
$userobj = $this->container->userobj;
|
$userobj = $this->container->userobj;
|
||||||
$settings = $this->container->config;
|
$settings = $this->container->config;
|
||||||
|
$notifier = $this->container->notifier;
|
||||||
|
|
||||||
if(!$userobj) {
|
if(!$userobj) {
|
||||||
return $response->withJson(array('success'=>false, 'message'=>'Not logged in', 'data'=>''), 403);
|
return $response->withJson(array('success'=>false, 'message'=>'Not logged in', 'data'=>''), 403);
|
||||||
|
@ -869,6 +881,9 @@ class RestapiController { /* {{{ */
|
||||||
unlink($temp);
|
unlink($temp);
|
||||||
if($res) {
|
if($res) {
|
||||||
$doc = $res[0];
|
$doc = $res[0];
|
||||||
|
if($notifier) {
|
||||||
|
$notifier->sendNewDocumentMail($doc, $userobj);
|
||||||
|
}
|
||||||
$rec = array('id'=>(int)$doc->getId(), 'name'=>$doc->getName());
|
$rec = array('id'=>(int)$doc->getId(), 'name'=>$doc->getName());
|
||||||
return $response->withJson(array('success'=>true, 'message'=>'Upload succeded', 'data'=>$rec), 200);
|
return $response->withJson(array('success'=>true, 'message'=>'Upload succeded', 'data'=>$rec), 200);
|
||||||
} else {
|
} else {
|
||||||
|
@ -2596,6 +2611,13 @@ class TestController { /* {{{ */
|
||||||
public function echoData($request, $response, $args) { /* {{{ */
|
public function echoData($request, $response, $args) { /* {{{ */
|
||||||
return $response->withJson(array('success'=>true, 'message'=>'This is the result of the echo call.', 'data'=>$args['data']), 200);
|
return $response->withJson(array('success'=>true, 'message'=>'This is the result of the echo call.', 'data'=>$args['data']), 200);
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
public function version($request, $response, $args) { /* {{{ */
|
||||||
|
$logger = $this->container->logger;
|
||||||
|
|
||||||
|
$v = new SeedDMS_Version();
|
||||||
|
return $response->withJson(array('success'=>true, 'message'=>'This is '.$v->banner(), 'data'=>['major'=>$v->majorVersion(), 'minor'=>$v->minorVersion(), 'subminor'=>$v->subminorVersion()]), 200);
|
||||||
|
} /* }}} */
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
/* Middleware for authentication */
|
/* Middleware for authentication */
|
||||||
|
@ -2645,7 +2667,7 @@ class RestapiAuth { /* {{{ */
|
||||||
*/
|
*/
|
||||||
if($request->getMethod() == 'OPTIONS') {
|
if($request->getMethod() == 'OPTIONS') {
|
||||||
$logger->log("Received preflight options request", PEAR_LOG_DEBUG);
|
$logger->log("Received preflight options request", PEAR_LOG_DEBUG);
|
||||||
} elseif(!in_array($request->getUri()->getPath(), array('login')) && substr($request->getUri()->getPath(), 0, 5) != 'echo/') {
|
} elseif(!in_array($request->getUri()->getPath(), array('login')) && substr($request->getUri()->getPath(), 0, 5) != 'echo/' && $request->getUri()->getPath() != 'version') {
|
||||||
$userobj = null;
|
$userobj = null;
|
||||||
if(!empty($this->container->environment['HTTP_AUTHORIZATION']) && !empty($settings->_apiKey) && !empty($settings->_apiUserId)) {
|
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);
|
$logger->log("Authorization key: ".$this->container->environment['HTTP_AUTHORIZATION'], PEAR_LOG_DEBUG);
|
||||||
|
@ -2803,6 +2825,7 @@ $app->put('/categories/{id}/name', \RestapiController::class.':changeCategoryNam
|
||||||
$app->get('/attributedefinitions', \RestapiController::class.':getAttributeDefinitions');
|
$app->get('/attributedefinitions', \RestapiController::class.':getAttributeDefinitions');
|
||||||
$app->put('/attributedefinitions/{id}/name', \RestapiController::class.':changeAttributeDefinitionName');
|
$app->put('/attributedefinitions/{id}/name', \RestapiController::class.':changeAttributeDefinitionName');
|
||||||
$app->get('/echo/{data}', \TestController::class.':echoData');
|
$app->get('/echo/{data}', \TestController::class.':echoData');
|
||||||
|
$app->get('/version', \TestController::class.':version');
|
||||||
$app->get('/statstotal', \RestapiController::class.':getStatsTotal');
|
$app->get('/statstotal', \RestapiController::class.':getStatsTotal');
|
||||||
|
|
||||||
if(isset($GLOBALS['SEEDDMS_HOOKS']['initRestAPI'])) {
|
if(isset($GLOBALS['SEEDDMS_HOOKS']['initRestAPI'])) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user