public function actionIndex()
 {
     if (Yii::app()->user->isGuest or Yii::app()->user->access_level < Config::get('access_level_admin')) {
         $this->redirect(Yii::app()->homeUrl);
     }
     $this->pageTitle = Yii::t('title', 'Send mail');
     $model = new Mail();
     if (isset($_POST['Mail'])) {
         $model->attributes = $_POST['Mail'];
         $player_id = Players::model()->find('name = "' . $model->player_name . '"');
         if ($player_id->online == 1) {
             Yii::app()->user->setFlash('message', '<div class="flash_error">' . Yii::t('webshop', 'Error - You must first log out of the game server.') . '</div>');
         }
         $criteria = new CDbCriteria();
         $criteria->select = 'MAX(mail_unique_id) as mail_unique_id';
         $last_mail_id = Mail::model()->find($criteria);
         $model->mail_unique_id = $last_mail_id->mail_unique_id + 1;
         $model->mail_recipient_id = $player_id->id;
         $model->sender_name = 'ServerWebsite';
         $model->mail_title = $model->mail_title;
         $model->mail_message = $model->mail_message . "\n\nThis has been sent via our server website.  Please, do not reply.";
         $model->unread = 1;
         // Fallenfate - Add function to send kinah to players.
         if ($model->item_count != NULL || $model->item_count != "") {
             $model->attached_item_id = 0;
             $model->attached_kinah_count = $model->item_count;
         }
         $model->express = 1;
         if ($model->save(false)) {
             Yii::app()->user->setFlash('message', '<div class="flash_success">' . Yii::t('main', 'Mail sent!') . '</div>');
             $this->refresh();
         }
     }
     $this->render('/admin/mail', array('model' => $model));
 }
Beispiel #2
0
 static function createMail($data)
 {
     require_once "common.php";
     $data = Filter::filterArray($data);
     $mail = new Mail($data);
     return $mail->save();
 }
Beispiel #3
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $_SESSION['KCFINDER']['disabled'] = false;
     // enables the file browser in the admin
     $_SESSION['KCFINDER']['uploadURL'] = Yii::app()->params->siteURL . "uploads/";
     // URL for the uploads folder
     $_SESSION['KCFINDER']['uploadDir'] = Yii::app()->basePath . "/../uploads/";
     // path to the uploads folder
     $model = new Mail();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Mail'])) {
         $model->attributes = $_POST['Mail'];
         $model->UserID = Yii::app()->user->ID;
         $model->Date = date("Y-m-d");
         if ($model->save()) {
             // Si pulsas Guardar y enviar lo envia
             if ($_POST["Enviar"] == 1) {
                 $this->actionSend($model->ID);
                 echo "<script>alert('El boletin se ha enviado correctamente.')</script>";
                 echo "<script>window.location.href = '" . $this->createURL('admin') . "'</script>";
             }
         }
         $this->redirect(array('admin'));
     }
     $this->render('create', array('model' => $model));
 }
 public function newAction()
 {
     $form = new NewMailForm();
     if ($this->request->isPost()) {
         if ($form->isValid($this->request->getPost()) != false) {
             $mail = new Mail();
             $mail->assign(array('fk_user' => $this->session->get('authenticated')['id'], 'state' => 'output', 'subject' => $this->request->getPost('subject'), 'content' => $this->request->getPost('content'), 'date' => date('Y-m-d H:i:s'), 'active' => 1));
             if ($mail->save()) {
                 $num = $mail->id_mail;
                 $str = $this->request->getPost('adress');
                 $adresses = explode(",", $str);
                 for ($i = 0; $i < count($adresses); $i++) {
                     $adresse = new Adressee();
                     if (filter_var($adresses[$i], FILTER_VALIDATE_EMAIL)) {
                         $adresse->assign(array('adresse' => $adresses[$i], 'id_mail' => $num, 'active' => 1));
                         if ($adresse->save()) {
                         }
                     } else {
                         echo "<script>alert('La dirección de correo:  ({$adresses[$i]}) es incorrecta por lo cual no se agregara a los destinatarios del email que desea enviar, solo los correctos.')</script>";
                     }
                 }
                 return $this->response->redirect('dashboard');
             } else {
                 echo "<h5>Upps! Data couldn't be saved :(... Try again...</h5>";
             }
             $this->flash->error($mail->getMessages());
         }
     }
     $this->view->form = $form;
 }
