Ejemplo n.º 1
0
 public function init()
 {
     // this method is called when the module is being created
     // you may place code here to customize the module or the application
     $cs = Yii::app()->getClientScript();
     $this->_assetsUrl = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('application.modules.event.assets'), false, 1, YII_DEBUG);
     $cs->registerCssFile($this->_assetsUrl . "/css/event.css");
     // import the module-level models and components
     $this->setImport(array('event.models.*'));
     $userPhone = yii::app()->user->getState('msisdn');
     if ($userPhone && (!isset($_SESSION['visit']) || !$_SESSION['visit'])) {
         $_SESSION['visit'] = 1;
         $gameEventActivity = new GameEventActivityModel();
         $gameEventActivity->user_phone = $userPhone;
         $gameEventActivity->activity = 'visit';
         $gameEventActivity->updated_time = date('Y-m-d H:i:s');
         $gameEventActivity->note = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
         $gameEventActivity->save();
     }
 }
Ejemplo n.º 2
0
 public function actionShare()
 {
     $userPhone = yii::app()->user->getState('msisdn');
     $isShare = GameEventActivityModel::isShareOnDay($userPhone, date('Y-m-d'));
     if ($isShare) {
         $this->redirect('/event/play/thank');
         Yii::app()->end();
     }
     $error = 0;
     $isSend = false;
     if (Yii::app()->request->isPostRequest) {
         $isSend = 0;
         $phoneList = $_POST['phone_list'];
         if ($phoneList != '') {
             $phoneArr = explode(',', $phoneList);
             if ($phoneArr) {
                 foreach ($phoneArr as $key => $value) {
                     $phone = Formatter::formatPhone($value);
                     if (Formatter::isVinaphoneNumber($phone)) {
                         $isSend++;
                         $sms = new SmsClient();
                         $content = 'DV Chacha - Vinaphone kinh chao Quy Khach. Quy Khach vua duoc thue bao ' . $userPhone . ' moi dua tai trong chuong trinh "Vui cung Chacha - Nhan qua nhu y" voi giai thuong hap dan len toi 20 trieu dong. Chi tiet moi Quy Khach xem tai day http://m.chacha.vn/event';
                         $sms->sentMT("9234", $phone, 0, $content, 0, "", time(), 9234);
                     }
                 }
                 if ($isSend > 0) {
                     //chia se it nhat duoc 1 so vinaphone
                     $gameActivity = new GameEventActivityModel();
                     $gameActivity->setAttribute('user_phone', $userPhone);
                     $gameActivity->setAttribute('activity', 'share');
                     $gameActivity->setAttribute('point', 1);
                     $gameActivity->setAttribute('updated_time', date('Y-m-d H:i:s'));
                     $gameActivity->setAttribute('note', $phoneList, PDO::PARAM_STR);
                     $gameActivity->save();
                     $this->redirect('/event/play/thank');
                 }
             }
         } else {
             //ko có sô dt nao
             $error = 1;
         }
     }
     $this->render('share', array('isShare' => $isShare, 'error' => $error, 'isSend' => $isSend));
 }
 /**
  * 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 the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = GameEventActivityModel::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }