/**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new DetalleProyecto();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['DetalleProyecto'])) {
         $usuarioActual = Usuario::model()->obtenerUsuarioActual();
         $model->attributes = $_POST['DetalleProyecto'];
         $model->proyecto_did = $_GET["id"];
         if (!isset($_GET["ayuda"])) {
             $model->responsable_did = $usuarioActual->id;
         } else {
             $model->ayuda_did = 3;
         }
         if ($model->save()) {
             Yii::app()->user->setFlash("info", "Se agregó una actividad el proyecto: " . $model->proyecto->nombre . ".");
             $proyecto = Proyecto::model()->find("id = " . $model->proyecto_did);
             if ($proyecto->estatus_did == 2) {
                 $proyecto->estatus_did = 1;
                 if ($proyecto->save()) {
                     Yii::app()->user->setFlash("info", "El proyecto: " . $proyecto->nombre . " se volvió a poner en Proceso, debido a que tiene más de 1 actividad en pendiente");
                 }
             }
             $this->redirect(array('create', 'id' => $model->proyecto_did));
         }
     }
     $this->render('create', array('model' => $model));
 }
Exemple #2
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Foro();
     date_default_timezone_set("America/Monterrey");
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Foro'])) {
         $model->attributes = $_POST['Foro'];
         $usuarioActual = Usuario::model()->obtenerUsuarioActual();
         if (isset($_GET["id"])) {
             $model->identificador = $_GET["id"];
             $temaPrincipal = $this->loadModel($_GET["id"]);
             $temaPrincipal->respuestas++;
             $temaPrincipal->fecha_f = date("Y-d-m H:i:s", strtotime($temaPrincipal->fecha_f));
             $temaPrincipal->ult_respuesta = date("Y-d-m H:i:s", strtotime($temaPrincipal->ult_respuesta));
             $temaPrincipal->save();
         } else {
             $model->identificador = 0;
         }
         $model->respuestas = 0;
         $model->fecha_f = date("Y-d-m H:i:s");
         $model->ult_respuesta = date("Y-d-m H:i:s");
         $model->estatus_did = 1;
         $model->usuario_did = $usuarioActual->id;
         if ($model->save()) {
             Yii::app()->user->setFlash('info', "Agregó un nuevo mensaje: ' " . $model->mensaje . "'");
             $this->redirect(array('view', 'id' => isset($_GET["id"]) ? $_GET["id"] : $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
 public function authenticate()
 {
     $record = Usuario::model()->findByAttributes(array('usuario_email' => $this->username, 'usuario_excluido' => 'S'));
     //$passwd_ = Yii::app()->controller->action->id != 'nova_'? md5($this->password) : $this->password;
     $passwd_ = md5($this->password);
     if ($record === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if ($record->usuario_senha !== $passwd_) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             if ($record->usuario_excluido == "N") {
                 $this->errorCode = "Conta de usuário desativada.";
             } else {
                 $this->_id = $record->usuario_id;
                 //$this->setState('title', $record->title);
                 $this->errorCode = self::ERROR_NONE;
                 /* Seta um novo nome de sessão e variável */
                 $this->setState(Yii::app()->params['user_session_usuario_id'], array(Yii::app()->params['user_session_usuario_id'] => $record->usuario_id));
                 $this->setState(Yii::app()->params['user_session_usuario_tipo'], array(Yii::app()->params['user_session_usuario_tipo'] => $record->usuario_tipo));
                 $this->setState('usuario_nome_responsavel', $record->usuario_nome_responsavel);
             }
         }
     }
     //echo $this->errorCode; exit;
     return !$this->errorCode;
 }
