本文整理汇总了PHP中RoleModel::getByUserID方法的典型用法代码示例。如果您正苦于以下问题:PHP RoleModel::getByUserID方法的具体用法?PHP RoleModel::getByUserID怎么用?PHP RoleModel::getByUserID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RoleModel
的用法示例。
在下文中一共展示了RoleModel::getByUserID方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testOne
/**
* Test an individual condition.
*
* @param string $Type One of the types in this condition.
* @param string $Field The field to test against.
* @param string $Expr The expression to test with.
* @return bool
*/
public static function testOne($Type, $Field, $Expr = null)
{
switch (strtolower($Type)) {
case PERMISSION:
// Check to see if the user has the given permission.
$Result = Gdn::session()->checkPermission($Field);
if ($Expr === false) {
return !$Result;
}
return $Result;
case REQUEST:
// See if the field is a specific value.
switch (strtolower($Field)) {
case 'path':
$Value = Gdn::request()->path();
break;
default:
// See if the field is targetting a specific part of the request.
$Fields = explode('.', $Field, 2);
if (count($Fields) >= 2) {
$Value = Gdn::request()->getValueFrom($Fields[0], $Fields[1], null);
} else {
$Value = Gdn::request()->getValue($Field, null);
}
break;
}
$Result = Gdn_Condition::testValue($Value, $Expr);
return $Result;
case ROLE:
// See if the user is in the given role.
$RoleModel = new RoleModel();
$Roles = $RoleModel->getByUserID(Gdn::session()->UserID)->resultArray();
foreach ($Roles as $Role) {
if (is_numeric($Expr)) {
$Result = $Expr == val('RoleID', $Role);
} else {
$Result = Gdn_Condition::testValue(val('Name', $Role), $Expr);
}
if ($Result) {
return true;
}
}
return false;
}
return false;
}
示例2: htmlspecialchars
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body id="<?php
echo htmlspecialchars($BodyIdentifier);
?>
" class="<?php
echo $this->CssClass;
?>
">
<?php
$this->renderAsset('Symbols');
// TODO: Pull this asset out elsewhere
Gdn_Theme::assetBegin('DashboardUserDropDown');
$user = Gdn::session()->User;
$rm = new RoleModel();
$roles = $rm->getByUserID(val('UserID', $user))->resultArray();
$roleTitlesArray = [];
foreach ($roles as $role) {
$roleTitlesArray[] = val('Name', $role);
}
$roleTitles = implode(', ', $roleTitlesArray);
/** var UserController $user */
?>
<div class="card card-user">
<?php
$userBlock = new MediaItemModule(val('Name', $user), userUrl($user), $roleTitles, '', ['class' => 'card-block']);
$userBlock->setView('media-sm')->setImage(userPhotoUrl($user))->addButton(t('My Profile') . ' ' . dashboardSymbol('external-link', 'icon-11 icon-text'), userUrl($user), ['class' => 'btn btn-sm-rounded btn-secondary padded-top']);
echo $userBlock;
?>
<div class="list-group list-group-flush">
<?php