38 lines
1.1 KiB
PHP
38 lines
1.1 KiB
PHP
|
|
<?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'),
|
||
|
|
array('email', 'comprobarEmailRepetido', 'message' => Yii::t('profind', 'Ya existe un agente con el mismo email')),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function comprobarEmailRepetido($email, $message) {
|
||
|
|
$consulta = new CDbCriteria();
|
||
|
|
$consulta->addCondition('id_empresa = ' . Yii::app()->user->id_empresa);
|
||
|
|
$consulta->addCondition('email = ' . $email);
|
||
|
|
$consulta->limit = 1;
|
||
|
|
|
||
|
|
if (Usuario::model()->count($consulta) != '0')
|
||
|
|
$this->addError($email, $message);
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|