@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
fork

Configure Feed

Select the types of activity you want to include in your feed.

Conpherence - add storage for view / edit / join policy

Summary: Ref T7582. Also adds the basic logic for "rooms" implementation. Also makes sure we use the initializeNewThread method as appropriate.

Test Plan: made a new conpherence and it worked!

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T7582

Differential Revision: https://secure.phabricator.com/D12103

+60 -5
+17
resources/sql/autopatches/20150317.conpherence.policy.sql
··· 1 + ALTER TABLE {$NAMESPACE}_conpherence.conpherence_thread 2 + ADD viewPolicy VARBINARY(64) NOT NULL AFTER recentParticipantPHIDs; 3 + 4 + UPDATE {$NAMESPACE}_conpherence.conpherence_thread 5 + SET viewPolicy = 'users' WHERE viewPolicy = ''; 6 + 7 + ALTER TABLE {$NAMESPACE}_conpherence.conpherence_thread 8 + ADD editPolicy VARBINARY(64) NOT NULL AFTER viewPolicy; 9 + 10 + UPDATE {$NAMESPACE}_conpherence.conpherence_thread 11 + SET editPolicy = 'users' WHERE editPolicy = ''; 12 + 13 + ALTER TABLE {$NAMESPACE}_conpherence.conpherence_thread 14 + ADD joinPolicy VARBINARY(64) NOT NULL AFTER editPolicy; 15 + 16 + UPDATE {$NAMESPACE}_conpherence.conpherence_thread 17 + SET joinPolicy = 'users' WHERE joinPolicy = '';
+1 -4
src/applications/conpherence/editor/ConpherenceEditor.php
··· 20 20 $message, 21 21 PhabricatorContentSource $source) { 22 22 23 - $conpherence = id(new ConpherenceThread()) 24 - ->attachParticipants(array()) 25 - ->attachFilePHIDs(array()) 26 - ->setMessageCount(0); 23 + $conpherence = ConpherenceThread::initializeNewThread($creator); 27 24 $files = array(); 28 25 $errors = array(); 29 26 if (empty($participant_phids)) {
+42 -1
src/applications/conpherence/storage/ConpherenceThread.php
··· 8 8 protected $messageCount; 9 9 protected $recentParticipantPHIDs = array(); 10 10 protected $mailKey; 11 + protected $viewPolicy; 12 + protected $editPolicy; 13 + protected $joinPolicy; 11 14 12 15 private $participants = self::ATTACHABLE; 13 16 private $transactions = self::ATTACHABLE; ··· 19 22 public static function initializeNewThread(PhabricatorUser $sender) { 20 23 return id(new ConpherenceThread()) 21 24 ->setMessageCount(0) 22 - ->setTitle(''); 25 + ->setTitle('') 26 + ->attachParticipants(array()) 27 + ->attachFilePHIDs(array()) 28 + ->setViewPolicy(PhabricatorPolicies::POLICY_USER) 29 + ->setEditPolicy(PhabricatorPolicies::POLICY_USER) 30 + ->setJoinPolicy(PhabricatorPolicies::POLICY_USER); 31 + } 32 + 33 + public static function initializeNewRoom(PhabricatorUser $creator) { 34 + return id(new ConpherenceThread()) 35 + ->setIsRoom(1) 36 + ->setMessageCount(0) 37 + ->setTitle('') 38 + ->attachParticipants(array()) 39 + ->attachFilePHIDs(array()) 40 + ->setViewPolicy(PhabricatorPolicies::POLICY_USER) 41 + ->setEditPolicy($creator->getPHID()) 42 + ->setJoinPolicy(PhabricatorPolicies::POLICY_USER); 23 43 } 24 44 25 45 protected function getConfiguration() { ··· 33 53 'isRoom' => 'bool', 34 54 'messageCount' => 'uint64', 35 55 'mailKey' => 'text20', 56 + 'joinPolicy' => 'policy', 36 57 ), 37 58 self::CONFIG_KEY_SCHEMA => array( 38 59 'key_room' => array( ··· 190 211 return array( 191 212 PhabricatorPolicyCapability::CAN_VIEW, 192 213 PhabricatorPolicyCapability::CAN_EDIT, 214 + PhabricatorPolicyCapability::CAN_JOIN, 193 215 ); 194 216 } 195 217 196 218 public function getPolicy($capability) { 219 + if ($this->getIsRoom()) { 220 + switch ($capability) { 221 + case PhabricatorPolicyCapability::CAN_VIEW: 222 + return $this->getViewPolicy(); 223 + case PhabricatorPolicyCapability::CAN_EDIT: 224 + return $this->getEditPolicy(); 225 + case PhabricatorPolicyCapability::CAN_JOIN: 226 + return $this->getJoinPolicy(); 227 + } 228 + } 197 229 return PhabricatorPolicies::POLICY_NOONE; 198 230 } 199 231 ··· 202 234 if (!$this->getID()) { 203 235 return true; 204 236 } 237 + 238 + if ($this->getIsRoom()) { 239 + switch ($capability) { 240 + case PhabricatorPolicyCapability::CAN_EDIT: 241 + case PhabricatorPolicyCapability::CAN_JOIN: 242 + return false; 243 + } 244 + } 245 + 205 246 $participants = $this->getParticipants(); 206 247 return isset($participants[$user->getPHID()]); 207 248 }