function init() { global $db, $user, $mainframe, $hideMenu; setSysConfig("sidebar.display", 1); $task = Request::getVar("task", ""); if ($task != "") { $cmd = "action{$task}()"; if (method_exists($this, $cmd)) { $this->{$cmd}(); } } $db = $this->db = Yii::app()->db; Yii::app()->name = "Back end"; $user = $this->user = Yii::app()->session['userbackend']; if (is_object($user)) { $user->reloaUserLogin(); } $mainframe = MainFrame::getInstance($this->db, $user); parent::init(); $copyright = isset(Yii::app()->params->copyright) ? Yii::app()->params->copyright : 0; $timeout = isset(Yii::app()->params->timeout) ? Yii::app()->params->timeout : 900; // 15 phut $timeout2 = isset(Yii::app()->params->timeout2) ? Yii::app()->params->timeout2 : 1800; // 30 phut $YiiApp = Yii::app(); if (!$mainframe->isLogin()) { $duration = time() + $timeout; // 365 days } else { $permission = isset(Yii::app()->params->permission) ? Yii::app()->params->permission : 1; if ($permission == 1) { CheckPerMission::checking(); } $remember_admin = (isset($_COOKIE['remember_admin']) and $_COOKIE['remember_admin'] == 1) ? 1 : 0; if ($remember_admin == 1) { $duration = time() + $timeout2; } else { $duration = time() + $timeout; } // 15 minutes } $cookie = new CHttpCookie(session_name(), session_id(), array("expire" => $duration)); $YiiApp->getRequest()->getCookies()->add($cookie->name, $cookie); }
static function getResources($backEnd = false, $arr_url) { $app = Request::getVar('app'); if ($backEnd) { $query_resource = ' (`affected` IN("B", "BF"))'; } else { $query_resource = ' (`affected` IN("F", "BF"))'; } $query = "SELECT * FROM " . TBL_RSM_RESOURCES . " WHERE `status` = 1 AND type = 1 AND app = '{$app}' AND {$query_resource}"; $rows = Yii::app()->db->createCommand($query)->queryAll(); if (count($rows)) { $arr_resources = array(); $arr_resources_id = array(); foreach ($rows as $row) { $row = (object) $row; $str_in = 'app=' . $app; // if ($row->view != '') { // $str_in .= '&view=' . $row->view; // } if ($row->params != "") { $str_in .= '&' . $row->params; } $arr_url2 = $arr_url; if (CheckPerMission::Validate_Url($str_in, $arr_url2)) { $arr_resources[$row->id] = $row; $arr_resources_id[] = $row->id; } } //find the heighest level of resource by removing their parent resources $arr_resources_be_removed = array(); foreach ($arr_resources as $key => $value) { if (in_array($value->parentID, $arr_resources_id)) { $arr_resources_be_removed[] = $value->parentID; } } //removing $new_arr_resources = array(); foreach ($arr_resources as $key => $value) { if (!in_array($key, $arr_resources_be_removed)) { $new_arr_resources[$key] = $value; } } return $new_arr_resources; } }