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