Class humhub\modules\space\behaviors\SpaceModelMembership

Inheritancehumhub\modules\space\behaviors\SpaceModelMembership » yii\base\Behavior

SpaceModelMemberBehavior bundles all membership related methods of the Space model.

Public Methods

Hide inherited methods

MethodDescriptionDefined By
addMember() Adds an member to this space. humhub\modules\space\behaviors\SpaceModelMembership
canDelete() humhub\modules\space\behaviors\SpaceModelMembership
canLeave() Checks if a given Userid is allowed to leave this space. humhub\modules\space\behaviors\SpaceModelMembership
getAdmins() Returns the admins of the space humhub\modules\space\behaviors\SpaceModelMembership
getAdminsQuery() Returns user query for admins of the space humhub\modules\space\behaviors\SpaceModelMembership
getMembership() Returns the SpaceMembership Record for this Space humhub\modules\space\behaviors\SpaceModelMembership
getSpaceOwner() Gets Owner for this workspace humhub\modules\space\behaviors\SpaceModelMembership
inviteMember() Invites a registered user to this space humhub\modules\space\behaviors\SpaceModelMembership
inviteMemberByEMail() Invites a not registered member to this space humhub\modules\space\behaviors\SpaceModelMembership
isAdmin() Checks if given Userid is Admin of this Space or has the permission to manage spaces. humhub\modules\space\behaviors\SpaceModelMembership
isMember() Checks if given userId is Member of this Space. humhub\modules\space\behaviors\SpaceModelMembership
isSpaceOwner() Is given User owner of this Space humhub\modules\space\behaviors\SpaceModelMembership
removeMember() Remove Membership humhub\modules\space\behaviors\SpaceModelMembership
requestMembership() Requests Membership humhub\modules\space\behaviors\SpaceModelMembership
setAdmin() Sets Owner for this workspace humhub\modules\space\behaviors\SpaceModelMembership
setSpaceOwner() Sets Owner for this workspace humhub\modules\space\behaviors\SpaceModelMembership

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
sendInviteNotification() Sends an Invite Notification to the given user. humhub\modules\space\behaviors\SpaceModelMembership

Method Details

addMember() public method

Adds an member to this space.

This can happens after an clicking "Request Membership" Link after Approval or accepting an invite.

public boolean addMember ( $userId, $canLeave 1, $silent false )
$userId integer
$canLeave integer

0: user cannot cancel membership | 1: can cancel membership | 2: depending on space flag members_can_leave

$silent boolean

Add member without any notifications

canDelete() public method (available since version 1.3)

public boolean canDelete ( )
return boolean

Checks if the current user is allowed to delete this space

canLeave() public method

Checks if a given Userid is allowed to leave this space.

A User is allowed to leave, if the can_cancel_membership flag in the space_membership table is 1. If it is 2, the decision is delegated to the space.

public boolean canLeave ( $userId '' )
$userId \humhub\modules\space\behaviors\number

, if empty hte currently logged in user is taken.

getAdmins() public method

Returns the admins of the space

public humhub\modules\user\models\User[] getAdmins ( )
return humhub\modules\user\models\User[]

The admin users of the space

getAdminsQuery() public method (available since version 1.3)

Returns user query for admins of the space

public humhub\modules\user\components\ActiveQueryUser getAdminsQuery ( )
getMembership() public method

Returns the SpaceMembership Record for this Space

If none Record is found, null is given

public humhub\modules\space\models\Membership getMembership ( $userId null )
$userId
return humhub\modules\space\models\Membership

The membership

getSpaceOwner() public method

Gets Owner for this workspace

public humhub\modules\user\models\User getSpaceOwner ( )
inviteMember() public method

Invites a registered user to this space

If user is already invited, retrigger invitation. If user is applicant approve it.

public void inviteMember ( $userId, $originatorId, $sendInviteNotification true )
$userId integer
$originatorId integer
$sendInviteNotification boolean
inviteMemberByEMail() public method

Invites a not registered member to this space

public void inviteMemberByEMail ( $email, $originatorUserId )
$email string
$originatorUserId integer
isAdmin() public method

Checks if given Userid is Admin of this Space or has the permission to manage spaces.

If no UserId is given, current UserId will be used

public boolean isAdmin ( $user null )
$user humhub\modules\user\models\User|integer|null

User instance or userId

isMember() public method

Checks if given userId is Member of this Space.

public boolean isMember ( $userId '' )
$userId integer
isSpaceOwner() public method

Is given User owner of this Space

public boolean isSpaceOwner ( $userId null )
$userId humhub\modules\user\models\User|integer|null
removeMember() public method

Remove Membership

public boolean removeMember ( $userId '' )
$userId integer

Of User to Remove

throws \yii\base\InvalidConfigException
throws Throwable
requestMembership() public method

Requests Membership

public void requestMembership ( $userId, $message '' )
$userId integer
$message string
sendInviteNotification() protected method

Sends an Invite Notification to the given user.

protected void sendInviteNotification ( $userId, $originatorId )
$userId integer
$originatorId integer
setAdmin() public method

Sets Owner for this workspace

public boolean setAdmin ( $userId null )
$userId integer
setSpaceOwner() public method

Sets Owner for this workspace

public boolean setSpaceOwner ( $user null )
$user