git-svn-id: https://192.168.0.254/svn/Proyectos.Incam_PROFIND_Web/trunk@18 3fe1ab16-cfe0-e34b-8c9f-7d8c168d430d
134 lines
4.1 KiB
PHP
134 lines
4.1 KiB
PHP
<?php
|
|
|
|
/**
|
|
* This is the model class for table "tbl_usuarios".
|
|
*
|
|
* The followings are the available columns in table 'tbl_usuarios':
|
|
* @property integer $id
|
|
* @property integer $id_empresa
|
|
* @property string $estado
|
|
* @property string $email
|
|
* @property string $nombre
|
|
* @property string $apellidos
|
|
* @property string $password
|
|
* @property string $tipo
|
|
* @property string $titulo
|
|
* @property string $localidad
|
|
* @property string $telefono
|
|
* @property string $last_login_time
|
|
* @property string $clave_seguridad
|
|
* @property string $descripcion
|
|
*
|
|
* The followings are the available model relations:
|
|
* @property Empresa $empresa
|
|
*/
|
|
class Usuario extends CActiveRecord {
|
|
|
|
const ESTADO_NOACTIVO = 0;
|
|
const ESTADO_ACTIVO = 1;
|
|
const ESTADO_DENEGADO = 2;
|
|
|
|
//public $password_repeat;
|
|
//public $empresa;
|
|
|
|
public function getEstaActivo() {
|
|
return ($this->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);
|
|
}
|
|
|
|
}
|