Commit 20d16dd4 authored by jaapjansma's avatar jaapjansma
Browse files

Update

parent feb26776
Version 1.8 (not yet released)
-----------
* Added Latitude and Longitude fields to address actions.
* New action: 'Add attachment to bulk mail'.
Version 1.7
-----------
......
<?php
/**
* @author Jaap Jansma <jaap.jansma@civicoop.org>
* @license AGPL-3.0
*/
namespace Civi\ActionProvider\Action\BulkMail;
use Civi\ActionProvider\Action\AbstractAction;
use Civi\ActionProvider\Parameter\FileSpecification;
use Civi\ActionProvider\Parameter\ParameterBagInterface;
use Civi\ActionProvider\Parameter\Specification;
use Civi\ActionProvider\Parameter\SpecificationBag;
use CRM_ActionProvider_ExtensionUtil as E;
class AddAttachment 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
* @throws \Exception
*/
protected function doAction(ParameterBagInterface $parameters, ParameterBagInterface $output) {
$mailing_id = $parameters->getParameter('mailing_id');
$file = $parameters->getParameter('file');
if (empty($file)) {
return;
}
$attachmentParams = [
'entity_table' => 'civicrm_mailing',
'entity_id' => $mailing_id,
'name' => $file['name'],
'content' => base64_decode($file['content']),
'mime_type' => $file['mime_type'],
'check_permissions' => FALSE,
];
$result = civicrm_api3('Attachment', 'create', $attachmentParams);
}
/**
* Returns the specification of the configuration options for the actual
* action.
*
* @return SpecificationBag
*/
public function getConfigurationSpecification() {
return new SpecificationBag();
}
/**
* Returns the specification of the parameters of the actual action.
*
* @return SpecificationBag
*/
public function getParameterSpecification() {
return new SpecificationBag([
new Specification('mailing_id', 'Integer', E::ts('Mailing ID'), true),
new FileSpecification('file', E::ts('File'), false),
]);
}
}
......@@ -135,6 +135,14 @@ class ContactActionUtils {
$addressParams['country_id'] = $parameters->getParameter('country_id');
$hasAddressParams = true;
}
if ($parameters->doesParameterExists('latitude')) {
$addressParams['geo_code_1'] = $parameters->getParameter('latitude');
$addressParams['manual_geo_code'] = '1';
}
if ($parameters->doesParameterExists('longitude')) {
$addressParams['geo_code_2'] = $parameters->getParameter('longitude');
$addressParams['manual_geo_code'] = '1';
}
if ($hasAddressParams) {
$result = civicrm_api3('Address', 'create', $addressParams);
return $result['id'];
......@@ -170,6 +178,8 @@ class ContactActionUtils {
$spec->addSpecification(new Specification('city', 'String', E::ts('City'), false));
$spec->addSpecification(new Specification('state_province_id', 'Integer', E::ts('State/Province ID'), false, null, 'StateProvince'));
$spec->addSpecification(new Specification('country_id', 'Integer', E::ts('Country ID'), false, null, 'Country'));
$spec->addSpecification(new Specification('latitude', 'Float', E::ts('Latitude'), false, null, null));
$spec->addSpecification(new Specification('longitude', 'Float', E::ts('Longitude'), false, null, null));
}
......
......@@ -175,6 +175,10 @@ class Provider {
AbstractAction::SEND_MESSAGES_TO_CONTACTS,
'bulk_mail'
));
$this->addActionWithoutFiltering('AddAttachmentToBulkMail', '\Civi\ActionProvider\Action\BulkMail\AddAttachment', E::ts('Add attachment to Bulk Mail'), array(
AbstractAction::WITHOUT_CONTACT_ACTION_TAG,
AbstractAction::DATA_MANIPULATION_TAG,
));
$this->addActionWithoutFiltering('UpdateParticipantStatus', '\Civi\ActionProvider\Action\Event\UpdateParticipantStatus',E::ts('Update participant status') , array(
AbstractAction::SINGLE_CONTACT_ACTION_TAG,
AbstractAction::DATA_MANIPULATION_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