Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Attributes | List of all members
User Class Reference
Inheritance diagram for User:
RegistrationForm UserSearch

Public Member Functions

 tableName ()
 rules ()
 relations ()
 isExists ()
 attributeLabels ()
 scopes ()
 defaultScope ()
 search ()

Static Public Member Functions

static model ($className=__CLASS__)
static create ($account, $service)
static itemAlias ($type, $code=NULL)

Public Attributes

const STATUS_NOACTIVE = 0
const STATUS_ACTIVE = 1
const STATUS_BANED = -1
 $justSaved = false
 $firstname
 $lastname

Protected Attributes

 $isExists = null

Detailed Description

Definition at line 3 of file User.php.

Member Function Documentation

User::attributeLabels ( )
Returns
array customized attribute labels (name=>label)

Definition at line 180 of file User.php.

References UserModule\t().

{
return array(
'username' => UserModule::t("Username"),
'password' => UserModule::t("Password"),
'verifyPassword' => UserModule::t("Retype Password"),
'email' => UserModule::t("E-mail"),
'verifyCode' => UserModule::t("Verification Code"),
'id' => UserModule::t("Id"),
'activkey' => UserModule::t("activation key"),
'createtime' => UserModule::t("Registration date"),
'lastvisit' => UserModule::t("Last visit"),
'status' => UserModule::t("Status"),
);
}
static User::model (   $className = __CLASS__)
static
User::relations ( )
Returns
array relational rules.

Definition at line 106 of file User.php.

{
$relations = array(
'profile' => array(self::HAS_ONE, 'Profile', 'user_id'),
);
if (isset(Yii::app()->getModule('user')->relations)) $relations = array_merge($relations, Yii::app()->getModule('user')->relations);
return $relations;
}
User::rules ( )
Returns
array validation rules for model attributes.

Reimplemented in RegistrationForm, and UserSearch.

Definition at line 63 of file User.php.

References UserModule\t().

{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
if(Yii::app()->getModule('user')->isAdmin()){
return array(
#array('username, password, email', 'required'),
array('username', 'length', 'max' => 20, 'min' => 3, 'message' => UserModule::t("Incorrect username (length between 3 and 20 characters).")),
array('password', 'length', 'max' => 128, 'min' => 4, 'message' => UserModule::t("Incorrect password (minimal length 4 symbols).")),
array('email', 'email', 'message' => UserModule::t("Email invalid.") ),
array('username', 'unique', 'message' => UserModule::t("This user's name already exists."), 'except'=>'nameIsNotUniq'),
array('email', 'unique', 'message' => UserModule::t("This user's email address already exists.")),
array('username', 'match', 'pattern' => '/^[A-Za-z0-9_]+$/u', 'message' => UserModule::t("Incorrect symbols (A-z0-9).")),
array('status', 'in', 'range' => array(self::STATUS_NOACTIVE, self::STATUS_ACTIVE, self::STATUS_BANED), 'message' => UserModule::t("Incorrect status.")),
array('username, email, status', 'required'),
array('status', 'numerical', 'integerOnly' => true),
//array('createtime', 'default', 'value' => date('Y-m-d H:i:s')), move to db
//array('lastvisit', 'default', 'value' => NULL),
array('createtime, lastvisit', 'type', 'type' => 'datetime', 'datetimeFormat' => 'yyyy-MM-dd hh:mm:ss', 'message' => UserModule::t("Date invalid.") ),
array('id, username, password, email, activkey, createtime, lastvisit, status, is_bulk, firstname, lastname', 'safe', 'on' => 'search'),
);
}else{
if(Yii::app()->user->id == $this->id){
return array(
array('email', 'required'),
array('email', 'email'),
array('email', 'unique', 'message' => UserModule::t("This user's email address already exists.")),
array('status', 'numerical', 'integerOnly' => true),
//array('username', 'unique', 'message' => UserModule::t("This user's name already exists.")),
//array('username', 'match', 'pattern' => '/^[A-Za-z0-9_]+$/u', 'message' => UserModule::t("Incorrect symbols (A-z0-9).")),
array('username,email, createtime, lastvisit, status', 'safe', 'on' => 'search'),
);
}else{
return array();
}
}
}
string for backend User::search ( )

Retrieves a list of models based on the current search/filter conditions.

Returns
CActiveDataProvider the data provider that can return the models based on the search/filter conditions.

Definition at line 246 of file User.php.

{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria = new CDbCriteria;
$criteria->compare('id', $this->id);
$criteria->compare('username', $this->username, true);
$criteria->compare('password', $this->password, true);
$criteria->compare('email', $this->email, true);
$criteria->compare('activkey', $this->activkey, true);
$criteria->compare('createtime', $this->createtime, true);
$criteria->compare('lastvisit', $this->lastvisit, true);
$criteria->compare('status', $this->status);
$criteria->compare('is_bulk', $this->is_bulk);
$criteria->together = true;
$criteria->with = array('profile');
$criteria->compare('profile.firstname', $this->firstname, true);
$criteria->compare('profile.lastname', $this->lastname, true);
return new CActiveDataProvider($this, array(
'criteria' => $criteria,
'pagination' => array(
'pageSize' => Yii::app()->controller->module->user_page_size,
),
));
}
User::tableName ( )
Returns
string the associated database table name

Definition at line 50 of file User.php.

{
return Yii::app()->getModule('user')->tableUsers;
}

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