public function actionError() { $this->device = DeviceManager::getInstance(); $this->layout = 'application.views.touch.layouts.error'; if ($error = Yii::app()->errorHandler->error) { if (Yii::app()->request->isAjaxRequest) { echo $error['message']; } else { $this->render('error', compact('error')); } } }
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(); }