Skip to content
Snippets Groups Projects
Commit 7e97f5f8 authored by jaapjansma's avatar jaapjansma
Browse files
parents 7c007ba4 7e4e2fdb
No related branches found
No related tags found
No related merge requests found
......@@ -66,9 +66,7 @@ abstract class CRM_Civirules_Action {
* @return bool|string
* $access public
*/
public function getExtraDataInputUrl($ruleActionId) {
return false;
}
abstract public function getExtraDataInputUrl($ruleActionId);
/**
* Returns a user friendly text explaining the condition params
......
......@@ -20,32 +20,4 @@ class CRM_Civirules_Upgrader extends CRM_Civirules_Upgrader_Base {
$this->executeSqlFile('sql/createCiviruleRuleCondition.sql');
$this->executeSqlFile('sql/createCiviruleRuleLog.sql');
}
protected function addCondition($class_name, $name, $label) {
$session = CRM_Core_Session::singleton();
$userId = $session->get('userID');
$params['class_name'] = $class_name;
$params['name'] = $name;
$params['label'] = $label;
$params['is_active'] = 1;
$params['created_user_id'] = $userId;
$params['created_date'] = date('Ymd');
CRM_Civirules_BAO_Condition::add($params);
}
protected function addAction($class_name, $name, $label, $api_entity, $api_action) {
$session = CRM_Core_Session::singleton();
$userId = $session->get('userID');
$params['class_name'] = $class_name;
$params['name'] = $name;
$params['label'] = $label;
$params['api_entity'] = $api_entity;
$params['api_action'] = $api_action;
$params['is_active'] = 1;
$params['created_user_id'] = $userId;
$params['created_date'] = date('Ymd');
CRM_Civirules_BAO_Action::add($params);
}
}
\ No newline at end of file
<?php
return array (
0 =>
array (
'name' => 'Civirules:Action.CreateDonor',
'entity' => 'CiviRuleAction',
'params' =>
array (
'version' => 3,
'name' => 'CreateDonor',
'label' => 'Set Contact as Donor',
'class_name' => 'CRM_CivirulesActions_CreateDonor',
'is_active' => 1
),
),
);
\ No newline at end of file
<?php
/**
* Class for CiviRules Create Donor (set contact subtype Donor for Contact) Action
*
* @author Erik Hommel (CiviCooP) <erik.hommel@civicoop.org>
* @license AGPL-3.0
*/
class CRM_CivirulesActions_CreateDonor extends CRM_Civirules_Action {
/**
* Method processAction to execute the action
*
* @param CRM_Civirules_EventData_EventData $eventData
* @access public
*
*/
public function processAction(CRM_Civirules_EventData_EventData $eventData) {
$contactId = $eventData->getContactId();
$processContact = false;
// retrieve contact type of contact
$contactParams = array('id' => $contactId, 'return' => 'contact_type');
$contactType = civicrm_api3('Contact', 'Getvalue', $contactParams);
// retrieve contact type Donor and only execute if the same
$donorType = civicrm_api3('ContactType', 'Getsingle', array('name' => 'Donor'));
try {
switch ($contactType) {
case 'Individual':
if ($donorType['parent_id'] = 1) {
$processContact = true;
}
break;
case 'Household':
if ($donorType['parent_id'] = 2) {
$processContact = true;
}
break;
case 'Organization':
if ($donorType['parent_id'] = 3) {
$processContact = true;
}
break;
}
} catch (CiviCRM_API3_Exception $ex) {
}
if ($processContact) {
$newParams = array('id' => $contactId, 'contact_sub_type' => 'Donor');
civicrm_api3('Contact', 'Create', $newParams);
}
}
/**
* Method to return the url for additional form processing for action
* and return false if none is needed
*
* @param int $ruleActionId
* @return bool
* @access public
*/
public function getExtraDataInputUrl($ruleActionId) {
return FALSE;
}
}
\ No newline at end of file
<?php
return array (
0 =>
array (
'name' => 'Civirules:Condition.ActivityType',
'entity' => 'CiviRuleCondition',
'params' =>
array (
'version' => 3,
'name' => 'contact_has_activity_of_type',
'label' => 'Contact has an activity of type xxx',
'class_name' => 'CRM_CivirulesConditions_ActivityType',
'is_active' => 1
),
),
);
\ No newline at end of file
<?php
/**
* Class for CiviRule Condition FirstContribution
*
* @author Erik Hommel (CiviCooP) <erik.hommel@civicoop.org>
* @license http://www.gnu.org/licenses/agpl-3.0.html
*/
class CRM_CivirulesConditions_ActivityType extends CRM_Civirules_Condition {
public function getExtraDataInputUrl($ruleConditionId) {
}
public function isConditionValid(CRM_Civirules_EventData_EventData $eventData) {
}
}
\ 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