本文整理汇总了PHP中OA_Permission::deleteExistingPermissions方法的典型用法代码示例。如果您正苦于以下问题:PHP OA_Permission::deleteExistingPermissions方法的具体用法?PHP OA_Permission::deleteExistingPermissions怎么用?PHP OA_Permission::deleteExistingPermissions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OA_Permission
的用法示例。
在下文中一共展示了OA_Permission::deleteExistingPermissions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: storeUserAccountsPermissions
/**
* Store user rights per account
*
* @param array $aPermissions Array of permission IDs
* @param integer $accountId account ID
* @param integer $userId user ID
* @param array $aAllowedPermissions Array of allowed permissions - keys of array are permissions IDs
* @return true on success else false
*/
function storeUserAccountsPermissions($aPermissions, $accountId = null, $userId = null, $aAllowedPermissions = null)
{
if (empty($userId)) {
$userId = OA_Permission::getUserId();
}
if (empty($accountId)) {
$accountId = OA_Permission::getAccountId();
}
OA_Permission::deleteExistingPermissions($accountId, $userId, $aAllowedPermissions);
// add new permissions
foreach ($aPermissions as $permissionId) {
if (!is_null($aAllowedPermissions) && !isset($aAllowedPermissions[$permissionId])) {
// check if permission is on the list of allowed permissions
continue;
}
$doAccount_user_permission_assoc = OA_Dal::factoryDO('account_user_permission_assoc');
$doAccount_user_permission_assoc->account_id = $accountId;
$doAccount_user_permission_assoc->user_id = $userId;
$doAccount_user_permission_assoc->permission_id = $permissionId;
$doAccount_user_permission_assoc->is_allowed = 1;
if (!$doAccount_user_permission_assoc->insert()) {
return false;
}
}
return true;
}