/**
  * Formats an activity as a valid JSON object (with all the information about the activity)
  * @param ActivityEntity $activity
  * @return array
  */
 public static function getFormattedData(ActivityEntity $activity)
 {
     $people = Person::getFormattedPeopleShortWithRecords($activity->getPeople());
     $activityInfo = ['error' => null, 'id' => $activity->getId(), 'name' => $activity->getName(), 'target_groups' => TargetGroup::getFormattedTargetGroups($activity->getTargetGroup()), 'target_group_comment' => $activity->getTargetGroupComment(), 'start_date' => $activity->getStartDate()->format('Y-m-d H:i:s'), 'end_date' => $activity->getEndDate()->format('Y-m-d H:i:s'), 'participants' => $people];
     return $activityInfo;
 }
 /**
  * Gets all the people not in the specified activity, who meet the search criteria and who are not already temporarily added
  * @todo only return like the top ten results (in order to speed up the lookup)
  */
 public function actionActivityPeople()
 {
     $data = $this->parseRequest(['activity_id' => null, 'temporarily_added' => null, 'search' => null]);
     $people = null;
     $pqb = $this->getQueryForPeopleNotInProgramme($data);
     $pqb->setMaxResults(10);
     if (empty(Activity::getValidActivityWithId($data['activity_id']))) {
         $response['error'] = $this->getJSONError(2, "Activity hidden.");
     } else {
         try {
             $response['error'] = null;
             $query = $pqb->getQuery();
             $result = $query->getResult();
             $response['data'] = Person::getFormattedPeopleShortWithRecords($result);
         } catch (Exception $e) {
             $response['error'] = $this->getJSONError(1, "Query failed with exception " . $e->getMessage());
         }
     }
     echo json_encode($response);
 }