Commit 0cc63ecc authored by jaapjansma's avatar jaapjansma

added action to override membership status

parent 0b5840ab
Version 1.21 (not yet released)
------------
* Added action to override membership status.
Version 1.20
------------
......
......@@ -30,6 +30,10 @@ class Actions {
AbstractAction::SINGLE_CONTACT_ACTION_TAG,
AbstractAction::DATA_MANIPULATION_TAG,
));
$provider->addAction('OverrideMembershipStatus', '\Civi\ActionProvider\Action\Membership\OverrideStatus',E::ts('Membership: Override Status') , array(
AbstractAction::SINGLE_CONTACT_ACTION_TAG,
AbstractAction::DATA_MANIPULATION_TAG,
));
$provider->addAction('GetMembershipById', '\Civi\ActionProvider\Action\Membership\GetMembershipById',E::ts('Membership: Get by ID') , array(
AbstractAction::WITHOUT_CONTACT_ACTION_TAG,
AbstractAction::DATA_RETRIEVAL_TAG,
......
<?php
/**
* @author Jaap Jansma <jaap.jansma@civicoop.org>
* @license AGPL-3.0
*/
namespace Civi\ActionProvider\Action\Membership;
use Civi\ActionProvider\Action\AbstractAction;
use Civi\ActionProvider\Parameter\ParameterBagInterface;
use Civi\ActionProvider\Parameter\Specification;
use Civi\ActionProvider\Parameter\SpecificationBag;
use CRM_ActionProvider_ExtensionUtil as E;
class OverrideStatus extends AbstractAction {
/**
* Run the action
*
* @param ParameterBagInterface $parameters
* The parameters to this action.
* @param ParameterBagInterface $output
* The parameters this action can send back
*
* @return void
*/
protected function doAction(ParameterBagInterface $parameters, ParameterBagInterface $output) {
$membership_id = $parameters->getParameter('membership_id');
$status_id = $this->configuration->getParameter('status');
$apiParams = array();
$apiParams['id'] = $membership_id;
$apiParams['is_override'] = '1';
$apiParams['status_id'] = $status_id;
if ($parameters->doesParameterExists('status_override_end_date')) {
$apiParams['status_override_end_date'] = $parameters->getParameter('status_override_end_date');
}
civicrm_api3('Membership', 'create', $apiParams);
}
/**
* Returns the specification of the configuration options for the actual
* action.
*
* @return SpecificationBag
*/
public function getConfigurationSpecification() {
return new SpecificationBag([
new Specification('status', 'Integer', E::ts('Status'), true, null, 'MembershipStatus'),
]);
}
/**
* Returns the specification of the parameters of the actual action.
*
* @return SpecificationBag
*/
public function getParameterSpecification() {
return new SpecificationBag([
new Specification('membership_id', 'Integer', E::ts('Membership ID'), true),
new Specification('status_override_end_date', 'Date', E::ts('Status Override End Date'), false)
]);
}
/**
* Returns the specification of the output parameters of this action.
*
* This function could be overriden by child classes.
*
* @return SpecificationBag
*/
public function getOutputSpecification() {
return new SpecificationBag([]);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment