1 2<div class="box twoColumn"> 3 4 <div class="head"> 5 <h1><?php echo __("Mail Configuration")?></h1> 6 </div> 7 8 <div class="inner"> 9 10 <?php include_partial('global/flash_messages'); ?> 11 <?php include_partial('global/form_errors', array('form' => $form)); ?> 12 13 <form action="<?php echo url_for('admin/listMailConfiguration');?>" method="post" id="frmSave" name="frmSave" class="longLabels"> 14 15 <?php echo $form['_csrf_token']; ?> 16 17 <fieldset> 18 19 <ol> 20 <li> 21 <?php echo $form['txtMailAddress']->renderLabel(__("Mail Sent As") . ' <em>*</em>'); ?> 22 <?php echo $form['txtMailAddress']->render(array("maxlength" => 100)); ?> 23 </li> 24 <li> 25 <?php echo $form['cmbMailSendingMethod']->renderLabel(__("Sending Method")); ?> 26 <?php echo $form['cmbMailSendingMethod']->render(); ?> 27 </li> 28 <li id="divsendmailControls" class="toggleDiv"> 29 <label><?php echo __("Path to Sendmail"); ?></label> 30 <label><?php echo $sendmailPath; ?></label> 31 32 </li> 33 </ol> 34 35 <ol id="divsmtpControls" class="toggleDiv"> 36 <li> 37 <?php echo $form['txtSmtpHost']->renderLabel(__("SMTP Host")); ?> 38 <?php echo $form['txtSmtpHost']->render(array("maxlength" => 100)); ?> 39 </li> 40 <li> 41 <?php echo $form['txtSmtpPort']->renderLabel(__("SMTP Port")); ?> 42 <?php echo $form['txtSmtpPort']->render(array("maxlength" => 100)); ?> 43 </li> 44 <li class="line radio"> 45 <?php echo $form['optAuth']->renderLabel(__("Use SMTP Authentication")); ?> 46 <?php echo $form['optAuth']->render(); ?> 47 </li> 48 <li> 49 <?php echo $form['txtSmtpUser']->renderLabel(__("SMTP User")); ?> 50 <?php echo $form['txtSmtpUser']->render(array("maxlength" => 100)); ?> 51 </li> 52 <li> 53 <?php echo $form['txtSmtpPass']->renderLabel(__("SMTP Password")); ?> 54 <?php echo $form['txtSmtpPass']->render(array("maxlength" => 100)); ?> 55 </li> 56 <li class="line radio"> 57 <?php echo $form['optSecurity']->renderLabel(__("User Secure Connection")); ?> 58 <?php echo $form['optSecurity']->render(array("maxlength" => 100)); ?> 59 </li> 60 </ol> 61 62 <ol> 63 <li> 64 <?php echo $form['chkSendTestEmail']->renderLabel(__("Send Test Email")); ?> 65 <?php echo $form['chkSendTestEmail']->render(array("maxlength" => 100)); ?> 66 </li> 67 <li> 68 <?php echo $form['txtTestEmail']->renderLabel(__("Test Email Address")); ?> 69 <?php echo $form['txtTestEmail']->render(array("maxlength" => 100)); ?> 70 </li> 71 <li class="required"> 72 <em>*</em> <?php echo __(CommonMessages::REQUIRED_FIELD); ?> 73 </li> 74 </ol> 75 <p> 76 <input type="button" value="<?php echo __("Edit")?>" id="editBtn" class=""/> 77 <input type="button" value="<?php echo __("Reset")?>" id="resetBtn" tabindex="3" class="reset"/> 78 </p> 79 80 </fieldset> 81 82 </form> 83 84 </div> 85 86</div> 87 88<script type="text/javascript"> 89//<![CDATA[ 90 91 var requiredMsg = '<?php echo __js(ValidationMessages::REQUIRED); ?>'; 92 var validEmailMsg = '<?php echo __js(ValidationMessages::EMAIL_INVALID); ?>'; 93 94 $(document).ready(function() { 95 96 $('#emailConfigurationForm_chkSendTestEmail').prop('checked', false); 97 $('#emailConfigurationForm_txtTestEmail').val(''); 98 99 var mode = 'edit'; 100 101 //Disable all fields 102 $('#frmSave :input').prop('disabled', true); 103 $('#editBtn').prop('disabled', false); 104 105 $('#emailConfigurationForm_txtSmtpPass').on('click focusin', function() { 106 this.value = ''; 107 }); 108 109 $('#emailConfigurationForm_txtSmtpPass').on('focusout', function() { 110 if(this.value === ''){ 111 this.value = '<?php echo EmailConfigurationForm::EIGHT_STARS?>'; 112 } 113 }); 114 115 116 // Displaying the appropriate send mail method controls when page is ready 117 toggleSendMailMethodControls(); 118 119 $("#editBtn").click(function() { 120 121 if( mode == 'edit') 122 { 123 $('#editBtn').attr('value', "<?php echo __js('Save'); ?>"); 124 $('#frmSave :input').removeAttr('disabled'); 125 toggleSMTPAuthenticationFields(); 126 checkSendTestMail(); 127 mode = 'save'; 128 }else 129 { 130 $('#frmSave').submit(); 131 } 132 }); 133 134 //Validate the form 135 var validator = $("#frmSave").validate({ 136 rules: { 137 'emailConfigurationForm[txtMailAddress]': { 138 required: true, 139 email: true, 140 onkeyup: 'if_invalid' 141 } 142 }, 143 messages: { 144 'emailConfigurationForm[txtMailAddress]': { 145 required: requiredMsg, 146 email: validEmailMsg 147 } 148 } 149 }); 150 151 $("label[for=emailConfigurationForm_txtTestEmail] em").remove(); 152 $("#emailConfigurationForm_chkSendTestEmail").change(checkSendTestMail); 153 154 checkAuthenticationActivate(); 155 $("#emailConfigurationForm_optAuth_login, #emailConfigurationForm_optAuth_none").change(function() { 156 checkAuthenticationActivate(); 157 }) 158 159 160 checkSmtpValidation(); 161 $("#emailConfigurationForm_cmbMailSendingMethod").change(function() { 162 checkSmtpValidation(); 163 }); 164 //When click reset buton 165 $("#resetBtn").click(function() { 166 document.forms[0].reset(''); 167 validator.resetForm(); 168 $('#emailConfigurationForm_cmbMailSendingMethod').trigger('change'); 169 }); 170 171 // When changing the mail sending method 172 $("#emailConfigurationForm_cmbMailSendingMethod").change(toggleSendMailMethodControls); 173 174 // When changing the Use SMTP Authentication 175 $("#emailConfigurationForm_optAuth_login").change(toggleSMTPAuthenticationFields); 176 $("#emailConfigurationForm_optAuth_none").change(toggleSMTPAuthenticationFields); 177 }); 178 179 function toggleSendMailMethodControls(){ 180 $(".toggleDiv").hide(); 181 divId = "#div" + $("#emailConfigurationForm_cmbMailSendingMethod").val() + "Controls"; 182 $(divId).show(); 183 } 184 185 function checkSendTestMail() { 186 187 if($("#emailConfigurationForm_chkSendTestEmail").prop("checked")){ 188 $("label[for=emailConfigurationForm_txtTestEmail]").append(' <em>*</em>'); 189 $("#emailConfigurationForm_txtTestEmail") 190 .rules("add", { 191 required: true, 192 email: true, 193 onkeyup: 'if_invalid', 194 messages: { 195 required: '<?php echo __js(ValidationMessages::REQUIRED); ?>', 196 email: '<?php echo __js(ValidationMessages::EMAIL_INVALID); ?>' 197 } 198 }); 199 200 $("#emailConfigurationForm_txtTestEmail").prop('disabled', false); 201 202 } else { 203 $("label[for=emailConfigurationForm_txtTestEmail] em").remove(); 204 $("#emailConfigurationForm_txtTestEmail").rules("remove", "required email onkeyup") 205 206 $("#emailConfigurationForm_txtTestEmail").prop('disabled', true); 207 } 208 } 209 210 function checkSmtpValidation(){ 211 if($("#emailConfigurationForm_cmbMailSendingMethod").val() == 'smtp'){ 212 $("#emailConfigurationForm_txtSmtpHost").rules("add", { 213 required: true, 214 messages: { 215 required: requiredMsg 216 } 217 }); 218 $("#emailConfigurationForm_txtSmtpPort").rules("add", { 219 required: true, 220 number: true, 221 maxlength: 10, 222 messages: { 223 required: requiredMsg, 224 number: '<?php echo __js('Should be a number'); ?>', 225 maxlength: '<?php echo __js(ValidationMessages::TEXT_LENGTH_EXCEEDS, array('%amount%' => 10)); ?>' 226 } 227 }); 228 } else { 229 $("#emailConfigurationForm_txtSmtpHost").rules("remove", "required"); 230 $("#emailConfigurationForm_txtSmtpPort").rules("remove", "required"); 231 } 232 } 233 234 function checkAuthenticationActivate() { 235 if($("#emailConfigurationForm_optAuth_login").prop("checked")){ 236 $("label[for=emailConfigurationForm_txtSmtpUser]").append(' <em>*</em>'); 237 $("label[for=emailConfigurationForm_txtSmtpPass]").append(' <em>*</em>'); 238 $("#emailConfigurationForm_txtSmtpUser").rules("add", { 239 required: true, 240 messages: { 241 required: requiredMsg 242 } 243 }); 244 $("#emailConfigurationForm_txtSmtpPass").rules("add", { 245 required: true, 246 messages: { 247 required: requiredMsg 248 } 249 }); 250 } else { 251 $("#emailConfigurationForm_txtSmtpUser").rules("remove", "required"); 252 $("#emailConfigurationForm_txtSmtpPass").rules("remove", "required"); 253 $("label[for=emailConfigurationForm_txtSmtpUser] em").remove(); 254 $("label[for=emailConfigurationForm_txtSmtpPass] em").remove(); 255 } 256 } 257 258 function toggleSMTPAuthenticationFields() { 259 if ($('#emailConfigurationForm_optAuth_login').prop('checked')) { 260 $('#emailConfigurationForm_txtSmtpUser').prop('disabled', false); 261 $('#emailConfigurationForm_txtSmtpPass').prop('disabled', false); 262 } else { 263 $('#emailConfigurationForm_txtSmtpUser').prop('disabled', true); 264 $('#emailConfigurationForm_txtSmtpPass').prop('disabled', true); 265 } 266 } 267//]]> 268</script>