diff --git a/README.md b/README.md index ce425f3..babb545 100644 --- a/README.md +++ b/README.md @@ -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 \ No newline at end of file +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/) \ No newline at end of file diff --git a/composer.json b/composer.json index 256bea1..d18e9a6 100644 --- a/composer.json +++ b/composer.json @@ -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/"] } } diff --git a/composer.lock b/composer.lock index ada7f2d..d6a9558 100644 --- a/composer.lock +++ b/composer.lock @@ -1,23 +1,23 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f52ea56798e74b72d940d4341c5bc896", + "content-hash": "bc63ffda89fddcb882324f7123578594", "packages": [ { "name": "campaignmonitor/createsend-php", - "version": "5.1.2", + "version": "v5.1.3", "source": { "type": "git", "url": "https://github.com/campaignmonitor/createsend-php.git", - "reference": "dafaff661d651f41b959022ae7dce4f703fb7541" + "reference": "bf0709839c634e22ee8f30a508e49db5b0921c80" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/campaignmonitor/createsend-php/zipball/dafaff661d651f41b959022ae7dce4f703fb7541", - "reference": "dafaff661d651f41b959022ae7dce4f703fb7541", + "url": "https://api.github.com/repos/campaignmonitor/createsend-php/zipball/bf0709839c634e22ee8f30a508e49db5b0921c80", + "reference": "bf0709839c634e22ee8f30a508e49db5b0921c80", "shasum": "" }, "require": { @@ -62,7 +62,7 @@ "campaign", "monitor" ], - "time": "2017-05-15T05:59:55+00:00" + "time": "2018-04-20T23:24:11+00:00" } ], "packages-dev": [], diff --git a/docs/changelog.txt b/docs/changelog.txt index acf9402..54ae95a 100755 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -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 \ No newline at end of file +## 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 \ No newline at end of file diff --git a/docs/readme.txt b/docs/readme.txt index 7ec5834..babb545 100755 --- a/docs/readme.txt +++ b/docs/readme.txt @@ -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 -Copyright 2017 \ No newline at end of file +This package was built using Repoman (https://github.com/craftsmancoding/repoman/) \ No newline at end of file diff --git a/elements/snippets/cmTransactionalSend.php b/elements/snippets/cmTransactionalSend.php index 0eeda3f..7e42bb4 100644 --- a/elements/snippets/cmTransactionalSend.php +++ b/elements/snippets/cmTransactionalSend.php @@ -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); @@ -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']; @@ -187,4 +195,10 @@ return false; } -return true; \ No newline at end of file +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]; +} \ No newline at end of file diff --git a/lexicon/en/default.inc.php b/lexicon/en/default.inc.php index 26482eb..024c362 100755 --- a/lexicon/en/default.inc.php +++ b/lexicon/en/default.inc.php @@ -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 */ /** @@ -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"'; diff --git a/model/CM_API.php b/model/CM_API.php index 7a8ef73..cdacfee 100644 --- a/model/CM_API.php +++ b/model/CM_API.php @@ -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){ diff --git a/model/seeds/modSystemSetting.php b/model/seeds/modSystemSetting.php index 16adb70..a16be1e 100644 --- a/model/seeds/modSystemSetting.php +++ b/model/seeds/modSystemSetting.php @@ -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*/