Skip to content

Commit e5ec8f7

Browse files
committed
Added CC functinality @ bottom
Added single CC functionality and some little URL fixes and formatting.
1 parent b2b6588 commit e5ec8f7

File tree

7 files changed

+103
-17
lines changed

7 files changed

+103
-17
lines changed

helper.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,14 @@ public static function submitForm($ajax = false) {
9595
if(is_array($value)) {
9696
if(isset($value['email'])) {
9797
$values[$name] = $value['email'];
98+
//multiple cc
9899
if(isset($value['cc']) && $value['cc'] == 1) {
99100
$cc_emails[] = $value['email'];
100101
}
102+
//single cc
103+
if(isset($value['single_cc']) && $value['single_cc'] == 1) {
104+
$cc_emails[] = $value['email'];
105+
}
101106
}
102107
} else {
103108
$values[$name] = $value;
@@ -344,13 +349,25 @@ public static function getJS($moduleid) {
344349
return $GLOBALS['mod_jdscf_js_' . $moduleid];
345350
}
346351

347-
public static function isCCMail($field, $params){
352+
//for single email field (at bottom)
353+
public static function isSingleCCMail($params) {
354+
$singlesendcopy_email = $params->get('single_sendcopy_email', 0);
355+
$singlesendcopyemail_field = $params->get('singleSendCopyEmail_field', '');
356+
if($singlesendcopy_email && !empty($singlesendcopyemail_field)){
357+
return true;
358+
} else {
359+
return false;
360+
}
361+
}
362+
363+
//for multiple email fields
364+
public static function isCCMail($field, $params) {
348365
$sendcopy_email = $params->get('sendcopy_email', 0);
349366
$sendcopyemail_field = $params->get('sendcopyemail_field', '');
350367
$sendcopyemail_fields = explode(",", $sendcopyemail_field);
351368
if($sendcopy_email && !empty($sendcopyemail_fields) && in_array($field->name, $sendcopyemail_fields)){
352369
return true;
353-
}else{
370+
} else {
354371
return false;
355372
}
356373
}

language/en-GB/en-GB.mod_jdsimplecontactform.ini

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,17 @@ MOD_JDSCF_EMAIL_BCC_DESC="BCC email address to recieve submissions. Use comma to
123123
MOD_JDSCF_EMAIL_TEMPLATE_LBL="Email Template"
124124
MOD_JDSCF_EMAIL_TEMPLATE_DESC="Select the email template, The <b>default</b> template lists all fields in the order they exist in <br><b>{field:label}: {field:value}</b></br> format."
125125

126-
MOD_JDSCF_SEND_COPY="Send Copy of Email"
126+
; Single Email Fields
127+
MOD_JDSCF_SINGLE_SEND_COPY="Send Copy of Email (Single)"
128+
MOD_JDSCF_SINGLE_SEND_COPY_LBL_TITLE="Send me a copy"
129+
MOD_JDSCF_SINGLE_SEND_COPY_DESCRIPTION="Displays a checkbox on bottom for users to send a copy of email to themselves."
130+
MOD_JDSCF_SINGLE_SEND_COPY_EMAIL_FIELD="Enter Single Email Field Name"
131+
MOD_JDSCF_SINGLE_SEND_COPY_LABEL="Enter Send Copy Label"
132+
133+
; Multiple Email Fields
134+
MOD_JDSCF_SEND_COPY="Send Copy of Email (Multiple)"
127135
MOD_JDSCF_SEND_COPY_LBL_TITLE="Send me a copy"
128-
MOD_JDSCF_SEND_COPY_DESCRIPTION="Displays a checkbox for users to send a copy of email to themselves."
129-
136+
MOD_JDSCF_SEND_COPY_DESCRIPTION="Displays a checkboxes for users to send a copy of email to themselves under Email Fields."
130137
MOD_JDSCF_SEND_COPY_EMAIL_FIELD="Enter Email Field Name"
131138
MOD_JDSCF_SEND_COPY_LABEL="Enter Send Copy Label"
132139

layouts/emails/default.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@
137137
<table role="presentation" border="0" cellpadding="0" cellspacing="0" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%;" width="100%">
138138
<tr>
139139
<td class="content-block powered-by" style="font-family: sans-serif; vertical-align: top; padding-bottom: 10px; padding-top: 10px; color: #999999; font-size: 12px; text-align: center;" valign="top" align="center">
140-
Powered by <a href="https://www.joomdev.com/products/extensions/jd-simplecontactform" style="color: #999999; font-size: 12px; text-align: center; text-decoration: none;"><?php echo JText::_('MOD_JDSIMPLECONTACTFORM'); ?></a>.
140+
Powered by <a href="https://www.joomdev.com/products/extensions/jd-simple-contact-form" style="color: #999999; font-size: 12px; text-align: center; text-decoration: none;"><?php echo JText::_('MOD_JDSIMPLECONTACTFORM'); ?></a>.
141141
</td>
142142
</tr>
143143
</table>

layouts/fields/singlecc.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
/**
3+
* @package JD Simple Contact Form
4+
* @author JoomDev https://www.joomdev.com
5+
* @copyright Copyright (C) 2009 - 2019 JoomDev.
6+
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 or Later
7+
*/
8+
// no direct access
9+
defined('_JEXEC') or die;
10+
extract($displayData);
11+
$singleCCName = $params->get('singleSendCopyEmail_field', '');
12+
$singleCCTitle = $params->get('singleSendCopyEmailField_title', 'MOD_JDSCF_SINGLE_SEND_COPY_LBL_TITLE');
13+
?>
14+
<label><input type="checkbox" name="jdscf[<?php echo $singleCCName; ?>][single_cc]" value="1" /> <?php echo JText::_($singleCCTitle); ?></label>

layouts/fields/text.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
?>
5353
<input type="text" name="jdscf[<?php echo $field->name; ?>][email]" class="form-control" <?php echo implode(' ', $attrs); ?> />
5454
<?php
55-
if($field->type == 'email' && $isCCMail){ ?>
55+
if($field->type == 'email' && $isCCMail) { ?>
5656
<label><input type="checkbox" name="jdscf[<?php echo $field->name; ?>][cc]" value="1" /> <?php echo JText::_($params->get('sendcopyemailfield_title', 'MOD_JDSCF_SEND_COPY_LBL_TITLE')); ?></label>
5757
<?php }
5858
?>

mod_jdsimplecontactform.xml

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,48 @@
144144
<option value="">JDEFAULT</option>
145145
<option value="custom">JGLOBAL_CUSTOM</option>
146146
</field>
147+
<field
148+
showon="email_template:custom"
149+
name="email_custom"
150+
type="editor"
151+
label="MOD_JDSCF_EMAIL_CUSTOM_TEMPLATE_LBL"
152+
description="MOD_JDSCF_EMAIL_CUSTOM_TEMPLATE_LBL"
153+
filter="safehtml"
154+
default=""
155+
/>
156+
157+
<!-- For single email fields -->
158+
<field
159+
name="single_sendcopy_email"
160+
type="radio"
161+
label="MOD_JDSCF_SINGLE_SEND_COPY"
162+
description="MOD_JDSCF_SINGLE_SEND_COPY_DESCRIPTION"
163+
default="0"
164+
class="btn-group"
165+
>
166+
<option value="1">Yes</option>
167+
<option value="0">No</option>
168+
</field>
169+
170+
<field
171+
showon="single_sendcopy_email:1"
172+
name="singleSendCopyEmail_field"
173+
default=""
174+
type="text"
175+
label="MOD_JDSCF_SINGLE_SEND_COPY_EMAIL_FIELD"
176+
description=""
177+
/>
178+
179+
<field
180+
showon="single_sendcopy_email:1"
181+
name="singleSendCopyEmailField_title"
182+
default=""
183+
type="text"
184+
label="MOD_JDSCF_SINGLE_SEND_COPY_LABEL"
185+
description=""
186+
/>
187+
188+
<!-- For multiple email fields -->
147189
<field
148190
name="sendcopy_email"
149191
type="radio"
@@ -174,15 +216,7 @@
174216
description=""
175217
/>
176218

177-
<field
178-
showon="email_template:custom"
179-
name="email_custom"
180-
type="editor"
181-
label="MOD_JDSCF_EMAIL_CUSTOM_TEMPLATE_LBL"
182-
description="MOD_JDSCF_EMAIL_CUSTOM_TEMPLATE_LBL"
183-
filter="safehtml"
184-
default=""
185-
/>
219+
186220
</fieldset>
187221
<fieldset name="advanced">
188222
<field

tmpl/default.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
$session = JFactory::getSession();
1313
$message = $session->get('jdscf-message-' . $module->id, '');
1414
$captcha = $params->get('captcha', 0);
15+
//checking if single cc is enabled
16+
$single_cc_enable = ModJDSimpleContactFormHelper::isSingleCCMail($params);
1517
?>
1618
<?php
1719
if (!empty($message)) {
@@ -35,7 +37,7 @@
3537
<form method="POST" action="<?php echo JURI::root(); ?>index.php?option=com_ajax&module=jdsimplecontactform&format=json&method=submit" data-parsley-validate data-parsley-errors-wrapper="<ul class='text-danger list-unstyled mt-2 small'></ul>" data-parsley-error-class="border-danger" data-parsley-success-class="border-success" id="simple-contact-form-<?php echo $module->id; ?>" enctype="multipart/form-data">
3638
<div class="jdscf-row">
3739
<?php
38-
ModJDSimpleContactFormHelper::renderForm($params, $module);
40+
ModJDSimpleContactFormHelper::renderForm($params, $module);
3941
?>
4042
</div>
4143

@@ -67,6 +69,18 @@
6769
}
6870
?>
6971

72+
<div class="jdscf-row">
73+
<div class="jdscf-col">
74+
<div class="form-group">
75+
<?php
76+
if($single_cc_enable) {
77+
$singleCC = new JLayoutFile('fields.singlecc', JPATH_SITE . '/modules/mod_jdsimplecontactform/layouts');
78+
echo $singleCC->render(['params' => $params]);
79+
} ?>
80+
</div>
81+
</div>
82+
</div>
83+
7084
<div class="jdscf-row">
7185
<?php
7286
$submit = new JLayoutFile('fields.submit', JPATH_SITE . '/modules/mod_jdsimplecontactform/layouts');

0 commit comments

Comments
 (0)