/** * Function to perform processing before displaying form (overrides parent function) * * @access public */ function preProcess() { $this->ruleId = CRM_Utils_Request::retrieve('id', 'Integer'); $this->rule = new CRM_Civirules_BAO_Rule(); $this->trigger = new CRM_Civirules_BAO_Trigger(); $this->assign('trigger_edit_params', false); $this->triggerClass = false; if (!empty($this->ruleId)) { $this->rule->id = $this->ruleId; 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->triggerClass = CRM_Civirules_BAO_Trigger::getTriggerObjectByTriggerId($this->trigger->id, TRUE); $this->triggerClass->setTriggerId($this->trigger->id); $this->triggerClass->setRuleId($this->rule->id); $this->triggerClass->setTriggerParams($this->rule->trigger_params); $this->assign('trigger_edit_params', $this->triggerClass->getExtraDataInputUrl($this->ruleId)); } $this->assign('triggerClass', $this->triggerClass); $ruleConditionAddUrl = CRM_Utils_System::url('civicrm/civirule/form/rule_condition', 'reset=1&action=add&rid=' . $this->ruleId, TRUE); $ruleActionAddUrl = CRM_Utils_System::url('civicrm/civirule/form/rule_action', 'reset=1&action=add&rid=' . $this->ruleId, TRUE); $this->assign('ruleConditionAddUrl', $ruleConditionAddUrl); $this->assign('ruleActionAddUrl', $ruleActionAddUrl); $this->assign('action', $this->_action); $this->assign('rule', $this->rule); $session = CRM_Core_Session::singleton(); switch ($this->_action) { case CRM_Core_Action::DISABLE: CRM_Civirules_BAO_Rule::disable($this->ruleId); $session->setStatus('CiviRule disabled', 'Disable', 'success'); CRM_Utils_System::redirect($session->readUserContext()); break; case CRM_Core_Action::ENABLE: CRM_Civirules_BAO_Rule::enable($this->ruleId); $session->setStatus('CiviRule enabled', 'Enable', 'success'); CRM_Utils_System::redirect($session->readUserContext()); break; } }
/** * Overridden parent method to perform processing before form is build * * @access public */ public function preProcess() { $this->ruleId = CRM_Utils_Request::retrieve('rule_id', 'Integer'); $this->rule = new CRM_Civirules_BAO_Rule(); $this->trigger = new CRM_Civirules_BAO_Trigger(); $this->rule->id = $this->ruleId; 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->triggerClass = CRM_Civirules_BAO_Trigger::getTriggerObjectByTriggerId($this->trigger->id, true); $this->triggerClass->setTriggerId($this->trigger->id); $this->triggerClass->setRuleId($this->rule->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); }