/** * Function to get values * * @return array $result found rows with data * @access public * @static */ public static function getValues($params) { $result = array(); $ruleCondition = new CRM_Civirules_BAO_RuleCondition(); if (!empty($params)) { $fields = self::fields(); foreach ($params as $key => $value) { if (isset($fields[$key])) { $ruleCondition->{$key} = $value; } } } $ruleCondition->find(); while ($ruleCondition->fetch()) { $row = array(); self::storeValues($ruleCondition, $row); if (!empty($row['condition_id'])) { $result[$row['id']] = $row; } else { //invalid ruleCondition because no there is no linked condition CRM_Civirules_BAO_RuleCondition::deleteWithId($row['id']); } } return $result; }
/** * Function to perform processing before displaying form (overrides parent function) * * @access public */ function preProcess() { $this->ruleId = CRM_Utils_Request::retrieve('rid', 'Integer'); $redirectUrl = CRM_Utils_System::url('civicrm/civirule/form/rule', 'action=update&id=' . $this->ruleId, TRUE); $session = CRM_Core_Session::singleton(); $session->pushUserContext($redirectUrl); $this->assign('countRuleConditions', CRM_Civirules_BAO_RuleCondition::countConditionsForRule($this->ruleId)); if ($this->_action == CRM_Core_Action::DELETE) { $ruleConditionId = CRM_Utils_Request::retrieve('id', 'Integer'); CRM_Civirules_BAO_RuleCondition::deleteWithId($ruleConditionId); CRM_Utils_System::redirect($redirectUrl); } }
function cancelAction() { if (isset($this->_submitValues['rule_condition_id']) && $this->_action == CRM_Core_Action::ADD) { CRM_Civirules_BAO_RuleCondition::deleteWithId($this->_submitValues['rule_condition_id']); } }