/**
  * function actionPackage
  * call to render package info page
  */
 public function actionPackage()
 {
     if (Yii::app()->user->isGuest) {
         $this->redirect($this->createUrl("/account/login"));
         return;
     }
     $phone = yii::app()->user->getState('msisdn');
     $packages = WapPackageModel::model()->findAllByAttributes(array('status' => 1));
     $this->render('package', array('packages' => $packages));
 }
Esempio n. 2
0
 public function init()
 {
     // setup multi language
     self::_setupLanguage();
     // DETECT DEVICE
     $this->device = DeviceManager::getInstance();
     if (!isset(yii::app()->session['deviceId'])) {
         Yii::app()->session['deviceId'] = $this->device->getDeviceID();
         Yii::app()->session['device'] = $this->device->getInfo('model_name');
         Yii::app()->session['deviceOS'] = $this->device->getDeviceOs();
     }
     $this->deviceOs = Yii::app()->session['deviceOS'];
     // check user login
     if (Yii::app()->user->isGuest) {
         $identity = new UserIdentity(null, null);
         $type = 'autoLogin';
         if ($identity->userAuthenticate($type, $this->deviceOs)) {
             Yii::app()->user->login($identity);
         }
     }
     // get banners
     $this->banners = WapBannerModel::getBanner('wap');
     // reload package state if request
     if (isset($_REQUEST['reloadPackage']) && $_REQUEST['reloadPackage'] == 1) {
         $package = WapUserSubscribeModel::model()->getUserSubscribe(Yii::app()->user->getState('msisdn'));
         //get user_subscribe record by phone
         if ($package) {
             $packageObj = WapPackageModel::model()->findByPk($package->package_id);
             Yii::app()->user->setState('package', $packageObj->code);
         }
     }
     $this->promotion_realtime = WapUserSubscribeModel::model()->checkPromotion(Yii::app()->user->getState('msisdn'));
     if (!isset(Yii::app()->session['isPromotion']) || Yii::app()->session['isPromotion'] == '') {
         if (Yii::app()->user->getState('msisdn')) {
             //Yii::app()->session['isPromotion'] = WapUserSubscribeModel::model()->checkPromotion(Yii::app()->user->getState('msisdn'));
             Yii::app()->session['isPromotion'] = $this->promotion_realtime;
         } else {
             Yii::app()->session['isPromotion'] = "";
         }
     }
     $this->isPromotion = Yii::app()->session['isPromotion'];
     if (Yii::app()->user->getState('msisdn')) {
         $this->userSub = WapUserSubscribeModel::model()->getUserSubscribe(Yii::app()->user->getState('msisdn'));
     } else {
         $this->userSub = "";
     }
     Yii::app()->user->setState('userSub', $this->userSub);
     if (!Yii::app()->user->isGuest && $this->userSub == '') {
         $this->getPopup();
     }
     $this->getPopupKM();
     $this->getPopupCTKM();
     // load config from DB
     $wap_configs = Yii::app()->cache->get("WAP_CONFIG");
     if ($wap_configs === false) {
         $wap_configs = ConfigModel::model()->getConfig('', 'wap');
         Yii::app()->cache->set("WAP_CONFIG", $wap_configs, Yii::app()->params['cacheTime']);
     }
     if (!empty($wap_configs)) {
         foreach ($wap_configs as $key => $info) {
             $config_type = $info['type'];
             if ($config_type == "string") {
                 Yii::app()->params[$key] = $info['value'];
             }
             if ($config_type == "int") {
                 Yii::app()->params[$key] = intval($info['value']);
             }
             if ($config_type == "array") {
                 Yii::app()->params[$key] = unserialize($info['value']);
             }
         }
     }
     $this->updateCache();
     return parent::init();
 }
Esempio n. 3
0
 public function userAuthenticateWifi($msisdn)
 {
     if ($msisdn) {
         // get user info from phone
         $user = UserModel::model()->findByAttributes(array("phone" => $msisdn));
         if ($user) {
             if (!empty($user->suggested_list)) {
                 $this->setState('_user', array('id' => $user->id, 'suggested_list' => $user->suggested_list));
             } else {
                 $this->setState('_user', array('phone' => $msisdn, 'suggested_list' => ""));
             }
         } else {
             $this->setState('_user', array('phone' => $msisdn, 'suggested_list' => ""));
         }
         $this->_msisdn = $msisdn;
         $this->setState('msisdn', $msisdn);
         $package = WapUserSubscribeModel::model()->getUserSubscribe($this->_msisdn);
         // get user_subscribe record by phone
         if ($package) {
             $packageObj = WapPackageModel::model()->findByPk($package->package_id);
             $this->setState('package', $packageObj->code);
         }
         self::_logDetectMSISDN($msisdn, 'wifi');
         $this->errorCode = self::ERROR_NONE;
     } else {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     }
     return !$this->errorCode;
 }
Esempio n. 4
0
    ?>
            <?php 
    echo Yii::t("wap", "Bạn đang dùng {PACKAGE}", array('{PACKAGE}' => $user_sub->package->name));
    ?>
            <?php 
    $title = Yii::t("wap", "Change the package");
    ?>
            <br>
        <?php 
} else {
    ?>
            <?php 
    $title = Yii::t("wap", "Register");
    ?>
            <?php 
    $packages = WapPackageModel::model()->findAllByAttributes(array('status' => 1));
    ?>
            <ul class="song_list">
                <?php 
    $i = 0;
    foreach ($packages as $pack) {
        $i++;
        ?>
                    <li class="item <?php 
        if ($i == count($packages)) {
            echo 'last_item';
        }
        ?>
" style="padding: 10px 0">
                        <div>
                            <?php