Add storage for custom policies
Summary: Ref T603. Allows custom policies to be saved. No integration with policy controls yet.
Test Plan:
mysql> select * from policy where id = 3\G
*************************** 1. row ***************************
id: 3
phid: PHID-PLCY-e4v2fnbyuibi4supl5tn
rules: [{"action":"allow","rule":"PhabricatorPolicyRuleAdministrators","value":null},{"action":"allow","rule":"PhabricatorPolicyRuleProjects","value":["PHID-PROJ-cwovm5gn2ilubjehcdgd"]},{"action":"allow","rule":"PhabricatorPolicyRuleLunarPhase","value":"new"}]
defaultAction: deny
dateCreated: 1381437466
dateModified: 1381437466
1 row in set (0.00 sec)
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T603
Differential Revision: https://secure.phabricator.com/D7282
This commit is contained in:
@@ -7,6 +7,8 @@ final class PhabricatorPolicyEditController
|
||||
$request = $this->getRequest();
|
||||
$viewer = $request->getUser();
|
||||
|
||||
$policy = new PhabricatorPolicy();
|
||||
|
||||
$root_id = celerity_generate_unique_node_id();
|
||||
|
||||
$action_options = array(
|
||||
@@ -53,7 +55,6 @@ final class PhabricatorPolicyEditController
|
||||
$rule_obj = $rules[$rule_class];
|
||||
|
||||
$value = $rule_obj->getValueForStorage(idx($rule, 'value'));
|
||||
$value = $rule_obj->getValueForDisplay($viewer, $value);
|
||||
|
||||
$rule_data[] = array(
|
||||
'action' => $action,
|
||||
@@ -62,7 +63,13 @@ final class PhabricatorPolicyEditController
|
||||
);
|
||||
}
|
||||
|
||||
$default_value = $request->getStr('default');
|
||||
$policy->setRules($rule_data);
|
||||
$policy->setDefaultAction($request->getStr('default'));
|
||||
$policy->save();
|
||||
|
||||
// TODO: Integrate with policy editors.
|
||||
$id = $policy->getID();
|
||||
throw new Exception("OK, saved policy {$id}!");
|
||||
} else {
|
||||
$rule_data = array(
|
||||
$default_rule,
|
||||
@@ -76,7 +83,6 @@ final class PhabricatorPolicyEditController
|
||||
'name' => 'default',
|
||||
));
|
||||
|
||||
|
||||
$form = id(new PHUIFormLayoutView())
|
||||
->appendChild(
|
||||
javelin_tag(
|
||||
|
||||
Reference in New Issue
Block a user