public function applyEffect($object, HeraldEffect $effect) { $phid = $effect->getRule()->getAuthorPHID(); // For personal rules, we'll force delivery of a real email. This effect // is stronger than notification preferences, so you get an actual email // even if your preferences are set to "Notify" or "Ignore". return $this->applyEmail(array($phid), $force = true); }
public function applyEffect($object, HeraldEffect $effect) { $phid = $this->getAdapter()->getPHID(); $rule = $effect->getRule(); $author = $rule->getAuthor(); $flag = PhabricatorFlagQuery::loadUserFlag($author, $phid); if ($flag) { $this->logEffect(self::DO_IGNORE, $flag->getColor()); return; } $flag = id(new PhabricatorFlag())->setOwnerPHID($author->getPHID())->setType(phid_get_type($phid))->setObjectPHID($phid)->setReasonPHID($rule->getPHID())->setColor($effect->getTarget())->setNote('')->save(); $this->logEffect(self::DO_FLAG, $flag->getColor()); }
public function applyEffect($object, HeraldEffect $effect) { $status = head($effect->getTarget()); if (!$status) { $this->logEffect(self::DO_STANDARD_EMPTY); return; } $adapter = $this->getAdapter(); $object = $adapter->getObject(); $current = $object->getStatus(); if ($current == $status) { $this->logEffect(self::DO_STANDARD_NO_EFFECT, $status); return; } $xaction = $adapter->newTransaction()->setTransactionType(ManiphestTransaction::TYPE_STATUS)->setNewValue($status); $adapter->queueTransaction($xaction); $this->logEffect(self::DO_STATUS, $status); }
public function applyEffect($object, HeraldEffect $effect) { $priority = head($effect->getTarget()); if (!$priority) { $this->logEffect(self::DO_STANDARD_EMPTY); return; } $adapter = $this->getAdapter(); $object = $adapter->getObject(); $current = $object->getPriority(); if ($current == $priority) { $this->logEffect(self::DO_STANDARD_NO_EFFECT, $priority); return; } $xaction = $adapter->newTransaction()->setTransactionType(ManiphestTransaction::TYPE_PRIORITY)->setNewValue($priority); $adapter->queueTransaction($xaction); $this->logEffect(self::DO_PRIORITY, $priority); }
public static function applyFlagEffect(HeraldEffect $effect, $phid) { $color = $effect->getTarget(); // TODO: Silly that we need to load this again here. $rule = id(new HeraldRule())->load($effect->getRuleID()); $user = id(new PhabricatorUser())->loadOneWhere('phid = %s', $rule->getAuthorPHID()); $flag = PhabricatorFlagQuery::loadUserFlag($user, $phid); if ($flag) { return new HeraldApplyTranscript($effect, false, 'Object already flagged.'); } $handle = PhabricatorObjectHandleData::loadOneHandle($phid); $flag = new PhabricatorFlag(); $flag->setOwnerPHID($user->getPHID()); $flag->setType($handle->getType()); $flag->setObjectPHID($handle->getPHID()); // TOOD: Should really be transcript PHID, but it doesn't exist yet. $flag->setReasonPHID($user->getPHID()); $flag->setColor($color); $flag->setNote('Flagged by Herald Rule "' . $rule->getName() . '".'); $flag->save(); return new HeraldApplyTranscript($effect, true, 'Added flag.'); }
public function __construct(HeraldEffect $effect, $applied, $reason = null) { $this->setAction($effect->getAction()); $this->setTarget($effect->getTarget()); $this->setRuleID($effect->getRuleID()); $this->setEffector($effect->getEffector()); $this->setReason($effect->getReason()); $this->setApplied($applied); $this->setAppliedReason($reason); }
public function applyEffect($object, HeraldEffect $effect) { return $this->applyBuilds($effect->getTarget(), $effect->getRule()); }
/** * @task apply */ private function applyEmailEffect(HeraldEffect $effect) { foreach ($effect->getTarget() as $phid) { $this->emailPHIDs[$phid] = $phid; // If this is a personal rule, we'll force delivery of a real email. This // effect is stronger than notification preferences, so you get an actual // email even if your preferences are set to "Notify" or "Ignore". $rule = $effect->getRule(); if ($rule->isPersonalRule()) { $this->forcedEmailPHIDs[$phid] = $phid; } } return new HeraldApplyTranscript($effect, true, pht('Added mailable to mail targets.')); }
public function applyEffect($object, HeraldEffect $effect) { $rule = $effect->getRule(); $author_phid = $rule->getAuthorPHID(); $this->applyRouting($rule, PhabricatorMailRoutingRule::ROUTE_AS_MAIL, array($author_phid)); }
public function applyEffect($object, HeraldEffect $effect) { return $this->applyEmail($effect->getTarget(), $force = false); }
public function applyEffect($object, HeraldEffect $effect) { $rule = $effect->getRule(); $phid = $rule->getAuthorPHID(); return $this->applyAuditors(array($phid), $rule); }
public function applyHeraldEffects(array $effects) { assert_instances_of($effects, 'HeraldEffect'); $result = array(); if ($this->explicitCCs) { $effect = new HeraldEffect(); $effect->setAction(HeraldActionConfig::ACTION_ADD_CC); $effect->setTarget(array_keys($this->explicitCCs)); $effect->setReason('CCs provided explicitly by revision author or carried over from a ' . 'previous version of the revision.'); $result[] = new HeraldApplyTranscript($effect, true, 'Added addresses to CC list.'); } $forbidden_ccs = array_fill_keys(nonempty($this->forbiddenCCs, array()), true); foreach ($effects as $effect) { $action = $effect->getAction(); switch ($action) { case HeraldActionConfig::ACTION_NOTHING: $result[] = new HeraldApplyTranscript($effect, true, 'OK, did nothing.'); break; case HeraldActionConfig::ACTION_FLAG: $result[] = parent::applyFlagEffect($effect, $this->revision->getPHID()); break; case HeraldActionConfig::ACTION_EMAIL: case HeraldActionConfig::ACTION_ADD_CC: $op = $action == HeraldActionConfig::ACTION_EMAIL ? 'email' : 'CC'; $base_target = $effect->getTarget(); $forbidden = array(); foreach ($base_target as $key => $fbid) { if (isset($forbidden_ccs[$fbid])) { $forbidden[] = $fbid; unset($base_target[$key]); } else { if ($action == HeraldActionConfig::ACTION_EMAIL) { $this->emailPHIDs[$fbid] = true; } else { $this->newCCs[$fbid] = true; } } } if ($forbidden) { $failed = clone $effect; $failed->setTarget($forbidden); if ($base_target) { $effect->setTarget($base_target); $result[] = new HeraldApplyTranscript($effect, true, 'Added these addresses to ' . $op . ' list. ' . 'Others could not be added.'); } $result[] = new HeraldApplyTranscript($failed, false, $op . ' forbidden, these addresses have unsubscribed.'); } else { $result[] = new HeraldApplyTranscript($effect, true, 'Added addresses to ' . $op . ' list.'); } break; case HeraldActionConfig::ACTION_REMOVE_CC: foreach ($effect->getTarget() as $fbid) { $this->remCCs[$fbid] = true; } $result[] = new HeraldApplyTranscript($effect, true, 'Removed addresses from CC list.'); break; default: throw new Exception("No rules to handle action '{$action}'."); } } return $result; }
protected function getRuleEffects(HeraldRule $rule, HeraldObjectAdapter $object) { $effects = array(); foreach ($rule->getActions() as $action) { $effect = new HeraldEffect(); $effect->setObjectPHID($object->getPHID()); $effect->setAction($action->getAction()); $effect->setTarget($action->getTarget()); $effect->setRuleID($rule->getID()); $name = $rule->getName(); $id = $rule->getID(); $effect->setReason('Conditions were met for Herald rule "' . $name . '" (#' . $id . ').'); $effects[] = $effect; } return $effects; }
public function applyEffect($object, HeraldEffect $effect) { $phid = $effect->getRule()->getAuthorPHID(); return $this->applyAssign(array($phid)); }
public function applyEffect($object, HeraldEffect $effect) { return $this->applyRequire($effect->getTarget()); }
public function applyEffect($object, HeraldEffect $effect) { return $this->applyProjects($effect->getTarget(), $is_add = true); }
public function applyEffect($object, HeraldEffect $effect) { $rule = $effect->getRule(); return $this->applyAuditors($effect->getTarget(), $rule); }
public function applyHeraldEffects(array $effects) { assert_instances_of($effects, 'HeraldEffect'); $result = array(); if ($this->explicitCCs) { $effect = new HeraldEffect(); $effect->setAction(self::ACTION_ADD_CC); $effect->setTarget(array_keys($this->explicitCCs)); $effect->setReason(pht('CCs provided explicitly by revision author or carried over ' . 'from a previous version of the revision.')); $result[] = new HeraldApplyTranscript($effect, true, pht('Added addresses to CC list.')); } $forbidden_ccs = array_fill_keys(nonempty($this->forbiddenCCs, array()), true); foreach ($effects as $effect) { $action = $effect->getAction(); switch ($action) { case self::ACTION_NOTHING: $result[] = new HeraldApplyTranscript($effect, true, pht('OK, did nothing.')); break; case self::ACTION_FLAG: $result[] = parent::applyFlagEffect($effect, $this->revision->getPHID()); break; case self::ACTION_EMAIL: case self::ACTION_ADD_CC: $op = $action == self::ACTION_EMAIL ? 'email' : 'CC'; $base_target = $effect->getTarget(); $forbidden = array(); foreach ($base_target as $key => $fbid) { if (isset($forbidden_ccs[$fbid])) { $forbidden[] = $fbid; unset($base_target[$key]); } else { if ($action == self::ACTION_EMAIL) { $this->emailPHIDs[$fbid] = true; } else { $this->newCCs[$fbid] = true; } } } if ($forbidden) { $failed = clone $effect; $failed->setTarget($forbidden); if ($base_target) { $effect->setTarget($base_target); $result[] = new HeraldApplyTranscript($effect, true, pht('Added these addresses to %s list. ' . 'Others could not be added.', $op)); } $result[] = new HeraldApplyTranscript($failed, false, pht('%s forbidden, these addresses have unsubscribed.', $op)); } else { $result[] = new HeraldApplyTranscript($effect, true, pht('Added addresses to %s list.', $op)); } break; case self::ACTION_REMOVE_CC: foreach ($effect->getTarget() as $fbid) { $this->remCCs[$fbid] = true; } $result[] = new HeraldApplyTranscript($effect, true, pht('Removed addresses from CC list.')); break; case self::ACTION_ADD_REVIEWERS: foreach ($effect->getTarget() as $phid) { $this->addReviewerPHIDs[$phid] = true; } $result[] = new HeraldApplyTranscript($effect, true, pht('Added reviewers.')); break; case self::ACTION_ADD_BLOCKING_REVIEWERS: // This adds reviewers normally, it just also marks them blocking. foreach ($effect->getTarget() as $phid) { $this->addReviewerPHIDs[$phid] = true; $this->blockingReviewerPHIDs[$phid] = true; } $result[] = new HeraldApplyTranscript($effect, true, pht('Added blocking reviewers.')); break; case self::ACTION_APPLY_BUILD_PLANS: foreach ($effect->getTarget() as $phid) { $this->buildPlans[] = $phid; } $result[] = new HeraldApplyTranscript($effect, true, pht('Applied build plans.')); break; case self::ACTION_REQUIRE_SIGNATURE: foreach ($effect->getTarget() as $phid) { $this->requiredSignatureDocumentPHIDs[] = $phid; } $result[] = new HeraldApplyTranscript($effect, true, pht('Required signatures.')); break; default: $custom_result = parent::handleCustomHeraldEffect($effect); if ($custom_result === null) { throw new Exception(pht("No rules to handle action '%s'.", $action)); } $result[] = $custom_result; break; } } return $result; }
/** * @task apply */ protected function applyStandardEffect(HeraldEffect $effect) { $action = $effect->getAction(); $rule_type = $effect->getRule()->getRuleType(); $impl = $this->getActionImplementation($action); if (!$impl) { return new HeraldApplyTranscript($effect, false, array(array(HeraldAction::DO_STANDARD_INVALID_ACTION, $action))); } if (!$impl->supportsRuleType($rule_type)) { return new HeraldApplyTranscript($effect, false, array(array(HeraldAction::DO_STANDARD_WRONG_RULE_TYPE, $rule_type))); } $impl->applyEffect($this->getObject(), $effect); return $impl->getApplyTranscript($effect); }
public function applyEffect($object, HeraldEffect $effect) { return $this->applySubscribe($effect->getTarget(), $is_add = false); }
public function applyEffect($object, HeraldEffect $effect) { $phid = $effect->getRule()->getAuthorPHID(); return $this->applySubscribe(array($phid), $is_add = false); }
public function applyEffect($object, HeraldEffect $effect) { $phid = $effect->getRule()->getAuthorPHID(); return $this->applyReviewers(array($phid), $is_blocking = false); }
protected function getRuleEffects(HeraldRule $rule, HeraldAdapter $object) { $effects = array(); foreach ($rule->getActions() as $action) { $effect = new HeraldEffect(); $effect->setObjectPHID($object->getPHID()); $effect->setAction($action->getAction()); $effect->setTarget($action->getTarget()); $effect->setRuleID($rule->getID()); $effect->setRulePHID($rule->getPHID()); $name = $rule->getName(); $id = $rule->getID(); $effect->setReason(pht('Conditions were met for %s', "H{$id} {$name}")); $effects[] = $effect; } return $effects; }
public function applyEffect($object, HeraldEffect $effect) { return $this->applyReviewers($effect->getTarget(), $is_blocking = true); }