/** * Method to set the Rule Condition data * * @param array $ruleCondition * @access public */ public function setRuleConditionData($ruleCondition) { parent::setRuleConditionData($ruleCondition); $this->conditionParams = array(); if (!empty($this->ruleCondition['condition_params'])) { $this->conditionParams = unserialize($this->ruleCondition['condition_params']); } }
/** * Overridden parent method to perform processing before form is build * * @access public */ public function preProcess() { $this->ruleConditionId = CRM_Utils_Request::retrieve('rule_condition_id', 'Integer'); $this->ruleCondition = new CRM_Civirules_BAO_RuleCondition(); $this->ruleCondition->id = $this->ruleConditionId; $ruleConditionData = array(); CRM_Core_DAO::storeValues($this->ruleCondition, $ruleConditionData); $this->condition = new CRM_Civirules_BAO_Condition(); $this->rule = new CRM_Civirules_BAO_Rule(); $this->trigger = new CRM_Civirules_BAO_Trigger(); if (!$this->ruleCondition->find(true)) { throw new Exception('Civirules could not find ruleCondition'); } $this->condition->id = $this->ruleCondition->condition_id; if (!$this->condition->find(true)) { throw new Exception('Civirules could not find condition'); } $this->rule->id = $this->ruleCondition->rule_id; if (!$this->rule->find(true)) { throw new Exception('Civirules could not find rule'); } $this->trigger->id = $this->rule->trigger_id; if (!$this->trigger->find(true)) { throw new Exception('Civirules could not find trigger'); } $this->conditionClass = CRM_Civirules_BAO_Condition::getConditionObjectById($this->condition->id, false); if ($this->conditionClass) { $this->conditionClass->setRuleConditionData($ruleConditionData); } $this->triggerClass = CRM_Civirules_BAO_Trigger::getTriggerObjectByTriggerId($this->trigger->id, true); $this->triggerClass->setTriggerId($this->trigger->id); $this->triggerClass->setTriggerParams($this->rule->trigger_params); parent::preProcess(); $this->setFormTitle(); //set user context $session = CRM_Core_Session::singleton(); $editUrl = CRM_Utils_System::url('civicrm/civirule/form/rule', 'action=update&id=' . $this->rule->id, TRUE); $session->pushUserContext($editUrl); }
/** * Function to set the actions for each rule condition * * @param int $ruleConditionId * @param CRM_Civirules_Condition $condition * @return array * @access protected */ protected function setRuleConditionActions($ruleConditionId, CRM_Civirules_Condition $condition) { $conditionActions = array(); $editUrl = $condition->getExtraDataInputUrl($ruleConditionId); if (!empty($editUrl)) { $conditionActions[] = '<a class="action-item" title="Edit" href="' . $editUrl . '">' . ts('Edit') . '</a>'; } $removeUrl = CRM_Utils_System::url('civicrm/civirule/form/rule_condition', 'reset=1&action=delete&rid=' . $this->ruleId . '&id=' . $ruleConditionId); $conditionActions[] = '<a class="action-item" title="Remove" href="' . $removeUrl . '">Remove</a>'; return $conditionActions; }