/** * Parse the rights for all the users and return it into a bitmask per user. * * @param array $params The post values. * @param string $type Type of right, for users or modules. * @param string $moduleId The module ID. * @param boolean $newItem If is a new item or not. * @param integer $ownerId The owner ID or 0 for the current user. * * @return array Array with user IDs per access. */ public static function getRights($params) { $right = array(); $rights = array(); if (isset($params['dataAccess'])) { $ids = array_keys($params['dataAccess']); foreach ($ids as $accessId) { $right = array(); $right['none'] = self::_checked($params, 'checkNoneAccess', $accessId); $right['read'] = self::_checked($params, 'checkReadAccess', $accessId); $right['write'] = self::_checked($params, 'checkWriteAccess', $accessId); $right['access'] = self::_checked($params, 'checkAccessAccess', $accessId); $right['create'] = self::_checked($params, 'checkCreateAccess', $accessId); $right['copy'] = self::_checked($params, 'checkCopyAccess', $accessId); $right['delete'] = self::_checked($params, 'checkDeleteAccess', $accessId); $right['download'] = self::_checked($params, 'checkDownloadAccess', $accessId); $right['admin'] = self::_checked($params, 'checkAdminAccess', $accessId); $rights[$accessId] = Phprojekt_Acl::convertArrayToBitmask($right); } } return $rights; }
/** * Parse the rights for all the users and return it into a bitmask per user. * * @param array $params The post values. * @param string $type Type of right, for users or modules. * @param string $moduleId The module ID. * @param boolean $newItem If is a new item or not. * @param integer $ownerId The owner ID or 0 for the current user. * * @return array Array with user IDs per access. */ private static function getRights($params, $type, $moduleId = 0, $newItem = false, $ownerId = 0) { $right = array(); $rights = array(); if (isset($params['dataAccess'])) { $ids = array_keys($params['dataAccess']); foreach ($ids as $accessId) { $right = array(); $right['none'] = self::_checked($params, 'checkNoneAccess', $accessId); $right['read'] = self::_checked($params, 'checkReadAccess', $accessId); $right['write'] = self::_checked($params, 'checkWriteAccess', $accessId); $right['access'] = self::_checked($params, 'checkAccessAccess', $accessId); $right['create'] = self::_checked($params, 'checkCreateAccess', $accessId); $right['copy'] = self::_checked($params, 'checkCopyAccess', $accessId); $right['delete'] = self::_checked($params, 'checkDeleteAccess', $accessId); $right['download'] = self::_checked($params, 'checkDownloadAccess', $accessId); $right['admin'] = self::_checked($params, 'checkAdminAccess', $accessId); $rights[$accessId] = Phprojekt_Acl::convertArrayToBitmask($right); } } if ($type == self::ITEM_TYPE) { // Only set the full access if is a new item if ($newItem) { if ($ownerId == 0) { $ownerId = Phprojekt_Auth::getUserId(); } $rights[$ownerId] = Phprojekt_Acl::ALL; } // Return access only for allowed users $activeRecord = Phprojekt_Loader::getLibraryClass('Phprojekt_User_User'); $result = $activeRecord->getAllowedUsers(); $resultRights = array(); foreach ($result as $node) { if (isset($rights[$node['id']])) { $resultRights[$node['id']] = $rights[$node['id']]; } } if (isset($params['dataAccess'])) { $moduleType = Phprojekt_Module::getSaveType($moduleId); if ($moduleType != 1) { // Items under a project => add admin with full access $resultRights[1] = Phprojekt_Acl::ALL; } } } else { $resultRights = $rights; } return $resultRights; }
private function _getDefaultRightsForProject($projectId) { $model = new Project_Models_Project(); $record = $model->find($projectId); $rights = $record->getUsersRights(); foreach ($rights as $userId => $accessArray) { $rights[$userId] = Phprojekt_Acl::convertArrayToBitmask($accessArray); } return $rights; }