Commit 6b280f8b authored by jaapjansma's avatar jaapjansma
Browse files

Added subject field with tokens

parent 8dda21b9
name = CiviCRM Documents views integeration
description = Integrates CiviCRM Documents with views
version = 7.x-1.9
version = 7.x-1.10
core = 7.x
package = CiviCRM
dependencies[] = civicrm (>=4.4)
......
......@@ -28,7 +28,14 @@ class WebformCiviCRMDocuments {
foreach ($this->node->webform['components'] as $cid => $field) {
if ($this->checkComponentForDocument($cid, $field)) {
$this->saveFiles($field['name'], $this->submission->data[$cid], $field);
$subject = _webform_civicrm_documents_get_subject($field);
if ($subject) {
$subject = webform_replace_tokens($subject, $this->node, $this->submission);
}
if (!$subject) {
$subject = $field['name'];
}
$this->saveFiles($subject, $this->submission->data[$cid], $field);
}
}
}
......
name = CiviCRM Webform upload to CiviCRM Document
description = Create documents from CiviCRM Webform uploaded files.
version = 7.x-1.9
version = 7.x-1.10
core = 7.x
package = CiviCRM
dependencies[] = civicrm (>=4.4)
......
......@@ -21,7 +21,7 @@ function webform_civicrm_documents_form_webform_component_edit_form_alter(&$form
if (!isset($form['#node']->webform_civicrm)) {
return;
}
$form['webform_civicrm_documents'] = array(
'#type' => 'fieldset',
'#title' => t('CiviCRM Documents'),
......@@ -30,9 +30,20 @@ function webform_civicrm_documents_form_webform_component_edit_form_alter(&$form
$form['webform_civicrm_documents']['enabled'] = array(
'#type' => 'checkbox',
'#title' => t('Save this file as a document in civicrm'),
'#description' => t("The file is saved as document in civicrm by its name"),
'#description' => t("The file is saved as document in civicrm."),
'#default_value' => _webform_civicrm_documents_get_enabled($component),
);
$form['webform_civicrm_documents']['subject'] = array(
'#type' => 'textfield',
'#title' => t('Subject.'),
'#description' => t("Default to the title of the field.").' '.theme('webform_token_help', array('groups' => array('node', 'submission'))),
'#default_value' => _webform_civicrm_documents_get_subject($component),
'#states' => array(
'invisible' => array(
':input[name="webform_civicrm_documents[enabled]"]' => array('checked' => false),
),
),
);
$form['webform_civicrm_documents']['existing'] = array(
'#type' => 'select',
'#title' => t('What to do when document already exist'),
......@@ -67,6 +78,7 @@ function webform_civicrm_documents_webform_component_presave(&$component) {
return;
}
$component['extra']['webform_civicrm_documents_enabled'] = $component['webform_civicrm_documents']['enabled'] ? true : false;
$component['extra']['webform_civicrm_documents_subject'] = $component['webform_civicrm_documents']['subject'];
$component['extra']['webform_civicrm_documents_existing'] = $component['webform_civicrm_documents']['existing'];
$component['extra']['webform_civicrm_documents_contacts'] = serialize($component['webform_civicrm_documents']['contact']);
}
......@@ -79,6 +91,14 @@ function _webform_civicrm_documents_get_enabled(array $component) {
return $enabled;
}
function _webform_civicrm_documents_get_subject(array $component) {
$subject = '';
if (isset($component['extra']['webform_civicrm_documents_subject'])) {
$subject = $component['extra']['webform_civicrm_documents_subject'];
}
return $subject;
}
function _webform_civicrm_documents_get_contact(array $component) {
$contacts = array();
if (!empty($component['extra']['webform_civicrm_documents_contacts'])) {
......
......@@ -14,8 +14,8 @@
<url desc="Support">http://civicoop.org</url>
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2018-09-05</releaseDate>
<version>1.9</version>
<releaseDate>2019-07-16</releaseDate>
<version>1.10</version>
<develStage>stable</develStage>
<compatibility>
<ver>4.7</ver>
......
Supports Markdown
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