Skip to content
Snippets Groups Projects
Commit 1b1c59f8 authored by jaapjansma's avatar jaapjansma
Browse files

added campaign type

parent fdbf336a
No related branches found
No related tags found
No related merge requests found
......@@ -2,10 +2,11 @@ Version 1.2
===========
* Implemented the refactored action provider
* Remoed the action provider for default data actions, all actions are now available at the default data.
* Removed the action provider for default data actions, all actions are now available at the default data.
* Added a Campaign Type
** Importanted notices when you are updating **
* You have also to update the action provider extension
* When you have a _Create/Update Group_ action in your form processor you have to check that form processor
because this action has been renamed in the action provider extension.
\ No newline at end of file
because this action has been renamed in the action provider extension.
<?php
/**
* @author Jaap Jansma (CiviCooP) <jaap.jansma@civicoop.org>
* @license http://www.gnu.org/licenses/agpl-3.0.html
*/
namespace Civi\FormProcessor\Type;
use \Civi\FormProcessor\Config\Specification;
use \Civi\FormProcessor\Config\SpecificationBag;
use \Civi\FormProcessor\Type\AbstractType;
use \Civi\FormProcessor\Type\OptionListInterface;
use \CRM_FormProcessor_ExtensionUtil as E;
class CampaignType extends AbstractType implements OptionListInterface {
/**
* Get the configuration specification
*
* @return SpecificationBag
*/
public function getConfigurationSpecification() {
return new SpecificationBag(array());
}
public function validateValue($value, $allValues=array()) {
$options = $this->getOptions();
if (!is_array($value)) {
if (\CRM_Utils_Type::validate($value, 'Integer', FALSE) === NULL) {
return FALSE;
}
if (!isset($options[$value])) {
return FALSE;
}
} else {
return FALSE;
}
return true;
}
/**
* Returns the type number from CRM_Utils_Type
*/
public function getCrmType() {
return \CRM_Utils_Type::T_INT;
}
public function getOptions($params) {
static $return;
if ($return) {
return $return;
}
$groups = civicrm_api3('Campaign', 'get', array('is_active' => 1, 'options'=>array('limit'=>0)));
$return = array();
foreach($groups['values'] as $group) {
$return[$group['id']] = $group['title'];
}
return $return;
}
}
\ No newline at end of file
......@@ -33,6 +33,7 @@
$this->addType(new CountryType('Country', E::ts('Country')));
$this->addType(new MailingGroupType('MailingGroup', E::ts('Mailing Group')));
$this->addType(new ParticipantStatusType('ParticipantStatusType', E::ts('Participant Status')));
$this->addType(new CampaignType('CampaignType', E::ts('Campaign')));
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment