Differential D20544 Diff 49017 src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
Show First 20 Lines • Show All 254 Lines • ▼ Show 20 Lines | public function setIsHeraldEditor($is_herald_editor) { | ||||
$this->isHeraldEditor = $is_herald_editor; | $this->isHeraldEditor = $is_herald_editor; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getIsHeraldEditor() { | public function getIsHeraldEditor() { | ||||
return $this->isHeraldEditor; | return $this->isHeraldEditor; | ||||
} | } | ||||
public function setUnmentionablePHIDMap(array $map) { | public function addUnmentionablePHIDs(array $phids) { | ||||
$this->unmentionablePHIDMap = $map; | foreach ($phids as $phid) { | ||||
$this->unmentionablePHIDMap[$phid] = true; | |||||
} | |||||
return $this; | return $this; | ||||
} | } | ||||
public function getUnmentionablePHIDMap() { | private function getUnmentionablePHIDMap() { | ||||
return $this->unmentionablePHIDMap; | return $this->unmentionablePHIDMap; | ||||
} | } | ||||
protected function shouldEnableMentions( | protected function shouldEnableMentions( | ||||
PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
array $xactions) { | array $xactions) { | ||||
return true; | return true; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,808 Lines • ▼ Show 20 Lines | if (!$mentioned_phids) { | ||||
return $block_xactions; | return $block_xactions; | ||||
} | } | ||||
$mentioned_objects = id(new PhabricatorObjectQuery()) | $mentioned_objects = id(new PhabricatorObjectQuery()) | ||||
->setViewer($this->getActor()) | ->setViewer($this->getActor()) | ||||
->withPHIDs($mentioned_phids) | ->withPHIDs($mentioned_phids) | ||||
->execute(); | ->execute(); | ||||
$unmentionable_map = $this->getUnmentionablePHIDMap(); | |||||
$mentionable_phids = array(); | $mentionable_phids = array(); | ||||
if ($this->shouldEnableMentions($object, $xactions)) { | if ($this->shouldEnableMentions($object, $xactions)) { | ||||
foreach ($mentioned_objects as $mentioned_object) { | foreach ($mentioned_objects as $mentioned_object) { | ||||
if ($mentioned_object instanceof PhabricatorMentionableInterface) { | if ($mentioned_object instanceof PhabricatorMentionableInterface) { | ||||
$mentioned_phid = $mentioned_object->getPHID(); | $mentioned_phid = $mentioned_object->getPHID(); | ||||
if (idx($this->getUnmentionablePHIDMap(), $mentioned_phid)) { | if (isset($unmentionable_map[$mentioned_phid])) { | ||||
continue; | continue; | ||||
} | } | ||||
// don't let objects mention themselves | // don't let objects mention themselves | ||||
if ($object->getPHID() && $mentioned_phid == $object->getPHID()) { | if ($object->getPHID() && $mentioned_phid == $object->getPHID()) { | ||||
continue; | continue; | ||||
} | } | ||||
$mentionable_phids[$mentioned_phid] = $mentioned_phid; | $mentionable_phids[$mentioned_phid] = $mentioned_phid; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 3,229 Lines • Show Last 20 Lines |