本文整理匯總了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());
}
}