/** * Unlinks user from account and if necessary deletes user account. * Sets apropriate message * * @param integer $accountId Account ID * @param integer $userId User ID */ function unlinkUserFromAccount($accountId, $userId) { if (OA_Permission::isUserLinkedToAccount($accountId, $userId)) { $doAccount_user_assoc = OA_Dal::factoryDO('account_user_assoc'); $doAccount_user_assoc->account_id = $accountId; $doAccount_user_assoc->user_id = $userId; $doAccount_user_assoc->delete(); OA_Session::setMessage($GLOBALS['strUserUnlinkedFromAccount']); $doUsers = OA_Dal::staticGetDO('users', $userId); // delete user account if he is not linked anymore to any account if ($doUsers->countLinkedAccounts() == 0) { $doUsers->delete(); OA_Session::setMessage($GLOBALS['strUserWasDeleted']); } else { OA_Admin_UI_UserAccess::resetUserDefaultAccount($userId, $accountId); } } else { OA_Session::setMessage($GLOBALS['strUserNotLinkedWithAccount']); } }