Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | List of all members
Friendship Class Reference

Public Member Functions

 tableName ()
 rules ()
 relations ()
 friend ($user_id)
 me ($user_id)
 myRequest ($user_id)

Static Public Member Functions

static model ($className=__CLASS__)

Public Attributes

const STATUS_CANCELED = -1
const STATUS_NOT_APPROVED = 0
const STATUS_APPROVED = 1

Protected Member Functions

 afterFind ()

Detailed Description

Definition at line 18 of file Friendship.php.

Member Function Documentation

Friendship::afterFind ( )
protected

If the user was removed after friendship with him was created gportal will destruct such relations to avoid errors

Definition at line 121 of file Friendship.php.

{
if(!isset($this->user1) || !isset($this->user2)){
$this->delete();
}
}
Friendship::friend (   $user_id)

Returns friend User model.

Parameters
int$user_idid of some user in this friendship
Returns
null|User his friend

Definition at line 73 of file Friendship.php.

{
if ($user_id == $this->user1_id) {
return $this->user2;
} elseif ($user_id == $this->user2_id) {
return $this->user1;
}
return null;
}
Friendship::me (   $user_id)

Get User model of user with $user_id

Parameters
int$user_idid of some user in this friendship
Returns
null|User his model

Definition at line 90 of file Friendship.php.

{
if ($user_id == $this->user1->id) {
return $this->user1;
} elseif ($user_id == $this->user2->id) {
return $this->user2;
}
return null;
}
static Friendship::model (   $className = __CLASS__)
static

Returns the static model of the specified AR class.

Parameters
string$classNameactive record class name
Returns
array|CActiveRecord

Definition at line 32 of file Friendship.php.

Referenced by FriendsController\actionAdd(), FriendsController\actionApprove(), and FriendsController\actionCancel().

{
return parent::model($className);
}
Friendship::myRequest (   $user_id)

Check if user with $user_id make friend request or not

Parameters
int$user_idid of needed user
Returns
bool

Definition at line 107 of file Friendship.php.

{
if ($user_id == $this->user1->id) {
return true;
}
return false;
}
Friendship::tableName ( )

Returns the name of the associated database table. By default this method returns the class name as the table name. You may override this method if the table is not named after this convention.

Returns
string the table name

Definition at line 44 of file Friendship.php.

{
return '{{friendship}}';
}

The documentation for this class was generated from the following file: