/** * Format information, about the attendees of a calendar event, to be viewed. The current user * logged in, if he is one of the attendees, so he must be the first exhibited attendee. The * remaining attendees will be group by, in the following order, that have the confirmation * type: ACCEPTED, TENTATIVE, NEEDS-ACTION and DECLINED. * * @param array $attendees An array of attendees objects * @return array An array of formatted information about attendees in wich element contains * the name (->name) of the attendee, it's current confirmation (->userConfirm), * the icon css class of the current confirmation type (->userConfirmIcon) and * the organization and region about attendee's role */ private function formatAttendeesInformation($attendees) { // Email of current logged in user, because we'll search for it in attendees list $currUserEmail = TineSessionRepository::getTineSession()->getAttribute('Expressomail.email'); // Array which indexes are confirmation types, each one containing an empty list of attendees $result = EventUtils::prepareListOfConfirmationTypesToGroupAttendees(); $currUserAttendee = null; $userHasNotFounded = true; foreach ($attendees as $attendee) { // Formatting the description for the current attendee event confirmation type $attendee->confirmStatus = EventUtils::getConfirmationDescription($attendee->confirmation); // Verifying if the logged in user is also an attendee of the event. if ($userHasNotFounded && $attendee->email === $currUserEmail) { $currUserAttendee = $attendee; $userHasNotFounded = false; } else { $result[$attendee->confirmation][] = $attendee; } } // Checking whether the logged in user is a attendee of the current event if (!$userHasNotFounded && !is_null($currUserAttendee)) { array_unshift($result, array($currUserAttendee)); // First one to be displayed } return EventUtils::sortAttendeesByName($result); }