本文整理汇总了PHP中UserRole::findOneByRoleIdAndUserId方法的典型用法代码示例。如果您正苦于以下问题:PHP UserRole::findOneByRoleIdAndUserId方法的具体用法?PHP UserRole::findOneByRoleIdAndUserId怎么用?PHP UserRole::findOneByRoleIdAndUserId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserRole
的用法示例。
在下文中一共展示了UserRole::findOneByRoleIdAndUserId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeRemoveMember
public function executeRemoveMember()
{
$this->validAjaxRequest();
$ajax = new \AjaxResponse();
if (!$this->isAllowed(PERMISSION_ROLE_PERMISSION_MANAGE)) {
$ajax->type = \AjaxResponse::ERROR;
$ajax->message = t("You don't have permission");
return $this->renderText($ajax->toString());
}
$user_id = $this->post('user_id', 'INT', 0);
//not need check user
$role_id = $this->post('role_id', 'INT', 0);
if (!$role_id || !($role = \Roles::retrieveById($role_id))) {
$ajax->type = \AjaxResponse::ERROR;
$ajax->message = self::t("Không có nhóm này");
return $this->renderText($ajax->toString());
}
if ($userRole = \UserRole::findOneByRoleIdAndUserId($role->getId(), $user_id)) {
if ($userRole->delete()) {
$role->setMemberNo($role->getMemberNo() - 1);
$role->save(false);
}
}
$ajax->type = \AjaxResponse::SUCCESS;
$ajax->message = t("Remove member success!");
$ajax->user_id = $user_id;
$ajax->role = $role->toArray();
return $this->renderText($ajax->toString());
}