示例#1
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;
 }
 /**
  * 
  * @return String generated time
  */
 public function actionBackgroundProcess()
 {
     $gentime = microtime();
     $gentime = explode(' ', $gentime);
     $gentime = $gentime[1] + $gentime[0];
     $pg_start = $gentime;
     // verify if are emails pending to send
     $emails = Emails::model()->findAll(array('condition' => 't.email_status = 0', 'limit' => Yii::app()->params['mailSendMultiples']));
     if (count($emails) > 0) {
         foreach ($emails as $email) {
             Yii::import('application.extensions.phpMailer.yiiPhpMailer');
             $mailer = new yiiPhpMailer();
             if ($mailer->Ready($email->email_subject, $email->email_body, array('email' => $email->email_toMail, 'name' => $email->email_toName), $email->email_priority)) {
                 $email->email_status = 1;
                 $email->email_sentDate = date("Y-m-d G:i:s");
                 $email->save(false);
             }
         }
     }
     $gentime = microtime();
     $gentime = explode(' ', $gentime);
     $gentime = $gentime[1] + $gentime[0];
     $pg_end = $gentime;
     $totaltime = $pg_end - $pg_start;
     $showtime = number_format($totaltime, 4, '.', '');
     echo "Generacion en " . $showtime . " segundos";
 }
示例#3
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 loadUpdateEmail()
 {
     if ($this->_model === null) {
         if (isset($_POST['ContactForm']['email'])) {
             $condition = "email='" . $_POST['ContactForm']['email'] . "'";
             $this->_model = Emails::model()->find($condition);
         }
         if ($this->_model === null) {
             $this->_model = new Emails();
         }
     }
     return $this->_model;
 }
 public function actionPendingMails()
 {
     // verify if are emails pending to send
     $emails = Emails::model()->findAll(array('condition' => 't.email_status = 0', 'limit' => Yii::app()->params['mailSendMultiples']));
     if (count($emails) > 0) {
         foreach ($emails as $email) {
             Yii::import('application.extensions.phpMailer.yiiPhpMailer');
             $mailer = new yiiPhpMailer();
             if ($mailer->Ready($email->email_subject, $email->email_body, array('email' => $email->email_toMail, 'name' => $email->email_toName), $email->email_priority)) {
                 $email->email_status = 1;
                 $email->email_sentDate = date("Y-m-d G:i:s");
                 $email->save(false);
             }
         }
     }
 }
示例#5
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 Emails the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Emails::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 public function send_deffered_emails()
 {
     $emails = Emails::model()->sending_round(self::EMAILS_COUNT)->findAll();
     foreach ($emails as $email) {
         if ($email->send()) {
             $email->delete();
         }
     }
 }
 /**
  * Send pending emails
  * Execute all minutes
  * identificator 5 
  */
 public function actionSendPendingEmails()
 {
     $controlCronJobId = 5;
     //Check control job
     $control = ControlCronjobs::model()->findByPk($controlCronJobId);
     //Check if status is 0 for to execute
     if ($control->status == 0) {
         $control->status = 1;
         if ($control->save()) {
             //Search all pending emails
             $emails = Emails::model()->findAll('status = :status', array(':status' => Emails::STATUS_PENDING));
             if (count($emails)) {
                 foreach ($emails as $email) {
                     if (Yii::app()->email->send('*****@*****.**', $email->destination, $email->title, $email->body, array($email->headers))) {
                         $email->status = Emails::STATUS_SENDED;
                         Yii::trace('[CRONJOBS][actionSendPendingEmails] email enviado.');
                     } else {
                         $email->status = Emails::STATUS_ERROR;
                         Yii::trace('[CRONJOBS][actionSendPendingEmails] No se puede enviar el email.', 'error');
                     }
                     $email->date = date('Y-m-d H:i:s');
                     if (!$email->save()) {
                         Yii::trace('[CRONJOBS][actionSendPendingEmails] No se puede actualizar el email a enviado', 'error');
                     }
                 }
             }
             //Free job
             $control->status = 0;
             if (!$control->save()) {
                 Yii::trace('[CRONJOBS][actionSendPendingEmails] No se ha podido salvar el control de proceso una vez finalizado.', 'warning');
             }
         } else {
             Yii::trace('[CRONJOBS][actionSendPendingEmails] No se ha podido salvar el control de proceso.', 'warning');
         }
     } else {
         Yii::trace('[CRONJOBS][actionSendPendingEmails] Hay otra ejecución en proceso.', 'warning');
     }
 }
 public function actionSendEmails()
 {
     $emails = Emails::model()->findAll();
     foreach($emails as $email) {
         $this->sendMail($email->email);
     }
 }