本文整理汇总了PHP中error::createGroupLastAdmin方法的典型用法代码示例。如果您正苦于以下问题:PHP error::createGroupLastAdmin方法的具体用法?PHP error::createGroupLastAdmin怎么用?PHP error::createGroupLastAdmin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类error
的用法示例。
在下文中一共展示了error::createGroupLastAdmin方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: removemember
/**
* Remove a emember of the group
*
* @param string $userid
* @return Group object (this)
*/
function removemember($userid)
{
global $DB, $CFG, $USER, $HUB_SQL;
//check user can add to the group
if (!$this->isgroupadmin($USER->userid)) {
return access_denied_error();
}
// check user exists
$user = new User($userid);
if ($user->load() instanceof Error) {
global $ERROR;
$ERROR = new error();
return $ERROR->createUserNotFoundError($userid);
}
// remove them as admin (if they are already)
if ($this->isgroupadmin($userid) && $this->removeadmin($userid) instanceof Error) {
global $ERROR;
$ERROR = new error();
return $ERROR->createGroupLastAdmin($userid);
}
// remove the user from the group
$params = array();
$params[0] = $this->groupid;
$params[1] = $userid;
$res = $DB->delete($HUB_SQL->DATAMODEL_GROUP_MEMBER_DELETE, $params);
if (!$res) {
return database_error();
} else {
$this->reportpendingmember($userid);
}
$this->load();
$this->loadmembers();
return $this;
}