Commit b589bcc2 authored by Kevin Cristiano's avatar Kevin Cristiano 🌎

Merge pull request #1 from progressivetech/dynamic-targets

Dynamic targets
parents 651c1df8 4312a80d
<?php
// This file declares a managed database record of type "ReportTemplate".
// The record will be automatically inserted, updated, or deleted from the
// database as appropriate. For more details, see "hook_civicrm_managed" at:
// http://wiki.civicrm.org/confluence/display/CRMDOC42/Hook+Reference
return array (
0 =>
array (
'name' => 'CRM_Petitionemail_Form_Report_PetitionEmail',
'entity' => 'ReportTemplate',
'params' =>
array (
'version' => 3,
'label' => 'PetitionEmail',
'description' => 'PetitionEmail (cc.tadpole.petitionemail)',
'class_name' => 'CRM_Petitionemail_Form_Report_PetitionEmail',
'report_url' => 'petition-email',
'component' => 'CiviCampaign',
),
),
);
\ No newline at end of file
<?php
class CRM_Petitionemail_Form_Report_PetitionEmail extends CRM_Report_Form {
protected $_summary = NULL;
protected $_customGroupGroupBy = FALSE; function __construct() {
$this->_columns = array(
'civicrm_contact' => array(
'dao' => 'CRM_Contact_DAO_Contact',
'fields' => array(
'id' => array(
'display' => FALSE,
'required' => TRUE,
),
'display_name' => array(
'title' => ts('Contact Name'),
'required' => TRUE,
'default' => TRUE,
'no_repeat' => TRUE,
),
'contacts_matched' => array(
'title' => ts('Contacts Matched'),
),
'emails_sent' => array(
'title' => ts('Emails Sent'),
),
),
),
'civicrm_petition_email' => array(
'dao' => 'CRM_Campaign_DAO_Survey',
'filters' => array(
'petition_id' => array(
'title' => ts("Petition"),
'operatorType' => CRM_Report_Form::OP_SELECT,
'options' => $this->get_petition_options()
),
),
),
'civicrm_group_contact' => array(
'dao' => 'CRM_Contact_DAO_GroupContact',
'filters' => array(
'group_id' => array(
'title' => ts("Group"),
'operatorType' => CRM_Report_Form::OP_SELECT,
'options' => $this->get_group_options(),
),
),
)
);
parent::__construct();
}
function get_group_options() {
$choose_one = array('' => ts("Choose one"));
return $choose_one + CRM_Core_PseudoConstant::group('Mailing');
}
function get_petition_options() {
$sql = "SELECT s.id, s.title FROM civicrm_survey s JOIN civicrm_petition_email e ".
"ON s.id = e.petition_id";
$dao = CRM_Core_DAO::executeQuery($sql);
$ret = array();
while($dao->fetch()) {
$ret[$dao->id] = $dao->title;
}
return $ret;
}
function preProcess() {
$this->assign('reportTitle', ts('Petition Email Report'));
parent::preProcess();
}
function select() {
$select = array();
// don't use our special fields which get populated in alterDisplay
$special = array('contacts_matched', 'emails_sent');
foreach ($this->_columns as $tableName => $table) {
if (array_key_exists('fields', $table)) {
foreach ($table['fields'] as $fieldName => $field) {
if (CRM_Utils_Array::value('required', $field) ||
CRM_Utils_Array::value($fieldName, $this->_params['fields'])
) {
$alias = "{$tableName}_{$fieldName}";
if(in_array($fieldName, $special)) {
$select[] = "1 AS $alias";
}
else {
$select[] = "{$field['dbAlias']} as $alias";
}
$this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array::value('title', $field);
$this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field);
$this->_selectAliases[] = $alias;
}
}
}
}
$this->_selectClauses = $select;
$this->_select = "SELECT " . implode(', ', $select) . " ";
}
function from() {
$this->_from = "FROM civicrm_contact {$this->_aliases['civicrm_contact']} {$this->_aclFrom}";
}
function where() {
$petition_id = intval($this->_params['petition_id_value']);
$group_id = NULL;
if(array_key_exists('group_id_value', $this->_params)) {
$group_id = intval($this->_params['group_id_value']);
}
$petition_activity_type_id =
intval(CRM_Core_OptionGroup::getValue('activity_type', 'Petition', 'name'));
$activityContacts =
CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
$source_activity_record_type_id =
intval(CRM_Utils_Array::key('Activity Source', $activityContacts));
$this->_where = "WHERE ";
$signed = '';
$group = '';
// Include people who have signed the petition OR people who are in the passed in group
// First the signers.
$signed = "{$this->_aliases['civicrm_contact']}.id IN (SELECT contact_id
FROM civicrm_activity_contact ac JOIN civicrm_activity a ON
ac.activity_id = a.id WHERE ac.record_type_id = $source_activity_record_type_id
AND source_record_id = $petition_id AND a.activity_type_id = $petition_activity_type_id)";
// Now the people in the specified group
if($group_id) {
// Check if we are a smart group or regular group
$results = civicrm_api3('Group', 'getsingle', array('id' => $group_id));
if(!empty($results['id'])) {
$group = "{$this->_aliases['civicrm_contact']}.id IN (SELECT contact_id FROM ";
if(!empty($results['saved_search_id'])) {
// Populate the cache
CRM_Contact_BAO_GroupContactCache::check($group_id);
$group .= "civicrm_group_contact_cache cc WHERE cc.group_id = $group_id)";
}
else {
$group .= "civicrm_group_contact gc WHERE gc.group_id = $group_id
AND gc.status = 'Added')";
}
}
}
if(!empty($group)) {
$this->_where .= " ($signed) OR ($group) ";
}
else {
$this->_where .= "$signed";
}
}
function alterDisplay(&$rows) {
$petition_id = $this->_params['petition_id_value'];
foreach ($rows as $rowNum => $row) {
if(array_key_exists('civicrm_contact_contacts_matched', $row)) {
$recipients = petitionemail_get_recipients($row['civicrm_contact_id'], $petition_id);
$contacts_matched = array();
while(list(,$recipient) = each($recipients)) {
if(!empty($recipient['contact_id'])) {
$contacts_matched[] = $this->convert_contact_to_link($recipient['name'], $recipient['contact_id']);
}
}
$rows[$rowNum]['civicrm_contact_contacts_matched'] = implode($contacts_matched, ',');
}
if(array_key_exists('civicrm_contact_emails_sent', $row)) {
$emails_sent = $this->get_emails_sent_for_contact($row['civicrm_contact_id'], $petition_id);
$rows[$rowNum]['civicrm_contact_emails_sent'] = implode($emails_sent, ',');
}
if(array_key_exists('civicrm_contact_display_name', $row)) {
$rows[$rowNum]['civicrm_contact_display_name'] =
$this->convert_contact_to_link($row['civicrm_contact_display_name'], $row['civicrm_contact_id']);
}
}
}
function get_emails_sent_for_contact($contact_id, $petition_id) {
$ret = array();
$activityContacts =
CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
$source_activity_record_type_id =
intval(CRM_Utils_Array::key('Activity Source', $activityContacts));
$target_activity_record_type_id =
intval(CRM_Utils_Array::key('Activity Targets', $activityContacts));
$email_activity_type_id =
intval(CRM_Core_OptionGroup::getValue('activity_type', 'Email', 'name'));
$sql = "SELECT DISTINCT c.id, display_name FROM civicrm_contact c JOIN
civicrm_activity_contact ac ON c.id = ac.contact_id WHERE record_type_id = %0
AND activity_id IN (SELECT a.id FROM civicrm_activity a JOIN
civicrm_activity_contact ac ON a.id = ac.activity_id WHERE
record_type_id = %1 AND source_record_id = %2 AND activity_type_id = %3
AND contact_id = %4)";
$params = array(
0 => array($target_activity_record_type_id, 'Integer'),
1 => array($source_activity_record_type_id, 'Integer'),
2 => array($petition_id, 'Integer'),
3 => array($email_activity_type_id, 'Integer'),
4 => array($contact_id, 'Integer')
);
$dao = CRM_Core_DAO::executeQuery($sql, $params);
while($dao->fetch()) {
$ret[] = $this->convert_contact_to_link($dao->display_name, $dao->id);
}
return $ret;
}
function convert_contact_to_link($name, $contact_id) {
$url = CRM_Utils_System::url('civicrm/contact/view', array('cid' => $contact_id));
return '<a href="' . $url . '">' . $name . '</a>';
}
}
......@@ -9,9 +9,10 @@ class CRM_Petitionemail_Upgrader extends CRM_Petitionemail_Upgrader_Base {
/**
* Create civicrm_petition_email table during install
*
*
*/
public function install() {
$this->executeSqlFile('sql/Petitionemail_install.sql');
// Nothing to do. All *_install.sql files installed automatically.
}
/**
......@@ -19,7 +20,76 @@ class CRM_Petitionemail_Upgrader extends CRM_Petitionemail_Upgrader_Base {
*
*/
public function uninstall() {
$this->executeSqlFile('sql/Petitionemail_uninstall.sql');
// Nothing to do. All *_uninstall.sql files installed automatically.
}
/**
* Add new fields and table allowing for dynamic targets to be selected.
*
*/
function upgrade_1001() {
// First create the new table
if(!$this->executeSqlFile('sql/Petitionemail_matching_field_install.sql')) return FALSE;
// Now add the new recipient field if it doesn't exist.
$sql = "DESC civicrm_petition_email";
$dao = CRM_Core_DAO::executeQuery($sql);
$needs_upgrade = TRUE;
$needs_transfer = FALSE;
while($dao->fetch()) {
if($dao->Field == 'recipients') {
$needs_upgrade = FALSE;
}
if($dao->Field == 'recipient_email') {
$needs_transfer = TRUE;
}
}
if($needs_upgrade) {
$sql = "ALTER TABLE civicrm_petition_email ADD COLUMN `recipients` text ".
"COMMENT 'The name and email address of additional targets that should ".
"receive a copy of all petitions signed, separated by line breaks.'";
$dao = CRM_Core_DAO::executeQuery($sql);
}
// Now transfer the data to the new tables
if($needs_transfer) {
$sql = "SELECT petition_id, recipient_email, recipient_name FROM civicrm_petition_email";
$dao = CRM_Core_DAO::executeQuery($sql);
while($dao->fetch()) {
$target = '"' . $dao->recipient_name . '" <' . $dao->recipient_email . '>';
$sql = "UPDATE civicrm_petition_email SET recipients = %0 WHERE petition_id = %1";
$params = array(
0 => array($target, 'String'),
1 => array($dao->petition_id, 'Integer'),
);
CRM_Core_DAO::executeQuery($sql, $params);
}
}
// Now drop/add fields.
if(!$this->executeSqlFile('sql/Petitionemail_1001_upgrade.sql')) return FALSE;
return TRUE;
}
/**
* Add field to allow user to specify custom subject line.
*/
function upgrade_1002() {
if(!$this->executeSqlFile('sql/Petitionemail_1002_upgrade.sql')) return FALSE;
return TRUE;
}
/**
* Ensure all profiles and custom fields are created.
*/
function upgrade_1003() {
// These are indempotent.
if(FALSE === petitionemail_create_custom_fields()) return FALSE;
if(FALSE === petitionemail_get_profile_id('petitionemail_profile_matching_fields')) return FALSE;
if(FALSE === petitionemail_get_profile_id('petitionemail_profile_default_contact')) return FALSE;
if(FALSE === petitionemail_get_profile_id('petitionemail_profile_default_activity')) return FALSE;
return TRUE;
}
}
# Petition Email #
The Petition Email CiviCRM extension allows you to automatically trigger an email everytime someone signs a petition. The email can go to one or more static targets or you can do a dyna mic lookup of targets by matching the value of a field in the petition signer's contact with a value in a target group's contact.
If combined with an extension that can do auto-lookups of electoral districts (such as the [CiviCRM Cicero](https://drupal.org/project/civicrm_cicero) module) , you can use this extension for e-advocacy campaigns.
......@@ -3,19 +3,20 @@
<downloadUrl>http://git.palantetech.coop/tadpole/civicrm/extensions/cc.tadpole.petitionemail/</downloadUrl>
<file>petitionemail</file>
<name>Petition Email</name>
<description>Email petition signatures to a selected recipient</description>
<description>Email petition signatures to static or dynamic list of selected recipients</description>
<license>AGPL</license>
<maintainer>
<author>Joseph Lacey</author>
<email>joseph@palantetech.coop</email>
</maintainer>
<releaseDate>2013-12-16</releaseDate>
<version>1.0</version>
<version>2.0</version>
<develStage>beta</develStage>
<compatibility>
<ver>4.4</ver>
<ver>4.5</ver>
</compatibility>
<comments>This extension is a port of the Progressive Technology Project's CiviCRM Petition Email Drupal module</comments>
<comments>This extension is a re-write of the extension written by Palante which was a port of the Progressive Technology Project's CiviCRM Petition Email Drupal module</comments>
<civix>
<namespace>CRM/Petitionemail</namespace>
</civix>
......
......@@ -4,6 +4,8 @@
/**
* (Delegated) Implementation of hook_civicrm_config
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_config
*/
function _petitionemail_civix_civicrm_config(&$config = NULL) {
static $configured = FALSE;
......@@ -29,6 +31,7 @@ function _petitionemail_civix_civicrm_config(&$config = NULL) {
* (Delegated) Implementation of hook_civicrm_xmlMenu
*
* @param $files array(string)
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_xmlMenu
*/
function _petitionemail_civix_civicrm_xmlMenu(&$files) {
foreach (_petitionemail_civix_glob(__DIR__ . '/xml/Menu/*.xml') as $file) {
......@@ -38,6 +41,8 @@ function _petitionemail_civix_civicrm_xmlMenu(&$files) {
/**
* Implementation of hook_civicrm_install
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_install
*/
function _petitionemail_civix_civicrm_install() {
_petitionemail_civix_civicrm_config();
......@@ -48,6 +53,8 @@ function _petitionemail_civix_civicrm_install() {
/**
* Implementation of hook_civicrm_uninstall
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_uninstall
*/
function _petitionemail_civix_civicrm_uninstall() {
_petitionemail_civix_civicrm_config();
......@@ -58,6 +65,8 @@ function _petitionemail_civix_civicrm_uninstall() {
/**
* (Delegated) Implementation of hook_civicrm_enable
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_enable
*/
function _petitionemail_civix_civicrm_enable() {
_petitionemail_civix_civicrm_config();
......@@ -70,6 +79,8 @@ function _petitionemail_civix_civicrm_enable() {
/**
* (Delegated) Implementation of hook_civicrm_disable
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_disable
*/
function _petitionemail_civix_civicrm_disable() {
_petitionemail_civix_civicrm_config();
......@@ -88,6 +99,8 @@ function _petitionemail_civix_civicrm_disable() {
*
* @return mixed based on op. for 'check', returns array(boolean) (TRUE if upgrades are pending)
* for 'enqueue', returns void
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_upgrade
*/
function _petitionemail_civix_civicrm_upgrade($op, CRM_Queue_Queue $queue = NULL) {
if ($upgrader = _petitionemail_civix_upgrader()) {
......@@ -95,6 +108,9 @@ function _petitionemail_civix_civicrm_upgrade($op, CRM_Queue_Queue $queue = NULL
}
}
/**
* @return CRM_Petitionemail_Upgrader
*/
function _petitionemail_civix_upgrader() {
if (!file_exists(__DIR__.'/CRM/Petitionemail/Upgrader.php')) {
return NULL;
......@@ -144,6 +160,8 @@ function _petitionemail_civix_find_files($dir, $pattern) {
* (Delegated) Implementation of hook_civicrm_managed
*
* Find any *.mgd.php files, merge their content, and return.
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_managed
*/
function _petitionemail_civix_civicrm_managed(&$entities) {
$mgdFiles = _petitionemail_civix_find_files(__DIR__, '*.mgd.php');
......@@ -158,6 +176,35 @@ function _petitionemail_civix_civicrm_managed(&$entities) {
}
}
/**
* (Delegated) Implementation of hook_civicrm_caseTypes
*
* Find any and return any files matching "xml/case/*.xml"
*
* Note: This hook only runs in CiviCRM 4.4+.
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_caseTypes
*/
function _petitionemail_civix_civicrm_caseTypes(&$caseTypes) {
if (!is_dir(__DIR__ . '/xml/case')) {
return;
}
foreach (_petitionemail_civix_glob(__DIR__ . '/xml/case/*.xml') as $file) {
$name = preg_replace('/\.xml$/', '', basename($file));
if ($name != CRM_Case_XMLProcessor::mungeCaseType($name)) {
$errorMessage = sprintf("Case-type file name is malformed (%s vs %s)", $name, CRM_Case_XMLProcessor::mungeCaseType($name));
CRM_Core_Error::fatal($errorMessage);
// throw new CRM_Core_Exception($errorMessage);
}
$caseTypes[$name] = array(
'module' => 'cc.tadpole.petitionemail',
'name' => $name,
'file' => $file,
);
}
}
/**
* Glob wrapper which is guaranteed to return an array.
*
......@@ -166,7 +213,7 @@ function _petitionemail_civix_civicrm_managed(&$entities) {
* result for an empty match is sometimes array() and sometimes FALSE.
* This wrapper provides consistency.
*
* @see http://php.net/glob
* @link http://php.net/glob
* @param string $pattern
* @return array, possibly empty
*/
......@@ -213,3 +260,19 @@ function _petitionemail_civix_insert_navigation_menu(&$menu, $path, $item, $pare
return $found;
}
}
/**
* (Delegated) Implementation of hook_civicrm_alterSettingsFolders
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_alterSettingsFolders
*/
function _petitionemail_civix_civicrm_alterSettingsFolders(&$metaDataFolders = NULL) {
static $configured = FALSE;
if ($configured) return;
$configured = TRUE;
$settingsDir = __DIR__ . DIRECTORY_SEPARATOR . 'settings';
if(is_dir($settingsDir) && !in_array($settingsDir, $metaDataFolders)) {
$metaDataFolders[] = $settingsDir;
}
}
cj(document).ready( function() {
showHideEmailPetition();
populateUserFieldOptions();
cj("input#email_petition").click( function() { showHideEmailPetition(); });
cj("#profile_id").change( function() { populateUserFieldOptions(); });
});
function populateUserFieldOptions() {
var actProfile = cj("#profile_id").val();
var selected_message = cj('#message_field').val();
var selected_subject = cj('#subject_field').val();
var options = {};
cj('#message_field').empty();
cj('#subject_field').empty();
if(actProfile) {
CRM.api("UFField","get",{ "uf_group_id" : actProfile },{ success:function (data) {
if(data['is_error'] == 0) {
cj('#message_field').append('<option value="">--Choose one--</option>');
cj('#subject_field').append('<option value="">--Choose one--</option>');
cj.each(data["values"], function(key, value) {
cj('#message_field').append('<option value="' + value['field_name'] + '">' + value['label'] + '</option>');
cj('#subject_field').append('<option value="' + value['field_name'] + '">' + value['label'] + '</option>');
});
cj('#message_field').val(selected_message);
cj('#subject_field').val(selected_subject);
}
}});
}
else {
options[''] = "No activity profile selected.";
cj('#message_field').append('<option value="">No activity profile selected.</option>');
cj('#subject_field').append('<option value="">No activity profile selected.</option>');
}
}
function showHideEmailPetition() {
if( cj("input#email_petition:checked").length == 1 ) {
cj("tr.crm-campaign-survey-form-block-subject").show("fast");
cj("tr.crm-campaign-survey-form-block-subject_field").show("fast");
cj("tr.crm-campaign-survey-form-block-default_message").show("fast");
cj("tr.crm-campaign-survey-form-block-message_field").show("fast");
cj("tr.crm-campaign-survey-form-block-recipient_options").show("fast");
} else {
cj("tr.crm-campaign-survey-form-block-subject").hide("fast");
cj("tr.crm-campaign-survey-form-block-subject_field").hide("fast");
cj("tr.crm-campaign-survey-form-block-default_message").hide("fast");
cj("tr.crm-campaign-survey-form-block-message_field").hide("fast");
cj("tr.crm-campaign-survey-form-block-recipient_options").hide("fast");
}
}
This diff is collapsed.
--
-- SQL statements to handle the 1001 upgrade
ALTER TABLE civicrm_petition_email DROP COLUMN `recipient_email`;
ALTER TABLE civicrm_petition_email DROP COLUMN `recipient_name`;
ALTER TABLE civicrm_petition_email CHANGE COLUMN message_field message_field varchar(128);
ALTER TABLE civicrm_petition_email ADD COLUMN `location_type_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'The location type that should be used when selecting the target email address.';
ALTER TABLE civicrm_petition_email ADD CONSTRAINT `FK_civicrm_petition_email_petition_id` FOREIGN KEY (`petition_id`) REFERENCES `civicrm_survey` (`id`) ON DELETE CASCADE;
--
-- SQL statements to handle the 1002 upgrade
ALTER TABLE civicrm_petition_email ADD COLUMN `subject_field` varchar(255) DEFAULT NULL COMMENT "The custom field used to store the petition signer's personal subject." AFTER default_message;
......@@ -2,14 +2,17 @@
-- Table structure for table `civicrm_petition_email`
--
DROP TABLE IF EXISTS `civicrm_petition_email`;
CREATE TABLE `civicrm_petition_email` (
CREATE TABLE IF NOT EXISTS `civicrm_petition_email` (
`petition_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'The SID of the petition.',
`recipient_email` varchar(128) DEFAULT NULL COMMENT 'The email of the petition target.',
`recipient_name` varchar(128) DEFAULT NULL COMMENT 'The display name of the petition target.',
`location_type_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'The location type that should be used when selecting the target email address.',
`default_message` text COMMENT 'The default message for the petition',
`message_field` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'The ID of the custom field used for petition messages.',
`message_field` varchar(128) COMMENT 'The name of the custom field used for petition messages.',
`subject_field` varchar(255) DEFAULT NULL COMMENT "The custom field used to store the petition signer's personal subject.",
`subject` varchar(128) DEFAULT NULL COMMENT 'The subject line for outgoing emails.',
`recipients` text COMMENT 'The name and email address of additional targets that should receive a copy of all petitions signed, separated by line breaks.',
PRIMARY KEY (`petition_id`),
KEY `petition_id` (`petition_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Stores recipient and message information for petitions...';
KEY `petition_id` (`petition_id`),
CONSTRAINT `FK_civicrm_petition_email_petition_id` FOREIGN KEY (`petition_id`) REFERENCES `civicrm_survey` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Stores recipient and message information for petitions.';
--
-- Table structure for table `civicrm_petition_email_matching_field`
--
CREATE TABLE IF NOT EXISTS `civicrm_petition_email_matching_field` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'The unique ID of the email field.',
`petition_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'The SID of the petition.',
`matching_field` text COMMENT 'The name of the field that should match between petition signer and target.',
`matching_group_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'The group that should match against this field.',
PRIMARY KEY (`id`),
KEY `petition_id` (`petition_id`),
CONSTRAINT `FK_civicrm_petition_email_matching_field_petition_id` FOREIGN KEY (`petition_id`) REFERENCES `civicrm_survey` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Stores the fields used to match petition signers and targets.';
DROP TABLE IF EXISTS `civicrm_petition_email`;
DROP TABLE IF EXISTS `civicrm_petition_email_matching_field`;
{*
+--------------------------------------------------------------------+
| CiviCRM version 4.4 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2013 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*}
<div class="crm-block crm-form-block crm-campaign-survey-form-block">
<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
{if $action eq 8}
<table class="form-layout">
<tr>
<td colspan="2">
<div class="status">
<div class="icon inform-icon"></div>
&nbsp;{ts}Are you sure you want to delete this Petition?{/ts}</div>
</td>
</tr>
</table>
{else}
{if $action eq 1}
<div id="help">
{ts}Use this form to Add new Survey. You can create a new Activity type, specific to this Survey or select an existing activity type for this Survey.{/ts}
</div>
{/if}
<table class="form-layout">
<tr class="crm-campaign-survey-form-block-title">
<td class="label">{$form.title.label}</td>
<td>{$form.title.html}
</tr>
<tr class="crm-campaign-survey-form-block-instructions">
<td class="label">{$form.instructions.label}</td>
<td class="view-value">{$form.instructions.html}
</tr>
<tr class="crm-campaign-survey-form-block-campaign_id">
<td class="label">{$form.campaign_id.label}</td>
<td>{$form.campaign_id.html}
</tr>
<tr class="crm-campaign-survey-form-block-activity_type_id">
<td class="label">{$form.activity_type_id.label}</td>
<td>{$form.activity_type_id.html}
</tr>
<tr class="crm-campaign-survey-form-block-profile_id">
<td class="label">{$form.contact_profile_id.label}</td>
<td>{$form.contact_profile_id.html}&nbsp;<span class="profile-links"></span>
<div class="description">{ts}Fields about the contact you want to collect.{/ts}</div>
</td>
</tr>
<tr class="crm-campaign-survey-form-block-profile_id">
<td class="label">{$form.profile_id.label}</td>
<td>{$form.profile_id.html}&nbsp;<span class="profile-links"></span>
<div class="description">{ts}Fields about the petition.{/ts}</div>
<div class="profile-create">
<a href="{crmURL p='civicrm/admin/uf/group/add' q='reset=1&action=add'}"
target="_blank">{ts}Click here for new profile{/ts}
</div>
</td>
</tr>
<tr class="crm-campaign-survey-form-block-thankyou_title">
<td
class="label">{$form.thankyou_title.label}{if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_contribution_page' field='thankyou_title' id=$contributionPageID}{/if}</td>
<td>{$form.thankyou_title.html}<br/>
<div class="description">{ts}This title will be displayed at the top of the thank-you page.{/ts}</div>
</td>
</tr>
<tr class="crm-campaign-survey-form-block-thankyou_text">
<td
class="label">{$form.thankyou_text.label}{if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_contribution_page' field='thankyou_text' id=$contributionPageID}{/if}</td>
<td>{$form.thankyou_text.html}<br/>
<div
class="description">{ts}Enter text (and optional HTML layout tags) for the thank-you message that will appear at the top of the thank-you page.{/ts}</div>
</td>
</tr>
<tr class="crm-campaign-survey-form-block-bypass_confirm">
<td class="label">{$form.bypass_confirm.label}</td>
<td>{$form.bypass_confirm.html}
<div class="description">{ts}Disable the email confirmation for unverified contacts?{/ts}</div>
</td></