mirror of
https://github.com/humhub/humhub.git
synced 2025-01-29 12:28:06 +01:00
Merge branch 'v1.3-dev' of github.com:humhub/humhub into v1.3-dev
This commit is contained in:
commit
a11384ae01
@ -8,21 +8,25 @@
|
||||
|
||||
namespace humhub\modules\admin\widgets;
|
||||
|
||||
use humhub\modules\admin\models\UserApprovalSearch;
|
||||
use humhub\modules\user\models\Invite;
|
||||
use Yii;
|
||||
use yii\helpers\Url;
|
||||
use humhub\modules\admin\models\UserApprovalSearch;
|
||||
use humhub\modules\admin\permissions\ManageUsers;
|
||||
use humhub\modules\admin\permissions\ManageGroups;
|
||||
use humhub\modules\admin\permissions\ManageSettings;
|
||||
use humhub\modules\user\models\Invite;
|
||||
use humhub\widgets\BaseMenu;
|
||||
|
||||
/**
|
||||
* User Administration Menu
|
||||
*
|
||||
* @author Basti
|
||||
*/
|
||||
class UserMenu extends \humhub\widgets\BaseMenu
|
||||
class UserMenu extends BaseMenu
|
||||
{
|
||||
|
||||
public $template = "@humhub/widgets/views/tabMenu";
|
||||
public $type = "adminUserSubNavigation";
|
||||
public $template = '@humhub/widgets/views/tabMenu';
|
||||
public $type = 'adminUserSubNavigation';
|
||||
|
||||
public function init()
|
||||
{
|
||||
@ -32,8 +36,8 @@ class UserMenu extends \humhub\widgets\BaseMenu
|
||||
'sortOrder' => 100,
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && (Yii::$app->controller->id == 'user' || Yii::$app->controller->id == 'pending-registrations')),
|
||||
'isVisible' => Yii::$app->user->can([
|
||||
new \humhub\modules\admin\permissions\ManageUsers(),
|
||||
new \humhub\modules\admin\permissions\ManageGroups(),
|
||||
new ManageUsers(),
|
||||
new ManageGroups(),
|
||||
])
|
||||
]);
|
||||
|
||||
@ -43,7 +47,7 @@ class UserMenu extends \humhub\widgets\BaseMenu
|
||||
'sortOrder' => 200,
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'authentication'),
|
||||
'isVisible' => Yii::$app->user->can([
|
||||
new \humhub\modules\admin\permissions\ManageSettings()
|
||||
new ManageSettings()
|
||||
])
|
||||
]);
|
||||
|
||||
@ -55,8 +59,8 @@ class UserMenu extends \humhub\widgets\BaseMenu
|
||||
'sortOrder' => 300,
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'approval'),
|
||||
'isVisible' => Yii::$app->user->can([
|
||||
new \humhub\modules\admin\permissions\ManageUsers(),
|
||||
new \humhub\modules\admin\permissions\ManageGroups()
|
||||
new ManageUsers(),
|
||||
new ManageGroups()
|
||||
])
|
||||
]);
|
||||
}
|
||||
@ -67,7 +71,7 @@ class UserMenu extends \humhub\widgets\BaseMenu
|
||||
'sortOrder' => 400,
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'user-profile'),
|
||||
'isVisible' => Yii::$app->user->can([
|
||||
new \humhub\modules\admin\permissions\ManageUsers()
|
||||
new ManageUsers()
|
||||
])
|
||||
]);
|
||||
|
||||
@ -77,7 +81,7 @@ class UserMenu extends \humhub\widgets\BaseMenu
|
||||
'sortOrder' => 500,
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'group'),
|
||||
'isVisible' => Yii::$app->user->can(
|
||||
new \humhub\modules\admin\permissions\ManageGroups()
|
||||
new ManageGroups()
|
||||
)
|
||||
]);
|
||||
|
||||
|
@ -1,12 +1,15 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Schema;
|
||||
use yii\db\Query;
|
||||
use yii\db\Expression;
|
||||
use humhub\components\Migration;
|
||||
|
||||
class m160229_162959_multiusergroups extends \humhub\components\Migration
|
||||
class m160229_162959_multiusergroups extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$this->createTable('group_user', array(
|
||||
$this->createTable('group_user', [
|
||||
'id' => 'pk',
|
||||
'user_id' => 'int(11) NOT NULL',
|
||||
'group_id' => 'int(11) NOT NULL',
|
||||
@ -15,53 +18,53 @@ class m160229_162959_multiusergroups extends \humhub\components\Migration
|
||||
'created_by' => 'int(11) DEFAULT NULL',
|
||||
'updated_at' => 'datetime DEFAULT NULL',
|
||||
'updated_by' => 'int(11) DEFAULT NULL',
|
||||
), '');
|
||||
|
||||
//Add indexes and foreign keys
|
||||
], '');
|
||||
|
||||
// Add indexes and foreign keys
|
||||
$this->createIndex('idx-group_user', 'group_user', ['user_id', 'group_id'], true);
|
||||
$this->addForeignKey('fk-user-group', 'group_user', 'user_id', 'user', 'id', 'CASCADE');
|
||||
$this->addForeignKey('fk-group-group', 'group_user', 'group_id', '`group`', 'id', 'CASCADE');
|
||||
|
||||
//Merge old group user and group admins
|
||||
|
||||
// Merge old group user and group admins
|
||||
$this->execute('INSERT INTO group_user (user_id, group_id) SELECT DISTINCT user.id, user.group_id FROM user LEFT JOIN `group` ON user.group_id=group.id WHERE group.id IS NOT NULL');
|
||||
$this->execute('UPDATE group_user u SET is_group_admin = :value WHERE EXISTS (Select 1 FROM group_admin a WHERE u.user_id = a.user_id);', [':value' => 1]);
|
||||
|
||||
//Add group columns
|
||||
|
||||
// Add group columns
|
||||
$this->addColumn('group', 'is_admin_group', Schema::TYPE_BOOLEAN. ' NOT NULL DEFAULT 0');
|
||||
$this->addColumn('group', 'show_at_registration', Schema::TYPE_BOOLEAN. ' NOT NULL DEFAULT 1');
|
||||
$this->addColumn('group', 'show_at_directory', Schema::TYPE_BOOLEAN. ' NOT NULL DEFAULT 1');
|
||||
|
||||
//Create initial administration group
|
||||
|
||||
// Create initial administration group
|
||||
$this->insertSilent('group', [
|
||||
'name' => 'Administrator',
|
||||
'description' => 'Administrator Group',
|
||||
'is_admin_group' => '1',
|
||||
'show_at_registration' => '0',
|
||||
'show_at_directory' => '0',
|
||||
'created_at' => new \yii\db\Expression('NOW()')
|
||||
'created_at' => new Expression('NOW()')
|
||||
]);
|
||||
|
||||
//Determine administration group id
|
||||
$adminGroupId = (new \yii\db\Query())
|
||||
|
||||
// Determine administration group id
|
||||
$adminGroupId = (new Query())
|
||||
->select('id')
|
||||
->from('group')
|
||||
->where(['is_admin_group' => '1'])
|
||||
->scalar();
|
||||
|
||||
//Load current super_admin user
|
||||
$rows = (new \yii\db\Query())
|
||||
|
||||
// Load current super_admin user
|
||||
$rows = (new Query())
|
||||
->select("id")
|
||||
->from('user')
|
||||
->where(['super_admin' => '1'])
|
||||
->all();
|
||||
|
||||
//Insert group_user for administartion groups for all current super_admins
|
||||
foreach($rows as $adminUserRow) {
|
||||
|
||||
// Insert group_user for administration groups for all current super_admins
|
||||
foreach ($rows as $adminUserRow) {
|
||||
$this->insertSilent('group_user', ['user_id' => $adminUserRow['id'], 'group_id' => $adminGroupId, 'is_group_admin' => '1']);
|
||||
}
|
||||
|
||||
|
||||
//$this->insertSilent('group_permission', ['permission_id' => 'user_admin', 'group_id' => $adminGroupId, 'module_id' => 'user', 'class' => 'humhub\modules\user\permissions']);
|
||||
|
||||
|
||||
$this->dropTable('group_admin');
|
||||
$this->dropColumn('user', 'super_admin');
|
||||
$this->dropColumn('user', 'group_id');
|
||||
|
Loading…
x
Reference in New Issue
Block a user