/**
  * 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()
 {
     $Institucion = Institucion::model()->findByAttributes(array('email' => $this->username));
     if ($Institucion == null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } elseif (md5($this->password) != $Institucion->password) {
         $this->errorCode = self::ERROR_PASSWORD_INVALID;
     } else {
         $this->_id = $Institucion->id_institucion;
         $this->setState("email", $Institucion->email);
         $this->errorCode = self::ERROR_NONE;
     }
     return !$this->errorCode;
 }
Ejemplo n.º 2
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCrearActividad()
 {
     $usuarioins = Institucion::model()->findByPk(Yii::app()->user->id);
     $actividad = new Actividad();
     $deporte = new Deporte();
     $ficha_usuario = new FichaUsuario();
     $actividad_horario = new ActividadHorario();
     if (isset($_POST['Actividad'])) {
         $actividad->attributes = $_POST['Actividad'];
         $actividad->id_institucion = $usuarioins->id_institucion;
         $actividad->fhcreacion = new CDbExpression('NOW()');
         $actividad->fhultmod = new CDbExpression('NOW()');
         $actividad->cusuario = $usuarioins->email;
         $actividades = 0;
         if ($actividad->save()) {
             $cant = count($_POST['dia']);
             for ($i = 0; $i <= $cant - 1; $i++) {
                 $actividad_horario = new ActividadHorario();
                 $actividad_horario->id_actividad = $actividad->id_actividad;
                 $actividad_horario->id_dia = $_POST['dia'][$i];
                 $actividad_horario->hora = $_POST['hora'][$actividad_horario->id_dia - 1];
                 $actividad_horario->minutos = $_POST['minutos'][$actividad_horario->id_dia - 1];
                 $actividad_horario->fhcreacion = new CDbExpression('NOW()');
                 $actividad_horario->fhultmod = new CDbExpression('NOW()');
                 $actividad_horario->cusuario = $usuarioins->email;
                 if ($actividad_horario->save()) {
                     $actividades++;
                 }
             }
             if ($actividades = $cant) {
                 $this->redirect('CrearActividadOk');
             }
         }
     }
     $this->render('CrearActividad', array('deporte' => $deporte, 'actividad' => $actividad, 'actividad_horario' => $actividad_horario, 'ficha_usuario' => $ficha_usuario));
 }
<?php

/* @var $this UsuarioController */
/* @var $model Usuario */
/* @var $form CActiveForm */
if (!Yii::app()->user->isGuest) {
    //Es un usuario logueado.
    $usuarioins = Institucion::model()->findByPk(Yii::app()->user->id);
}
?>

<style type="text/css">
    body {
        background: url(../img/25.jpg) no-repeat center center fixed;
        -webkit-background-size: cover;
        -moz-background-size: cover;
        -o-background-size: cover;
        background-size: cover;
    }
</style>


<header class="navbar navbar-static-top bs-docs-nav" id="top" role="banner">
    <div class="container">
        <div class="navbar-header">
            <button class="navbar-toggle collapsed" type="button" data-toggle="collapse" data-target="#bs-navbar" aria-controls="bs-navbar" aria-expanded="false">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
 /**
  * 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 Institucion the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Institucion::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }