diff --git a/CHANGELOG b/CHANGELOG index f3f57e113..7955bf7f5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -203,6 +203,7 @@ -------------------------------------------------------------------------------- - output path of parent folder in many document/folder lists - list affected documents when transfering processes to another user +- check for quota and duplicate content in restapi -------------------------------------------------------------------------------- Changes in version 5.1.22 diff --git a/inc/inc.ClassUI.php b/inc/inc.ClassUI.php index 2b601f65e..4114cb7f2 100644 --- a/inc/inc.ClassUI.php +++ b/inc/inc.ClassUI.php @@ -183,10 +183,12 @@ class UI extends UI_Default { } /* }}} */ static function exitError($pagetitle, $error, $noexit=false, $plain=false) { - global $theme, $dms, $user; + global $theme, $dms, $user, $settings; + $accessop = new SeedDMS_AccessOperation($dms, null, $user, $settings); $view = UI::factory($theme, 'ErrorDlg'); $view->setParam('dms', $dms); $view->setParam('user', $user); + $view->setParam('accessobject', $accessop); $view->setParam('pagetitle', $pagetitle); $view->setParam('errormsg', $error); $view->setParam('plain', $plain); diff --git a/out/out.ErrorDlg.php b/out/out.ErrorDlg.php index bbea7a3ec..6681f02c8 100644 --- a/out/out.ErrorDlg.php +++ b/out/out.ErrorDlg.php @@ -37,7 +37,10 @@ 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); + if($view) { + $view->setParam('accessobject', $accessop); $view($_GET); exit; } diff --git a/restapi/index.php b/restapi/index.php index e402228c9..227631ec3 100644 --- a/restapi/index.php +++ b/restapi/index.php @@ -595,6 +595,13 @@ class RestapiController { /* {{{ */ return $response->withJson(array('success'=>false, 'message'=>'No parent folder id given', 'data'=>''), 400); } + if($settings->_quota > 0) { + $remain = checkQuota($userobj); + if ($remain < 0) { + return $response->withJson(array('success'=>false, 'message'=>'Quota exceeded', 'data'=>''), 400); + } + } + $mfolder = $dms->getFolder($args['id']); if($mfolder) { $uploadedFiles = $request->getUploadedFiles(); @@ -692,6 +699,7 @@ class RestapiController { /* {{{ */ function updateDocument($request, $response, $args) { /* {{{ */ $dms = $this->container->dms; $userobj = $this->container->userobj; + $settings = $this->container->config; if(!$userobj) { return $response->withJson(array('success'=>false, 'message'=>'Not logged in', 'data'=>''), 403); @@ -701,6 +709,13 @@ class RestapiController { /* {{{ */ return $response->withJson(array('success'=>false, 'message'=>'No document id given', 'data'=>''), 400); } + if($settings->_quota > 0) { + $remain = checkQuota($userobj); + if ($remain < 0) { + return $response->withJson(array('success'=>false, 'message'=>'Quota exceeded', 'data'=>''), 400); + } + } + $document = $dms->getDocument($args['id']); if($document) { if ($document->getAccessMode($userobj, 'updateDocument') >= M_READWRITE) { @@ -726,7 +741,13 @@ class RestapiController { /* {{{ */ $file_info = array_pop($uploadedFiles); if ($origfilename == null) $origfilename = $file_info->getClientFilename(); - $temp = $file_info->file; + $temp = $file_info->file; + + /* Check if the uploaded file is identical to last version */ + $lc = $document->getLatestContent(); + if($lc->getChecksum() == SeedDMS_Core_File::checksum($temp)) { + return $response->withJson(array('success'=>false, 'message'=>'Uploaded file identical to last version', 'data'=>''), 400); + } $finfo = finfo_open(FILEINFO_MIME_TYPE); $userfiletype = finfo_file($finfo, $temp); $fileType = ".".pathinfo($origfilename, PATHINFO_EXTENSION); @@ -762,7 +783,15 @@ class RestapiController { /* {{{ */ if(!ctype_digit($args['id']) || $args['id'] == 0) { return $response->withJson(array('success'=>false, 'message'=>'No document id given', 'data'=>''), 400); - } + } + + if($settings->_quota > 0) { + $remain = checkQuota($userobj); + if ($remain < 0) { + return $response->withJson(array('success'=>false, 'message'=>'Quota exceeded', 'data'=>''), 400); + } + } + $mfolder = $dms->getFolder($args['id']); if($mfolder) { if ($mfolder->getAccessMode($userobj, 'addDocument') >= M_READWRITE) { diff --git a/views/bootstrap/class.Settings.php b/views/bootstrap/class.Settings.php index 1f0655d8f..4ddff2538 100644 --- a/views/bootstrap/class.Settings.php +++ b/views/bootstrap/class.Settings.php @@ -32,13 +32,13 @@ class SeedDMS_View_Settings extends SeedDMS_Theme_Style { protected function showPaneHeader($name, $title, $isactive) { /* {{{ */ - echo '
= getMLText($title) ?>: | - |