Skip to content
Snippets Groups Projects
Commit 751d6b63 authored by Erik Hommel's avatar Erik Hommel
Browse files

cleanup Group Action

parent b0f0d1eb
Branches
Tags
No related merge requests found
<?php
/**
* Class for CiviRules Group Contact Action Form
*
* @author Jaap Jansma (CiviCooP) <jaap.jansma@civicoop.org>
* @license AGPL-3.0
*/
class CRM_CivirulesActions_Form_GroupContact extends CRM_Core_Form {
......@@ -8,7 +14,13 @@ class CRM_CivirulesActions_Form_GroupContact extends CRM_Core_Form {
protected $action;
function preProcess() {
/**
* Overridden parent method to do pre-form building processing
*
* @throws Exception when action or rule action not found
* @access public
*/
public function preProcess() {
$this->ruleActionId = CRM_Utils_Request::retrieve('rule_action_id', 'Integer');
$this->ruleAction = new CRM_Civirules_BAO_RuleAction();
......@@ -26,11 +38,23 @@ class CRM_CivirulesActions_Form_GroupContact extends CRM_Core_Form {
parent::preProcess();
}
/**
* Method to get groups
*
* @return array
* @access protected
*/
protected function getGroups() {
return array('' => ts('-- please select --')) + CRM_Contact_BAO_GroupContact::getGroupList();
}
function buildQuickForm() {
/**
* Overridden parent method to build the form
*
* @access public
*/
public function buildQuickForm() {
$this->setFormTitle();
$this->add('hidden', 'rule_action_id');
......@@ -42,6 +66,12 @@ class CRM_CivirulesActions_Form_GroupContact extends CRM_Core_Form {
array('type' => 'cancel', 'name' => ts('Cancel'))));
}
/**
* Overridden parent method to set default values
*
* @return array $defaultValues
* @access public
*/
public function setDefaultValues() {
$data = array();
$defaultValues = array();
......@@ -55,6 +85,11 @@ class CRM_CivirulesActions_Form_GroupContact extends CRM_Core_Form {
return $defaultValues;
}
/**
* Overridden parent method to process form data after submitting
*
* @access public
*/
public function postProcess() {
$data['group_id'] = $this->_submitValues['group_id'];
......@@ -70,6 +105,11 @@ class CRM_CivirulesActions_Form_GroupContact extends CRM_Core_Form {
$redirectUrl = CRM_Utils_System::url('civicrm/civirule/form/rule', 'action=update&id='.$this->ruleAction->rule_id, TRUE);
CRM_Utils_System::redirect($redirectUrl); }
/**
* Method to set the form title
*
* @access protected
*/
protected function setFormTitle() {
$title = 'CiviRules Edit Action parameters';
$this->assign('ruleActionHeader', 'Edit action '.$this->action->label.' of CiviRule '.CRM_Civirules_BAO_Rule::getRuleLabelWithId($this->ruleAction->rule_id));
......
<?php
/**
* Class for CiviRules Group Contact Action
*
* @author Jaap Jansma (CiviCooP) <jaap.jansma@civicoop.org>
* @license AGPL-3.0
*/
class CRM_CivirulesActions_GroupContact extends CRM_Civirules_Action {
/**
* Returns an array with parameters used for processing an action
*
* @param array $parameters
* @param CRM_Civirules_EventData_EventData $eventData
* @return array
* @param array $params
* @param object CRM_Civirules_EventData_EventData $eventData
* @return array $params
* @access protected
*/
protected function alterApiParameters($parameters, CRM_Civirules_EventData_EventData $eventData) {
protected function alterApiParameters($params, CRM_Civirules_EventData_EventData $eventData) {
//this function could be overridden in subclasses to alter parameters to meet certain criteraia
$parameters['contact_id'] = $eventData->getContactId();
return $parameters;
$params['contact_id'] = $eventData->getContactId();
return $params;
}
/**
......@@ -22,16 +29,18 @@ class CRM_CivirulesActions_GroupContact extends CRM_Civirules_Action {
*
* @param int $ruleActionId
* @return bool|string
* @access public
*/
public function getExtraDataInputUrl($ruleActionId) {
return CRM_Utils_System::url('civicrm/civirule/form/action/groupcontact', 'rule_action_id='.$ruleActionId);
}
/**
* Retruns a user friendly text explaining the condition params
* Returns a user friendly text explaining the condition params
* e.g. 'Older than 65'
*
* @return string
* @access public
*/
public function userFriendlyConditionParams() {
$params = $this->getActionParameters();
......@@ -41,5 +50,4 @@ class CRM_CivirulesActions_GroupContact extends CRM_Civirules_Action {
}
return '';
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment