本文整理汇总了PHP中UserGroup::getByName方法的典型用法代码示例。如果您正苦于以下问题:PHP UserGroup::getByName方法的具体用法?PHP UserGroup::getByName怎么用?PHP UserGroup::getByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserGroup
的用法示例。
在下文中一共展示了UserGroup::getByName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
if (!$superadmin_reg && !$session->allow_registrations) {
return;
}
// Handle new user registrations
if (isset($_POST['register_usr']) && isset($_POST['register_pwd']) && isset($_POST['register_pwd2'])) {
$reg = UserHandler::getInstance();
$user_id = $reg->register($_POST['register_usr'], $_POST['register_pwd'], $_POST['register_pwd2']);
if ($user_id) {
if ($superadmin_reg) {
if (!UserGroup::getAll()) {
// If no UserGroup:s exist, create them
UserGroup::create('Webmasters', 1);
UserGroup::create('Admins', 2);
$sadmin_id = UserGroup::create('Super Admins', 3);
} else {
$grp = UserGroup::getByName('Super Admins');
$sadmin_id = $grp['groupId'];
}
if (!$sadmin_id) {
throw new \Exception('super admin group not found');
}
// Add this user to Super Admin group
UserGroupHandler::addToGroup($user_id, $sadmin_id);
}
if ($session->login($_POST['register_usr'], $_POST['register_pwd'])) {
$session->showStartPage();
}
}
// after form submit failed, put focus back to the register form <div> to show error
$header->embedJsOnload('show_reg_form();');
}
示例2: arcGetMenu
public static function arcGetMenu()
{
$menu = [];
$pages = \Page::getAllPages();
$groups[] = \UserGroup::getByName("Guests");
if (self::arcIsUserLoggedIn() == true) {
$groups = array_merge($groups, self::arcGetUser()->getGroups());
}
foreach ($pages as $page) {
if ($page->hidefrommenu == true || $page->hideonlogin == true && self::arcIsUserLoggedIn() == true) {
continue;
}
if (\UserPermission::hasPermission($groups, $page->seourl)) {
$data = explode("/", $page->seourl);
$menu[ucwords($data[0])][$page->title]["name"] = $page->title;
$menu[ucwords($data[0])][$page->title]["url"] = $page->seourl;
$menu[ucwords($data[0])][$page->title]["icon"] = $page->iconclass;
}
}
return $menu;
}
示例3: getGroups
/**
*
* @return \UserGroup Gets the group of the user
*/
public function getGroups()
{
$groups = [];
foreach (json_decode($this->groups) as $group) {
$grp = UserGroup::getByName($group);
if ($grp->id != 0) {
$groups[] = $grp;
}
}
return $groups;
}