private function performMerge(ManiphestTask $task, PhabricatorObjectHandle $handle, array $phids)
 {
     $user = $this->getRequest()->getUser();
     $response = id(new AphrontReloadResponse())->setURI($handle->getURI());
     $phids = array_fill_keys($phids, true);
     unset($phids[$task->getPHID()]);
     // Prevent merging a task into itself.
     if (!$phids) {
         return $response;
     }
     $targets = id(new ManiphestTaskQuery())->setViewer($user)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->withPHIDs(array_keys($phids))->needSubscriberPHIDs(true)->needProjectPHIDs(true)->execute();
     if (empty($targets)) {
         return $response;
     }
     $editor = id(new ManiphestTransactionEditor())->setActor($user)->setContentSourceFromRequest($this->getRequest())->setContinueOnNoEffect(true)->setContinueOnMissingFields(true);
     $cc_vector = array();
     // since we loaded this via a generic object query, go ahead and get the
     // attach the subscriber and project phids now
     $task->attachSubscriberPHIDs(PhabricatorSubscribersQuery::loadSubscribersForPHID($task->getPHID()));
     $task->attachProjectPHIDs(PhabricatorEdgeQuery::loadDestinationPHIDs($task->getPHID(), PhabricatorProjectObjectHasProjectEdgeType::EDGECONST));
     $cc_vector[] = $task->getSubscriberPHIDs();
     foreach ($targets as $target) {
         $cc_vector[] = $target->getSubscriberPHIDs();
         $cc_vector[] = array($target->getAuthorPHID(), $target->getOwnerPHID());
         $merged_into_txn = id(new ManiphestTransaction())->setTransactionType(ManiphestTransaction::TYPE_MERGED_INTO)->setNewValue($task->getPHID());
         $editor->applyTransactions($target, array($merged_into_txn));
     }
     $all_ccs = array_mergev($cc_vector);
     $all_ccs = array_filter($all_ccs);
     $all_ccs = array_unique($all_ccs);
     $add_ccs = id(new ManiphestTransaction())->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS)->setNewValue(array('=' => $all_ccs));
     $merged_from_txn = id(new ManiphestTransaction())->setTransactionType(ManiphestTransaction::TYPE_MERGED_FROM)->setNewValue(mpull($targets, 'getPHID'));
     $editor->applyTransactions($task, array($add_ccs, $merged_from_txn));
     return $response;
 }
 public static function updateTaskProjects(ManiphestTask $task)
 {
     $dao = new ManiphestTaskProject();
     $conn = $dao->establishConnection('w');
     $sql = array();
     foreach ($task->getProjectPHIDs() as $project_phid) {
         $sql[] = qsprintf($conn, '(%s, %s)', $task->getPHID(), $project_phid);
     }
     queryfx($conn, 'DELETE FROM %T WHERE taskPHID = %s', $dao->getTableName(), $task->getPHID());
     if ($sql) {
         queryfx($conn, 'INSERT INTO %T (taskPHID, projectPHID) VALUES %Q', $dao->getTableName(), implode(', ', $sql));
     }
 }
 private function performMerge(ManiphestTask $task, PhabricatorObjectHandle $handle, array $phids)
 {
     $user = $this->getRequest()->getUser();
     $response = id(new AphrontReloadResponse())->setURI($handle->getURI());
     $phids = array_fill_keys($phids, true);
     unset($phids[$task->getPHID()]);
     // Prevent merging a task into itself.
     if (!$phids) {
         return $response;
     }
     $targets = id(new ManiphestTaskQuery())->setViewer($user)->withPHIDs(array_keys($phids))->execute();
     if (empty($targets)) {
         return $response;
     }
     $editor = id(new ManiphestTransactionEditor())->setActor($user)->setContentSourceFromRequest($this->getRequest())->setContinueOnNoEffect(true)->setContinueOnMissingFields(true);
     $cc_vector = array();
     $cc_vector[] = $task->getCCPHIDs();
     foreach ($targets as $target) {
         $cc_vector[] = $target->getCCPHIDs();
         $cc_vector[] = array($target->getAuthorPHID(), $target->getOwnerPHID());
         $merged_into_txn = id(new ManiphestTransaction())->setTransactionType(ManiphestTransaction::TYPE_MERGED_INTO)->setNewValue($task->getPHID());
         $editor->applyTransactions($target, array($merged_into_txn));
     }
     $all_ccs = array_mergev($cc_vector);
     $all_ccs = array_filter($all_ccs);
     $all_ccs = array_unique($all_ccs);
     $add_ccs = id(new ManiphestTransaction())->setTransactionType(ManiphestTransaction::TYPE_CCS)->setNewValue($all_ccs);
     $merged_from_txn = id(new ManiphestTransaction())->setTransactionType(ManiphestTransaction::TYPE_MERGED_FROM)->setNewValue(mpull($targets, 'getPHID'));
     $editor->applyTransactions($task, array($add_ccs, $merged_from_txn));
     return $response;
 }
 public static function updateTaskSubscribers(ManiphestTask $task)
 {
     $dao = new ManiphestTaskSubscriber();
     $conn = $dao->establishConnection('w');
     $sql = array();
     $subscribers = $task->getCCPHIDs();
     $subscribers[] = $task->getOwnerPHID();
     $subscribers = array_unique($subscribers);
     foreach ($subscribers as $subscriber_phid) {
         $sql[] = qsprintf($conn, '(%s, %s)', $task->getPHID(), $subscriber_phid);
     }
     queryfx($conn, 'DELETE FROM %T WHERE taskPHID = %s', $dao->getTableName(), $task->getPHID());
     if ($sql) {
         queryfx($conn, 'INSERT INTO %T (taskPHID, subscriberPHID) VALUES %Q', $dao->getTableName(), implode(', ', $sql));
     }
 }
 private function buildActionView(ManiphestTask $task)
 {
     $viewer = $this->getRequest()->getUser();
     $id = $task->getID();
     $phid = $task->getPHID();
     $can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $task, PhabricatorPolicyCapability::CAN_EDIT);
     $view = id(new PhabricatorActionListView())->setUser($viewer)->setObject($task);
     $view->addAction(id(new PhabricatorActionView())->setName(pht('Edit Task'))->setIcon('fa-pencil')->setHref($this->getApplicationURI("/task/edit/{$id}/"))->setDisabled(!$can_edit)->setWorkflow(!$can_edit));
     $view->addAction(id(new PhabricatorActionView())->setName(pht('Merge Duplicates In'))->setHref("/search/attach/{$phid}/TASK/merge/")->setWorkflow(true)->setIcon('fa-compress')->setDisabled(!$can_edit)->setWorkflow(true));
     $edit_config = id(new ManiphestEditEngine())->setViewer($viewer)->loadDefaultEditConfiguration();
     $can_create = (bool) $edit_config;
     if ($can_create) {
         $form_key = $edit_config->getIdentifier();
         $edit_uri = id(new PhutilURI("/task/edit/form/{$form_key}/"))->setQueryParam('parent', $id)->setQueryParam('template', $id)->setQueryParam('status', ManiphestTaskStatus::getDefaultStatus());
         $edit_uri = $this->getApplicationURI($edit_uri);
     } else {
         // TODO: This will usually give us a somewhat-reasonable error page, but
         // could be a bit cleaner.
         $edit_uri = "/task/edit/{$id}/";
         $edit_uri = $this->getApplicationURI($edit_uri);
     }
     $view->addAction(id(new PhabricatorActionView())->setName(pht('Create Subtask'))->setHref($edit_uri)->setIcon('fa-level-down')->setDisabled(!$can_create)->setWorkflow(!$can_create));
     $view->addAction(id(new PhabricatorActionView())->setName(pht('Edit Blocking Tasks'))->setHref("/search/attach/{$phid}/TASK/blocks/")->setWorkflow(true)->setIcon('fa-link')->setDisabled(!$can_edit)->setWorkflow(true));
     return $view;
 }
 private function buildCurtain(ManiphestTask $task, PhabricatorEditEngine $edit_engine)
 {
     $viewer = $this->getViewer();
     $id = $task->getID();
     $phid = $task->getPHID();
     $can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $task, PhabricatorPolicyCapability::CAN_EDIT);
     $curtain = $this->newCurtainView($task);
     $curtain->addAction(id(new PhabricatorActionView())->setName(pht('Edit Task'))->setIcon('fa-pencil')->setHref($this->getApplicationURI("/task/edit/{$id}/"))->setDisabled(!$can_edit)->setWorkflow(!$can_edit));
     $edit_config = $edit_engine->loadDefaultEditConfiguration();
     $can_create = (bool) $edit_config;
     $can_reassign = $edit_engine->hasEditAccessToTransaction(ManiphestTransaction::TYPE_OWNER);
     if ($can_create) {
         $form_key = $edit_config->getIdentifier();
         $edit_uri = id(new PhutilURI("/task/edit/form/{$form_key}/"))->setQueryParam('parent', $id)->setQueryParam('template', $id)->setQueryParam('status', ManiphestTaskStatus::getDefaultStatus());
         $edit_uri = $this->getApplicationURI($edit_uri);
     } else {
         // TODO: This will usually give us a somewhat-reasonable error page, but
         // could be a bit cleaner.
         $edit_uri = "/task/edit/{$id}/";
         $edit_uri = $this->getApplicationURI($edit_uri);
     }
     $subtask_item = id(new PhabricatorActionView())->setName(pht('Create Subtask'))->setHref($edit_uri)->setIcon('fa-level-down')->setDisabled(!$can_create)->setWorkflow(!$can_create);
     $relationship_list = PhabricatorObjectRelationshipList::newForObject($viewer, $task);
     $submenu_actions = array($subtask_item, ManiphestTaskHasParentRelationship::RELATIONSHIPKEY, ManiphestTaskHasSubtaskRelationship::RELATIONSHIPKEY, ManiphestTaskMergeInRelationship::RELATIONSHIPKEY, ManiphestTaskCloseAsDuplicateRelationship::RELATIONSHIPKEY);
     $task_submenu = $relationship_list->newActionSubmenu($submenu_actions)->setName(pht('Edit Related Tasks...'))->setIcon('fa-anchor');
     $curtain->addAction($task_submenu);
     $relationship_submenu = $relationship_list->newActionMenu();
     if ($relationship_submenu) {
         $curtain->addAction($relationship_submenu);
     }
     $owner_phid = $task->getOwnerPHID();
     $author_phid = $task->getAuthorPHID();
     $handles = $viewer->loadHandles(array($owner_phid, $author_phid));
     if ($owner_phid) {
         $image_uri = $handles[$owner_phid]->getImageURI();
         $image_href = $handles[$owner_phid]->getURI();
         $owner = $viewer->renderHandle($owner_phid)->render();
         $content = phutil_tag('strong', array(), $owner);
         $assigned_to = id(new PHUIHeadThingView())->setImage($image_uri)->setImageHref($image_href)->setContent($content);
     } else {
         $assigned_to = phutil_tag('em', array(), pht('None'));
     }
     $curtain->newPanel()->setHeaderText(pht('Assigned To'))->appendChild($assigned_to);
     $author_uri = $handles[$author_phid]->getImageURI();
     $author_href = $handles[$author_phid]->getURI();
     $author = $viewer->renderHandle($author_phid)->render();
     $content = phutil_tag('strong', array(), $author);
     $date = phabricator_date($task->getDateCreated(), $viewer);
     $content = pht('%s, %s', $content, $date);
     $authored_by = id(new PHUIHeadThingView())->setImage($author_uri)->setImageHref($author_href)->setContent($content);
     $curtain->newPanel()->setHeaderText(pht('Authored By'))->appendChild($authored_by);
     return $curtain;
 }
 private function buildCurtain(ManiphestTask $task, PhabricatorEditEngine $edit_engine)
 {
     $viewer = $this->getViewer();
     $id = $task->getID();
     $phid = $task->getPHID();
     $can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $task, PhabricatorPolicyCapability::CAN_EDIT);
     $curtain = $this->newCurtainView($task);
     $curtain->addAction(id(new PhabricatorActionView())->setName(pht('Edit Task'))->setIcon('fa-pencil')->setHref($this->getApplicationURI("/task/edit/{$id}/"))->setDisabled(!$can_edit)->setWorkflow(!$can_edit));
     $curtain->addAction(id(new PhabricatorActionView())->setName(pht('Merge Duplicates In'))->setHref("/search/attach/{$phid}/TASK/merge/")->setWorkflow(true)->setIcon('fa-compress')->setDisabled(!$can_edit)->setWorkflow(true));
     $edit_config = $edit_engine->loadDefaultEditConfiguration();
     $can_create = (bool) $edit_config;
     $can_reassign = $edit_engine->hasEditAccessToTransaction(ManiphestTransaction::TYPE_OWNER);
     if ($can_create) {
         $form_key = $edit_config->getIdentifier();
         $edit_uri = id(new PhutilURI("/task/edit/form/{$form_key}/"))->setQueryParam('parent', $id)->setQueryParam('template', $id)->setQueryParam('status', ManiphestTaskStatus::getDefaultStatus());
         $edit_uri = $this->getApplicationURI($edit_uri);
     } else {
         // TODO: This will usually give us a somewhat-reasonable error page, but
         // could be a bit cleaner.
         $edit_uri = "/task/edit/{$id}/";
         $edit_uri = $this->getApplicationURI($edit_uri);
     }
     $curtain->addAction(id(new PhabricatorActionView())->setName(pht('Create Subtask'))->setHref($edit_uri)->setIcon('fa-level-down')->setDisabled(!$can_create)->setWorkflow(!$can_create));
     $curtain->addAction(id(new PhabricatorActionView())->setName(pht('Edit Blocking Tasks'))->setHref("/search/attach/{$phid}/TASK/blocks/")->setWorkflow(true)->setIcon('fa-link')->setDisabled(!$can_edit)->setWorkflow(true));
     $owner_phid = $task->getOwnerPHID();
     $author_phid = $task->getAuthorPHID();
     $handles = $viewer->loadHandles(array($owner_phid, $author_phid));
     if ($owner_phid) {
         $image_uri = $handles[$owner_phid]->getImageURI();
         $image_href = $handles[$owner_phid]->getURI();
         $owner = $viewer->renderHandle($owner_phid)->render();
         $content = phutil_tag('strong', array(), $owner);
         $assigned_to = id(new PHUIHeadThingView())->setImage($image_uri)->setImageHref($image_href)->setContent($content);
     } else {
         $assigned_to = phutil_tag('em', array(), pht('None'));
     }
     $curtain->newPanel()->setHeaderText(pht('Assigned To'))->appendChild($assigned_to);
     $author_uri = $handles[$author_phid]->getImageURI();
     $author_href = $handles[$author_phid]->getURI();
     $author = $viewer->renderHandle($author_phid)->render();
     $content = phutil_tag('strong', array(), $author);
     $date = phabricator_date($task->getDateCreated(), $viewer);
     $content = pht('%s, %s', $content, $date);
     $authored_by = id(new PHUIHeadThingView())->setImage($author_uri)->setImageHref($author_href)->setContent($content);
     $curtain->newPanel()->setHeaderText(pht('Authored By'))->appendChild($authored_by);
     return $curtain;
 }
 private function performMerge(ManiphestTask $task, PhabricatorObjectHandle $handle, array $phids)
 {
     $user = $this->getRequest()->getUser();
     $response = id(new AphrontReloadResponse())->setURI($handle->getURI());
     $phids = array_fill_keys($phids, true);
     unset($phids[$task->getPHID()]);
     // Prevent merging a task into itself.
     if (!$phids) {
         return $response;
     }
     $targets = id(new ManiphestTaskQuery())->setViewer($user)->withPHIDs(array_keys($phids))->execute();
     if (empty($targets)) {
         return $response;
     }
     $editor = id(new ManiphestTransactionEditor())->setActor($user)->setContentSourceFromRequest($this->getRequest())->setContinueOnNoEffect(true)->setContinueOnMissingFields(true);
     $task_names = array();
     $merge_into_name = 'T' . $task->getID();
     $cc_vector = array();
     $cc_vector[] = $task->getCCPHIDs();
     foreach ($targets as $target) {
         $cc_vector[] = $target->getCCPHIDs();
         $cc_vector[] = array($target->getAuthorPHID(), $target->getOwnerPHID());
         $close_task = id(new ManiphestTransaction())->setTransactionType(ManiphestTransaction::TYPE_STATUS)->setNewValue(ManiphestTaskStatus::getDuplicateStatus());
         $merge_comment = id(new ManiphestTransaction())->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)->attachComment(id(new ManiphestTransactionComment())->setContent("✘ Merged into {$merge_into_name}."));
         $editor->applyTransactions($target, array($close_task, $merge_comment));
         $task_names[] = 'T' . $target->getID();
     }
     $all_ccs = array_mergev($cc_vector);
     $all_ccs = array_filter($all_ccs);
     $all_ccs = array_unique($all_ccs);
     $task_names = implode(', ', $task_names);
     $add_ccs = id(new ManiphestTransaction())->setTransactionType(ManiphestTransaction::TYPE_CCS)->setNewValue($all_ccs);
     $merged_comment = id(new ManiphestTransaction())->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)->attachComment(id(new ManiphestTransactionComment())->setContent("◀ Merged tasks: {$task_names}."));
     $editor->applyTransactions($task, array($add_ccs, $merged_comment));
     return $response;
 }
