Removed deprecated methods

This commit is contained in:
Lucas Bartholemy 2019-09-23 17:03:20 +02:00
parent a77a2a455a
commit 03fdf0267e
7 changed files with 38 additions and 73 deletions

View File

@ -58,3 +58,5 @@ HumHub Change Log (DEVELOP)
- Enh: More generic approach to determine themed view files - Enh: More generic approach to determine themed view files
- Enh: Always use ISO 639-1 alpha-2 (and ISO 3166-2) language codes - Enh: Always use ISO 639-1 alpha-2 (and ISO 3166-2) language codes
- Enh: Update Yii version to 2.0.27 - Enh: Update Yii version to 2.0.27
- Enh: Reorganized translation method categories to reduce language files
- Enh: Removed deprecated methods/classes since v1.1 - see migration guide for details

View File

@ -56,7 +56,7 @@ If you're using any custom modules, please change the message directories accord
The following deprecated method have been removed. The following deprecated method have been removed.
**Content model** **Content model -removed methods **
- canWrite() - canWrite()
- canRead() - canRead()
@ -64,7 +64,18 @@ The following deprecated method have been removed.
- getSpace() - getSpace()
- getUser() - getUser()
**Removed class**
- humhub\modules\space\modules\manage\widgets\Menu
**Space class - removed methods**
- canInvite()
- canShare()
**Notification class - removed methods**
- getSpace()
Migrate from 1.2 to 1.3 Migrate from 1.2 to 1.3
----------------------- -----------------------

View File

@ -160,17 +160,6 @@ class Notification extends \humhub\components\ActiveRecord
return $this->hasOne(User::class, ['id' => 'originator_user_id']); return $this->hasOne(User::class, ['id' => 'originator_user_id']);
} }
/**
* Returns space of this notification
*
* @return \yii\db\ActiveQuery
* @deprecated since version 1.1
*/
public function getSpace()
{
return $this->hasOne(Space::class, ['id' => 'space_id']);
}
/** /**
* Returns polymorphic relation linked with this notification * Returns polymorphic relation linked with this notification
* *

View File

@ -354,31 +354,6 @@ class Space extends ContentContainerActiveRecord implements Searchable
return false; return false;
} }
/**
* Checks if given user can invite people to this workspace
* Note: use directly permission instead
*
* @return boolean
* @deprecated since version 1.1
*/
public function canInvite()
{
return $this->getPermissionManager()->can(new InviteUsers());
}
/**
* Checks if given user can share content.
* Shared Content is public and is visible also for non members of the space.
* Note: use directly permission instead
*
* @return boolean
* @deprecated since version 1.1
*/
public function canShare()
{
return $this->getPermissionManager()->can(new CreatePublicContent());
}
/** /**
* Returns an array of informations used by search subsystem. * Returns an array of informations used by search subsystem.
* Function is defined in interface ISearchable * Function is defined in interface ISearchable

View File

@ -1,21 +0,0 @@
<?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\widgets;
/**
* Menu compatibility
*
* @see \humhub\modules\space\widgets\HeaderControlsMenu
* @deprecated since version 1.1
* @author Luke
*/
class Menu extends \humhub\modules\space\widgets\HeaderControlsMenu
{
}

View File

@ -8,28 +8,32 @@
namespace humhub\modules\space\widgets; namespace humhub\modules\space\widgets;
use Yii; use humhub\modules\space\models\Space;
use humhub\modules\space\permissions\InviteUsers;
use yii\base\Widget; use yii\base\Widget;
use yii\helpers\Html;
/** /**
* SpaceInviteButtonWidget * InviteButton class
* *
* @author luke * @author luke
* @package humhub.modules_core.space.widgets
* @since 0.11 * @since 0.11
*/ */
class InviteButton extends Widget class InviteButton extends Widget
{ {
/**
* @var Space
*/
public $space; public $space;
/**
* @inheritDoc
*/
public function run() public function run()
{ {
if (!$this->space->canInvite()) { if (!$this->space->getPermissionManager()->can(new InviteUsers())) {
return; return;
} }
return $this->render('inviteButton', ['space' => $this->space]); return $this->render('inviteButton', ['space' => $this->space]);
} }

View File

@ -8,6 +8,7 @@
namespace humhub\modules\user\controllers; namespace humhub\modules\user\controllers;
use humhub\modules\user\Module;
use Yii; use Yii;
use yii\web\Controller; use yii\web\Controller;
use yii\web\HttpException; use yii\web\HttpException;
@ -20,7 +21,7 @@ use humhub\widgets\ModalClose;
/** /**
* InviteController for new user invites * InviteController for new user invites
* *
* @since 1.1 * @since 1.1
*/ */
class InviteController extends Controller class InviteController extends Controller
@ -40,7 +41,7 @@ class InviteController extends Controller
/** /**
* Invite form and processing action * Invite form and processing action
* *
* @return string the action result * @return string the action result
* @throws \yii\web\HttpException * @throws \yii\web\HttpException
*/ */
@ -56,7 +57,7 @@ class InviteController extends Controller
foreach ($model->getEmails() as $email) { foreach ($model->getEmails() as $email) {
$this->createInvite($email); $this->createInvite($email);
} }
return ModalClose::widget([ return ModalClose::widget([
'success' => Yii::t('UserModule.base', 'User has been invited.') 'success' => Yii::t('UserModule.base', 'User has been invited.')
]); ]);
@ -67,7 +68,7 @@ class InviteController extends Controller
/** /**
* Creates and sends an e-mail invite * Creates and sends an e-mail invite
* *
* @param email $email * @param email $email
*/ */
protected function createInvite($email) protected function createInvite($email)
@ -76,25 +77,29 @@ class InviteController extends Controller
$userInvite->email = $email; $userInvite->email = $email;
$userInvite->source = Invite::SOURCE_INVITE; $userInvite->source = Invite::SOURCE_INVITE;
$userInvite->user_originator_id = Yii::$app->user->getIdentity()->id; $userInvite->user_originator_id = Yii::$app->user->getIdentity()->id;
$existingInvite = Invite::findOne(['email' => $email]); $existingInvite = Invite::findOne(['email' => $email]);
if ($existingInvite !== null) { if ($existingInvite !== null) {
$userInvite->token = $existingInvite->token; $userInvite->token = $existingInvite->token;
$existingInvite->delete(); $existingInvite->delete();
} }
$userInvite->save(); $userInvite->save();
$userInvite->sendInviteMail(); $userInvite->sendInviteMail();
} }
/** /**
* Checks if current user can invite new members * Checks if current user can invite new members
* *
* @return boolean can invite new members * @return boolean can invite new members
*/ */
protected function canInvite() protected function canInvite()
{ {
return Yii::$app->getModule('user')->settings->get('auth.internalUsersCanInvite') || Yii::$app->user->can([new ManageUsers(), new ManageGroups()]); /** @var Module $module */
$module = Yii::$app->getModule('user');
return $module->settings->get('auth.internalUsersCanInvite') ||
Yii::$app->user->can([new ManageUsers(), new ManageGroups()]);
} }
} }