/** * Checks if the user has the authority role * @param String $action The current action * @return Boolean true if user has the authority role */ protected function beforeAction($action) { if (!$this->module->isInstalled() && $action->id != "install") { $this->redirect(array("install")); return false; } if ($this->module->debug) { return true; } if (Yii::app()->user->checkAccess(Helper::findModule('srbac')->superUser)) { return true; } else { parent::beforeAction($action); } }
protected function beforeAction($action) { $params = Yii::app()->params['controllerlog']; $act = $this->getAction()->getId(); $ctr = $this->getId(); $ctract = $ctr . $act; $method = isset($params[$ctract]) ? $params[$ctract] : ""; $flag = false; if (Yii::app()->request->isPostRequest) { //Log tat ca cac action la post $flag = true; } else { if (array_key_exists($ctract, $params) && ($method == 'get' || $method == 'all')) { // Log cac action la GET va nam trong config 'controllerlog' $flag = true; } else { if ($ctr == 'customer' && Yii::app()->session['phone'] != '' && $act != "logAction" && $act != "viewLogAction") { // Log cac action la GET va nam trong config 'controllerlog' if ($act == "logAction") { $act = "Xem log tác động khách hàng"; } else { if ($act == "index") { $act = "Tra cứu thuê bao"; } else { if ($act == "register") { $act = "Đăng ký gói cước"; } else { if ($act == "subscriber") { $act = "Xem lịch sử đăng ký, huỷ dịch vụ của thuê bao"; } else { if ($act == "history") { $act = "Xem lịch sử trừ cước của thuê bao"; } else { if ($act == "sms") { $act = "Xem tin nhắn MO/MT của thuê bao"; } } } } } } $flag = true; } } } if ($flag) { $model = new AdminLogActionModel(); $model->adminId = $this->userId; $model->adminName = $this->username; $model->controller = $ctr; $model->action = $act; $model->created_time = new CDbExpression("NOW()"); $model->ip = Yii::app()->request->getUserHostAddress(); $model->roles = $this->adminGroup; $model->msisdn = Yii::app()->session['phone']; $model->params = json_encode($_REQUEST); $model->save(); } //log action delete if (strpos(strtolower($act), 'delete') !== false) { $uri = $_SERVER['REQUEST_URI']; $ip = $_SERVER['REMOTE_ADDR']; $log = new KLogger('LogActionDeleteCMS', KLogger::INFO); $log->LogInfo("Log Delete | UserId: " . Yii::app()->user->id . "|IP:{$ip}" . "| URI:" . $uri, false); } return parent::beforeAction($action); }