Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14057313
D7392.id16653.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
18 KB
Referenced Files
None
Subscribers
None
D7392.id16653.diff
View Options
Index: src/__phutil_library_map__.php
===================================================================
--- src/__phutil_library_map__.php
+++ src/__phutil_library_map__.php
@@ -1297,6 +1297,7 @@
'PhabricatorFlagQuery' => 'applications/flag/query/PhabricatorFlagQuery.php',
'PhabricatorFlagSearchEngine' => 'applications/flag/query/PhabricatorFlagSearchEngine.php',
'PhabricatorFlagSelectControl' => 'applications/flag/view/PhabricatorFlagSelectControl.php',
+ 'PhabricatorFlaggableInterface' => 'applications/flag/interface/PhabricatorFlaggableInterface.php',
'PhabricatorFlagsUIEventListener' => 'applications/flag/events/PhabricatorFlagsUIEventListener.php',
'PhabricatorFormExample' => 'applications/uiexample/examples/PhabricatorFormExample.php',
'PhabricatorGarbageCollectorConfigOptions' => 'applications/config/option/PhabricatorGarbageCollectorConfigOptions.php',
@@ -2583,7 +2584,8 @@
0 => 'DifferentialDAO',
1 => 'PhabricatorTokenReceiverInterface',
2 => 'PhabricatorPolicyInterface',
- 3 => 'PhrequentTrackableInterface',
+ 3 => 'PhabricatorFlaggableInterface',
+ 4 => 'PhrequentTrackableInterface',
),
'DifferentialRevisionCommentListView' => 'AphrontView',
'DifferentialRevisionCommentView' => 'AphrontView',
@@ -2879,7 +2881,8 @@
'HeraldRule' =>
array(
0 => 'HeraldDAO',
- 1 => 'PhabricatorPolicyInterface',
+ 1 => 'PhabricatorFlaggableInterface',
+ 2 => 'PhabricatorPolicyInterface',
),
'HeraldRuleController' => 'HeraldController',
'HeraldRuleEdit' => 'HeraldDAO',
@@ -2994,8 +2997,9 @@
1 => 'PhabricatorMarkupInterface',
2 => 'PhabricatorPolicyInterface',
3 => 'PhabricatorTokenReceiverInterface',
- 4 => 'PhrequentTrackableInterface',
- 5 => 'PhabricatorCustomFieldInterface',
+ 4 => 'PhabricatorFlaggableInterface',
+ 5 => 'PhrequentTrackableInterface',
+ 6 => 'PhabricatorCustomFieldInterface',
),
'ManiphestTaskDescriptionPreviewController' => 'ManiphestController',
'ManiphestTaskDetailController' => 'ManiphestController',
@@ -3512,7 +3516,8 @@
0 => 'PhabricatorFileDAO',
1 => 'PhabricatorTokenReceiverInterface',
2 => 'PhabricatorSubscribableInterface',
- 3 => 'PhabricatorPolicyInterface',
+ 3 => 'PhabricatorFlaggableInterface',
+ 4 => 'PhabricatorPolicyInterface',
),
'PhabricatorFileCommentController' => 'PhabricatorFileController',
'PhabricatorFileComposeController' => 'PhabricatorFileController',
@@ -3527,7 +3532,8 @@
0 => 'PhabricatorFileDAO',
1 => 'PhabricatorSubscribableInterface',
2 => 'PhabricatorApplicationTransactionInterface',
- 3 => 'PhabricatorPolicyInterface',
+ 3 => 'PhabricatorFlaggableInterface',
+ 4 => 'PhabricatorPolicyInterface',
),
'PhabricatorFileInfoController' => 'PhabricatorFileController',
'PhabricatorFileLinkListView' => 'AphrontView',
@@ -3758,7 +3764,8 @@
0 => 'PhabricatorPasteDAO',
1 => 'PhabricatorSubscribableInterface',
2 => 'PhabricatorTokenReceiverInterface',
- 3 => 'PhabricatorPolicyInterface',
+ 3 => 'PhabricatorFlaggableInterface',
+ 4 => 'PhabricatorPolicyInterface',
),
'PhabricatorPasteCommentController' => 'PhabricatorPasteController',
'PhabricatorPasteConfigOptions' => 'PhabricatorApplicationConfigOptions',
@@ -3840,7 +3847,8 @@
'PhabricatorProject' =>
array(
0 => 'PhabricatorProjectDAO',
- 1 => 'PhabricatorPolicyInterface',
+ 1 => 'PhabricatorFlaggableInterface',
+ 2 => 'PhabricatorPolicyInterface',
),
'PhabricatorProjectBoardController' => 'PhabricatorProjectController',
'PhabricatorProjectColumn' =>
@@ -3896,7 +3904,8 @@
array(
0 => 'PhabricatorRepositoryDAO',
1 => 'PhabricatorPolicyInterface',
- 2 => 'PhabricatorMarkupInterface',
+ 2 => 'PhabricatorFlaggableInterface',
+ 3 => 'PhabricatorMarkupInterface',
),
'PhabricatorRepositoryArcanistProject' =>
array(
@@ -3912,7 +3921,8 @@
array(
0 => 'PhabricatorRepositoryDAO',
1 => 'PhabricatorPolicyInterface',
- 2 => 'PhabricatorTokenReceiverInterface',
+ 2 => 'PhabricatorFlaggableInterface',
+ 3 => 'PhabricatorTokenReceiverInterface',
),
'PhabricatorRepositoryCommitChangeParserWorker' => 'PhabricatorRepositoryCommitParserWorker',
'PhabricatorRepositoryCommitData' => 'PhabricatorRepositoryDAO',
@@ -4037,7 +4047,8 @@
0 => 'PhabricatorSlowvoteDAO',
1 => 'PhabricatorPolicyInterface',
2 => 'PhabricatorSubscribableInterface',
- 3 => 'PhabricatorTokenReceiverInterface',
+ 3 => 'PhabricatorFlaggableInterface',
+ 4 => 'PhabricatorTokenReceiverInterface',
),
'PhabricatorSlowvotePollController' => 'PhabricatorSlowvoteController',
'PhabricatorSlowvoteQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
@@ -4239,7 +4250,8 @@
'PhluxVariable' =>
array(
0 => 'PhluxDAO',
- 1 => 'PhabricatorPolicyInterface',
+ 1 => 'PhabricatorFlaggableInterface',
+ 2 => 'PhabricatorPolicyInterface',
),
'PhluxVariableEditor' => 'PhabricatorApplicationTransactionEditor',
'PhluxVariableQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
@@ -4272,7 +4284,8 @@
2 => 'PhabricatorPolicyInterface',
3 => 'PhabricatorSubscribableInterface',
4 => 'PhabricatorTokenReceiverInterface',
- 5 => 'PhabricatorApplicationTransactionInterface',
+ 5 => 'PhabricatorFlaggableInterface',
+ 6 => 'PhabricatorApplicationTransactionInterface',
),
'PholioMockCommentController' => 'PholioController',
'PholioMockEditController' => 'PholioController',
@@ -4386,7 +4399,8 @@
0 => 'PhrictionDAO',
1 => 'PhabricatorPolicyInterface',
2 => 'PhabricatorSubscribableInterface',
- 3 => 'PhabricatorTokenReceiverInterface',
+ 3 => 'PhabricatorFlaggableInterface',
+ 4 => 'PhabricatorTokenReceiverInterface',
),
'PhrictionDocumentController' => 'PhrictionController',
'PhrictionDocumentEditor' => 'PhabricatorEditor',
@@ -4414,8 +4428,9 @@
1 => 'PhabricatorMarkupInterface',
2 => 'PonderVotableInterface',
3 => 'PhabricatorPolicyInterface',
- 4 => 'PhabricatorSubscribableInterface',
- 5 => 'PhabricatorTokenReceiverInterface',
+ 4 => 'PhabricatorFlaggableInterface',
+ 5 => 'PhabricatorSubscribableInterface',
+ 6 => 'PhabricatorTokenReceiverInterface',
),
'PonderAnswerCommentController' => 'PonderController',
'PonderAnswerEditController' => 'PonderController',
@@ -4443,8 +4458,9 @@
1 => 'PhabricatorMarkupInterface',
2 => 'PonderVotableInterface',
3 => 'PhabricatorSubscribableInterface',
- 4 => 'PhabricatorPolicyInterface',
- 5 => 'PhabricatorTokenReceiverInterface',
+ 4 => 'PhabricatorFlaggableInterface',
+ 5 => 'PhabricatorPolicyInterface',
+ 6 => 'PhabricatorTokenReceiverInterface',
),
'PonderQuestionCommentController' => 'PonderController',
'PonderQuestionEditController' => 'PonderController',
Index: src/applications/differential/storage/DifferentialRevision.php
===================================================================
--- src/applications/differential/storage/DifferentialRevision.php
+++ src/applications/differential/storage/DifferentialRevision.php
@@ -4,6 +4,7 @@
implements
PhabricatorTokenReceiverInterface,
PhabricatorPolicyInterface,
+ PhabricatorFlaggableInterface,
PhrequentTrackableInterface {
protected $title = '';
Index: src/applications/files/storage/PhabricatorFile.php
===================================================================
--- src/applications/files/storage/PhabricatorFile.php
+++ src/applications/files/storage/PhabricatorFile.php
@@ -7,6 +7,7 @@
implements
PhabricatorTokenReceiverInterface,
PhabricatorSubscribableInterface,
+ PhabricatorFlaggableInterface,
PhabricatorPolicyInterface {
const STORAGE_FORMAT_RAW = 'raw';
Index: src/applications/flag/events/PhabricatorFlagsUIEventListener.php
===================================================================
--- src/applications/flag/events/PhabricatorFlagsUIEventListener.php
+++ src/applications/flag/events/PhabricatorFlagsUIEventListener.php
@@ -24,10 +24,7 @@
return;
}
- if (($object instanceof PhabricatorUser)) {
- // Although there's no real reason not to let you flag users, it also
- // makes less conceptual sense than flaging other types of objects. For
- // now, don't allow it.
+ if (!($object instanceof PhabricatorFlaggableInterface)) {
return;
}
Index: src/applications/flag/interface/PhabricatorFlaggableInterface.php
===================================================================
--- /dev/null
+++ src/applications/flag/interface/PhabricatorFlaggableInterface.php
@@ -0,0 +1,7 @@
+<?php
+
+interface PhabricatorFlaggableInterface {
+
+ public function getPHID();
+
+}
Index: src/applications/flag/query/PhabricatorFlagQuery.php
===================================================================
--- src/applications/flag/query/PhabricatorFlagQuery.php
+++ src/applications/flag/query/PhabricatorFlagQuery.php
@@ -5,12 +5,14 @@
const GROUP_COLOR = 'color';
const GROUP_NONE = 'none';
+ const ALL_TYPES = 'all-types';
private $ownerPHIDs;
private $types;
private $objectPHIDs;
private $colors;
private $groupBy = self::GROUP_NONE;
+ private $objectType = self::ALL_TYPES;
private $needHandles;
private $needObjects;
@@ -40,6 +42,16 @@
* for large datasets. Pragmatically, this is fine for user flags which are
* typically well under 100 flags per user.
*/
+ public function withObjectType($type) {
+ $this->objectType = $type;
+ return $this;
+ }
+
+ /**
+ * Note this is done in php and not in mySQL, which means its inappropriate
+ * for large datasets. Pragmatically, this is fine for user flags which are
+ * typically well under 100 flags per user.
+ */
public function setGroupBy($group) {
$this->groupBy = $group;
return $this;
@@ -83,6 +95,15 @@
public function willFilterPage(array $flags) {
+ if ($this->objectType != self::ALL_TYPES) {
+ foreach ($flags as $index => $flag) {
+ $object_phid = $flag->getObjectPHID();
+ $object_type = phid_get_type($object_phid);
+ if ($object_type != $this->objectType) {
+ unset($flags[$index]);
+ }
+ }
+ }
if ($this->needObjects) {
$objects = id(new PhabricatorObjectQuery())
->setViewer($this->getViewer())
Index: src/applications/flag/query/PhabricatorFlagSearchEngine.php
===================================================================
--- src/applications/flag/query/PhabricatorFlagSearchEngine.php
+++ src/applications/flag/query/PhabricatorFlagSearchEngine.php
@@ -7,6 +7,7 @@
$saved = new PhabricatorSavedQuery();
$saved->setParameter('colors', $request->getArr('colors'));
$saved->setParameter('group', $request->getStr('group'));
+ $saved->setParameter('objectFilter', $request->getStr('objectFilter'));
return $saved;
}
@@ -25,6 +26,12 @@
$query->setGroupBy($group);
}
+ $object_filter = $saved->getParameter('objectFilter');
+ $objects = $this->getObjectFilterOptions();
+ if ($object_filter && isset($objects[$object_filter])) {
+ $query->withObjectType($object_filter);
+ }
+
return $query;
}
@@ -43,8 +50,13 @@
->setName('group')
->setLabel(pht('Group By'))
->setValue($saved_query->getParameter('group'))
- ->setOptions($this->getGroupOptions()));
-
+ ->setOptions($this->getGroupOptions()))
+ ->appendChild(
+ id(new AphrontFormSelectControl())
+ ->setName('objectFilter')
+ ->setLabel(pht('Object Type'))
+ ->setValue($saved_query->getParameter('objectFilter'))
+ ->setOptions($this->getObjectFilterOptions()));
}
protected function getURI($path) {
@@ -79,4 +91,23 @@
);
}
+ private function getObjectFilterOptions() {
+ $objects = id(new PhutilSymbolLoader())
+ ->setAncestorClass('PhabricatorFlaggableInterface')
+ ->loadObjects();
+ $all_types = PhabricatorPHIDType::getAllTypes();
+ $options = array(
+ 0 => 'All Objects');
+ foreach ($objects as $object) {
+ $phid = $object->generatePHID();
+ $phid_type = phid_get_type($phid);
+ $type_object = idx($all_types, $phid_type);
+ if ($type_object) {
+ $options[$phid_type] = $type_object->getTypeName();
+ }
+ }
+
+ return $options;
+ }
+
}
Index: src/applications/herald/storage/HeraldRule.php
===================================================================
--- src/applications/herald/storage/HeraldRule.php
+++ src/applications/herald/storage/HeraldRule.php
@@ -1,7 +1,9 @@
<?php
final class HeraldRule extends HeraldDAO
- implements PhabricatorPolicyInterface {
+ implements
+ PhabricatorFlaggableInterface,
+ PhabricatorPolicyInterface {
const TABLE_RULE_APPLIED = 'herald_ruleapplied';
Index: src/applications/macro/storage/PhabricatorFileImageMacro.php
===================================================================
--- src/applications/macro/storage/PhabricatorFileImageMacro.php
+++ src/applications/macro/storage/PhabricatorFileImageMacro.php
@@ -4,6 +4,7 @@
implements
PhabricatorSubscribableInterface,
PhabricatorApplicationTransactionInterface,
+ PhabricatorFlaggableInterface,
PhabricatorPolicyInterface {
protected $authorPHID;
Index: src/applications/maniphest/storage/ManiphestTask.php
===================================================================
--- src/applications/maniphest/storage/ManiphestTask.php
+++ src/applications/maniphest/storage/ManiphestTask.php
@@ -5,6 +5,7 @@
PhabricatorMarkupInterface,
PhabricatorPolicyInterface,
PhabricatorTokenReceiverInterface,
+ PhabricatorFlaggableInterface,
PhrequentTrackableInterface,
PhabricatorCustomFieldInterface {
Index: src/applications/paste/storage/PhabricatorPaste.php
===================================================================
--- src/applications/paste/storage/PhabricatorPaste.php
+++ src/applications/paste/storage/PhabricatorPaste.php
@@ -4,6 +4,7 @@
implements
PhabricatorSubscribableInterface,
PhabricatorTokenReceiverInterface,
+ PhabricatorFlaggableInterface,
PhabricatorPolicyInterface {
protected $title;
Index: src/applications/phlux/storage/PhluxVariable.php
===================================================================
--- src/applications/phlux/storage/PhluxVariable.php
+++ src/applications/phlux/storage/PhluxVariable.php
@@ -1,7 +1,9 @@
<?php
final class PhluxVariable extends PhluxDAO
- implements PhabricatorPolicyInterface {
+ implements
+ PhabricatorFlaggableInterface,
+ PhabricatorPolicyInterface {
protected $variableKey;
protected $variableValue;
Index: src/applications/pholio/storage/PholioMock.php
===================================================================
--- src/applications/pholio/storage/PholioMock.php
+++ src/applications/pholio/storage/PholioMock.php
@@ -9,6 +9,7 @@
PhabricatorPolicyInterface,
PhabricatorSubscribableInterface,
PhabricatorTokenReceiverInterface,
+ PhabricatorFlaggableInterface,
PhabricatorApplicationTransactionInterface {
const MARKUP_FIELD_DESCRIPTION = 'markup:description';
Index: src/applications/phriction/storage/PhrictionDocument.php
===================================================================
--- src/applications/phriction/storage/PhrictionDocument.php
+++ src/applications/phriction/storage/PhrictionDocument.php
@@ -7,6 +7,7 @@
implements
PhabricatorPolicyInterface,
PhabricatorSubscribableInterface,
+ PhabricatorFlaggableInterface,
PhabricatorTokenReceiverInterface {
protected $slug;
Index: src/applications/ponder/storage/PonderAnswer.php
===================================================================
--- src/applications/ponder/storage/PonderAnswer.php
+++ src/applications/ponder/storage/PonderAnswer.php
@@ -5,6 +5,7 @@
PhabricatorMarkupInterface,
PonderVotableInterface,
PhabricatorPolicyInterface,
+ PhabricatorFlaggableInterface,
PhabricatorSubscribableInterface,
PhabricatorTokenReceiverInterface {
Index: src/applications/ponder/storage/PonderQuestion.php
===================================================================
--- src/applications/ponder/storage/PonderQuestion.php
+++ src/applications/ponder/storage/PonderQuestion.php
@@ -5,6 +5,7 @@
PhabricatorMarkupInterface,
PonderVotableInterface,
PhabricatorSubscribableInterface,
+ PhabricatorFlaggableInterface,
PhabricatorPolicyInterface,
PhabricatorTokenReceiverInterface {
Index: src/applications/project/storage/PhabricatorProject.php
===================================================================
--- src/applications/project/storage/PhabricatorProject.php
+++ src/applications/project/storage/PhabricatorProject.php
@@ -1,7 +1,9 @@
<?php
final class PhabricatorProject extends PhabricatorProjectDAO
- implements PhabricatorPolicyInterface {
+ implements
+ PhabricatorFlaggableInterface,
+ PhabricatorPolicyInterface {
protected $name;
protected $status = PhabricatorProjectStatus::STATUS_ACTIVE;
Index: src/applications/repository/storage/PhabricatorRepository.php
===================================================================
--- src/applications/repository/storage/PhabricatorRepository.php
+++ src/applications/repository/storage/PhabricatorRepository.php
@@ -6,6 +6,7 @@
final class PhabricatorRepository extends PhabricatorRepositoryDAO
implements
PhabricatorPolicyInterface,
+ PhabricatorFlaggableInterface,
PhabricatorMarkupInterface {
/**
Index: src/applications/repository/storage/PhabricatorRepositoryCommit.php
===================================================================
--- src/applications/repository/storage/PhabricatorRepositoryCommit.php
+++ src/applications/repository/storage/PhabricatorRepositoryCommit.php
@@ -4,6 +4,7 @@
extends PhabricatorRepositoryDAO
implements
PhabricatorPolicyInterface,
+ PhabricatorFlaggableInterface,
PhabricatorTokenReceiverInterface {
protected $repositoryID;
Index: src/applications/slowvote/storage/PhabricatorSlowvotePoll.php
===================================================================
--- src/applications/slowvote/storage/PhabricatorSlowvotePoll.php
+++ src/applications/slowvote/storage/PhabricatorSlowvotePoll.php
@@ -7,6 +7,7 @@
implements
PhabricatorPolicyInterface,
PhabricatorSubscribableInterface,
+ PhabricatorFlaggableInterface,
PhabricatorTokenReceiverInterface {
const RESPONSES_VISIBLE = 0;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 18, 2:13 AM (18 h, 28 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6758633
Default Alt Text
D7392.id16653.diff (18 KB)
Attached To
Mode
D7392: Add filter by object ability to flag query
Attached
Detach File
Event Timeline
Log In to Comment