Skip to content

Commit da84546

Browse files
committed
Add filter by object ability to flag query
Summary: See title. Fixes T1809. Test Plan: verified each type that has flaggable interface still can be flagged verified that new custom query filter works Reviewers: epriestley Reviewed By: epriestley CC: Korvin, epriestley, aran Maniphest Tasks: T1809 Differential Revision: https://secure.phabricator.com/D7392
1 parent 203d820 commit da84546

File tree

19 files changed

+101
-27
lines changed

19 files changed

+101
-27
lines changed

src/__phutil_library_map__.php

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,6 +1299,7 @@
12991299
'PhabricatorFlagQuery' => 'applications/flag/query/PhabricatorFlagQuery.php',
13001300
'PhabricatorFlagSearchEngine' => 'applications/flag/query/PhabricatorFlagSearchEngine.php',
13011301
'PhabricatorFlagSelectControl' => 'applications/flag/view/PhabricatorFlagSelectControl.php',
1302+
'PhabricatorFlaggableInterface' => 'applications/flag/interface/PhabricatorFlaggableInterface.php',
13021303
'PhabricatorFlagsUIEventListener' => 'applications/flag/events/PhabricatorFlagsUIEventListener.php',
13031304
'PhabricatorFormExample' => 'applications/uiexample/examples/PhabricatorFormExample.php',
13041305
'PhabricatorGarbageCollectorConfigOptions' => 'applications/config/option/PhabricatorGarbageCollectorConfigOptions.php',
@@ -2587,7 +2588,8 @@
25872588
0 => 'DifferentialDAO',
25882589
1 => 'PhabricatorTokenReceiverInterface',
25892590
2 => 'PhabricatorPolicyInterface',
2590-
3 => 'PhrequentTrackableInterface',
2591+
3 => 'PhabricatorFlaggableInterface',
2592+
4 => 'PhrequentTrackableInterface',
25912593
),
25922594
'DifferentialRevisionCommentListView' => 'AphrontView',
25932595
'DifferentialRevisionCommentView' => 'AphrontView',
@@ -2883,7 +2885,8 @@
28832885
'HeraldRule' =>
28842886
array(
28852887
0 => 'HeraldDAO',
2886-
1 => 'PhabricatorPolicyInterface',
2888+
1 => 'PhabricatorFlaggableInterface',
2889+
2 => 'PhabricatorPolicyInterface',
28872890
),
28882891
'HeraldRuleController' => 'HeraldController',
28892892
'HeraldRuleEdit' => 'HeraldDAO',
@@ -2998,8 +3001,9 @@
29983001
1 => 'PhabricatorMarkupInterface',
29993002
2 => 'PhabricatorPolicyInterface',
30003003
3 => 'PhabricatorTokenReceiverInterface',
3001-
4 => 'PhrequentTrackableInterface',
3002-
5 => 'PhabricatorCustomFieldInterface',
3004+
4 => 'PhabricatorFlaggableInterface',
3005+
5 => 'PhrequentTrackableInterface',
3006+
6 => 'PhabricatorCustomFieldInterface',
30033007
),
30043008
'ManiphestTaskDescriptionPreviewController' => 'ManiphestController',
30053009
'ManiphestTaskDetailController' => 'ManiphestController',
@@ -3518,7 +3522,8 @@
35183522
0 => 'PhabricatorFileDAO',
35193523
1 => 'PhabricatorTokenReceiverInterface',
35203524
2 => 'PhabricatorSubscribableInterface',
3521-
3 => 'PhabricatorPolicyInterface',
3525+
3 => 'PhabricatorFlaggableInterface',
3526+
4 => 'PhabricatorPolicyInterface',
35223527
),
35233528
'PhabricatorFileCommentController' => 'PhabricatorFileController',
35243529
'PhabricatorFileComposeController' => 'PhabricatorFileController',
@@ -3533,7 +3538,8 @@
35333538
0 => 'PhabricatorFileDAO',
35343539
1 => 'PhabricatorSubscribableInterface',
35353540
2 => 'PhabricatorApplicationTransactionInterface',
3536-
3 => 'PhabricatorPolicyInterface',
3541+
3 => 'PhabricatorFlaggableInterface',
3542+
4 => 'PhabricatorPolicyInterface',
35373543
),
35383544
'PhabricatorFileInfoController' => 'PhabricatorFileController',
35393545
'PhabricatorFileLinkListView' => 'AphrontView',
@@ -3764,7 +3770,8 @@
37643770
0 => 'PhabricatorPasteDAO',
37653771
1 => 'PhabricatorSubscribableInterface',
37663772
2 => 'PhabricatorTokenReceiverInterface',
3767-
3 => 'PhabricatorPolicyInterface',
3773+
3 => 'PhabricatorFlaggableInterface',
3774+
4 => 'PhabricatorPolicyInterface',
37683775
),
37693776
'PhabricatorPasteCommentController' => 'PhabricatorPasteController',
37703777
'PhabricatorPasteConfigOptions' => 'PhabricatorApplicationConfigOptions',
@@ -3846,7 +3853,8 @@
38463853
'PhabricatorProject' =>
38473854
array(
38483855
0 => 'PhabricatorProjectDAO',
3849-
1 => 'PhabricatorPolicyInterface',
3856+
1 => 'PhabricatorFlaggableInterface',
3857+
2 => 'PhabricatorPolicyInterface',
38503858
),
38513859
'PhabricatorProjectBoardController' => 'PhabricatorProjectController',
38523860
'PhabricatorProjectColumn' =>
@@ -3904,7 +3912,8 @@
39043912
array(
39053913
0 => 'PhabricatorRepositoryDAO',
39063914
1 => 'PhabricatorPolicyInterface',
3907-
2 => 'PhabricatorMarkupInterface',
3915+
2 => 'PhabricatorFlaggableInterface',
3916+
3 => 'PhabricatorMarkupInterface',
39083917
),
39093918
'PhabricatorRepositoryArcanistProject' =>
39103919
array(
@@ -3920,7 +3929,8 @@
39203929
array(
39213930
0 => 'PhabricatorRepositoryDAO',
39223931
1 => 'PhabricatorPolicyInterface',
3923-
2 => 'PhabricatorTokenReceiverInterface',
3932+
2 => 'PhabricatorFlaggableInterface',
3933+
3 => 'PhabricatorTokenReceiverInterface',
39243934
),
39253935
'PhabricatorRepositoryCommitChangeParserWorker' => 'PhabricatorRepositoryCommitParserWorker',
39263936
'PhabricatorRepositoryCommitData' => 'PhabricatorRepositoryDAO',
@@ -4045,7 +4055,8 @@
40454055
0 => 'PhabricatorSlowvoteDAO',
40464056
1 => 'PhabricatorPolicyInterface',
40474057
2 => 'PhabricatorSubscribableInterface',
4048-
3 => 'PhabricatorTokenReceiverInterface',
4058+
3 => 'PhabricatorFlaggableInterface',
4059+
4 => 'PhabricatorTokenReceiverInterface',
40494060
),
40504061
'PhabricatorSlowvotePollController' => 'PhabricatorSlowvoteController',
40514062
'PhabricatorSlowvoteQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
@@ -4247,7 +4258,8 @@
42474258
'PhluxVariable' =>
42484259
array(
42494260
0 => 'PhluxDAO',
4250-
1 => 'PhabricatorPolicyInterface',
4261+
1 => 'PhabricatorFlaggableInterface',
4262+
2 => 'PhabricatorPolicyInterface',
42514263
),
42524264
'PhluxVariableEditor' => 'PhabricatorApplicationTransactionEditor',
42534265
'PhluxVariableQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
@@ -4280,7 +4292,8 @@
42804292
2 => 'PhabricatorPolicyInterface',
42814293
3 => 'PhabricatorSubscribableInterface',
42824294
4 => 'PhabricatorTokenReceiverInterface',
4283-
5 => 'PhabricatorApplicationTransactionInterface',
4295+
5 => 'PhabricatorFlaggableInterface',
4296+
6 => 'PhabricatorApplicationTransactionInterface',
42844297
),
42854298
'PholioMockCommentController' => 'PholioController',
42864299
'PholioMockEditController' => 'PholioController',
@@ -4394,7 +4407,8 @@
43944407
0 => 'PhrictionDAO',
43954408
1 => 'PhabricatorPolicyInterface',
43964409
2 => 'PhabricatorSubscribableInterface',
4397-
3 => 'PhabricatorTokenReceiverInterface',
4410+
3 => 'PhabricatorFlaggableInterface',
4411+
4 => 'PhabricatorTokenReceiverInterface',
43984412
),
43994413
'PhrictionDocumentController' => 'PhrictionController',
44004414
'PhrictionDocumentEditor' => 'PhabricatorEditor',
@@ -4422,8 +4436,9 @@
44224436
1 => 'PhabricatorMarkupInterface',
44234437
2 => 'PonderVotableInterface',
44244438
3 => 'PhabricatorPolicyInterface',
4425-
4 => 'PhabricatorSubscribableInterface',
4426-
5 => 'PhabricatorTokenReceiverInterface',
4439+
4 => 'PhabricatorFlaggableInterface',
4440+
5 => 'PhabricatorSubscribableInterface',
4441+
6 => 'PhabricatorTokenReceiverInterface',
44274442
),
44284443
'PonderAnswerCommentController' => 'PonderController',
44294444
'PonderAnswerEditController' => 'PonderController',
@@ -4451,8 +4466,9 @@
44514466
1 => 'PhabricatorMarkupInterface',
44524467
2 => 'PonderVotableInterface',
44534468
3 => 'PhabricatorSubscribableInterface',
4454-
4 => 'PhabricatorPolicyInterface',
4455-
5 => 'PhabricatorTokenReceiverInterface',
4469+
4 => 'PhabricatorFlaggableInterface',
4470+
5 => 'PhabricatorPolicyInterface',
4471+
6 => 'PhabricatorTokenReceiverInterface',
44564472
),
44574473
'PonderQuestionCommentController' => 'PonderController',
44584474
'PonderQuestionEditController' => 'PonderController',

src/applications/differential/storage/DifferentialRevision.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ final class DifferentialRevision extends DifferentialDAO
44
implements
55
PhabricatorTokenReceiverInterface,
66
PhabricatorPolicyInterface,
7+
PhabricatorFlaggableInterface,
78
PhrequentTrackableInterface {
89

910
protected $title = '';

src/applications/files/storage/PhabricatorFile.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ final class PhabricatorFile extends PhabricatorFileDAO
77
implements
88
PhabricatorTokenReceiverInterface,
99
PhabricatorSubscribableInterface,
10+
PhabricatorFlaggableInterface,
1011
PhabricatorPolicyInterface {
1112

1213
const STORAGE_FORMAT_RAW = 'raw';

src/applications/flag/events/PhabricatorFlagsUIEventListener.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ private function handleActionEvent($event) {
2424
return;
2525
}
2626

27-
if (($object instanceof PhabricatorUser)) {
28-
// Although there's no real reason not to let you flag users, it also
29-
// makes less conceptual sense than flaging other types of objects. For
30-
// now, don't allow it.
27+
if (!($object instanceof PhabricatorFlaggableInterface)) {
3128
return;
3229
}
3330

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
interface PhabricatorFlaggableInterface {
4+
5+
public function getPHID();
6+
7+
}

src/applications/flag/query/PhabricatorFlagSearchEngine.php

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ public function buildSavedQueryFromRequest(AphrontRequest $request) {
77
$saved = new PhabricatorSavedQuery();
88
$saved->setParameter('colors', $request->getArr('colors'));
99
$saved->setParameter('group', $request->getStr('group'));
10+
$saved->setParameter('objectFilter', $request->getStr('objectFilter'));
1011
return $saved;
1112
}
1213

@@ -25,6 +26,12 @@ public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
2526
$query->setGroupBy($group);
2627
}
2728

29+
$object_filter = $saved->getParameter('objectFilter');
30+
$objects = $this->getObjectFilterOptions();
31+
if ($object_filter && isset($objects[$object_filter])) {
32+
$query->withTypes(array($object_filter));
33+
}
34+
2835
return $query;
2936
}
3037

@@ -43,8 +50,13 @@ public function buildSearchForm(
4350
->setName('group')
4451
->setLabel(pht('Group By'))
4552
->setValue($saved_query->getParameter('group'))
46-
->setOptions($this->getGroupOptions()));
47-
53+
->setOptions($this->getGroupOptions()))
54+
->appendChild(
55+
id(new AphrontFormSelectControl())
56+
->setName('objectFilter')
57+
->setLabel(pht('Object Type'))
58+
->setValue($saved_query->getParameter('objectFilter'))
59+
->setOptions($this->getObjectFilterOptions()));
4860
}
4961

5062
protected function getURI($path) {
@@ -79,4 +91,28 @@ private function getGroupOptions() {
7991
);
8092
}
8193

94+
private function getObjectFilterOptions() {
95+
$objects = id(new PhutilSymbolLoader())
96+
->setAncestorClass('PhabricatorFlaggableInterface')
97+
->loadObjects();
98+
$all_types = PhabricatorPHIDType::getAllTypes();
99+
$options = array();
100+
foreach ($objects as $object) {
101+
$phid = $object->generatePHID();
102+
$phid_type = phid_get_type($phid);
103+
$type_object = idx($all_types, $phid_type);
104+
if ($type_object) {
105+
$options[$phid_type] = $type_object->getTypeName();
106+
}
107+
}
108+
// sort it alphabetically...
109+
asort($options);
110+
$default_option = array(
111+
0 => 'All Objects');
112+
// ...and stick the default option on front
113+
$options = array_merge($default_option, $options);
114+
115+
return $options;
116+
}
117+
82118
}

src/applications/herald/storage/HeraldRule.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<?php
22

33
final class HeraldRule extends HeraldDAO
4-
implements PhabricatorPolicyInterface {
4+
implements
5+
PhabricatorFlaggableInterface,
6+
PhabricatorPolicyInterface {
57

68
const TABLE_RULE_APPLIED = 'herald_ruleapplied';
79

src/applications/macro/storage/PhabricatorFileImageMacro.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ final class PhabricatorFileImageMacro extends PhabricatorFileDAO
44
implements
55
PhabricatorSubscribableInterface,
66
PhabricatorApplicationTransactionInterface,
7+
PhabricatorFlaggableInterface,
78
PhabricatorPolicyInterface {
89

910
protected $authorPHID;

src/applications/maniphest/storage/ManiphestTask.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ final class ManiphestTask extends ManiphestDAO
55
PhabricatorMarkupInterface,
66
PhabricatorPolicyInterface,
77
PhabricatorTokenReceiverInterface,
8+
PhabricatorFlaggableInterface,
89
PhrequentTrackableInterface,
910
PhabricatorCustomFieldInterface {
1011

src/applications/paste/storage/PhabricatorPaste.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ final class PhabricatorPaste extends PhabricatorPasteDAO
44
implements
55
PhabricatorSubscribableInterface,
66
PhabricatorTokenReceiverInterface,
7+
PhabricatorFlaggableInterface,
78
PhabricatorPolicyInterface {
89

910
protected $title;

0 commit comments

Comments
 (0)