Add 'viewer' to some Remarkup callsites
Summary:
I want to implement a `{P123}` rule to embed pastes, but we need viewers everywhere before it will work with privacy.
This is not exhaustive; many Remarkup callsites haven't been converted to `PhabricatorMarkupInterface` yet.
Test Plan: Looked at Maniphest, Differential, Diffusion, Phriction; added markup, made edits and hit previews.
Reviewers: vrana, btrahan
Reviewed By: vrana
CC: aran
Differential Revision: https://secure.phabricator.com/D3428
This commit is contained in:
@@ -56,6 +56,7 @@
|
||||
final class PhabricatorMarkupEngine {
|
||||
|
||||
private $objects = array();
|
||||
private $viewer;
|
||||
|
||||
|
||||
/* -( Markup Pipeline )---------------------------------------------------- */
|
||||
@@ -67,13 +68,16 @@ final class PhabricatorMarkupEngine {
|
||||
*
|
||||
* @param PhabricatorMarkupInterface The object to render.
|
||||
* @param string The field to render.
|
||||
* @param PhabricatorUser User viewing the markup.
|
||||
* @return string Marked up output.
|
||||
* @task markup
|
||||
*/
|
||||
public static function renderOneObject(
|
||||
PhabricatorMarkupInterface $object,
|
||||
$field) {
|
||||
$field,
|
||||
PhabricatorUser $viewer) {
|
||||
return id(new PhabricatorMarkupEngine())
|
||||
->setViewer($viewer)
|
||||
->addObject($object, $field)
|
||||
->process()
|
||||
->getOutput($object, $field);
|
||||
@@ -126,6 +130,7 @@ final class PhabricatorMarkupEngine {
|
||||
$engines = array();
|
||||
foreach ($objects as $key => $info) {
|
||||
$engines[$key] = $info['object']->newMarkupEngine($info['field']);
|
||||
$engines[$key]->setConfig('viewer', $this->viewer);
|
||||
}
|
||||
|
||||
// Load or build the preprocessor caches.
|
||||
@@ -243,9 +248,23 @@ final class PhabricatorMarkupEngine {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the viewing user. Used to implement object permissions.
|
||||
*
|
||||
* @param PhabricatorUser The viewing user.
|
||||
* @return this
|
||||
* @task markup
|
||||
*/
|
||||
public function setViewer(PhabricatorUser $viewer) {
|
||||
$this->viewer = $viewer;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/* -( Engine Construction )------------------------------------------------ */
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @task engine
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user