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