estado == self::ESTADO_ACTIVO); } /** * Returns the static model of the specified AR class. * @param string $className active record class name. * @return Usuario 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 'tbl_usuarios'; } /** * @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('email, password', 'required'), array('estado', 'length', 'max'=>1), array('email', 'email'), array('email', 'unique'), array('descripcion', 'safe'), array('email, nombre, apellidos, password, tipo, titulo, localidad, telefono', 'length', 'max'=>255), array('id, id_empresa, estado, email, nombre, apellidos, tipo, titulo, localidad, telefono, descripcion', '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( 'empresa' => array(self::HAS_ONE, 'Empresa', 'id'), ); } /** * @return array customized attribute labels (name=>label) */ public function attributeLabels() { return array( 'id' => 'ID', 'estado' => 'Estado', 'email' => 'Email', 'nombre' => 'Nombre', 'apellidos' => 'Apellidos', 'password' => 'Password', 'tipo' => 'Tipo', 'titulo' => 'Título', 'localidad' => 'Localidad', 'telefono' => 'Teléfono', 'descripcion' => 'Descripción', ); } /** * 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() { $criteria=new CDbCriteria; $criteria->compare('id',$this->id); $criteria->compare('id_empresa',$this->id_empresa); $criteria->compare('estado',$this->estado,true); $criteria->compare('email',$this->email,true); $criteria->compare('nombre',$this->nombre,true); $criteria->compare('apellidos',$this->apellidos,true); $criteria->compare('tipo',$this->tipo,true); $criteria->compare('titulo',$this->titulo,true); $criteria->compare('localidad',$this->localidad,true); $criteria->compare('telefono',$this->telefono,true); $criteria->compare('last_login_time',$this->last_login_time,true); $criteria->compare('descripcion',$this->descripcion,true); return new CActiveDataProvider($this, array( 'criteria'=>$criteria, )); } public function encrypt($value) { return md5($value); } }