mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-10 23:01:04 +01:00
Render handles in View and Edit Policies
Summary: Fixes T3184 We make sure that we're not working with a global policy that just sets the title correctly. Otherwise we have a PHID to work with and set the handle as required. Test Plan: Change policies on a mock and see the title render correctly. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T3184 Differential Revision: https://secure.phabricator.com/D6042
This commit is contained in:
parent
9a9e556ca7
commit
d853388944
2 changed files with 27 additions and 4 deletions
|
@ -118,6 +118,16 @@ final class PhabricatorPolicyQuery extends PhabricatorQuery {
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function isGlobalPolicy($policy) {
|
||||||
|
$globalPolicies = self::getGlobalPolicies();
|
||||||
|
|
||||||
|
if (isset($globalPolicies[$policy])) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private static function getGlobalPolicies() {
|
private static function getGlobalPolicies() {
|
||||||
static $constants = array(
|
static $constants = array(
|
||||||
PhabricatorPolicies::POLICY_PUBLIC,
|
PhabricatorPolicies::POLICY_PUBLIC,
|
||||||
|
|
|
@ -123,6 +123,15 @@ abstract class PhabricatorApplicationTransaction
|
||||||
$phids[] = ipull($old, 'dst');
|
$phids[] = ipull($old, 'dst');
|
||||||
$phids[] = ipull($new, 'dst');
|
$phids[] = ipull($new, 'dst');
|
||||||
break;
|
break;
|
||||||
|
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
||||||
|
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
||||||
|
if (!PhabricatorPolicyQuery::isGlobalPolicy($old)) {
|
||||||
|
$phids[] = array($old);
|
||||||
|
}
|
||||||
|
if (!PhabricatorPolicyQuery::isGlobalPolicy($new)) {
|
||||||
|
$phids[] = array($new);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return array_mergev($phids);
|
return array_mergev($phids);
|
||||||
|
@ -242,16 +251,20 @@ abstract class PhabricatorApplicationTransaction
|
||||||
'%s changed the visibility of this %s from "%s" to "%s".',
|
'%s changed the visibility of this %s from "%s" to "%s".',
|
||||||
$this->renderHandleLink($author_phid),
|
$this->renderHandleLink($author_phid),
|
||||||
$this->getApplicationObjectTypeName(),
|
$this->getApplicationObjectTypeName(),
|
||||||
$old,
|
PhabricatorPolicyQuery::isGlobalPolicy($old) ?
|
||||||
$new);
|
$old : $this->renderHandleLink($old),
|
||||||
|
PhabricatorPolicyQuery::isGlobalPolicy($new) ?
|
||||||
|
$new : $this->renderHandleLink($new));
|
||||||
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
||||||
// TODO: Render human-readable.
|
// TODO: Render human-readable.
|
||||||
return pht(
|
return pht(
|
||||||
'%s changed the edit policy of this %s from "%s" to "%s".',
|
'%s changed the edit policy of this %s from "%s" to "%s".',
|
||||||
$this->renderHandleLink($author_phid),
|
$this->renderHandleLink($author_phid),
|
||||||
$this->getApplicationObjectTypeName(),
|
$this->getApplicationObjectTypeName(),
|
||||||
$old,
|
PhabricatorPolicyQuery::isGlobalPolicy($old) ?
|
||||||
$new);
|
$old : $this->renderHandleLink($old),
|
||||||
|
PhabricatorPolicyQuery::isGlobalPolicy($new) ?
|
||||||
|
$new : $this->renderHandleLink($new));
|
||||||
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
|
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
|
||||||
$add = array_diff($new, $old);
|
$add = array_diff($new, $old);
|
||||||
$rem = array_diff($old, $new);
|
$rem = array_diff($old, $new);
|
||||||
|
|
Loading…
Reference in a new issue