git-svn-id: https://192.168.0.254/svn/Proyectos.Incam_PROFIND_Web/trunk@47 3fe1ab16-cfe0-e34b-8c9f-7d8c168d430d
40 lines
1.2 KiB
PHP
40 lines
1.2 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;
|
|
|
|
/**
|
|
* 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', 'safe'),
|
|
array('email', 'email'),
|
|
array('email', 'comprobarEmailRepetido', 'message' => Yii::t('profind', 'Ya existe un agente con el mismo email')),
|
|
);
|
|
}
|
|
|
|
public function comprobarEmailRepetido($attribute, $params) {
|
|
$consulta = new CDbCriteria();
|
|
$consulta->addColumnCondition(array(
|
|
'id_empresa' => Yii::app()->user->id_empresa,
|
|
'email' => $this->$attribute
|
|
));
|
|
$consulta->limit = 1;
|
|
|
|
if (Usuario::model()->count($consulta) != '0') {
|
|
$this->addError($attribute, $params['message']);
|
|
}
|
|
}
|
|
|
|
}
|