diff --git a/src/applications/maniphest/controller/ManiphestBatchEditController.php b/src/applications/maniphest/controller/ManiphestBatchEditController.php --- a/src/applications/maniphest/controller/ManiphestBatchEditController.php +++ b/src/applications/maniphest/controller/ManiphestBatchEditController.php @@ -3,7 +3,7 @@ final class ManiphestBatchEditController extends ManiphestController { public function handleRequest(AphrontRequest $request) { - $viewer = $this->getViewer(); + $viewer = $request->getViewer(); $this->requireApplicationCapability( ManiphestBulkEditCapability::CAPABILITY); diff --git a/src/applications/maniphest/controller/ManiphestExportController.php b/src/applications/maniphest/controller/ManiphestExportController.php --- a/src/applications/maniphest/controller/ManiphestExportController.php +++ b/src/applications/maniphest/controller/ManiphestExportController.php @@ -2,27 +2,20 @@ final class ManiphestExportController extends ManiphestController { - private $key; - - public function willProcessRequest(array $data) { - $this->key = $data['key']; - return $this; - } - /** * @phutil-external-symbol class PHPExcel * @phutil-external-symbol class PHPExcel_IOFactory * @phutil-external-symbol class PHPExcel_Style_NumberFormat * @phutil-external-symbol class PHPExcel_Cell_DataType */ - public function processRequest() { - $request = $this->getRequest(); - $user = $request->getUser(); + public function handleRequest(AphrontRequest $request) { + $viewer = $request->getViewer(); + $key = $request->getURIData('key'); $ok = @include_once 'PHPExcel.php'; if (!$ok) { $dialog = new AphrontDialogView(); - $dialog->setUser($user); + $dialog->setUser($viewer); $inst1 = pht( 'This system does not have PHPExcel installed. This software '. @@ -54,14 +47,14 @@ // for that here, since it fatals if we don't have the ZipArchive class. $saved = id(new PhabricatorSavedQueryQuery()) - ->setViewer($user) - ->withQueryKeys(array($this->key)) + ->setViewer($viewer) + ->withQueryKeys(array($key)) ->executeOne(); if (!$saved) { $engine = id(new ManiphestTaskSearchEngine()) - ->setViewer($user); - if ($engine->isBuiltinQuery($this->key)) { - $saved = $engine->buildSavedQueryFromBuiltin($this->key); + ->setViewer($viewer); + if ($engine->isBuiltinQuery($key)) { + $saved = $engine->buildSavedQueryFromBuiltin($key); } if (!$saved) { return new Aphront404Response(); @@ -76,7 +69,7 @@ if (!$request->isDialogFormPost()) { $dialog = new AphrontDialogView(); - $dialog->setUser($user); + $dialog->setUser($viewer); $dialog->setTitle(pht('Export Tasks to Excel')); $dialog->appendChild( @@ -108,22 +101,22 @@ $saved->setParameter('limit', PHP_INT_MAX); $engine = id(new ManiphestTaskSearchEngine()) - ->setViewer($user); + ->setViewer($viewer); $query = $engine->buildQueryFromSavedQuery($saved); - $query->setViewer($user); + $query->setViewer($viewer); $tasks = $query->execute(); $all_projects = array_mergev(mpull($tasks, 'getProjectPHIDs')); $all_assigned = mpull($tasks, 'getOwnerPHID'); $handles = id(new PhabricatorHandleQuery()) - ->setViewer($user) + ->setViewer($viewer) ->withPHIDs(array_merge($all_projects, $all_assigned)) ->execute(); $workbook = new PHPExcel(); - $format->buildWorkbook($workbook, $tasks, $handles, $user); + $format->buildWorkbook($workbook, $tasks, $handles, $viewer); $writer = PHPExcel_IOFactory::createWriter($workbook, 'Excel2007'); ob_start(); diff --git a/src/applications/maniphest/controller/ManiphestReportController.php b/src/applications/maniphest/controller/ManiphestReportController.php --- a/src/applications/maniphest/controller/ManiphestReportController.php +++ b/src/applications/maniphest/controller/ManiphestReportController.php @@ -4,13 +4,9 @@ private $view; - public function willProcessRequest(array $data) { - $this->view = idx($data, 'view'); - } - - public function processRequest() { - $request = $this->getRequest(); - $user = $request->getUser(); + public function handleRequest(AphrontRequest $request) { + $viewer = $request->getViewer(); + $this->view = $request->getURIData('view'); if ($request->isFormPost()) { $uri = $request->getRequestURI(); @@ -64,7 +60,7 @@ public function renderBurn() { $request = $this->getRequest(); - $user = $request->getUser(); + $viewer = $request->getUser(); $handle = null; @@ -132,7 +128,7 @@ $day_bucket = phabricator_format_local_time( $row['dateCreated'], - $user, + $viewer, 'Yz'); $day_buckets[$day_bucket] = $row['dateCreated']; if (empty($stats[$day_bucket])) { @@ -166,12 +162,12 @@ $week_bucket = phabricator_format_local_time( $epoch, - $user, + $viewer, 'YW'); if ($week_bucket != $last_week) { if ($week) { $rows[] = $this->formatBurnRow( - pht('Week of %s', phabricator_date($last_week_epoch, $user)), + pht('Week of %s', phabricator_date($last_week_epoch, $viewer)), $week); $rowc[] = 'week'; } @@ -182,12 +178,12 @@ $month_bucket = phabricator_format_local_time( $epoch, - $user, + $viewer, 'Ym'); if ($month_bucket != $last_month) { if ($month) { $rows[] = $this->formatBurnRow( - phabricator_format_local_time($last_month_epoch, $user, 'F, Y'), + phabricator_format_local_time($last_month_epoch, $viewer, 'F, Y'), $month); $rowc[] = 'month'; } @@ -196,7 +192,7 @@ $last_month_epoch = $epoch; } - $rows[] = $this->formatBurnRow(phabricator_date($epoch, $user), $info); + $rows[] = $this->formatBurnRow(phabricator_date($epoch, $viewer), $info); $rowc[] = null; $week['open'] += $info['open']; $week['close'] += $info['close']; @@ -315,10 +311,10 @@ private function renderReportFilters(array $tokens, $has_window) { $request = $this->getRequest(); - $user = $request->getUser(); + $viewer = $request->getUser(); $form = id(new AphrontFormView()) - ->setUser($user) + ->setUser($viewer) ->appendControl( id(new AphrontFormTokenizerControl()) ->setDatasource(new PhabricatorProjectDatasource()) @@ -390,11 +386,11 @@ public function renderOpenTasks() { $request = $this->getRequest(); - $user = $request->getUser(); + $viewer = $request->getUser(); $query = id(new ManiphestTaskQuery()) - ->setViewer($user) + ->setViewer($viewer) ->withStatuses(ManiphestTaskStatus::getOpenStatusConstants()); switch ($this->view) { @@ -420,7 +416,7 @@ $recently_closed = $this->loadRecentlyClosedTasks(); - $date = phabricator_date(time(), $user); + $date = phabricator_date(time(), $viewer); switch ($this->view) { case 'user': @@ -615,7 +611,7 @@ $cclass[] = 'n'; list($ignored, $window_epoch) = $this->getWindow(); - $edate = phabricator_datetime($window_epoch, $user); + $edate = phabricator_datetime($window_epoch, $viewer); $cname[] = javelin_tag( 'span', array( @@ -726,7 +722,7 @@ */ private function getWindow() { $request = $this->getRequest(); - $user = $request->getUser(); + $viewer = $request->getUser(); $window_str = $this->getRequest()->getStr('window', '12 AM 7 days ago'); @@ -736,7 +732,7 @@ // Do locale-aware parsing so that the user's timezone is assumed for // time windows like "3 PM", rather than assuming the server timezone. - $window_epoch = PhabricatorTime::parseLocalTime($window_str, $user); + $window_epoch = PhabricatorTime::parseLocalTime($window_str, $viewer); if (!$window_epoch) { $error = 'Invalid'; $window_epoch = time() - (60 * 60 * 24 * 7); diff --git a/src/applications/maniphest/controller/ManiphestSubpriorityController.php b/src/applications/maniphest/controller/ManiphestSubpriorityController.php --- a/src/applications/maniphest/controller/ManiphestSubpriorityController.php +++ b/src/applications/maniphest/controller/ManiphestSubpriorityController.php @@ -2,16 +2,15 @@ final class ManiphestSubpriorityController extends ManiphestController { - public function processRequest() { - $request = $this->getRequest(); - $user = $request->getUser(); + public function handleRequest(AphrontRequest $request) { + $viewer = $request->getViewer(); if (!$request->validateCSRF()) { return new Aphront403Response(); } $task = id(new ManiphestTaskQuery()) - ->setViewer($user) + ->setViewer($viewer) ->withIDs(array($request->getInt('task'))) ->needProjectPHIDs(true) ->requireCapabilities( @@ -26,7 +25,7 @@ if ($request->getInt('after')) { $after_task = id(new ManiphestTaskQuery()) - ->setViewer($user) + ->setViewer($viewer) ->withIDs(array($request->getInt('after'))) ->executeOne(); if (!$after_task) { @@ -52,7 +51,7 @@ ->setNewValue($sub); $editor = id(new ManiphestTransactionEditor()) - ->setActor($user) + ->setActor($viewer) ->setContinueOnMissingFields(true) ->setContinueOnNoEffect(true) ->setContentSourceFromRequest($request); diff --git a/src/applications/maniphest/controller/ManiphestTaskDetailController.php b/src/applications/maniphest/controller/ManiphestTaskDetailController.php --- a/src/applications/maniphest/controller/ManiphestTaskDetailController.php +++ b/src/applications/maniphest/controller/ManiphestTaskDetailController.php @@ -2,27 +2,21 @@ final class ManiphestTaskDetailController extends ManiphestController { - private $id; - public function shouldAllowPublic() { return true; } - public function willProcessRequest(array $data) { - $this->id = $data['id']; - } - - public function processRequest() { - $request = $this->getRequest(); - $user = $request->getUser(); + public function handleRequest(AphrontRequest $request) { + $viewer = $request->getViewer(); + $id = $request->getURIData('id'); $e_title = null; $priority_map = ManiphestTaskPriority::getTaskPriorityMap(); $task = id(new ManiphestTaskQuery()) - ->setViewer($user) - ->withIDs(array($this->id)) + ->setViewer($viewer) + ->withIDs(array($id)) ->needSubscriberPHIDs(true) ->executeOne(); if (!$task) { @@ -33,7 +27,7 @@ $parent_task = null; if ($workflow && is_numeric($workflow)) { $parent_task = id(new ManiphestTaskQuery()) - ->setViewer($user) + ->setViewer($viewer) ->withIDs(array($workflow)) ->executeOne(); } @@ -42,7 +36,7 @@ $task, PhabricatorCustomField::ROLE_VIEW); $field_list - ->setViewer($user) + ->setViewer($viewer) ->readFieldsFromStorage($task); $e_commit = ManiphestTaskHasCommitEdgeType::EDGECONST; @@ -83,7 +77,7 @@ } $phids = array_keys($phids); - $handles = $user->loadHandles($phids); + $handles = $viewer->loadHandles($phids); $info_view = null; if ($parent_task) { @@ -115,7 +109,7 @@ } $engine = new PhabricatorMarkupEngine(); - $engine->setViewer($user); + $engine->setViewer($viewer); $engine->setContextObject($task); $engine->addObject($task, ManiphestTask::MARKUP_FIELD_DESCRIPTION); @@ -169,12 +163,13 @@ } $default_claim = array( - $user->getPHID() => $user->getUsername().' ('.$user->getRealName().')', + $viewer->getPHID() => $viewer->getUsername(). + ' ('.$viewer->getRealName().')', ); $draft = id(new PhabricatorDraft())->loadOneWhere( 'authorPHID = %s AND draftKey = %s', - $user->getPHID(), + $viewer->getPHID(), $task->getPHID()); if ($draft) { $draft_text = $draft->getDraft(); @@ -188,7 +183,7 @@ $comment_form = new AphrontFormView(); $comment_form - ->setUser($user) + ->setUser($viewer) ->setWorkflow(true) ->setAction('/maniphest/transaction/save/') ->setEncType('multipart/form-data') @@ -249,12 +244,12 @@ ->setControlStyle('display: none')) ->appendChild( id(new PhabricatorRemarkupControl()) - ->setUser($user) + ->setUser($viewer) ->setLabel(pht('Comments')) ->setName('comments') ->setValue($draft_text) ->setID('transaction-comments') - ->setUser($user)) + ->setUser($viewer)) ->appendChild( id(new AphrontFormSubmitControl()) ->setValue(pht('Submit'))); @@ -288,7 +283,7 @@ ); // TODO: Initializing these behaviors for logged out users fatals things. - if ($user->isLoggedIn()) { + if ($viewer->isLoggedIn()) { Javelin::initBehavior('maniphest-transaction-controls', array( 'select' => 'transaction-action', 'controlMap' => $control_map, @@ -330,11 +325,11 @@ $task, $field_list, $edges, $actions, $handles); $description = $this->buildDescriptionView($task, $engine); - if (!$user->isLoggedIn()) { + if (!$viewer->isLoggedIn()) { // TODO: Eventually, everything should run through this. For now, we're // only using it to get a consistent "Login to Comment" button. $comment_box = id(new PhabricatorApplicationTransactionCommentView()) - ->setUser($user) + ->setUser($viewer) ->setRequestURI($request->getRequestURI()); $preview_panel = null; } else { diff --git a/src/applications/maniphest/controller/ManiphestTaskEditController.php b/src/applications/maniphest/controller/ManiphestTaskEditController.php --- a/src/applications/maniphest/controller/ManiphestTaskEditController.php +++ b/src/applications/maniphest/controller/ManiphestTaskEditController.php @@ -2,15 +2,9 @@ final class ManiphestTaskEditController extends ManiphestController { - private $id; - - public function willProcessRequest(array $data) { - $this->id = idx($data, 'id'); - } - - public function processRequest() { - $request = $this->getRequest(); - $user = $request->getUser(); + public function handleRequest(AphrontRequest $request) { + $viewer = $request->getViewer(); + $id = $request->getURIData('id'); $response_type = $request->getStr('responseType', 'task'); $order = $request->getStr('order', PhabricatorProjectColumn::DEFAULT_ORDER); @@ -26,22 +20,22 @@ $can_edit_status = $this->hasApplicationCapability( ManiphestEditStatusCapability::CAPABILITY); $can_create_projects = PhabricatorPolicyFilter::hasCapability( - $user, + $viewer, PhabricatorApplication::getByClass('PhabricatorProjectApplication'), ProjectCreateProjectsCapability::CAPABILITY); $parent_task = null; $template_id = null; - if ($this->id) { + if ($id) { $task = id(new ManiphestTaskQuery()) - ->setViewer($user) + ->setViewer($viewer) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, )) - ->withIDs(array($this->id)) + ->withIDs(array($id)) ->needSubscriberPHIDs(true) ->needProjectPHIDs(true) ->executeOne(); @@ -49,7 +43,7 @@ return new Aphront404Response(); } } else { - $task = ManiphestTask::initializeNewTask($user); + $task = ManiphestTask::initializeNewTask($viewer); // We currently do not allow you to set the task status when creating // a new task, although now that statuses are custom it might make @@ -82,7 +76,7 @@ } $default_projects = id(new PhabricatorObjectQuery()) - ->setViewer($user) + ->setViewer($viewer) ->withNames($tokens) ->execute(); $default_projects = mpull($default_projects, 'getPHID'); @@ -109,12 +103,12 @@ $assign = $request->getStr('assign'); if (strlen($assign)) { $assign_user = id(new PhabricatorPeopleQuery()) - ->setViewer($user) + ->setViewer($viewer) ->withUsernames(array($assign)) ->executeOne(); if (!$assign_user) { $assign_user = id(new PhabricatorPeopleQuery()) - ->setViewer($user) + ->setViewer($viewer) ->withPHIDs(array($assign)) ->executeOne(); } @@ -132,7 +126,7 @@ $parent_id = $request->getInt('parent'); if (strlen($parent_id)) { $parent_task = id(new ManiphestTaskQuery()) - ->setViewer($user) + ->setViewer($viewer) ->withIDs(array($parent_id)) ->executeOne(); if (!$parent_task) { @@ -150,7 +144,7 @@ $field_list = PhabricatorCustomField::getObjectFields( $task, PhabricatorCustomField::ROLE_EDIT); - $field_list->setViewer($user); + $field_list->setViewer($viewer); $field_list->readFieldsFromStorage($task); $aux_fields = $field_list->getFields(); @@ -250,7 +244,7 @@ // allow for putting a task in a project column at creation -only- if (!$task->getID() && $column_phid && $projects) { $column = id(new PhabricatorProjectColumnQuery()) - ->setViewer($user) + ->setViewer($viewer) ->withProjectPHIDs($projects) ->withPHIDs(array($column_phid)) ->executeOne(); @@ -329,7 +323,7 @@ 'new' => $is_new, 'transactions' => $transactions, )); - $event->setUser($user); + $event->setUser($viewer); $event->setAphrontRequest($request); PhutilEventEngine::dispatchEvent($event); @@ -337,7 +331,7 @@ $transactions = $event->getValue('transactions'); $editor = id(new ManiphestTransactionEditor()) - ->setActor($user) + ->setActor($viewer) ->setContentSourceFromRequest($request) ->setContinueOnNoEffect(true) ->applyTransactions($task, $transactions); @@ -349,7 +343,7 @@ 'new' => $is_new, 'transactions' => $transactions, )); - $event->setUser($user); + $event->setUser($viewer); $event->setAphrontRequest($request); PhutilEventEngine::dispatchEvent($event); } @@ -372,19 +366,19 @@ $owner = null; if ($task->getOwnerPHID()) { $owner = id(new PhabricatorHandleQuery()) - ->setViewer($user) + ->setViewer($viewer) ->withPHIDs(array($task->getOwnerPHID())) ->executeOne(); } $tasks = id(new ProjectBoardTaskCard()) - ->setViewer($user) + ->setViewer($viewer) ->setTask($task) ->setOwner($owner) ->setCanEdit(true) ->getItem(); $column = id(new PhabricatorProjectColumnQuery()) - ->setViewer($user) + ->setViewer($viewer) ->withPHIDs(array($request->getStr('columnPHID'))) ->executeOne(); if (!$column) { @@ -403,13 +397,13 @@ } $positions = id(new PhabricatorProjectColumnPositionQuery()) - ->setViewer($user) + ->setViewer($viewer) ->withColumns(array($column)) ->execute(); $task_phids = mpull($positions, 'getObjectPHID'); $column_tasks = id(new ManiphestTaskQuery()) - ->setViewer($user) + ->setViewer($viewer) ->withPHIDs($task_phids) ->execute(); @@ -461,11 +455,11 @@ } else { if (!$task->getID()) { $task->attachSubscriberPHIDs(array( - $user->getPHID(), + $viewer->getPHID(), )); if ($template_id) { $template_task = id(new ManiphestTaskQuery()) - ->setViewer($user) + ->setViewer($viewer) ->withIDs(array($template_id)) ->needSubscriberPHIDs(true) ->needProjectPHIDs(true) @@ -473,7 +467,7 @@ if ($template_task) { $cc_phids = array_unique(array_merge( $template_task->getSubscriberPHIDs(), - array($user->getPHID()))); + array($viewer->getPHID()))); $task->attachSubscriberPHIDs($cc_phids); $task->attachProjectPHIDs($template_task->getProjectPHIDs()); $task->setOwnerPHID($template_task->getOwnerPHID()); @@ -499,7 +493,7 @@ if ($fields) { id(new PhabricatorCustomFieldList($fields)) - ->setViewer($user) + ->setViewer($viewer) ->readFieldsFromStorage($template_task); foreach ($fields as $key => $field) { @@ -563,7 +557,7 @@ $form = new AphrontFormView(); $form - ->setUser($user) + ->setUser($viewer) ->addHiddenInput('template', $template_id) ->addHiddenInput('responseType', $response_type) ->addHiddenInput('order', $order) @@ -575,7 +569,7 @@ ->appendChild( id(new AphrontFormStaticControl()) ->setLabel(pht('Parent Task')) - ->setValue($user->renderHandle($parent_task->getPHID()))) + ->setValue($viewer->renderHandle($parent_task->getPHID()))) ->addHiddenInput('parent', $parent_task->getID()); } @@ -607,7 +601,7 @@ } $policies = id(new PhabricatorPolicyQuery()) - ->setViewer($user) + ->setViewer($viewer) ->setObject($task) ->execute(); @@ -617,7 +611,7 @@ ->setLabel(pht('Assigned To')) ->setName('assigned_to') ->setValue($assigned_value) - ->setUser($user) + ->setUser($viewer) ->setDatasource(new PhabricatorPeopleDatasource()) ->setLimit(1)); } @@ -628,7 +622,7 @@ ->setLabel(pht('CC')) ->setName('cc') ->setValue($cc_value) - ->setUser($user) + ->setUser($viewer) ->setDatasource(new PhabricatorMetaMTAMailableDatasource())); if ($can_edit_priority) { @@ -645,7 +639,7 @@ $form ->appendChild( id(new AphrontFormPolicyControl()) - ->setUser($user) + ->setUser($viewer) ->setCapability(PhabricatorPolicyCapability::CAN_VIEW) ->setPolicyObject($task) ->setPolicies($policies) @@ -653,7 +647,7 @@ ->setName('viewPolicy')) ->appendChild( id(new AphrontFormPolicyControl()) - ->setUser($user) + ->setUser($viewer) ->setCapability(PhabricatorPolicyCapability::CAN_EDIT) ->setPolicyObject($task) ->setPolicies($policies) @@ -696,14 +690,14 @@ ->setName('description') ->setID('description-textarea') ->setValue($task->getDescription()) - ->setUser($user); + ->setUser($viewer); $form ->appendChild($description_control); if ($request->isAjax()) { $dialog = id(new AphrontDialogView()) - ->setUser($user) + ->setUser($viewer) ->setWidth(AphrontDialogView::WIDTH_FULL) ->setTitle($header_name) ->appendChild( diff --git a/src/applications/maniphest/controller/ManiphestTaskListController.php b/src/applications/maniphest/controller/ManiphestTaskListController.php --- a/src/applications/maniphest/controller/ManiphestTaskListController.php +++ b/src/applications/maniphest/controller/ManiphestTaskListController.php @@ -3,19 +3,15 @@ final class ManiphestTaskListController extends ManiphestController { - private $queryKey; - public function shouldAllowPublic() { return true; } - public function willProcessRequest(array $data) { - $this->queryKey = idx($data, 'queryKey'); - } + public function handleRequest(AphrontRequest $request) { + $querykey = $request->getURIData('queryKey'); - public function processRequest() { $controller = id(new PhabricatorApplicationSearchController()) - ->setQueryKey($this->queryKey) + ->setQueryKey($querykey) ->setSearchEngine( id(new ManiphestTaskSearchEngine()) ->setShowBatchControls(true))