user()->id]['owner'] == true; } } /** * Business Permit */ if (!function_exists('businessAccess')) { function businessAccess($ids) { return isset(request('_business_info')['info']['users'][$ids['user_id']?? auth()->id()]); } } if (!function_exists('isBusinessOwner')) { function isBusinessOwner($ids) { return businessAccess($ids) && request('_business_info')['info']['users'][$ids['user_id'] ?? auth()->id()]['level'] == enum('levels.owner.id'); } } if (!function_exists('isAtLeastBusinessAdmin')) { function isAtLeastBusinessAdmin($ids) { return businessAccess($ids) && request('_business_info')['info']['users'][$ids['user_id'] ?? auth()->id()]['level'] >= enum('levels.admin.id'); } } if (!function_exists('businessEdit')) { function businessEdit($ids) { return isBusinessOwner($ids); } } if (!function_exists('businessUsers')) { function businessUsers($ids) { return isBusinessOwner($ids); } } if (!function_exists('businessWorkFlows')) { function businessWorkFlows($ids) { return isAtLeastBusinessAdmin($ids); } } if (!function_exists('businessProjects')) { function businessProjects($ids) { return isBusinessOwner($ids); } } if (!function_exists('businessTags')) { function businessTags($ids) { return isAtLeastBusinessAdmin($ids); } } if (!function_exists('businessStatuses')) { function businessStatuses($ids) { return isAtLeastBusinessAdmin($ids); } } /** * Project Permit */ if (!function_exists('isInProject')) { function isInProject($ids) { return isset(request('_business_info')['info']['projects'][$ids['project_id']]['members'][$ids['user_id'] ?? auth()->id()]); } } if (!function_exists('isActiveInProject')) { function isActiveInProject($ids) { return request('_business_info')['info']['projects'][$ids['project_id']]['members'][$ids['user_id'] ?? auth()->id()]['level'] > 0; } } if (!function_exists('projectAccess')) { function projectAccess($ids) { return isInProject($ids) && isActiveInProject($ids); } } if (!function_exists('isOwnerLevelInProject')) { function isOwnerLevelInProject($ids) { return request('_business_info')['info']['projects'][$ids['project_id']]['members'][$ids['user_id'] ?? auth()->id()]['level'] == enum('levels.owner.id'); } } if (!function_exists('isAtLeastAdminLevelInProject')) { function isAtLeastAdminLevelInProject($ids) { return request('_business_info')['info']['projects'][$ids['project_id']]['members'][$ids['user_id'] ?? auth()->id()]['level'] >= enum('levels.admin.id'); } } if (!function_exists('isAtLeastColleagueLevelInProject')) { function isAtLeastColleagueLevelInProject($ids) { return request('_business_info')['info']['projects'][$ids['project_id']]['members'][$ids['user_id'] ?? auth()->id()]['level'] >= enum('levels.colleague.id'); } } if (!function_exists('isAtLeastGuestLevelInProject')) { function isAtLeastGuestLevelInProject($ids) { return request('_business_info')['info']['projects'][$ids['project_id']]['members'][$ids['user_id'] ?? auth()->id()]['level'] >= enum('levels.guest.id'); } } if (!function_exists('isDefiniteGuestInProject')) { function isDefiniteGuestInProject($ids) { return isInProject($ids) && request('_business_info')['info']['projects'][$ids['project_id']]['members'][$ids['user_id'] ?? auth()->id()]['level'] == enum('levels.guest.id'); } } if (!function_exists('isProjectOwner')) { function isProjectOwner($ids) { return isInProject($ids) && isOwnerLevelInProject($ids); } } if (!function_exists('isProjectAdmin')) { function isProjectAdmin($ids) { return isInProject($ids) && isAtLeastAdminLevelInProject($ids); } } if (!function_exists('isProjectColleague')) { function isProjectColleague($ids) { return isInProject($ids) && isAtLeastColleagueLevelInProject($ids); } } if (!function_exists('isProjectGuest')) { function isProjectGuest($ids) { return isInProject($ids) && isAtLeastGuestLevelInProject($ids); } } if (!function_exists('projectEdit')) { function projectEdit($ids) { return isProjectAdmin($ids); } } if (!function_exists('projectUsers')) { function projectUsers($ids) { return isProjectOwner($ids); } } if (!function_exists('projectSystems')) { function projectSystems($ids) { return isProjectAdmin($ids); } } if (!function_exists('projectTasks')) { function projectTasks($ids) { return isProjectAdmin($ids); } } if (!function_exists('projectSprints')) { function projectSprints($ids) { return isProjectAdmin($ids); } } /** * other */ if (!function_exists('isActiveUser')) { function isActiveUser($ids) { return businessAccess($ids) && request('_business_info')['info']['users'][$ids['user_id'] ?? auth()->id()]['level'] > enum('levels.inactive.id'); } }