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

Allow Herald rules to be disabled, instead of deleted

Summary:
Ref T603. Ref T1279. Further improves transaction and policy support for Herald.

- Instead of deleting rules (which wipes out history and can't be undone) allow them to be disabled.
- Track disables with transactions.
- Gate disables with policy controls.
- Show policy and status information in the headers.
- Show transaction history on rule detail screens.
- Remove the delete controller.
- Support disabled queries in the ApplicationSearch.

Test Plan:
- Enabled and disabled rules.
- Searched for enabled/disabled rules.
- Verified disabled rules don't activate.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T1279, T603

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

+408 -96
+2
resources/sql/patches/20131006.hdisable.sql
··· 1 + ALTER TABLE {$NAMESPACE}_herald.herald_rule 2 + ADD isDisabled INT UNSIGNED NOT NULL DEFAULT 0;
+6 -2
src/__phutil_library_map__.php
··· 631 631 'HeraldConditionTranscript' => 'applications/herald/storage/transcript/HeraldConditionTranscript.php', 632 632 'HeraldController' => 'applications/herald/controller/HeraldController.php', 633 633 'HeraldDAO' => 'applications/herald/storage/HeraldDAO.php', 634 - 'HeraldDeleteController' => 'applications/herald/controller/HeraldDeleteController.php', 635 634 'HeraldDifferentialRevisionAdapter' => 'applications/herald/adapter/HeraldDifferentialRevisionAdapter.php', 635 + 'HeraldDisableController' => 'applications/herald/controller/HeraldDisableController.php', 636 636 'HeraldEditLogQuery' => 'applications/herald/query/HeraldEditLogQuery.php', 637 637 'HeraldEffect' => 'applications/herald/engine/HeraldEffect.php', 638 638 'HeraldEngine' => 'applications/herald/engine/HeraldEngine.php', ··· 651 651 'HeraldRuleEdit' => 'applications/herald/storage/HeraldRuleEdit.php', 652 652 'HeraldRuleEditHistoryController' => 'applications/herald/controller/HeraldRuleEditHistoryController.php', 653 653 'HeraldRuleEditHistoryView' => 'applications/herald/view/HeraldRuleEditHistoryView.php', 654 + 'HeraldRuleEditor' => 'applications/herald/editor/HeraldRuleEditor.php', 654 655 'HeraldRuleListController' => 'applications/herald/controller/HeraldRuleListController.php', 655 656 'HeraldRuleQuery' => 'applications/herald/query/HeraldRuleQuery.php', 656 657 'HeraldRuleSearchEngine' => 'applications/herald/query/HeraldRuleSearchEngine.php', ··· 660 661 'HeraldRuleTypeConfig' => 'applications/herald/config/HeraldRuleTypeConfig.php', 661 662 'HeraldRuleViewController' => 'applications/herald/controller/HeraldRuleViewController.php', 662 663 'HeraldTestConsoleController' => 'applications/herald/controller/HeraldTestConsoleController.php', 664 + 'HeraldTransactionQuery' => 'applications/herald/query/HeraldTransactionQuery.php', 663 665 'HeraldTranscript' => 'applications/herald/storage/transcript/HeraldTranscript.php', 664 666 'HeraldTranscriptController' => 'applications/herald/controller/HeraldTranscriptController.php', 665 667 'HeraldTranscriptListController' => 'applications/herald/controller/HeraldTranscriptListController.php', ··· 2724 2726 'HeraldCondition' => 'HeraldDAO', 2725 2727 'HeraldController' => 'PhabricatorController', 2726 2728 'HeraldDAO' => 'PhabricatorLiskDAO', 2727 - 'HeraldDeleteController' => 'HeraldController', 2728 2729 'HeraldDifferentialRevisionAdapter' => 'HeraldAdapter', 2730 + 'HeraldDisableController' => 'HeraldController', 2729 2731 'HeraldEditLogQuery' => 'PhabricatorOffsetPagedQuery', 2730 2732 'HeraldInvalidActionException' => 'Exception', 2731 2733 'HeraldInvalidConditionException' => 'Exception', ··· 2744 2746 'HeraldRuleEdit' => 'HeraldDAO', 2745 2747 'HeraldRuleEditHistoryController' => 'HeraldController', 2746 2748 'HeraldRuleEditHistoryView' => 'AphrontView', 2749 + 'HeraldRuleEditor' => 'PhabricatorApplicationTransactionEditor', 2747 2750 'HeraldRuleListController' => 2748 2751 array( 2749 2752 0 => 'HeraldController', ··· 2755 2758 'HeraldRuleTransactionComment' => 'PhabricatorApplicationTransactionComment', 2756 2759 'HeraldRuleViewController' => 'HeraldController', 2757 2760 'HeraldTestConsoleController' => 'HeraldController', 2761 + 'HeraldTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 2758 2762 'HeraldTranscript' => 2759 2763 array( 2760 2764 0 => 'HeraldDAO',
+2 -1
src/applications/herald/application/PhabricatorApplicationHerald.php
··· 41 41 => 'HeraldNewController', 42 42 'rule/(?P<id>[1-9]\d*)/' => 'HeraldRuleViewController', 43 43 'edit/(?:(?P<id>[1-9]\d*)/)?' => 'HeraldRuleController', 44 + 'disable/(?P<id>[1-9]\d*)/(?P<action>\w+)/' => 45 + 'HeraldDisableController', 44 46 'history/(?:(?P<id>[1-9]\d*)/)?' => 'HeraldRuleEditHistoryController', 45 - 'delete/(?P<id>[1-9]\d*)/' => 'HeraldDeleteController', 46 47 'test/' => 'HeraldTestConsoleController', 47 48 'transcript/' => 'HeraldTranscriptListController', 48 49 'transcript/(?P<id>[1-9]\d*)/(?:(?P<filter>\w+)/)?'
-57
src/applications/herald/controller/HeraldDeleteController.php
··· 1 - <?php 2 - 3 - final class HeraldDeleteController extends HeraldController { 4 - 5 - private $id; 6 - 7 - public function getFilter() { 8 - // note this controller is only used from a dialog-context at the moment 9 - // and there is actually no "delete" filter 10 - return 'delete'; 11 - } 12 - 13 - public function willProcessRequest(array $data) { 14 - $this->id = $data['id']; 15 - } 16 - 17 - public function processRequest() { 18 - 19 - $rule = id(new HeraldRule())->load($this->id); 20 - if (!$rule) { 21 - return new Aphront404Response(); 22 - } 23 - 24 - $request = $this->getRequest(); 25 - $user = $request->getUser(); 26 - 27 - // Anyone can delete a global rule, but only the rule owner can delete a 28 - // personal one. 29 - if ($rule->getRuleType() == HeraldRuleTypeConfig::RULE_TYPE_PERSONAL) { 30 - if ($user->getPHID() != $rule->getAuthorPHID()) { 31 - return new Aphront400Response(); 32 - } 33 - } 34 - 35 - if ($request->isFormPost()) { 36 - $rule->openTransaction(); 37 - $rule->logEdit($user->getPHID(), 'delete'); 38 - $rule->delete(); 39 - $rule->saveTransaction(); 40 - return id(new AphrontReloadResponse())->setURI('/herald/'); 41 - } 42 - 43 - $dialog = new AphrontDialogView(); 44 - $dialog->setUser($request->getUser()); 45 - $dialog->setTitle(pht('Really delete this rule?')); 46 - $dialog->appendChild(pht( 47 - "Are you sure you want to delete the rule: %s?", 48 - $rule->getName())); 49 - $dialog->addSubmitButton(pht('Delete')); 50 - $dialog->addCancelButton('/herald/'); 51 - $dialog->setSubmitURI($request->getPath()); 52 - 53 - return id(new AphrontDialogResponse())->setDialog($dialog); 54 - 55 - } 56 - 57 - }
+74
src/applications/herald/controller/HeraldDisableController.php
··· 1 + <?php 2 + 3 + final class HeraldDisableController extends HeraldController { 4 + 5 + private $id; 6 + private $action; 7 + 8 + public function willProcessRequest(array $data) { 9 + $this->id = $data['id']; 10 + $this->action = $data['action']; 11 + } 12 + 13 + public function processRequest() { 14 + $request = $this->getRequest(); 15 + $viewer = $request->getUser(); 16 + $id = $this->id; 17 + 18 + $rule = id(new HeraldRuleQuery()) 19 + ->setViewer($viewer) 20 + ->withIDs(array($id)) 21 + ->requireCapabilities( 22 + array( 23 + PhabricatorPolicyCapability::CAN_VIEW, 24 + PhabricatorPolicyCapability::CAN_EDIT, 25 + )) 26 + ->executeOne(); 27 + if (!$rule) { 28 + return new Aphront404Response(); 29 + } 30 + 31 + if ($rule->getRuleType() == HeraldRuleTypeConfig::RULE_TYPE_GLOBAL) { 32 + $this->requireApplicationCapability( 33 + PhabricatorApplicationHerald::CAN_CREATE_GLOBAL_RULE); 34 + } 35 + 36 + $view_uri = $this->getApplicationURI("rule/{$id}/"); 37 + 38 + $is_disable = ($this->action === 'disable'); 39 + 40 + if ($request->isFormPost()) { 41 + $xaction = id(new HeraldRuleTransaction()) 42 + ->setTransactionType(HeraldRuleTransaction::TYPE_DISABLE) 43 + ->setNewValue($is_disable); 44 + 45 + id(new HeraldRuleEditor()) 46 + ->setActor($viewer) 47 + ->setContinueOnNoEffect(true) 48 + ->setContentSourceFromRequest($request) 49 + ->applyTransactions($rule, array($xaction)); 50 + 51 + return id(new AphrontRedirectResponse())->setURI($view_uri); 52 + } 53 + 54 + if ($is_disable) { 55 + $title = pht('Really disable this rule?'); 56 + $body = pht('This rule will no longer activate.'); 57 + $button = pht('Disable Rule'); 58 + } else { 59 + $title = pht('Really enable this rule?'); 60 + $body = pht('This rule will become active again.'); 61 + $button = pht('Enable Rule'); 62 + } 63 + 64 + $dialog = id(new AphrontDialogView()) 65 + ->setUser($viewer) 66 + ->setTitle($title) 67 + ->appendChild($body) 68 + ->addSubmitButton($button) 69 + ->addCancelButton($view_uri); 70 + 71 + return id(new AphrontDialogResponse())->setDialog($dialog); 72 + } 73 + 74 + }
+5 -6
src/applications/herald/controller/HeraldRuleListController.php
··· 54 54 $item->addIcon('world', pht('Global Rule')); 55 55 } 56 56 57 + if ($rule->getIsDisabled()) { 58 + $item->setDisabled(true); 59 + $item->addIcon('disable-grey', pht('Disabled')); 60 + } 61 + 57 62 $item->addAction( 58 63 id(new PHUIListItemView()) 59 64 ->setHref($this->getApplicationURI("history/{$id}/")) 60 65 ->setIcon('transcript') 61 66 ->setName(pht('Edit Log'))); 62 - 63 - $item->addAction( 64 - id(new PHUIListItemView()) 65 - ->setHref('/herald/delete/'.$rule->getID().'/') 66 - ->setIcon('delete') 67 - ->setWorkflow(true)); 68 67 69 68 $content_type_name = idx($content_type_map, $rule->getContentType()); 70 69 $item->addAttribute(pht('Affects: %s', $content_type_name));
+64 -1
src/applications/herald/controller/HeraldRuleViewController.php
··· 22 22 } 23 23 24 24 $header = id(new PHUIHeaderView()) 25 - ->setHeader($rule->getName()); 25 + ->setUser($viewer) 26 + ->setHeader($rule->getName()) 27 + ->setPolicyObject($rule); 28 + 29 + if ($rule->getIsDisabled()) { 30 + $header->setStatus( 31 + 'oh-open', 32 + 'red', 33 + pht('Disabled')); 34 + } else { 35 + $header->setStatus( 36 + 'oh-open', 37 + null, 38 + pht('Active')); 39 + } 26 40 27 41 $actions = $this->buildActionView($rule); 28 42 $properties = $this->buildPropertyView($rule); ··· 37 51 ->setActionList($actions) 38 52 ->setPropertyList($properties); 39 53 54 + $timeline = $this->buildTimeline($rule); 55 + 40 56 return $this->buildApplicationPage( 41 57 array( 42 58 $crumbs, 43 59 $object_box, 60 + $timeline, 44 61 ), 45 62 array( 46 63 'title' => $rule->getName(), ··· 70 87 ->setDisabled(!$can_edit) 71 88 ->setWorkflow(!$can_edit)); 72 89 90 + if ($rule->getIsDisabled()) { 91 + $disable_uri = "disable/{$id}/enable/"; 92 + $disable_icon = 'enable'; 93 + $disable_name = pht('Enable Rule'); 94 + } else { 95 + $disable_uri = "disable/{$id}/disable/"; 96 + $disable_icon = 'disable'; 97 + $disable_name = pht('Disable Rule'); 98 + } 99 + 100 + $view->addAction( 101 + id(new PhabricatorActionView()) 102 + ->setName(pht('Disable Rule')) 103 + ->setHref($this->getApplicationURI($disable_uri)) 104 + ->setIcon($disable_icon) 105 + ->setName($disable_name) 106 + ->setDisabled(!$can_edit) 107 + ->setWorkflow(true)); 108 + 73 109 return $view; 74 110 } 75 111 ··· 113 149 } 114 150 115 151 return $view; 152 + } 153 + 154 + private function buildTimeline(HeraldRule $rule) { 155 + $viewer = $this->getRequest()->getUser(); 156 + 157 + $xactions = id(new HeraldTransactionQuery()) 158 + ->setViewer($viewer) 159 + ->withObjectPHIDs(array($rule->getPHID())) 160 + ->needComments(true) 161 + ->execute(); 162 + 163 + $engine = id(new PhabricatorMarkupEngine()) 164 + ->setViewer($viewer); 165 + foreach ($xactions as $xaction) { 166 + if ($xaction->getComment()) { 167 + $engine->addObject( 168 + $xaction->getComment(), 169 + PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT); 170 + } 171 + } 172 + $engine->process(); 173 + 174 + return id(new PhabricatorApplicationTransactionView()) 175 + ->setUser($viewer) 176 + ->setObjectPHID($rule->getPHID()) 177 + ->setTransactions($xactions) 178 + ->setMarkupEngine($engine); 116 179 } 117 180 118 181 }
+1
src/applications/herald/controller/HeraldTestConsoleController.php
··· 59 59 $rules = id(new HeraldRuleQuery()) 60 60 ->setViewer($user) 61 61 ->withContentTypes(array($adapter->getAdapterContentType())) 62 + ->withDisabled(false) 62 63 ->needConditionsAndActions(true) 63 64 ->needAppliedToPHIDs(array($object->getPHID())) 64 65 ->needValidateAuthors(true)
+54
src/applications/herald/editor/HeraldRuleEditor.php
··· 1 + <?php 2 + 3 + final class HeraldRuleEditor 4 + extends PhabricatorApplicationTransactionEditor { 5 + 6 + public function getTransactionTypes() { 7 + $types = parent::getTransactionTypes(); 8 + 9 + $types[] = PhabricatorTransactions::TYPE_COMMENT; 10 + $types[] = HeraldRuleTransaction::TYPE_DISABLE; 11 + 12 + return $types; 13 + } 14 + 15 + protected function getCustomTransactionOldValue( 16 + PhabricatorLiskDAO $object, 17 + PhabricatorApplicationTransaction $xaction) { 18 + 19 + switch ($xaction->getTransactionType()) { 20 + case HeraldRuleTransaction::TYPE_DISABLE: 21 + return (int)$object->getIsDisabled(); 22 + } 23 + 24 + } 25 + 26 + protected function getCustomTransactionNewValue( 27 + PhabricatorLiskDAO $object, 28 + PhabricatorApplicationTransaction $xaction) { 29 + 30 + switch ($xaction->getTransactionType()) { 31 + case HeraldRuleTransaction::TYPE_DISABLE: 32 + return (int)$xaction->getNewValue(); 33 + } 34 + 35 + } 36 + 37 + protected function applyCustomInternalTransaction( 38 + PhabricatorLiskDAO $object, 39 + PhabricatorApplicationTransaction $xaction) { 40 + 41 + switch ($xaction->getTransactionType()) { 42 + case HeraldRuleTransaction::TYPE_DISABLE: 43 + return $object->setIsDisabled($xaction->getNewValue()); 44 + } 45 + 46 + } 47 + 48 + protected function applyCustomExternalTransaction( 49 + PhabricatorLiskDAO $object, 50 + PhabricatorApplicationTransaction $xaction) { 51 + return; 52 + } 53 + 54 + }
+1
src/applications/herald/engine/HeraldEngine.php
··· 27 27 public static function loadAndApplyRules(HeraldAdapter $adapter) { 28 28 $rules = id(new HeraldRuleQuery()) 29 29 ->setViewer(PhabricatorUser::getOmnipotentUser()) 30 + ->withDisabled(false) 30 31 ->withContentTypes(array($adapter->getAdapterContentType())) 31 32 ->needConditionsAndActions(true) 32 33 ->needAppliedToPHIDs(array($adapter->getPHID()))
+14
src/applications/herald/query/HeraldRuleQuery.php
··· 8 8 private $authorPHIDs; 9 9 private $ruleTypes; 10 10 private $contentTypes; 11 + private $disabled; 11 12 12 13 private $needConditionsAndActions; 13 14 private $needAppliedToPHIDs; ··· 40 41 41 42 public function withExecutableRules($executable) { 42 43 $this->executable = $executable; 44 + return $this; 45 + } 46 + 47 + public function withDisabled($disabled) { 48 + $this->disabled = $disabled; 43 49 return $this; 44 50 } 45 51 ··· 82 88 $types = HeraldAdapter::getEnabledAdapterMap($this->getViewer()); 83 89 foreach ($rules as $key => $rule) { 84 90 if (empty($types[$rule->getContentType()])) { 91 + $this->didRejectResult($rule); 85 92 unset($rules[$key]); 86 93 } 87 94 } ··· 169 176 $conn_r, 170 177 'rule.contentType IN (%Ls)', 171 178 $this->contentTypes); 179 + } 180 + 181 + if ($this->disabled !== null) { 182 + $where[] = qsprintf( 183 + $conn_r, 184 + 'rule.isDisabled = %d', 185 + (int)$this->disabled); 172 186 } 173 187 174 188 $where[] = $this->buildPagingClause($conn_r);
+28 -4
src/applications/herald/query/HeraldRuleSearchEngine.php
··· 12 12 13 13 $saved->setParameter('contentType', $request->getStr('contentType')); 14 14 $saved->setParameter('ruleType', $request->getStr('ruleType')); 15 + $saved->setParameter( 16 + 'disabled', 17 + $this->readBoolFromRequest($request, 'disabled')); 15 18 16 19 return $saved; 17 20 } ··· 34 37 $rule_type = idx($this->getRuleTypeValues(), $rule_type); 35 38 if ($rule_type) { 36 39 $query->withRuleTypes(array($rule_type)); 40 + } 41 + 42 + $disabled = $saved->getParameter('disabled'); 43 + if ($disabled !== null) { 44 + $query->withDisabled($disabled); 37 45 } 38 46 39 47 return $query; ··· 71 79 ->setName('ruleType') 72 80 ->setLabel(pht('Rule Type')) 73 81 ->setValue($rule_type) 74 - ->setOptions($this->getRuleTypeOptions())); 82 + ->setOptions($this->getRuleTypeOptions())) 83 + ->appendChild( 84 + id(new AphrontFormSelectControl()) 85 + ->setName('disabled') 86 + ->setLabel(pht('Rule Status')) 87 + ->setValue($this->getBoolFromQuery($saved_query, 'disabled')) 88 + ->setOptions( 89 + array( 90 + '' => pht('Show Enabled and Disabled Rules'), 91 + 'false' => pht('Show Only Enabled Rules'), 92 + 'true' => pht('Show Only Disabled Rules'), 93 + ))); 75 94 } 76 95 77 96 protected function getURI($path) { ··· 85 104 $names['authored'] = pht('Authored'); 86 105 } 87 106 107 + $names['active'] = pht('Active'); 88 108 $names['all'] = pht('All'); 89 109 90 110 return $names; ··· 94 114 95 115 $query = $this->newSavedQuery(); 96 116 $query->setQueryKey($query_key); 117 + 118 + $viewer_phid = $this->requireViewer()->getPHID(); 97 119 98 120 switch ($query_key) { 99 121 case 'all': 100 122 return $query; 123 + case 'active': 124 + return $query->setParameter('disabled', false); 101 125 case 'authored': 102 - return $query->setParameter( 103 - 'authorPHIDs', 104 - array($this->requireViewer()->getPHID())); 126 + return $query 127 + ->setParameter('authorPHIDs', array($viewer_phid)) 128 + ->setParameter('disabled', false); 105 129 } 106 130 107 131 return parent::buildSavedQueryFromBuiltin($query_key);
+10
src/applications/herald/query/HeraldTransactionQuery.php
··· 1 + <?php 2 + 3 + final class HeraldTransactionQuery 4 + extends PhabricatorApplicationTransactionQuery { 5 + 6 + public function getTemplateApplicationTransaction() { 7 + return new HeraldRuleTransaction(); 8 + } 9 + 10 + }
+14 -3
src/applications/herald/storage/HeraldRule.php
··· 12 12 protected $mustMatchAll; 13 13 protected $repetitionPolicy; 14 14 protected $ruleType; 15 + protected $isDisabled = 0; 15 16 16 17 protected $configVersion = 14; 17 18 ··· 198 199 199 200 public function getPolicy($capability) { 200 201 if ($this->isGlobalRule()) { 201 - return PhabricatorPolicies::POLICY_USER; 202 + switch ($capability) { 203 + case PhabricatorPolicyCapability::CAN_VIEW: 204 + return PhabricatorPolicies::POLICY_USER; 205 + case PhabricatorPolicyCapability::CAN_EDIT: 206 + $app = 'PhabricatorApplicationHerald'; 207 + $herald = PhabricatorApplication::getByClass($app); 208 + $global = PhabricatorApplicationHerald::CAN_CREATE_GLOBAL_RULE; 209 + return $herald->getPolicy($global); 210 + } 202 211 } else { 203 212 return PhabricatorPolicies::POLICY_NOONE; 204 213 } ··· 213 222 } 214 223 215 224 public function describeAutomaticCapability($capability) { 216 - // TODO: (T603) Sort this out. 225 + if ($this->isPersonalRule()) { 226 + return pht("A personal rule's owner can always view and edit it."); 227 + } 228 + 217 229 return null; 218 230 } 219 - 220 231 221 232 }
+72 -1
src/applications/herald/storage/HeraldRuleTransaction.php
··· 4 4 extends PhabricatorApplicationTransaction { 5 5 6 6 const TYPE_EDIT = 'herald:edit'; 7 + const TYPE_DISABLE = 'herald:disable'; 7 8 8 9 public function getApplicationName() { 9 10 return 'herald'; ··· 17 18 return new HeraldRuleTransactionComment(); 18 19 } 19 20 20 - } 21 + public function getColor() { 22 + $old = $this->getOldValue(); 23 + $new = $this->getNewValue(); 24 + 25 + switch ($this->getTransactionType()) { 26 + case self::TYPE_DISABLE: 27 + if ($new) { 28 + return 'red'; 29 + } else { 30 + return 'green'; 31 + } 32 + } 33 + 34 + return parent::getColor(); 35 + } 36 + 37 + public function getActionName() { 38 + $old = $this->getOldValue(); 39 + $new = $this->getNewValue(); 40 + 41 + switch ($this->getTransactionType()) { 42 + case self::TYPE_DISABLE: 43 + if ($new) { 44 + return pht('Disabled'); 45 + } else { 46 + return pht('Enabled'); 47 + } 48 + } 49 + 50 + return parent::getActionName(); 51 + } 52 + 53 + public function getIcon() { 54 + $old = $this->getOldValue(); 55 + $new = $this->getNewValue(); 56 + 57 + switch ($this->getTransactionType()) { 58 + case self::TYPE_DISABLE: 59 + if ($new) { 60 + return 'disable'; 61 + } else { 62 + return 'enable'; 63 + } 64 + } 21 65 66 + return parent::getIcon(); 67 + } 68 + 69 + 70 + public function getTitle() { 71 + $author_phid = $this->getAuthorPHID(); 72 + 73 + $old = $this->getOldValue(); 74 + $new = $this->getNewValue(); 75 + 76 + switch ($this->getTransactionType()) { 77 + case self::TYPE_DISABLE: 78 + if ($new) { 79 + return pht( 80 + '%s disabled this rule.', 81 + $this->renderHandleLink($author_phid)); 82 + } else { 83 + return pht( 84 + '%s enabled this rule.', 85 + $this->renderHandleLink($author_phid)); 86 + } 87 + } 88 + 89 + return parent::getTitle(); 90 + } 91 + 92 + }
+12 -21
src/applications/meta/query/PhabricatorAppSearchEngine.php
··· 12 12 13 13 $saved->setParameter('name', $request->getStr('name')); 14 14 15 - $saved->setParameter('installed', $this->readBool($request, 'installed')); 16 - $saved->setParameter('beta', $this->readBool($request, 'beta')); 17 - $saved->setParameter('firstParty', $this->readBool($request, 'firstParty')); 15 + $saved->setParameter( 16 + 'installed', 17 + $this->readBoolFromRequest($request, 'installed')); 18 + $saved->setParameter( 19 + 'beta', 20 + $this->readBoolFromRequest($request, 'beta')); 21 + $saved->setParameter( 22 + 'firstParty', 23 + $this->readBoolFromRequest($request, 'firstParty')); 18 24 19 25 return $saved; 20 26 } ··· 61 67 id(new AphrontFormSelectControl()) 62 68 ->setLabel(pht('Installed')) 63 69 ->setName('installed') 64 - ->setValue($this->getBool($saved, 'installed')) 70 + ->setValue($this->getBoolFromQuery($saved, 'installed')) 65 71 ->setOptions( 66 72 array( 67 73 '' => pht('Show All Applications'), ··· 72 78 id(new AphrontFormSelectControl()) 73 79 ->setLabel(pht('Beta')) 74 80 ->setName('beta') 75 - ->setValue($this->getBool($saved, 'beta')) 81 + ->setValue($this->getBoolFromQuery($saved, 'beta')) 76 82 ->setOptions( 77 83 array( 78 84 '' => pht('Show All Applications'), ··· 83 89 id(new AphrontFormSelectControl()) 84 90 ->setLabel(pht('Provenance')) 85 91 ->setName('firstParty') 86 - ->setValue($this->getBool($saved, 'firstParty')) 92 + ->setValue($this->getBoolFromQuery($saved, 'firstParty')) 87 93 ->setOptions( 88 94 array( 89 95 '' => pht('Show All Applications'), ··· 116 122 } 117 123 118 124 return parent::buildSavedQueryFromBuiltin($query_key); 119 - } 120 - 121 - private function readBool(AphrontRequest $request, $key) { 122 - if (!strlen($request->getStr($key))) { 123 - return null; 124 - } 125 - return $request->getBool($key); 126 - } 127 - 128 - private function getBool(PhabricatorSavedQuery $query, $key) { 129 - $value = $query->getParameter($key); 130 - if ($value === null) { 131 - return $value; 132 - } 133 - return $value ? 'true' : 'false'; 134 125 } 135 126 136 127 }
+1
src/applications/repository/worker/PhabricatorRepositoryCommitHeraldWorker.php
··· 29 29 $rules = id(new HeraldRuleQuery()) 30 30 ->setViewer(PhabricatorUser::getOmnipotentUser()) 31 31 ->withContentTypes(array($adapter->getAdapterContentType())) 32 + ->withDisabled(false) 32 33 ->needConditionsAndActions(true) 33 34 ->needAppliedToPHIDs(array($adapter->getPHID())) 34 35 ->needValidateAuthors(true)
+19
src/applications/search/engine/PhabricatorApplicationSearchEngine.php
··· 299 299 } 300 300 301 301 302 + protected function readBoolFromRequest( 303 + AphrontRequest $request, 304 + $key) { 305 + if (!strlen($request->getStr($key))) { 306 + return null; 307 + } 308 + return $request->getBool($key); 309 + } 310 + 311 + 312 + protected function getBoolFromQuery(PhabricatorSavedQuery $query, $key) { 313 + $value = $query->getParameter($key); 314 + if ($value === null) { 315 + return $value; 316 + } 317 + return $value ? 'true' : 'false'; 318 + } 319 + 320 + 302 321 /* -( Dates )-------------------------------------------------------------- */ 303 322 304 323
+4
src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php
··· 1660 1660 'type' => 'php', 1661 1661 'name' => $this->getPatchPath('20131004.dxreviewers.php'), 1662 1662 ), 1663 + '20131006.hdisable.sql' => array( 1664 + 'type' => 'sql', 1665 + 'name' => $this->getPatchPath('20131006.hdisable.sql'), 1666 + ), 1663 1667 ); 1664 1668 } 1665 1669 }
+25
src/view/phui/PHUIHeaderView.php
··· 65 65 return $this; 66 66 } 67 67 68 + public function setStatus($icon, $color, $name) { 69 + $header_class = 'phui-header-status'; 70 + 71 + if ($color) { 72 + $icon = $icon.'-'.$color; 73 + $header_class = $header_class.'-'.$color; 74 + } 75 + 76 + $img = id(new PHUIIconView()) 77 + ->setSpriteSheet(PHUIIconView::SPRITE_STATUS) 78 + ->setSpriteIcon($icon); 79 + 80 + $tag = phutil_tag( 81 + 'span', 82 + array( 83 + 'class' => "{$header_class} plr", 84 + ), 85 + array( 86 + $img, 87 + $name, 88 + )); 89 + 90 + return $this->addProperty(self::PROPERTY_STATUS, $tag); 91 + } 92 + 68 93 public function render() { 69 94 require_celerity_resource('phui-header-view-css'); 70 95