diff --git a/src/applications/maniphest/controller/taskdetail/ManiphestTaskDetailController.php b/src/applications/maniphest/controller/taskdetail/ManiphestTaskDetailController.php index 08fec31400..5f7140ce83 100644 --- a/src/applications/maniphest/controller/taskdetail/ManiphestTaskDetailController.php +++ b/src/applications/maniphest/controller/taskdetail/ManiphestTaskDetailController.php @@ -1,240 +1,240 @@ <?php /* * Copyright 2011 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ class ManiphestTaskDetailController extends ManiphestController { private $id; public function willProcessRequest(array $data) { $this->id = $data['id']; } public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); $e_title = null; $priority_map = ManiphestTaskPriority::getTaskPriorityMap(); $task = id(new ManiphestTask())->load($this->id); $transactions = id(new ManiphestTransaction())->loadAllWhere( 'taskID = %d', $task->getID()); $phids = array(); foreach ($transactions as $transaction) { foreach ($transaction->extractPHIDs() as $phid) { $phids[$phid] = true; } } foreach ($task->getCCPHIDs() as $phid) { $phids[$phid] = true; } if ($task->getOwnerPHID()) { $phids[$task->getOwnerPHID()] = true; } $phids[$task->getAuthorPHID()] = true; $phids = array_keys($phids); $handles = id(new PhabricatorObjectHandleData($phids)) ->loadHandles(); $factory = new DifferentialMarkupEngineFactory(); $engine = $factory->newDifferentialCommentMarkupEngine(); $dict = array(); $dict['Status'] = '<strong>'. ManiphestTaskStatus::getTaskStatusFullName($task->getStatus()). '</strong>'; $dict['Assigned To'] = $task->getOwnerPHID() ? $handles[$task->getOwnerPHID()]->renderLink() : '<em>None</em>'; $dict['Priority'] = ManiphestTaskPriority::getTaskPriorityName( $task->getPriority()); $cc = $task->getCCPHIDs(); if ($cc) { $cc_links = array(); foreach ($cc as $phid) { $cc_links[] = $handles[$phid]->renderLink(); } $dict['CC'] = implode(', ', $cc_links); } else { $dict['CC'] = '<em>None</em>'; } $dict['Author'] = $handles[$task->getAuthorPHID()]->renderLink(); $dict['Description'] = '<div class="maniphest-task-description">'. '<div class="phabricator-remarkup">'. $engine->markupText($task->getDescription()). '</div>'. '</div>'; require_celerity_resource('mainphest-task-detail-css'); $table = array(); foreach ($dict as $key => $value) { $table[] = '<tr>'. '<th>'.phutil_escape_html($key).':</th>'. '<td>'.$value.'</td>'. '</tr>'; } $table = '<table class="maniphest-task-properties">'. implode("\n", $table). '</table>'; $panel = '<div class="maniphest-panel">'. '<div class="maniphest-task-detail-core">'. '<h1>'. phutil_escape_html('T'.$task->getID().' '.$task->getTitle()). '</h1>'. $table. '</div>'. '</div>'; $transaction_types = ManiphestTransactionType::getTransactionTypeMap(); $resolution_types = ManiphestTaskStatus::getTaskStatusMap(); if ($task->getStatus() == ManiphestTaskStatus::STATUS_OPEN) { $resolution_types = array_select_keys( $resolution_types, array( ManiphestTaskStatus::STATUS_CLOSED_RESOLVED, ManiphestTaskStatus::STATUS_CLOSED_WONTFIX, ManiphestTaskStatus::STATUS_CLOSED_INVALID, ManiphestTaskStatus::STATUS_CLOSED_SPITE, )); } else { $resolution_types = array( ManiphestTaskStatus::STATUS_OPEN => 'Reopened', ); $transaction_types[ManiphestTransactionType::TYPE_STATUS] = 'Reopen Task'; unset($transaction_types[ManiphestTransactionType::TYPE_PRIORITY]); unset($transaction_types[ManiphestTransactionType::TYPE_OWNER]); } $default_claim = array( $user->getPHID() => $user->getUsername().' ('.$user->getRealName().')', ); $comment_form = new AphrontFormView(); $comment_form ->setUser($user) ->setAction('/maniphest/transaction/save/') ->addHiddenInput('taskID', $task->getID()) ->appendChild( id(new AphrontFormSelectControl()) ->setLabel('Action') ->setName('action') ->setOptions($transaction_types) ->setID('transaction-action')) ->appendChild( id(new AphrontFormSelectControl()) ->setLabel('Resolution') ->setName('resolution') ->setControlID('resolution') ->setControlStyle('display: none') ->setOptions($resolution_types)) ->appendChild( id(new AphrontFormTokenizerControl()) ->setLabel('Assign To') ->setName('assign_to') ->setControlID('assign_to') ->setControlStyle('display: none') ->setID('assign-tokenizer') ->setDisableBehavior(true)) ->appendChild( id(new AphrontFormTokenizerControl()) ->setLabel('CCs') ->setName('ccs') ->setControlID('ccs') ->setControlStyle('display: none') ->setID('cc-tokenizer') ->setDisableBehavior(true)) ->appendChild( id(new AphrontFormSelectControl()) ->setLabel('Priority') ->setName('priority') ->setOptions($priority_map) ->setControlID('priority') ->setControlStyle('display: none') ->setValue($task->getPriority())) ->appendChild( id(new AphrontFormTextAreaControl()) ->setLabel('Comments') ->setName('comments') ->setValue('')) ->appendChild( id(new AphrontFormSubmitControl()) ->setValue('Avast!')); Javelin::initBehavior('maniphest-transaction-controls', array( 'select' => 'transaction-action', 'controlMap' => array( ManiphestTransactionType::TYPE_STATUS => 'resolution', ManiphestTransactionType::TYPE_OWNER => 'assign_to', ManiphestTransactionType::TYPE_CCS => 'ccs', ManiphestTransactionType::TYPE_PRIORITY => 'priority', ), 'tokenizers' => array( ManiphestTransactionType::TYPE_OWNER => array( 'id' => 'assign-tokenizer', 'src' => '/typeahead/common/users/', 'value' => $default_claim, 'limit' => 1, ), ManiphestTransactionType::TYPE_CCS => array( 'id' => 'cc-tokenizer', 'src' => '/typeahead/common/mailable/', ), ), )); $comment_panel = new AphrontPanelView(); $comment_panel->appendChild($comment_form); $comment_panel->setHeader('Leap Into Action'); $transaction_view = new ManiphestTransactionListView(); $transaction_view->setTransactions($transactions); $transaction_view->setHandles($handles); $transaction_view->setUser($user); $transaction_view->setMarkupEngine($engine); return $this->buildStandardPageResponse( array( $panel, $transaction_view, $comment_panel, ), array( - 'title' => 'Create Task', + 'title' => 'T'.$task->getID().' '.$task->getTitle(), )); } } diff --git a/src/applications/maniphest/controller/tasklist/ManiphestTaskListController.php b/src/applications/maniphest/controller/tasklist/ManiphestTaskListController.php index cc29ad47c7..2b18343edd 100644 --- a/src/applications/maniphest/controller/tasklist/ManiphestTaskListController.php +++ b/src/applications/maniphest/controller/tasklist/ManiphestTaskListController.php @@ -1,131 +1,130 @@ <?php /* * Copyright 2011 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ class ManiphestTaskListController extends ManiphestController { private $view; public function willProcessRequest(array $data) { $this->view = idx($data, 'view'); } public function processRequest() { $views = array( 'Your Tasks', 'action' => 'Action Required', // 'activity' => 'Recently Active', // 'closed' => 'Recently Closed', 'created' => 'Created', 'triage' => 'Need Triage', '<hr />', 'All Open Tasks', 'alltriage' => 'Need Triage', 'unassigned' => 'Unassigned', 'allopen' => 'All Open', - ); if (empty($views[$this->view])) { $this->view = 'action'; } $tasks = $this->loadTasks(); $nav = new AphrontSideNavView(); foreach ($views as $view => $name) { if (is_integer($view)) { $nav->addNavItem( phutil_render_tag( 'span', array(), $name)); } else { $nav->addNavItem( phutil_render_tag( 'a', array( 'href' => '/maniphest/view/'.$view.'/', 'class' => ($this->view == $view) ? 'aphront-side-nav-selected' : null, ), phutil_escape_html($name))); } } $handle_phids = mpull($tasks, 'getOwnerPHID'); $handles = id(new PhabricatorObjectHandleData($handle_phids)) ->loadHandles(); $task_list = new ManiphestTaskListView(); $task_list->setTasks($tasks); $task_list->setHandles($handles); $nav->appendChild( '<div style="text-align: right; padding: 1em 1em 0;">'. '<a href="/maniphest/task/create/" class="green button">'. 'Create New Task'. '</a>'. '</div>'); $nav->appendChild($task_list); return $this->buildStandardPageResponse( $nav, array( 'title' => 'Task List', )); } private function loadTasks() { $request = $this->getRequest(); $user = $request->getUser(); $phids = array($user->getPHID()); switch ($this->view) { case 'action': return id(new ManiphestTask())->loadAllWhere( 'ownerPHID in (%Ls) AND status = 0', $phids); case 'created': return id(new ManiphestTask())->loadAllWhere( 'authorPHID in (%Ls) AND status = 0', $phids); case 'triage': return id(new ManiphestTask())->loadAllWhere( 'ownerPHID in (%Ls) and status = %d', $phids, ManiphestTaskPriority::PRIORITY_TRIAGE); case 'alltriage': return id(new ManiphestTask())->loadAllWhere( 'status = %d', ManiphestTaskPriority::PRIORITY_TRIAGE); case 'unassigned': return id(new ManiphestTask())->loadAllWhere( 'ownerPHID IS NULL'); case 'allopen': return id(new ManiphestTask())->loadAllWhere( 'status = 0'); } return array(); } } diff --git a/src/view/page/base/AphrontPageView.php b/src/view/page/base/AphrontPageView.php index 9df2f9ae5e..e853a3f790 100755 --- a/src/view/page/base/AphrontPageView.php +++ b/src/view/page/base/AphrontPageView.php @@ -1,81 +1,81 @@ <?php /* * Copyright 2011 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ class AphrontPageView extends AphrontView { private $title; public function setTitle($title) { $this->title = $title; return $this; } public function getTitle() { return $this->title; } protected function getHead() { return ''; } protected function getBody() { return $this->renderChildren(); } protected function getTail() { return ''; } protected function willRenderPage() { return; } protected function willSendResponse($response) { return $response; } public function render() { $this->willRenderPage(); - $title = $this->getTitle(); + $title = phutil_escape_html($this->getTitle()); $head = $this->getHead(); $body = $this->getBody(); $tail = $this->getTail(); $response = <<<EOHTML <!DOCTYPE html> <html> <head> <title>{$title}</title> {$head} </head> <body> {$body} </body> {$tail} </html> EOHTML; $response = $this->willSendResponse($response); return $response; } } diff --git a/src/view/page/base/__init__.php b/src/view/page/base/__init__.php index 6d56a9bb99..9eadbb1909 100644 --- a/src/view/page/base/__init__.php +++ b/src/view/page/base/__init__.php @@ -1,12 +1,14 @@ <?php /** * This file is automatically generated. Lint this module to rebuild it. * @generated */ phutil_require_module('phabricator', 'view/base'); +phutil_require_module('phutil', 'markup'); + phutil_require_source('AphrontPageView.php');