@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class ConpherenceEditEngine
4 extends PhabricatorEditEngine {
5
6 const ENGINECONST = 'conpherence.thread';
7
8 public function getEngineName() {
9 return pht('Conpherence');
10 }
11
12 public function getEngineApplicationClass() {
13 return PhabricatorConpherenceApplication::class;
14 }
15
16 public function getSummaryHeader() {
17 return pht('Configure Conpherence Forms');
18 }
19
20 public function getSummaryText() {
21 return pht('Configure creation and editing forms in Conpherence.');
22 }
23
24 protected function newEditableObject() {
25 return ConpherenceThread::initializeNewRoom($this->getViewer());
26 }
27
28 protected function newObjectQuery() {
29 return new ConpherenceThreadQuery();
30 }
31
32 protected function getObjectCreateTitleText($object) {
33 return pht('Create New Room');
34 }
35
36 protected function getObjectEditTitleText($object) {
37 return pht('Edit Room: %s', $object->getTitle());
38 }
39
40 protected function getObjectEditShortText($object) {
41 return $object->getTitle();
42 }
43
44 protected function getObjectCreateShortText() {
45 return pht('Create Room');
46 }
47
48 protected function getObjectName() {
49 return pht('Room');
50 }
51
52 protected function getObjectCreateCancelURI($object) {
53 return $this->getApplication()->getApplicationURI('/');
54 }
55
56 protected function getEditorURI() {
57 return $this->getApplication()->getApplicationURI('edit/');
58 }
59
60 protected function getObjectViewURI($object) {
61 return $object->getURI();
62 }
63
64 protected function getCreateNewObjectPolicy() {
65 return $this->getApplication()->getPolicy(
66 ConpherenceCreateRoomCapability::CAPABILITY);
67 }
68
69 public function isEngineConfigurable() {
70 return false;
71 }
72
73 protected function buildCustomEditFields($object) {
74 $viewer = $this->getViewer();
75
76 if ($this->getIsCreate()) {
77 $participant_phids = array($viewer->getPHID());
78 $initial_phids = array();
79 } else {
80 $participant_phids = $object->getParticipantPHIDs();
81 $initial_phids = $participant_phids;
82 }
83
84 // Only show participants on create or conduit, not edit.
85 $show_participants = (bool)$this->getIsCreate();
86
87 return array(
88 id(new PhabricatorTextEditField())
89 ->setKey('name')
90 ->setLabel(pht('Name'))
91 ->setDescription(pht('Room name.'))
92 ->setConduitTypeDescription(pht('New Room name.'))
93 ->setIsRequired(true)
94 ->setTransactionType(
95 ConpherenceThreadTitleTransaction::TRANSACTIONTYPE)
96 ->setValue($object->getTitle()),
97
98 id(new PhabricatorTextEditField())
99 ->setKey('topic')
100 ->setLabel(pht('Topic'))
101 ->setDescription(pht('Room topic.'))
102 ->setConduitTypeDescription(pht('New Room topic.'))
103 ->setTransactionType(
104 ConpherenceThreadTopicTransaction::TRANSACTIONTYPE)
105 ->setValue($object->getTopic()),
106
107 id(new PhabricatorUsersEditField())
108 ->setKey('participants')
109 ->setValue($participant_phids)
110 ->setInitialValue($initial_phids)
111 ->setIsFormField($show_participants)
112 ->setAliases(array('users', 'members', 'participants', 'userPHID'))
113 ->setDescription(pht('Room participants.'))
114 ->setUseEdgeTransactions(true)
115 ->setConduitTypeDescription(pht('New Room participants.'))
116 ->setTransactionType(
117 ConpherenceThreadParticipantsTransaction::TRANSACTIONTYPE)
118 ->setLabel(pht('Initial Participants')),
119
120 );
121 }
122
123}