/**
  * 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'
     $idioma = Idiomas::model()->find('idioma=:idioma', array(':idioma' => Yii::app()->language));
     if ($idioma->idioma == Yii::app()->params->idiomas['Español']) {
         //español
         $criteria = new CDbCriteria();
         $criteria->select = 't.*';
         $criteria->order = 'fecha DESC';
         $criteria2 = new CDbCriteria();
         $criteria2->select = 't.*';
         $criteria2->condition = 't.lugar = :lugar';
         $criteria2->params = array(':lugar' => 'index_derecha');
     } else {
         //ingles
         $criteria = new CDbCriteria();
         $criteria->select = 't.*, tra_noticia.*';
         $criteria->join = 'LEFT JOIN tra_noticia ON tra_noticia.noticiaid = t.idnoticia';
         $criteria->order = 'fecha DESC';
         $criteria->condition = 'tra_noticia.idiomaid =:id';
         $criteria->params = array(':id' => $idioma->id);
         $criteria2 = new CDbCriteria();
         $criteria2->select = 't.*, tra_texto.*';
         $criteria2->join = 'LEFT JOIN tra_texto ON tra_texto.textoid = t.idtexto';
         $criteria2->condition = 'tra_texto.idiomaid =:id and t.lugar = :lugar';
         $criteria2->params = array(':id' => $idioma->id, ':lugar' => 'index_derecha');
     }
     $criteria3 = new CDbCriteria();
     $criteria3->select = 't.*';
     $criteria3->order = 'apellido ASC';
     $artistas = Artista::model()->findAll($criteria3);
     $noticias = Noticia::model()->findAll($criteria);
     $texto = Texto::model()->find($criteria2);
     $model = new Subscripcion();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Subscripcion'])) {
         $model->attributes = $_POST['Subscripcion'];
         if ($model->save()) {
             Yii::app()->user->setFlash('success', "Suscripción completada");
             $this->redirect(array('index'));
         } else {
             Yii::app()->user->setFlash('success', "Correo no válido");
             $this->redirect(array('index'));
         }
     }
     $this->render('index', array('model' => $model, 'noticias' => $noticias, 'idioma' => $idioma, 'texto' => $texto, 'artistas' => $artistas));
 }
 /**
  * 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 Subscripcion the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Subscripcion::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }