Page MenuHomePhabricator

D14652.id35447.diff
No OneTemporary

D14652.id35447.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -7975,6 +7975,7 @@
'PhabricatorFlaggableInterface',
'PhabricatorTokenReceiverInterface',
'PhabricatorDestructibleInterface',
+ 'PhabricatorProjectInterface',
'PhabricatorApplicationTransactionInterface',
),
'PhrictionDocumentAuthorHeraldField' => 'PhrictionDocumentHeraldField',
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
@@ -54,9 +54,11 @@
if ($document) {
$content = $document->getContent();
$current_version = $content->getVersion();
+ $is_new = false;
} else {
$document = PhrictionDocument::initializeNewDocument($viewer, $slug);
$content = $document->getContent();
+ $is_new = true;
}
}
@@ -91,11 +93,7 @@
$draft_note->setSeverity(PHUIInfoView::SEVERITY_NOTICE);
$draft_note->setTitle(pht('Recovered Draft'));
$draft_note->appendChild(
- hsprintf(
- '<p>%s</p>',
- pht(
- 'Showing a saved draft of your edits, you can %s.',
- $discard)));
+ pht('Showing a saved draft of your edits, you can %s.', $discard));
} else {
$content_text = $content->getContent();
$draft_note = null;
@@ -112,6 +110,15 @@
$v_cc = PhabricatorSubscribersQuery::loadSubscribersForPHID(
$document->getPHID());
+ if ($is_new) {
+ $v_projects = array();
+ } else {
+ $v_projects = PhabricatorEdgeQuery::loadDestinationPHIDs(
+ $document->getPHID(),
+ PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
+ $v_projects = array_reverse($v_projects);
+ }
+
if ($request->isFormPost()) {
$title = $request->getStr('title');
@@ -120,7 +127,8 @@
$current_version = $request->getInt('contentVersion');
$v_view = $request->getStr('viewPolicy');
$v_edit = $request->getStr('editPolicy');
- $v_cc = $request->getArr('cc');
+ $v_cc = $request->getArr('cc');
+ $v_projects = $request->getArr('projects');
$xactions = array();
$xactions[] = id(new PhrictionTransaction())
@@ -139,6 +147,12 @@
->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS)
->setNewValue(array('=' => $v_cc));
+ $proj_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
+ $xactions[] = id(new PhrictionTransaction())
+ ->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
+ ->setMetadataValue('edge:type', $proj_edge_type)
+ ->setNewValue(array('=' => array_fuse($v_projects)));
+
$editor = id(new PhrictionTransactionEditor())
->setActor($viewer)
->setContentSourceFromRequest($request)
@@ -230,6 +244,12 @@
->setUser($viewer))
->appendControl(
id(new AphrontFormTokenizerControl())
+ ->setLabel(pht('Projects'))
+ ->setName('projects')
+ ->setValue($v_projects)
+ ->setDatasource(new PhabricatorProjectDatasource()))
+ ->appendControl(
+ id(new AphrontFormTokenizerControl())
->setLabel(pht('Subscribers'))
->setName('cc')
->setValue($v_cc)
diff --git a/src/applications/phriction/editor/PhrictionTransactionEditor.php b/src/applications/phriction/editor/PhrictionTransactionEditor.php
--- a/src/applications/phriction/editor/PhrictionTransactionEditor.php
+++ b/src/applications/phriction/editor/PhrictionTransactionEditor.php
@@ -80,13 +80,14 @@
public function getTransactionTypes() {
$types = parent::getTransactionTypes();
- $types[] = PhabricatorTransactions::TYPE_COMMENT;
$types[] = PhrictionTransaction::TYPE_TITLE;
$types[] = PhrictionTransaction::TYPE_CONTENT;
$types[] = PhrictionTransaction::TYPE_DELETE;
$types[] = PhrictionTransaction::TYPE_MOVE_TO;
$types[] = PhrictionTransaction::TYPE_MOVE_AWAY;
+ $types[] = PhabricatorTransactions::TYPE_EDGE;
+ $types[] = PhabricatorTransactions::TYPE_COMMENT;
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
diff --git a/src/applications/phriction/query/PhrictionDocumentQuery.php b/src/applications/phriction/query/PhrictionDocumentQuery.php
--- a/src/applications/phriction/query/PhrictionDocumentQuery.php
+++ b/src/applications/phriction/query/PhrictionDocumentQuery.php
@@ -73,13 +73,22 @@
$this->setOrderVector(array('depth', 'title', 'updated'));
break;
default:
- throw new Exception(pht('Unknown order "%s".', $order));
+ // Defaults to "newest" no matter what I try. ):
+ // throw new Exception(pht('Unknown order "%s".', $order));
}
return $this;
}
protected function loadPage() {
+ return $this->loadStandardPage($this->newResultObject());
+ }
+
+ public function newResultObject() {
+ return new PhrictionDocument();
+ }
+
+ /* protected function loadPage() {
$table = new PhrictionDocument();
$conn_r = $table->establishConnection('r');
@@ -124,7 +133,7 @@
}
return $documents;
- }
+ }*/
protected function willFilterPage(array $documents) {
// To view a Phriction document, you must also be able to view all of the
@@ -190,58 +199,59 @@
return $documents;
}
- protected function buildJoinClause(AphrontDatabaseConnection $conn) {
- $join = '';
+ protected function buildJoinClauseParts(AphrontDatabaseConnection $conn) {
+ $joins = array();
if ($this->getOrderVector()->containsKey('updated')) {
$content_dao = new PhrictionContent();
- $join = qsprintf(
+ $joins[] = qsprintf(
$conn,
'JOIN %T c ON d.contentID = c.id',
$content_dao->getTableName());
}
- return $join;
+ return $joins;
}
- protected function buildWhereClause(AphrontDatabaseConnection $conn) {
- $where = array();
- if ($this->ids) {
+ protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
+ $where = parent::buildWhereClauseParts($conn);
+
+ if ($this->ids !== null) {
$where[] = qsprintf(
$conn,
'd.id IN (%Ld)',
$this->ids);
}
- if ($this->phids) {
+ if ($this->phids !== null) {
$where[] = qsprintf(
$conn,
'd.phid IN (%Ls)',
$this->phids);
}
- if ($this->slugs) {
+ if ($this->slugs !== null) {
$where[] = qsprintf(
$conn,
'd.slug IN (%Ls)',
$this->slugs);
}
- if ($this->statuses) {
+ if ($this->statuses !== null) {
$where[] = qsprintf(
$conn,
'd.status IN (%Ld)',
$this->statuses);
}
- if ($this->slugPrefix) {
+ if ($this->slugPrefix !== null) {
$where[] = qsprintf(
$conn,
'd.slug LIKE %>',
$this->slugPrefix);
}
- if ($this->depths) {
+ if ($this->depths !== null) {
$where[] = qsprintf(
$conn,
'd.depth IN (%Ld)',
@@ -274,9 +284,7 @@
throw new Exception(pht("Unknown status '%s'!", $this->status));
}
- $where[] = $this->buildPagingClause($conn);
-
- return $this->formatWhereClause($where);
+ return $where;
}
public function getOrderableColumns() {
@@ -331,6 +339,9 @@
}
}
+ protected function getPrimaryTableAlias() {
+ return 'd';
+ }
public function getQueryApplicationClass() {
return 'PhabricatorPhrictionApplication';
diff --git a/src/applications/phriction/query/PhrictionSearchEngine.php b/src/applications/phriction/query/PhrictionSearchEngine.php
--- a/src/applications/phriction/query/PhrictionSearchEngine.php
+++ b/src/applications/phriction/query/PhrictionSearchEngine.php
@@ -11,52 +11,29 @@
return 'PhabricatorPhrictionApplication';
}
- public function buildSavedQueryFromRequest(AphrontRequest $request) {
- $saved = new PhabricatorSavedQuery();
-
- $saved->setParameter('status', $request->getStr('status'));
- $saved->setParameter('order', $request->getStr('order'));
-
- return $saved;
- }
-
- public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
- $query = id(new PhrictionDocumentQuery())
+ public function newQuery() {
+ return id(new PhrictionDocumentQuery())
->needContent(true)
->withStatus(PhrictionDocumentQuery::STATUS_NONSTUB);
+ }
- $status = $saved->getParameter('status');
- $status = idx($this->getStatusValues(), $status);
- if ($status) {
- $query->withStatus($status);
- }
+ protected function buildQueryFromParameters(array $map) {
+ $query = $this->newQuery();
- $order = $saved->getParameter('order');
- $order = idx($this->getOrderValues(), $order);
- if ($order) {
- $query->setOrder($order);
+ if ($map['status']) {
+ $query->withStatus($map['status']);
}
return $query;
}
- public function buildSearchForm(
- AphrontFormView $form,
- PhabricatorSavedQuery $saved_query) {
-
- $form
- ->appendChild(
- id(new AphrontFormSelectControl())
- ->setLabel(pht('Status'))
- ->setName('status')
- ->setOptions($this->getStatusOptions())
- ->setValue($saved_query->getParameter('status')))
- ->appendChild(
- id(new AphrontFormSelectControl())
- ->setLabel(pht('Order'))
- ->setName('order')
- ->setOptions($this->getOrderOptions())
- ->setValue($saved_query->getParameter('order')));
+ protected function buildCustomSearchFields() {
+ return array(
+ id(new PhabricatorSearchSelectField())
+ ->setKey('status')
+ ->setLabel(pht('Status'))
+ ->setOptions($this->getStatusOptions()),
+ );
}
protected function getURI($path) {
@@ -66,7 +43,6 @@
protected function getBuiltinQueryNames() {
$names = array(
'active' => pht('Active'),
- 'updated' => pht('Updated'),
'all' => pht('All'),
);
@@ -79,12 +55,11 @@
$query->setQueryKey($query_key);
switch ($query_key) {
- case 'active':
- return $query->setParameter('status', 'active');
case 'all':
return $query;
- case 'updated':
- return $query->setParameter('order', 'updated');
+ case 'active':
+ return $query->setParameter(
+ 'status', PhrictionDocumentQuery::STATUS_OPEN);
}
return parent::buildSavedQueryFromBuiltin($query_key);
@@ -92,29 +67,8 @@
private function getStatusOptions() {
return array(
- 'active' => pht('Show Active Documents'),
- 'all' => pht('Show All Documents'),
- );
- }
-
- private function getStatusValues() {
- return array(
- 'active' => PhrictionDocumentQuery::STATUS_OPEN,
- 'all' => PhrictionDocumentQuery::STATUS_NONSTUB,
- );
- }
-
- private function getOrderOptions() {
- return array(
- 'created' => pht('Date Created'),
- 'updated' => pht('Date Updated'),
- );
- }
-
- private function getOrderValues() {
- return array(
- 'created' => PhrictionDocumentQuery::ORDER_CREATED,
- 'updated' => PhrictionDocumentQuery::ORDER_UPDATED,
+ PhrictionDocumentQuery::STATUS_OPEN => pht('Show Active Documents'),
+ PhrictionDocumentQuery::STATUS_NONSTUB => pht('Show All Documents'),
);
}
diff --git a/src/applications/phriction/storage/PhrictionDocument.php b/src/applications/phriction/storage/PhrictionDocument.php
--- a/src/applications/phriction/storage/PhrictionDocument.php
+++ b/src/applications/phriction/storage/PhrictionDocument.php
@@ -7,6 +7,7 @@
PhabricatorFlaggableInterface,
PhabricatorTokenReceiverInterface,
PhabricatorDestructibleInterface,
+ PhabricatorProjectInterface,
PhabricatorApplicationTransactionInterface {
protected $slug;
@@ -18,6 +19,7 @@
protected $editPolicy;
private $contentObject = self::ATTACHABLE;
+ private $edgeProjectPHIDs = self::ATTACHABLE;
private $ancestors = array();
protected function getConfiguration() {
@@ -94,6 +96,15 @@
return parent::save();
}
+ public function getProjectPHIDs() {
+ return $this->assertAttached($this->edgeProjectPHIDs);
+ }
+
+ public function attachProjectPHIDs(array $phids) {
+ $this->edgeProjectPHIDs = $phids;
+ return $this;
+ }
+
public static function getSlugURI($slug, $type = 'document') {
static $types = array(
'document' => '/w/',

File Metadata

Mime Type
text/plain
Expires
Sat, Apr 5, 1:36 PM (2 d, 22 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7712035
Default Alt Text
D14652.id35447.diff (12 KB)

Event Timeline