/** * @param PresentationSpeaker $speaker * @param Presentation $presentation * @return bool */ public function canAddSpeakerOnPresentation(PresentationSpeaker $speaker, Presentation $presentation) { $category = $presentation->Category(); $summit = $category->Summit(); if ($summit->isCallForSpeakersOpen() && $summit->isPublicCategory($category)) { $max_per_summit = intval($summit->MaxSubmissionAllowedPerUser); //zero means infinity if ($max_per_summit === 0) { $max_per_summit = PHP_INT_MAX; } $presentation_count = intval($speaker->getPublicCategoryPresentationsBySummit($summit)->count()) + intval($speaker->getPublicCategoryOwnedPresentationsBySummit($summit)->count()); return $presentation_count < $max_per_summit; } if ($summit->isPrivateCategory($category) && ($group = $summit->getPrivateGroupFor($category))) { if ($group->isSubmissionOpen()) { $max_per_group = intval($group->MaxSubmissionAllowedPerUser); //zero means infinity if ($max_per_group === 0) { $max_per_group = PHP_INT_MAX; } $group_presentation_count = intval($speaker->getPrivateCategoryPresentationsBySummit($summit, $group)->count()) + intval($speaker->getPrivateCategoryOwnedPresentationsBySummit($summit, $group)->count()); return $group_presentation_count < $max_per_group; } } return false; }