Commit c2f7db88 authored by jaapjansma's avatar jaapjansma

added action update event status

parent 84906129
......@@ -10,6 +10,7 @@ Version 1.4 (not yet released)
* Added action to get repetition of an event
* Added action to create a case
* Added action to concat (meger) a date and a time field into one
* Added action to update an event status
Version 1.3
-----------
......
<?php
namespace Civi\ActionProvider\Action\Event;
use \Civi\ActionProvider\Action\AbstractAction;
use Civi\ActionProvider\Action\Contact\ContactActionUtils;
use \Civi\ActionProvider\Parameter\ParameterBagInterface;
use \Civi\ActionProvider\Parameter\SpecificationBag;
use \Civi\ActionProvider\Parameter\Specification;
use \Civi\ActionProvider\Parameter\OptionGroupSpecification;
use \Civi\ActionProvider\Utils\CustomField;
use CRM_ActionProvider_ExtensionUtil as E;
use Dompdf\Exception;
class UpdateEventStatus extends AbstractAction {
/**
* Returns the specification of the configuration options for the actual action.
*
* @return SpecificationBag
*/
public function getConfigurationSpecification() {
return new SpecificationBag(array());
}
/**
* Returns a help text for this action.
*
* The help text is shown to the administrator who is configuring the action.
* Override this function in a child class if your action has a help text.
*
* @return string|false
*/
public function getHelpText() {
return E::ts('Updates the Active and Public state of an event.');
}
/**
* Returns the specification of the configuration options for the actual action.
*
* @return SpecificationBag
*/
public function getParameterSpecification() {
$specs = new SpecificationBag(array(
/**
* The parameters given to the Specification object are:
* @param string $name
* @param string $dataType
* @param string $title
* @param bool $required
* @param mixed $defaultValue
* @param string|null $fkEntity
* @param array $options
* @param bool $multiple
*/
new Specification('event_id', 'Integer', E::ts('Event ID'), true, null, null, null, FALSE),
new Specification('is_active', 'Boolean', E::ts('Is active'), false, 1, null, null, FALSE),
new Specification('is_public', 'Boolean', E::ts('Is public'), false, 0, null, null, FALSE),
));
return $specs;
}
/**
* 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('id', 'Integer', E::ts('Event ID')),
));
}
/**
* Run the action
*
* @param ParameterInterface $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) {
// Get the contact and the event.
$apiParams = array();
if ($parameters->doesParameterExists('is_active')) {
$apiParams['is_active'] = $parameters->getParameter('is_active');
}
if ($parameters->doesParameterExists('is_public')) {
$apiParams['is_public'] = $parameters->getParameter('is_public');
}
// Create or Update the event through an API call.
try {
if (count($apiParams)) {
$apiParams['id'] = $parameters->getParameter('event_id');
$result = civicrm_api3('Event', 'create', $apiParams);
}
} catch (Exception $e) {
throw new \Civi\ActionProvider\Exception\ExecutionException(E::ts('Could not update event status.'));
}
$output->setParameter('id', $parameters->getParameter('event_id'));
}
}
\ No newline at end of file
......@@ -217,6 +217,9 @@ class Provider {
$this->addActionWithoutFiltering('SendEmailToParticipants', '\Civi\ActionProvider\Action\Event\SendEmailToParticipants', E::ts('Send e-mail to participants'), array(
AbstractAction::SEND_MESSAGES_TO_CONTACTS,
));
$this->addActionWithoutFiltering('UpdateEventStatus', '\Civi\ActionProvider\Action\Event\UpdateEventStatus', E::ts('Update Event Status') , array(
AbstractAction::DATA_MANIPULATION_TAG,
));
$this->addActionWithoutFiltering('GetRelationship', '\Civi\ActionProvider\Action\Relationship\GetRelationship',E::ts('Get relationship') , array(
AbstractAction::MULTIPLE_CONTACTS_ACTION_TAG,
AbstractAction::DATA_RETRIEVAL_TAG,
......
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