From 751d6b63a29f6f95b2a0bb69288f23bb0203b921 Mon Sep 17 00:00:00 2001 From: Erik Hommel <hommel@ee-atwork.nl> Date: Thu, 12 Mar 2015 15:43:15 +0100 Subject: [PATCH] cleanup Group Action --- CRM/CivirulesActions/Form/GroupContact.php | 44 +++++++++++++++++++++- CRM/CivirulesActions/GroupContact.php | 24 ++++++++---- 2 files changed, 58 insertions(+), 10 deletions(-) diff --git a/CRM/CivirulesActions/Form/GroupContact.php b/CRM/CivirulesActions/Form/GroupContact.php index 756bf5c..9fddcdd 100644 --- a/CRM/CivirulesActions/Form/GroupContact.php +++ b/CRM/CivirulesActions/Form/GroupContact.php @@ -1,4 +1,10 @@ <?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)); diff --git a/CRM/CivirulesActions/GroupContact.php b/CRM/CivirulesActions/GroupContact.php index 992b38f..0e9f1ef 100644 --- a/CRM/CivirulesActions/GroupContact.php +++ b/CRM/CivirulesActions/GroupContact.php @@ -1,18 +1,25 @@ <?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 -- GitLab