From 111c0366708428c49b4e3a1d28b5628b6aec6c06 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Thu, 26 Apr 2018 21:59:59 +0200 Subject: code cleanup and extended permissions (mainly database side) --- main/app/sprinkles/ConfigManager/CHANGELOG.md | 27 - main/app/sprinkles/ConfigManager/LICENSE | 21 - main/app/sprinkles/ConfigManager/README.md | 56 --- .../app/sprinkles/ConfigManager/asset-bundles.json | 16 - .../ConfigManager/assets/js/ConfigManager.js | 92 ---- main/app/sprinkles/ConfigManager/composer.json | 26 - .../ConfigManager/locale/en_US/AdminLTE.php | 27 - .../ConfigManager/locale/en_US/ConfigManager.php | 27 - .../ConfigManager/locale/fr_FR/AdminLTE.php | 27 - .../ConfigManager/locale/fr_FR/ConfigManager.php | 27 - .../ConfigManager/routes/ConfigManager.php | 16 - .../ConfigManager/schema/config/AdminLTE.json | 32 -- .../ConfigManager/schema/config/site.json | 40 -- .../sprinkles/ConfigManager/src/ConfigManager.php | 40 -- .../src/Controller/ConfigManagerController.php | 173 ------- .../src/Database/Migrations/v100/SettingsTable.php | 48 -- .../Migrations/v101/SettingsPermissions.php | 70 --- .../ConfigManager/src/Database/Models/Config.php | 70 --- .../src/ServicesProvider/ServicesProvider.php | 31 -- .../ConfigManager/src/Util/ConfigManager.php | 243 --------- .../templates/pages/ConfigManager.html.twig | 64 --- main/app/sprinkles/admin/routes/posts.php | 4 - .../admin/src/Controller/PostController.php | 2 +- .../templates/navigation/sidebar-menu.html.twig | 5 - main/app/sprinkles/core/asset-bundles.json | 4 +- .../sprinkles/core/assets/SiteAssets/css/slick.css | 104 ---- .../core/assets/SiteAssets/css/swiper.css | 104 ++++ .../sprinkles/core/assets/SiteAssets/js/slick.js | 556 --------------------- .../sprinkles/core/assets/SiteAssets/js/swiper.js | 556 +++++++++++++++++++++ 29 files changed, 663 insertions(+), 1845 deletions(-) delete mode 100644 main/app/sprinkles/ConfigManager/CHANGELOG.md delete mode 100644 main/app/sprinkles/ConfigManager/LICENSE delete mode 100644 main/app/sprinkles/ConfigManager/README.md delete mode 100644 main/app/sprinkles/ConfigManager/asset-bundles.json delete mode 100644 main/app/sprinkles/ConfigManager/assets/js/ConfigManager.js delete mode 100644 main/app/sprinkles/ConfigManager/composer.json delete mode 100644 main/app/sprinkles/ConfigManager/locale/en_US/AdminLTE.php delete mode 100644 main/app/sprinkles/ConfigManager/locale/en_US/ConfigManager.php delete mode 100644 main/app/sprinkles/ConfigManager/locale/fr_FR/AdminLTE.php delete mode 100644 main/app/sprinkles/ConfigManager/locale/fr_FR/ConfigManager.php delete mode 100644 main/app/sprinkles/ConfigManager/routes/ConfigManager.php delete mode 100644 main/app/sprinkles/ConfigManager/schema/config/AdminLTE.json delete mode 100644 main/app/sprinkles/ConfigManager/schema/config/site.json delete mode 100644 main/app/sprinkles/ConfigManager/src/ConfigManager.php delete mode 100644 main/app/sprinkles/ConfigManager/src/Controller/ConfigManagerController.php delete mode 100644 main/app/sprinkles/ConfigManager/src/Database/Migrations/v100/SettingsTable.php delete mode 100644 main/app/sprinkles/ConfigManager/src/Database/Migrations/v101/SettingsPermissions.php delete mode 100644 main/app/sprinkles/ConfigManager/src/Database/Models/Config.php delete mode 100644 main/app/sprinkles/ConfigManager/src/ServicesProvider/ServicesProvider.php delete mode 100644 main/app/sprinkles/ConfigManager/src/Util/ConfigManager.php delete mode 100644 main/app/sprinkles/ConfigManager/templates/pages/ConfigManager.html.twig delete mode 100644 main/app/sprinkles/core/assets/SiteAssets/css/slick.css create mode 100644 main/app/sprinkles/core/assets/SiteAssets/css/swiper.css delete mode 100644 main/app/sprinkles/core/assets/SiteAssets/js/slick.js create mode 100644 main/app/sprinkles/core/assets/SiteAssets/js/swiper.js (limited to 'main/app/sprinkles') diff --git a/main/app/sprinkles/ConfigManager/CHANGELOG.md b/main/app/sprinkles/ConfigManager/CHANGELOG.md deleted file mode 100644 index 4248a56..0000000 --- a/main/app/sprinkles/ConfigManager/CHANGELOG.md +++ /dev/null @@ -1,27 +0,0 @@ -# Change Log - -## 2.0.4 -- Fix issue with FormGenerator (for real this time) -- Bump FormGenerator version - -## 2.0.3 -- Fix issue with FormGenerator - -## 2.0.2 -- Fix assets bundle issue - -## 2.0.1 -- Updated dependencies - -## 2.0.0 -Updated for UserFrosting v4.1.x - -## 1.0.2 -- Update composer.json - -## 1.0.1 -- Added controlled access -- Added more settings to the default UI - -## 1.0.0 -- Initial release diff --git a/main/app/sprinkles/ConfigManager/LICENSE b/main/app/sprinkles/ConfigManager/LICENSE deleted file mode 100644 index 09386f7..0000000 --- a/main/app/sprinkles/ConfigManager/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2016 Louis Charette - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/main/app/sprinkles/ConfigManager/README.md b/main/app/sprinkles/ConfigManager/README.md deleted file mode 100644 index d90b2fe..0000000 --- a/main/app/sprinkles/ConfigManager/README.md +++ /dev/null @@ -1,56 +0,0 @@ -# Configuration Manager Sprinkle for [UserFrosting 4](https://www.userfrosting.com) - -Configuration Manager sprinkle for [UserFrosting 4](https://www.userfrosting.com). Lets you edit UserFrosting configs from the interface. - -> This version only works with UserFrosting 4.1.x ! - -# Help and Contributing - -If you need help using this sprinkle or found any bug, feels free to open an issue or submit a pull request. You can also find me on the [UserFrosting Chat](https://chat.userfrosting.com/) most of the time for direct support. - -Buy Me a Coffee at ko-fi.com - -# Installation - -Edit UserFrosting `app/sprinkles.json` file and add the following to the `require` list : `"lcharette/uf_configmanager": "^2.0.0"`. Also add `FormGenerator` and `ConfigManager` to the `base` list. For example: - -``` -{ - "require": { - "lcharette/uf_configmanager": "^2.0.0" - }, - "base": [ - "core", - "account", - "admin", - "FormGenerator", - "ConfigManager" - ] -} -``` - -Run `composer update` then `php bakery bake` to install the sprinkle. - -## Permissions -The migration will automatically add the `update_site_config` permission to the `Site Administrator` role. To give access to the config UI to another user, simply add the `update_site_config` permission slug to that user role. - -## Add link to the menu -The configuration UI is bound to the the `/settings` route. Simply add a link to this route where you want it. The checkAccess make it so it will appear only for users having the appropriate permission. For example, you can add the following to the sidebar menu : - -``` -{% if checkAccess('update_site_config') %} -
  • - {{ translate("SITE.CONFIG.MANAGER") }} -
  • -{% endif %} -``` - -## Adding custom config - -! TODO - -> *NOTE* Only `.json` are accepted. `Yaml` schemas are cannot be used for now. - -# Licence - -By [Louis Charette](https://github.com/lcharette). Copyright (c) 2017, free to use in personal and commercial software as per the MIT license. \ No newline at end of file diff --git a/main/app/sprinkles/ConfigManager/asset-bundles.json b/main/app/sprinkles/ConfigManager/asset-bundles.json deleted file mode 100644 index 7550df9..0000000 --- a/main/app/sprinkles/ConfigManager/asset-bundles.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "bundle": { - "js/ConfigManager" : { - "scripts": [ - "js/ConfigManager.js" - ], - "options": { - "result": { - "type": { - "scripts": "plain" - } - } - } - } - } -} \ No newline at end of file diff --git a/main/app/sprinkles/ConfigManager/assets/js/ConfigManager.js b/main/app/sprinkles/ConfigManager/assets/js/ConfigManager.js deleted file mode 100644 index 2a298f5..0000000 --- a/main/app/sprinkles/ConfigManager/assets/js/ConfigManager.js +++ /dev/null @@ -1,92 +0,0 @@ -/*! - * UF Config Manager - Config Manager Widget - * - * @link https://github.com/lcharette/UF_ConfigManager - * @copyright Copyright (c) 2016 Louis Charette - * @license https://github.com/lcharette/UF_ConfigManager/blob/master/LICENSE (MIT License) - */ - -(function( $ ){ - - 'use strict'; - - var options = {}; - - var methods = { - init : function(optionsArg) { - - // Setup options - options = $.extend( options, $.fn.ConfigManager.defaultOptions, optionsArg ); - - // To use this inside sub-functions - var elements = this; - - // Get the currently selected panel from the url anchor and switch to it - var hash = window.location.hash.substr(1); - if (hash != undefined && hash !== "") { - $(elements).hide(); - $("#"+hash).show(); - - // Change the menu - $(options.menu).find("li").removeClass('active'); - $(options.menu).find('a[href="#'+hash+'"]').parent().addClass("active"); - } - - // Set the menu - $(options.menu).find("li > a").click(function () { - - // Change the menu first - $(options.menu).find("li").removeClass('active'); - $(this).parent().addClass("active"); - - // Change the displayed forms next - $(elements).hide(); - $("#"+$(this).data('target')).show(); - }); - - // For each element the plugin is called on - this.each(function() { - - // To use this inside sub-functions - var formPanel = this; - - // ufForm instance. Don't need FormGeneator now - $(formPanel).find("form").ufForm({ - validators: options.validators[ $(formPanel).attr('id') ], - msgTarget: $(formPanel).find("form .form-alerts") - }).on("submitSuccess.ufForm", function() { - // Forward to settings page on success - window.location.reload(true); - }).on("submitError.ufForm", function() { - $(formPanel).find("form .form-alerts").show(); - }); - - }); - return; - } - }; - - /* - * Main plugin function - */ - $.fn.ConfigManager = function(methodOrOptions) { - if ( methods[methodOrOptions] ) { - return methods[ methodOrOptions ].apply( this, Array.prototype.slice.call( arguments, 1 )); - } else if ( typeof methodOrOptions === 'object' || ! methodOrOptions ) { - // Default to "init" - return methods.init.apply( this, arguments ); - } else { - $.error( 'Method ' + methodOrOptions + ' does not exist on jQuery.ConfigManager' ); - } - }; - - /* - * Default plugin options - */ - $.fn.ConfigManager.defaultOptions = { - menu : $(".configMenu"), - validators: {} - }; - - -})( jQuery ); \ No newline at end of file diff --git a/main/app/sprinkles/ConfigManager/composer.json b/main/app/sprinkles/ConfigManager/composer.json deleted file mode 100644 index d524836..0000000 --- a/main/app/sprinkles/ConfigManager/composer.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "lcharette/uf_configmanager", - "type": "userfrosting-sprinkle", - "description": "This Sprinkle provides a UI for core and custom site settings", - "keywords": ["UserFrosting", "Config", "Settings", "Admin Panel"], - "homepage": "https://github.com/lcharette/UF_ConfigManager", - "license" : "MIT", - "authors" : [ - { - "name": "Louis Charette", - "homepage": "https://github.com/lcharette" - } - ], - "require": { - "php": ">=5.6", - "lcharette/uf_formgenerator": "^2.2.10" - }, - "autoload": { - "psr-4": { - "UserFrosting\\Sprinkle\\ConfigManager\\": "src/" - } - }, - "extra": { - "installer-name": "ConfigManager" - } -} diff --git a/main/app/sprinkles/ConfigManager/locale/en_US/AdminLTE.php b/main/app/sprinkles/ConfigManager/locale/en_US/AdminLTE.php deleted file mode 100644 index bd1d032..0000000 --- a/main/app/sprinkles/ConfigManager/locale/en_US/AdminLTE.php +++ /dev/null @@ -1,27 +0,0 @@ - [ - "SETTINGS" => [ - "@TRANSLATION" => "AdminLTE Settings", - - "DESC" => "Settings for the AdminLTE Theme", - - "SKIN" => "Skin color" - ], - - "SKIN" => [ - "BLUE" => "Blue", - "BLACK" => "Black", - "PURPLE" => "Purple", - "GREEN" => "Green", - "RED" => "Red", - "YELLOW" => "Yellow", - "BLUE_LIGHT" => "Blue Light", - "BLACK_LIGHT" => "Black Light", - "PURPLE_LIGHT" => "Purple Light", - "GREEN_LIGHT" => "Green Light", - "RED_LIGHT" => "Red Light", - "YELLOW_LIGHT" => "Yellow Light" - ] - ] -]; \ No newline at end of file diff --git a/main/app/sprinkles/ConfigManager/locale/en_US/ConfigManager.php b/main/app/sprinkles/ConfigManager/locale/en_US/ConfigManager.php deleted file mode 100644 index b82f099..0000000 --- a/main/app/sprinkles/ConfigManager/locale/en_US/ConfigManager.php +++ /dev/null @@ -1,27 +0,0 @@ - [ - "CONFIG" => [ - "@TRANSLATION" => "UserFrosting Settings", - - "DESC" => "Core settings of UserFrosting. See the config file for more configuration options", - - "MANAGER" => "Configuration manager", - - "PAGEDESC" => "This pages allows to edit the global site configuration variables stored in the database", - - "SAVED" => "Changes saved successfully !" - ], - "TITLE" => [ - "@TRANSLATION" => "Site title", - "REQUIRED" => "The site title is required" - ], - "REGISTRATION" => [ - "ENABLED" => "Enabled site registration", - "REQUIRE_EMAIL_VERIFICATION" => "Require email verification when registering" - ] - ], - "SETTINGS" => [ - "DISPLAY_ERROR_DETAILS" => "Display error details" - ] -]; \ No newline at end of file diff --git a/main/app/sprinkles/ConfigManager/locale/fr_FR/AdminLTE.php b/main/app/sprinkles/ConfigManager/locale/fr_FR/AdminLTE.php deleted file mode 100644 index 39b4614..0000000 --- a/main/app/sprinkles/ConfigManager/locale/fr_FR/AdminLTE.php +++ /dev/null @@ -1,27 +0,0 @@ - [ - "SETTINGS" => [ - "@TRANSLATION" => "Paramètres d'AdminLTE", - - "DESC" => "Paramètres du thème AdminLTE", - - "SKIN" => "Couleur du thème" - ], - - "SKIN" => [ - "BLUE" => "Bleu", - "BLACK" => "Noir", - "PURPLE" => "Violet", - "GREEN" => "Vert", - "RED" => "Rouge", - "YELLOW" => "Jaune", - "BLUE_LIGHT" => "Bleu (Light)", - "BLACK_LIGHT" => "Noir (Light)", - "PURPLE_LIGHT" => "Violet (Light)", - "GREEN_LIGHT" => "Vert (Light)", - "RED_LIGHT" => "Rouge (Light)", - "YELLOW_LIGHT" => "Jaune (Light)" - ] - ] -]; \ No newline at end of file diff --git a/main/app/sprinkles/ConfigManager/locale/fr_FR/ConfigManager.php b/main/app/sprinkles/ConfigManager/locale/fr_FR/ConfigManager.php deleted file mode 100644 index 3f9acff..0000000 --- a/main/app/sprinkles/ConfigManager/locale/fr_FR/ConfigManager.php +++ /dev/null @@ -1,27 +0,0 @@ - [ - "CONFIG" => [ - "@TRANSLATION" => "Paramètres de UserFrosting", - - "DESC" => "Paramètres principaux de UserFrosting. Voir le fichier config pour plus d'options", - - "MANAGER" => "Gestionnaire des paramètres", - - "PAGEDESC" => "Cette page permet de modifier les paramètres globaux du site enregistrés dans la base de données", - - "SAVED" => "Changements sauvegardés avec succès !" - ], - "TITLE" => [ - "@TRANSLATION" => "Titre du site", - "REQUIRED" => "Le titre du site est requis" - ], - "REGISTRATION" => [ - "ENABLED" => "Activer l'inscription", - "REQUIRE_EMAIL_VERIFICATION" => "Exiger une vérification par e-mail lors de l'inscription" - ] - ], - "SETTINGS" => [ - "DISPLAY_ERROR_DETAILS" => "Afficher le détails des erreurs" - ] -]; \ No newline at end of file diff --git a/main/app/sprinkles/ConfigManager/routes/ConfigManager.php b/main/app/sprinkles/ConfigManager/routes/ConfigManager.php deleted file mode 100644 index f17f589..0000000 --- a/main/app/sprinkles/ConfigManager/routes/ConfigManager.php +++ /dev/null @@ -1,16 +0,0 @@ -group('/settings', function () { - $this->get('', 'UserFrosting\Sprinkle\ConfigManager\Controller\ConfigManagerController:displayMain') - ->setName('ConfigManager'); - - $this->post('/{schema}', 'UserFrosting\Sprinkle\ConfigManager\Controller\ConfigManagerController:update') - ->setName('ConfigManager.save'); -}); \ No newline at end of file diff --git a/main/app/sprinkles/ConfigManager/schema/config/AdminLTE.json b/main/app/sprinkles/ConfigManager/schema/config/AdminLTE.json deleted file mode 100644 index 04e92da..0000000 --- a/main/app/sprinkles/ConfigManager/schema/config/AdminLTE.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "name" : "ADMINLTE.SETTINGS", - "desc" : "ADMINLTE.SETTINGS.DESC", - - "config": { - "site.AdminLTE.skin" : { - "validators" : { - "required" : {} - }, - "cached" : true, - "form" : { - "type" : "select", - "label" : "ADMINLTE.SETTINGS.SKIN", - "icon" : "", - "options" : { - "blue" : "ADMINLTE.SKIN.BLUE", - "black" : "ADMINLTE.SKIN.BLACK", - "purple" : "ADMINLTE.SKIN.PURPLE", - "green" : "ADMINLTE.SKIN.GREEN", - "red" : "ADMINLTE.SKIN.RED", - "yellow" : "ADMINLTE.SKIN.YELLOW", - "blue-light" : "ADMINLTE.SKIN.BLUE_LIGHT", - "black-light" : "ADMINLTE.SKIN.BLACK_LIGHT", - "purple-light" : "ADMINLTE.SKIN.PURPLE_LIGHT", - "green-light" : "ADMINLTE.SKIN.GREEN_LIGHT", - "red-light" : "ADMINLTE.SKIN.RED_LIGHT", - "yellow-light" : "ADMINLTE.SKIN.YELLOW_LIGHT" - } - } - } - } -} \ No newline at end of file diff --git a/main/app/sprinkles/ConfigManager/schema/config/site.json b/main/app/sprinkles/ConfigManager/schema/config/site.json deleted file mode 100644 index 2c9f4f0..0000000 --- a/main/app/sprinkles/ConfigManager/schema/config/site.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "name" : "SITE.CONFIG", - "desc" : "SITE.CONFIG.DESC", - - "config": { - "site.title" : { - "validators" : { - "required" : { - "message" : "SITE.TITLE.REQUIRED" - } - }, - "form" : { - "type" : "text", - "label" : "SITE.TITLE", - "icon" : "fa-comment" - } - }, - "site.registration.enabled" : { - "validators" : {}, - "form" : { - "type" : "checkbox", - "label" : "SITE.REGISTRATION.ENABLED" - } - }, - "site.registration.require_email_verification" : { - "validators" : {}, - "form" : { - "type" : "checkbox", - "label" : "SITE.REGISTRATION.REQUIRE_EMAIL_VERIFICATION" - } - }, - "settings.displayErrorDetails" : { - "validators" : {}, - "form" : { - "type" : "checkbox", - "label" : "SETTINGS.DISPLAY_ERROR_DETAILS" - } - } - } -} \ No newline at end of file diff --git a/main/app/sprinkles/ConfigManager/src/ConfigManager.php b/main/app/sprinkles/ConfigManager/src/ConfigManager.php deleted file mode 100644 index c29cee9..0000000 --- a/main/app/sprinkles/ConfigManager/src/ConfigManager.php +++ /dev/null @@ -1,40 +0,0 @@ - ['onAddGlobalMiddleware', 0] - ]; - } - - /** - * Add middleware. - */ - public function onAddGlobalMiddleware(Event $event) - { - $app = $event->getApp(); - $app->add($this->ci->configManager); - } -} diff --git a/main/app/sprinkles/ConfigManager/src/Controller/ConfigManagerController.php b/main/app/sprinkles/ConfigManager/src/Controller/ConfigManagerController.php deleted file mode 100644 index 0b5aac0..0000000 --- a/main/app/sprinkles/ConfigManager/src/Controller/ConfigManagerController.php +++ /dev/null @@ -1,173 +0,0 @@ -ci = $ci; - $this->manager = new ConfigManager($ci); - } - - /** - * mainList function. - * Used to display a list of all schema with their form - * - * @access public - * @param mixed $request - * @param mixed $response - * @param mixed $args - * @return void - */ - public function displayMain($request, $response, $args){ - - // Access-controlled resource - if (!$this->ci->authorizer->checkAccess($this->ci->currentUser, 'update_site_config')) { - throw new ForbiddenException(); - } - - // Get all the config schemas - $schemas = $this->manager->getAllShemas(); - - // Parse each of them to get it's content - foreach ($schemas as $i => $schemaData) { - - // Set the schemam, the validator and the form - $schema = new RequestSchemaRepository($schemaData['config']); - $validator = new JqueryValidationAdapter($schema, $this->ci->translator); - - // Create the form - $config = $this->ci->config; - $form = new Form($schema, $config); - - // The field names dot syntaxt won't make it across the HTTP POST request. - // Wrap them in a nice `data` array - $form->setFormNamespace("data"); - - // Twig doesn't need the raw thing - unset($schemas[$i]['config']); - - // Add the field and validator so Twig can play with them - $schemas[$i]["fields"] = $form->generate(); - $schemas[$i]["validators"] = $validator->rules('json', true); - - // Add the save url for that schema - $schemas[$i]["formAction"] = $this->ci->router->pathFor('ConfigManager.save', ['schema' => $schemaData['filename']]); - } - - // Time to render the page ! - $this->ci->view->render($response, 'pages/ConfigManager.html.twig', [ - "schemas" => $schemas, - ]); - - } - - /** - * update function. - * Processes the request to save the settings to the db - * - * @access public - * @param mixed $request - * @param mixed $response - * @param mixed $args - * @return void - */ - public function update($request, $response, $args){ - - // Get the alert message stream - $ms = $this->ci->alerts; - - // Access-controlled resource - if (!$this->ci->authorizer->checkAccess($this->ci->currentUser, 'update_site_config')) { - throw new ForbiddenException(); - } - - // Request POST data - $post = $request->getParsedBody(); - - // So we first get the shcema data - $loader = new YamlFileLoader("schema://config/".$args['schema'].".json"); - $schemaData = $loader->load(); - - // We can't pass the file directly to RequestSchema because it's a custom one - // So we create a new empty RequestSchemaRepository and feed it the `config` part of our custom schema - $schema = new RequestSchemaRepository($schemaData['config']); - - // Transform the data - $transformer = new RequestDataTransformer($schema); - $data = $transformer->transform($post['data']); - - // We change the dot notation of our elements to a multidimensionnal array - // This is required for the fields (but not for the schema) because the validator doesn't use the - // dot notation the same way. Sending dot notation field name to the validator will fail. - $dataArray = array(); - foreach ($data as $key => $value) { - array_set($dataArray, $key, $value); - } - - // We validate the data array against the schema - $validator = new ServerSideValidator($schema, $this->ci->translator); - if (!$validator->validate($dataArray)) { - $ms->addValidationErrors($validator); - return $response->withStatus(400); - } - - // The data is now validaded. Instead or switching back the array to dot notation, - // we can use the `$data` that's still intact. The validator doesn't change the data - // Next, update each config - foreach ($data as $key => $value) { - - // We need to access the $schemaData to find if we need to cache this one - $cached = (isset($schemaData['config'][$key]['cached'])) ? $schemaData['config'][$key]['cached'] : true; - - // Set the config using the manager - $this->manager->set($key, $value, $cached); - } - - //Success message! - $ms->addMessageTranslated("success", "SITE.CONFIG.SAVED"); - return $response->withJson([], 200, JSON_PRETTY_PRINT); - } -} diff --git a/main/app/sprinkles/ConfigManager/src/Database/Migrations/v100/SettingsTable.php b/main/app/sprinkles/ConfigManager/src/Database/Migrations/v100/SettingsTable.php deleted file mode 100644 index 182dbfb..0000000 --- a/main/app/sprinkles/ConfigManager/src/Database/Migrations/v100/SettingsTable.php +++ /dev/null @@ -1,48 +0,0 @@ -schema->hasTable('settings')) { - $this->schema->create('settings', function (Blueprint $table) { - $table->increments('id'); - $table->string('key'); - $table->string('value')->nullable(); - $table->boolean('cached')->default(1); - $table->timestamps(); - - $table->engine = 'InnoDB'; - $table->collation = 'utf8_unicode_ci'; - $table->charset = 'utf8'; - }); - } - } - - /** - * {@inheritDoc} - */ - public function down() - { - $this->schema->drop('settings'); - } -} \ No newline at end of file diff --git a/main/app/sprinkles/ConfigManager/src/Database/Migrations/v101/SettingsPermissions.php b/main/app/sprinkles/ConfigManager/src/Database/Migrations/v101/SettingsPermissions.php deleted file mode 100644 index c3928d9..0000000 --- a/main/app/sprinkles/ConfigManager/src/Database/Migrations/v101/SettingsPermissions.php +++ /dev/null @@ -1,70 +0,0 @@ -first(); - if ($permissionExist) { - $this->io->warning("\nPermission slug `update_site_config` already exist. Skipping..."); - return; - } - - // Add default permissions - $permission = new Permission([ - 'slug' => 'update_site_config', - 'name' => 'Update site configuration', - 'conditions' => 'always()', - 'description' => 'Edit site configuration from the UI' - ]); - $permission->save(); - - $roleSiteAdmin = Role::where('slug', 'site-admin')->first(); - if ($roleSiteAdmin) { - $roleSiteAdmin->permissions()->attach([ - $permission->id - ]); - } - } - - /** - * {@inheritDoc} - */ - public function down() - { - $permissions = Permission::where('slug', 'update_site_config')->get(); - foreach ($permissions as $permission) { - $permission->delete(); - } - } -} \ No newline at end of file diff --git a/main/app/sprinkles/ConfigManager/src/Database/Models/Config.php b/main/app/sprinkles/ConfigManager/src/Database/Models/Config.php deleted file mode 100644 index 53a85ca..0000000 --- a/main/app/sprinkles/ConfigManager/src/Database/Models/Config.php +++ /dev/null @@ -1,70 +0,0 @@ -db; - return new ConfigManager($c); - }; - } -} diff --git a/main/app/sprinkles/ConfigManager/src/Util/ConfigManager.php b/main/app/sprinkles/ConfigManager/src/Util/ConfigManager.php deleted file mode 100644 index e935487..0000000 --- a/main/app/sprinkles/ConfigManager/src/Util/ConfigManager.php +++ /dev/null @@ -1,243 +0,0 @@ -ci = $ci; - } - - /** - * __invoke function. - * Invoke the ConfigManager middleware, merging the db config with the file based one - * - * @access public - * @param \Psr\Http\Message\ServerRequestInterface $request PSR7 request - * @param \Psr\Http\Message\ResponseInterface $response PSR7 response - * @param callable $next Next middleware - * @return \Psr\Http\Message\ResponseInterface - */ - public function __invoke($request, $response, $next) - { - $this->ci->config->mergeItems(null, $this->fetch()); - return $next($request, $response); - } - - /** - * fetch function. - * Fetch all the config from the db and uses the - * cache container to store most of thoses setting in the cache system - * - * @access public - * @return void - */ - public function fetch() { - - $cache = $this->ci->cache; - - // Case n° 1 we don't have cached content. We load everything - // Case n° 2 we have cached content, pull that and load the non chanched things to it - if (($cached_settings = $cache->get('UF_config')) === null) - { - $settingsCollection = Config::all(); - $settings = $this->collectionToArray($settingsCollection); - - // Save in cache. The settings that are not cached are not included - $cache->forever('UF_config', $this->collectionToArray($settingsCollection, false)); - } - else - { - // We have the cached values, we need to grab the non cached ones - $settingsCollection = Config::where('cached', 0); - $settings = array_merge_recursive($cached_settings, $this->collectionToArray($settingsCollection)); - } - - return $settings; - } - - /** - * delete function. - * Removes a configuration option - * - * @access public - * @param string $key The setting's name - * @return bool Success - */ - public function delete($key) { - - // Get the desired key - if (!$setting = Config::where('key', $key)->first()) { - return false; - } - - // Delete time - $setting->delete(); - - // Remove from current laod - unset($this->ci->config[$key]); - - // Delete cache - if ($setting->cached) - { - $this->ci->cache->forget('UF_config'); - } - - return true; - } - - /** - * set function. - * Sets a setting's value - * - * @access public - * @param string $key The setting's name - * @param string $value The new value - * @param bool $cached (default: true) Whether this variable should be cached or if it - * changes too frequently to be efficiently cached. - * @return bool True if the value was changed, false otherwise - */ - public function set($key, $value, $cached = true) { - return $this->set_atomic($key, false, $value, $cached); - } - - /** - * set_atomic function. - * Sets a setting's value only if the old_value matches the - * current value or the setting does not exist yet. - * - * @access public - * @param string $key The setting's name - * @param string $old_value Current configuration value or false to ignore - * the old value - * @param string $new_value The new value - * @param bool $cached (default: true) Whether this variable should be cached or if it - * changes too frequently to be efficiently cached. - * @return bool True if the value was changed, false otherwise - */ - public function set_atomic($key, $old_value, $new_value, $cached = true) { - - // Get the desired key - $setting = Config::where('key', $key)->first(); - - if ($setting) { - - if ($old_value === false || $setting->value == $old_value) { - - $setting->value = $new_value; - $setting->save(); - - } else { - return false; - } - - } else { - $setting = new Config([ - 'key' => $key, - 'value' => $new_value, - 'cached' => $cached - ]); - $setting->save(); - } - - if ($cached) - { - $this->ci->cache->forget('UF_config'); - } - - $this->ci->config[$key] = $new_value; - return true; - } - - /** - * getAllShemas function. - * Get all the config schemas available - * - * @access public - * @return void - */ - public function getAllShemas() { - - $configSchemas = []; - - $loader = new YamlFileLoader([]); - - // Get all the location where we can find config schemas - $paths = array_reverse($this->ci->locator->findResources('schema://config', true, false)); - - // For every location... - foreach ($paths as $path) { - - // Get a list of all the schemas file - $files_with_path = glob($path . "/*.json"); - - // Load every found files - foreach ($files_with_path as $file) { - - // Load the file content - $schema = $loader->loadFile($file); - - // Get file name - $filename = basename($file, ".json"); - - //inject file name - $schema['filename'] = $filename; - - // Add to list - $configSchemas[$filename] = $schema; - } - } - - return $configSchemas; - } - - - /** - * collectionToArray function. - * This function Expand the db dot notation single level array - * to a multi-dimensional array - * - * @access private - * @param Collection $Collection Eloquent collection - * @return array - */ - private function collectionToArray($Collection, $include_noncached = true) { - $settings_array = array(); - foreach ($Collection as $setting) { - if ($include_noncached || $setting->cached) { - array_set($settings_array, $setting->key, $setting->value); - } - } - return $settings_array; - } -} \ No newline at end of file diff --git a/main/app/sprinkles/ConfigManager/templates/pages/ConfigManager.html.twig b/main/app/sprinkles/ConfigManager/templates/pages/ConfigManager.html.twig deleted file mode 100644 index ebfb251..0000000 --- a/main/app/sprinkles/ConfigManager/templates/pages/ConfigManager.html.twig +++ /dev/null @@ -1,64 +0,0 @@ -{% extends "pages/abstract/dashboard.html.twig" %} - -{% block page_title %}{{ translate('SITE.CONFIG.MANAGER') }}{% endblock %} -{% block page_description %}{{ translate('SITE.CONFIG.PAGEDESC') }}{% endblock %} - -{% block body_matter %} -
    -
    -
    -
    -

    Menu

    -
    -
    - -
    -
    -
    -
    - {% for schema in schemas %} - - {% endfor %} -
    -
    -{% endblock %} -{% block scripts_page %} - - - - - {{ assets.js('js/ConfigManager') | raw }} - {{ assets.js('js/form-widgets') | raw }} - -{% endblock %} diff --git a/main/app/sprinkles/admin/routes/posts.php b/main/app/sprinkles/admin/routes/posts.php index 2168818..ebc2cda 100644 --- a/main/app/sprinkles/admin/routes/posts.php +++ b/main/app/sprinkles/admin/routes/posts.php @@ -6,10 +6,6 @@ * @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License) */ -use Slim\Http\Request; -use Slim\Http\Response; -use Slim\Http\UploadedFile; - /** * Routes for posting. */ diff --git a/main/app/sprinkles/admin/src/Controller/PostController.php b/main/app/sprinkles/admin/src/Controller/PostController.php index e191207..a3015f7 100644 --- a/main/app/sprinkles/admin/src/Controller/PostController.php +++ b/main/app/sprinkles/admin/src/Controller/PostController.php @@ -39,7 +39,7 @@ class PostController extends SimpleController $authorizer = $this->ci->authorizer; $currentUser = $this->ci->currentUser; - if (!$authorizer->checkAccess($currentUser, 'uri_dashboard')) { + if (!$authorizer->checkAccess($currentUser, 'post_image')) { throw new ForbiddenException(); } diff --git a/main/app/sprinkles/admin/templates/navigation/sidebar-menu.html.twig b/main/app/sprinkles/admin/templates/navigation/sidebar-menu.html.twig index bde2674..e6d4a7c 100644 --- a/main/app/sprinkles/admin/templates/navigation/sidebar-menu.html.twig +++ b/main/app/sprinkles/admin/templates/navigation/sidebar-menu.html.twig @@ -35,9 +35,4 @@ {{ translate("GROUP", 2) }} {% endif %} - {% if checkAccess('update_site_config') %} -
  • - {{ translate("SITE.CONFIG.MANAGER") }} -
  • - {% endif %} {% endblock %} \ No newline at end of file diff --git a/main/app/sprinkles/core/asset-bundles.json b/main/app/sprinkles/core/asset-bundles.json index 68f26fe..8ab6c15 100644 --- a/main/app/sprinkles/core/asset-bundles.json +++ b/main/app/sprinkles/core/asset-bundles.json @@ -50,7 +50,7 @@ "SiteAssets/js/modernizr.js", "SiteAssets/js/linkify.js", "SiteAssets/js/encryption.js", - "SiteAssets/js/slick.js", + "SiteAssets/js/swiper.js", "SiteAssets/js/console.image.js", "SiteAssets/js/main.js" ], @@ -97,7 +97,7 @@ }, "css/main-site": { "styles": [ - "SiteAssets/css/slick.css", + "SiteAssets/css/swiper.css", "SiteAssets/css/main.css" ], "options": { diff --git a/main/app/sprinkles/core/assets/SiteAssets/css/slick.css b/main/app/sprinkles/core/assets/SiteAssets/css/slick.css deleted file mode 100644 index 5910f93..0000000 --- a/main/app/sprinkles/core/assets/SiteAssets/css/slick.css +++ /dev/null @@ -1,104 +0,0 @@ -.slick-slider { - position: relative; - display: block; - box-sizing: border-box; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; - -webkit-touch-callout: none; - -khtml-user-select: none; - -ms-touch-action: pan-y; - touch-action: pan-y; - -webkit-tap-highlight-color: transparent -} - -.slick-list { - position: relative; - display: block; - overflow: hidden; - margin: 0; - padding: 0 -} - -.slick-list:focus { - outline: 0 -} - -.slick-list.dragging { - cursor: pointer; - cursor: hand -} - -.slick-slider .slick-list, .slick-slider .slick-track { - -webkit-transform: translate3d(0, 0, 0); - -moz-transform: translate3d(0, 0, 0); - -ms-transform: translate3d(0, 0, 0); - -o-transform: translate3d(0, 0, 0); - transform: translate3d(0, 0, 0) -} - -.slick-track { - position: relative; - top: 0; - left: 0; - display: block; - margin-left: auto; - margin-right: auto -} - -.slick-track:after, .slick-track:before { - display: table; - content: '' -} - -.slick-track:after { - clear: both -} - -.slick-loading .slick-track { - visibility: hidden -} - -.slick-slide { - display: none; - float: left; - height: 100%; - min-height: 1px -} - -[dir=rtl] .slick-slide { - float: right -} - -.slick-slide img { - display: block -} - -.slick-slide.slick-loading img { - display: none -} - -.slick-slide.dragging img { - pointer-events: none -} - -.slick-initialized .slick-slide { - display: block -} - -.slick-loading .slick-slide { - visibility: hidden -} - -.slick-vertical .slick-slide { - display: block; - height: auto; - border: 1px solid transparent -} - -.slick-arrow.slick-hidden { - display: none -} - -/*# sourceMappingURL=slick.min.css.map */ \ No newline at end of file diff --git a/main/app/sprinkles/core/assets/SiteAssets/css/swiper.css b/main/app/sprinkles/core/assets/SiteAssets/css/swiper.css new file mode 100644 index 0000000..5910f93 --- /dev/null +++ b/main/app/sprinkles/core/assets/SiteAssets/css/swiper.css @@ -0,0 +1,104 @@ +.slick-slider { + position: relative; + display: block; + box-sizing: border-box; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + -webkit-touch-callout: none; + -khtml-user-select: none; + -ms-touch-action: pan-y; + touch-action: pan-y; + -webkit-tap-highlight-color: transparent +} + +.slick-list { + position: relative; + display: block; + overflow: hidden; + margin: 0; + padding: 0 +} + +.slick-list:focus { + outline: 0 +} + +.slick-list.dragging { + cursor: pointer; + cursor: hand +} + +.slick-slider .slick-list, .slick-slider .slick-track { + -webkit-transform: translate3d(0, 0, 0); + -moz-transform: translate3d(0, 0, 0); + -ms-transform: translate3d(0, 0, 0); + -o-transform: translate3d(0, 0, 0); + transform: translate3d(0, 0, 0) +} + +.slick-track { + position: relative; + top: 0; + left: 0; + display: block; + margin-left: auto; + margin-right: auto +} + +.slick-track:after, .slick-track:before { + display: table; + content: '' +} + +.slick-track:after { + clear: both +} + +.slick-loading .slick-track { + visibility: hidden +} + +.slick-slide { + display: none; + float: left; + height: 100%; + min-height: 1px +} + +[dir=rtl] .slick-slide { + float: right +} + +.slick-slide img { + display: block +} + +.slick-slide.slick-loading img { + display: none +} + +.slick-slide.dragging img { + pointer-events: none +} + +.slick-initialized .slick-slide { + display: block +} + +.slick-loading .slick-slide { + visibility: hidden +} + +.slick-vertical .slick-slide { + display: block; + height: auto; + border: 1px solid transparent +} + +.slick-arrow.slick-hidden { + display: none +} + +/*# sourceMappingURL=slick.min.css.map */ \ No newline at end of file diff --git a/main/app/sprinkles/core/assets/SiteAssets/js/slick.js b/main/app/sprinkles/core/assets/SiteAssets/js/slick.js deleted file mode 100644 index 5c668f2..0000000 --- a/main/app/sprinkles/core/assets/SiteAssets/js/slick.js +++ /dev/null @@ -1,556 +0,0 @@ -!function (i) { - "use strict"; - "function" == typeof define && define.amd ? define(["jquery"], i) : "undefined" != typeof exports ? module.exports = i(require("jquery")) : i(jQuery) -}(function (i) { - "use strict"; - var e = window.Slick || {}; - (e = function () { - var e = 0; - return function (t, o) { - var s, n = this; - n.defaults = { - accessibility: !0, - adaptiveHeight: !1, - appendArrows: i(t), - appendDots: i(t), - arrows: !0, - asNavFor: null, - prevArrow: '', - nextArrow: '', - autoplay: !1, - autoplaySpeed: 3e3, - centerMode: !1, - centerPadding: "50px", - cssEase: "ease", - customPaging: function (e, t) { - return i('', + nextArrow: '', + autoplay: !1, + autoplaySpeed: 3e3, + centerMode: !1, + centerPadding: "50px", + cssEase: "ease", + customPaging: function (e, t) { + return i('