Class humhub\modules\friendship\models\Friendship

Inheritancehumhub\modules\friendship\models\Friendship » humhub\components\ActiveRecord » yii\db\ActiveRecord
ImplementsSerializable

This is the model class for table "user_friendship".

Public Methods

Hide inherited methods

MethodDescriptionDefined By
add() Adds a friendship or sends a request humhub\modules\friendship\models\Friendship
afterSave() humhub\modules\friendship\models\Friendship
attributeLabels() humhub\modules\friendship\models\Friendship
beforeSave() humhub\components\ActiveRecord
cancel() Cancels a friendship or request to a friend humhub\modules\friendship\models\Friendship
getCreatedBy() Relation to User defined in created_by attribute humhub\components\ActiveRecord
getErrorMessage() Returns the errors as string for all attribute or a single attribute. humhub\components\ActiveRecord
getFileManager() Returns the file manager for this record humhub\components\ActiveRecord
getFriendUser() humhub\modules\friendship\models\Friendship
getFriendsQuery() Returns a query for friends of a user humhub\modules\friendship\models\Friendship
getReceivedRequestsQuery() Returns a query for received and not responded friend requests of an user humhub\modules\friendship\models\Friendship
getSentRequestsQuery() Returns a query for sent and not approved friend requests of an user humhub\modules\friendship\models\Friendship
getStateForUser() Returns the friendship state between to users humhub\modules\friendship\models\Friendship
getUniqueId() Returns a unique id for this record/model humhub\components\ActiveRecord
getUpdatedBy() Relation to User defined in updated_by attribute humhub\components\ActiveRecord
getUser() humhub\modules\friendship\models\Friendship
rules() humhub\modules\friendship\models\Friendship
serialize() Serializes attributes and oldAttributes of this record. humhub\components\ActiveRecord
tableName() humhub\modules\friendship\models\Friendship
unserialize() Unserializes the given string, calls the init() function and sets the attributes and oldAttributes. humhub\components\ActiveRecord

Constants

Hide inherited constants

ConstantValueDescriptionDefined By
STATE_FRIENDS 1 humhub\modules\friendship\models\Friendship
STATE_NONE 0 Friendship States humhub\modules\friendship\models\Friendship
STATE_REQUEST_RECEIVED 2 humhub\modules\friendship\models\Friendship
STATE_REQUEST_SENT 3 humhub\modules\friendship\models\Friendship

Method Details

add() public static method

Adds a friendship or sends a request

public static void add ( $user, $friend )
$user humhub\modules\user\models\User
$friend humhub\modules\user\models\User
afterSave() public method

public void afterSave ( $insert, $changedAttributes )
$insert
$changedAttributes
attributeLabels() public method

public void attributeLabels ( )
cancel() public static method

Cancels a friendship or request to a friend

public static void cancel ( $user, $friend )
$user humhub\modules\user\models\User
$friend humhub\modules\user\models\User
getFriendUser() public method

public \yii\db\ActiveQuery getFriendUser ( )
getFriendsQuery() public static method

Returns a query for friends of a user

public static \yii\db\ActiveQuery getFriendsQuery ( humhub\modules\user\models\User $user )
$user humhub\modules\user\models\User
getReceivedRequestsQuery() public static method

Returns a query for received and not responded friend requests of an user

public static \yii\db\ActiveQuery getReceivedRequestsQuery ( $user )
$user humhub\modules\user\models\User
getSentRequestsQuery() public static method

Returns a query for sent and not approved friend requests of an user

public static \yii\db\ActiveQuery getSentRequestsQuery ( humhub\modules\user\models\User $user )
$user humhub\modules\user\models\User
getStateForUser() public static method

Returns the friendship state between to users

public static integer getStateForUser ( $user, $friend )
$user humhub\modules\user\models\User
$friend humhub\modules\user\models\User
return integer

The request state see self::STATE_*

getUser() public method

public \yii\db\ActiveQuery getUser ( )
rules() public method

public void rules ( )
tableName() public static method

public static void tableName ( )

Event Details

EVENT_FRIENDSHIP_CREATED event of type humhub\modules\friendship\FriendshipEvent
EVENT_FRIENDSHIP_REMOVED event of type humhub\modules\friendship\FriendshipEvent