/** * Get the condition class for this condition * * @param $conditionId * @param bool $abort if true this function will throw an exception if class could not be instanciated * @return CRM_Civirules_Condition * @throws Exception if abort is set to true and class does not exist or is not valid */ public static function getConditionObjectById($conditionId, $abort = true) { $condition = new CRM_Civirules_BAO_Condition(); $condition->id = $conditionId; if (!$condition->find(true)) { if ($abort) { throw new Exception('CiviRule could not find condition'); } return false; } $className = $condition->class_name; if (!class_exists($className)) { if ($abort) { throw new Exception('CiviRule condition class "' . $className . '" does not exist'); } return false; } $object = new $className(); if (!$object instanceof CRM_Civirules_Condition) { if ($abort) { throw new Exception('CiviRule condition class "' . $className . '" is not a subclass of CRM_Civirules_Condition'); } return false; } return $object; }
/** * Method to set the form title * * @access protected */ protected function setFormTitle() { $conditionLabel = ''; $ruleCondition = new CRM_Civirules_BAO_RuleCondition(); $ruleCondition->id = $this->ruleConditionId; if ($ruleCondition->find(true)) { $condition = new CRM_Civirules_BAO_Condition(); $condition->id = $ruleCondition->condition_id; if ($condition->find(true)) { $conditionLabel = $condition->label; } } $title = 'CiviRules Edit Condition parameters'; $this->assign('ruleConditionHeader', 'Edit Condition ' . $conditionLabel . ' of CiviRule ' . CRM_Civirules_BAO_Rule::getRuleLabelWithId($ruleCondition->rule_id)); CRM_Utils_System::setTitle($title); }