forked from wikimedia/mediawiki-extensions-Flow
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FlowActions.php
1002 lines (960 loc) · 33.6 KB
/
FlowActions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
use Flow\Data\Listener\RecentChangesListener;
use Flow\Log\ModerationLogger;
use Flow\Model\AbstractRevision;
use Flow\Model\Header;
use Flow\Model\PostRevision;
use Flow\Model\PostSummary;
use Flow\RevisionActionPermissions;
/**
* Flow actions: key => value map with key being the action name.
* The value consists of an array of these below keys (and appropriate values):
* * performs-writes: Must be boolean true for any action that writes to the wiki.
* actions with this set will additionally require the core 'edit' permission.
* * log_type: the Special:Log filter to save actions to; false means 'not logged'.
* * rc_insert: whether or not to insert the write action into RC table.
* * permissions: array of permissions, where each key is the existing post
* state and the value is the right required to execute the action. A blank
* value means anyone can take the action. However, an omitted key means
* no one can perform the action described by that key.
* * root-permissions: similar to 'permissions', but applies to the last revision
* of the root post (= the topic) for the revision the action is executed against.
* If root-permissions is omitted entirely, it doesn't affect what is allowed.
* However, if any keys are set, omitted keys are treated as prohibited.
* * core-delete-permissions: array of rights, where any of those rights will
* give you permission to do the action on a deleted board (isAllowedAny).
* Empty string and omitted behave like 'permissions'.
* * links: the set of read links to generate and return in API responses
* * actions: the set of write links to generate and return in API responses
* * history: all history-related information:
* * i18n-message: the i18n message key for this change type
* * i18n-params: array of i18n parameters for the provided message (see
* AbstractFormatter::processParam phpdoc for more details)
* * class: classname to be added to the list-item for this changetype
* * bundle: array with, again, all of the above information if multiple types
* should be bundled (then the bundle i18n & class will be used to generate
* the list-item; clicking on it will reveal the individual history entries)
* * watch: Used by the WatchTopicListener to auto-subscribe users to topics. Only
* value value currently is immediate.
* * immediate: watchlist the title in the current process
* * rc_title: Either 'article' or 'owner' to select between Workflow::getArticleTitle
* or Workflow::getOwnerTitle being used as the related recentchanges entry on insert
* * editcount: True to increment user's edit count for this action
* * modules: Modules to insert with RL to html page for this action instead of the defaults.
* * All actions other than view should have an array here, unless the default
* * modules are known to work. You can specify an empty array, or a custom set of modules.
* * moduleStyles: Style modules to insert with RL to html page for this action instead of the defaults
* * hasUserGeneratedContent: Whether this action renders a page consisting of user-generated content
*/
return [
'create-header' => [
'performs-writes' => true,
'log_type' => false,
'rc_insert' => true,
'permissions' => [
Header::MODERATED_NONE => '',
],
'links' => [ 'board-history', 'workflow', 'header-revision' ],
'actions' => [ 'edit-header' ],
'history' => [
'i18n-message' => 'flow-rev-message-create-header',
'i18n-params' => [
'user-links',
'user-text',
],
'class' => 'flow-history-create-header',
],
'editcount' => true,
],
'edit-header' => [
'performs-writes' => true,
'log_type' => false,
'rc_insert' => true,
'permissions' => [
Header::MODERATED_NONE => '',
],
'links' => [ 'board-history', 'diff-header', 'workflow', 'header-revision' ],
'actions' => [ 'edit-header', 'undo-edit-header' ],
'history' => [
'i18n-message' => 'flow-rev-message-edit-header',
'i18n-params' => [
'user-links',
'user-text',
],
'class' => 'flow-history-edit-header',
],
'handler-class' => \Flow\Actions\FlowAction::class,
'modules' => [],
'editcount' => true,
],
// @todo this is almost copy/paste from edit-header except the handler-class. find
// a way to share.
'undo-edit-header' => [
'performs-writes' => true,
'log_type' => false,
'rc_insert' => true,
'permissions' => [
Header::MODERATED_NONE => '',
],
'links' => [ 'board-history', 'diff-header', 'workflow', 'header-revision' ],
'actions' => [ 'edit-header', 'undo-edit-header' ],
'history' => [
'i18n-message' => 'flow-rev-message-edit-header',
'i18n-params' => [
'user-links',
'user-text',
],
'class' => 'flow-history-edit-header',
],
'handler-class' => \Flow\Actions\FlowAction::class,
'editcount' => true,
// theis modules/moduleStyles is repeated in all the undo-* actions. Find a way to share.
'moduleStyles' => [
'mediawiki.ui.button',
'mediawiki.ui.input',
'ext.flow.styles.base',
],
],
'create-topic-summary' => [
'performs-writes' => true,
'log_type' => false,
'rc_insert' => true,
'permissions' => [
PostSummary::MODERATED_NONE => '',
PostSummary::MODERATED_LOCKED => [ 'flow-lock', 'flow-delete', 'flow-suppress' ],
PostSummary::MODERATED_HIDDEN => [ 'flow-hide', 'flow-delete', 'flow-suppress' ],
PostSummary::MODERATED_DELETED => [ 'flow-delete', 'flow-suppress' ],
PostSummary::MODERATED_SUPPRESSED => [ 'flow-suppress' ],
],
'root-permissions' => [
PostRevision::MODERATED_NONE => '',
PostRevision::MODERATED_LOCKED => '',
],
'links' => [
'topic', 'topic-history', 'diff-post-summary', 'watch-topic', 'unwatch-topic',
'summary-revision'
],
'actions' => [ 'edit-topic-summary', 'lock-topic', 'restore-topic' ],
'history' => [
'i18n-message' => 'flow-rev-message-create-topic-summary',
'i18n-params' => [
'user-links',
'user-text',
'post-of-summary',
],
'class' => 'flow-history-create-topic-summary',
],
'editcount' => true,
],
'edit-topic-summary' => [
'performs-writes' => true,
'log_type' => false,
'rc_insert' => true,
'permissions' => [
PostSummary::MODERATED_NONE => '',
PostSummary::MODERATED_LOCKED => [ 'flow-lock', 'flow-delete', 'flow-suppress' ],
PostSummary::MODERATED_HIDDEN => [ 'flow-hide', 'flow-delete', 'flow-suppress' ],
PostSummary::MODERATED_DELETED => [ 'flow-delete', 'flow-suppress' ],
PostSummary::MODERATED_SUPPRESSED => [ 'flow-suppress' ],
],
'root-permissions' => [
PostRevision::MODERATED_NONE => '',
PostRevision::MODERATED_LOCKED => '',
],
'links' => [
'topic', 'topic-history', 'diff-post-summary', 'watch-topic', 'unwatch-topic',
'summary-revision'
],
'actions' => [
'edit-topic-summary', 'lock-topic', 'restore-topic', 'undo-edit-topic-summary'
],
'history' => [
'i18n-message' => 'flow-rev-message-edit-topic-summary',
'i18n-params' => [
'user-links',
'user-text',
'post-of-summary',
],
'class' => 'flow-history-edit-topic-summary',
],
'handler-class' => \Flow\Actions\FlowAction::class,
'modules' => [],
'editcount' => true,
],
// @todo this is almost copy/paste from edit-topic-summary except the handler class. find a
// way to share
'undo-edit-topic-summary' => [
'performs-writes' => true,
'log_type' => false,
'rc_insert' => true,
'permissions' => [
PostSummary::MODERATED_NONE => '',
PostSummary::MODERATED_LOCKED => [ 'flow-lock', 'flow-delete', 'flow-suppress' ],
PostSummary::MODERATED_HIDDEN => [ 'flow-hide', 'flow-delete', 'flow-suppress' ],
PostSummary::MODERATED_DELETED => [ 'flow-delete', 'flow-suppress' ],
PostSummary::MODERATED_SUPPRESSED => [ 'flow-suppress' ],
],
'root-permissions' => [
PostRevision::MODERATED_NONE => '',
],
'links' => [ 'topic', 'topic-history', 'diff-post-summary', 'watch-topic', 'unwatch-topic' ],
'actions' => [ 'edit-topic-summary', 'lock-topic', 'restore-topic', 'undo-edit-topic-summary' ],
'history' => [
'i18n-message' => 'flow-rev-message-edit-topic-summary',
'i18n-params' => [
'user-links',
'user-text',
'post-of-summary',
],
'class' => 'flow-history-edit-topic-summary',
],
'handler-class' => \Flow\Actions\FlowAction::class,
'editcount' => true,
'moduleStyles' => [
'mediawiki.ui.button',
'mediawiki.ui.input',
'ext.flow.styles.base',
],
],
'edit-title' => [
'performs-writes' => true,
'log_type' => false,
'rc_insert' => true,
'permissions' => [
// no permissions needed for own posts
PostRevision::MODERATED_NONE => static function (
PostRevision $post, RevisionActionPermissions $permissions
) {
return $post->isCreator( $permissions->getUser() ) ? '' : 'flow-edit-title';
}
],
'links' => [
'topic', 'topic-history', 'diff-post', 'topic-revision', 'watch-topic', 'unwatch-topic'
],
'actions' => [
'reply', 'thank', 'edit-title', 'lock-topic', 'hide-topic', 'delete-topic',
'suppress-topic', 'edit-topic-summary', 'lock-topic', 'restore-topic'
],
'history' => [
'i18n-message' => 'flow-rev-message-edit-title',
'i18n-params' => [
'user-links',
'user-text',
'workflow-url',
'plaintext',
'prev-plaintext',
],
'class' => 'flow-history-edit-title',
],
'handler-class' => \Flow\Actions\FlowAction::class,
'modules' => [],
'watch' => [
'immediate' => [ \Flow\Data\Listener\ImmediateWatchTopicListener::class, 'getCurrentUser' ],
],
'editcount' => true,
],
'new-topic' => [
'performs-writes' => true,
'log_type' => false,
'rc_title' => 'owner',
'rc_insert' => true,
'exclude_from_contributions' => true,
// If you add exclude_from_history to new change types, you *must* update
// the *HistoryQuery's (to use doInternalQueries with a good overfetch factor).
// You should also adjust the memcached indices for best results.
'exclude_from_history' => true,
// exclude_from_recentchanges only refers to the actual Special:RecentChanges.
// It does not affect Special:Watchlist.
'exclude_from_recentchanges' => true,
'permissions' => [
PostRevision::MODERATED_NONE => '',
],
'links' => [
'topic-history', 'topic', 'post', 'topic-revision', 'watch-topic', 'unwatch-topic'
],
'actions' => [
'reply', 'thank', 'edit-title', 'hide-topic', 'delete-topic', 'suppress-topic',
'edit-topic-summary', 'lock-topic', 'restore-topic'
],
'history' => [
'i18n-message' => 'flow-rev-message-new-post',
'i18n-params' => [
'user-links',
'user-text',
'workflow-url',
'wikitext',
],
'class' => 'flow-history-new-post',
],
'handler-class' => \Flow\Actions\FlowAction::class,
'modules' => [],
'watch' => [
'immediate' => [ \Flow\Data\Listener\ImmediateWatchTopicListener::class, 'getCurrentUser' ],
],
'editcount' => true,
],
'edit-post' => [
'performs-writes' => true,
'log_type' => false,
'rc_insert' => true,
'permissions' => [
// no permissions needed for own posts
PostRevision::MODERATED_NONE => static function (
PostRevision $post, RevisionActionPermissions $permissions
) {
return $post->isCreator( $permissions->getUser() ) ? '' : 'flow-edit-post';
}
],
'root-permissions' => [
PostRevision::MODERATED_NONE => '',
],
'links' => [ 'post-history', 'topic-history', 'topic', 'post', 'diff-post', 'post-revision' ],
'actions' => [
'reply', 'thank', 'edit-post', 'restore-post', 'hide-post', 'delete-post',
'suppress-post', 'undo-edit-post'
],
'history' => [
'i18n-message' => 'flow-rev-message-edit-post',
'i18n-params' => [
'user-links',
'user-text',
'post-url',
'topic-of-post-text-from-html',
],
'class' => 'flow-history-edit-post',
],
'handler-class' => \Flow\Actions\FlowAction::class,
'modules' => [],
'watch' => [
'immediate' => [ \Flow\Data\Listener\ImmediateWatchTopicListener::class, 'getCurrentUser' ],
],
'editcount' => true,
],
// @todo this is almost (but not quite) copy/paste from 'edit-post'. find a way to share?
'undo-edit-post' => [
'performs-writes' => true,
'log_type' => false, // maybe?
'rc_insert' => true,
'permissions' => [
// no permissions needed for own posts
PostRevision::MODERATED_NONE => static function (
PostRevision $post, RevisionActionPermissions $permissions
) {
return $post->isCreator( $permissions->getUser() ) ? '' : 'flow-edit-post';
}
],
'root-permissions' => [
PostRevision::MODERATED_NONE => '',
],
'links' => [ 'post-history', 'topic-history', 'topic', 'post', 'diff-post', 'post-revision' ],
'actions' => [
'reply', 'thank', 'edit-post', 'restore-post', 'hide-post', 'delete-post',
'suppress-post', 'undo-edit-post'
],
'history' => [
'i18n-message' => 'flow-rev-message-edit-post',
'i18n-params' => [
'user-links',
'user-text',
'post-url',
'topic-of-post-text-from-html',
],
'class' => 'flow-history-edit-post',
],
'handler-class' => \Flow\Actions\FlowAction::class,
'watch' => [
'immediate' => [ \Flow\Data\Listener\ImmediateWatchTopicListener::class, 'getCurrentUser' ],
],
'editcount' => true,
'moduleStyles' => [
'mediawiki.ui.button',
'mediawiki.ui.input',
'ext.flow.styles.base',
],
],
'hide-post' => [
'performs-writes' => true,
'log_type' => false,
'rc_insert' => true,
'permissions' => [
// Permissions required to perform action. The key is the moderation state
// of the post to perform the action against. The value is a string or array
// of user rights that can allow this action.
PostRevision::MODERATED_NONE => [ 'flow-hide', 'flow-delete', 'flow-suppress' ],
],
'root-permissions' => [
// Can only hide within an unmoderated or hidden topic. This doesn't check for a specific
// permissions because thats already done above in 'permissions', this just ensures the
// topic is in an appropriate state.
PostRevision::MODERATED_NONE => '',
PostRevision::MODERATED_HIDDEN => '',
],
'links' => [ 'topic', 'post', 'post-history', 'topic-history', 'post-revision' ],
'actions' => [
'reply', 'thank', 'edit-post', 'restore-post', 'hide-post', 'delete-post', 'suppress-post'
],
'history' => [
'i18n-message' => 'flow-rev-message-hid-post',
'i18n-params' => [
'user-links',
'user-text',
'creator-text',
'post-url',
'moderated-reason',
'topic-of-post-text-from-html',
],
'class' => 'flow-history-hide-post',
],
],
'hide-topic' => [
'performs-writes' => true,
'log_type' => false,
'rc_insert' => true,
'permissions' => [
PostRevision::MODERATED_NONE => [ 'flow-hide', 'flow-delete', 'flow-suppress' ],
],
'links' => [
'topic', 'post', 'topic-history', 'post-history', 'topic-revision', 'watch-topic', 'unwatch-topic'
],
'actions' => [
'reply', 'thank', 'edit-title', 'restore-topic', 'hide-topic', 'delete-topic', 'suppress-topic'
],
'history' => [
'i18n-message' => 'flow-rev-message-hid-topic',
'i18n-params' => [
'user-links',
'user-text',
'creator-text',
'workflow-url',
'moderated-reason',
'topic-of-post-text-from-html',
],
'class' => 'flow-history-hide-topic',
],
],
'delete-post' => [
'performs-writes' => true,
'log_type' => 'delete',
'rc_insert' => true,
'permissions' => [
PostRevision::MODERATED_NONE => [ 'flow-delete', 'flow-suppress' ],
PostRevision::MODERATED_HIDDEN => [ 'flow-delete', 'flow-suppress' ],
],
'links' => [
'topic', 'post', 'post-history', 'topic-history', 'post-revision', 'watch-topic', 'unwatch-topic'
],
'actions' => [
'reply', 'thank', 'edit-post', 'restore-post', 'hide-post', 'delete-post', 'suppress-post'
],
'history' => [
'i18n-message' => 'flow-rev-message-deleted-post',
'i18n-params' => [
'user-links',
'user-text',
'creator-text',
'post-url',
'moderated-reason',
'topic-of-post-text-from-html',
],
'class' => 'flow-history-delete-post',
],
],
'delete-topic' => [
'performs-writes' => true,
'log_type' => 'delete',
'rc_insert' => true,
'permissions' => [
PostRevision::MODERATED_NONE => [ 'flow-delete', 'flow-suppress' ],
PostRevision::MODERATED_HIDDEN => [ 'flow-delete', 'flow-suppress' ],
PostRevision::MODERATED_LOCKED => [ 'flow-delete', 'flow-suppress' ],
],
'links' => [ 'topic', 'topic-history', 'topic-revision', 'watch-topic', 'unwatch-topic' ],
'actions' => [
'reply', 'thank', 'edit-title', 'hide-topic', 'delete-topic', 'suppress-topic',
'edit-topic-summary', 'lock-topic', 'restore-topic'
],
'history' => [
'i18n-message' => 'flow-rev-message-deleted-topic',
'i18n-params' => [
'user-links',
'user-text',
'creator-text',
'workflow-url',
'moderated-reason',
'topic-of-post-text-from-html',
],
'class' => 'flow-history-delete-topic',
],
],
'suppress-post' => [
'performs-writes' => true,
'log_type' => 'suppress',
'rc_insert' => false,
'permissions' => [
PostRevision::MODERATED_NONE => 'flow-suppress',
PostRevision::MODERATED_HIDDEN => 'flow-suppress',
PostRevision::MODERATED_DELETED => 'flow-suppress',
],
'links' => [ 'topic', 'post', 'topic-history', 'post-revision' ],
'actions' => [
'reply', 'thank', 'edit-post', 'restore-post', 'hide-post', 'delete-post', 'suppress-post'
],
'history' => [
'i18n-message' => 'flow-rev-message-suppressed-post',
'i18n-params' => [
'user-links',
'user-text',
'creator-text',
'post-url',
'moderated-reason',
'topic-of-post-text-from-html',
],
'class' => 'flow-history-suppress-post',
],
],
'suppress-topic' => [
'performs-writes' => true,
'log_type' => 'suppress',
'rc_insert' => false,
'permissions' => [
PostRevision::MODERATED_NONE => 'flow-suppress',
PostRevision::MODERATED_HIDDEN => 'flow-suppress',
PostRevision::MODERATED_DELETED => 'flow-suppress',
PostRevision::MODERATED_LOCKED => 'flow-suppress',
],
'links' => [ 'topic', 'topic-history', 'topic-revision', 'watch-topic', 'unwatch-topic' ],
'actions' => [
'reply', 'thank', 'edit-title', 'hide-topic', 'delete-topic', 'suppress-topic',
'edit-topic-summary', 'lock-topic', 'restore-topic'
],
'history' => [
'i18n-message' => 'flow-rev-message-suppressed-topic',
'i18n-params' => [
'user-links',
'user-text',
'creator-text',
'workflow-url',
'moderated-reason',
'topic-of-post-text-from-html',
],
'class' => 'flow-history-suppress-topic',
],
],
'lock-topic' => [
'performs-writes' => true,
'log_type' => 'lock',
'rc_insert' => true,
'permissions' => [
// Only non-moderated topic can be locked
PostRevision::MODERATED_NONE => [ 'flow-lock', 'flow-delete', 'flow-suppress' ],
],
'links' => [ 'topic', 'topic-history', 'watch-topic', 'unwatch-topic', 'topic-revision' ],
'actions' => [ 'edit-topic-summary', 'restore-topic', 'delete-topic', 'suppress-topic' ],
'history' => [
'i18n-message' => 'flow-rev-message-locked-topic',
'i18n-params' => [
'user-links',
'user-text',
'creator-text',
'workflow-url',
'moderated-reason',
'topic-of-post-text-from-html',
],
'class' => 'flow-history-locked-topic',
],
'handler-class' => \Flow\Actions\FlowAction::class,
'modules' => [],
],
'restore-post' => [
'performs-writes' => true,
'log_type' => static function ( PostRevision $revision, ModerationLogger $logger ) {
$post = $revision->getCollection();
$previousRevision = $post->getPrevRevision( $revision );
if ( $previousRevision ) {
// Kind of log depends on the previous change type:
// * if post was deleted, restore should go to deletion log
// * if post was suppressed, restore should go to suppression log
return $previousRevision->getModerationState();
}
return '';
},
'rc_insert' => static function ( PostRevision $revision, RecentChangesListener $recentChanges ) {
$post = $revision->getCollection();
$previousRevision = $post->getPrevRevision( $revision );
if ( $previousRevision ) {
// * if post was hidden/deleted, restore can go to RC
// * if post was suppressed, restore can not go to RC
return $previousRevision->getModerationState() !== 'suppress';
}
return true;
},
'permissions' => [
PostRevision::MODERATED_HIDDEN => [ 'flow-hide', 'flow-delete', 'flow-suppress' ],
PostRevision::MODERATED_DELETED => [ 'flow-delete', 'flow-suppress' ],
PostRevision::MODERATED_SUPPRESSED => 'flow-suppress',
],
'links' => [ 'topic', 'post', 'post-history', 'post-revision' ],
'actions' => [
'reply', 'thank', 'edit-post', 'restore-post', 'hide-post', 'delete-post', 'suppress-post'
],
'history' => [
'i18n-message' => 'flow-rev-message-restored-post',
'i18n-params' => [
'user-links',
'user-text',
'creator-text',
'post-url',
'moderated-reason',
'topic-of-post-text-from-html',
],
'class' => static function ( PostRevision $revision ) {
$previous = $revision->getCollection()->getPrevRevision( $revision );
$state = $previous->getModerationState();
return "flow-history-un$state-post";
}
],
'handler-class' => \Flow\Actions\FlowAction::class,
'modules' => [],
],
'restore-topic' => [
'performs-writes' => true,
'log_type' => static function ( PostRevision $revision, ModerationLogger $logger ) {
$post = $revision->getCollection();
$previousRevision = $post->getPrevRevision( $revision );
if ( $previousRevision ) {
// Kind of log depends on the previous change type:
// * if topic was deleted, restore should go to deletion log
// * if topic was suppressed, restore should go to suppression log
return $previousRevision->getModerationState();
}
return '';
},
'rc_insert' => static function ( PostRevision $revision, RecentChangesListener $recentChanges ) {
$post = $revision->getCollection();
$previousRevision = $post->getPrevRevision( $revision );
if ( $previousRevision ) {
// * if topic was hidden/deleted, restore can go to RC
// * if topic was suppressed, restore can not go to RC
return $previousRevision->getModerationState() !== 'suppress';
}
return true;
},
'permissions' => [
PostRevision::MODERATED_LOCKED => [ 'flow-lock', 'flow-delete', 'flow-suppress' ],
PostRevision::MODERATED_HIDDEN => [ 'flow-hide', 'flow-delete', 'flow-suppress' ],
PostRevision::MODERATED_DELETED => [ 'flow-delete', 'flow-suppress' ],
PostRevision::MODERATED_SUPPRESSED => 'flow-suppress',
],
'links' => [ 'topic', 'topic-history', 'topic-revision', 'watch-topic', 'unwatch-topic' ],
'actions' => [
'reply', 'thank', 'edit-title', 'hide-topic', 'delete-topic', 'suppress-topic',
'edit-topic-summary', 'lock-topic', 'restore-topic'
],
'history' => [
'i18n-message' => 'flow-rev-message-restored-topic',
'i18n-params' => [
'user-links',
'user-text',
'creator-text',
'workflow-url',
'moderated-reason',
'topic-of-post-text-from-html',
],
'class' => static function ( PostRevision $revision ) {
$previous = $revision->getCollection()->getPrevRevision( $revision );
$state = $previous->getModerationState();
return "flow-history-un$state-topic";
}
],
'handler-class' => \Flow\Actions\FlowAction::class,
'modules' => [],
],
'view' => [
'performs-writes' => false,
'hasUserGeneratedContent' => true,
'log_type' => false, // don't log views
'rc_insert' => false, // won't even be called, actually; only for writes
'permissions' => [
PostRevision::MODERATED_NONE => '',
// Everyone has permission to see this,
// but hidden comments are only visible (collapsed) on permalinks directly to them.
PostRevision::MODERATED_HIDDEN => '',
PostRevision::MODERATED_LOCKED => '',
PostRevision::MODERATED_DELETED => [ 'flow-delete', 'flow-suppress' ],
PostRevision::MODERATED_SUPPRESSED => 'flow-suppress',
],
'core-delete-permissions' => [ 'deletedtext' ],
'links' => [], // @todo
'actions' => [], // view is not a recorded change type, no actions will be requested
'history' => [], // views don't generate history
'handler-class' => \Flow\Actions\ViewAction::class,
],
'reply' => [
'performs-writes' => true,
'log_type' => false,
'rc_insert' => true,
'permissions' => [
PostRevision::MODERATED_NONE => '',
],
'root-permissions' => [
PostRevision::MODERATED_NONE => '',
],
'links' => [ 'topic-history', 'topic', 'post', 'post-revision', 'watch-topic', 'unwatch-topic' ],
'actions' => [
'reply', 'thank', 'edit-post', 'hide-post', 'delete-post', 'suppress-post',
'edit-topic-summary', 'lock-topic', 'restore-topic'
],
'history' => [
'i18n-message' => 'flow-rev-message-reply',
'i18n-params' => [
'user-links',
'user-text',
'post-url',
'topic-of-post-text-from-html',
'summary',
],
'class' => 'flow-history-reply',
'bundle' => [
'i18n-message' => 'flow-rev-message-reply-bundle',
'i18n-params' => [
'bundle-count'
],
'class' => 'flow-history-bundle',
],
],
'handler-class' => \Flow\Actions\FlowAction::class,
'modules' => [],
'watch' => [
'immediate' => [ \Flow\Data\Listener\ImmediateWatchTopicListener::class, 'getCurrentUser' ],
],
'editcount' => true,
],
'history' => [
'performs-writes' => false,
'log_type' => false,
'rc_insert' => false, // won't even be called, actually; only for writes
'permissions' => [
PostRevision::MODERATED_NONE => function (
AbstractRevision $revision,
RevisionActionPermissions $permissions
) {
static $previousCollectionId;
/*
* To check permissions, both the current revision (revision-
* specific moderation state) & the last revision (global
* collection moderation state) will always be checked.
* This one has special checks to make sure "restore" actions
* are hidden when the user has no permissions to see the
* moderation state they were restored from.
* We don't want that test to happen; otherwise, when a post
* has just been restored in the most recent revisions, that
* would result in none of the previous revisions being
* available (because a user would need permissions for the
* state the last revision was restored from)
*/
$collection = $revision->getCollection();
if ( $previousCollectionId && $collection->getId()->equals( $previousCollectionId ) ) {
// doublecheck that this run is indeed against the most
// recent revision, to get the global collection state
try {
/** @var Flow\Collection\CollectionCache $cache */
$cache = \Flow\Container::get( 'collection.cache' );
$lastRevision = $cache->getLastRevisionFor( $revision );
if ( $revision->getRevisionId()->equals( $lastRevision->getRevisionId() ) ) {
$previousCollectionId = null;
return '';
}
} catch ( Exception $e ) {
// nothing to do here; if fetching last revision failed,
// we're just not testing any stored revision; that's ok
}
}
$previousCollectionId = $collection->getId();
/*
* If a revision was the result of a restore-action, we have
* to look at the previous revision what the original moderation
* status was; permissions for the restore-actions visibility
* is the same as the moderation (e.g. if user can't see
* suppress actions, he can't see restores from suppress.
*/
if ( strpos( $revision->getChangeType(), 'restore-' ) === 0 ) {
$previous = $collection->getPrevRevision( $revision );
if ( $previous === null ||
$previous->getModerationState() === AbstractRevision::MODERATED_NONE
) {
return '';
}
return $permissions->getPermission( $previous, 'history' );
}
return '';
},
PostRevision::MODERATED_HIDDEN => '',
PostRevision::MODERATED_LOCKED => '',
PostRevision::MODERATED_DELETED => '',
PostRevision::MODERATED_SUPPRESSED => 'flow-suppress',
],
'root-permissions' => [
PostRevision::MODERATED_NONE => '',
PostRevision::MODERATED_LOCKED => '',
PostRevision::MODERATED_HIDDEN => '',
// No data should be shown for other moderation levels: if a topic
// has been deleted, we don't want a bunch of irrelevant
// "new reply", "edit", ... spam in there.
// All we want is the "topic has been deleted", which will still be
// displayed (root-permissions won't be tested for the topic, since
// it is the root)
],
'core-delete-permissions' => [ 'deletedhistory' ],
'history' => [], // views don't generate history
'handler-class' => \Flow\Actions\FlowAction::class,
],
// Pseudo-action to determine when to show thank links,
// currently no limitation. if you can see revision you
// can thank.
'thank' => [
'performs-writes' => false,
'permissions' => [
PostRevision::MODERATED_NONE => '',
PostRevision::MODERATED_HIDDEN => '',
PostRevision::MODERATED_LOCKED => '',
PostRevision::MODERATED_DELETED => '',
PostRevision::MODERATED_SUPPRESSED => '',
],
],
'view-topic-summary' => [
'performs-writes' => false,
'hasUserGeneratedContent' => true,
'log_type' => false, // don't log views
'rc_insert' => false, // won't even be called, actually; only for writes
'permissions' => [
PostRevision::MODERATED_NONE => '',
// Everyone has permission to see this,
// but hidden comments are only visible (collapsed) on permalinks directly to them.
PostRevision::MODERATED_HIDDEN => '',
PostRevision::MODERATED_LOCKED => '',
PostRevision::MODERATED_DELETED => [ 'flow-delete', 'flow-suppress' ],
PostRevision::MODERATED_SUPPRESSED => 'flow-suppress',
],
'root-permissions' => [
PostRevision::MODERATED_NONE => '',
PostRevision::MODERATED_HIDDEN => '',
PostRevision::MODERATED_LOCKED => '',
],
'core-delete-permissions' => [ 'deletedtext' ],
'links' => [], // @todo
'actions' => [], // view is not a recorded change type, no actions will be requested
'history' => [], // views don't generate history
'handler-class' => \Flow\Actions\FlowAction::class,
'modules' => [],
],
// This is only used when we specifically want to see the topic title. If we're
// cascading from a post (to view a post we need to be able to view the topic),
// we'll use 'view' for both the post and topic root. Unprivileged users shouldn't
// be able to view a post in a deleted topic, but should be able to view the topic
// title.
'view-topic-title' => [
'performs-writes' => false,
'hasUserGeneratedContent' => true,
'log_type' => false, // don't log views
'rc_insert' => false, // won't even be called, actually; only for writes
'permissions' => [
// Everyone can see topic titles on existent boards, unless the
// version you're viewing is suppressed, or the most recent version
// is
PostRevision::MODERATED_NONE => '',
PostRevision::MODERATED_HIDDEN => '',
PostRevision::MODERATED_LOCKED => '',
PostRevision::MODERATED_DELETED => '',
PostRevision::MODERATED_SUPPRESSED => 'flow-suppress',
],
'core-delete-permissions' => [ 'deletedtext' ],
'links' => [], // @todo
'actions' => [], // view is not a recorded change type, no actions will be requested
'history' => [], // views don't generate history
'modules' => [],
],
// Actions not tied to a particular revision change_type
// or just move these to a different file
// @todo: we should probably at least add 'permissions' in these below
'compare-header-revisions' => [
'hasUserGeneratedContent' => true,
'handler-class' => \Flow\Actions\FlowAction::class,
'modules' => [],
],
'view-header' => [
'hasUserGeneratedContent' => true,
'handler-class' => \Flow\Actions\FlowAction::class,
'modules' => [],
],
'compare-post-revisions' => [
'hasUserGeneratedContent' => true,
'handler-class' => \Flow\Actions\FlowAction::class,
'modules' => [],
],
// @todo - This is a very bad action name, consolidate with view-post action
'single-view' => [
'hasUserGeneratedContent' => true,
'handler-class' => \Flow\Actions\FlowAction::class,
'modules' => [],
],
'compare-postsummary-revisions' => [
'hasUserGeneratedContent' => true,
'handler-class' => \Flow\Actions\FlowAction::class,
'modules' => [],
],
'moderate-topic' => [
'handler-class' => \Flow\Actions\FlowAction::class,
'modules' => [],
],
'moderate-post' => [
'handler-class' => \Flow\Actions\FlowAction::class,
'modules' => [],
],
// Other formatters have the same config as history
'recentchanges' => 'history',
'contributions' => 'history',
'checkuser' => 'history',
/*
* Backwards compatibility; these are old values that may have made their
* way into the database.
* Instead of having the correct config-array as value, you can just
* reference another action.
*/
'flow-rev-message-edit-title' => 'edit-title',
'flow-edit-title' => 'edit-title',
'flow-rev-message-new-post' => 'new-topic',
'flow-new-post' => 'new-topic',
'flow-rev-message-edit-post' => 'edit-post',
'flow-edit-post' => 'edit-post',
'flow-rev-message-reply' => 'reply',
'flow-reply' => 'reply',
'flow-rev-message-restored-post' => 'restore-post',
'flow-post-restored' => 'restore-post',
'flow-rev-message-hid-post' => 'hide-post',
'flow-post-hidden' => 'hide-post',
'flow-rev-message-deleted-post' => 'delete-post',
'flow-post-deleted' => 'delete-post',
'flow-rev-message-censored-post' => 'suppress-post',
'flow-post-censored' => 'suppress-post',
'flow-rev-message-edit-header' => 'edit-header',
'flow-edit-summary' => 'edit-header',
'flow-rev-message-create-header' => 'create-header',
'flow-create-summary' => 'create-header',
'flow-create-header' => 'create-header',
/*
* Backwards compatibility for previous suppression terminology (=censor).
*/
'censor-post' => 'suppress-post',
'censor-topic' => 'suppress-topic',
/*
* Backwards compatibility for old (separated) history actions
*/
'post-history' => 'history',
'topic-history' => 'history',
'board-history' => 'history',
// The new-topic type used to be called new-post
'new-post' => 'new-topic',
// BC for lock-topic, which used to be called differently
'close-topic' => 'lock-topic',