本文整理匯總了PHP中models\User::getAccessLevel方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::getAccessLevel方法的具體用法?PHP User::getAccessLevel怎麽用?PHP User::getAccessLevel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models\User
的用法示例。
在下文中一共展示了User::getAccessLevel方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: function
$app->group('/v1', function () use($app) {
/**
* GET route to export whole database to JSON
*
*/
$app->get('/database/export', function () use($app) {
//create empty user
$oUser = new User();
//request header
$request = $app->request();
$public_key = $request->headers('X-PublicKey');
//get User array from sent public key
$user = $oUser->getUserByPublicKey($public_key);
$userdb = $oUser->setDefaultDatabase($user['LoginID']);
//get access level string of user
$access_level = $oUser->getAccessLevel($user['LoginID']);
//create new instance with the user specific database
$tempTool = new DbExport($userdb);
//read relevant table names with the user specific access level
$export = $tempTool->readRelevantTables($access_level);
$app->contentType('application/json;charset=utf-8');
echo json_encode($export);
});
/**
* GET route to export database meta information to JSON
*
*/
$app->get('/database/scheme', function () use($app) {
$userdb = R::readDbFromRequest();
$by_user = R::readUsernameFromRequest();
$tempTool = new DbExport($userdb);
示例2:
$response['login_id'] = $user['LoginID'];
$response['username'] = $user['username'];
$response['group_id'] = $user['GroupID'];
$response['locale'] = $user['locale'];
$public_key = $oUser->generateKeys($loginId, $username, $password);
// field in DB is NULL by default, so let's check if they have been already created before.
if ($public_key != NULL) {
$response['public_key'] = $public_key;
$code = 200;
} else {
$response['public_key'] = "could not create or read keys";
$code = 500;
Log::write("Could not create or read keys from user", $user['username']);
}
//get access level of user (stored in employee table)
$access_level = $oUser->getAccessLevel($loginId);
$response['access_level'] = $access_level;
if ($access_level == NULL) {
Log::write("*** access_level of user is NULL", $user['username']);
}
} else {
// unknown error occurred
$response['error'] = true;
$response['message'] = "An error occurred. Possible duplicate username?";
$code = 500;
Log::write("Could not get user from database", $user['username']);
}
} else {
// user credentials are wrong
$response['error'] = true;
$response['message'] = 'Login failed. Incorrect credentials';