mirror of
https://github.com/humhub/humhub.git
synced 2025-02-25 03:34:10 +01:00
Clean space DefaultController
This commit is contained in:
parent
ab6248ed6a
commit
fab7e58f24
@ -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]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,17 +59,17 @@ class DefaultController extends Controller
|
|||||||
$space->scenario = 'edit';
|
$space->scenario = 'edit';
|
||||||
$space->indexUrl = Yii::$app->getModule('space')->settings->space()->get('indexUrl');
|
$space->indexUrl = Yii::$app->getModule('space')->settings->space()->get('indexUrl');
|
||||||
$space->indexGuestUrl = Yii::$app->getModule('space')->settings->space()->get('indexGuestUrl');
|
$space->indexGuestUrl = Yii::$app->getModule('space')->settings->space()->get('indexGuestUrl');
|
||||||
|
|
||||||
if ($space->load(Yii::$app->request->post()) && $space->validate() && $space->save()) {
|
if ($space->load(Yii::$app->request->post()) && $space->validate() && $space->save()) {
|
||||||
$this->view->saved();
|
$this->view->saved();
|
||||||
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]);
|
||||||
}
|
}
|
||||||
@ -78,15 +81,15 @@ 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,
|
||||||
'space' => Chooser::getSpaceResult($space, true, ['isMember' => true])
|
'space' => Chooser::getSpaceResult($space, true, ['isMember' => true])
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->redirect($space->createUrl('/space/manage'));
|
return $this->redirect($space->createUrl('/space/manage'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,20 +100,20 @@ 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,
|
||||||
'space' => Chooser::getSpaceResult($space, true, ['isMember' => true])
|
'space' => Chooser::getSpaceResult($space, true, ['isMember' => true])
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->redirect($space->createUrl('/space/manage'));
|
return $this->redirect($space->createUrl('/space/manage'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes this Space
|
* Deletes the space
|
||||||
*/
|
*/
|
||||||
public function actionDelete()
|
public function actionDelete()
|
||||||
{
|
{
|
||||||
@ -124,5 +127,3 @@ class DefaultController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user