diff --git a/CHANGELOG.md b/CHANGELOG.md index 624ebb3c62..1a95e317b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## Unreleased +- Fix #2033: Create a mockup for all upload statuses except published - Feat #2066: Update file attribute values form layout and add expand button for long values - Feat #2102: Delete outdated apidocs files - Feat #1667: Add log entry when minting DOI diff --git a/protected/controllers/AdminDatasetController.php b/protected/controllers/AdminDatasetController.php index e40f931e7a..e2ca16c5c1 100644 --- a/protected/controllers/AdminDatasetController.php +++ b/protected/controllers/AdminDatasetController.php @@ -327,16 +327,26 @@ public function actionUpdate($id) */ public function actionPrivate() { - $id = $_GET['identifier']; + $id = Yii::$app->request->get('identifier'); $model= Dataset::model()->find("identifier=?", array($id)); $datasetPageSettings = new DatasetPageSettings($model); - if ( "invalid" === $datasetPageSettings->getPageType() ) { + $pageType = $datasetPageSettings->getPageType(); + + if (!in_array($pageType, ['invalid', 'public', 'hidden', 'draft', 'mockup'])) { + throw new CHttpException(404, 'Page type not found'); + } + + if ( "invalid" === $pageType) { $this->redirect('/site/index'); - } elseif ( "public" === $datasetPageSettings->getPageType() ) { + } elseif ( "public" === $pageType) { $this->redirect('/dataset/'.$model->identifier); - } elseif ( "hidden" === $datasetPageSettings->getPageType() || "draft" === $datasetPageSettings->getPageType() ) { + } else { $model->token = Yii::$app->security->generateRandomString(16); - $model->save(); + + if (!$model->save()) { + throw new CHttpException(500, 'Fail to update dataset token'); + } + $this->redirect('/dataset/'.$model->identifier.'/token/'.$model->token); } } diff --git a/protected/views/adminDataset/_form.php b/protected/views/adminDataset/_form.php index fca4062026..1b2ea71487 100644 --- a/protected/views/adminDataset/_form.php +++ b/protected/views/adminDataset/_form.php @@ -5,7 +5,7 @@ user->getFlash('updateError')) { ?> -