<?php
/**
* This file is part of TruwePDF.
* TruwePDF is a software project to power websites with subscription-based
* access to PDF files. No permission is granted to use, modify or distribute this source code.
*
* @copyright Copyright (c) 2012, Ben Truwe <truwe@mind.net>
* @author Sean McCleary <sean@seanmccleary.info>
*/
/**
* This is the model class for table "User".
*
* The followings are the available columns in table 'User':
* @property integer $id
* @property string $emailAddress
* @property boolean $isEmailAddressVerified
* @property string $accountCreated
* @property string $accountDeleted
* @property string $lastLogin
* @property string $subscriptionExpires
* @property string $adminNote
* @property boolean $isAdmin
* @property string $accountLocked
*
* The followings are the available model relations:
* @property ExternalLogin[] $externalLogins
* @property PaymentHistory[] $paymentHistories
*/
class User extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @return User the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'User';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('emailAddress, accountCreated, lastLogin', 'required'),
array('isEmailAddressVerified, isAdmin', 'boolean'),
array('emailAddress', 'length', 'max'=>100),
array('adminNote', 'length', 'max'=>140),
array('accountDeleted, subscriptionExpires, accountLocked', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, emailAddress, isEmailAddressVerified, accountCreated, accountDeleted, lastLogin, subscriptionExpires, adminNote, isAdmin, accountLocked', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'externalLogins' => array(self::HAS_MANY, 'ExternalLogin', 'userId'),
'paymentHistories' => array(self::HAS_MANY, 'PaymentHistory', 'userId'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'emailAddress' => 'Email Address',
'isEmailAddressVerified' => 'Is Email Address Verified',
'accountCreated' => 'Account Created',
'accountDeleted' => 'Account Deleted',
'lastLogin' => 'Last Login',
'subscriptionExpires' => 'Subscription Expires',
'adminNote' => 'Admin Note',
'isAdmin' => 'Is Admin',
'accountLocked' => 'Account Locked',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('emailAddress',$this->emailAddress,true);
$criteria->compare('isEmailAddressVerified',$this->isEmailAddressVerified);
$criteria->compare('accountCreated',$this->accountCreated,true);
$criteria->compare('accountDeleted',$this->accountDeleted,true);
$criteria->compare('lastLogin',$this->lastLogin,true);
$criteria->compare('subscriptionExpires',$this->subscriptionExpires,true);
$criteria->compare('adminNote',$this->adminNote,true);
$criteria->compare('isAdmin',$this->isAdmin);
$criteria->compare('accountLocked',$this->accountLocked,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
}