From d6debb40f54650699d94416241cbf7c4dc08b532 Mon Sep 17 00:00:00 2001 From: alextselegidis Date: Mon, 22 Nov 2021 08:00:39 +0100 Subject: [PATCH] Removed old settings files --- .../views/pages/settings/settings_page.php | 691 ------------------ assets/js/backend_settings.js | 335 --------- assets/js/backend_settings_system.js | 249 ------- assets/js/backend_settings_user.js | 131 ---- 4 files changed, 1406 deletions(-) delete mode 100755 application/views/pages/settings/settings_page.php delete mode 100644 assets/js/backend_settings.js delete mode 100644 assets/js/backend_settings_system.js delete mode 100644 assets/js/backend_settings_user.js diff --git a/application/views/pages/settings/settings_page.php b/application/views/pages/settings/settings_page.php deleted file mode 100755 index dbab14f8..00000000 --- a/application/views/pages/settings/settings_page.php +++ /dev/null @@ -1,691 +0,0 @@ - - - - - - - - - - - - - - -
- - -
- - - - -
-
-
- - - - - - - -
-
-
- - - - - -
- -
- - - - - -
- -
- - - - - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
-
-
- - - - - -
-
- - - - - -
- - -
-
-
-
-
- - - - -
-
-
- - - - - - - -
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- -
-
-
- - -
- - - -
-
-
- - -
- - - -
-
-
- - -
- - - -
-
-
- - -
- - - -
-
-
- - -
-
-
- - - - -
-
-
- - - - - - - -
-
-

- - - - - - - - - - - - - -
- -
- -
- -
- -

-
- - -

- -

-
-
-
-

- - - - - -
- -
- -
- - - - - - - - - - - -
-
-
-
-
-
- - - - - - - - - -
-
-
-
- - - - - - - - - -
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
-
- -
- - - - -
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
-
-
-
-
- - - -
-

Easy!Appointments

- -

- -

- -
- - - - - - -
- -

-

- - -

- - - - - | - - - - | - - - - | - - Facebook - - | - - Twitter - -

- -

- -

- - http://www.gnu.org/copyleft/gpl.html -

