本文整理汇总了PHP中Access::fillFromUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Access::fillFromUser方法的具体用法?PHP Access::fillFromUser怎么用?PHP Access::fillFromUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Access
的用法示例。
在下文中一共展示了Access::fillFromUser方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: configuration
private function configuration()
{
Assets::$test = TRUE;
// Delete in real
$this->fc = FrontController::getInstance();
$this->controller = strtolower(str_replace('Controller', '', $this->fc->getController()));
$this->action = strtolower(str_replace('Action', '', $this->fc->getAction()));
$this->view = new View();
$this->params = $this->fc->getParams();
if ($this->controller == 'error') {
return;
}
// Users and Access
$this->mu = M_Users::Instance();
$this->user = $this->mu->GetUser();
$accessByIp = IpAccess::isAccess($_SERVER['REMOTE_ADDR']);
if ((!$accessByIp || $this->user->locked) && $this->controller != 'authorization') {
$expire = time() + 3600 * 24 * 100;
setcookie('rUrl', $_SERVER['REQUEST_URI'], $expire, "/");
$this->redirect(array('authorization', 'login'));
exit;
}
$access = new Access();
$access->fillFromUser($this->user);
$access->setAccessParams($this->controller, $this->action);
$sectionAccess = $access->sectionAccess();
$actionAccess = $access->actionAccess();
if (!$sectionAccess || !$actionAccess) {
if ($this->user->isGuest) {
$expire = time() + 3600 * 24 * 100;
setcookie('rUrl', $_SERVER['REQUEST_URI'], $expire, "/");
$this->redirect(array('authorization', 'login'));
}
$pageArr = $access->UserAccessPage;
$redirectArray = $pageArr ? $pageArr : array('error', '');
$this->redirect($redirectArray);
}
$this->access = $access;
$sInfo = $access->actionAccess(array('service', 'info')) ? true : false;
$this->fc->setSInfo($sInfo);
unset($access);
$this->pageTitle = __('pageTitle');
$array = array('access' => $this->access, 'controller' => $this->controller, 'action' => $this->action, 'user' => $this->user);
$this->setMainVars($array);
if (!empty($_POST)) {
$_POST = AF::clearDataArray($_POST);
}
// Set user
AF::setUser($this->user);
AF::setUserAccess($this->access);
//$sectionID = ( isset($this->params['id']) && is_numeric($this->params['id']) ) ? $this->params['id'] : '';
//Log::createLog($this->user->user_id, $this->action."Action", $this->controller, $sectionID);
}
示例2: privilegeAction
function privilegeAction()
{
$model = new User();
$model->allFIelds = true;
$id = AF::get($this->params, 'id', 0);
if (!$id) {
throw new AFHttpException(0, 'no_id');
}
if (!$model->setByID($id)) {
throw new AFHttpException(0, 'incorrect_id');
}
$access = new Access();
$access->fillFromUser($model);
$userAccess = $access->getUserUpdateAccess();
ksort($userAccess);
if (isset($_POST['ajax'])) {
$newAcces = AF::get($_POST, 'array');
if ($newAcces) {
$access->setUserAccess($newAcces);
// hack to get the uesrs_access table to update instead of insert
$msql = SafeMySQL::getInstance();
$sql = "SELECT * FROM ?n WHERE user_id = ?i";
$result = $msql->getRow($sql, $access->tableName(), $access->user_id);
if (!empty($result)) {
$access->setIsNewRecord(0);
}
if ($access->save()) {
$model->user_id_updated = $this->user->user_id;
$model->updated = 'NOW():sql';
$model->IsNewRecord = false;
$model->save();
Message::echoJsonSuccess(__('user_access_updated'));
} else {
Message::echoJsonError(__('user_access_not_updated'));
}
} else {
Message::echoJsonError(__('user_access_not_updated'));
}
}
Assets::js('jquery.form');
$this->addToPageTitle('User privilege');
$this->render('privilege', array('userAccess' => $userAccess, 'model' => $model));
}