Clean space DefaultController

This commit is contained in:
Carlos Ferreira 2018-01-12 12:34:02 +01:00 committed by GitHub
parent ab6248ed6a
commit fab7e58f24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,7 +2,7 @@
/** /**
* @link https://www.humhub.org/ * @link https://www.humhub.org/
* @copyright Copyright (c) 2016 HumHub GmbH & Co. KG * @copyright Copyright (c) 2018 HumHub GmbH & Co. KG
* @license https://www.humhub.com/licences * @license https://www.humhub.com/licences
*/ */
@ -11,6 +11,7 @@ namespace humhub\modules\space\modules\manage\controllers;
use Yii; use Yii;
use humhub\modules\space\models\Space; use humhub\modules\space\models\Space;
use humhub\modules\space\modules\manage\models\AdvancedSettingsSpace; use humhub\modules\space\modules\manage\models\AdvancedSettingsSpace;
use humhub\modules\space\widgets\Menu;
use humhub\modules\space\widgets\Chooser; use humhub\modules\space\widgets\Chooser;
use humhub\modules\space\modules\manage\components\Controller; use humhub\modules\space\modules\manage\components\Controller;
use humhub\modules\space\modules\manage\models\DeleteForm; use humhub\modules\space\modules\manage\models\DeleteForm;
@ -32,6 +33,7 @@ class DefaultController extends Controller
$result[] = [ $result[] = [
'userGroup' => [Space::USERGROUP_OWNER], 'actions' => ['archive', 'unarchive', 'delete'] 'userGroup' => [Space::USERGROUP_OWNER], 'actions' => ['archive', 'unarchive', 'delete']
]; ];
return $result; return $result;
} }
@ -47,6 +49,7 @@ class DefaultController extends Controller
$this->view->saved(); $this->view->saved();
return $this->redirect($space->createUrl('index')); return $this->redirect($space->createUrl('index'));
} }
return $this->render('index', ['model' => $space]); return $this->render('index', ['model' => $space]);
} }
@ -62,11 +65,11 @@ class DefaultController extends Controller
return $this->redirect($space->createUrl('advanced')); return $this->redirect($space->createUrl('advanced'));
} }
$indexModuleSelection = \humhub\modules\space\widgets\Menu::getAvailablePages(); $indexModuleSelection = Menu::getAvailablePages();
//To avoid infinit redirects of actionIndex we remove the stream value and set an empty selection instead // To avoid infinit redirects of actionIndex we remove the stream value and set an empty selection instead
array_shift($indexModuleSelection); array_shift($indexModuleSelection);
$indexModuleSelection = ["" => Yii::t('SpaceModule.controllers_AdminController', 'Stream (Default)')] + $indexModuleSelection; $indexModuleSelection = ['' => Yii::t('SpaceModule.controllers_AdminController', 'Stream (Default)')] + $indexModuleSelection;
return $this->render('advanced', ['model' => $space, 'indexModuleSelection' => $indexModuleSelection]); return $this->render('advanced', ['model' => $space, 'indexModuleSelection' => $indexModuleSelection]);
} }
@ -79,7 +82,7 @@ class DefaultController extends Controller
$space = $this->getSpace(); $space = $this->getSpace();
$space->archive(); $space->archive();
if(Yii::$app->request->isAjax) { if (Yii::$app->request->isAjax) {
Yii::$app->response->format = 'json'; Yii::$app->response->format = 'json';
return [ return [
'success' => true, 'success' => true,
@ -98,7 +101,7 @@ class DefaultController extends Controller
$space = $this->getSpace(); $space = $this->getSpace();
$space->unarchive(); $space->unarchive();
if(Yii::$app->request->isAjax) { if (Yii::$app->request->isAjax) {
Yii::$app->response->format = 'json'; Yii::$app->response->format = 'json';
return [ return [
'success' => true, 'success' => true,
@ -110,7 +113,7 @@ class DefaultController extends Controller
} }
/** /**
* Deletes this Space * Deletes the space
*/ */
public function actionDelete() public function actionDelete()
{ {
@ -124,5 +127,3 @@ class DefaultController extends Controller
} }
} }
?>