mirror of
https://github.com/humhub/humhub.git
synced 2025-01-17 14:18:27 +01:00
Added space pretty urls, cleanup space controls menu
This commit is contained in:
parent
81446fa858
commit
21dab558df
@ -23,6 +23,7 @@
|
|||||||
"cebe/markdown": "1.0.2",
|
"cebe/markdown": "1.0.2",
|
||||||
"yiisoft/yii2-jui": "^2.0",
|
"yiisoft/yii2-jui": "^2.0",
|
||||||
"zendframework/zend-http": "*",
|
"zendframework/zend-http": "*",
|
||||||
|
"jbroadway/urlify": "^1.0",
|
||||||
"nqxcode/zendsearch": "^2.0",
|
"nqxcode/zendsearch": "^2.0",
|
||||||
"xj/yii2-jplayer-widget": "*",
|
"xj/yii2-jplayer-widget": "*",
|
||||||
"zendframework/zend-ldap": "^2.5",
|
"zendframework/zend-ldap": "^2.5",
|
||||||
|
@ -15,6 +15,11 @@ Here you will learn how you can adapt existing modules to working fine with actu
|
|||||||
|
|
||||||
- system_admin attribute in user table was removed
|
- system_admin attribute in user table was removed
|
||||||
|
|
||||||
|
- Renamed space header settings menu dropdown class
|
||||||
|
from humhub\modules\space\modules\manage\widgets\Menu to humhub\modules\space\widgets\HeaderControlMenu
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## to 0.20
|
## to 0.20
|
||||||
|
|
||||||
|
@ -2,13 +2,12 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @link https://www.humhub.org/
|
* @link https://www.humhub.org/
|
||||||
* @copyright Copyright (c) 2015 HumHub GmbH & Co. KG
|
* @copyright Copyright (c) 2016 HumHub GmbH & Co. KG
|
||||||
* @license https://www.humhub.com/licences
|
* @license https://www.humhub.com/licences
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace humhub\modules\space\components;
|
namespace humhub\modules\space\components;
|
||||||
|
|
||||||
use yii\helpers\Url;
|
|
||||||
use yii\web\UrlRuleInterface;
|
use yii\web\UrlRuleInterface;
|
||||||
use yii\base\Object;
|
use yii\base\Object;
|
||||||
use humhub\modules\space\models\Space;
|
use humhub\modules\space\models\Space;
|
||||||
@ -26,6 +25,11 @@ class UrlRule extends Object implements UrlRuleInterface
|
|||||||
*/
|
*/
|
||||||
public $defaultRoute = 'space/space';
|
public $defaultRoute = 'space/space';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array map with space guid/url pairs
|
||||||
|
*/
|
||||||
|
protected static $spaceUrlMap = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
@ -35,13 +39,17 @@ class UrlRule extends Object implements UrlRuleInterface
|
|||||||
if ($route == $this->defaultRoute) {
|
if ($route == $this->defaultRoute) {
|
||||||
$route = '';
|
$route = '';
|
||||||
}
|
}
|
||||||
$url = "s/" . urlencode($params['sguid']) . "/" . $route;
|
|
||||||
unset($params['sguid']);
|
|
||||||
|
|
||||||
if (!empty($params) && ($query = http_build_query($params)) !== '') {
|
$urlPart = static::getUrlBySpaceGuid($params['sguid']);
|
||||||
$url .= '?' . $query;
|
if ($urlPart !== null) {
|
||||||
|
$url = "s/" . urlencode($urlPart) . "/" . $route;
|
||||||
|
unset($params['sguid']);
|
||||||
|
|
||||||
|
if (!empty($params) && ($query = http_build_query($params)) !== '') {
|
||||||
|
$url .= '?' . $query;
|
||||||
|
}
|
||||||
|
return $url;
|
||||||
}
|
}
|
||||||
return $url;
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -55,7 +63,7 @@ class UrlRule extends Object implements UrlRuleInterface
|
|||||||
if (substr($pathInfo, 0, 2) == "s/") {
|
if (substr($pathInfo, 0, 2) == "s/") {
|
||||||
$parts = explode('/', $pathInfo, 3);
|
$parts = explode('/', $pathInfo, 3);
|
||||||
if (isset($parts[1])) {
|
if (isset($parts[1])) {
|
||||||
$space = Space::find()->where(['guid' => $parts[1]])->one();
|
$space = Space::find()->where(['guid' => $parts[1]])->orWhere(['url' => $parts[1]])->one();
|
||||||
if ($space !== null) {
|
if ($space !== null) {
|
||||||
if (!isset($parts[2]) || $parts[2] == "") {
|
if (!isset($parts[2]) || $parts[2] == "") {
|
||||||
$parts[2] = $this->defaultRoute;
|
$parts[2] = $this->defaultRoute;
|
||||||
@ -71,4 +79,25 @@ class UrlRule extends Object implements UrlRuleInterface
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets space url name by given guid
|
||||||
|
*
|
||||||
|
* @param string $guid
|
||||||
|
* @return string|null the space url part
|
||||||
|
*/
|
||||||
|
public static function getUrlBySpaceGuid($guid)
|
||||||
|
{
|
||||||
|
if (isset(static::$spaceUrlMap[$guid])) {
|
||||||
|
return static::$spaceUrlMap[$guid];
|
||||||
|
}
|
||||||
|
|
||||||
|
$space = Space::findOne(['guid' => $guid]);
|
||||||
|
if ($space !== null) {
|
||||||
|
static::$spaceUrlMap[$space->guid] = ($space->url != '') ? $space->url : $space->guid;
|
||||||
|
return static::$spaceUrlMap[$space->guid];
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
71
protected/humhub/modules/space/components/UrlValidator.php
Normal file
71
protected/humhub/modules/space/components/UrlValidator.php
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @link https://www.humhub.org/
|
||||||
|
* @copyright Copyright (c) 2016 HumHub GmbH & Co. KG
|
||||||
|
* @license https://www.humhub.com/licences
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace humhub\modules\space\components;
|
||||||
|
|
||||||
|
use Yii;
|
||||||
|
use yii\validators\Validator;
|
||||||
|
use URLify;
|
||||||
|
use humhub\modules\space\models\Space;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UrlValidator for space urls
|
||||||
|
*
|
||||||
|
* @since 1.1
|
||||||
|
* @author Luke
|
||||||
|
*/
|
||||||
|
class UrlValidator extends Validator
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public function validateAttribute($model, $attribute)
|
||||||
|
{
|
||||||
|
$value = $model->$attribute;
|
||||||
|
if (mb_strtolower($value) != URLify::filter($value, 45)) {
|
||||||
|
$this->addError($model, $attribute, Yii::t('SpaceModule.manage', 'The url contains illegal characters!'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate a unique space url
|
||||||
|
*
|
||||||
|
* @param string $name
|
||||||
|
* @return string a unique space url
|
||||||
|
*/
|
||||||
|
public static function autogenerateUniqueSpaceUrl($name)
|
||||||
|
{
|
||||||
|
$maxUrlLength = 45;
|
||||||
|
|
||||||
|
$url = URLify::filter($name, $maxUrlLength - 4);
|
||||||
|
|
||||||
|
// Get a list of all similar space urls
|
||||||
|
$existingSpaceUrls = [];
|
||||||
|
foreach (Space::find()->where(['LIKE', 'url', $url . '%', false])->all() as $space) {
|
||||||
|
$existingSpaceUrls[] = $space->url;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Url is free
|
||||||
|
if (!in_array($url, $existingSpaceUrls)) {
|
||||||
|
return $url;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add number to taken url
|
||||||
|
for ($i = 0; $i <= count($existingSpaceUrls); $i++) {
|
||||||
|
$tryUrl = $url . ($i + 2);
|
||||||
|
if (!in_array($tryUrl, $existingSpaceUrls)) {
|
||||||
|
return $tryUrl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Shouldn't never happen - failed
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\db\Query;
|
||||||
|
use humhub\components\Migration;
|
||||||
|
|
||||||
|
class m160509_214811_spaceurl extends Migration
|
||||||
|
{
|
||||||
|
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
$this->addColumn('space', 'url', $this->string(45));
|
||||||
|
$this->createIndex('url-unique', 'space', 'url', true);
|
||||||
|
|
||||||
|
$rows = (new Query())
|
||||||
|
->select("*")
|
||||||
|
->from('space')
|
||||||
|
->all();
|
||||||
|
foreach ($rows as $row) {
|
||||||
|
$url = \humhub\modules\space\components\UrlValidator::autogenerateUniqueSpaceUrl($row['name']);
|
||||||
|
$this->updateSilent('space', ['url' => $url], ['id' => $row['id']]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
echo "m160509_214811_spaceurl cannot be reverted.\n";
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Use safeUp/safeDown to run migration code within a transaction
|
||||||
|
public function safeUp()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function safeDown()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
@ -12,6 +12,7 @@ use Yii;
|
|||||||
use humhub\modules\space\models\Membership;
|
use humhub\modules\space\models\Membership;
|
||||||
use humhub\modules\space\permissions\CreatePrivateSpace;
|
use humhub\modules\space\permissions\CreatePrivateSpace;
|
||||||
use humhub\modules\space\permissions\CreatePublicSpace;
|
use humhub\modules\space\permissions\CreatePublicSpace;
|
||||||
|
use humhub\modules\space\components\UrlValidator;
|
||||||
use humhub\modules\content\models\Content;
|
use humhub\modules\content\models\Content;
|
||||||
use humhub\modules\content\components\ContentContainerActiveRecord;
|
use humhub\modules\content\components\ContentContainerActiveRecord;
|
||||||
use humhub\modules\user\models\User;
|
use humhub\modules\user\models\User;
|
||||||
@ -24,6 +25,7 @@ use humhub\modules\user\models\User;
|
|||||||
* @property integer $wall_id
|
* @property integer $wall_id
|
||||||
* @property string $name
|
* @property string $name
|
||||||
* @property string $description
|
* @property string $description
|
||||||
|
* @property string $url
|
||||||
* @property integer $join_policy
|
* @property integer $join_policy
|
||||||
* @property integer $visibility
|
* @property integer $visibility
|
||||||
* @property integer $status
|
* @property integer $status
|
||||||
@ -61,7 +63,7 @@ class Space extends ContentContainerActiveRecord implements \humhub\modules\sear
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains the form value for indexUrl setting
|
* Contains the form value for indexUrl setting
|
||||||
* @var type
|
* @var string|null
|
||||||
*/
|
*/
|
||||||
public $indexUrl = null;
|
public $indexUrl = null;
|
||||||
|
|
||||||
@ -87,10 +89,12 @@ class Space extends ContentContainerActiveRecord implements \humhub\modules\sear
|
|||||||
[['join_policy'], 'in', 'range' => [0, 1, 2]],
|
[['join_policy'], 'in', 'range' => [0, 1, 2]],
|
||||||
[['visibility'], 'in', 'range' => [0, 1, 2]],
|
[['visibility'], 'in', 'range' => [0, 1, 2]],
|
||||||
[['visibility'], 'checkVisibility'],
|
[['visibility'], 'checkVisibility'],
|
||||||
[['guid', 'name'], 'string', 'max' => 45],
|
[['url'], 'unique', 'skipOnEmpty' => 'true'],
|
||||||
|
[['guid', 'name', 'url'], 'string', 'max' => 45, 'min' => 2],
|
||||||
|
[['url'], UrlValidator::className()],
|
||||||
];
|
];
|
||||||
|
|
||||||
if(Yii::$app->getModule('space')->useUniqueSpaceNames) {
|
if (Yii::$app->getModule('space')->useUniqueSpaceNames) {
|
||||||
$rules[] = [['name'], 'unique', 'targetClass' => self::className()];
|
$rules[] = [['name'], 'unique', 'targetClass' => self::className()];
|
||||||
}
|
}
|
||||||
return $rules;
|
return $rules;
|
||||||
@ -103,7 +107,7 @@ class Space extends ContentContainerActiveRecord implements \humhub\modules\sear
|
|||||||
{
|
{
|
||||||
$scenarios = parent::scenarios();
|
$scenarios = parent::scenarios();
|
||||||
|
|
||||||
$scenarios['edit'] = ['name', 'color', 'description', 'tags', 'indexUrl', 'join_policy', 'visibility', 'default_content_visibility'];
|
$scenarios['edit'] = ['name', 'color', 'description', 'tags', 'indexUrl', 'join_policy', 'visibility', 'default_content_visibility', 'url'];
|
||||||
$scenarios['create'] = ['name', 'color', 'description', 'join_policy', 'visibility'];
|
$scenarios['create'] = ['name', 'color', 'description', 'join_policy', 'visibility'];
|
||||||
|
|
||||||
return $scenarios;
|
return $scenarios;
|
||||||
@ -129,6 +133,7 @@ class Space extends ContentContainerActiveRecord implements \humhub\modules\sear
|
|||||||
'updated_at' => Yii::t('SpaceModule.models_Space', 'Updated At'),
|
'updated_at' => Yii::t('SpaceModule.models_Space', 'Updated At'),
|
||||||
'updated_by' => Yii::t('SpaceModule.models_Space', 'Updated by'),
|
'updated_by' => Yii::t('SpaceModule.models_Space', 'Updated by'),
|
||||||
'ownerUsernameSearch' => Yii::t('SpaceModule.models_Space', 'Owner'),
|
'ownerUsernameSearch' => Yii::t('SpaceModule.models_Space', 'Owner'),
|
||||||
|
'indexUrl' => Yii::t('SpaceModule.models_Space', 'Homepage'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,7 +177,7 @@ class Space extends ContentContainerActiveRecord implements \humhub\modules\sear
|
|||||||
$activity->create();
|
$activity->create();
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->indexUrl != null) {
|
if ($this->indexUrl != null) {
|
||||||
Yii::$app->getModule('space')->settings->contentContainer($this)->set('indexUrl', $this->indexUrl);
|
Yii::$app->getModule('space')->settings->contentContainer($this)->set('indexUrl', $this->indexUrl);
|
||||||
} else {
|
} else {
|
||||||
//Remove entry from db
|
//Remove entry from db
|
||||||
@ -182,6 +187,24 @@ class Space extends ContentContainerActiveRecord implements \humhub\modules\sear
|
|||||||
Yii::$app->cache->delete('userSpaces_' . $user->id);
|
Yii::$app->cache->delete('userSpaces_' . $user->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public function beforeSave($insert)
|
||||||
|
{
|
||||||
|
if ($insert) {
|
||||||
|
$this->url = UrlValidator::autogenerateUniqueSpaceUrl($this->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->url == '') {
|
||||||
|
$this->url = new \yii\db\Expression('NULL');
|
||||||
|
} else {
|
||||||
|
$this->url = mb_strtolower($this->url);
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::beforeSave($insert);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
@ -268,7 +291,6 @@ class Space extends ContentContainerActiveRecord implements \humhub\modules\sear
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if given user can invite people to this workspace
|
* Checks if given user can invite people to this workspace
|
||||||
* Note: use directly permission instead
|
* Note: use directly permission instead
|
||||||
@ -452,8 +474,7 @@ class Space extends ContentContainerActiveRecord implements \humhub\modules\sear
|
|||||||
{
|
{
|
||||||
$status = ($status == null) ? Membership::STATUS_MEMBER : $status;
|
$status = ($status == null) ? Membership::STATUS_MEMBER : $status;
|
||||||
$query = User::find();
|
$query = User::find();
|
||||||
$query->leftJoin('space_membership', 'space_membership.user_id=user.id AND space_membership.space_id=:space_id AND space_membership.status=:member',
|
$query->leftJoin('space_membership', 'space_membership.user_id=user.id AND space_membership.space_id=:space_id AND space_membership.status=:member', ['space_id' => $this->id, 'member' => $status]);
|
||||||
['space_id' => $this->id, 'member' => $status]);
|
|
||||||
$query->andWhere('space_membership.space_id IS NOT NULL');
|
$query->andWhere('space_membership.space_id IS NOT NULL');
|
||||||
$query->addOrderBy(['space_membership.group_id' => SORT_DESC]);
|
$query->addOrderBy(['space_membership.group_id' => SORT_DESC]);
|
||||||
return $query;
|
return $query;
|
||||||
@ -462,8 +483,7 @@ class Space extends ContentContainerActiveRecord implements \humhub\modules\sear
|
|||||||
public function getNonMembershipUser()
|
public function getNonMembershipUser()
|
||||||
{
|
{
|
||||||
$query = User::find();
|
$query = User::find();
|
||||||
$query->leftJoin('space_membership', 'space_membership.user_id=user.id AND space_membership.space_id=:space_id ',
|
$query->leftJoin('space_membership', 'space_membership.user_id=user.id AND space_membership.space_id=:space_id ', ['space_id' => $this->id]);
|
||||||
['space_id' => $this->id]);
|
|
||||||
$query->andWhere('space_membership.space_id IS NULL');
|
$query->andWhere('space_membership.space_id IS NULL');
|
||||||
$query->orWhere(['!=', 'space_membership.status', Membership::STATUS_MEMBER]);
|
$query->orWhere(['!=', 'space_membership.status', Membership::STATUS_MEMBER]);
|
||||||
$query->addOrderBy(['space_membership.group_id' => SORT_DESC]);
|
$query->addOrderBy(['space_membership.group_id' => SORT_DESC]);
|
||||||
@ -538,4 +558,5 @@ class Space extends ContentContainerActiveRecord implements \humhub\modules\sear
|
|||||||
|
|
||||||
return Content::VISIBILITY_PRIVATE;
|
return Content::VISIBILITY_PRIVATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -28,12 +28,24 @@ class DefaultController extends Controller
|
|||||||
{
|
{
|
||||||
$space = $this->contentContainer;
|
$space = $this->contentContainer;
|
||||||
$space->scenario = 'edit';
|
$space->scenario = 'edit';
|
||||||
$space->indexUrl = Yii::$app->settings->get($space->id, 'indexUrl');
|
|
||||||
|
|
||||||
if ($space->load(Yii::$app->request->post()) && $space->validate() && $space->save()) {
|
if ($space->load(Yii::$app->request->post()) && $space->validate() && $space->save()) {
|
||||||
Yii::$app->getSession()->setFlash('data-saved', Yii::t('SpaceModule.controllers_AdminController', 'Saved'));
|
Yii::$app->getSession()->setFlash('data-saved', Yii::t('SpaceModule.controllers_AdminController', 'Saved'));
|
||||||
return $this->redirect($space->createUrl('index'));
|
return $this->redirect($space->createUrl('index'));
|
||||||
}
|
}
|
||||||
|
return $this->render('index', ['model' => $space]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function actionAdvanced()
|
||||||
|
{
|
||||||
|
$space = $this->contentContainer;
|
||||||
|
$space->scenario = 'edit';
|
||||||
|
$space->indexUrl = Yii::$app->settings->get($space->id, 'indexUrl');
|
||||||
|
|
||||||
|
if ($space->load(Yii::$app->request->post()) && $space->validate() && $space->save()) {
|
||||||
|
Yii::$app->getSession()->setFlash('data-saved', Yii::t('SpaceModule.controllers_AdminController', 'Saved'));
|
||||||
|
return $this->redirect($space->createUrl('advanced'));
|
||||||
|
}
|
||||||
|
|
||||||
$indexModuleSelection = SpacePages::getAvailablePages();
|
$indexModuleSelection = SpacePages::getAvailablePages();
|
||||||
|
|
||||||
@ -41,24 +53,7 @@ class DefaultController extends Controller
|
|||||||
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('index', ['model' => $space, 'indexModuleSelection' => $indexModuleSelection]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Security settings
|
|
||||||
*/
|
|
||||||
public function actionSecurity()
|
|
||||||
{
|
|
||||||
$space = $this->contentContainer;
|
|
||||||
$space->scenario = 'edit';
|
|
||||||
|
|
||||||
if ($space->load(Yii::$app->request->post()) && $space->validate() && $space->save()) {
|
|
||||||
Yii::$app->getSession()->setFlash('data-saved', Yii::t('SpaceModule.controllers_AdminController', 'Saved'));
|
|
||||||
return $this->redirect($space->createUrl('security'));
|
|
||||||
}
|
|
||||||
return $this->render('security', array('model' => $space));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -155,37 +155,6 @@ class MemberController extends Controller
|
|||||||
return $this->htmlRedirect($space->createUrl('/space/manage/member'));
|
return $this->htmlRedirect($space->createUrl('/space/manage/member'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Shows space permessions
|
|
||||||
*/
|
|
||||||
public function actionPermissions()
|
|
||||||
{
|
|
||||||
$space = $this->getSpace();
|
|
||||||
|
|
||||||
$groups = $space->getUserGroups();
|
|
||||||
$groupId = Yii::$app->request->get('groupId', Space::USERGROUP_MEMBER);
|
|
||||||
if (!array_key_exists($groupId, $groups)) {
|
|
||||||
throw new HttpException(500, 'Invalid group id given!');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle permission state change
|
|
||||||
if (Yii::$app->request->post('dropDownColumnSubmit')) {
|
|
||||||
Yii::$app->response->format = 'json';
|
|
||||||
$permission = $space->permissionManager->getById(Yii::$app->request->post('permissionId'), Yii::$app->request->post('moduleId'));
|
|
||||||
if ($permission === null) {
|
|
||||||
throw new \yii\web\HttpException(500, 'Could not find permission!');
|
|
||||||
}
|
|
||||||
$space->permissionManager->setGroupState($groupId, $permission, Yii::$app->request->post('state'));
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->render('permissions', array(
|
|
||||||
'space' => $space,
|
|
||||||
'groups' => $groups,
|
|
||||||
'groupId' => $groupId
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change owner
|
* Change owner
|
||||||
*/
|
*/
|
||||||
|
@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @link https://www.humhub.org/
|
||||||
|
* @copyright Copyright (c) 2016 HumHub GmbH & Co. KG
|
||||||
|
* @license https://www.humhub.com/licences
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace humhub\modules\space\modules\manage\controllers;
|
||||||
|
|
||||||
|
use Yii;
|
||||||
|
use humhub\modules\space\modules\manage\components\Controller;
|
||||||
|
use humhub\modules\space\models\Space;
|
||||||
|
use yii\web\HttpException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SecurityController
|
||||||
|
*
|
||||||
|
* @since 1.1
|
||||||
|
* @author Luke
|
||||||
|
*/
|
||||||
|
class SecurityController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
public function actionIndex()
|
||||||
|
{
|
||||||
|
$space = $this->contentContainer;
|
||||||
|
$space->scenario = 'edit';
|
||||||
|
|
||||||
|
if ($space->load(Yii::$app->request->post()) && $space->validate() && $space->save()) {
|
||||||
|
Yii::$app->getSession()->setFlash('data-saved', Yii::t('SpaceModule.controllers_AdminController', 'Saved'));
|
||||||
|
return $this->redirect($space->createUrl('security'));
|
||||||
|
}
|
||||||
|
return $this->render('index', ['model' => $space]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shows space permessions
|
||||||
|
*/
|
||||||
|
public function actionPermissions()
|
||||||
|
{
|
||||||
|
$space = $this->getSpace();
|
||||||
|
|
||||||
|
$groups = $space->getUserGroups();
|
||||||
|
$groupId = Yii::$app->request->get('groupId', Space::USERGROUP_MEMBER);
|
||||||
|
if (!array_key_exists($groupId, $groups)) {
|
||||||
|
throw new HttpException(500, 'Invalid group id given!');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle permission state change
|
||||||
|
if (Yii::$app->request->post('dropDownColumnSubmit')) {
|
||||||
|
Yii::$app->response->format = 'json';
|
||||||
|
$permission = $space->permissionManager->getById(Yii::$app->request->post('permissionId'), Yii::$app->request->post('moduleId'));
|
||||||
|
if ($permission === null) {
|
||||||
|
throw new \yii\web\HttpException(500, 'Could not find permission!');
|
||||||
|
}
|
||||||
|
$space->permissionManager->setGroupState($groupId, $permission, Yii::$app->request->post('state'));
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render('permissions', array(
|
||||||
|
'space' => $space,
|
||||||
|
'groups' => $groups,
|
||||||
|
'groupId' => $groupId
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\bootstrap\ActiveForm;
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\helpers\Url;
|
||||||
|
use humhub\modules\space\models\Space;
|
||||||
|
use humhub\modules\space\modules\manage\widgets\DefaultMenu;
|
||||||
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="panel panel-default">
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<div class="panel-heading">
|
||||||
|
<?php echo Yii::t('SpaceModule.views_settings', '<strong>Space</strong> settings'); ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?= DefaultMenu::widget(['space' => $model]); ?>
|
||||||
|
<div class="panel-body">
|
||||||
|
|
||||||
|
<?php $form = ActiveForm::begin(['options' => ['id' => 'spaceIndexForm'], 'enableClientValidation' => false]); ?>
|
||||||
|
|
||||||
|
<?php if (Yii::$app->urlManager->enablePrettyUrl): ?>
|
||||||
|
<?php echo $form->field($model, 'url')->hint(Yii::t('SpaceModule.manage', 'e.g. example for {baseUrl}/s/example', ['baseUrl' => Url::base(true)])); ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php echo $form->field($model, 'indexUrl')->dropDownList($indexModuleSelection)->hint('') ?>
|
||||||
|
|
||||||
|
<?php echo Html::submitButton(Yii::t('SpaceModule.views_admin_edit', 'Save'), array('class' => 'btn btn-primary', 'data-ui-loader' => '')); ?>
|
||||||
|
|
||||||
|
<?php echo \humhub\widgets\DataSaved::widget(); ?>
|
||||||
|
|
||||||
|
<div class="pull-right">
|
||||||
|
<?php if ($model->status == Space::STATUS_ENABLED) { ?>
|
||||||
|
<?php echo Html::a(Yii::t('SpaceModule.views_admin_edit', 'Archive'), $model->createUrl('/space/manage/default/archive'), array('class' => 'btn btn-warning', 'data-post' => 'POST')); ?>
|
||||||
|
<?php } elseif ($model->status == Space::STATUS_ARCHIVED) { ?>
|
||||||
|
<?php echo Html::a(Yii::t('SpaceModule.views_admin_edit', 'Unarchive'), $model->createUrl('/space/manage/default/unarchive'), array('class' => 'btn btn-warning', 'data-post' => 'POST')); ?>
|
||||||
|
<?php } ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php ActiveForm::end(); ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
@ -14,21 +14,17 @@ $this->registerCssFile('@web/resources/space/colorpicker/css/bootstrap-colorpick
|
|||||||
|
|
||||||
<div>
|
<div>
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<?php echo Yii::t('SpaceModule.views_settings', '<strong>Space</strong> settings'); ?>
|
<?php echo Yii::t('SpaceModule.views_settings', '<strong>Space</strong> settings'); ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?= DefaultMenu::widget(['space' => $model]); ?>
|
<?= DefaultMenu::widget(['space' => $model]); ?>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
|
|
||||||
<?php $form = ActiveForm::begin(['options' => ['id' => 'spaceIndexForm']]); ?>
|
<?php $form = ActiveForm::begin(['options' => ['id' => 'spaceIndexForm'], 'enableClientValidation' => false]); ?>
|
||||||
|
<div class="form-group space-color-chooser-edit" style="margin-top: 5px;">
|
||||||
|
<?= Html::activeTextInput($model, 'color', ['class' => 'form-control', 'id' => 'space-color-picker-edit', 'value' => $model->color, 'style' => 'display:none']); ?>
|
||||||
<div class="form-group space-color-chooser-edit" style="margin-top: 5px;">
|
<?= $form->field($model, 'name', [ 'template' => '
|
||||||
|
|
||||||
<?= Html::activeTextInput($model, 'color', ['class' => 'form-control', 'id' => 'space-color-picker-edit', 'value' => $model->color, 'style' => 'display:none']); ?>
|
|
||||||
<!-- ?= Html::activeTextInput($model, 'name' , ['class' => 'form-control', 'id' => 'space-name', 'placeholder' => Yii::t('SpaceModule.views_create_create', 'space name'), 'maxlength' => 45]) ?-->
|
|
||||||
<?= $form->field($model, 'name', [ 'template' => '
|
|
||||||
{label}
|
{label}
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<span class="input-group-addon">
|
<span class="input-group-addon">
|
||||||
@ -38,15 +34,12 @@ $this->registerCssFile('@web/resources/space/colorpicker/css/bootstrap-colorpick
|
|||||||
</input>
|
</input>
|
||||||
</div>
|
</div>
|
||||||
{error}{hint}'])->textInput() ?>
|
{error}{hint}'])->textInput() ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<?php echo $form->field($model, 'description')->textarea(['rows' => 6]); ?>
|
<?php echo $form->field($model, 'description')->textarea(['rows' => 6]); ?>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-3">
|
|
||||||
<?php echo $form->field($model, 'indexUrl')->dropDownList($indexModuleSelection) ?>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<?php echo $form->field($model, 'tags')->textInput(['maxlength' => 200]); ?>
|
<?php echo $form->field($model, 'tags')->textInput(['maxlength' => 200]); ?>
|
||||||
</div>
|
</div>
|
||||||
@ -58,11 +51,9 @@ $this->registerCssFile('@web/resources/space/colorpicker/css/bootstrap-colorpick
|
|||||||
<?php echo \humhub\widgets\DataSaved::widget(); ?>
|
<?php echo \humhub\widgets\DataSaved::widget(); ?>
|
||||||
|
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
<?php if ($model->status == Space::STATUS_ENABLED) { ?>
|
<?php if ($model->isSpaceOwner()) : ?>
|
||||||
<?php echo Html::a(Yii::t('SpaceModule.views_admin_edit', 'Archive'), $model->createUrl('/space/manage/default/archive'), array('class' => 'btn btn-warning', 'data-post' => 'POST')); ?>
|
<?php echo Html::a(Yii::t('SpaceModule.views_admin_edit', 'Delete'), $model->createUrl('delete'), array('class' => 'btn btn-danger', 'data-post' => 'POST')); ?>
|
||||||
<?php } elseif ($model->status == Space::STATUS_ARCHIVED) { ?>
|
<?php endif; ?>
|
||||||
<?php echo Html::a(Yii::t('SpaceModule.views_admin_edit', 'Unarchive'), $model->createUrl('/space/manage/default/unarchive'), array('class' => 'btn btn-warning', 'data-post' => 'POST')); ?>
|
|
||||||
<?php } ?>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php ActiveForm::end(); ?>
|
<?php ActiveForm::end(); ?>
|
||||||
@ -74,7 +65,7 @@ $this->registerCssFile('@web/resources/space/colorpicker/css/bootstrap-colorpick
|
|||||||
// prevent enter key and simulate ajax button submit click
|
// prevent enter key and simulate ajax button submit click
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
var $colorPickerHexInput, picker;
|
var $colorPickerHexInput, picker;
|
||||||
|
|
||||||
$('.space-color-chooser-edit').colorpicker({
|
$('.space-color-chooser-edit').colorpicker({
|
||||||
format: 'hex',
|
format: 'hex',
|
||||||
color: '<?= $model->color; ?>',
|
color: '<?= $model->color; ?>',
|
||||||
@ -85,37 +76,37 @@ $this->registerCssFile('@web/resources/space/colorpicker/css/bootstrap-colorpick
|
|||||||
});
|
});
|
||||||
|
|
||||||
//Add hex input field to color picker
|
//Add hex input field to color picker
|
||||||
$('.space-color-chooser-edit').on('create', function() {
|
$('.space-color-chooser-edit').on('create', function () {
|
||||||
if(typeof $colorPickerHexInput === 'undefined') {
|
if (typeof $colorPickerHexInput === 'undefined') {
|
||||||
picker = $(this).data('colorpicker');
|
picker = $(this).data('colorpicker');
|
||||||
$colorPickerHexInput = $('<input type="text" style="border:0px;outline: none;" id="colorPickerHexInput" value="'+picker.color.toHex()+'"></input>');
|
$colorPickerHexInput = $('<input type="text" style="border:0px;outline: none;" id="colorPickerHexInput" value="' + picker.color.toHex() + '"></input>');
|
||||||
picker.picker.append($colorPickerHexInput);
|
picker.picker.append($colorPickerHexInput);
|
||||||
$colorPickerHexInput.on('change', function() {
|
$colorPickerHexInput.on('change', function () {
|
||||||
picker.color.setColor($(this).val());
|
picker.color.setColor($(this).val());
|
||||||
picker.update();
|
picker.update();
|
||||||
});
|
});
|
||||||
|
|
||||||
$colorPickerHexInput.on('keydown', function(e) {
|
$colorPickerHexInput.on('keydown', function (e) {
|
||||||
var keyCode = e.keyCode || e.which;
|
var keyCode = e.keyCode || e.which;
|
||||||
//Close On Tab
|
//Close On Tab
|
||||||
if (keyCode === 9) {
|
if (keyCode === 9) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
picker.hide();
|
picker.hide();
|
||||||
$('#space-name').focus();
|
$('#space-name').focus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.colorpicker').on('click', function() {
|
$('.colorpicker').on('click', function () {
|
||||||
$colorPickerHexInput.select();
|
$colorPickerHexInput.select();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.space-color-chooser-edit').on('showPicker', function() {
|
$('.space-color-chooser-edit').on('showPicker', function () {
|
||||||
$colorPickerHexInput.select();
|
$colorPickerHexInput.select();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.space-color-chooser-edit').on('changeColor', function() {
|
$('.space-color-chooser-edit').on('changeColor', function () {
|
||||||
$colorPickerHexInput.val(picker.color.toHex());
|
$colorPickerHexInput.val(picker.color.toHex());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -2,18 +2,18 @@
|
|||||||
|
|
||||||
use yii\bootstrap\ActiveForm;
|
use yii\bootstrap\ActiveForm;
|
||||||
use yii\helpers\Html;
|
use yii\helpers\Html;
|
||||||
use \humhub\models\Setting;
|
use humhub\modules\space\modules\manage\widgets\SecurityTabMenu;
|
||||||
use humhub\modules\space\modules\manage\widgets\DefaultMenu;
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div>
|
<div>
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<?php echo Yii::t('SpaceModule.views_settings', '<strong>Space</strong> settings'); ?>
|
<?php echo Yii::t('SpaceModule.views_settings', '<strong>Security</strong> settings'); ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?= DefaultMenu::widget(['space' => $model]); ?>
|
<?= SecurityTabMenu::widget(['space' => $model]); ?>
|
||||||
|
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<?php $form = ActiveForm::begin(); ?>
|
<?php $form = ActiveForm::begin(); ?>
|
||||||
|
|
@ -1,15 +1,18 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use yii\helpers\Html;
|
use yii\helpers\Html;
|
||||||
use humhub\modules\space\modules\manage\widgets\MemberMenu;
|
|
||||||
use humhub\modules\user\widgets\PermissionGridEditor;
|
use humhub\modules\user\widgets\PermissionGridEditor;
|
||||||
|
use humhub\modules\space\modules\manage\widgets\SecurityTabMenu;
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">
|
<div>
|
||||||
<?php echo Yii::t('SpaceModule.views_admin_members', '<strong>Manage</strong> members'); ?>
|
<div class="panel-heading">
|
||||||
|
<?php echo Yii::t('SpaceModule.views_settings', '<strong>Security</strong> settings'); ?>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?= MemberMenu::widget(['space' => $space]); ?>
|
|
||||||
|
<?= SecurityTabMenu::widget(['space' => $space]); ?>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<?php
|
<?php
|
||||||
echo Yii::t('SpaceModule.views_admin_members', '<strong>Current Group:</strong>');
|
echo Yii::t('SpaceModule.views_admin_members', '<strong>Current Group:</strong>');
|
@ -36,16 +36,10 @@ class DefaultMenu extends \humhub\widgets\BaseMenu
|
|||||||
'isActive' => (Yii::$app->controller->id == 'default' && Yii::$app->controller->action->id == 'index'),
|
'isActive' => (Yii::$app->controller->id == 'default' && Yii::$app->controller->action->id == 'index'),
|
||||||
));
|
));
|
||||||
$this->addItem(array(
|
$this->addItem(array(
|
||||||
'label' => Yii::t('AdminModule.manage', 'Security'),
|
'label' => Yii::t('AdminModule.manage', 'Advanced'),
|
||||||
'url' => $this->space->createUrl('/space/manage/default/security'),
|
'url' => $this->space->createUrl('/space/manage/default/advanced'),
|
||||||
'sortOrder' => 200,
|
'sortOrder' => 200,
|
||||||
'isActive' => (Yii::$app->controller->id == 'default' && Yii::$app->controller->action->id == 'security'),
|
'isActive' => (Yii::$app->controller->id == 'default' && Yii::$app->controller->action->id == 'advanced'),
|
||||||
));
|
|
||||||
$this->addItem(array(
|
|
||||||
'label' => Yii::t('AdminModule.manage', 'Delete'),
|
|
||||||
'url' => $this->space->createUrl('/space/manage/default/delete'),
|
|
||||||
'sortOrder' => 500,
|
|
||||||
'isActive' => (Yii::$app->controller->id == 'default' && Yii::$app->controller->action->id == 'delete'),
|
|
||||||
));
|
));
|
||||||
parent::init();
|
parent::init();
|
||||||
}
|
}
|
||||||
|
@ -30,33 +30,27 @@ class MemberMenu extends \humhub\widgets\BaseMenu
|
|||||||
{
|
{
|
||||||
|
|
||||||
$this->addItem(array(
|
$this->addItem(array(
|
||||||
'label' => Yii::t('SpaceModule.widgets_SpaceMembersMenu','Members'),
|
'label' => Yii::t('SpaceModule.widgets_SpaceMembersMenu', 'Members'),
|
||||||
'url' => $this->space->createUrl('/space/manage/member/index'),
|
'url' => $this->space->createUrl('/space/manage/member/index'),
|
||||||
'sortOrder' => 100,
|
'sortOrder' => 100,
|
||||||
'isActive' => (Yii::$app->controller->action->id == 'index' && Yii::$app->controller->id === 'member'),
|
'isActive' => (Yii::$app->controller->action->id == 'index' && Yii::$app->controller->id === 'member'),
|
||||||
));
|
));
|
||||||
$this->addItem(array(
|
$this->addItem(array(
|
||||||
'label' => Yii::t('SpaceModule.widgets_SpaceMembersMenu','Pending Invites'),
|
'label' => Yii::t('SpaceModule.widgets_SpaceMembersMenu', 'Pending Invites'),
|
||||||
'url' => $this->space->createUrl('/space/manage/member/pending-invitations'),
|
'url' => $this->space->createUrl('/space/manage/member/pending-invitations'),
|
||||||
'sortOrder' => 200,
|
'sortOrder' => 200,
|
||||||
'isActive' => (Yii::$app->controller->action->id == 'pending-invitations'),
|
'isActive' => (Yii::$app->controller->action->id == 'pending-invitations'),
|
||||||
));
|
));
|
||||||
$this->addItem(array(
|
$this->addItem(array(
|
||||||
'label' => Yii::t('SpaceModule.widgets_SpaceMembersMenu','Pending Approvals'),
|
'label' => Yii::t('SpaceModule.widgets_SpaceMembersMenu', 'Pending Approvals'),
|
||||||
'url' => $this->space->createUrl('/space/manage/member/pending-approvals'),
|
'url' => $this->space->createUrl('/space/manage/member/pending-approvals'),
|
||||||
'sortOrder' => 300,
|
'sortOrder' => 300,
|
||||||
'isActive' => (Yii::$app->controller->action->id == 'pending-approvals'),
|
'isActive' => (Yii::$app->controller->action->id == 'pending-approvals'),
|
||||||
));
|
));
|
||||||
$this->addItem(array(
|
|
||||||
'label' => Yii::t('SpaceModule.widgets_SpaceMembersMenu','Permissions'),
|
|
||||||
'url' => $this->space->createUrl('/space/manage/member/permissions'),
|
|
||||||
'sortOrder' => 400,
|
|
||||||
'isActive' => (Yii::$app->controller->action->id == 'permissions'),
|
|
||||||
));
|
|
||||||
|
|
||||||
if ($this->space->isSpaceOwner()) {
|
if ($this->space->isSpaceOwner()) {
|
||||||
$this->addItem(array(
|
$this->addItem(array(
|
||||||
'label' => Yii::t('SpaceModule.widgets_SpaceMembersMenu','Owner'),
|
'label' => Yii::t('SpaceModule.widgets_SpaceMembersMenu', 'Owner'),
|
||||||
'url' => $this->space->createUrl('/space/manage/member/change-owner'),
|
'url' => $this->space->createUrl('/space/manage/member/change-owner'),
|
||||||
'sortOrder' => 500,
|
'sortOrder' => 500,
|
||||||
'isActive' => (Yii::$app->controller->action->id == 'change-owner'),
|
'isActive' => (Yii::$app->controller->action->id == 'change-owner'),
|
||||||
|
@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @link https://www.humhub.org/
|
||||||
|
* @copyright Copyright (c) 2015 HumHub GmbH & Co. KG
|
||||||
|
* @license https://www.humhub.com/licences
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace humhub\modules\space\modules\manage\widgets;
|
||||||
|
|
||||||
|
use Yii;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Space Administration Menu
|
||||||
|
*
|
||||||
|
* @author Luke
|
||||||
|
*/
|
||||||
|
class SecurityTabMenu extends \humhub\widgets\BaseMenu
|
||||||
|
{
|
||||||
|
|
||||||
|
public $template = "@humhub/widgets/views/tabMenu";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \humhub\modules\space\models\Space
|
||||||
|
*/
|
||||||
|
public $space;
|
||||||
|
|
||||||
|
public function init()
|
||||||
|
{
|
||||||
|
$this->addItem(array(
|
||||||
|
'label' => Yii::t('AdminModule.manage', 'General'),
|
||||||
|
'url' => $this->space->createUrl('/space/manage/security'),
|
||||||
|
'sortOrder' => 100,
|
||||||
|
'isActive' => (Yii::$app->controller->id == 'security' && Yii::$app->controller->action->id == 'index'),
|
||||||
|
));
|
||||||
|
$this->addItem(array(
|
||||||
|
'label' => Yii::t('AdminModule.manage', 'Permissions'),
|
||||||
|
'url' => $this->space->createUrl('/space/manage/security/permissions'),
|
||||||
|
'sortOrder' => 200,
|
||||||
|
'isActive' => (Yii::$app->controller->id == 'security' && Yii::$app->controller->action->id == 'permissions'),
|
||||||
|
));
|
||||||
|
parent::init();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @link https://www.humhub.org/
|
* @link https://www.humhub.org/
|
||||||
* @copyright Copyright (c) 2015 HumHub GmbH & Co. KG
|
* @copyright Copyright (c) 2016 HumHub GmbH & Co. KG
|
||||||
* @license https://www.humhub.com/licences
|
* @license https://www.humhub.com/licences
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace humhub\modules\space\modules\manage\widgets;
|
namespace humhub\modules\space\widgets;
|
||||||
|
|
||||||
use Yii;
|
use Yii;
|
||||||
use \yii\base\Widget;
|
use \yii\base\Widget;
|
||||||
@ -18,7 +18,7 @@ use \yii\base\Widget;
|
|||||||
* @package humhub.modules_core.space.widgets
|
* @package humhub.modules_core.space.widgets
|
||||||
* @since 0.5
|
* @since 0.5
|
||||||
*/
|
*/
|
||||||
class Menu extends \humhub\widgets\BaseMenu
|
class HeaderControlsMenu extends \humhub\widgets\BaseMenu
|
||||||
{
|
{
|
||||||
|
|
||||||
public $space;
|
public $space;
|
||||||
@ -37,14 +37,23 @@ class Menu extends \humhub\widgets\BaseMenu
|
|||||||
if ($this->space->isAdmin()) {
|
if ($this->space->isAdmin()) {
|
||||||
|
|
||||||
$this->addItem(array(
|
$this->addItem(array(
|
||||||
'label' => Yii::t('SpaceModule.widgets_SpaceAdminMenuWidget', 'General'),
|
'label' => Yii::t('SpaceModule.base', 'Settings'),
|
||||||
'group' => 'admin',
|
'group' => 'admin',
|
||||||
'url' => $this->space->createUrl('/space/manage'),
|
'url' => $this->space->createUrl('/space/manage'),
|
||||||
'icon' => '<i class="fa fa-cogs"></i>',
|
'icon' => '<i class="fa fa-cogs"></i>',
|
||||||
'sortOrder' => 100,
|
'sortOrder' => 100,
|
||||||
'isActive' => (Yii::$app->controller->id == "default"),
|
'isActive' => (Yii::$app->controller->id == "default"),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
$this->addItem(array(
|
||||||
|
'label' => Yii::t('SpaceModule.widgets_SpaceAdminMenuWidget', 'Security'),
|
||||||
|
'group' => 'admin',
|
||||||
|
'url' => $this->space->createUrl('/space/manage/security'),
|
||||||
|
'icon' => '<i class="fa fa-lock"></i>',
|
||||||
|
'sortOrder' => 200,
|
||||||
|
'isActive' => (Yii::$app->controller->id == "security"),
|
||||||
|
));
|
||||||
|
|
||||||
$this->addItem(array(
|
$this->addItem(array(
|
||||||
'label' => Yii::t('SpaceModule.widgets_SpaceAdminMenuWidget', 'Members'),
|
'label' => Yii::t('SpaceModule.widgets_SpaceAdminMenuWidget', 'Members'),
|
||||||
'group' => 'admin',
|
'group' => 'admin',
|
||||||
@ -73,7 +82,6 @@ class Menu extends \humhub\widgets\BaseMenu
|
|||||||
'sortOrder' => 300,
|
'sortOrder' => 300,
|
||||||
'isActive' => (Yii::$app->controller->id == "module"),
|
'isActive' => (Yii::$app->controller->id == "module"),
|
||||||
'htmlOptions' => ['data-method' => 'POST']
|
'htmlOptions' => ['data-method' => 'POST']
|
||||||
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +108,6 @@ class Menu extends \humhub\widgets\BaseMenu
|
|||||||
'title' => Yii::t('SpaceModule.widgets_SpaceAdminMenuWidget', 'This option will hide new content from this space at your dashboard')
|
'title' => Yii::t('SpaceModule.widgets_SpaceAdminMenuWidget', 'This option will hide new content from this space at your dashboard')
|
||||||
]
|
]
|
||||||
));
|
));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$this->addItem(array(
|
$this->addItem(array(
|
||||||
@ -117,9 +124,7 @@ class Menu extends \humhub\widgets\BaseMenu
|
|||||||
'title' => Yii::t('SpaceModule.widgets_SpaceAdminMenuWidget', 'This option will show new content from this space at your dashboard')
|
'title' => Yii::t('SpaceModule.widgets_SpaceAdminMenuWidget', 'This option will show new content from this space at your dashboard')
|
||||||
]
|
]
|
||||||
));
|
));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -204,8 +204,12 @@ if ($space->isAdmin()) {
|
|||||||
['sortOrder' => 30]]
|
['sortOrder' => 30]]
|
||||||
]]);
|
]]);
|
||||||
?>
|
?>
|
||||||
|
<?=
|
||||||
<?php echo humhub\modules\space\modules\manage\widgets\Menu::widget(['space' => $space, 'template' => '@humhub/widgets/views/dropdownNavigation']); ?>
|
humhub\modules\space\widgets\HeaderControlsMenu::widget([
|
||||||
|
'space' => $space,
|
||||||
|
'template' => '@humhub/widgets/views/dropdownNavigation'
|
||||||
|
]);
|
||||||
|
?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user