mirror of
https://github.com/humhub/humhub.git
synced 2025-02-22 18:22:43 +01:00
#4586 remove the column space_id since it is no longer used in migration. If a space or group is deleted, we should cleanup the corresponding entries of the table group_space using beforeDelete
This commit is contained in:
parent
5a98ebfd23
commit
073f86bacc
@ -324,10 +324,10 @@ class Space extends ContentContainerActiveRecord implements Searchable
|
||||
|
||||
Invite::deleteAll(['space_invite_id' => $this->id]);
|
||||
|
||||
// When this workspace is used in a group as default workspace, delete the link
|
||||
foreach (Group::findAll(['space_id' => $this->id]) as $group) {
|
||||
$group->space_id = '';
|
||||
$group->save();
|
||||
// Delete the corresponding entries of the table group_space
|
||||
if (!empty($this->id)){
|
||||
$groupSpace = GroupSpace::findOne(['space_id'=>$this->id]);
|
||||
$groupSpace->delete();
|
||||
}
|
||||
|
||||
return parent::beforeDelete();
|
||||
|
@ -37,6 +37,7 @@ class m201025_095247_spaces_of_users_group extends Migration
|
||||
]);
|
||||
}
|
||||
|
||||
$this->dropColumn('group', 'space_id');
|
||||
|
||||
}
|
||||
|
||||
|
@ -57,13 +57,27 @@ class Group extends ActiveRecord
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['space_id', 'sort_order'], 'integer'],
|
||||
[['sort_order'], 'integer'],
|
||||
[['description'], 'string'],
|
||||
[['name'], 'string', 'max' => 45],
|
||||
['show_at_registration', 'validateShowAtRegistration'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function beforeDelete()
|
||||
{
|
||||
// Delete the corresponding entries of the table group_space
|
||||
if (!empty($this->id)){
|
||||
$groupSpace = GroupSpace::findOne(['group_id'=>$this->id]);
|
||||
$groupSpace->delete();
|
||||
}
|
||||
|
||||
return parent::beforeDelete();
|
||||
}
|
||||
|
||||
public function validateShowAtRegistration($attribute, $params)
|
||||
{
|
||||
if($this->is_admin_group && $this->show_at_registration) {
|
||||
@ -78,7 +92,6 @@ class Group extends ActiveRecord
|
||||
{
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'space_id' => Yii::t('UserModule.base', 'Space ID'),
|
||||
'name' => Yii::t('UserModule.base', 'Name'),
|
||||
'defaultSpaceGuid' => Yii::t('UserModule.base', 'Default Space'),
|
||||
'managerGuids' => Yii::t('UserModule.base', 'Manager'),
|
||||
|
Loading…
x
Reference in New Issue
Block a user