Exemple #4
0
 public function authenticate()
 {
     $username = strtolower($this->username);
     $user = usuario::model()->find('LOWER(username)=?', array($username));
     if ($user === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if (!$user->validatePassword($this->password)) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             $this->_id = $user->idusuario;
             $this->username = $user->username;
             $this->errorCode = self::ERROR_NONE;
             /* Consultamos los datos del usuario por el username ($user->username) */
             $info_usuario = Usuario::model()->find('LOWER(username)=?', array($user->username));
             /* En las vistas tendremos disponibles last_login y perfil pueden setear las que requieran */
             // $this->setState('last_login',$info_usuario->last_login);
             // $this->setState('perfil',$info_usuario->perfil);
             /*
              * Actualizamos el last_login del usuario que se esta autenticando ($user->username)
              * $sql = "update usuario set last_login = now() where username='******'";
              * $connection = Yii::app() -> db;
              * $command = $connection -> createCommand($sql);
              * $command -> execute();
              */
         }
     }
     return $this->errorCode == self::ERROR_NONE;
 }
 /**
  * Envia e-mail de recuperação de senha 
  */
 public function recover()
 {
     if (!$this->validate()) {
         return false;
     }
     $usuario = Usuario::model()->ativos()->find("email = ?", array($this->email));
     if ($usuario == null) {
         $this->addError('email', Yii::t('RecuperarSenhaForm', 'Este e-mail está incorreto ou não está cadastrado.'));
         return false;
     }
     $usuario->geraTokenRecuperacaoSenha();
     $assunto = 'Recuperação de senha';
     $view = Yii::app()->controller->renderFile(Yii::getPathOfAlias('application.views.mail') . '/recuperarSenha.php', array('usuario' => $usuario), true);
     $email = new YiiMailMessage();
     $email->view = "template";
     $email->setBody(array('content' => $view, 'title' => $assunto), 'text/html');
     $email->subject = $assunto;
     $email->addTo($this->email);
     $email->from = Yii::app()->params['adminEmail'];
     try {
         Yii::app()->mail->send($email);
     } catch (Exception $e) {
         Yii::log('Erro ao enviar o e-mail:  ' . $e->getMessage(), CLogger::LEVEL_ERROR);
         return false;
     }
     return true;
 }
Exemple #6
0
 /**
  * Authenticates a user.
  * The example implementation makes sure if the username and password
  * are both 'demo'.
  * In practical applications, this should be changed to authenticate
  * against some persistent user identity storage (e.g. database).
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     $record = Usuario::model()->findByAttributes(array('usuario' => $this->username));
     if ($record == null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if ($record->clave != crypt($this->password, 'salt')) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             $this->errorCode = self::ERROR_NONE;
         }
     }
     return !$this->errorCode;
     /*
     $users=array(
     	// username => password
     	'demo'=>'demo',
     	'admin'=>'admin',
     );
     if(!isset($users[$this->username]))
     	$this->errorCode=self::ERROR_USERNAME_INVALID;
     elseif($users[$this->username]!==$this->password)
     	$this->errorCode=self::ERROR_PASSWORD_INVALID;
     else
     	$this->errorCode=self::ERROR_NONE;
     return !$this->errorCode;
     */
 }
