mirror of
https://codeberg.org/SeedDMS/paperless
synced 2025-02-06 06:55:28 +00:00
access container elements with get() add set them with set()
This commit is contained in:
parent
3fb56643ee
commit
b7b3e20cf4
|
@ -147,9 +147,9 @@ class SeedDMS_ExtPaperless_RestAPI_Controller { /* {{{ */
|
||||||
* @param bool $full set to true for content from the file instead of the index
|
* @param bool $full set to true for content from the file instead of the index
|
||||||
*/
|
*/
|
||||||
protected function __getDocumentData($document, $truncate_content=false, $full=false) { /* {{{ */
|
protected function __getDocumentData($document, $truncate_content=false, $full=false) { /* {{{ */
|
||||||
$fulltextservice = $this->container->fulltextservice;
|
$fulltextservice = $this->container->get('fulltextservice');
|
||||||
$settings = $this->container->config;
|
$settings = $this->container->get('config');
|
||||||
$conversionmgr = $this->container->conversionmgr;
|
$conversionmgr = $this->container->get('conversionmgr');
|
||||||
|
|
||||||
$lc = $document->getLatestContent();
|
$lc = $document->getLatestContent();
|
||||||
$dms = $document->getDMS();
|
$dms = $document->getDMS();
|
||||||
|
@ -277,9 +277,9 @@ class SeedDMS_ExtPaperless_RestAPI_Controller { /* {{{ */
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
function token($request, $response) { /* {{{ */
|
function token($request, $response) { /* {{{ */
|
||||||
$settings = $this->container->config;
|
$settings = $this->container->get('config');
|
||||||
$authenticator = $this->container->authenticator;
|
$authenticator = $this->container->get('authenticator');
|
||||||
$logger = $this->container->logger;
|
$logger = $this->container->get('logger');
|
||||||
|
|
||||||
$data = $request->getParsedBody();
|
$data = $request->getParsedBody();
|
||||||
if(empty($data['username'])) {
|
if(empty($data['username'])) {
|
||||||
|
@ -310,11 +310,11 @@ class SeedDMS_ExtPaperless_RestAPI_Controller { /* {{{ */
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
function tags($request, $response) { /* {{{ */
|
function tags($request, $response) { /* {{{ */
|
||||||
$dms = $this->container->dms;
|
$dms = $this->container->get('dms');
|
||||||
$userobj = $this->container->userobj;
|
$userobj = $this->container->get('userobj');
|
||||||
$settings = $this->container->config;
|
$settings = $this->container->get('config');
|
||||||
$fulltextservice = $this->container->fulltextservice;
|
$fulltextservice = $this->container->get('fulltextservice');
|
||||||
$logger = $this->container->logger;
|
$logger = $this->container->get('logger');
|
||||||
|
|
||||||
if(false === ($categories = $dms->getDocumentCategories())) {
|
if(false === ($categories = $dms->getDocumentCategories())) {
|
||||||
return $response->withJson(array('results'=>null), 500);
|
return $response->withJson(array('results'=>null), 500);
|
||||||
|
@ -351,12 +351,12 @@ class SeedDMS_ExtPaperless_RestAPI_Controller { /* {{{ */
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
function post_tag($request, $response) { /* {{{ */
|
function post_tag($request, $response) { /* {{{ */
|
||||||
$dms = $this->container->dms;
|
$dms = $this->container->get('dms');
|
||||||
$userobj = $this->container->userobj;
|
$userobj = $this->container->get('userobj');
|
||||||
$settings = $this->container->config;
|
$settings = $this->container->get('config');
|
||||||
$logger = $this->container->logger;
|
$logger = $this->container->get('logger');
|
||||||
$fulltextservice = $this->container->fulltextservice;
|
$fulltextservice = $this->container->get('fulltextservice');
|
||||||
$notifier = $this->container->notifier;
|
$notifier = $this->container->get('notifier');
|
||||||
|
|
||||||
if(!$userobj->isAdmin())
|
if(!$userobj->isAdmin())
|
||||||
return $response->withStatus(404);
|
return $response->withStatus(404);
|
||||||
|
@ -374,13 +374,13 @@ class SeedDMS_ExtPaperless_RestAPI_Controller { /* {{{ */
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
function delete_tag($request, $response, $args) { /* {{{ */
|
function delete_tag($request, $response, $args) { /* {{{ */
|
||||||
$dms = $this->container->dms;
|
$dms = $this->container->get('dms');
|
||||||
$userobj = $this->container->userobj;
|
$userobj = $this->container->get('userobj');
|
||||||
$settings = $this->container->config;
|
$settings = $this->container->get('config');
|
||||||
$conversionmgr = $this->container->conversionmgr;
|
$conversionmgr = $this->container->get('conversionmgr');
|
||||||
$logger = $this->container->logger;
|
$logger = $this->container->get('logger');
|
||||||
$notifier = $this->container->notifier;
|
$notifier = $this->container->get('notifier');
|
||||||
$fulltextservice = $this->container->fulltextservice;
|
$fulltextservice = $this->container->get('fulltextservice');
|
||||||
|
|
||||||
if(!$userobj->isAdmin())
|
if(!$userobj->isAdmin())
|
||||||
return $response->withStatus(404);
|
return $response->withStatus(404);
|
||||||
|
@ -407,10 +407,10 @@ class SeedDMS_ExtPaperless_RestAPI_Controller { /* {{{ */
|
||||||
* instead of calling getStatistics()
|
* instead of calling getStatistics()
|
||||||
*/
|
*/
|
||||||
function correspondents($request, $response) { /* {{{ */
|
function correspondents($request, $response) { /* {{{ */
|
||||||
$dms = $this->container->dms;
|
$dms = $this->container->get('dms');
|
||||||
$userobj = $this->container->userobj;
|
$userobj = $this->container->get('userobj');
|
||||||
$settings = $this->container->config;
|
$settings = $this->container->get('config');
|
||||||
$logger = $this->container->logger;
|
$logger = $this->container->get('logger');
|
||||||
|
|
||||||
//file_put_contents("php://stdout", var_dump($request, true));
|
//file_put_contents("php://stdout", var_dump($request, true));
|
||||||
|
|
||||||
|
@ -437,10 +437,10 @@ class SeedDMS_ExtPaperless_RestAPI_Controller { /* {{{ */
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
function document_types($request, $response) { /* {{{ */
|
function document_types($request, $response) { /* {{{ */
|
||||||
$dms = $this->container->dms;
|
$dms = $this->container->get('dms');
|
||||||
$userobj = $this->container->userobj;
|
$userobj = $this->container->get('userobj');
|
||||||
$settings = $this->container->config;
|
$settings = $this->container->get('config');
|
||||||
$logger = $this->container->logger;
|
$logger = $this->container->get('logger');
|
||||||
|
|
||||||
$types = array();
|
$types = array();
|
||||||
if(!empty($settings->_extensions['paperless']['documenttypesattr']) && $attrdef = $dms->getAttributeDefinition($settings->_extensions['paperless']['documenttypesattr'])) {
|
if(!empty($settings->_extensions['paperless']['documenttypesattr']) && $attrdef = $dms->getAttributeDefinition($settings->_extensions['paperless']['documenttypesattr'])) {
|
||||||
|
@ -463,10 +463,10 @@ class SeedDMS_ExtPaperless_RestAPI_Controller { /* {{{ */
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
function saved_views($request, $response) { /* {{{ */
|
function saved_views($request, $response) { /* {{{ */
|
||||||
$dms = $this->container->dms;
|
$dms = $this->container->get('dms');
|
||||||
$userobj = $this->container->userobj;
|
$userobj = $this->container->get('userobj');
|
||||||
$settings = $this->container->config;
|
$settings = $this->container->get('config');
|
||||||
$logger = $this->container->logger;
|
$logger = $this->container->get('logger');
|
||||||
|
|
||||||
require_once('class.PaperlessView.php');
|
require_once('class.PaperlessView.php');
|
||||||
|
|
||||||
|
@ -481,12 +481,12 @@ class SeedDMS_ExtPaperless_RestAPI_Controller { /* {{{ */
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
function post_saved_views($request, $response) { /* {{{ */
|
function post_saved_views($request, $response) { /* {{{ */
|
||||||
$dms = $this->container->dms;
|
$dms = $this->container->get('dms');
|
||||||
$userobj = $this->container->userobj;
|
$userobj = $this->container->get('userobj');
|
||||||
$settings = $this->container->config;
|
$settings = $this->container->get('config');
|
||||||
$logger = $this->container->logger;
|
$logger = $this->container->get('logger');
|
||||||
$fulltextservice = $this->container->fulltextservice;
|
$fulltextservice = $this->container->get('fulltextservice');
|
||||||
$notifier = $this->container->notifier;
|
$notifier = $this->container->get('notifier');
|
||||||
|
|
||||||
require_once('class.PaperlessView.php');
|
require_once('class.PaperlessView.php');
|
||||||
|
|
||||||
|
@ -505,12 +505,12 @@ class SeedDMS_ExtPaperless_RestAPI_Controller { /* {{{ */
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
function delete_saved_views($request, $response, $args) { /* {{{ */
|
function delete_saved_views($request, $response, $args) { /* {{{ */
|
||||||
$dms = $this->container->dms;
|
$dms = $this->container->get('dms');
|
||||||
$userobj = $this->container->userobj;
|
$userobj = $this->container->get('userobj');
|
||||||
$settings = $this->container->config;
|
$settings = $this->container->get('config');
|
||||||
$conversionmgr = $this->container->conversionmgr;
|
$conversionmgr = $this->container->get('conversionmgr');
|
||||||
$logger = $this->container->logger;
|
$logger = $this->container->get('logger');
|
||||||
$notifier = $this->container->notifier;
|
$notifier = $this->container->get('notifier');
|
||||||
|
|
||||||
if (!isset($args['id']) || !$args['id'])
|
if (!isset($args['id']) || !$args['id'])
|
||||||
return $response->withStatus(404);
|
return $response->withStatus(404);
|
||||||
|
@ -526,12 +526,12 @@ class SeedDMS_ExtPaperless_RestAPI_Controller { /* {{{ */
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
function patch_saved_views($request, $response, $args) { /* {{{ */
|
function patch_saved_views($request, $response, $args) { /* {{{ */
|
||||||
$dms = $this->container->dms;
|
$dms = $this->container->get('dms');
|
||||||
$userobj = $this->container->userobj;
|
$userobj = $this->container->get('userobj');
|
||||||
$settings = $this->container->config;
|
$settings = $this->container->get('config');
|
||||||
$conversionmgr = $this->container->conversionmgr;
|
$conversionmgr = $this->container->get('conversionmgr');
|
||||||
$logger = $this->container->logger;
|
$logger = $this->container->get('logger');
|
||||||
$notifier = $this->container->notifier;
|
$notifier = $this->container->get('notifier');
|
||||||
|
|
||||||
if (!isset($args['id']) || !$args['id'])
|
if (!isset($args['id']) || !$args['id'])
|
||||||
return $response->withStatus(404);
|
return $response->withStatus(404);
|
||||||
|
@ -551,10 +551,10 @@ class SeedDMS_ExtPaperless_RestAPI_Controller { /* {{{ */
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
function storage_paths($request, $response) { /* {{{ */
|
function storage_paths($request, $response) { /* {{{ */
|
||||||
$dms = $this->container->dms;
|
$dms = $this->container->get('dms');
|
||||||
$userobj = $this->container->userobj;
|
$userobj = $this->container->get('userobj');
|
||||||
$settings = $this->container->config;
|
$settings = $this->container->get('config');
|
||||||
$logger = $this->container->logger;
|
$logger = $this->container->get('logger');
|
||||||
|
|
||||||
if(!empty($settings->_extensions['paperless']['usehomefolder'])) {
|
if(!empty($settings->_extensions['paperless']['usehomefolder'])) {
|
||||||
if(!($rootfolder = $dms->getFolder((int) $userobj->getHomeFolder())))
|
if(!($rootfolder = $dms->getFolder((int) $userobj->getHomeFolder())))
|
||||||
|
@ -576,11 +576,11 @@ class SeedDMS_ExtPaperless_RestAPI_Controller { /* {{{ */
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
function documents($request, $response) { /* {{{ */
|
function documents($request, $response) { /* {{{ */
|
||||||
$dms = $this->container->dms;
|
$dms = $this->container->get('dms');
|
||||||
$userobj = $this->container->userobj;
|
$userobj = $this->container->get('userobj');
|
||||||
$settings = $this->container->config;
|
$settings = $this->container->get('config');
|
||||||
$fulltextservice = $this->container->fulltextservice;
|
$fulltextservice = $this->container->get('fulltextservice');
|
||||||
$logger = $this->container->logger;
|
$logger = $this->container->get('logger');
|
||||||
|
|
||||||
$params = $request->getQueryParams();
|
$params = $request->getQueryParams();
|
||||||
$logger->log(var_export($params, true), PEAR_LOG_DEBUG);
|
$logger->log(var_export($params, true), PEAR_LOG_DEBUG);
|
||||||
|
@ -917,11 +917,11 @@ class SeedDMS_ExtPaperless_RestAPI_Controller { /* {{{ */
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
function document($request, $response, $args) { /* {{{ */
|
function document($request, $response, $args) { /* {{{ */
|
||||||
$dms = $this->container->dms;
|
$dms = $this->container->get('dms');
|
||||||
$userobj = $this->container->userobj;
|
$userobj = $this->container->get('userobj');
|
||||||
$settings = $this->container->config;
|
$settings = $this->container->get('config');
|
||||||
$fulltextservice = $this->container->fulltextservice;
|
$fulltextservice = $this->container->get('fulltextservice');
|
||||||
$logger = $this->container->logger;
|
$logger = $this->container->get('logger');
|
||||||
|
|
||||||
if (!isset($args['id']) || !$args['id'])
|
if (!isset($args['id']) || !$args['id'])
|
||||||
return $response->withStatus(404);
|
return $response->withStatus(404);
|
||||||
|
@ -947,11 +947,11 @@ class SeedDMS_ExtPaperless_RestAPI_Controller { /* {{{ */
|
||||||
* etc.
|
* etc.
|
||||||
*/
|
*/
|
||||||
function autocomplete($request, $response) { /* {{{ */
|
function autocomplete($request, $response) { /* {{{ */
|
||||||
$dms = $this->container->dms;
|
$dms = $this->container->get('dms');
|
||||||
$userobj = $this->container->userobj;
|
$userobj = $this->container->get('userobj');
|
||||||
$settings = $this->container->config;
|
$settings = $this->container->get('config');
|
||||||
$fulltextservice = $this->container->fulltextservice;
|
$fulltextservice = $this->container->get('fulltextservice');
|
||||||
$logger = $this->container->logger;
|
$logger = $this->container->get('logger');
|
||||||
|
|
||||||
if(!empty($settings->_extensions['paperless']['autocompletefield']))
|
if(!empty($settings->_extensions['paperless']['autocompletefield']))
|
||||||
$field = $settings->_extensions['paperless']['autocompletefield'];
|
$field = $settings->_extensions['paperless']['autocompletefield'];
|
||||||
|
@ -975,10 +975,10 @@ class SeedDMS_ExtPaperless_RestAPI_Controller { /* {{{ */
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
function ui_settings($request, $response) { /* {{{ */
|
function ui_settings($request, $response) { /* {{{ */
|
||||||
$dms = $this->container->dms;
|
$dms = $this->container->get('dms');
|
||||||
$userobj = $this->container->userobj;
|
$userobj = $this->container->get('userobj');
|
||||||
$settings = $this->container->config;
|
$settings = $this->container->get('config');
|
||||||
$logger = $this->container->logger;
|
$logger = $this->container->get('logger');
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
'user_id'=>$userobj->getId(),
|
'user_id'=>$userobj->getId(),
|
||||||
|
@ -1035,11 +1035,11 @@ class SeedDMS_ExtPaperless_RestAPI_Controller { /* {{{ */
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
function statstotal($request, $response) { /* {{{ */
|
function statstotal($request, $response) { /* {{{ */
|
||||||
$dms = $this->container->dms;
|
$dms = $this->container->get('dms');
|
||||||
$userobj = $this->container->userobj;
|
$userobj = $this->container->get('userobj');
|
||||||
$settings = $this->container->config;
|
$settings = $this->container->get('config');
|
||||||
$fulltextservice = $this->container->fulltextservice;
|
$fulltextservice = $this->container->get('fulltextservice');
|
||||||
$logger = $this->container->logger;
|
$logger = $this->container->get('logger');
|
||||||
|
|
||||||
if(false === ($categories = $dms->getDocumentCategories())) {
|
if(false === ($categories = $dms->getDocumentCategories())) {
|
||||||
return $response->withJson(array('results'=>null), 500);
|
return $response->withJson(array('results'=>null), 500);
|
||||||
|
@ -1095,11 +1095,11 @@ class SeedDMS_ExtPaperless_RestAPI_Controller { /* {{{ */
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
function documents_thumb($request, $response, $args) { /* {{{ */
|
function documents_thumb($request, $response, $args) { /* {{{ */
|
||||||
$dms = $this->container->dms;
|
$dms = $this->container->get('dms');
|
||||||
$userobj = $this->container->userobj;
|
$userobj = $this->container->get('userobj');
|
||||||
$settings = $this->container->config;
|
$settings = $this->container->get('config');
|
||||||
$conversionmgr = $this->container->conversionmgr;
|
$conversionmgr = $this->container->get('conversionmgr');
|
||||||
$logger = $this->container->logger;
|
$logger = $this->container->get('logger');
|
||||||
|
|
||||||
if (!isset($args['id']) || !$args['id'])
|
if (!isset($args['id']) || !$args['id'])
|
||||||
return $response->withStatus(404);
|
return $response->withStatus(404);
|
||||||
|
@ -1135,7 +1135,7 @@ class SeedDMS_ExtPaperless_RestAPI_Controller { /* {{{ */
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
function fetch_doc($request, $response, $args) { /* {{{ */
|
function fetch_doc($request, $response, $args) { /* {{{ */
|
||||||
$logger = $this->container->logger;
|
$logger = $this->container->get('logger');
|
||||||
$logger->log('Fetch doc '.$args['id'], PEAR_LOG_INFO);
|
$logger->log('Fetch doc '.$args['id'], PEAR_LOG_INFO);
|
||||||
return $response->withRedirect($request->getUri()->getBasePath().'/api/documents/'.$args['id'].'/download/', 302);
|
return $response->withRedirect($request->getUri()->getBasePath().'/api/documents/'.$args['id'].'/download/', 302);
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
@ -1145,11 +1145,11 @@ class SeedDMS_ExtPaperless_RestAPI_Controller { /* {{{ */
|
||||||
* documents which are not pdf already into pdf
|
* documents which are not pdf already into pdf
|
||||||
*/
|
*/
|
||||||
function documents_preview($request, $response, $args) { /* {{{ */
|
function documents_preview($request, $response, $args) { /* {{{ */
|
||||||
$dms = $this->container->dms;
|
$dms = $this->container->get('dms');
|
||||||
$userobj = $this->container->userobj;
|
$userobj = $this->container->get('userobj');
|
||||||
$settings = $this->container->config;
|
$settings = $this->container->get('config');
|
||||||
$conversionmgr = $this->container->conversionmgr;
|
$conversionmgr = $this->container->get('conversionmgr');
|
||||||
$logger = $this->container->logger;
|
$logger = $this->container->get('logger');
|
||||||
|
|
||||||
if (!isset($args['id']) || !$args['id'])
|
if (!isset($args['id']) || !$args['id'])
|
||||||
return $response->withStatus(404);
|
return $response->withStatus(404);
|
||||||
|
@ -1213,11 +1213,11 @@ class SeedDMS_ExtPaperless_RestAPI_Controller { /* {{{ */
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
function documents_download($request, $response, $args) { /* {{{ */
|
function documents_download($request, $response, $args) { /* {{{ */
|
||||||
$dms = $this->container->dms;
|
$dms = $this->container->get('dms');
|
||||||
$userobj = $this->container->userobj;
|
$userobj = $this->container->get('userobj');
|
||||||
$settings = $this->container->config;
|
$settings = $this->container->get('config');
|
||||||
$conversionmgr = $this->container->conversionmgr;
|
$conversionmgr = $this->container->get('conversionmgr');
|
||||||
$logger = $this->container->logger;
|
$logger = $this->container->get('logger');
|
||||||
|
|
||||||
if (!isset($args['id']) || !$args['id'])
|
if (!isset($args['id']) || !$args['id'])
|
||||||
return $response->withStatus(404);
|
return $response->withStatus(404);
|
||||||
|
@ -1290,11 +1290,11 @@ class SeedDMS_ExtPaperless_RestAPI_Controller { /* {{{ */
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
function documents_metadata($request, $response, $args) { /* {{{ */
|
function documents_metadata($request, $response, $args) { /* {{{ */
|
||||||
$dms = $this->container->dms;
|
$dms = $this->container->get('dms');
|
||||||
$userobj = $this->container->userobj;
|
$userobj = $this->container->get('userobj');
|
||||||
$settings = $this->container->config;
|
$settings = $this->container->get('config');
|
||||||
$conversionmgr = $this->container->conversionmgr;
|
$conversionmgr = $this->container->get('conversionmgr');
|
||||||
$logger = $this->container->logger;
|
$logger = $this->container->get('logger');
|
||||||
|
|
||||||
if (!isset($args['id']) || !$args['id'])
|
if (!isset($args['id']) || !$args['id'])
|
||||||
return $response->withStatus(404);
|
return $response->withStatus(404);
|
||||||
|
@ -1329,12 +1329,12 @@ class SeedDMS_ExtPaperless_RestAPI_Controller { /* {{{ */
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
function post_document($request, $response) { /* {{{ */
|
function post_document($request, $response) { /* {{{ */
|
||||||
$dms = $this->container->dms;
|
$dms = $this->container->get('dms');
|
||||||
$userobj = $this->container->userobj;
|
$userobj = $this->container->get('userobj');
|
||||||
$settings = $this->container->config;
|
$settings = $this->container->get('config');
|
||||||
$logger = $this->container->logger;
|
$logger = $this->container->get('logger');
|
||||||
$fulltextservice = $this->container->fulltextservice;
|
$fulltextservice = $this->container->get('fulltextservice');
|
||||||
$notifier = $this->container->notifier;
|
$notifier = $this->container->get('notifier');
|
||||||
|
|
||||||
if(isset($settings->_extensions['paperless']['uploadfolder']))
|
if(isset($settings->_extensions['paperless']['uploadfolder']))
|
||||||
$mfolder = $dms->getFolder($settings->_extensions['paperless']['uploadfolder']);
|
$mfolder = $dms->getFolder($settings->_extensions['paperless']['uploadfolder']);
|
||||||
|
@ -1502,12 +1502,12 @@ class SeedDMS_ExtPaperless_RestAPI_Controller { /* {{{ */
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
function patch_documents($request, $response, $args) { /* {{{ */
|
function patch_documents($request, $response, $args) { /* {{{ */
|
||||||
$dms = $this->container->dms;
|
$dms = $this->container->get('dms');
|
||||||
$userobj = $this->container->userobj;
|
$userobj = $this->container->get('userobj');
|
||||||
$settings = $this->container->config;
|
$settings = $this->container->get('config');
|
||||||
$conversionmgr = $this->container->conversionmgr;
|
$conversionmgr = $this->container->get('conversionmgr');
|
||||||
$logger = $this->container->logger;
|
$logger = $this->container->get('logger');
|
||||||
$fulltextservice = $this->container->fulltextservice;
|
$fulltextservice = $this->container->get('fulltextservice');
|
||||||
|
|
||||||
if (!isset($args['id']) || !$args['id'])
|
if (!isset($args['id']) || !$args['id'])
|
||||||
return $response->withStatus(404);
|
return $response->withStatus(404);
|
||||||
|
@ -1547,12 +1547,12 @@ class SeedDMS_ExtPaperless_RestAPI_Controller { /* {{{ */
|
||||||
* is still disregarded.
|
* is still disregarded.
|
||||||
*/
|
*/
|
||||||
function put_documents($request, $response, $args) { /* {{{ */
|
function put_documents($request, $response, $args) { /* {{{ */
|
||||||
$dms = $this->container->dms;
|
$dms = $this->container->get('dms');
|
||||||
$userobj = $this->container->userobj;
|
$userobj = $this->container->get('userobj');
|
||||||
$settings = $this->container->config;
|
$settings = $this->container->get('config');
|
||||||
$conversionmgr = $this->container->conversionmgr;
|
$conversionmgr = $this->container->get('conversionmgr');
|
||||||
$logger = $this->container->logger;
|
$logger = $this->container->get('logger');
|
||||||
$fulltextservice = $this->container->fulltextservice;
|
$fulltextservice = $this->container->get('fulltextservice');
|
||||||
|
|
||||||
if (!isset($args['id']) || !$args['id'])
|
if (!isset($args['id']) || !$args['id'])
|
||||||
return $response->withStatus(404);
|
return $response->withStatus(404);
|
||||||
|
@ -1605,13 +1605,13 @@ class SeedDMS_ExtPaperless_RestAPI_Controller { /* {{{ */
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
function delete_documents($request, $response, $args) { /* {{{ */
|
function delete_documents($request, $response, $args) { /* {{{ */
|
||||||
$dms = $this->container->dms;
|
$dms = $this->container->get('dms');
|
||||||
$userobj = $this->container->userobj;
|
$userobj = $this->container->get('userobj');
|
||||||
$settings = $this->container->config;
|
$settings = $this->container->get('config');
|
||||||
$conversionmgr = $this->container->conversionmgr;
|
$conversionmgr = $this->container->get('conversionmgr');
|
||||||
$logger = $this->container->logger;
|
$logger = $this->container->get('logger');
|
||||||
$notifier = $this->container->notifier;
|
$notifier = $this->container->get('notifier');
|
||||||
$fulltextservice = $this->container->fulltextservice;
|
$fulltextservice = $this->container->get('fulltextservice');
|
||||||
|
|
||||||
if (!isset($args['id']) || !$args['id'])
|
if (!isset($args['id']) || !$args['id'])
|
||||||
return $response->withStatus(404);
|
return $response->withStatus(404);
|
||||||
|
@ -1671,14 +1671,14 @@ class SeedDMS_ExtPaperless_RestAPI_Auth { /* {{{ */
|
||||||
*/
|
*/
|
||||||
public function __invoke($request, $response, $next) { /* {{{ */
|
public function __invoke($request, $response, $next) { /* {{{ */
|
||||||
// $this->container has the DI
|
// $this->container has the DI
|
||||||
$dms = $this->container->dms;
|
$dms = $this->container->get('dms');
|
||||||
$settings = $this->container->config;
|
$settings = $this->container->get('config');
|
||||||
$logger = $this->container->logger;
|
$logger = $this->container->get('logger');
|
||||||
|
|
||||||
/* Skip this middleware if the authentication was already successful */
|
/* Skip this middleware if the authentication was already successful */
|
||||||
$userobj = null;
|
$userobj = null;
|
||||||
if($this->container->has('userobj'))
|
if($this->container->has('userobj'))
|
||||||
$userobj = $this->container->userobj;
|
$userobj = $this->container->get('userobj');
|
||||||
|
|
||||||
if($userobj) {
|
if($userobj) {
|
||||||
$response = $next($request, $response);
|
$response = $next($request, $response);
|
||||||
|
@ -1714,7 +1714,10 @@ class SeedDMS_ExtPaperless_RestAPI_Auth { /* {{{ */
|
||||||
return $response->withJson("No such user", 403);
|
return $response->withJson("No such user", 403);
|
||||||
}
|
}
|
||||||
$dms->setUser($userobj);
|
$dms->setUser($userobj);
|
||||||
$this->container['userobj'] = $userobj;
|
if($this->container instanceof \Slim\Container)
|
||||||
|
$this->container['userobj'] = $userobj;
|
||||||
|
else
|
||||||
|
$this->container->set('userobj', $userobj);
|
||||||
$logger->log("Login with jwt as '".$userobj->getLogin()."' successful", PEAR_LOG_INFO);
|
$logger->log("Login with jwt as '".$userobj->getLogin()."' successful", PEAR_LOG_INFO);
|
||||||
} else {
|
} else {
|
||||||
if(!empty($settings->_apiKey) && !empty($settings->_apiUserId)) {
|
if(!empty($settings->_apiKey) && !empty($settings->_apiUserId)) {
|
||||||
|
@ -1727,13 +1730,16 @@ class SeedDMS_ExtPaperless_RestAPI_Auth { /* {{{ */
|
||||||
return $response->withStatus(403);
|
return $response->withStatus(403);
|
||||||
}
|
}
|
||||||
$dms->setUser($userobj);
|
$dms->setUser($userobj);
|
||||||
$this->container['userobj'] = $userobj;
|
if($this->container instanceof \Slim\Container)
|
||||||
|
$this->container['userobj'] = $userobj;
|
||||||
|
else
|
||||||
|
$this->container->set('userobj', $userobj);
|
||||||
$logger->log("Login with apikey as '".$userobj->getLogin()."' successful", PEAR_LOG_INFO);
|
$logger->log("Login with apikey as '".$userobj->getLogin()."' successful", PEAR_LOG_INFO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'Basic':
|
case 'Basic':
|
||||||
$authenticator = $this->container->authenticator;
|
$authenticator = $this->container->get('authenticator');
|
||||||
$kk = explode(':', base64_decode($tmp[1]));
|
$kk = explode(':', base64_decode($tmp[1]));
|
||||||
$userobj = $authenticator->authenticate($kk[0], $kk[1]);
|
$userobj = $authenticator->authenticate($kk[0], $kk[1]);
|
||||||
if(!$userobj) {
|
if(!$userobj) {
|
||||||
|
@ -1741,14 +1747,20 @@ class SeedDMS_ExtPaperless_RestAPI_Auth { /* {{{ */
|
||||||
return $response->withStatus(403);
|
return $response->withStatus(403);
|
||||||
}
|
}
|
||||||
$dms->setUser($userobj);
|
$dms->setUser($userobj);
|
||||||
$this->container['userobj'] = $userobj;
|
if($this->container instanceof \Slim\Container)
|
||||||
|
$this->container['userobj'] = $userobj;
|
||||||
|
else
|
||||||
|
$this->container->set('userobj', $userobj);
|
||||||
$logger->log("Login with basic authentication as '".$userobj->getLogin()."' successful", PEAR_LOG_INFO);
|
$logger->log("Login with basic authentication as '".$userobj->getLogin()."' successful", PEAR_LOG_INFO);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Set userobj to keep other middlewares for authentication from running */
|
/* Set userobj to keep other middlewares for authentication from running */
|
||||||
$this->container['userobj'] = true;
|
if($this->container instanceof \Slim\Container)
|
||||||
|
$this->container['userobj'] = true;
|
||||||
|
else
|
||||||
|
$this->container->set('userobj', true);
|
||||||
}
|
}
|
||||||
$logger->log("End of paperless middleware for method ".$request->getMethod()." on '".$request->getUri()->getPath()."'", PEAR_LOG_INFO);
|
$logger->log("End of paperless middleware for method ".$request->getMethod()." on '".$request->getUri()->getPath()."'", PEAR_LOG_INFO);
|
||||||
$response = $next($request, $response);
|
$response = $next($request, $response);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user