Commit 1e601a75 authored by jaapjansma's avatar jaapjansma

update added gender, added a set date value action.

parent bcfa5a47
......@@ -3,6 +3,7 @@
namespace Civi\ActionProvider\Action\Contact;
use \Civi\ActionProvider\Action\AbstractAction;
use Civi\ActionProvider\Parameter\OptionGroupSpecification;
use \Civi\ActionProvider\Parameter\ParameterBagInterface;
use \Civi\ActionProvider\Parameter\SpecificationBag;
use \Civi\ActionProvider\Parameter\Specification;
......@@ -38,6 +39,9 @@ class CreateUpdateIndividual extends AbstractAction {
if ($parameters->getParameter('birth_date')) {
$params['birth_date'] = $parameters->getParameter('birth_date');
}
if ($parameters->getParameter('gender_id')) {
$params['gender_id'] = $parameters->getParameter('gender_id');
}
$result = civicrm_api3('Contact', 'create', $params);
$contact_id = $result['id'];
$output->setParameter('contact_id', $contact_id);
......@@ -100,6 +104,7 @@ class CreateUpdateIndividual extends AbstractAction {
new Specification('last_name', 'String', E::ts('Last name'), false),
new Specification('middle_name', 'String', E::ts('Middle name'), false),
new Specification('birth_date', 'Date', E::ts('Birth date'), false),
new OptionGroupSpecification('gender_id', 'gender', E::ts('Gender'), false),
));
ContactActionUtils::createAddressParameterSpecification($spec);
ContactActionUtils::createEmailParameterSpecification($spec);
......
<?php
/**
* @author Jaap Jansma <jaap.jansma@civicoop.org>
* @license AGPL-3.0
*/
namespace Civi\ActionProvider\Action\Generic;
use \Civi\ActionProvider\Action\AbstractAction;
use \Civi\ActionProvider\Parameter\ParameterBagInterface;
use \Civi\ActionProvider\Parameter\SpecificationBag;
use \Civi\ActionProvider\Parameter\Specification;
use \Civi\ActionProvider\Utils\CustomField;
use CRM_ActionProvider_ExtensionUtil as E;
class SetDateValue extends AbstractAction {
/**
* Returns the human readable title of this action
*/
public function getTitle() {
return E::ts('Set date value');
}
/**
* Returns the specification of the configuration options for the actual action.
*
* @return SpecificationBag
*/
public function getConfigurationSpecification() {
$date = new Specification('date', 'String', E::ts('Date'), true);
$date->setDescription('Set the date value follow the formats from <a href="https://secure.php.net/manual/en/datetime.formats.php">PHP.net date time</a>.');
return new SpecificationBag(array(
$date,
));
}
/**
* Returns the specification of the configuration options for the actual action.
*
* @return SpecificationBag
* @throws \Exception
*/
public function getParameterSpecification() {
return new SpecificationBag();
}
/**
* 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(array(
new Specification('date', 'Date', E::ts('Date')),
));
}
/**
* Run the action
*
* @param ParameterBagInterface $parameters
* The parameters to this action.
* @param ParameterBagInterface $output
* The parameters this action can send back
* @return void
* @throws \Exception
*/
protected function doAction(ParameterBagInterface $parameters, ParameterBagInterface $output) {
$date = new \DateTime($this->configuration->getParameter('date'));
$output->setParameter('date', $date->format('Ymd'));
}
/**
* Returns the tags for this action.
*/
public function getTags() {
return array(
AbstractAction::DATA_MANIPULATION_TAG
);
}
}
\ No newline at end of file
......@@ -40,6 +40,7 @@ class Provider {
public function __construct() {
$actions = array(
new \Civi\ActionProvider\Action\Generic\SetValue(),
new \Civi\ActionProvider\Action\Generic\SetDateValue(),
new \Civi\ActionProvider\Action\AddToGroup(),
new \Civi\ActionProvider\Action\Contact\ContactDataById(),
new \Civi\ActionProvider\Action\Contact\CreateUpdateAddress(),
......
......@@ -13,13 +13,17 @@
<url desc="Documentation">https://lab.civicrm.org/jaapjansma/action-provider/wikis/home</url>
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2018-02-08</releaseDate>
<releaseDate>2018-08-08</releaseDate>
<version>1.0</version>
<develStage>alpha</develStage>
<develStage>stable</develStage>
<compatibility>
<ver>4.7</ver>
<ver>5.0</ver>
<ver>5.1</ver>
<ver>5.2</ver>
<ver>5.3</ver>
<ver>5.4</ver>
</compatibility>
<comments>This is a module in a prototype stage</comments>
<classloader>
<psr4 prefix="Civi\" path="Civi" />
</classloader>
......
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