Exemple #7
0
 public function authenticate()
 {
     $record = Usuario::model()->findByAttributes(array('email' => $this->username, 'senha' => $this->password));
     if ($record === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if ($record->senha !== $this->password) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             $this->_id = $record->id;
             $this->setState('nome', $record->nome);
             $this->setState('sobrenome', $record->sobrenome);
             $this->setState('celular', $record->celular);
             $this->setState('email', $record->email);
             $this->setState('foto', $record->foto);
             $this->setState('tipoUsuario', $record->tipoUsuario);
             $petshops = $record->Usuariopetshop;
             $idPetshop = array();
             foreach ($petshops as $key => $petshop) {
                 $idPetshop[] = $petshop->petshop;
             }
             $this->setState('petshop', $idPetshop);
             $this->setState('petatual', $idPetshop[0]);
             $this->errorCode = self::ERROR_NONE;
         }
     }
     return !$this->errorCode;
 }
 public function authenticate()
 {
     $record = Usuario::model()->findByAttributes(array('nombre' => $this->username));
     $conexion = Yii::app()->db;
     $consulta = "SELECT nombre, clave FROM usuario ";
     $consulta .= "WHERE nombre='" . $this->username . "' AND ";
     $consulta .= "clave='" . $this->password . "'";
     $resultado = $conexion->createCommand($consulta)->query();
     $resultado->bindColumn(1, $this->username);
     $resultado->bindColumn(2, $this->password);
     while ($resultado->read() !== false) {
         $this->errorCode = self::ERROR_NONE;
         $this->_id = $record->id;
         //bien
         $role = Roles::model()->findByPk($record->IdRol);
         //bien
         $this->setState('role', $role->NOMBRE);
         //bien
         return !$this->errorCode;
     }
     /*$users=array(
     			// username => password
     			'demo'=>'demo',
     			'admin'=>'admin',
     		);
     		if(!isset($users[$this->username]))
     			$this->errorCode=self::ERROR_USERNAME_INVALID;
     		elseif($users[$this->username]!==$this->password)
     			$this->errorCode=self::ERROR_PASSWORD_INVALID;
     		else
     			$this->errorCode=self::ERROR_NONE;
     		return !$this->errorCode;*/
 }
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     $modelUsuario = Usuario::model()->findByAttributes(array('cliente_id' => $id));
     $modelUsuario->setScenario('update');
     $this->tituloManual = "Editar o cliente: " . $model->nome;
     $this->performAjaxValidation($model);
     if (isset($_POST['Cliente'])) {
         $model->attributes = $_POST['Cliente'];
         $modelUsuario->email = $_POST['Usuario']['email'];
         if (!empty($_POST['Usuario']['senha'])) {
             $modelUsuario->setScenario('updatePassword');
             $modelUsuario->senha = $_POST['Usuario']['senha'];
             $modelUsuario->senha2 = $_POST['Usuario']['senha2'];
         }
         if ($modelUsuario->validate() && $model->validate()) {
             if ($model->save()) {
                 $modelUsuario->cliente_id = $model->id;
                 if ($modelUsuario->save()) {
                     $this->redirect(array('index'));
                 }
             }
         }
     } else {
         $modelUsuario->senha = '';
     }
     $this->render('update', array('model' => $model, 'modelUsuario' => $modelUsuario));
 }
Exemple #10
0
 /**
  * Carrega a hierarquia de roles
  */
 public function init()
 {
     $return = parent::init();
     $oUsuario = Usuario::model()->findByPk(Yii::app()->user->getId());
     $role = $this->createRole($oUsuario->tipoUsuario->titulo);
     if (empty($_SESSION[base64_encode(Yii::app()->params['projeto'] . '_PermissoesAcesso')][base64_encode('PermissoesAcessoUsuario')])) {
         $_aPermissoes = Yii::app()->user->getState('__' . base64_encode(Yii::app()->params['projeto'] . '_PermissoesAcessoUsuario'));
         if (!empty($_aPermissoes)) {
             $aPermissoes = $_aPermissoes[base64_encode(Yii::app()->params['projeto'] . '_PermissoesAcesso')][base64_encode('PermissoesAcessoUsuario')];
         }
     } else {
         $aPermissoes = $_SESSION[base64_encode(Yii::app()->params['projeto'] . '_PermissoesAcesso')][base64_encode('PermissoesAcessoUsuario')];
     }
     $this->createOperation('site/logout');
     $role->addChild('site/logout');
     $this->createOperation('site/index');
     $role->addChild('site/index');
     $this->createOperation('site/semPermissao');
     $role->addChild('site/semPermissao');
     if (!empty($aPermissoes)) {
         foreach ($aPermissoes as $controller => $actions) {
             foreach ($actions[base64_encode('actions')] as $action) {
                 $dController = base64_decode($controller);
                 $dAction = base64_decode($action);
                 $this->createOperation($dController . '/' . $dAction);
                 $role->addChild($dController . '/' . $dAction);
             }
         }
     }
     return $return;
 }
 /**
  * Authenticates a user.
  * The example implementation makes sure if the username and password
  * are both 'demo'.
  * In practical applications, this should be changed to authenticate
  * against some persistent user identity storage (e.g. database).
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     // nome de usuário em mininusculo, pos ele é salvo da mesma  forma
     $usuario = strtolower($this->username);
     // associa o email
     $record = Usuario::model()->find("LOWER(email) = '{$usuario}'");
     if ($record === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         // se o status do usuário for diferente de ativo
         if ($record->status != 1) {
             // identificação desconhecida
             $this->errorCode = self::ERROR_UNKNOWN_IDENTITY;
             // caso a senha seja diferente do salt com mds e a senha correta
         } else {
             if ($record->senha !== md5(SALT_MD5 . $this->password)) {
                 // senha inválida
                 $this->errorCode = self::ERROR_PASSWORD_INVALID;
                 // caso contrário
             } else {
                 // armazena as os estados repassando-as para a classe CWebUser
                 // que pos usa vez salva na sessão de forma persistente.
                 $this->setState('idUsuario', $record->id);
                 $this->setState('perfil', strtolower($record->perfil->descricao));
                 $this->setState('objeto', $record);
                 $this->errorCode = self::ERROR_NONE;
             }
         }
     }
     return !$this->errorCode;
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Empresa();
     if (isset($_POST['Empresa'])) {
         $model->attributes = $_POST['Empresa'];
         if (Yii::app()->user->tipo_usuario == 'super_admin') {
             $model->tipo_empresa_id = Yii::app()->params['empresa_admin'];
             $model->logo_tipo_id = $_POST['Empresa']['logo_tipo_id'];
             if ($model->logo_tipo_id == 1) {
                 $uploadedFile = CUploadedFile::getInstance($model, 'logo');
                 $fileName = "empresa_logo_" . "{$uploadedFile}";
                 // random number + file name
                 $model->logo = $fileName;
             }
         } else {
             $model->tipo_empresa_id = Yii::app()->params['empresa_cliente'];
             $model->empresa_id = Usuario::model()->findByPk(Yii::app()->user->id)->empresa_id;
         }
         if ($model->save()) {
             if (Yii::app()->user->tipo_usuario == 'super_admin') {
                 if ($model->logo_tipo_id == 1) {
                     $uploadedFile->saveAs(Yii::app()->basePath . '/../images/' . $fileName);
                 }
             }
             $this->redirect(array('admin'));
         }
     }
     $this->render('create', array('model' => $model));
 }
 /**
  * 
  * @return void
  */
 public function actionResendPassword()
 {
     $form = new ResendPasswordForm();
     // Formular wurde abgeschickt
     if (isset($_POST['ResendPasswordForm'])) {
         $form->attributes = $_POST['ResendPasswordForm'];
         // Form validieren
         if ($form->validate()) {
             // Neues Passwort generieren
             $password = substr(md5(rand()), 0, 8);
             // User holen, Passwort setzen und speichern
             $user = Usuario::model()->findByAttributes(array('usuario_email' => $form->usuario_email));
             $user = Usuario::model()->findByPk($user->usuario_id);
             $user->setScenario('update_usuario_password');
             $user->setPassword($password);
             $user->save();
             // Email
             $header = 'From: ' . Yii::app()->params['adminEmail'] . "\r\n" . 'Reply-To: ' . Yii::app()->params['adminEmail'];
             $body = Yii::t('user', 'Nova senha: {password}', array('{password}' => $password));
             // Versuchen E-Mail zu senden
             if (@mail($form->usuario_email, Yii::t('user', Yii::app()->params['assunto_form_nova_senha']), $body, $header)) {
                 Yii::app()->user->setFlash('resendPassword', Yii::t('user', 'Senha enviada com sucesso para: ' . $form->usuario_email . '.'));
             } else {
                 Yii::app()->user->setFlash('resendPassword', Yii::t('user', 'Erro ao enviar email de : {email}', array('{email}' => Yii::app()->params['adminEmail'])));
             }
             $this->refresh();
         }
     }
     $this->render('resendPassword', array('form' => $form));
 }
Exemple #14
0
        public function actionBorrarUsuario()
	{
		$contenidoFlujo = file_get_contents("php://input");
		$objetoUsuario = CJSON::decode($contenidoFlujo, false);
		$model = Usuario::model()->findByPk($objetoUsuario->idUsuario)->delete();
		exit();
		
	}
Exemple #15
0
 public function findUsuarioByPk($id)
 {
     try {
         return Usuario::model()->findByPk($id)->attributes;
     } catch (Exception $exc) {
         return null;
     }
 }
Exemple #16
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Usuario the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Usuario::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Exemple #17
0
 protected function loadUser($id = null)
 {
     if ($this->_model === null) {
         if ($id !== null) {
             $this->_model = Usuario::model()->findByPk($id);
         }
     }
     return $this->_model;
 }
 public function change()
 {
     if (!$this->hasErrors()) {
         $model = Usuario::model()->findByPk(Yii::app()->user->id);
         $model->usu_cla = MD5($this->password_new);
         return $model->save();
     }
     return false;
 }
 /**
  * Valida existencia de usuario con correo ingresado
  */
 public function validarCorreo($attribute, $params)
 {
     if (!$this->hasErrors()) {
         $this->usuario = Usuario::model()->find(array('with' => 'objUsuarioExtendida', 'condition' => 'correoElectronico=:correo', 'params' => array(':correo' => $this->correoElectronico)));
         if ($this->usuario === null) {
             $this->addError('correoElectronico', $this->getAttributeLabel($attribute) . ' no registrado');
         }
     }
 }
Exemple #20
0
 public function testEmailDeveSerUnico()
 {
     Usuario::model()->deleteAllByAttributes(['email' => '*****@*****.**']);
     $usuario1 = new Usuario();
     $usuario1->setAttributes(['pnome' => 'Fulano', 'snome' => 'de Tal', 'email' => '*****@*****.**', 'senha' => '123456', 'situacao' => Usuario::SIT_ATIVO, 'dt_criacao' => date('Y-m-d H:i:s')], false);
     $this->assertTrue($usuario1->save(false));
     $usuario2 = new Usuario();
     $usuario2->setAttributes(['pnome' => 'Ciclano', 'snome' => 'de Tal', 'email' => '*****@*****.**', 'senha' => '123456', 'senha_confirma' => '123456', 'situacao' => Usuario::SIT_ATIVO, 'dt_criacao' => date('Y-m-d H:i:s')], false);
     $this->assertFalse($usuario2->save());
 }
Exemple #21
0
 function getUser()
 {
     if ($this->isGuest) {
         return;
     }
     if ($this->_user === null) {
         $this->_user = Usuario::model()->findByPk($this->id);
     }
     return $this->_user;
 }
 public function valid()
 {
     $usuario = Usuario::model()->findByAttributes(array('email' => $this->username));
     if ($usuario->id_estado == 0) {
         $this->errorCode = self::ERROR_USERNAME_INACTIVE;
     } else {
         $this->errorCode = self::ERROR_NONE;
     }
     return !$this->errorCode;
 }
Exemple #23
0
 public function testCreate()
 {
     $user = new Usuario();
     $comment->setAttributes(array('id' => '50', 'cedula' => 'A', 'nombre' => 'José', 'sexo_id' => 1, 'profesion_id' => 1, 'f_creacion' => '2012-05-08 19:37:02', 'f_cambios' => '2012-05-08 19:37:02'), false);
     $this->assertTrue($user->save(false));
     // verify
     $user = Usuario::model()->findByPk($user->id);
     $this->assertTrue($user instanceof Usuario);
     $this->assertEquals(1, $user->profesion_id);
 }
 public function getPerfilFoto5($UsuId)
 {
     $Us = Usuario::model()->findByPk($UsuId);
     $perfilSocial = PerfilSocial::model()->find('id_usuario=:id_usuario', array(':id_usuario' => $Us->id_usuario));
     if ($perfilSocial->foto5 != null) {
         return $perfilSocial->foto5;
     } else {
         return null;
     }
 }
 public function actionPruebaAjax()
 {
     $usuario = Usuario::model()->findByPk(Yii::app()->user->id);
     $busqueda = $_GET['q'];
     $resultSet = Yii::app()->db->createCommand("select fu.id_usuario as id,concat(fu.nombre,' ',fu.apellido) as name from actividad_alumno acal join ficha_usuario fu where acal.id_actividad in(select distinct(a.id_actividad) from actividad_alumno aa,actividad a where aa.id_actividad=a.id_actividad and aa.id_usuario =" . $usuario->id_usuario . " or a.id_usuario =" . $usuario->id_usuario . ") and acal.id_usuario=fu.id_usuario and fu.nombre like '%" . $busqueda . "%' or fu.apellido like '%" . $busqueda . "%' limit 4")->queryAll();
     if ($resultSet) {
         echo CJSON::encode($resultSet);
     } else {
         echo "error";
     }
 }
 /**
  * Authenticates a user.
  * The example implementation makes sure if the username and password
  * are both 'demo'.
  * In practical applications, this should be changed to authenticate
  * against some persistent user identity storage (e.g. database).
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     $modelUser = Usuario::model()->findByAttributes(array('username_usuario' => $this->username, 'clave_usuario' => $this->password));
     if (!$modelUser) {
         $this->errorCode = self::ERROR_PASSWORD_INVALID;
     } else {
         Yii::app()->session['userModel'] = $modelUser;
         $this->errorCode = self::ERROR_NONE;
     }
     return !$this->errorCode;
 }
Exemple #27
0
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     // renders the view file 'protected/views/site/index.php'
     // using the default layout 'protected/views/layouts/main.php'
     $tipo = Usuario::model()->findByPk(Yii::app()->user->id)->tipoUsuario->nombre;
     if ($tipo == 'admin' || $tipo == 'super_admin') {
         $this->redirect(array('usuario/admin'));
     } else {
         $this->redirect(array('empresa/admin'));
     }
 }
 /**
  * Specifies the access control rules.
  * This method is used by the 'accessControl' filter.
  * @return array access control rules
  */
 public function accessRules()
 {
     $admin = TipoUsuario::model()->find('nombre=:nombre', array(':nombre' => 'Admin'));
     $usuarios = Usuario::model()->findAll();
     $arrayAdmin = array();
     foreach ($usuarios as $t) {
         if ($t->tipo_usuario_id == $admin->id) {
             $arrayAdmin[$t->cedula] = $t->usuario;
         }
     }
     return array(array('allow', 'actions' => array('index', 'view'), 'users' => $arrayAdmin), array('allow', 'actions' => array('create', 'update'), 'users' => $arrayAdmin), array('allow', 'actions' => array('admin', 'delete'), 'users' => $arrayAdmin), array('deny', 'users' => array('*')));
 }
Exemple #29
0
 /**
  * @return array validation rules for model attributes.
  */
 public function rules()
 {
     // NOTE: you should only define rules for those attributes that
     // will receive user inputs.
     $match = Usuario::model()->findByPk('usuario_cedula');
     if ($match) {
         $cedula = '/' . $match->cedula . '/';
     } else {
         $cedula = '/ /';
     }
     return array(array('usuario_cedula', 'required'), array('lunes, martes, miercoles, jueves, viernes, sabado, domingo, usuario_cedula', 'numerical', 'integerOnly' => true), array('fecha_inicio, fecha_fin', 'length', 'max' => 10), array('hora_inicio, hora_fin', 'length', 'max' => 2), array('usuario_cedula', 'exist', 'allowEmpty' => false, 'attributeName' => 'cedula', 'className' => 'Usuario', 'message' => 'Debe ingresar la cedula de un usuario registrado.'), array('hora_fin', 'compare', 'compareAttribute' => 'hora_inicio', 'operator' => '>=', 'message' => 'Hora de culminación debe ser mayor o igual a la de inicio'), array('fecha_fin', 'compare', 'compareAttribute' => 'fecha_inicio', 'operator' => '>=', 'message' => 'Fecha de culminación debe ser mayor o igual a la de inicio'), array('id, fecha_inicio, fecha_fin, hora_inicio, hora_fin, lunes, martes, miercoles, jueves, viernes, sabado, domingo, usuario_cedula', 'safe', 'on' => 'search'));
 }
Exemple #30
0
 /**
  * Authenticates a user.
  * The example implementation makes sure if the username and password
  * are both 'demo'.
  * In practical applications, this should be changed to authenticate
  * against some persistent user identity storage (e.g. database).
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     $user = Usuario::model()->find('LOWER(CodUsuario)=?', array($this->username));
     if ($user === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } elseif (sha1($this->password) !== $user->Contrasena) {
         $this->errorCode = self::ERROR_PASSWORD_INVALID;
     } else {
         $this->errorCode = self::ERROR_NONE;
     }
     return !$this->errorCode;
 }