本文整理汇总了PHP中Sentry::findAllUsersInGroup方法的典型用法代码示例。如果您正苦于以下问题:PHP Sentry::findAllUsersInGroup方法的具体用法?PHP Sentry::findAllUsersInGroup怎么用?PHP Sentry::findAllUsersInGroup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sentry
的用法示例。
在下文中一共展示了Sentry::findAllUsersInGroup方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
$data = $this->project->find($id);
$group = Sentry::findGroupByName('Project Manager');
$users = Sentry::findAllUsersInGroup($group);
return View::make('projects.edit')->with('projects', $data)->with('users', $users);
}
示例2: deleteRole
public function deleteRole($id)
{
PermApi::access_check('manage_permissions');
try {
DB::beginTransaction();
// start the DB transaction
$group = Sentry::findGroupById($id);
$authenticatedGroup = Sentry::findGroupById(3);
// super admin group cannot be deleted
if ($id == 1 || $id == 3) {
SentryHelper::setMessage('This role cannot be deleted.', 'warning');
return Redirect::to('user/permission/list');
}
// assign authenticated user group
$users = Sentry::findAllUsersInGroup($group);
foreach ($users as $user) {
$user->addGroup($authenticatedGroup);
}
// delete group
$group->delete();
// clear permission in group mapping
DB::table('permission_in_group')->where('group_id', $id)->delete();
DB::table('users_groups')->where('user_id', $id)->update(array('group_id' => $authenticatedGroup->id));
DB::commit();
// commit the DB transaction
SentryHelper::setMessage('Role deleted, all users of this role are now Authenticated users.');
return Redirect::to('user/permission/list');
} catch (\Exception $e) {
DB::rollback();
// something went wrong
}
}
示例3: checkForOtherAdmins
public function checkForOtherAdmins($data)
{
try {
$userId = $data['userid'];
$group = \Sentry::findGroupByName('admin');
$users = \Sentry::findAllUsersInGroup($group)->toArray();
if (sizeof($users) == 0) {
throw new \Exception('this cant be right');
}
if (sizeof($users) == 1) {
if ($users[0]['id'] == $userId) {
return false;
}
}
return true;
} catch (\Exception $e) {
\Log::error('Something Went Wrong in User Repository - checkForOtherAdmins():' . $e->getMessage());
}
}