forked from mirrors/easyappointments
Integrated CAPTCHA setting within the booking wizard.
This commit is contained in:
parent
c16a06a273
commit
655f068a8d
3 changed files with 25 additions and 16 deletions
|
@ -319,8 +319,15 @@ class Appointments extends CI_Controller {
|
|||
try {
|
||||
$post_data = $_POST['post_data']; // alias
|
||||
|
||||
$this->load->model('appointments_model');
|
||||
$this->load->model('providers_model');
|
||||
$this->load->model('services_model');
|
||||
$this->load->model('customers_model');
|
||||
$this->load->model('settings_model');
|
||||
|
||||
// Validate the CAPTCHA string.
|
||||
if ($this->session->userdata('captcha_phrase') !== $_POST['captcha']) {
|
||||
if ($this->settings_model->get_setting('require_captcha') === '1'
|
||||
&& $this->session->userdata('captcha_phrase') !== $_POST['captcha']) {
|
||||
throw new Exception($this->lang->line('captcha_is_wrong'));
|
||||
}
|
||||
|
||||
|
@ -332,12 +339,6 @@ class Appointments extends CI_Controller {
|
|||
$appointment = $_POST['post_data']['appointment'];
|
||||
$customer = $_POST['post_data']['customer'];
|
||||
|
||||
$this->load->model('appointments_model');
|
||||
$this->load->model('providers_model');
|
||||
$this->load->model('services_model');
|
||||
$this->load->model('customers_model');
|
||||
$this->load->model('settings_model');
|
||||
|
||||
if ($this->customers_model->exists($customer)) {
|
||||
$customer['id'] = $this->customers_model->find_record_id($customer);
|
||||
}
|
||||
|
@ -703,7 +704,7 @@ class Appointments extends CI_Controller {
|
|||
private function calculate_available_hours(array $empty_periods, $selected_date, $service_duration,
|
||||
$manage_mode = FALSE) {
|
||||
$this->load->model('settings_model');
|
||||
|
||||
|
||||
$available_hours = array();
|
||||
|
||||
foreach ($empty_periods as $period) {
|
||||
|
|
|
@ -364,16 +364,18 @@
|
|||
<div id="appointment-details" class="col-md-6"></div>
|
||||
<div id="customer-details" class="col-md-6"></div>
|
||||
</div>
|
||||
<?php if ($this->settings_model->get_setting('require_captcha') === '1'): ?>
|
||||
<div class="frame-content row">
|
||||
<div class="col-md-6 col-sm-12">
|
||||
<h4 class="captcha-title">
|
||||
Captcha
|
||||
CAPTCHA
|
||||
<small class="glyphicon glyphicon-refresh"></small>
|
||||
</h4>
|
||||
<img class="captcha-image" src="<?php echo $this->config->item('base_url'); ?>/index.php/captcha">
|
||||
<input class="captcha-text" type="text" value="" />
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="command-buttons">
|
||||
|
|
|
@ -615,21 +615,27 @@ var FrontendBook = {
|
|||
* the appointment to the database.
|
||||
*/
|
||||
registerAppointment: function() {
|
||||
if ($('.captcha-text').val() === '') {
|
||||
$('.captcha-text').css('border', '1px solid red');
|
||||
return;
|
||||
} else {
|
||||
$('.captcha-text').css('border', '');
|
||||
var $captchaText = $('.captcha-text');
|
||||
|
||||
if ($captchaText.length > 0) {
|
||||
$captchaText.css('border', '');
|
||||
if ($captchaText.val() === '') {
|
||||
$captchaText.css('border', '1px solid red');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var formData = jQuery.parseJSON($('input[name="post_data"]').val());
|
||||
|
||||
var postData = {
|
||||
'csrfToken': GlobalVariables.csrfToken,
|
||||
'post_data': formData,
|
||||
'captcha': $('.captcha-text').val()
|
||||
'post_data': formData
|
||||
};
|
||||
|
||||
if ($captchaText.length > 0) {
|
||||
postData.captcha = $captchaText.val();
|
||||
}
|
||||
|
||||
if (GlobalVariables.manageMode) {
|
||||
postData.exclude_appointment_id = GlobalVariables.appointmentData.id;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue