示例#1
0
 public function ejecutar($id_usuario, $id_partido, $id_equipo)
 {
     $ret = 0;
     //Traer el array de efectos
     parent::ejecutar($id_usuario, $id_partido, $id_equipo);
     //Validar usuario
     $us = Usuarios::model()->findByPk($id_usuario);
     if ($us === null) {
         throw new Exception("Usuario incorrecto.", 404);
     }
     // Cojo el equipo del usuario
     $equipo = $us->equipos;
     // Modifico Los factores de ese partido
     $ret = min($ret, Partidos::aumentar_factores($id_partido, $equipo->id_equipo, "defensivo", Efectos::$datos_acciones['RetransmitirRRSS']['defensivo']));
     //Modifico los recursos Del usuario
     if (Recursos::aumentar_recursos($id_usuario, "animo", Efectos::$datos_acciones['RetransmitirRRSS']['animo']) == 0) {
         $ret = min($ret, 0);
     } else {
         $ret = -1;
     }
     // Incorporo un registro a la tabla acciones turno si el usuario aun no esta en ella
     AccionesTurno::incorporarAccion($id_usuario, $id_partido, $id_equipo);
     //Finalizar función
     return $ret;
 }
 /**
  * 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()
 {
     $intentos = 0;
     $users = Usuarios::model()->findByAttributes(array('usuario' => $this->username));
     // Si no se encuentra el usuario
     if ($users === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if ($users->clave != md5($this->password) && $users !== null) {
             //Miramos cuantos fallos tiene ya ese usuario y le añadimos el fallo actual
             $users->numFallos = $users->numFallos + 1;
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             // Coinciden usuario y contrasenia: no hay error
             $this->_id = $users->usuario;
             $this->username = $users->usuario;
             $this->errorCode = self::ERROR_NONE;
             //En las vistas tendremos disponible la fecha y hora de la última conexión. Si es la primera vez que ponga el mensaje "primera vez"
             if ($users->FechaHoraUltimaConexion == "NULL" || $users->FechaHoraUltimaConexion == "" || $users->FechaHoraUltimaConexion == "0000-00-00 00:00:00") {
                 $this->setState('FechaHoraUltimaConexion', date("Y-m-d H:i:s"));
             } else {
                 $this->setState('FechaHoraUltimaConexion', $users->FechaHoraUltimaConexion);
             }
             $this->_id = $users->IdUsuario;
             $this->name = $users->usuario;
             $users->FechaHoraUltimaConexion = date("Y-m-d H:i:s");
             $users->numFallos = 0;
         }
     }
     if ($users !== null) {
         $users->save();
         $this->setState('NumFallos', $users->numFallos);
     }
     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 actionModificarProducto($id)
 {
     $id = intval($id);
     $model = $this->loadModel($id);
     $usuario = Usuarios::model()->findByPk(Yii::app()->user->getId());
     if (isset($_POST['PresupuestoProductos'])) {
         if ($model->proyectoPartida->ente_organo_id == $usuario->ente_organo_id) {
             $modelNuevo = new PresupuestoProductos();
             $modelNuevo->attributes = $_POST['PresupuestoProductos'];
             $monAct = $modelNuevo->costo_unidad * $modelNuevo->cantidad;
             $monCar = $model->proyectoPartida->montoCargadoPartida();
             $montoPresuDif = $monAct - $monCar;
             if ($monAct > $model->proyectoPartida->monto_presupuestado) {
                 Yii::app()->user->setFlash('error', "El cambio no puede realizarse, el monto sobrepasa la cantidad de presupuesto disponible para la partida asociada al producto.");
             } else {
                 $model->costo_unidad = $modelNuevo->costo_unidad;
                 $model->cantidad = $modelNuevo->cantidad;
                 $model->monto_presupuesto = $model->costo_unidad * $model->cantidad;
                 if ($model->save()) {
                     Yii::app()->user->setFlash('success', "El cambio fue realizado con éxito.");
                 }
             }
         }
     }
     $this->render('update', array('model' => $model));
 }
 /**
  * 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()
 {
     /*$users=array(
     			// username => password
     			'demo'=>'demo',
     			'admin'=>'admin',
     		);*/
     if (isset($this->username)) {
         $username = strtolower($this->username);
         $user = Usuarios::model()->find('LOWER(email)=?', 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->id;
                 $this->username = $user->email;
                 $this->errorCode = self::ERROR_NONE;
                 Yii::app()->session['id_usuario'] = $user->id;
                 Yii::app()->session['nombre_usuario'] = $user->nombre;
                 Yii::app()->session['apellido_usuario'] = $user->apellido;
             }
         }
         return $this->errorCode == self::ERROR_NONE;
     }
 }
