本文整理汇总了PHP中Hubzero\User\Group::remove方法的典型用法代码示例。如果您正苦于以下问题:PHP Group::remove方法的具体用法?PHP Group::remove怎么用?PHP Group::remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hubzero\User\Group
的用法示例。
在下文中一共展示了Group::remove方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: removeTask
/**
* Remove member(s) from a group
* Disallows removal of last manager (group must have at least one)
*
* @return void
*/
public function removeTask()
{
// Check for request forgeries
Request::checkToken(['get', 'post']);
$gid = Request::getVar('gid', '');
// Load the group page
$group = new Group();
$group->read($gid);
// Get all the group's managers
$managers = $group->get('managers');
// Get all the group's members
$members = $group->get('members');
$users_mem = array();
$users_man = array();
// Incoming array of users to remove
$id = Request::getInt('id', 0);
// Ensure we found an account
if (!$id) {
\App::abort(404, Lang::txt('COM_MEMBERS_NOT_FOUND'));
}
if (in_array($id, $members)) {
$users_mem[] = $id;
}
if (in_array($id, $managers)) {
$users_man[] = $id;
}
// Remove users from members list
$group->remove('members', $users_mem);
// Remove users from managers list
$group->remove('managers', $users_man);
// Save changes
$group->update();
// Push through to the groups view
$this->displayTask($id);
}