Beispiel #5
0
 /**
  * Test
  *
  * @test
  *
  * @return void
  */
 public function storeNew()
 {
     $mail = new Mail();
     $mail->setUserId(5);
     $mail->setMailId(5);
     $mail->setMail('Benny');
     $mail->save();
     $mail = $mail->get()->whereEquals('userId', 5)->whereEquals('mailId', 5)->current();
     $this->assertEquals(5, $mail->getUserId());
 }
 public function actionCategory($name)
 {
     if (Yii::app()->user->isGuest) {
         $this->redirect(Yii::app()->homeUrl);
     }
     $id = WebshopCategory::model()->find('alt_name = "' . $name . '"');
     $this->pageTitle = Yii::t('title', 'Webshop') . ': ' . $id->name;
     $criteria = new CDbCriteria();
     $criteria->select = '*';
     $criteria->condition = 'category_id = ' . $id->category_id;
     $pages = new CPagination(Webshop::model()->count($criteria));
     $pages->pageSize = Config::get('page_shop');
     $pages->applyLimit($criteria);
     $model = Webshop::model()->findAll($criteria);
     $form = new Inventory();
     $form->scenario = 'buy';
     if (isset($_POST['Inventory'])) {
         $form->attributes = $_POST['Inventory'];
         if ($form->validate()) {
             $criteria = new CDbCriteria();
             $criteria->select = '*';
             $criteria->condition = 'item_id = ' . $form->item_id;
             $item = Webshop::model()->find($criteria);
             $real_price = ceil($form->new_amount * ($item->price / $item->amount));
             $account = AccountData::model()->findByPk(Yii::app()->user->id);
             if ($account[Yii::app()->params->money] < $real_price) {
                 Yii::app()->user->setFlash('message', '<div class="flash_error">' . Yii::t('webshop', 'Insufficient funds.') . '</div>');
                 $this->refresh();
             }
             $criteria = new CDbCriteria();
             $criteria->condition = 'id = ' . $form->item_owner . ' AND online = 1';
             $online = Players::model()->count($criteria);
             if ($online == 1) {
                 Yii::app()->user->setFlash('message', '<div class="flash_error">' . Yii::t('webshop', 'Log-out') . '</div>');
                 $this->refresh();
             }
             $criteria = new CDbCriteria();
             $criteria->select = 'MAX(mail_unique_id) as mail_unique_id';
             $last_mail_id = Mail::model()->find($criteria);
             $mail = new Mail();
             $mail->mail_unique_id = $last_mail_id->mail_unique_id + 1;
             $mail->mail_recipient_id = $form->item_owner;
             $mail->sender_name = 'Admin';
             $mail->mail_title = Yii::t('webshop', 'Delivery');
             $mail->mail_message = Yii::t('webshop', 'Your purchase has been successful.  Thank you, and we hope you enjoy the game!');
             $mail->unread = 1;
             if ($form->item_id == 182400001) {
                 $mail->attached_item_id = 0;
                 $mail->attached_kinah_count = $form->new_amount;
             } else {
                 $mail->attached_item_id = $this->add_item($form->item_id, $form->item_owner, $form->new_amount);
                 $mail->attached_kinah_count = 0;
             }
             $mail->express = 1;
             $mail->save(false);
             $account[Yii::app()->params->money] = $account[Yii::app()->params->money] - $real_price;
             $account->save(false);
             $log = new LogWebshop();
             $log->player_id = $form->item_owner;
             $log->item = $form->item_id;
             $log->amount = $form->new_amount;
             $log->price = $real_price;
             $log->save(false);
             Yii::app()->user->setFlash('message', '<div class="flash_success">' . Yii::t('webshop', 'Purchase successful!') . '</div>');
             $this->refresh();
         }
     }
     $this->render('category', array('model' => $model, 'id' => $id, 'form' => $form, 'players' => Players::getPlayers(), 'pages' => $pages));
 }
 public function savePaymentInformation(sfWebRequest $request)
 {
     $payment_information = $request->getParameter('payment_information');
     $first_name = $payment_information['first_name'];
     $last_name = $payment_information['last_name'];
     $number = $payment_information['number'];
     $cvv_code = $payment_information['cvv_code'];
     $address = $payment_information['address'];
     $mail = $payment_information['email'];
     $document = $payment_information['document'];
     $comments = $payment_information['comment'];
     $mes = $request->getParameter('mes');
     $anio = $request->getParameter('anio');
     $user_name = $this->getUser()->isAuthenticated() ? $this->getUser()->getUserName() : "";
     $mail_object = new Mail();
     $mail_object->setMail($mail);
     $mail_object->setIdState(2);
     $mail_object->setMailTypeId(1);
     $mail_object->save();
     $client = new Client();
     $client->setFirstName($first_name);
     $client->setLastName($last_name);
     $client->setIdState(2);
     $client->save();
     $client_mail = new ClientMail();
     $client_mail->setIdState(2);
     $client_mail->setClientId($client->getId());
     $client_mail->setMailId($mail_object->getId());
     $client_mail->save();
     $identity_document = new IdentityDocument();
     $identity_document->setIdState(2);
     $identity_document->setIdentityDocumentTypeId(1);
     $identity_document->setNumber($document);
     $identity_document->save();
     $time = mktime(0, 0, 0, $mes, 1, $anio);
     $date = date('Y-m-d H:i:s', $time);
     $payment_inf = new PaymentInformation();
     $payment_inf->setNumber($number);
     $payment_inf->setCvvCode($cvv_code);
     $payment_inf->setClientId($client->getId());
     $payment_inf->setComment($comments);
     $payment_inf->setAddress($address);
     $payment_inf->setUserName($user_name);
     $payment_inf->setIdentityDocumentId($identity_document->getId());
     // $payment_inf->setDate($date);
     $payment_inf->save();
 }
Beispiel #8
0
 public function add($to, $subject, $message, $replyTo = '', $cc = '', $bcc = '')
 {
     foreach (array('to', 'replyTo', 'cc', 'bcc') as $var) {
         if (is_array(${$var})) {
             ${$var} = implode(self::SEPARATOR, ${$var});
         }
     }
     $mail = new Mail();
     $mail->to = $to;
     $mail->reply_to = $replyTo;
     $mail->cc = $cc;
     $mail->bcc = $bcc;
     $mail->subject = $subject;
     $mail->message = $message;
     $mail->add_time = $mail->update_time = time();
     return $mail->save();
 }