示例#5
0
文件: UserIdentity.php 项目: cicb/tpc
 public function authenticate()
 {
     $username = strtolower($this->username);
     $user = Usuarios::model()->findAll(array('condition' => "UsuariosNick= '{$this->username}' AND UsuariosPass=MD5('{$this->password}') AND UsuariosStatus='ALTA' AND TipUsrId IN(1,2)"));
     if (empty($user)) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         $this->_id = $user[0]->UsuariosId;
         $this->username = $user[0]->UsuariosNick;
         $this->errorCode = self::ERROR_NONE;
         /*Consultamos los datos del usuario por el username ($user->username) */
         //$info_usuario = Usuarios::model()->find('UsuariosNick)=?', array($user->UsuariosNick));
         /*En las vistas tendremos disponibles last_login y perfil pueden setear las que requieran */
         $this->setState('Admin', $user[0]->TipUsrId == "1" ? true : false);
         $this->setState('TipUsrId', $user[0]->TipUsrId);
         $this->setState('accesos', $user[0]->Accesos());
         $this->setState('modelo', $user[0]);
         /*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;
 }
示例#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()
 {
     $user = Usuarios::model()->find("LoginUsuario=?", array($this->username));
     if ($user == null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } elseif (sha1($this->password) != $user->ContrasenaUsuario) {
         $this->errorCode = self::ERROR_PASSWORD_INVALID;
     } else {
         $this->_id = $user->IdUsuario;
         $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;
     */
 }
示例#7
0
 /** Funcion auxiliar que modifica la tabla de recursos
  * 
  * @paremetro usuario al que modificamos sus recursos
  * @parametro columna sobre la que modificamos (dinero, dinero_gen, ...)
  * @parametro cantidad de recursos que quitamos
  * @devuelve flag de error
  * @ejemplo	$h->quitar_recursos(3, "animo", 30);
  */
 public function quitar_recursos($id_usuario, $columna, $cantidad)
 {
     /* ROBER */
     /*Recupero el usuario del que voy a aumentar los recursos*/
     $usuario = Usuarios::model()->findByPK($id_usuario);
     //Comprobación de seguridad
     if ($usuario === null) {
         throw new CHttpException(404, "Partido no encontrado. (quitar_recursos,Helper.php)");
     }
     /*Recupero de la tabla recursos la fila correspondiente a este usuario
       Compruebo si hay una instancia para ese usuario, sino la hay es null y devuelvo error*/
     $recursos = $usuario->recursos;
     if ($recursos === null) {
         return -1;
     } else {
         /*Cojo la columna a modificar del modelo, para modificarla despues*/
         $actuales = $recursos->{$columna};
         $recursos->{$columna} = $actuales - $cantidad;
         /*Al restar debo de comprobar que no sea valor negativo*/
         if ($recursos->{$columna} < 0) {
             $recursos->{$columna} = 0;
         }
         /*Si save() no lanza error entonces se realizo correctamente la actualizacion
         	 sino devuelves error*/
         if ($recursos->save()) {
             return 0;
         } else {
             return -1;
         }
     }
 }
示例#8
0
 /**
  * Comprueba que el usuario puede desbloquear la habilidad.
  *
  * Las restricciones actuales son:
  *
  * - Nivel del jugador
  * - Lista de habilidades requeridas 
  *
  * @param int $id_usuario      usuario que quiere desbloquear la habilidad
  * @param int $id_habilidad    habilidad que quiere ser desbloqueada
  * @return boolean             flag si la habilidad puede ser desbloqueada (true si es capaz, false cc)
  */
 public function puedeDesbloquear($id_usuario, $id_habilidad)
 {
     //Obtenemos los datos del usuario (para consultar el nivel)
     $usuario = Usuarios::model()->findByPk($id_usuario);
     //Obtenemos los datos de la habilidad (para consultar su codigo)
     $habilidad = Habilidades::model()->findByPk($id_habilidad);
     $puedeDesbloquear = true;
     $comentarioFlash = "";
     //1) comprobamos que el usario tenga un nivel igual o superior al requisito para desbloquear la habilidad y que tenga puntos de desbloqueo
     if ($usuario->nivel < RequisitosDesbloquearHabilidades::$datos_acciones[$habilidad->codigo]['nivel'] || $usuario->puntos_desbloqueo == 0) {
         $comentarioFlash .= "Nivel insuficiente. ";
         $puedeDesbloquear = false;
     }
     //2) Comprobamos que el usuario haya desbloqueado las habilidades requisito antes de intentar desbloquear esta
     //sacamos las habilidades requisito
     $habilidadesRequisito = RequisitosDesbloquearHabilidades::$datos_acciones[$habilidad->codigo]['desbloqueadas_previas'];
     if ($habilidadesRequisito !== null) {
         //Comprobamos que las haya desbloqueado
         foreach ($habilidadesRequisito as $habilidadReq) {
             //Con el codigo de la habilidad saco la habilidad requisito
             $habilidadAux = Habilidades::model()->findByAttributes(array('codigo' => $habilidadReq));
             //miro si el usuario tiene esa habilidad desbloqueada
             $desbloqueada = Desbloqueadas::model()->findByAttributes(array('habilidades_id_habilidad' => $habilidadAux->id_habilidad, 'usuarios_id_usuario' => $id_usuario));
             if ($desbloqueada === null) {
                 $puedeDesbloquear = false;
                 $comentarioFlash .= "Desbloquea antes " . $habilidadReq . ". ";
             }
         }
     }
     if ($puedeDesbloquear == false) {
         //Yii::app()->user->setFlash('desbloqueada', $comentarioFlash);
     }
     return $puedeDesbloquear;
 }
示例#9
0
 public function beforeAction($action)
 {
     if (!parent::beforeAction($action)) {
         return false;
     }
     if (isset(Yii::app()->user->usIdent)) {
         // Obtiene la clasificación de los equipos
         $clasificacion = Clasificacion::model()->with('equipos')->findAll(array('order' => 'posicion ASC'));
         Yii::app()->setParams(array('clasificacion' => $clasificacion));
         // Obtiene la información del usuario
         $usuario = Usuarios::model()->with('recursos')->findByPK(Yii::app()->user->usIdent);
         Yii::app()->setParams(array('usuario' => $usuario));
         // Obtiene la información de la mensajeria
         //Saca la lista de los emails recibidos por el usuario y que ademas no los haya leido
         $mensajeria = Emails::model()->findAllByAttributes(array('id_usuario_to' => Yii::app()->user->usIdent, 'leido' => 0));
         $countmens = count($mensajeria);
         Yii::app()->setParams(array('countmens' => $countmens));
         // Obtiene la información de las notificaciones
         //Saca la lista de las notinicaciones recibidas por el usuario y que ademas no haya leido
         $notificaciones = Usrnotif::model()->findAllByAttributes(array('usuarios_id_usuario' => Yii::app()->user->usIdent, 'leido' => 0));
         $countnot = count($notificaciones);
         Yii::app()->setParams(array('countnot' => $countnot));
     }
     Yii::app()->setParams(array('bgclass' => 'bg-estadio-fuera'));
     return true;
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new ProveedoresObjetos();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['ProveedoresObjetos'])) {
         $model->attributes = $_POST['ProveedoresObjetos'];
         $usuario = Usuarios::model()->actual();
         $model->ente_organo_id = $usuario->ente_organo_id;
         if ($model->validate()) {
             $objPrin = new ProveedorDominio();
             $objPrin->objeto = $model->objeto_principal;
             $objPrin->proveedor_id = $model->proveedor_id;
             $objPrin->ente_organo_id = $model->ente_organo_id;
             $objPrin->save();
             $productos = $model->rama_producto_id;
             foreach ($productos as $key) {
                 $aux = new ProveedoresObjetos();
                 $aux->attributes = $_POST['ProveedoresObjetos'];
                 $aux->ente_organo_id = $model->ente_organo_id;
                 $aux->rama_producto_id = $key;
                 $aux->save();
             }
             Yii::app()->user->setFlash('success', "Guardado con éxito!");
             $model = new ProveedoresObjetos();
         }
     }
     $this->render('create', array('model' => $model));
 }
示例#11
0
 protected function getIdentityName()
 {
     // the name shown
     $id = Yii::app()->user->usIdent;
     $model = Usuarios::model()->findByPk($id);
     return $model->nick;
 }
示例#12
0
 public function loadModel($id)
 {
     $model = Usuarios::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, Yii::t('app', 'The requested page does not exist.'));
     }
     return $model;
 }
示例#13
0
 /**
  *  Asignando anho y id del ente organo al cual pertenece el usuario.
  */
 public function beforeSave()
 {
     if ($this->isNewRecord) {
         $this->anho = Yii::app()->params['trimestresFechas'][Yii::app()->session['trimestreSeleccionado']]['anho'];
         $this->ente_organo_id = Usuarios::model()->findByPk(Yii::app()->user->getId())->enteOrgano->ente_organo_id;
     }
     return parent::beforeSave();
 }
示例#14
0
 public function tieneusuario($ente_organo_id)
 {
     if (Usuarios::model()->findByAttributes(array(':ente_organo_id' => $ente_organo_id))) {
         return true;
     } else {
         return false;
     }
 }
示例#15
0
 /**
  *
  * @param string $usr el usuario
  */
 public function validaLogin($usr)
 {
     $model = Usuarios::model()->findByAttributes(array('usuario' => $usr));
     if ($model == NULL) {
         $model = Usuarios::model()->findByAttributes(array('correo' => $usr));
     }
     return $model;
 }
示例#16
0
 /**
  * Pone el Id de la sesion en el objeto persistente de yii (cookie)
  * @param string $usuario el nombre
  */
 public function setIdUsuario($usuario)
 {
     $model = Usuarios::model()->findByAttributes(array('usuario' => $usuario));
     if ($model == NULL) {
         $model = Usuarios::model()->findByAttributes(array('correo' => $usuario));
     }
     Yii::app()->user->setState('id_usuario', $model->id);
 }
示例#17
0
 public function validarCodigo($cedula)
 {
     $usuario = Usuarios::model()->findByAttributes(array('cedula' => $this->cedula));
     if (empty($usuario)) {
         $this->addError($cedula, 'La cédula no se esta registrada.');
     }
     /*else(!empty($usuario))
     		$this->addError($cedula, 'Cédula ya existe ya utilizado.');*/
 }
 public function montoAccion(PresupuestoPartidaAcciones $accion)
 {
     $monto = 0;
     $usuario = Usuarios::model()->findByPk(Yii::app()->user->getId());
     $partidasAcciones = PresupuestoPartidaAcciones::model()->findAllByAttributes(array('accion_id' => $accion->accion_id, 'ente_organo_id' => $usuario->enteOrgano->ente_organo_id, 'anho' => Yii::app()->params['trimestresFechas'][Yii::app()->session['trimestreSeleccionado']]['anho']));
     foreach ($partidasAcciones as $key => $partidaAcciones) {
         $monto += $partidaAcciones->presupuestoPartida->monto_presupuestado;
     }
     return $monto;
 }
 /**
  *Busca la lista de partidas de la acción
  *@return Partidas[] $partidas
  **/
 public function presuPartidas($id)
 {
     $presuPartidas = array();
     foreach (PresupuestoPartidaAcciones::model()->findAllByAttributes(array('accion_id' => $id, 'ente_organo_id' => Usuarios::model()->actual()->ente_organo_id, 'anho' => Yii::app()->params['trimestresFechas'][Yii::app()->session['trimestreSeleccionado']]['anho'])) as $key => $prePar) {
         if (!empty($prePar)) {
             $presuPartidas[$key] = $prePar->presupuestoPartida;
         }
     }
     return $presuPartidas;
 }
 /**
  * Retrieves a list of models based on the current search/filter conditions.
  *
  * Typical usecase:
  * - Initialize the model fields with values from filter form.
  * - Execute this method to get CActiveDataProvider instance which will filter
  * models according to data in model fields.
  * - Pass data provider to CGridView, CListView or any similar widget.
  *
  * @return CActiveDataProvider the data provider that can return the models
  * based on the search/filter conditions.
  */
 public function search()
 {
     // @todo Please modify the following code to remove attributes that should not be searched.
     $criteria = new CDbCriteria();
     $criteria->compare('id', $this->id);
     $criteria->compare('proveedor_id', $this->proveedor_id);
     $criteria->compare('ente_organo_id', Usuarios::model()->actual()->ente_organo_id);
     $criteria->compare('anho', $this->anho);
     return new CActiveDataProvider($this, array('criteria' => $criteria));
 }
示例#21
0
 public static function soloUnVideo()
 {
     $usuario = Usuarios::model()->findByPk(Yii::app()->user->id_usuario);
     // Ya no puede subir mas fotografias
     if (count($usuario->videos) == 1) {
         return false;
     } else {
         return true;
     }
 }
示例#22
0
 /**
  * Ejecutar la accion
  *
  * @param int $id_usuario id del usuario que realiza la accion
  * @throws \Exception usuario no encontrado
  * @return int 0 si completada con exito ; -1 en caso contrario
  */
 public function ejecutar($id_usuario)
 {
     // TODO
     $ret = 0;
     //Validar usuario
     $us = Usuarios::model()->findByPk($id_usuario);
     if ($us === null) {
         throw new Exception("Usuario incorrecto.", 404);
     }
     //Aumentar animo_max
     $ret = min($ret, Recursos::aumentar_recursos($id_usuario, "influencias_max", Efectos::$datos_acciones['EscribirBlog']['influencias_max']));
     return $ret;
 }
