private function getLineForData($data) { $action = $data->getValue('action'); $actor_phid = $data->getAuthorPHID(); $actor_link = $this->linkTo($actor_phid); $task_phid = $data->getValue('taskPHID'); $task_link = $this->linkTo($task_phid); $owner_phid = $data->getValue('ownerPHID'); $owner_link = $this->linkTo($owner_phid); $verb = ManiphestAction::getActionPastTenseVerb($action); switch ($action) { case ManiphestAction::ACTION_ASSIGN: case ManiphestAction::ACTION_REASSIGN: if ($owner_phid) { if ($owner_phid == $actor_phid) { $one_line = "{$actor_link} claimed {$task_link}"; } else { $one_line = "{$actor_link} {$verb} {$task_link} to {$owner_link}"; } } else { $one_line = "{$actor_link} placed {$task_link} up for grabs"; } break; default: $one_line = "{$actor_link} {$verb} {$task_link}"; break; } return $one_line; }
public function renderView() { $data = $this->getStoryData(); $author_phid = $data->getAuthorPHID(); $owner_phid = $data->getValue('ownerPHID'); $task_phid = $data->getValue('taskPHID'); $objects = $this->getObjects(); $action = $data->getValue('action'); $view = new PhabricatorFeedStoryView(); $verb = ManiphestAction::getActionPastTenseVerb($action); $extra = null; switch ($action) { case ManiphestAction::ACTION_ASSIGN: if ($owner_phid) { $extra = ' to ' . '<strong>' . $this->getHandle($owner_phid)->renderLink() . '</strong>'; } else { $verb = 'placed'; $extra = ' up for grabs'; } break; } $title = '<strong>' . $this->getHandle($author_phid)->renderLink() . '</strong>' . " {$verb} task " . '<strong>' . $this->getHandle($task_phid)->renderLink() . '</strong>'; $title .= $extra; $title .= '.'; $view->setTitle($title); switch ($action) { case ManiphestAction::ACTION_CREATE: $full_size = true; break; default: $full_size = false; break; } $view->setEpoch($data->getEpoch()); if ($full_size) { if (!empty($objects[$author_phid])) { $image_phid = $objects[$author_phid]->getProfileImagePHID(); $image_uri = PhabricatorFileURI::getViewURIForPHID($image_phid); $view->setImage($image_uri); } $content = phutil_escape_html(phutil_utf8_shorten($data->getValue('description'), 128)); $content = str_replace("\n", '<br />', $content); $view->appendChild($content); } else { $view->setOneLineStory(true); } return $view; }
public function renderView() { $data = $this->getStoryData(); $author_phid = $data->getAuthorPHID(); $owner_phid = $data->getValue('ownerPHID'); $task_phid = $data->getValue('taskPHID'); $action = $data->getValue('action'); $view = new PhabricatorFeedStoryView(); $verb = ManiphestAction::getActionPastTenseVerb($action); $extra = null; switch ($action) { case ManiphestAction::ACTION_ASSIGN: if ($owner_phid) { $extra = ' to ' . $this->linkTo($owner_phid); } else { $verb = 'placed'; $extra = ' up for grabs'; } break; } $title = $this->linkTo($author_phid) . " {$verb} task " . $this->linkTo($task_phid); $title .= $extra; $title .= '.'; $view->setTitle($title); switch ($action) { case ManiphestAction::ACTION_CREATE: $full_size = true; break; default: $full_size = false; break; } $view->setEpoch($data->getEpoch()); if ($full_size) { $view->setImage($this->getHandle($author_phid)->getImageURI()); $content = $this->renderSummary($data->getValue('description')); $view->appendChild($content); } else { $view->setOneLineStory(true); } return $view; }
private function publishFeedStory(ManiphestTask $task, array $transactions) { assert_instances_of($transactions, 'ManiphestTransaction'); $actions = array(ManiphestAction::ACTION_UPDATE); $comments = null; foreach ($transactions as $transaction) { if ($transaction->hasComments()) { $comments = $transaction->getComments(); } switch ($transaction->getTransactionType()) { case ManiphestTransactionType::TYPE_OWNER: $actions[] = ManiphestAction::ACTION_ASSIGN; break; case ManiphestTransactionType::TYPE_STATUS: if ($task->getStatus() != ManiphestTaskStatus::STATUS_OPEN) { $actions[] = ManiphestAction::ACTION_CLOSE; } else { if ($this->isCreate($transactions)) { $actions[] = ManiphestAction::ACTION_CREATE; } } break; default: break; } } $action_type = ManiphestAction::selectStrongestAction($actions); $owner_phid = $task->getOwnerPHID(); $actor_phid = head($transactions)->getAuthorPHID(); $author_phid = $task->getAuthorPHID(); id(new PhabricatorFeedStoryPublisher())->setStoryType(PhabricatorFeedStoryTypeConstants::STORY_MANIPHEST)->setStoryData(array('taskPHID' => $task->getPHID(), 'transactionIDs' => mpull($transactions, 'getID'), 'ownerPHID' => $owner_phid, 'action' => $action_type, 'comments' => $comments, 'description' => $task->getDescription()))->setStoryTime(time())->setStoryAuthorPHID($actor_phid)->setRelatedPHIDs(array_merge(array_filter(array($task->getPHID(), $author_phid, $actor_phid, $owner_phid)), $task->getProjectPHIDs()))->publish(); }