예제 #9
0
 private function getColumnMap(ManiphestTask $task)
 {
     $phid = $task->getPHID();
     if (!$phid) {
         return array();
     }
     $board_phids = PhabricatorEdgeQuery::loadDestinationPHIDs($phid, PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
     if (!$board_phids) {
         return array();
     }
     $viewer = $this->getViewer();
     $layout_engine = id(new PhabricatorBoardLayoutEngine())->setViewer($viewer)->setBoardPHIDs($board_phids)->setObjectPHIDs(array($task->getPHID()))->executeLayout();
     $map = array();
     foreach ($board_phids as $board_phid) {
         $in_columns = $layout_engine->getObjectColumns($board_phid, $phid);
         $in_columns = mpull($in_columns, null, 'getPHID');
         $all_columns = $layout_engine->getColumns($board_phid);
         if (!$all_columns) {
             // This could be a project with no workboard, or a project the viewer
             // does not have permission to see.
             continue;
         }
         $board = head($all_columns)->getProject();
         $options = array();
         foreach ($all_columns as $column) {
             $name = $column->getDisplayName();
             $is_hidden = $column->isHidden();
             $is_selected = isset($in_columns[$column->getPHID()]);
             // Don't show hidden, subproject or milestone columns in this map
             // unless the object is currently in the column.
             $skip_column = $is_hidden || $column->getProxyPHID();
             if ($skip_column) {
                 if (!$is_selected) {
                     continue;
                 }
             }
             if ($is_hidden) {
                 $name = pht('(%s)', $name);
             }
             if ($is_selected) {
                 $name = pht("● %s", $name);
             } else {
                 $name = pht("○ %s", $name);
             }
             $option = array('key' => $column->getPHID(), 'label' => $name, 'selected' => (bool) $is_selected);
             $options[] = $option;
         }
         $map[] = array('label' => $board->getDisplayName(), 'options' => $options);
     }
     $map = isort($map, 'label');
     $map = array_values($map);
     return $map;
 }
예제 #10
0
 private function buildCardResponse(ManiphestTask $task)
 {
     $controller = $this->getController();
     $request = $controller->getRequest();
     $viewer = $request->getViewer();
     $column_phid = $request->getStr('columnPHID');
     $order = $request->getStr('order');
     $column = id(new PhabricatorProjectColumnQuery())->setViewer($viewer)->withPHIDs(array($column_phid))->executeOne();
     if (!$column) {
         return new Aphront404Response();
     }
     // If the workboard's project and all descendant projects have been removed
     // from the card's project list, we are going to remove it from the board
     // completely.
     // TODO: If the user did something sneaky and changed a subproject, we'll
     // currently leave the card where it was but should really move it to the
     // proper new column.
     $board_phid = $column->getProjectPHID();
     $descendant_projects = id(new PhabricatorProjectQuery())->setViewer($viewer)->withAncestorProjectPHIDs(array($column->getProjectPHID()))->execute();
     $board_phids = mpull($descendant_projects, 'getPHID', 'getPHID');
     $board_phids[$board_phid] = $board_phid;
     $project_map = array_fuse($task->getProjectPHIDs());
     $remove_card = !array_intersect_key($board_phids, $project_map);
     // TODO: Maybe the caller should pass a list of visible task PHIDs so we
     // know which ones we need to reorder? This is a HUGE overfetch.
     $objects = id(new ManiphestTaskQuery())->setViewer($viewer)->withEdgeLogicPHIDs(PhabricatorProjectObjectHasProjectEdgeType::EDGECONST, PhabricatorQueryConstraint::OPERATOR_ANCESTOR, array($board_phids))->setViewer($viewer)->execute();
     $objects = mpull($objects, null, 'getPHID');
     $layout_engine = id(new PhabricatorBoardLayoutEngine())->setViewer($viewer)->setBoardPHIDs(array($board_phid))->setObjectPHIDs(array_keys($objects))->executeLayout();
     $positions = $layout_engine->getColumnObjectPositions($board_phid, $column_phid);
     $column_phids = $layout_engine->getColumnObjectPHIDs($board_phid, $column_phid);
     $column_tasks = array_select_keys($objects, $column_phids);
     if ($order == PhabricatorProjectColumn::ORDER_NATURAL) {
         // TODO: This is a little bit awkward, because PHP and JS use
         // slightly different sort order parameters to achieve the same
         // effect. It would be good to unify this a bit at some point.
         $sort_map = array();
         foreach ($positions as $position) {
             $sort_map[$position->getObjectPHID()] = array(-$position->getSequence(), $position->getID());
         }
     } else {
         $sort_map = mpull($column_tasks, 'getPrioritySortVector', 'getPHID');
     }
     $data = array('removeFromBoard' => $remove_card, 'sortMap' => $sort_map);
     $rendering_engine = id(new PhabricatorBoardRenderingEngine())->setViewer($viewer)->setObjects(array($task))->setExcludedProjectPHIDs($board_phids);
     $card = $rendering_engine->renderCard($task->getPHID());
     $item = $card->getItem();
     $item->addClass('phui-workcard');
     $payload = array('tasks' => $item, 'data' => $data);
     return id(new AphrontAjaxResponse())->setContent(array('tasks' => $item, 'data' => $data));
 }
 private function performMerge(ManiphestTask $task, PhabricatorObjectHandle $handle, array $phids)
 {
     $user = $this->getRequest()->getUser();
     $response = id(new AphrontReloadResponse())->setURI($handle->getURI());
     $phids = array_fill_keys($phids, true);
     unset($phids[$task->getPHID()]);
     // Prevent merging a task into itself.
     if (!$phids) {
         return $response;
     }
     $targets = id(new ManiphestTask())->loadAllWhere('phid in (%Ls) ORDER BY id ASC', array_keys($phids));
     if (empty($targets)) {
         return $response;
     }
     $editor = new ManiphestTransactionEditor();
     $task_names = array();
     $merge_into_name = 'T' . $task->getID();
     $cc_vector = array();
     $cc_vector[] = $task->getCCPHIDs();
     foreach ($targets as $target) {
         $cc_vector[] = $target->getCCPHIDs();
         $cc_vector[] = array($target->getAuthorPHID(), $target->getOwnerPHID());
         $close_task = id(new ManiphestTransaction())->setAuthorPHID($user->getPHID())->setTransactionType(ManiphestTransactionType::TYPE_STATUS)->setNewValue(ManiphestTaskStatus::STATUS_CLOSED_DUPLICATE)->setComments("✘ Merged into {$merge_into_name}.");
         $editor->applyTransactions($target, array($close_task));
         $task_names[] = 'T' . $target->getID();
     }
     $all_ccs = array_mergev($cc_vector);
     $all_ccs = array_filter($all_ccs);
     $all_ccs = array_unique($all_ccs);
     $task_names = implode(', ', $task_names);
     $add_ccs = id(new ManiphestTransaction())->setAuthorPHID($user->getPHID())->setTransactionType(ManiphestTransactionType::TYPE_CCS)->setNewValue($all_ccs)->setComments("◀ Merged tasks: {$task_names}.");
     $editor->applyTransactions($task, array($add_ccs));
     return $response;
 }
 private function getTaskProjects(ManiphestTask $task)
 {
     $project_phids = PhabricatorEdgeQuery::loadDestinationPHIDs($task->getPHID(), PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
     sort($project_phids);
     return $project_phids;
 }
 private function buildActionView(ManiphestTask $task)
 {
     $viewer = $this->getRequest()->getUser();
     $id = $task->getID();
     $phid = $task->getPHID();
     $can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $task, PhabricatorPolicyCapability::CAN_EDIT);
     $can_create = $viewer->isLoggedIn();
     $view = id(new PhabricatorActionListView())->setUser($viewer)->setObject($task)->setObjectURI($this->getRequest()->getRequestURI());
     $view->addAction(id(new PhabricatorActionView())->setName(pht('Edit Task'))->setIcon('fa-pencil')->setHref($this->getApplicationURI("/task/edit/{$id}/"))->setDisabled(!$can_edit)->setWorkflow(!$can_edit));
     $view->addAction(id(new PhabricatorActionView())->setName(pht('Merge Duplicates In'))->setHref("/search/attach/{$phid}/TASK/merge/")->setWorkflow(true)->setIcon('fa-compress')->setDisabled(!$can_edit)->setWorkflow(true));
     $view->addAction(id(new PhabricatorActionView())->setName(pht('Create Subtask'))->setHref($this->getApplicationURI("/task/create/?parent={$id}"))->setIcon('fa-level-down')->setDisabled(!$can_create)->setWorkflow(!$can_create));
     $view->addAction(id(new PhabricatorActionView())->setName(pht('Edit Blocking Tasks'))->setHref("/search/attach/{$phid}/TASK/blocks/")->setWorkflow(true)->setIcon('fa-link')->setDisabled(!$can_edit)->setWorkflow(true));
     return $view;
 }
예제 #14
0
 private function buildCardResponse(ManiphestTask $task)
 {
     $controller = $this->getController();
     $request = $controller->getRequest();
     $viewer = $request->getViewer();
     $column_phid = $request->getStr('columnPHID');
     $visible_phids = $request->getStrList('visiblePHIDs');
     if (!$visible_phids) {
         $visible_phids = array();
     }
     $column = id(new PhabricatorProjectColumnQuery())->setViewer($viewer)->withPHIDs(array($column_phid))->executeOne();
     if (!$column) {
         return new Aphront404Response();
     }
     $board_phid = $column->getProjectPHID();
     $object_phid = $task->getPHID();
     return id(new PhabricatorBoardResponseEngine())->setViewer($viewer)->setBoardPHID($board_phid)->setObjectPHID($object_phid)->setVisiblePHIDs($visible_phids)->buildResponse();
 }
 protected function newMergeIntoTransactions(ManiphestTask $task)
 {
     return array(id(new ManiphestTransaction())->setTransactionType(ManiphestTransaction::TYPE_MERGED_INTO)->setNewValue($task->getPHID()));
 }
 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();
 }
 protected function buildTaskInfoDictionary(ManiphestTask $task)
 {
     $results = $this->buildTaskInfoDictionaries(array($task));
     return idx($results, $task->getPHID());
 }
 public static function indexTask(ManiphestTask $task)
 {
     $doc = new PhabricatorSearchAbstractDocument();
     $doc->setPHID($task->getPHID());
     $doc->setDocumentType(PhabricatorPHIDConstants::PHID_TYPE_TASK);
     $doc->setDocumentTitle($task->getTitle());
     $doc->setDocumentCreated($task->getDateCreated());
     $doc->setDocumentModified($task->getDateModified());
     $doc->addField(PhabricatorSearchField::FIELD_BODY, $task->getDescription());
     $doc->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR, $task->getAuthorPHID(), PhabricatorPHIDConstants::PHID_TYPE_USER, $task->getDateCreated());
     if ($task->getStatus() == ManiphestTaskStatus::STATUS_OPEN) {
         $doc->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_OPEN, $task->getPHID(), PhabricatorPHIDConstants::PHID_TYPE_TASK, time());
     }
     $transactions = id(new ManiphestTransaction())->loadAllWhere('taskID = %d', $task->getID());
     $current_ccs = $task->getCCPHIDs();
     $touches = array();
     $owner = null;
     $ccs = array();
     foreach ($transactions as $transaction) {
         if ($transaction->hasComments()) {
             $doc->addField(PhabricatorSearchField::FIELD_COMMENT, $transaction->getComments());
         }
         $author = $transaction->getAuthorPHID();
         // Record the most recent time they touched this object.
         $touches[$author] = $transaction->getDateCreated();
         switch ($transaction->getTransactionType()) {
             case ManiphestTransactionType::TYPE_OWNER:
                 $owner = $transaction;
                 break;
             case ManiphestTransactionType::TYPE_CCS:
                 // For users who are still CC'd, record the first time they were
                 // added to CC.
                 foreach ($transaction->getNewValue() as $added_cc) {
                     if (in_array($added_cc, $current_ccs)) {
                         if (empty($ccs[$added_cc])) {
                             $ccs[$added_cc] = $transaction->getDateCreated();
                         }
                     }
                 }
                 break;
         }
     }
     foreach ($task->getProjectPHIDs() as $phid) {
         $doc->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_PROJECT, $phid, PhabricatorPHIDConstants::PHID_TYPE_PROJ, $task->getDateModified());
         // Bogus.
     }
     if ($owner && $owner->getNewValue()) {
         $doc->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_OWNER, $owner->getNewValue(), PhabricatorPHIDConstants::PHID_TYPE_USER, $owner->getDateCreated());
     } else {
         $doc->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_OWNER, ManiphestTaskOwner::OWNER_UP_FOR_GRABS, PhabricatorPHIDConstants::PHID_TYPE_MAGIC, $owner ? $owner->getDateCreated() : $task->getDateCreated());
     }
     foreach ($touches as $touch => $time) {
         $doc->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_TOUCH, $touch, PhabricatorPHIDConstants::PHID_TYPE_USER, $time);
     }
     // We need to load handles here since non-users may subscribe (mailing
     // lists, e.g.)
     $handles = id(new PhabricatorObjectHandleData(array_keys($ccs)))->loadHandles();
     foreach ($ccs as $cc => $time) {
         $doc->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_SUBSCRIBER, $handles[$cc]->getPHID(), $handles[$cc]->getType(), $time);
     }
     self::reindexAbstractDocument($doc);
 }
 private function buildActionView(ManiphestTask $task)
 {
     $viewer = $this->getRequest()->getUser();
     $viewer_phid = $viewer->getPHID();
     $viewer_is_cc = in_array($viewer_phid, $task->getCCPHIDs());
     $id = $task->getID();
     $phid = $task->getPHID();
     $can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $task, PhabricatorPolicyCapability::CAN_EDIT);
     $view = id(new PhabricatorActionListView())->setUser($viewer)->setObject($task)->setObjectURI($this->getRequest()->getRequestURI());
     $view->addAction(id(new PhabricatorActionView())->setName(pht('Edit Task'))->setIcon('fa-pencil')->setHref($this->getApplicationURI("/task/edit/{$id}/"))->setDisabled(!$can_edit)->setWorkflow(!$can_edit));
     if ($task->getOwnerPHID() === $viewer_phid) {
         $view->addAction(id(new PhabricatorActionView())->setName(pht('Automatically Subscribed'))->setDisabled(true)->setIcon('fa-check-circle'));
     } else {
         $action = $viewer_is_cc ? 'rem' : 'add';
         $name = $viewer_is_cc ? pht('Unsubscribe') : pht('Subscribe');
         $icon = $viewer_is_cc ? 'fa-minus-circle' : 'fa-plus-circle';
         $view->addAction(id(new PhabricatorActionView())->setName($name)->setHref("/maniphest/subscribe/{$action}/{$id}/")->setRenderAsForm(true)->setUser($viewer)->setIcon($icon));
     }
     $view->addAction(id(new PhabricatorActionView())->setName(pht('Merge Duplicates In'))->setHref("/search/attach/{$phid}/TASK/merge/")->setWorkflow(true)->setIcon('fa-compress')->setDisabled(!$can_edit)->setWorkflow(true));
     $view->addAction(id(new PhabricatorActionView())->setName(pht('Create Subtask'))->setHref($this->getApplicationURI("/task/create/?parent={$id}"))->setIcon('fa-level-down'));
     $view->addAction(id(new PhabricatorActionView())->setName(pht('Edit Blocking Tasks'))->setHref("/search/attach/{$phid}/TASK/blocks/")->setWorkflow(true)->setIcon('fa-link')->setDisabled(!$can_edit)->setWorkflow(true));
     return $view;
 }