Page MenuHomePhabricator

D13682.id33070.diff
No OneTemporary

D13682.id33070.diff

diff --git a/src/applications/phriction/controller/PhrictionDeleteController.php b/src/applications/phriction/controller/PhrictionDeleteController.php
--- a/src/applications/phriction/controller/PhrictionDeleteController.php
+++ b/src/applications/phriction/controller/PhrictionDeleteController.php
@@ -2,19 +2,13 @@
final class PhrictionDeleteController extends PhrictionController {
- private $id;
-
- 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');
$document = id(new PhrictionDocumentQuery())
- ->setViewer($user)
- ->withIDs(array($this->id))
+ ->setViewer($viewer)
+ ->withIDs(array($id))
->needContent(true)
->requireCapabilities(
array(
@@ -36,7 +30,7 @@
->setNewValue(true);
$editor = id(new PhrictionTransactionEditor())
- ->setActor($user)
+ ->setActor($viewer)
->setContentSourceFromRequest($request)
->setContinueOnNoEffect(true);
try {
@@ -49,13 +43,13 @@
if ($e_text) {
$dialog = id(new AphrontDialogView())
- ->setUser($user)
+ ->setUser($viewer)
->setTitle(pht('Can Not Delete Document!'))
->appendChild($e_text)
->addCancelButton($document_uri);
} else {
$dialog = id(new AphrontDialogView())
- ->setUser($user)
+ ->setUser($viewer)
->setTitle(pht('Delete Document?'))
->appendChild(
pht('Really delete this document? You can recover it later by '.
diff --git a/src/applications/phriction/controller/PhrictionDiffController.php b/src/applications/phriction/controller/PhrictionDiffController.php
--- a/src/applications/phriction/controller/PhrictionDiffController.php
+++ b/src/applications/phriction/controller/PhrictionDiffController.php
@@ -2,23 +2,17 @@
final class PhrictionDiffController extends PhrictionController {
- 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');
$document = id(new PhrictionDocumentQuery())
- ->setViewer($user)
- ->withIDs(array($this->id))
+ ->setViewer($viewer)
+ ->withIDs(array($id))
->needContent(true)
->executeOne();
if (!$document) {
@@ -73,7 +67,7 @@
$whitespace_mode = DifferentialChangesetParser::WHITESPACE_SHOW_ALL;
$parser = id(new DifferentialChangesetParser())
- ->setUser($user)
+ ->setUser($viewer)
->setChangeset($changeset)
->setRenderingReference("{$l},{$r}");
@@ -81,7 +75,7 @@
$parser->setWhitespaceMode($whitespace_mode);
$engine = new PhabricatorMarkupEngine();
- $engine->setViewer($user);
+ $engine->setViewer($viewer);
$engine->process();
$parser->setMarkupEngine($engine);
@@ -262,7 +256,7 @@
private function renderComparisonTable(array $content) {
assert_instances_of($content, 'PhrictionContent');
- $user = $this->getRequest()->getUser();
+ $viewer = $this->getViewer();
$phids = mpull($content, 'getAuthorPHID');
$handles = $this->loadViewerHandles($phids);
@@ -278,8 +272,8 @@
$author,
pht('Version %s', $c->getVersion())))
->addAttribute(pht('%s %s',
- phabricator_date($c->getDateCreated(), $user),
- phabricator_time($c->getDateCreated(), $user)));
+ phabricator_date($c->getDateCreated(), $viewer),
+ phabricator_time($c->getDateCreated(), $viewer)));
if ($c->getDescription()) {
$item->addAttribute($c->getDescription());
diff --git a/src/applications/phriction/controller/PhrictionDocumentController.php b/src/applications/phriction/controller/PhrictionDocumentController.php
--- a/src/applications/phriction/controller/PhrictionDocumentController.php
+++ b/src/applications/phriction/controller/PhrictionDocumentController.php
@@ -9,13 +9,9 @@
return true;
}
- public function willProcessRequest(array $data) {
- $this->slug = $data['slug'];
- }
-
- public function processRequest() {
- $request = $this->getRequest();
- $user = $request->getUser();
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $request->getViewer();
+ $this->slug = $request->getURIData('slug');
$slug = PhabricatorSlug::normalize($this->slug);
if ($slug != $this->slug) {
@@ -27,7 +23,7 @@
require_celerity_resource('phriction-document-css');
$document = id(new PhrictionDocumentQuery())
- ->setViewer($user)
+ ->setViewer($viewer)
->withSlugs(array($slug))
->executeOne();
@@ -39,7 +35,7 @@
if (!$document) {
- $document = PhrictionDocument::initializeNewDocument($user, $slug);
+ $document = PhrictionDocument::initializeNewDocument($viewer, $slug);
$create_uri = '/phriction/edit/?slug='.$slug;
@@ -67,7 +63,7 @@
}
if ($content->getID() != $document->getContentID()) {
- $vdate = phabricator_datetime($content->getDateCreated(), $user);
+ $vdate = phabricator_datetime($content->getDateCreated(), $viewer);
$version_note = new PHUIInfoView();
$version_note->setSeverity(PHUIInfoView::SEVERITY_NOTICE);
$version_note->appendChild(
@@ -87,7 +83,7 @@
if ($current_status == PhrictionChangeType::CHANGE_EDIT ||
$current_status == PhrictionChangeType::CHANGE_MOVE_HERE) {
- $core_content = $content->renderContent($user);
+ $core_content = $content->renderContent($viewer);
} else if ($current_status == PhrictionChangeType::CHANGE_DELETE) {
$notice = new PHUIInfoView();
$notice->setSeverity(PHUIInfoView::SEVERITY_NOTICE);
@@ -112,7 +108,7 @@
// If the new document exists and the viewer can see it, provide a link
// to it. Otherwise, render a generic message.
$new_docs = id(new PhrictionDocumentQuery())
- ->setViewer($user)
+ ->setViewer($viewer)
->withIDs(array($new_doc_id))
->execute();
if ($new_docs) {
@@ -157,7 +153,7 @@
// If the old document exists and is visible, provide a link to it.
$from_docs = id(new PhrictionDocumentQuery())
- ->setViewer($user)
+ ->setViewer($viewer)
->withIDs(array($from_doc_id))
->execute();
if ($from_docs) {
@@ -183,7 +179,7 @@
$children = $this->renderDocumentChildren($slug);
- $actions = $this->buildActionView($user, $document);
+ $actions = $this->buildActionView($viewer, $document);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->setBorder(true);
@@ -201,7 +197,7 @@
->setDropdownMenu($actions);
$header = id(new PHUIHeaderView())
- ->setUser($user)
+ ->setUser($viewer)
->setPolicyObject($document)
->setHeader($page_title)
->addActionLink($action_button);
@@ -257,17 +253,17 @@
}
private function buildActionView(
- PhabricatorUser $user,
+ PhabricatorUser $viewer,
PhrictionDocument $document) {
$can_edit = PhabricatorPolicyFilter::hasCapability(
- $user,
+ $viewer,
$document,
PhabricatorPolicyCapability::CAN_EDIT);
$slug = PhabricatorSlug::normalize($this->slug);
$action_view = id(new PhabricatorActionListView())
- ->setUser($user)
+ ->setUser($viewer)
->setObjectURI($this->getRequest()->getRequestURI())
->setObject($document);
diff --git a/src/applications/phriction/controller/PhrictionEditController.php b/src/applications/phriction/controller/PhrictionEditController.php
--- a/src/applications/phriction/controller/PhrictionEditController.php
+++ b/src/applications/phriction/controller/PhrictionEditController.php
@@ -3,22 +3,15 @@
final class PhrictionEditController
extends PhrictionController {
- 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');
$current_version = null;
- if ($this->id) {
+ if ($id) {
$document = id(new PhrictionDocumentQuery())
- ->setViewer($user)
- ->withIDs(array($this->id))
+ ->setViewer($viewer)
+ ->withIDs(array($id))
->needContent(true)
->requireCapabilities(
array(
@@ -53,7 +46,7 @@
}
$document = id(new PhrictionDocumentQuery())
- ->setViewer($user)
+ ->setViewer($viewer)
->withSlugs(array($slug))
->needContent(true)
->executeOne();
@@ -62,7 +55,7 @@
$content = $document->getContent();
$current_version = $content->getVersion();
} else {
- $document = PhrictionDocument::initializeNewDocument($user, $slug);
+ $document = PhrictionDocument::initializeNewDocument($viewer, $slug);
$content = $document->getContent();
}
}
@@ -78,7 +71,7 @@
}
$draft = id(new PhabricatorDraft())->loadOneWhere(
'authorPHID = %s AND draftKey = %s',
- $user->getPHID(),
+ $viewer->getPHID(),
$draft_key);
}
@@ -141,7 +134,7 @@
->setNewValue($v_edit);
$editor = id(new PhrictionTransactionEditor())
- ->setActor($user)
+ ->setActor($viewer)
->setContentSourceFromRequest($request)
->setContinueOnNoEffect(true)
->setDescription($notes)
@@ -198,14 +191,14 @@
$cancel_uri = PhrictionDocument::getSlugURI($document->getSlug());
$policies = id(new PhabricatorPolicyQuery())
- ->setViewer($user)
+ ->setViewer($viewer)
->setObject($document)
->execute();
$view_capability = PhabricatorPolicyCapability::CAN_VIEW;
$edit_capability = PhabricatorPolicyCapability::CAN_EDIT;
$form = id(new AphrontFormView())
- ->setUser($user)
+ ->setUser($viewer)
->addHiddenInput('slug', $document->getSlug())
->addHiddenInput('nodraft', $request->getBool('nodraft'))
->addHiddenInput('contentVersion', $current_version)
@@ -228,7 +221,7 @@
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL)
->setName('content')
->setID('document-textarea')
- ->setUser($user))
+ ->setUser($viewer))
->appendChild(
id(new AphrontFormPolicyControl())
->setName('viewPolicy')
diff --git a/src/applications/phriction/controller/PhrictionHistoryController.php b/src/applications/phriction/controller/PhrictionHistoryController.php
--- a/src/applications/phriction/controller/PhrictionHistoryController.php
+++ b/src/applications/phriction/controller/PhrictionHistoryController.php
@@ -9,17 +9,12 @@
return true;
}
- public function willProcessRequest(array $data) {
- $this->slug = $data['slug'];
- }
-
- public function processRequest() {
-
- $request = $this->getRequest();
- $user = $request->getUser();
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $request->getViewer();
+ $this->slug = $request->getURIData('slug');
$document = id(new PhrictionDocumentQuery())
- ->setViewer($user)
+ ->setViewer($viewer)
->withSlugs(array(PhabricatorSlug::normalize($this->slug)))
->needContent(true)
->executeOne();
@@ -102,8 +97,8 @@
),
pht('Version %s', $version)))
->addAttribute(pht('%s %s',
- phabricator_date($content->getDateCreated(), $user),
- phabricator_time($content->getDateCreated(), $user)));
+ phabricator_date($content->getDateCreated(), $viewer),
+ phabricator_time($content->getDateCreated(), $viewer)));
if ($content->getDescription()) {
$item->addAttribute($content->getDescription());
diff --git a/src/applications/phriction/controller/PhrictionListController.php b/src/applications/phriction/controller/PhrictionListController.php
--- a/src/applications/phriction/controller/PhrictionListController.php
+++ b/src/applications/phriction/controller/PhrictionListController.php
@@ -3,19 +3,15 @@
final class PhrictionListController
extends PhrictionController {
- 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(new PhrictionSearchEngine())
->setNavigation($this->buildSideNavView());
diff --git a/src/applications/phriction/controller/PhrictionNewController.php b/src/applications/phriction/controller/PhrictionNewController.php
--- a/src/applications/phriction/controller/PhrictionNewController.php
+++ b/src/applications/phriction/controller/PhrictionNewController.php
@@ -2,14 +2,13 @@
final class PhrictionNewController extends PhrictionController {
- public function processRequest() {
- $request = $this->getRequest();
- $user = $request->getUser();
- $slug = PhabricatorSlug::normalize($request->getStr('slug'));
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $request->getViewer();
+ $slug = PhabricatorSlug::normalize($request->getStr('slug'));
if ($request->isFormPost()) {
$document = id(new PhrictionDocumentQuery())
- ->setViewer($user)
+ ->setViewer($viewer)
->withSlugs(array($slug))
->executeOne();
$prompt = $request->getStr('prompt', 'no');
@@ -20,7 +19,7 @@
$dialog = new AphrontDialogView();
$dialog->setSubmitURI('/phriction/new/')
->setTitle(pht('Edit Existing Document?'))
- ->setUser($user)
+ ->setUser($viewer)
->appendChild(pht(
'The document %s already exists. Do you want to edit it instead?',
phutil_tag('tt', array(), $slug)))
@@ -48,7 +47,7 @@
->setName('slug'));
$dialog = id(new AphrontDialogView())
- ->setUser($user)
+ ->setUser($viewer)
->setTitle(pht('New Document'))
->setSubmitURI('/phriction/new/')
->appendChild(phutil_tag('p',

File Metadata

Mime Type
text/plain
Expires
Thu, Nov 28, 3:24 PM (19 h, 35 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6801097
Default Alt Text
D13682.id33070.diff (14 KB)

Event Timeline