示例#23
0
 /**
  * Inline validator that checks if an identity exists matching provided username or password.
  * @param string $attribute
  * @param array $params
  * @return boolean
  */
 public function configurarUsuario($attribute, $params)
 {
     if ($this->hasErrors()) {
         return;
     }
     // Usuario recuperando/reseteando contraseña
     $usuario = Usuarios::model()->findByAttributes(array('usuario' => $this->usuario));
     if (!$usuario) {
         return false;
     }
     $this->cedula = $usuario->cedula;
     $this->correo = $usuario->correo;
     return true;
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new ProveedoresCuentas();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['ProveedoresCuentas'])) {
         $model->attributes = $_POST['ProveedoresCuentas'];
         $usuario = Usuarios::model()->actual();
         $model->ente_organo_id = $usuario->ente_organo_id;
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
示例#25
0
 /**
  * Ejecutar la accion
  *
  * @param int $id_usuario id del usuario que realiza la accion
  * @throws \Exception usuario no encontrado
  * @return int 0 si completada con exito ; -1 en caso contrario
  */
 public function ejecutar($id_usuario)
 {
     //Traer el array de efectos
     parent::ejecutar($id_usuario);
     //Validar usuario
     $us = Usuarios::model()->findByPk($id_usuario);
     if ($us === null) {
         throw new Exception("Usuario incorrecto.", 404);
     }
     if (Recursos::aumentar_recursos($id_usuario, "bonus_influencias", Efectos::$datos_acciones['ContratarRRPP']['bonus_jugador']['influencias']) == 0) {
         return 0;
     } else {
         return -1;
     }
 }
示例#26
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.
  */
 public function loadModel($id = null)
 {
     if ($this->_model === null) {
         if (!isset($id)) {
             if (isset($_GET['id'])) {
                 $id = $_GET['id'];
             }
         }
         $this->_model = Usuarios::model()->findbyPk($id);
         if ($this->_model === null) {
             throw new CHttpException(404, 'El Usuario no existe.');
         }
     }
     return $this->_model;
 }
示例#27
0
 /**
  * Ejecutar la accion
  *
  * @param int $id_usuario id del usuario que realiza la accion
  * @throws \Exception usuario no encontrado
  * @return int 0 si completada con exito ; -1 en caso contrario
  */
 public function ejecutar($id_usuario)
 {
     //Validar usuario
     $us = Usuarios::model()->findByPk($id_usuario);
     if ($us === null) {
         throw new Exception("Usuario incorrecto.", 404);
     }
     //Aumentar dinero
     $helper = new Helper();
     if (Recursos::aumentar_recursos($id_usuario, "dinero_gen", Efectos::$datos_acciones['Ascender']['dinero_gen']) == 0) {
         return 0;
     } else {
         return -1;
     }
 }
示例#28
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 = Usuarios::model()->findByAttributes(array('Usuario' => $this->username));
     if ($record === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if ($record->Password !== $this->password) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             $this->setState('idRol', $record->Roles_idRoles);
             $this->errorCode = self::ERROR_NONE;
         }
     }
     return !$this->errorCode;
 }
示例#29
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $fecha = date("YmdHis");
     if ($fecha < Yii::app()->params->fecha_termino) {
         $puede_subir = Videos::soloUnVideo();
         $usuario = Usuarios::model()->findByPk(Yii::app()->user->id_usuario);
         if ($puede_subir) {
             $adulto = $usuario->edad > 17 ? '1' : '0';
             $this->render('create', array('material' => 'videos', 'usuario' => Yii::app()->user->id_usuario, 'fecha' => date("Y-m-d_His_")));
         } else {
             throw new CHttpException(NULL, "Lo sentimos pero solo se permite subir un video");
         }
     } else {
         throw new CHttpException(NULL, "El tiempo para registrar tus videos ha terminado. Para más información consulta la convocatoria.");
     }
 }
 public function ejecutar($id_usuario)
 {
     //Traer el array de efectos
     parent::ejecutar($id_usuario);
     //Validar usuario
     $us = Usuarios::model()->findByPk($id_usuario);
     if ($us === null) {
         throw new Exception("Usuario incorrecto.", 404);
     }
     //Aumentar ánimo
     if (Recursos::aumentar_recursos($id_usuario, "animo", Efectos::$datos_acciones['CrearseEspectativas']['animo']) == 0) {
         return 0;
     } else {
         return -1;
     }
 }