Skip to content

Commit

Permalink
Merge pull request #1 from DashMedia/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
jonathanhaslett authored Jun 10, 2019
2 parents ca1c7a7 + 90e89e9 commit 8258e0f
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 32 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FormItCampaignMonitor
============
# FormItCampaignMonitor

Hooks and system settings to send transational email through Campaign Monitor as well as a subscriber hook to add form submissions to a mailing list
Hooks and system settings to send transational email through Campaign Monitor as well as a subscriber hook to add form submissions to a mailing list.

This package was built using Repoman (https://github.com/craftsmancoding/repoman/)
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
"extra": {
"package_name": "FormItCampaignMonitor",
"namespace": "formitcampaignmonitor",
"version": "1.1.3",
"version": "1.1.5",
"release": "pl",
"category": "FormItCampaignMonitor"
"category": "FormItCampaignMonitor",
"docs_path": "docs/",
"seeds_path": ["model/seeds/"]
}
}
14 changes: 7 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 18 additions & 10 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
Changelog for FormItCampaignMonitor
# Changelog for FormItCampaignMonitor

FormItCampaignMonitor 1.1.3
---------------------------------
Remove unneeded vars from top of cmSubscribe
## FormItCampaignMonitor 1.1.5-pl

FormItCampaignMonitor 1.1.2
---------------------------------
Fall back to `Email` when no replyToEmail` provided
* BUG FIX: Casting the custom-feilds variable into an array in CM_API in case it's empty or not valid the loop doesnot process it

FormItCampaignMonitor 1.0.0
---------------------------------
Initial Version
## FormItCampaignMonitor 1.1.4-pl

* Add max_filesize checks

## FormItCampaignMonitor 1.1.3-pl

* Remove unneeded vars from top of cmSubscribe

## FormItCampaignMonitor 1.1.2-pl

* Fall back to `Email` when no replyToEmail` provided

## FormItCampaignMonitor 1.0.0-pl

* Initial Version
7 changes: 3 additions & 4 deletions docs/readme.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
FormItCampaignMonitor
-----
# FormItCampaignMonitor

Hooks and system settings to send transational email through Campaign Monitor as well as a subscriber hook to add form submissions to a mailing list.

Author: Jason Carney <[email protected]>
Copyright 2017
This package was built using Repoman (https://github.com/craftsmancoding/repoman/)
16 changes: 15 additions & 1 deletion elements/snippets/cmTransactionalSend.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
$formFields = $modx->getOption('formFields', $formit->config, false);

$api_key = $modx->getOption('formitcampaignmonitor.api_key');
$max_upload = $modx->getOption('formitcampaignmonitor.max_upload');
$default_smart_email_id = $modx->getOption('formitcampaignmonitor.default_smart_email_id');
$smart_email_id = $modx->getOption('cmSmartEmailId', $hook->formit->config, $default_smart_email_id);

Expand Down Expand Up @@ -74,10 +75,17 @@
);
$attachments = array();
foreach ($dataArray as $field => $value) {
$original_name = $field;
$field = ucfirst(str_replace('_',' ',$field));
if(is_array($value)){
if(isset($value['tmp_name'])){
// file
if(filesize($value['tmp_name']) > $max_upload){
$human_size = human_filesize($max_upload);
$modx->setPlaceholder('fi.validation_error_message', "Uploaded file larger than {$human_size} limit");
$hook->addError($original_name, "File size must be under {$human_size}");
return false;
}
switch ($value['error']) {
case UPLOAD_ERR_OK:
$message = 'See attached - ' . $value['name'];
Expand Down Expand Up @@ -187,4 +195,10 @@
return false;
}

return true;
return true;

function human_filesize($bytes, $decimals = 2) {
$size = array('B','kB','MB','GB','TB','PB','EB','ZB','YB');
$factor = floor((strlen($bytes) - 1) / 3);
return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$size[$factor];
}
9 changes: 5 additions & 4 deletions lexicon/en/default.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* Query; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place, Suite 330, Boston, MA 02111-1307 USA
*
* @package yourpackage
* @package FormItCampaignMonitor
*/

/**
Expand All @@ -31,8 +31,9 @@
* @var $modx modX
* @var $scriptProperties array
*
* @package goldentemplate
* @package FormItCampaignMonitor
**/

// $_lang['setting_goldentemplate.color'] = 'Custom Color';
// $_lang['setting_goldentemplate.color_desc'] = 'A valid hex code';

$_lang['setting_formitcampaignmonitor.max_upload'] = 'Maximum file upload size';
$_lang['setting_formitcampaignmonitor.max_upload_desc'] = 'in bytes, eg "5242880"';
2 changes: 1 addition & 1 deletion model/CM_API.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function process_custom_fields(&$current_values = null)
//no custom field values to deal with
return false;
}
foreach($this->custom_fields as $key => &$value){
foreach((array) $this->custom_fields as $key => &$value){
// iterate through fields, making sure they exist, and that the value is a viable option.
foreach ($existing_custom_fields as $fieldId => $field) {
if($value['FieldName'] === $field->FieldName){
Expand Down
7 changes: 7 additions & 0 deletions model/seeds/modSystemSetting.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@
'xtype' => 'textfield',
'namespace' => 'formitcampaignmonitor',
'area' => 'formitcampaignmonitor:default'
),
array(
'key' => 'formitcampaignmonitor.max_upload',
'value' => '5242880',
'xtype' => 'textfield',
'namespace' => 'formitcampaignmonitor',
'area' => 'formitcampaignmonitor:default'
)
);
/*EOF*/

0 comments on commit 8258e0f

Please sign in to comment.