예제 #1
0
 /**
  * Add new Kanban Item
  *
  * Create a kanban item in the given column or backlog
  *
  * <pre>
  * /!\ Kanban REST routes are under construction and subject to changes /!\
  * </pre>
  * <pre>
  * /!\ Only works for trackers that allow artifact creation with only a "title" /!\
  * </pre>
  *
  * @access protected
  *
  * @url POST
  *
  * @param KanbanItemPOSTRepresentation $item The created kanban item {@from body} {@type Tuleap\AgileDashboard\REST\v1\Kanban\KanbanItemPOSTRepresentation}
  *
  * @status 201
  */
 protected function post(KanbanItemPOSTRepresentation $item)
 {
     $current_user = $this->getCurrentUser();
     $kanban = $this->getKanban($current_user, $item->kanban_id);
     $tracker = $this->tracker_factory->getTrackerById($kanban->getTrackerId());
     $updater = new ArtifactCreator(new ArtifactValidator($this->form_element_factory), $this->artifact_factory, $this->tracker_factory);
     $tracker_reference = new TrackerReference();
     $tracker_reference->build($tracker);
     $artifact_fields = $this->buildFieldsData($tracker, $item);
     $art_ref = $updater->create($current_user, $tracker_reference, $artifact_fields);
     $artifact = $art_ref->getArtifact();
     if (!$artifact) {
         throw new RestException(500, implode('. ', $GLOBALS['Response']->getFeedbackErrors()));
     }
     $this->statistics_aggregator->addKanbanAddInPlaceHit($tracker->getGroupId());
     $item_representation = $this->buildItemRepresentation($artifact);
     if (isset($_SERVER[self::HTTP_CLIENT_UUID]) && $_SERVER[self::HTTP_CLIENT_UUID]) {
         $this->node_js_client->sendMessage($current_user->getId(), $_SERVER[self::HTTP_CLIENT_UUID], $item->kanban_id, 'kanban_item:create', $item_representation);
     }
     return $item_representation;
 }
예제 #2
0
 private function sendMessageForDroppingItem($current_user, $kanban, $order, $add, $in_column)
 {
     if (isset($_SERVER[self::HTTP_CLIENT_UUID]) && $_SERVER[self::HTTP_CLIENT_UUID]) {
         $data = array('order' => $order, 'add' => $add, 'in_column' => $in_column);
         $this->node_js_client->sendMessage($current_user->getId(), $_SERVER[self::HTTP_CLIENT_UUID], $kanban->getId(), 'kanban_item:move', $data);
     }
 }
예제 #3
0
 private function sendMessageForEachArtifact(PFUser $current_user, AgileDashboard_Kanban $kanban, array $artifact_ids, array $data)
 {
     foreach ($artifact_ids as $artifact_id) {
         $artifact = $this->artifact_factory->getArtifactById($artifact_id);
         $rights = new KanbanArtifactRightsPresenter($artifact, $this->permissions_serializer);
         $message = new MessageDataPresenter($current_user->getId(), $_SERVER[self::HTTP_CLIENT_UUID], $kanban->getId(), $rights, 'kanban_item:move', $data);
         $this->node_js_client->sendMessage($message);
     }
 }
예제 #4
0
 private function sendMessage(PFUser $current_user, AgileDashboard_Kanban $kanban, array $data, $rights)
 {
     $this->node_js_client->sendMessage($current_user->getId(), $_SERVER[self::HTTP_CLIENT_UUID], $kanban->getId(), $rights, 'kanban_item:move', $data);
 }