Exemplo n.º 1
0
 /**
  * Get report
  *
  * Get the definition of the given report
  *
  * @url GET {id}
  * @access hybrid
  *
  * @param int $id Id of the report
  *
  * @return Tuleap\Tracker\REST\ReportRepresentation
  */
 public function getId($id)
 {
     $this->checkAccess();
     $user = UserManager::instance()->getCurrentUser();
     $report = $this->getReportById($user, $id);
     $rest_report = new ReportRepresentation();
     $rest_report->build($report);
     Header::allowOptionsGet();
     return $rest_report;
 }
Exemplo n.º 2
0
 /**
  * Get all reports of a given tracker
  *
  * All reports the user can see
  *
  * @url GET {id}/tracker_reports
  * @access hybrid
  *
  * @param int $id Id of the tracker
  * @param int $limit  Number of elements displayed per page {@from path}{@min 1}
  * @param int $offset Position of the first element to display {@from path}{@min 0}
  *
  * @return array {@type Tuleap\Tracker\REST\ReportRepresentation}
  */
 public function getReports($id, $limit = 10, $offset = self::DEFAULT_OFFSET)
 {
     $this->checkAccess();
     $this->checkLimitValue($limit);
     $user = UserManager::instance()->getCurrentUser();
     $tracker = $this->getTrackerById($user, $id);
     $all_reports = Tracker_ReportFactory::instance()->getReportsByTrackerId($tracker->getId(), $user->getId());
     $nb_of_reports = count($all_reports);
     $reports = array_slice($all_reports, $offset, $limit);
     Header::allowOptionsGet();
     Header::sendPaginationHeaders($limit, $offset, $nb_of_reports, self::MAX_LIMIT);
     return array_map(function (Tracker_Report $report) {
         $rest_report = new ReportRepresentation();
         $rest_report->build($report);
         return $rest_report;
     }, $reports);
 }