-
- -
-
- - diff --git a/assets/js/backend_settings.js b/assets/js/backend_settings.js deleted file mode 100644 index 61d1992c..00000000 --- a/assets/js/backend_settings.js +++ /dev/null @@ -1,335 +0,0 @@ -/* ---------------------------------------------------------------------------- - * Easy!Appointments - Open Source Web Scheduler - * - * @package EasyAppointments - * @author A.Tselegidis - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.0.0 - * ---------------------------------------------------------------------------- */ - -window.BackendSettings = window.BackendSettings || {}; - -/** - * Backend Settings - * - * Contains the functionality of the backend settings page. Can either work for system or user settings, - * but the actions allowed to the user are restricted to his role (only admin has full privileges). - * - * @module BackendSettings - */ -(function (exports) { - 'use strict'; - - // Constants - exports.SETTINGS_SYSTEM = 'SETTINGS_SYSTEM'; - exports.SETTINGS_USER = 'SETTINGS_USER'; - - /** - * Use this WorkingPlan class instance to perform actions on the page's working plan tables. - * - * @type {WorkingPlan} - */ - exports.wp = {}; - - /** - * Tab settings object. - * - * @type {Object} - */ - var settings = {}; - - /** - * Initialize Page - * - * @param {bool} defaultEventHandlers Optional (true), determines whether to bind the default event handlers. - */ - exports.initialize = function (defaultEventHandlers) { - defaultEventHandlers = defaultEventHandlers || true; - - $('#cookie-notice-content, #terms-and-conditions-content, #privacy-policy-content').trumbowyg(); - - // Apply setting values from database. - var workingPlan = {}; - - GlobalVariables.settings.system.forEach(function (setting) { - $('input[data-field="' + setting.name + '"]').val(setting.value); - $('select[data-field="' + setting.name + '"]').val(setting.value); - - if (setting.name === 'company_working_plan') { - workingPlan = $.parseJSON(setting.value); - } - - if (setting.name === 'customer_notifications') { - $('#customer-notifications').prop('checked', Boolean(Number(setting.value))); - } - - if (setting.name === 'require_captcha') { - $('#require-captcha').prop('checked', Boolean(Number(setting.value))); - } - - if (setting.name === 'require_phone_number') { - $('#require-phone-number').prop('checked', Boolean(Number(setting.value))); - } - - if (setting.name === 'display_any_provider') { - $('#display-any-provider').prop('checked', Boolean(Number(setting.value))); - } - - if (setting.name === 'display_cookie_notice') { - $('#display-cookie-notice').prop('checked', Boolean(Number(setting.value))); - } - - if (setting.name === 'cookie_notice_content') { - $('#cookie-notice-content').trumbowyg('html', setting.value); - } - - if (setting.name === 'display_terms_and_conditions') { - $('#display-terms-and-conditions').prop('checked', Boolean(Number(setting.value))); - } - - if (setting.name === 'terms_and_conditions_content') { - $('#terms-and-conditions-content').trumbowyg('html', setting.value); - } - - if (setting.name === 'display_privacy_policy') { - $('#display-privacy-policy').prop('checked', Boolean(Number(setting.value))); - } - - if (setting.name === 'privacy_policy_content') { - $('#privacy-policy-content').trumbowyg('html', setting.value); - } - - if (setting.name === 'show_phone_number' && setting.value === '1') { - $('#show-phone-number').find('div').toggleClass('hidden'); - } - - if (setting.name === 'show_address' && setting.value === '1') { - $('#show-address').find('div').toggleClass('hidden'); - } - - if (setting.name === 'show_city' && setting.value === '1') { - $('#show-city').find('div').toggleClass('hidden'); - } - - if (setting.name === 'show_zip_code' && setting.value === '1') { - $('#show-zip-code').find('div').toggleClass('hidden'); - } - - if (setting.name === 'show_notes' && setting.value === '1') { - $('#show-notes').find('div').toggleClass('hidden'); - } - }); - - exports.wp = new WorkingPlan(); - exports.wp.setup(workingPlan); - exports.wp.timepickers(false); - - // Load user settings into form - $('#user-id').val(GlobalVariables.settings.user.id); - $('#first-name').val(GlobalVariables.settings.user.first_name); - $('#last-name').val(GlobalVariables.settings.user.last_name); - $('#email').val(GlobalVariables.settings.user.email); - $('#mobile-number').val(GlobalVariables.settings.user.mobile_number); - $('#phone-number').val(GlobalVariables.settings.user.phone_number); - $('#address').val(GlobalVariables.settings.user.address); - $('#city').val(GlobalVariables.settings.user.city); - $('#state').val(GlobalVariables.settings.user.state); - $('#zip-code').val(GlobalVariables.settings.user.zip_code); - $('#notes').val(GlobalVariables.settings.user.notes); - $('#timezone').val(GlobalVariables.settings.user.timezone); - $('#username').val(GlobalVariables.settings.user.settings.username); - $('#password, #retype-password').val(''); - $('#calendar-view').val(GlobalVariables.settings.user.settings.calendar_view); - $('#user-notifications').prop('checked', Boolean(Number(GlobalVariables.settings.user.settings.notifications))); - - // Set default settings helper. - settings = new SystemSettings(); - - if (defaultEventHandlers) { - bindEventHandlers(); - var $link = $('#settings-page .nav li').not('.d-none').first().find('a'); - $link.tab('show'); - } - - // Apply Privileges - if (GlobalVariables.user.privileges.system_settings.edit === false) { - $('#general, #business-logic').find('select, input, textarea').prop('readonly', true); - $('#general, #business-logic').find('button').prop('disabled', true); - } - - if (GlobalVariables.user.privileges.user_settings.edit === false) { - $('#user').find('select, input, textarea').prop('readonly', true); - $('#user').find('button').prop('disabled', true); - } - - Backend.placeFooterToBottom(); - }; - - /** - * Bind the backend/settings default event handlers. - * - * This method depends on the backend/settings html, so do not use this method on a different page. - */ - function bindEventHandlers() { - exports.wp.bindEventHandlers(); - - /** - * Event: Tab "Click" - * - * Change the visible tab contents. - */ - $('a[data-toggle="tab"]').on('shown.bs.tab', function () { - var href = $(this).attr('href'); - - if (href === '#general') { - settings = new SystemSettings(); - } else if (href === '#business-logic') { - settings = new SystemSettings(); - } else if (href === '#legal-contents') { - settings = new SystemSettings(); - } else if (href === '#current-user') { - settings = new UserSettings(); - } - - Backend.placeFooterToBottom(); - }); - - /** - * Event: Save Settings Button "Click" - * - * Store the setting changes into the database. - */ - $('.save-settings').on('click', function () { - var data = settings.get(); - settings.save(data); - }); - - /** - * Event: Visible/Hidden button "Click" - * - * Change the state of the Visible/Hidden button - */ - $('.hide-toggle').on('click', function () { - var $input = $(this); - $input.find('div').toggleClass('hidden'); - }); - - /** - * set a Visible/Hidden toggle button to a certain state - * - * @argument $element for which jquery element to set the state for - * @argument isVisible a boolean which is true if the button should display 'visible' and false when the button should display 'hidden' - * - */ - function setShowToggleValue($element, isVisible) { - if (getShowToggleValue($element) !== isVisible) { - $element.find('div').toggleClass('hidden'); - } - } - - /** - * get the Visible/Hidden toggle button - * - * @argument $element for which jquery element to set the state for - * - * @return the state of the button. True for visible, false for hidden. - */ - function getShowToggleValue($element) { - var visiblePartArray = $element.find('.hide-toggle-visible'); - return !visiblePartArray.hasClass('hidden'); - } - - /** - * Event: require phone number switch "Click" - * - * make sure that our phone number is visible when it is required. - */ - $('#show-phone-number').on('click', function () { - if (!getShowToggleValue($(this))) { - //if button is set to hidden - $('#require-phone-number').prop('checked', false); - } - }); - - /** - * Event: require phone number switch "Click" - * - * make sure that our phone number is visible when it is required. - */ - $('#require-phone-number').on('click', function () { - if ($(this).prop('checked')) { - setShowToggleValue($('#show-phone-number'), true); - } - }); - - /** - * Event: Username "Focusout" - * - * When the user leaves the username input field we will need to check if the username - * is not taken by another record in the system. Usernames must be unique. - */ - $('#username').focusout(function () { - var $input = $(this); - - if ($input.prop('readonly') === true || $input.val() === '') { - return; - } - - var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_validate_username'; - - var data = { - csrfToken: GlobalVariables.csrfToken, - username: $input.val(), - user_id: $input.parents().eq(2).find('#user-id').val() - }; - - $.post(url, data).done(function (response) { - if (response.is_valid === 'false') { - $input.closest('.form-group').addClass('has-error'); - Backend.displayNotification(EALang.username_already_exists); - $input.attr('already-exists', 'true'); - } else { - $input.closest('.form-group').removeClass('has-error'); - $input.attr('already-exists', 'false'); - } - }); - }); - - /** - * Event: Apply Global Working Plan - */ - $('#apply-global-working-plan').on('click', function () { - var buttons = [ - { - text: EALang.cancel, - click: function () { - $('#message-box').dialog('close'); - } - }, - { - text: 'OK', - click: function () { - var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_apply_global_working_plan'; - - var data = { - csrfToken: GlobalVariables.csrfToken, - working_plan: JSON.stringify(exports.wp.get()) - }; - - $.post(url, data) - .done(function () { - Backend.displayNotification(EALang.working_plans_got_updated); - }) - .always(function () { - $('#message-box').dialog('close'); - }); - } - } - ]; - - GeneralFunctions.displayMessageBox(EALang.working_plan, EALang.overwrite_existing_working_plans, buttons); - }); - } -})(window.BackendSettings); diff --git a/assets/js/backend_settings_system.js b/assets/js/backend_settings_system.js deleted file mode 100644 index 958a9b01..00000000 --- a/assets/js/backend_settings_system.js +++ /dev/null @@ -1,249 +0,0 @@ -/* ---------------------------------------------------------------------------- - * Easy!Appointments - Open Source Web Scheduler - * - * @package EasyAppointments - * @author A.Tselegidis - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.0.0 - * ---------------------------------------------------------------------------- */ - -(function () { - 'use strict'; - - /** - * "System Settings" Tab Helper Class - * - * @class SystemSettings - */ - var SystemSettings = function () {}; - - /** - * Save the system settings. - * - * This method is run after changes are detected on the tab input fields. - * - * @param {Array} settings Contains the system settings data. - */ - SystemSettings.prototype.save = function (settings) { - if (!this.validate()) { - return; // Validation failed, do not proceed. - } - - var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_settings'; - - var data = { - csrfToken: GlobalVariables.csrfToken, - settings: JSON.stringify(settings), - type: BackendSettings.SETTINGS_SYSTEM - }; - - $.post(url, data).done(function () { - Backend.displayNotification(EALang.settings_saved); - - // Update the logo title on the header. - $('#header-logo span').text($('#company-name').val()); - - // Update book_advance_timeout preview - var totalMinutes = $('#book-advance-timeout').val(); - var hours = Math.floor(totalMinutes / 60); - var minutes = totalMinutes % 60; - $('#book-advance-timeout-helper').text( - EALang.book_advance_timeout_hint.replace( - '{$limit}', - ('0' + hours).slice(-2) + ':' + ('0' + minutes).slice(-2) - ) - ); - - // Update variables also used in other setting tabs - GlobalVariables.timeFormat = $('#time-format').val(); - GlobalVariables.firstWeekday = $('#first-weekday').val(); - - // We need to refresh the working plan. - var workingPlan = BackendSettings.wp.get(); - BackendSettings.wp.setup(workingPlan); - BackendSettings.wp.timepickers(false); - }); - }; - - /** - * Get the state of a visible/hidden toggle button - * - * This method uses the DOM elements of the backend/settings page, so it can't be used in another page. - * - * @argument the element jquery of a button object that is a visible/hidden toggle. - * - * @return '0' when the button shows 'invisible' and '1' when the button shows 'visible'. Will always return '0' on an error. - */ - function getToggleButtonState($element) { - var visiblePartArray = $element.find('.hide-toggle-visible'); - var invisiblePartArray = $element.find('.hide-toggle-hidden'); - if (!(visiblePartArray.length === 0 || invisiblePartArray.length === 0)) { - if (visiblePartArray.hasClass('hidden')) { - //our button is currently invisible - return '0'; //invisible - } else { - //our button is currently visible - return '1'; //visible - } - } else { - return '0'; //invisible - } - } - - /** - * Prepare the system settings array. - * - * This method uses the DOM elements of the backend/settings page, so it can't be used in another page. - * - * @return {Array} Returns the system settings array. - */ - SystemSettings.prototype.get = function () { - var settings = []; - - // General Settings Tab - - $('#general') - .find('input, select') - .not('input:checkbox') - .each(function (index, field) { - settings.push({ - name: $(field).attr('data-field'), - value: $(field).val() - }); - }); - - settings.push({ - name: 'customer_notifications', - value: $('#customer-notifications').prop('checked') ? '1' : '0' - }); - - settings.push({ - name: 'require_captcha', - value: $('#require-captcha').prop('checked') ? '1' : '0' - }); - - settings.push({ - name: 'require_phone_number', - value: $('#require-phone-number').prop('checked') ? '1' : '0' - }); - - settings.push({ - name: 'display_any_provider', - value: $('#display-any-provider').prop('checked') ? '1' : '0' - }); - - //Client Form Tab - - settings.push({ - name: 'show_phone_number', - value: getToggleButtonState($('#show-phone-number')) - }); - - settings.push({ - name: 'show_address', - value: getToggleButtonState($('#show-address')) - }); - - settings.push({ - name: 'show_city', - value: getToggleButtonState($('#show-city')) - }); - - settings.push({ - name: 'show_zip_code', - value: getToggleButtonState($('#show-zip-code')) - }); - - settings.push({ - name: 'show_notes', - value: getToggleButtonState($('#show-notes')) - }); - - // Business Logic Tab - - settings.push({ - name: 'company_working_plan', - value: JSON.stringify(BackendSettings.wp.get()) - }); - - settings.push({ - name: 'book_advance_timeout', - value: $('#book-advance-timeout').val() - }); - - // Legal Contents Tab - - settings.push({ - name: 'display_cookie_notice', - value: $('#display-cookie-notice').prop('checked') ? '1' : '0' - }); - - settings.push({ - name: 'cookie_notice_content', - value: $('#cookie-notice-content').trumbowyg('html') - }); - - settings.push({ - name: 'display_terms_and_conditions', - value: $('#display-terms-and-conditions').prop('checked') ? '1' : '0' - }); - - settings.push({ - name: 'terms_and_conditions_content', - value: $('#terms-and-conditions-content').trumbowyg('html') - }); - - settings.push({ - name: 'display_privacy_policy', - value: $('#display-privacy-policy').prop('checked') ? '1' : '0' - }); - - settings.push({ - name: 'privacy_policy_content', - value: $('#privacy-policy-content').trumbowyg('html') - }); - - return settings; - }; - - /** - * Validate the settings data. - * - * If the validation fails then display a message to the user. - * - * @return {Boolean} Returns the validation result. - */ - SystemSettings.prototype.validate = function () { - $('#general .has-error').removeClass('has-error'); - - try { - // Validate required fields. - var missingRequired = false; - $('#general .required').each(function (index, requiredField) { - if (!$(requiredField).val()) { - $(requiredField).closest('.form-group').addClass('has-error'); - missingRequired = true; - } - }); - - if (missingRequired) { - throw new Error(EALang.fields_are_required); - } - - // Validate company email address. - if (!GeneralFunctions.validateEmail($('#company-email').val())) { - $('#company-email').closest('.form-group').addClass('has-error'); - throw new Error(EALang.invalid_email); - } - - return true; - } catch (error) { - Backend.displayNotification(error.message); - return false; - } - }; - - window.SystemSettings = SystemSettings; -})(); diff --git a/assets/js/backend_settings_user.js b/assets/js/backend_settings_user.js deleted file mode 100644 index 13b5bc87..00000000 --- a/assets/js/backend_settings_user.js +++ /dev/null @@ -1,131 +0,0 @@ -/* ---------------------------------------------------------------------------- - * Easy!Appointments - Open Source Web Scheduler - * - * @package EasyAppointments - * @author A.Tselegidis - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.0.0 - * ---------------------------------------------------------------------------- */ - -(function () { - 'use strict'; - - /** - * "User Settings" Tab Helper Class - * - * @class UserSettings - */ - var UserSettings = function () {}; - - /** - * Get the settings data for the user settings. - * - * @return {Object} Returns the user settings array. - */ - UserSettings.prototype.get = function () { - var user = { - id: $('#user-id').val(), - first_name: $('#first-name').val(), - last_name: $('#last-name').val(), - email: $('#email').val(), - mobile_number: $('#mobile-number').val(), - phone_number: $('#phone-number').val(), - address: $('#address').val(), - city: $('#city').val(), - state: $('#state').val(), - zip_code: $('#zip-code').val(), - notes: $('#notes').val(), - timezone: $('#timezone').val(), - settings: { - username: $('#username').val(), - notifications: $('#user-notifications').prop('checked'), - calendar_view: $('#calendar-view').val() - } - }; - - if ($('#password').val()) { - user.settings.password = $('#password').val(); - } - - return user; - }; - - /** - * Store the user settings into the database. - * - * @param {Array} settings Contains the user settings. - */ - UserSettings.prototype.save = function (settings) { - if (!this.validate(settings)) { - Backend.displayNotification(EALang.user_settings_are_invalid); - return; // Validation failed, do not proceed. - } - - var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_settings'; - - var data = { - csrfToken: GlobalVariables.csrfToken, - type: BackendSettings.SETTINGS_USER, - settings: JSON.stringify(settings) - }; - - $.post(url, data).done(function () { - Backend.displayNotification(EALang.settings_saved); - - // Update footer greetings. - $('#footer-user-display-name').text('Hello, ' + $('#first-name').val() + ' ' + $('#last-name').val() + '!'); - }); - }; - - /** - * Validate the settings data. - * - * If the validation fails then display a message to the user. - * - * @return {Boolean} Returns the validation result. - */ - UserSettings.prototype.validate = function () { - $('#current-user .has-error').removeClass('has-error'); - - try { - // Validate required fields. - var missingRequired = false; - $('#current-user .required').each(function (index, requiredField) { - if (!$(requiredField).val()) { - $(requiredField).closest('.form-group').addClass('has-error'); - missingRequired = true; - } - }); - - if (missingRequired) { - throw new Error(EALang.fields_are_required); - } - - // Validate passwords (if provided). - if ($('#password').val() !== $('#retype-password').val()) { - $('#password, #retype-password').closest('.form-group').addClass('has-error'); - throw new Error(EALang.passwords_mismatch); - } - - // Validate user email. - if (!GeneralFunctions.validateEmail($('#email').val())) { - $('#email').closest('.form-group').addClass('has-error'); - throw new Error(EALang.invalid_email); - } - - if ($('#username').attr('already-exists') === 'true') { - $('#username').closest('.form-group').addClass('has-error'); - throw new Error(EALang.username_already_exists); - } - - return true; - } catch (error) { - Backend.displayNotification(error.message); - return false; - } - }; - - window.UserSettings = UserSettings; -})();