2012-09-20 19:38:42 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Clase que representa los datos enviados por el usuario a través
|
|
|
|
|
* del formulario de registro de la página de entrada.
|
|
|
|
|
*/
|
|
|
|
|
class FormularioInvitarAgente extends CFormModel {
|
|
|
|
|
|
|
|
|
|
public $nombre;
|
|
|
|
|
public $email;
|
|
|
|
|
public $mensaje;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Declares the validation rules.
|
|
|
|
|
* The rules state that username and password are required,
|
|
|
|
|
* and password needs to be authenticated.
|
|
|
|
|
*/
|
|
|
|
|
public function rules() {
|
|
|
|
|
return array(
|
|
|
|
|
array('nombre, email', 'required'),
|
|
|
|
|
array('nombre, email, mensaje', 'safe'),
|
|
|
|
|
array('email', 'email'),
|
2012-09-30 17:08:01 +00:00
|
|
|
array('email', 'comprobarEmailRepetido', 'message' => Yii::t('profind', 'Ya existe un agente con el mismo email')),
|
2012-09-20 19:38:42 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-30 17:08:01 +00:00
|
|
|
public function comprobarEmailRepetido($attribute, $params) {
|
2012-09-20 19:38:42 +00:00
|
|
|
$consulta = new CDbCriteria();
|
2012-09-30 17:08:01 +00:00
|
|
|
$consulta->addColumnCondition(array(
|
|
|
|
|
'id_empresa' => Yii::app()->user->id_empresa,
|
|
|
|
|
'email' => $this->$attribute
|
|
|
|
|
));
|
2012-09-20 19:38:42 +00:00
|
|
|
$consulta->limit = 1;
|
2012-09-30 17:08:01 +00:00
|
|
|
|
|
|
|
|
if (Usuario::model()->count($consulta) != '0') {
|
|
|
|
|
$this->addError($attribute, $params['message']);
|
|
|
|
|
}
|
2012-09-20 19:38:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|