public function loadStatus(PhabricatorUser $user) { $status = array(); $query = id(new ManiphestTaskQuery())->setViewer($user)->withStatuses(ManiphestTaskStatus::getOpenStatusConstants())->withOwners(array($user->getPHID())); $count = count($query->execute()); $type = PhabricatorApplicationStatusView::TYPE_WARNING; $status[] = id(new PhabricatorApplicationStatusView())->setType($type)->setText(pht('%s Assigned Task(s)', new PhutilNumber($count)))->setCount($count); return $status; }
private function renderUserItems(PhutilEvent $event) { if (!$this->canUseApplication($event->getUser())) { return null; } $user = $event->getValue('object'); $phid = $user->getPHID(); $view_uri = sprintf('/maniphest/?statuses=%s&assigned=%s#R', implode(',', ManiphestTaskStatus::getOpenStatusConstants()), $phid); return id(new PhabricatorActionView())->setIcon('fa-anchor')->setName(pht('View Tasks'))->setHref($view_uri); }
public function loadStatus(PhabricatorUser $user) { $status = array(); if (!$user->isLoggedIn()) { return $status; } $query = id(new ManiphestTaskQuery())->setViewer($user)->withStatuses(ManiphestTaskStatus::getOpenStatusConstants())->withOwners(array($user->getPHID()))->setLimit(self::MAX_STATUS_ITEMS); $count = count($query->execute()); $count_str = self::formatStatusCount($count, '%s Assigned Tasks', '%d Assigned Task(s)'); $type = PhabricatorApplicationStatusView::TYPE_WARNING; $status[] = id(new PhabricatorApplicationStatusView())->setType($type)->setText($count_str)->setCount($count); return $status; }
protected function execute(ConduitAPIRequest $request) { $results = array('defaultStatus' => ManiphestTaskStatus::getDefaultStatus(), 'defaultClosedStatus' => ManiphestTaskStatus::getDefaultClosedStatus(), 'duplicateStatus' => ManiphestTaskStatus::getDuplicateStatus(), 'openStatuses' => ManiphestTaskStatus::getOpenStatusConstants(), 'closedStatuses' => ManiphestTaskStatus::getClosedStatusConstants(), 'allStatuses' => array_keys(ManiphestTaskStatus::getTaskStatusMap()), 'statusMap' => ManiphestTaskStatus::getTaskStatusMap()); return $results; }
/** * Load all the tasks that have been recently closed. */ private function loadRecentlyClosedTasks() { list($ignored, $window_epoch) = $this->getWindow(); $table = new ManiphestTask(); $xtable = new ManiphestTransaction(); $conn_r = $table->establishConnection('r'); // TODO: Gross. This table is not meant to be queried like this. Build // real stats tables. $open_status_list = array(); foreach (ManiphestTaskStatus::getOpenStatusConstants() as $constant) { $open_status_list[] = json_encode((string) $constant); } $rows = queryfx_all($conn_r, 'SELECT t.id FROM %T t JOIN %T x ON x.objectPHID = t.phid WHERE t.status NOT IN (%Ls) AND x.oldValue IN (null, %Ls) AND x.newValue NOT IN (%Ls) AND t.dateModified >= %d AND x.dateCreated >= %d', $table->getTableName(), $xtable->getTableName(), ManiphestTaskStatus::getOpenStatusConstants(), $open_status_list, $open_status_list, $window_epoch, $window_epoch); if (!$rows) { return array(); } $ids = ipull($rows, 'id'); $query = id(new ManiphestTaskQuery())->setViewer($this->getRequest()->getUser())->withIDs($ids); switch ($this->view) { case 'project': $query->needProjectPHIDs(true); break; } return $query->execute(); }
private function buildTasksPanel() { $user = $this->getRequest()->getUser(); $user_phid = $user->getPHID(); $task_query = id(new ManiphestTaskQuery())->setViewer($user)->withStatuses(ManiphestTaskStatus::getOpenStatusConstants())->setGroupBy(ManiphestTaskQuery::GROUP_PRIORITY)->withOwners(array($user_phid))->setLimit(10); $tasks = $task_query->execute(); if (!$tasks) { return $this->renderMiniPanel('No Assigned Tasks', 'You have no assigned tasks.'); } $title = pht('Assigned Tasks'); $href = '/maniphest'; $panel = new AphrontPanelView(); $panel->setHeader($this->renderSectionHeader($title, $href)); $panel->appendChild($this->buildTaskListView($tasks)); $panel->setNoBackground(); return $panel; }
private function buildTasksPanel() { $user = $this->getRequest()->getUser(); $user_phid = $user->getPHID(); $task_query = id(new ManiphestTaskQuery())->setViewer($user)->withStatuses(ManiphestTaskStatus::getOpenStatusConstants())->setGroupBy(ManiphestTaskQuery::GROUP_PRIORITY)->withOwners(array($user_phid))->needProjectPHIDs(true)->setLimit(10); $tasks = $task_query->execute(); if (!$tasks) { return $this->renderMiniPanel(pht('No Assigned Tasks'), pht('You have no assigned tasks.')); } $title = pht('Assigned Tasks'); $href = '/maniphest/query/assigned/'; $panel = new PHUIObjectBoxView(); $panel->setHeader($this->renderSectionHeader($title, $href)); $panel->setObjectList($this->buildTaskListView($tasks)); return $panel; }
public function buildSavedQueryFromBuiltin($query_key) { $query = $this->newSavedQuery(); $query->setQueryKey($query_key); $viewer_phid = $this->requireViewer()->getPHID(); switch ($query_key) { case 'all': return $query; case 'assigned': return $query->setParameter('assignedPHIDs', array($viewer_phid))->setParameter('statuses', ManiphestTaskStatus::getOpenStatusConstants()); case 'subscribed': return $query->setParameter('subscriberPHIDs', array($viewer_phid))->setParameter('statuses', ManiphestTaskStatus::getOpenStatusConstants()); case 'open': return $query->setParameter('statuses', ManiphestTaskStatus::getOpenStatusConstants()); case 'authored': return $query->setParameter('authorPHIDs', array($viewer_phid))->setParameter('order', 'created')->setParameter('group', 'none'); } return parent::buildSavedQueryFromBuiltin($query_key); }
private function buildDependenciesWhereClause(AphrontDatabaseConnection $conn) { if (!$this->shouldJoinBlockedTasks() && !$this->shouldJoinBlockingTasks()) { return null; } $parts = array(); if ($this->blockingTasks === true) { $parts[] = qsprintf($conn, 'blocking.dst IS NOT NULL AND blockingtask.status IN (%Ls)', ManiphestTaskStatus::getOpenStatusConstants()); } else { if ($this->blockingTasks === false) { $parts[] = qsprintf($conn, 'blocking.dst IS NULL OR blockingtask.status NOT IN (%Ls)', ManiphestTaskStatus::getOpenStatusConstants()); } } if ($this->blockedTasks === true) { $parts[] = qsprintf($conn, 'blocked.dst IS NOT NULL AND blockedtask.status IN (%Ls)', ManiphestTaskStatus::getOpenStatusConstants()); } else { if ($this->blockedTasks === false) { $parts[] = qsprintf($conn, 'blocked.dst IS NULL OR blockedtask.status NOT IN (%Ls)', ManiphestTaskStatus::getOpenStatusConstants()); } } return '(' . implode(') OR (', $parts) . ')'; }
private function buildStatusWhereClause(AphrontDatabaseConnection $conn) { static $map = array(self::STATUS_RESOLVED => ManiphestTaskStatus::STATUS_CLOSED_RESOLVED, self::STATUS_WONTFIX => ManiphestTaskStatus::STATUS_CLOSED_WONTFIX, self::STATUS_INVALID => ManiphestTaskStatus::STATUS_CLOSED_INVALID, self::STATUS_SPITE => ManiphestTaskStatus::STATUS_CLOSED_SPITE, self::STATUS_DUPLICATE => ManiphestTaskStatus::STATUS_CLOSED_DUPLICATE); switch ($this->status) { case self::STATUS_ANY: return null; case self::STATUS_OPEN: return qsprintf($conn, 'status IN (%Ls)', ManiphestTaskStatus::getOpenStatusConstants()); case self::STATUS_CLOSED: return qsprintf($conn, 'status IN (%Ls)', ManiphestTaskStatus::getClosedStatusConstants()); default: $constant = idx($map, $this->status); if (!$constant) { throw new Exception("Unknown status query '{$this->status}'!"); } return qsprintf($conn, 'status = %s', $constant); } }
private function renderTasksPage(PhabricatorProject $project) { $user = $this->getRequest()->getUser(); $query = id(new ManiphestTaskQuery())->setViewer($user)->withAnyProjects(array($project->getPHID()))->withStatuses(ManiphestTaskStatus::getOpenStatusConstants())->setOrderBy(ManiphestTaskQuery::ORDER_PRIORITY)->setLimit(10); $tasks = $query->execute(); $phids = mpull($tasks, 'getOwnerPHID'); $phids = array_merge($phids, array_mergev(mpull($tasks, 'getProjectPHIDs'))); $phids = array_filter($phids); $handles = $this->loadViewerHandles($phids); $task_list = new ManiphestTaskListView(); $task_list->setUser($user); $task_list->setTasks($tasks); $task_list->setHandles($handles); $phid = $project->getPHID(); $view_uri = urisprintf('/maniphest/?statuses=%s&allProjects=%s#R', implode(',', ManiphestTaskStatus::getOpenStatusConstants()), $phid); $create_uri = '/maniphest/task/create/?projects=' . $phid; $icon = id(new PHUIIconView())->setIconFont('fa-list'); $button_view = id(new PHUIButtonView())->setTag('a')->setText(pht('View All'))->setHref($view_uri)->setIcon($icon); $icon_new = id(new PHUIIconView())->setIconFont('fa-plus'); $button_add = id(new PHUIButtonView())->setTag('a')->setText(pht('New Task'))->setHref($create_uri)->setIcon($icon_new); $header = id(new PHUIHeaderView())->setHeader(pht('Open Tasks'))->addActionLink($button_add)->addActionLink($button_view); $content = id(new PHUIObjectBoxView())->setHeader($header)->appendChild($task_list); return $content; }
protected function buildJoinClauseParts(AphrontDatabaseConnection $conn) { $open_statuses = ManiphestTaskStatus::getOpenStatusConstants(); $edge_table = PhabricatorEdgeConfig::TABLE_NAME_EDGE; $task_table = $this->newResultObject()->getTableName(); $parent_type = ManiphestTaskDependedOnByTaskEdgeType::EDGECONST; $subtask_type = ManiphestTaskDependsOnTaskEdgeType::EDGECONST; $joins = array(); if ($this->hasOpenParents !== null) { if ($this->hasOpenParents) { $join_type = 'JOIN'; } else { $join_type = 'LEFT JOIN'; } $joins[] = qsprintf($conn, '%Q %T e_parent ON e_parent.src = task.phid AND e_parent.type = %d %Q %T parent ON e_parent.dst = parent.phid AND parent.status IN (%Ls)', $join_type, $edge_table, $parent_type, $join_type, $task_table, $open_statuses); } if ($this->hasOpenSubtasks !== null) { if ($this->hasOpenSubtasks) { $join_type = 'JOIN'; } else { $join_type = 'LEFT JOIN'; } $joins[] = qsprintf($conn, '%Q %T e_subtask ON e_subtask.src = task.phid AND e_subtask.type = %d %Q %T subtask ON e_subtask.dst = subtask.phid AND subtask.status IN (%Ls)', $join_type, $edge_table, $subtask_type, $join_type, $task_table, $open_statuses); } if ($this->subscriberPHIDs !== null) { $joins[] = qsprintf($conn, 'JOIN %T e_ccs ON e_ccs.src = task.phid ' . 'AND e_ccs.type = %s ' . 'AND e_ccs.dst in (%Ls)', PhabricatorEdgeConfig::TABLE_NAME_EDGE, PhabricatorObjectHasSubscriberEdgeType::EDGECONST, $this->subscriberPHIDs); } switch ($this->groupBy) { case self::GROUP_PROJECT: $ignore_group_phids = $this->getIgnoreGroupedProjectPHIDs(); if ($ignore_group_phids) { $joins[] = qsprintf($conn, 'LEFT JOIN %T projectGroup ON task.phid = projectGroup.src AND projectGroup.type = %d AND projectGroup.dst NOT IN (%Ls)', $edge_table, PhabricatorProjectObjectHasProjectEdgeType::EDGECONST, $ignore_group_phids); } else { $joins[] = qsprintf($conn, 'LEFT JOIN %T projectGroup ON task.phid = projectGroup.src AND projectGroup.type = %d', $edge_table, PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); } $joins[] = qsprintf($conn, 'LEFT JOIN %T projectGroupName ON projectGroup.dst = projectGroupName.indexedObjectPHID', id(new ManiphestNameIndex())->getTableName()); break; } if ($this->parentTaskIDs !== null) { $joins[] = qsprintf($conn, 'JOIN %T e_has_parent ON e_has_parent.src = task.phid AND e_has_parent.type = %d JOIN %T has_parent ON e_has_parent.dst = has_parent.phid AND has_parent.id IN (%Ld)', $edge_table, $parent_type, $task_table, $this->parentTaskIDs); } if ($this->subtaskIDs !== null) { $joins[] = qsprintf($conn, 'JOIN %T e_has_subtask ON e_has_subtask.src = task.phid AND e_has_subtask.type = %d JOIN %T has_subtask ON e_has_subtask.dst = has_subtask.phid AND has_subtask.id IN (%Ld)', $edge_table, $subtask_type, $task_table, $this->subtaskIDs); } $joins[] = parent::buildJoinClauseParts($conn); return $joins; }
private function openStatusQuery($viewer) { $query = id(new ManiphestTaskQuery())->setViewer($viewer)->needProjectPHIDs(true)->withStatuses(ManiphestTaskStatus::getOpenStatusConstants()); return $query; }