From 8af3e1d54129d047d95c15a00012684bd19f1ec1 Mon Sep 17 00:00:00 2001 From: Kerim Date: Mon, 24 Jul 2023 16:45:53 +0500 Subject: [PATCH] api --- config/auth.php | 37 +- config/authBackup.php | 126 +++ plugins/rainlab/notify/LICENSE.md | 19 - plugins/rainlab/notify/Plugin.php | 69 -- plugins/rainlab/notify/README.md | 400 --------- plugins/rainlab/notify/classes/ActionBase.php | 168 ---- .../notify/classes/CompoundCondition.php | 169 ---- .../rainlab/notify/classes/ConditionBase.php | 211 ----- plugins/rainlab/notify/classes/EventBase.php | 237 ------ .../rainlab/notify/classes/EventParams.php | 59 -- .../classes/ModelAttributesConditionBase.php | 731 ----------------- plugins/rainlab/notify/classes/Notifier.php | 134 ---- .../classes/compoundcondition/fields.yaml | 14 - .../_column_select_record.htm | 10 - .../_field_value.htm | 107 --- .../modelattributesconditionbase/fields.yaml | 22 - plugins/rainlab/notify/composer.json | 25 - .../notify/controllers/Notifications.php | 137 ---- .../notifications/_add_rule_event_form.htm | 41 - .../notifications/_add_rule_group_form.htm | 49 -- .../notifications/_form_toolbar.htm | 49 -- .../notifications/_list_toolbar.htm | 9 - .../notifications/config_form.yaml | 16 - .../notifications/config_list.yaml | 20 - .../controllers/notifications/create.htm | 31 - .../controllers/notifications/update.htm | 30 - .../notify/formwidgets/ActionBuilder.php | 350 -------- .../notify/formwidgets/ConditionBuilder.php | 454 ----------- .../actionbuilder/assets/css/actions.css | 227 ------ .../actionbuilder/assets/js/actions.js | 153 ---- .../actionbuilder/assets/less/actions.less | 273 ------- .../actionbuilder/partials/_action.htm | 29 - .../partials/_action_settings_form.htm | 71 -- .../actionbuilder/partials/_actions.htm | 31 - .../partials/_actions_container.htm | 12 - .../partials/_available_tags.htm | 23 - .../partials/_create_action_form.htm | 48 -- .../assets/css/conditions.css | 227 ------ .../conditionbuilder/assets/js/conditions.js | 184 ----- .../assets/js/conditions.multivalue.js | 139 ---- .../assets/less/conditions.less | 286 ------- .../conditionbuilder/partials/_condition.htm | 99 --- .../partials/_condition_settings_form.htm | 68 -- .../conditionbuilder/partials/_conditions.htm | 10 - .../partials/_conditions_container.htm | 13 - .../partials/_create_child_form.htm | 67 -- plugins/rainlab/notify/interfaces/Action.php | 31 - .../notify/interfaces/CompoundCondition.php | 19 - .../rainlab/notify/interfaces/Condition.php | 32 - plugins/rainlab/notify/interfaces/Event.php | 21 - plugins/rainlab/notify/lang/en/lang.php | 22 - plugins/rainlab/notify/lang/ro/lang.php | 22 - plugins/rainlab/notify/lang/ru/lang.php | 22 - plugins/rainlab/notify/lang/sl/lang.php | 22 - plugins/rainlab/notify/lang/tr/lang.php | 22 - plugins/rainlab/notify/lang/zh-tw/lang.php | 22 - .../rainlab/notify/models/Notification.php | 249 ------ .../notify/models/NotificationRule.php | 289 ------- plugins/rainlab/notify/models/RuleAction.php | 164 ---- .../rainlab/notify/models/RuleCondition.php | 172 ---- .../models/notificationrule/columns.yaml | 13 - .../models/notificationrule/fields.yaml | 47 -- .../notify/models/ruleaction/columns.yaml | 8 - .../notify/models/ruleaction/fields.yaml | 8 - .../notifyrules/ExecutionContextCondition.php | 136 ---- .../notify/notifyrules/SaveDatabaseAction.php | 125 --- .../notifyrules/SendMailTemplateAction.php | 223 ----- .../executioncontextcondition/fields.yaml | 21 - .../savedatabaseaction/fields.yaml | 8 - .../sendmailtemplateaction/fields.yaml | 42 - .../create_notification_rules_table.php | 29 - .../updates/create_notifications_table.php | 28 - .../updates/create_rule_actions_table.php | 25 - .../updates/create_rule_conditions_table.php | 29 - plugins/rainlab/notify/updates/version.yaml | 9 - plugins/rainlab/user/.gitignore | 3 + plugins/rainlab/user/Plugin.php | 45 +- plugins/rainlab/user/README.md | 29 +- .../rainlab/user/assets/js/bulk-actions.js | 14 +- plugins/rainlab/user/classes/AuthManager.php | 28 +- plugins/rainlab/user/components/Account.php | 312 +++---- .../rainlab/user/components/ResetPassword.php | 40 +- plugins/rainlab/user/components/Session.php | 55 +- .../user/components/resetpassword/check.htm | 5 - .../components/resetpassword/complete.htm | 15 +- .../user/components/resetpassword/default.htm | 19 +- .../user/components/resetpassword/reset.htm | 35 +- .../user/components/resetpassword/restore.htm | 29 +- plugins/rainlab/user/composer.json | 23 +- plugins/rainlab/user/config/config.php | 2 +- plugins/rainlab/user/controllers/Users.php | 1 + .../controllers/users/_convert_guest_form.htm | 13 +- .../user/controllers/users/_list_toolbar.htm | 10 +- .../controllers/users/_preview_toolbar.htm | 4 +- .../user/controllers/users/config_filter.yaml | 30 - .../user/controllers/users/config_list.yaml | 6 +- plugins/rainlab/user/lang/ar/lang.php | 228 ++++++ plugins/rainlab/user/lang/en/lang.php | 13 +- plugins/rainlab/user/lang/ru/lang.php | 11 +- plugins/rainlab/user/lang/si/lang.php | 228 ++++++ plugins/rainlab/user/lang/sl/lang.php | 25 +- plugins/rainlab/user/lang/tm/lang.php | 229 ------ plugins/rainlab/user/lang/zh-cn/lang.php | 45 +- plugins/rainlab/user/models/MailBlocker.php | 24 +- plugins/rainlab/user/models/User.php | 136 ++-- plugins/rainlab/user/models/user/columns.yaml | 13 - plugins/rainlab/user/models/user/fields.yaml | 174 ++-- plugins/rainlab/user/models/user/scopes.yaml | 30 + .../user/notifyrules/UserRegisteredEvent.php | 10 - .../userattributecondition/attributes.yaml | 3 - plugins/rainlab/user/phpunit.xml | 37 +- .../rainlab/user/tests/UserPluginTestCase.php | 26 +- .../tests/unit/facades/AuthFacadeTest.php | 34 +- .../user/updates/create_user_groups_table.php | 2 +- .../user/updates/users_add_additionals.php | 41 + .../user/updates/users_add_ip_address.php | 9 +- .../user/updates/users_add_sliders.php | 25 + plugins/rainlab/user/updates/version.yaml | 139 ++-- plugins/rainlab/user/vendor/autoload.php | 7 - .../user/vendor/composer/ClassLoader.php | 445 ---------- plugins/rainlab/user/vendor/composer/LICENSE | 21 - .../vendor/composer/autoload_classmap.php | 9 - .../vendor/composer/autoload_namespaces.php | 9 - .../user/vendor/composer/autoload_psr4.php | 10 - .../user/vendor/composer/autoload_real.php | 52 -- .../user/vendor/composer/autoload_static.php | 31 - .../user/vendor/composer/installed.json | 136 ---- .../vendor/composer/installers/CHANGELOG.md | 133 --- .../composer/installers/CONTRIBUTING.md | 24 - .../user/vendor/composer/installers/LICENSE | 19 - .../user/vendor/composer/installers/README.md | 287 ------- .../vendor/composer/installers/_config.yml | 1 - .../vendor/composer/installers/composer.json | 121 --- .../composer/installers/phpstan.neon.dist | 10 - .../composer/installers/phpunit.xml.dist | 29 - .../src/Composer/Installers/AglInstaller.php | 21 - .../Composer/Installers/AimeosInstaller.php | 9 - .../Installers/AnnotateCmsInstaller.php | 11 - .../Composer/Installers/AsgardInstaller.php | 49 -- .../Composer/Installers/AttogramInstaller.php | 9 - .../src/Composer/Installers/BaseInstaller.php | 137 ---- .../Composer/Installers/BitrixInstaller.php | 126 --- .../Composer/Installers/BonefishInstaller.php | 9 - .../Composer/Installers/CakePHPInstaller.php | 65 -- .../src/Composer/Installers/ChefInstaller.php | 11 - .../Composer/Installers/CiviCrmInstaller.php | 9 - .../Installers/ClanCatsFrameworkInstaller.php | 10 - .../Composer/Installers/CockpitInstaller.php | 32 - .../Installers/CodeIgniterInstaller.php | 11 - .../Installers/Concrete5Installer.php | 13 - .../Composer/Installers/CraftInstaller.php | 35 - .../Composer/Installers/CroogoInstaller.php | 21 - .../Composer/Installers/DecibelInstaller.php | 10 - .../Composer/Installers/DframeInstaller.php | 10 - .../Composer/Installers/DokuWikiInstaller.php | 50 -- .../Composer/Installers/DolibarrInstaller.php | 16 - .../Composer/Installers/DrupalInstaller.php | 22 - .../src/Composer/Installers/ElggInstaller.php | 9 - .../Composer/Installers/EliasisInstaller.php | 12 - .../Installers/ExpressionEngineInstaller.php | 29 - .../Installers/EzPlatformInstaller.php | 10 - .../src/Composer/Installers/FuelInstaller.php | 11 - .../Composer/Installers/FuelphpInstaller.php | 9 - .../src/Composer/Installers/GravInstaller.php | 30 - .../Composer/Installers/HuradInstaller.php | 25 - .../Composer/Installers/ImageCMSInstaller.php | 11 - .../src/Composer/Installers/Installer.php | 297 ------- .../src/Composer/Installers/ItopInstaller.php | 9 - .../Composer/Installers/JoomlaInstaller.php | 15 - .../Composer/Installers/KanboardInstaller.php | 18 - .../Composer/Installers/KirbyInstaller.php | 11 - .../Composer/Installers/KnownInstaller.php | 11 - .../Composer/Installers/KodiCMSInstaller.php | 10 - .../Composer/Installers/KohanaInstaller.php | 9 - .../LanManagementSystemInstaller.php | 27 - .../Composer/Installers/LaravelInstaller.php | 9 - .../Composer/Installers/LavaLiteInstaller.php | 10 - .../Composer/Installers/LithiumInstaller.php | 10 - .../Installers/MODULEWorkInstaller.php | 9 - .../Composer/Installers/MODXEvoInstaller.php | 16 - .../Composer/Installers/MagentoInstaller.php | 11 - .../Composer/Installers/MajimaInstaller.php | 37 - .../src/Composer/Installers/MakoInstaller.php | 9 - .../Composer/Installers/MantisBTInstaller.php | 23 - .../Composer/Installers/MauticInstaller.php | 25 - .../src/Composer/Installers/MayaInstaller.php | 33 - .../Installers/MediaWikiInstaller.php | 51 -- .../Composer/Installers/MiaoxingInstaller.php | 10 - .../Installers/MicroweberInstaller.php | 119 --- .../src/Composer/Installers/ModxInstaller.php | 12 - .../Composer/Installers/MoodleInstaller.php | 59 -- .../Composer/Installers/OctoberInstaller.php | 47 -- .../Composer/Installers/OntoWikiInstaller.php | 24 - .../Composer/Installers/OsclassInstaller.php | 14 - .../src/Composer/Installers/OxidInstaller.php | 59 -- .../src/Composer/Installers/PPIInstaller.php | 9 - .../Composer/Installers/PhiftyInstaller.php | 11 - .../Composer/Installers/PhpBBInstaller.php | 11 - .../Composer/Installers/PimcoreInstaller.php | 21 - .../Composer/Installers/PiwikInstaller.php | 32 - .../Installers/PlentymarketsInstaller.php | 29 - .../src/Composer/Installers/Plugin.php | 27 - .../Composer/Installers/PortoInstaller.php | 9 - .../Installers/PrestashopInstaller.php | 10 - .../Installers/ProcessWireInstaller.php | 22 - .../Composer/Installers/PuppetInstaller.php | 11 - .../Composer/Installers/PxcmsInstaller.php | 63 -- .../Composer/Installers/RadPHPInstaller.php | 24 - .../Composer/Installers/ReIndexInstaller.php | 10 - .../Composer/Installers/Redaxo5Installer.php | 10 - .../Composer/Installers/RedaxoInstaller.php | 10 - .../Installers/RoundcubeInstaller.php | 22 - .../src/Composer/Installers/SMFInstaller.php | 10 - .../Composer/Installers/ShopwareInstaller.php | 60 -- .../Installers/SilverStripeInstaller.php | 35 - .../Installers/SiteDirectInstaller.php | 25 - .../Composer/Installers/StarbugInstaller.php | 12 - .../Composer/Installers/SyDESInstaller.php | 47 -- .../Composer/Installers/SyliusInstaller.php | 9 - .../Composer/Installers/Symfony1Installer.php | 26 - .../Composer/Installers/TYPO3CmsInstaller.php | 16 - .../Installers/TYPO3FlowInstaller.php | 38 - .../src/Composer/Installers/TaoInstaller.php | 30 - .../Installers/TastyIgniterInstaller.php | 32 - .../Composer/Installers/TheliaInstaller.php | 12 - .../src/Composer/Installers/TuskInstaller.php | 14 - .../Installers/UserFrostingInstaller.php | 9 - .../Composer/Installers/VanillaInstaller.php | 10 - .../Composer/Installers/VgmcpInstaller.php | 49 -- .../Composer/Installers/WHMCSInstaller.php | 21 - .../Composer/Installers/WinterInstaller.php | 58 -- .../Composer/Installers/WolfCMSInstaller.php | 9 - .../Installers/WordPressInstaller.php | 12 - .../Composer/Installers/YawikInstaller.php | 32 - .../src/Composer/Installers/ZendInstaller.php | 11 - .../Composer/Installers/ZikulaInstaller.php | 10 - .../composer/installers/src/bootstrap.php | 13 - .../Installers/Test/AsgardInstallerTest.php | 80 -- .../Installers/Test/BitrixInstallerTest.php | 75 -- .../Installers/Test/CakePHPInstallerTest.php | 125 --- .../Installers/Test/CiviCrmInstallerTest.php | 55 -- .../Installers/Test/CraftInstallerTest.php | 83 -- .../Installers/Test/DokuWikiInstallerTest.php | 90 --- .../Installers/Test/GravInstallerTest.php | 63 -- .../Installers/Test/InstallerTest.php | 682 ---------------- .../Installers/Test/MayaInstallerTest.php | 62 -- .../Test/MediaWikiInstallerTest.php | 67 -- .../Installers/Test/OctoberInstallerTest.php | 89 -- .../Installers/Test/OntoWikiInstallerTest.php | 84 -- .../Installers/Test/PimcoreInstallerTest.php | 44 - .../Installers/Test/PiwikInstallerTest.php | 57 -- .../Installers/Test/PolyfillTestCase.php | 759 ------------------ .../Test/ProcessWireInstallerTest.php | 44 - .../Test/SiteDirectInstallerTest.php | 120 --- .../Installers/Test/SyDESInstallerTest.php | 82 -- .../Test/TastyIgniterInstallerTest.php | 94 --- .../Composer/Installers/Test/TestCase.php | 86 -- .../Installers/Test/VgmcpInstallerTest.php | 80 -- .../Installers/Test/WinterInstallerTest.php | 97 --- .../Installers/Test/YawikInstallerTest.php | 58 -- .../user/views/mail/email_verification.htm | 6 - plugins/rainlab/userplus/LICENCE.md | 19 - plugins/rainlab/userplus/Plugin.php | 124 --- plugins/rainlab/userplus/README.md | 13 - .../userplus/assets/css/notifications.css | 74 -- .../userplus/assets/js/notifications.js | 13 - .../userplus/assets/less/notifications.less | 84 -- .../userplus/components/Notifications.php | 129 --- .../components/notifications/default.htm | 1 - .../components/notifications/desktop.htm | 17 - .../components/notifications/mobile.htm | 17 - .../notifications/notifications-list.htm | 20 - plugins/rainlab/userplus/composer.json | 8 - .../userplus/config/notify_presets.yaml | 11 - .../userplus/config/profile_fields.yaml | 47 -- plugins/rainlab/userplus/lang/cs/lang.php | 19 - plugins/rainlab/userplus/lang/en/lang.php | 19 - plugins/rainlab/userplus/lang/fa/lang.php | 16 - plugins/rainlab/userplus/lang/fr/lang.php | 15 - plugins/rainlab/userplus/lang/hu/lang.php | 19 - plugins/rainlab/userplus/lang/pt-br/lang.php | 19 - plugins/rainlab/userplus/lang/tr/lang.php | 19 - .../UserLocationAttributeCondition.php | 37 - .../attributes.yaml | 23 - .../updates/user_add_location_fields.php | 29 - .../updates/user_add_mobile_field.php | 28 - .../updates/user_add_profile_fields.php | 32 - plugins/rainlab/userplus/updates/version.yaml | 10 - plugins/rainlab/userplus/vendor/autoload.php | 7 - .../userplus/vendor/composer/ClassLoader.php | 413 ---------- .../rainlab/userplus/vendor/composer/LICENSE | 21 - .../vendor/composer/autoload_classmap.php | 9 - .../vendor/composer/autoload_namespaces.php | 9 - .../vendor/composer/autoload_psr4.php | 10 - .../vendor/composer/autoload_real.php | 45 -- .../userplus/vendor/composer/installed.json | 210 ----- .../vendor/composer/installers/CHANGELOG.md | 60 -- .../composer/installers/CONTRIBUTING.md | 24 - .../vendor/composer/installers/LICENSE | 19 - .../vendor/composer/installers/README.md | 214 ----- .../vendor/composer/installers/composer.json | 99 --- .../composer/installers/phpunit.xml.dist | 25 - .../src/Composer/Installers/AglInstaller.php | 21 - .../Composer/Installers/AimeosInstaller.php | 9 - .../Installers/AnnotateCmsInstaller.php | 11 - .../Composer/Installers/AsgardInstaller.php | 49 -- .../Composer/Installers/AttogramInstaller.php | 9 - .../src/Composer/Installers/BaseInstaller.php | 136 ---- .../Composer/Installers/BitrixInstaller.php | 126 --- .../Composer/Installers/BonefishInstaller.php | 9 - .../Composer/Installers/CakePHPInstaller.php | 83 -- .../src/Composer/Installers/ChefInstaller.php | 11 - .../Installers/ClanCatsFrameworkInstaller.php | 10 - .../Composer/Installers/CockpitInstaller.php | 34 - .../Installers/CodeIgniterInstaller.php | 11 - .../Installers/Concrete5Installer.php | 13 - .../Composer/Installers/CraftInstaller.php | 35 - .../Composer/Installers/CroogoInstaller.php | 21 - .../Composer/Installers/DecibelInstaller.php | 10 - .../Composer/Installers/DokuWikiInstaller.php | 50 -- .../Composer/Installers/DolibarrInstaller.php | 16 - .../Composer/Installers/DrupalInstaller.php | 16 - .../src/Composer/Installers/ElggInstaller.php | 9 - .../Composer/Installers/EliasisInstaller.php | 9 - .../Installers/ExpressionEngineInstaller.php | 29 - .../src/Composer/Installers/FuelInstaller.php | 11 - .../Composer/Installers/FuelphpInstaller.php | 9 - .../src/Composer/Installers/GravInstaller.php | 30 - .../Composer/Installers/HuradInstaller.php | 25 - .../Composer/Installers/ImageCMSInstaller.php | 11 - .../src/Composer/Installers/Installer.php | 197 ----- .../src/Composer/Installers/ItopInstaller.php | 9 - .../Composer/Installers/JoomlaInstaller.php | 15 - .../Composer/Installers/KanboardInstaller.php | 18 - .../Composer/Installers/KirbyInstaller.php | 11 - .../Composer/Installers/KodiCMSInstaller.php | 10 - .../Composer/Installers/KohanaInstaller.php | 9 - .../Composer/Installers/LaravelInstaller.php | 9 - .../Composer/Installers/LavaLiteInstaller.php | 10 - .../Composer/Installers/LithiumInstaller.php | 10 - .../Installers/MODULEWorkInstaller.php | 9 - .../Composer/Installers/MODXEvoInstaller.php | 16 - .../Composer/Installers/MagentoInstaller.php | 11 - .../src/Composer/Installers/MakoInstaller.php | 9 - .../Composer/Installers/MauticInstaller.php | 25 - .../src/Composer/Installers/MayaInstaller.php | 33 - .../Installers/MediaWikiInstaller.php | 50 -- .../Installers/MicroweberInstaller.php | 111 --- .../Composer/Installers/MoodleInstaller.php | 57 -- .../Composer/Installers/OctoberInstaller.php | 46 -- .../Composer/Installers/OntoWikiInstaller.php | 24 - .../src/Composer/Installers/OxidInstaller.php | 59 -- .../src/Composer/Installers/PPIInstaller.php | 9 - .../Composer/Installers/PhiftyInstaller.php | 11 - .../Composer/Installers/PhpBBInstaller.php | 11 - .../Composer/Installers/PimcoreInstaller.php | 21 - .../Composer/Installers/PiwikInstaller.php | 32 - .../Installers/PlentymarketsInstaller.php | 29 - .../src/Composer/Installers/Plugin.php | 17 - .../Composer/Installers/PortoInstaller.php | 9 - .../Installers/PrestashopInstaller.php | 10 - .../Composer/Installers/PuppetInstaller.php | 11 - .../Composer/Installers/RadPHPInstaller.php | 24 - .../Composer/Installers/ReIndexInstaller.php | 10 - .../Composer/Installers/RedaxoInstaller.php | 10 - .../Installers/RoundcubeInstaller.php | 22 - .../src/Composer/Installers/SMFInstaller.php | 10 - .../Composer/Installers/ShopwareInstaller.php | 60 -- .../Installers/SilverStripeInstaller.php | 36 - .../Composer/Installers/SyDESInstaller.php | 49 -- .../Composer/Installers/Symfony1Installer.php | 26 - .../Composer/Installers/TYPO3CmsInstaller.php | 16 - .../Installers/TYPO3FlowInstaller.php | 38 - .../Composer/Installers/TheliaInstaller.php | 12 - .../src/Composer/Installers/TuskInstaller.php | 14 - .../Composer/Installers/VanillaInstaller.php | 10 - .../Composer/Installers/VgmcpInstaller.php | 49 -- .../Composer/Installers/WHMCSInstaller.php | 10 - .../Composer/Installers/WolfCMSInstaller.php | 9 - .../Installers/WordPressInstaller.php | 11 - .../Composer/Installers/YawikInstaller.php | 32 - .../src/Composer/Installers/ZendInstaller.php | 11 - .../Composer/Installers/ZikulaInstaller.php | 10 - .../composer/installers/src/bootstrap.php | 13 - .../Installers/Test/AsgardInstallerTest.php | 79 -- .../Installers/Test/BitrixInstallerTest.php | 76 -- .../Installers/Test/CakePHPInstallerTest.php | 115 --- .../Installers/Test/CraftInstallerTest.php | 83 -- .../Installers/Test/DokuWikiInstallerTest.php | 89 -- .../Installers/Test/GravInstallerTest.php | 63 -- .../Installers/Test/InstallerTest.php | 512 ------------ .../Installers/Test/MayaInstallerTest.php | 61 -- .../Test/MediaWikiInstallerTest.php | 66 -- .../Installers/Test/OctoberInstallerTest.php | 66 -- .../Installers/Test/OntoWikiInstallerTest.php | 85 -- .../Installers/Test/PimcoreInstallerTest.php | 44 - .../Installers/Test/PiwikInstallerTest.php | 63 -- .../Installers/Test/SyDESInstallerTest.php | 81 -- .../Composer/Installers/Test/TestCase.php | 64 -- .../Installers/Test/VgmcpInstallerTest.php | 79 -- .../Installers/Test/YawikInstallerTest.php | 64 -- .../composer/installers/tests/bootstrap.php | 4 - plugins/tps/birzha/Plugin.php | 20 +- .../tps/birzha/controllers/UserSliders.php | 18 + .../controllers/usersliders/_list_toolbar.htm | 18 + .../controllers/usersliders/config_form.yaml | 10 + .../controllers/usersliders/config_list.yaml | 12 + .../birzha/controllers/usersliders/create.htm | 46 ++ .../birzha/controllers/usersliders}/index.htm | 1 - .../controllers/usersliders/preview.htm | 22 + .../birzha/controllers/usersliders/update.htm | 54 ++ plugins/tps/birzha/models/Category.php | 12 +- plugins/tps/birzha/models/UserSliders.php | 30 + plugins/tps/birzha/models/UsersCategory.php | 27 + .../birzha/models/usersliders/columns.yaml | 18 + .../tps/birzha/models/usersliders/fields.yaml | 17 + plugins/tps/birzha/plugin.yaml | 18 +- ...r_table_create_tps_birzha_user_sliders.php | 24 + ...ble_create_tps_birzha_users_categories.php | 26 + ...r_table_update_tps_birzha_user_sliders.php | 27 + ...table_update_tps_birzha_user_sliders_2.php | 23 + ...table_update_tps_birzha_user_sliders_3.php | 23 + ...table_update_tps_birzha_user_sliders_4.php | 23 + ...table_update_tps_birzha_user_sliders_5.php | 23 + ...ble_update_tps_birzha_users_categories.php | 27 + plugins/tps/birzha/updates/version.yaml | 24 + plugins/vdomah/jwtauth/routes.php | 257 +----- 427 files changed, 1897 insertions(+), 21754 deletions(-) create mode 100644 config/authBackup.php delete mode 100644 plugins/rainlab/notify/LICENSE.md delete mode 100644 plugins/rainlab/notify/Plugin.php delete mode 100644 plugins/rainlab/notify/README.md delete mode 100644 plugins/rainlab/notify/classes/ActionBase.php delete mode 100644 plugins/rainlab/notify/classes/CompoundCondition.php delete mode 100644 plugins/rainlab/notify/classes/ConditionBase.php delete mode 100644 plugins/rainlab/notify/classes/EventBase.php delete mode 100644 plugins/rainlab/notify/classes/EventParams.php delete mode 100644 plugins/rainlab/notify/classes/ModelAttributesConditionBase.php delete mode 100644 plugins/rainlab/notify/classes/Notifier.php delete mode 100644 plugins/rainlab/notify/classes/compoundcondition/fields.yaml delete mode 100644 plugins/rainlab/notify/classes/modelattributesconditionbase/_column_select_record.htm delete mode 100644 plugins/rainlab/notify/classes/modelattributesconditionbase/_field_value.htm delete mode 100644 plugins/rainlab/notify/classes/modelattributesconditionbase/fields.yaml delete mode 100644 plugins/rainlab/notify/composer.json delete mode 100644 plugins/rainlab/notify/controllers/Notifications.php delete mode 100644 plugins/rainlab/notify/controllers/notifications/_add_rule_event_form.htm delete mode 100644 plugins/rainlab/notify/controllers/notifications/_add_rule_group_form.htm delete mode 100644 plugins/rainlab/notify/controllers/notifications/_form_toolbar.htm delete mode 100644 plugins/rainlab/notify/controllers/notifications/_list_toolbar.htm delete mode 100644 plugins/rainlab/notify/controllers/notifications/config_form.yaml delete mode 100644 plugins/rainlab/notify/controllers/notifications/config_list.yaml delete mode 100644 plugins/rainlab/notify/controllers/notifications/create.htm delete mode 100644 plugins/rainlab/notify/controllers/notifications/update.htm delete mode 100644 plugins/rainlab/notify/formwidgets/ActionBuilder.php delete mode 100644 plugins/rainlab/notify/formwidgets/ConditionBuilder.php delete mode 100644 plugins/rainlab/notify/formwidgets/actionbuilder/assets/css/actions.css delete mode 100644 plugins/rainlab/notify/formwidgets/actionbuilder/assets/js/actions.js delete mode 100644 plugins/rainlab/notify/formwidgets/actionbuilder/assets/less/actions.less delete mode 100644 plugins/rainlab/notify/formwidgets/actionbuilder/partials/_action.htm delete mode 100644 plugins/rainlab/notify/formwidgets/actionbuilder/partials/_action_settings_form.htm delete mode 100644 plugins/rainlab/notify/formwidgets/actionbuilder/partials/_actions.htm delete mode 100644 plugins/rainlab/notify/formwidgets/actionbuilder/partials/_actions_container.htm delete mode 100644 plugins/rainlab/notify/formwidgets/actionbuilder/partials/_available_tags.htm delete mode 100644 plugins/rainlab/notify/formwidgets/actionbuilder/partials/_create_action_form.htm delete mode 100644 plugins/rainlab/notify/formwidgets/conditionbuilder/assets/css/conditions.css delete mode 100644 plugins/rainlab/notify/formwidgets/conditionbuilder/assets/js/conditions.js delete mode 100644 plugins/rainlab/notify/formwidgets/conditionbuilder/assets/js/conditions.multivalue.js delete mode 100644 plugins/rainlab/notify/formwidgets/conditionbuilder/assets/less/conditions.less delete mode 100644 plugins/rainlab/notify/formwidgets/conditionbuilder/partials/_condition.htm delete mode 100644 plugins/rainlab/notify/formwidgets/conditionbuilder/partials/_condition_settings_form.htm delete mode 100644 plugins/rainlab/notify/formwidgets/conditionbuilder/partials/_conditions.htm delete mode 100644 plugins/rainlab/notify/formwidgets/conditionbuilder/partials/_conditions_container.htm delete mode 100644 plugins/rainlab/notify/formwidgets/conditionbuilder/partials/_create_child_form.htm delete mode 100644 plugins/rainlab/notify/interfaces/Action.php delete mode 100644 plugins/rainlab/notify/interfaces/CompoundCondition.php delete mode 100644 plugins/rainlab/notify/interfaces/Condition.php delete mode 100644 plugins/rainlab/notify/interfaces/Event.php delete mode 100644 plugins/rainlab/notify/lang/en/lang.php delete mode 100644 plugins/rainlab/notify/lang/ro/lang.php delete mode 100644 plugins/rainlab/notify/lang/ru/lang.php delete mode 100644 plugins/rainlab/notify/lang/sl/lang.php delete mode 100644 plugins/rainlab/notify/lang/tr/lang.php delete mode 100644 plugins/rainlab/notify/lang/zh-tw/lang.php delete mode 100644 plugins/rainlab/notify/models/Notification.php delete mode 100644 plugins/rainlab/notify/models/NotificationRule.php delete mode 100644 plugins/rainlab/notify/models/RuleAction.php delete mode 100644 plugins/rainlab/notify/models/RuleCondition.php delete mode 100644 plugins/rainlab/notify/models/notificationrule/columns.yaml delete mode 100644 plugins/rainlab/notify/models/notificationrule/fields.yaml delete mode 100644 plugins/rainlab/notify/models/ruleaction/columns.yaml delete mode 100644 plugins/rainlab/notify/models/ruleaction/fields.yaml delete mode 100644 plugins/rainlab/notify/notifyrules/ExecutionContextCondition.php delete mode 100644 plugins/rainlab/notify/notifyrules/SaveDatabaseAction.php delete mode 100644 plugins/rainlab/notify/notifyrules/SendMailTemplateAction.php delete mode 100644 plugins/rainlab/notify/notifyrules/executioncontextcondition/fields.yaml delete mode 100644 plugins/rainlab/notify/notifyrules/savedatabaseaction/fields.yaml delete mode 100644 plugins/rainlab/notify/notifyrules/sendmailtemplateaction/fields.yaml delete mode 100644 plugins/rainlab/notify/updates/create_notification_rules_table.php delete mode 100644 plugins/rainlab/notify/updates/create_notifications_table.php delete mode 100644 plugins/rainlab/notify/updates/create_rule_actions_table.php delete mode 100644 plugins/rainlab/notify/updates/create_rule_conditions_table.php delete mode 100644 plugins/rainlab/notify/updates/version.yaml create mode 100644 plugins/rainlab/user/.gitignore delete mode 100644 plugins/rainlab/user/components/resetpassword/check.htm delete mode 100644 plugins/rainlab/user/controllers/users/config_filter.yaml create mode 100644 plugins/rainlab/user/lang/ar/lang.php create mode 100644 plugins/rainlab/user/lang/si/lang.php delete mode 100644 plugins/rainlab/user/lang/tm/lang.php create mode 100644 plugins/rainlab/user/models/user/scopes.yaml create mode 100644 plugins/rainlab/user/updates/users_add_additionals.php create mode 100644 plugins/rainlab/user/updates/users_add_sliders.php delete mode 100644 plugins/rainlab/user/vendor/autoload.php delete mode 100644 plugins/rainlab/user/vendor/composer/ClassLoader.php delete mode 100644 plugins/rainlab/user/vendor/composer/LICENSE delete mode 100644 plugins/rainlab/user/vendor/composer/autoload_classmap.php delete mode 100644 plugins/rainlab/user/vendor/composer/autoload_namespaces.php delete mode 100644 plugins/rainlab/user/vendor/composer/autoload_psr4.php delete mode 100644 plugins/rainlab/user/vendor/composer/autoload_real.php delete mode 100644 plugins/rainlab/user/vendor/composer/autoload_static.php delete mode 100644 plugins/rainlab/user/vendor/composer/installed.json delete mode 100644 plugins/rainlab/user/vendor/composer/installers/CHANGELOG.md delete mode 100644 plugins/rainlab/user/vendor/composer/installers/CONTRIBUTING.md delete mode 100644 plugins/rainlab/user/vendor/composer/installers/LICENSE delete mode 100644 plugins/rainlab/user/vendor/composer/installers/README.md delete mode 100644 plugins/rainlab/user/vendor/composer/installers/_config.yml delete mode 100644 plugins/rainlab/user/vendor/composer/installers/composer.json delete mode 100644 plugins/rainlab/user/vendor/composer/installers/phpstan.neon.dist delete mode 100644 plugins/rainlab/user/vendor/composer/installers/phpunit.xml.dist delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/AglInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/AimeosInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/AnnotateCmsInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/AsgardInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/AttogramInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/BaseInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/BitrixInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/BonefishInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/CakePHPInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/ChefInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/CiviCrmInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/ClanCatsFrameworkInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/CockpitInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/CodeIgniterInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/Concrete5Installer.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/CraftInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/CroogoInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/DecibelInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/DframeInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/DokuWikiInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/DolibarrInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/DrupalInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/ElggInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/EliasisInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/ExpressionEngineInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/EzPlatformInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/FuelInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/FuelphpInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/GravInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/HuradInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/ImageCMSInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/Installer.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/ItopInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/JoomlaInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/KanboardInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/KirbyInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/KnownInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/KodiCMSInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/KohanaInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/LanManagementSystemInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/LaravelInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/LavaLiteInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/LithiumInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/MODULEWorkInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/MODXEvoInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/MagentoInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/MajimaInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/MakoInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/MantisBTInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/MauticInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/MayaInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/MediaWikiInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/MiaoxingInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/MicroweberInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/ModxInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/MoodleInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/OctoberInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/OntoWikiInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/OsclassInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/OxidInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/PPIInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/PhiftyInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/PhpBBInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/PimcoreInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/PiwikInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/PlentymarketsInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/Plugin.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/PortoInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/PrestashopInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/ProcessWireInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/PuppetInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/PxcmsInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/RadPHPInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/ReIndexInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/Redaxo5Installer.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/RedaxoInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/RoundcubeInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/SMFInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/ShopwareInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/SilverStripeInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/SiteDirectInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/StarbugInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/SyDESInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/SyliusInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/Symfony1Installer.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/TYPO3CmsInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/TYPO3FlowInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/TaoInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/TastyIgniterInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/TheliaInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/TuskInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/UserFrostingInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/VanillaInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/VgmcpInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/WHMCSInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/WinterInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/WolfCMSInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/WordPressInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/YawikInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/ZendInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/Composer/Installers/ZikulaInstaller.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/src/bootstrap.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/tests/Composer/Installers/Test/AsgardInstallerTest.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/tests/Composer/Installers/Test/BitrixInstallerTest.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/tests/Composer/Installers/Test/CakePHPInstallerTest.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/tests/Composer/Installers/Test/CiviCrmInstallerTest.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/tests/Composer/Installers/Test/CraftInstallerTest.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/tests/Composer/Installers/Test/DokuWikiInstallerTest.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/tests/Composer/Installers/Test/GravInstallerTest.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/tests/Composer/Installers/Test/InstallerTest.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/tests/Composer/Installers/Test/MayaInstallerTest.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/tests/Composer/Installers/Test/MediaWikiInstallerTest.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/tests/Composer/Installers/Test/OctoberInstallerTest.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/tests/Composer/Installers/Test/OntoWikiInstallerTest.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/tests/Composer/Installers/Test/PimcoreInstallerTest.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/tests/Composer/Installers/Test/PiwikInstallerTest.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/tests/Composer/Installers/Test/PolyfillTestCase.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/tests/Composer/Installers/Test/ProcessWireInstallerTest.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/tests/Composer/Installers/Test/SiteDirectInstallerTest.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/tests/Composer/Installers/Test/SyDESInstallerTest.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/tests/Composer/Installers/Test/TastyIgniterInstallerTest.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/tests/Composer/Installers/Test/TestCase.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/tests/Composer/Installers/Test/VgmcpInstallerTest.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/tests/Composer/Installers/Test/WinterInstallerTest.php delete mode 100644 plugins/rainlab/user/vendor/composer/installers/tests/Composer/Installers/Test/YawikInstallerTest.php delete mode 100644 plugins/rainlab/user/views/mail/email_verification.htm delete mode 100644 plugins/rainlab/userplus/LICENCE.md delete mode 100644 plugins/rainlab/userplus/Plugin.php delete mode 100644 plugins/rainlab/userplus/README.md delete mode 100644 plugins/rainlab/userplus/assets/css/notifications.css delete mode 100644 plugins/rainlab/userplus/assets/js/notifications.js delete mode 100644 plugins/rainlab/userplus/assets/less/notifications.less delete mode 100644 plugins/rainlab/userplus/components/Notifications.php delete mode 100644 plugins/rainlab/userplus/components/notifications/default.htm delete mode 100644 plugins/rainlab/userplus/components/notifications/desktop.htm delete mode 100644 plugins/rainlab/userplus/components/notifications/mobile.htm delete mode 100644 plugins/rainlab/userplus/components/notifications/notifications-list.htm delete mode 100644 plugins/rainlab/userplus/composer.json delete mode 100644 plugins/rainlab/userplus/config/notify_presets.yaml delete mode 100644 plugins/rainlab/userplus/config/profile_fields.yaml delete mode 100644 plugins/rainlab/userplus/lang/cs/lang.php delete mode 100644 plugins/rainlab/userplus/lang/en/lang.php delete mode 100644 plugins/rainlab/userplus/lang/fa/lang.php delete mode 100644 plugins/rainlab/userplus/lang/fr/lang.php delete mode 100644 plugins/rainlab/userplus/lang/hu/lang.php delete mode 100644 plugins/rainlab/userplus/lang/pt-br/lang.php delete mode 100644 plugins/rainlab/userplus/lang/tr/lang.php delete mode 100644 plugins/rainlab/userplus/notifyrules/UserLocationAttributeCondition.php delete mode 100644 plugins/rainlab/userplus/notifyrules/userlocationattributecondition/attributes.yaml delete mode 100644 plugins/rainlab/userplus/updates/user_add_location_fields.php delete mode 100644 plugins/rainlab/userplus/updates/user_add_mobile_field.php delete mode 100644 plugins/rainlab/userplus/updates/user_add_profile_fields.php delete mode 100644 plugins/rainlab/userplus/updates/version.yaml delete mode 100644 plugins/rainlab/userplus/vendor/autoload.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/ClassLoader.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/LICENSE delete mode 100644 plugins/rainlab/userplus/vendor/composer/autoload_classmap.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/autoload_namespaces.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/autoload_psr4.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/autoload_real.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installed.json delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/CHANGELOG.md delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/CONTRIBUTING.md delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/LICENSE delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/README.md delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/composer.json delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/phpunit.xml.dist delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/AglInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/AimeosInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/AnnotateCmsInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/AsgardInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/AttogramInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/BaseInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/BitrixInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/BonefishInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/CakePHPInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/ChefInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/ClanCatsFrameworkInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/CockpitInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/CodeIgniterInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/Concrete5Installer.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/CraftInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/CroogoInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/DecibelInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/DokuWikiInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/DolibarrInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/DrupalInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/ElggInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/EliasisInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/ExpressionEngineInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/FuelInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/FuelphpInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/GravInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/HuradInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/ImageCMSInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/Installer.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/ItopInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/JoomlaInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/KanboardInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/KirbyInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/KodiCMSInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/KohanaInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/LaravelInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/LavaLiteInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/LithiumInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/MODULEWorkInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/MODXEvoInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/MagentoInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/MakoInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/MauticInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/MayaInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/MediaWikiInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/MicroweberInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/MoodleInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/OctoberInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/OntoWikiInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/OxidInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/PPIInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/PhiftyInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/PhpBBInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/PimcoreInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/PiwikInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/PlentymarketsInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/Plugin.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/PortoInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/PrestashopInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/PuppetInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/RadPHPInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/ReIndexInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/RedaxoInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/RoundcubeInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/SMFInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/ShopwareInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/SilverStripeInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/SyDESInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/Symfony1Installer.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/TYPO3CmsInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/TYPO3FlowInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/TheliaInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/TuskInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/VanillaInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/VgmcpInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/WHMCSInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/WolfCMSInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/WordPressInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/YawikInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/ZendInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/Composer/Installers/ZikulaInstaller.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/src/bootstrap.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/tests/Composer/Installers/Test/AsgardInstallerTest.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/tests/Composer/Installers/Test/BitrixInstallerTest.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/tests/Composer/Installers/Test/CakePHPInstallerTest.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/tests/Composer/Installers/Test/CraftInstallerTest.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/tests/Composer/Installers/Test/DokuWikiInstallerTest.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/tests/Composer/Installers/Test/GravInstallerTest.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/tests/Composer/Installers/Test/InstallerTest.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/tests/Composer/Installers/Test/MayaInstallerTest.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/tests/Composer/Installers/Test/MediaWikiInstallerTest.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/tests/Composer/Installers/Test/OctoberInstallerTest.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/tests/Composer/Installers/Test/OntoWikiInstallerTest.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/tests/Composer/Installers/Test/PimcoreInstallerTest.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/tests/Composer/Installers/Test/PiwikInstallerTest.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/tests/Composer/Installers/Test/SyDESInstallerTest.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/tests/Composer/Installers/Test/TestCase.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/tests/Composer/Installers/Test/VgmcpInstallerTest.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/tests/Composer/Installers/Test/YawikInstallerTest.php delete mode 100644 plugins/rainlab/userplus/vendor/composer/installers/tests/bootstrap.php create mode 100644 plugins/tps/birzha/controllers/UserSliders.php create mode 100644 plugins/tps/birzha/controllers/usersliders/_list_toolbar.htm create mode 100644 plugins/tps/birzha/controllers/usersliders/config_form.yaml create mode 100644 plugins/tps/birzha/controllers/usersliders/config_list.yaml create mode 100644 plugins/tps/birzha/controllers/usersliders/create.htm rename plugins/{rainlab/notify/controllers/notifications => tps/birzha/controllers/usersliders}/index.htm (96%) create mode 100644 plugins/tps/birzha/controllers/usersliders/preview.htm create mode 100644 plugins/tps/birzha/controllers/usersliders/update.htm create mode 100644 plugins/tps/birzha/models/UserSliders.php create mode 100644 plugins/tps/birzha/models/UsersCategory.php create mode 100644 plugins/tps/birzha/models/usersliders/columns.yaml create mode 100644 plugins/tps/birzha/models/usersliders/fields.yaml create mode 100644 plugins/tps/birzha/updates/builder_table_create_tps_birzha_user_sliders.php create mode 100644 plugins/tps/birzha/updates/builder_table_create_tps_birzha_users_categories.php create mode 100644 plugins/tps/birzha/updates/builder_table_update_tps_birzha_user_sliders.php create mode 100644 plugins/tps/birzha/updates/builder_table_update_tps_birzha_user_sliders_2.php create mode 100644 plugins/tps/birzha/updates/builder_table_update_tps_birzha_user_sliders_3.php create mode 100644 plugins/tps/birzha/updates/builder_table_update_tps_birzha_user_sliders_4.php create mode 100644 plugins/tps/birzha/updates/builder_table_update_tps_birzha_user_sliders_5.php create mode 100644 plugins/tps/birzha/updates/builder_table_update_tps_birzha_users_categories.php diff --git a/config/auth.php b/config/auth.php index 4c36b28..4931114 100644 --- a/config/auth.php +++ b/config/auth.php @@ -1,41 +1,6 @@ [ - /* - |-------------------------------------------------------------------------- - | Enable throttling of Backend authentication attempts - |-------------------------------------------------------------------------- - | - | If set to true, users will be given a limited number of attempts to sign - | in to the Backend before being blocked for a specified number of minutes. - | - */ - 'enabled' => true, - - /* - |-------------------------------------------------------------------------- - | Failed Authentication Attempt Limit - |-------------------------------------------------------------------------- - | - | Number of failed attempts allowed while trying to authenticate a user. - | - */ - 'attemptLimit' => 5, - - /* - |-------------------------------------------------------------------------- - | Suspension Time - |-------------------------------------------------------------------------- - | - | The number of minutes to suspend further attempts on authentication once - | the attempt limit is reached. - | - */ - 'suspensionTime' => 15, - ], -/* + /* |-------------------------------------------------------------------------- | Authentication Defaults |-------------------------------------------------------------------------- diff --git a/config/authBackup.php b/config/authBackup.php new file mode 100644 index 0000000..4c36b28 --- /dev/null +++ b/config/authBackup.php @@ -0,0 +1,126 @@ + [ + /* + |-------------------------------------------------------------------------- + | Enable throttling of Backend authentication attempts + |-------------------------------------------------------------------------- + | + | If set to true, users will be given a limited number of attempts to sign + | in to the Backend before being blocked for a specified number of minutes. + | + */ + 'enabled' => true, + + /* + |-------------------------------------------------------------------------- + | Failed Authentication Attempt Limit + |-------------------------------------------------------------------------- + | + | Number of failed attempts allowed while trying to authenticate a user. + | + */ + 'attemptLimit' => 5, + + /* + |-------------------------------------------------------------------------- + | Suspension Time + |-------------------------------------------------------------------------- + | + | The number of minutes to suspend further attempts on authentication once + | the attempt limit is reached. + | + */ + 'suspensionTime' => 15, + ], +/* + |-------------------------------------------------------------------------- + | Authentication Defaults + |-------------------------------------------------------------------------- + | + | This option controls the default authentication "guard" and password + | reset options for your application. You may change these defaults + | as required, but they're a perfect start for most applications. + | + */ + 'defaults' => [ + 'guard' => env('AUTH_DEFAULT_GUARD', 'web'), + 'passwords' => env('AUTH_DEFAULT_PASSWORDS', 'users'), + ], + /* + |-------------------------------------------------------------------------- + | Authentication Guards + |-------------------------------------------------------------------------- + | + | Next, you may define every authentication guard for your application. + | Of course, a great default configuration has been defined for you + | here which uses session storage and the Eloquent user provider. + | + | All authentication drivers have a user provider. This defines how the + | users are actually retrieved out of your database or other storage + | mechanisms used by this application to persist your user's data. + | + | Supported: "session", "token" + | + */ + 'guards' => [ + 'web' => [ + 'driver' => env('AUTH_GUARDS_WEB_DRIVER', 'session'), + 'provider' => env('AUTH_GUARDS_WEB_PROVIDER', 'users'), + ], + 'api' => [ + 'driver' => env('AUTH_GUARDS_API_DRIVER', 'token'), + 'provider' => env('AUTH_GUARDS_API_PROVIDER', 'users'), + ], + ], + /* + |-------------------------------------------------------------------------- + | User Providers + |-------------------------------------------------------------------------- + | + | All authentication drivers have a user provider. This defines how the + | users are actually retrieved out of your database or other storage + | mechanisms used by this application to persist your user's data. + | + | If you have multiple user tables or models you may configure multiple + | sources which represent each model / table. These sources may then + | be assigned to any extra authentication guards you have defined. + | + | Supported: "database", "eloquent" + | + */ + 'providers' => [ + 'users' => [ + 'driver' => env('AUTH_PROVIDERS_USERS_DRIVER', 'eloquent'), + 'model' => env('AUTH_PROVIDERS_USERS_MODEL', '\RainLab\User\Models\User'), + ], + ], + /* + |-------------------------------------------------------------------------- + | Resetting Passwords + |-------------------------------------------------------------------------- + | + | Here you may set the options for resetting passwords including the view + | that is your password reset e-mail. You may also set the name of the + | table that maintains all of the reset tokens for your application. + | + | You may specify multiple password reset configurations if you have more + | than one user table or model in the application and you want to have + | separate password reset settings based on the specific user types. + | + | The expire time is the number of minutes that the reset token should be + | considered valid. This security feature keeps tokens short-lived so + | they have less time to be guessed. You may change this as needed. + | + */ + 'passwords' => [ + 'users' => [ + 'provider' => env('AUTH_PASSWORDS_USERS_PROVIDER', 'users'), + 'email' => env('AUTH_PASSWORDS_USERS_EMAIL', 'auth.emails.password'), + 'table' => env('AUTH_PASSWORDS_USERS_TABLE', 'password_resets'), + 'expire' => env('AUTH_PASSWORDS_USERS_EXPIRE', 60), + ], + ], +]; diff --git a/plugins/rainlab/notify/LICENSE.md b/plugins/rainlab/notify/LICENSE.md deleted file mode 100644 index 38cee79..0000000 --- a/plugins/rainlab/notify/LICENSE.md +++ /dev/null @@ -1,19 +0,0 @@ -# MIT license - -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/plugins/rainlab/notify/Plugin.php b/plugins/rainlab/notify/Plugin.php deleted file mode 100644 index 6dd9cb4..0000000 --- a/plugins/rainlab/notify/Plugin.php +++ /dev/null @@ -1,69 +0,0 @@ - 'rainlab.notify::lang.plugin.name', - 'description' => 'rainlab.notify::lang.plugin.description', - 'author' => 'Alexey Bobkov, Samuel Georges', - 'icon' => 'icon-bullhorn' - ]; - } - - public function registerSettings() - { - return [ - 'notifications' => [ - 'label' => 'rainlab.notify::lang.notifications.menu_label', - 'description' => 'rainlab.notify::lang.notifications.menu_description', - 'category' => SettingsManager::CATEGORY_NOTIFICATIONS, - 'icon' => 'icon-bullhorn', - 'url' => Backend::url('rainlab/notify/notifications'), - 'permissions' => ['rainlab.notify.manage_notifications'], - 'order' => 600 - ], - ]; - } - - public function registerNotificationRules() - { - return [ - 'groups' => [], - 'events' => [ - - ], - 'actions' => [ - \RainLab\Notify\NotifyRules\SaveDatabaseAction::class, - \RainLab\Notify\NotifyRules\SendMailTemplateAction::class, - ], - 'conditions' => [ - \RainLab\Notify\NotifyRules\ExecutionContextCondition::class, - ], - ]; - } - - public function registerPermissions() - { - return [ - 'rainlab.notify.manage_notifications' => [ - 'tab' => SettingsManager::CATEGORY_NOTIFICATIONS, - 'label' => 'rainlab.notify::lang.permissions.manage_notifications' - ], - ]; - } -} diff --git a/plugins/rainlab/notify/README.md b/plugins/rainlab/notify/README.md deleted file mode 100644 index d1edf67..0000000 --- a/plugins/rainlab/notify/README.md +++ /dev/null @@ -1,400 +0,0 @@ -# Notification engine - -**Plugin is currently in Beta status. Proceed with caution.** - -Adds support for sending notifications across a variety of different channels, including mail, SMS and Slack. - -Notifications are managed in the back-end area by navigating to *Settings > Notification rules*. - -## Notification workflow - -When a notification fires, it uses the following workflow: - -1. Plugin registers associated actions, conditions and events using `registerNotificationRules` -1. A notification class is bound to a system event using `Notifier::bindEvent` -1. A system event is fired `Event::fire` -1. The parameters of the event are captured, along with any global context parameters -1. A command is pushed on the queue to process the notification `Queue::push` -1. The command finds all notification rules using the notification class and triggers them -1. The notification conditions are checked and only proceed if met -1. The notification actions are triggered - -Here is an example of a plugin registering notification rules. The `groups` definition will create containers that are used to better organise events. The `presets` definition specifies notification rules defined by the system. - -```php -public function registerNotificationRules() -{ - return [ - 'events' => [ - \RainLab\User\NotifyRules\UserActivatedEvent::class, - ], - 'actions' => [ - \RainLab\User\NotifyRules\SaveToDatabaseAction::class, - ], - 'conditions' => [ - \RainLab\User\NotifyRules\UserAttributeCondition::class - ], - 'groups' => [ - 'user' => [ - 'label' => 'User', - 'icon' => 'icon-user' - ], - ], - 'presets' => '$/rainlab/user/config/notify_presets.yaml', - ]; -} -``` - -Here is an example of triggering a notification. The system event `rainlab.user.activate` is bound to the `UserActivatedEvent` class. - -```php -// Bind to a system event -\RainLab\Notify\Classes\Notifier::bindEvents([ - 'rainlab.user.activate' => \RainLab\User\NotifyRules\UserActivatedEvent::class -]); - -// Fire the system event -Event::fire('rainlab.user.activate', [$this]); -``` - -Here is an example of registering context parameters, which are available globally to all notifications. - -```php -\RainLab\Notify\Classes\Notifier::instance()->registerCallback(function($manager) { - $manager->registerGlobalParams([ - 'user' => Auth::getUser() - ]); -}); -``` - -Here is an example of an event preset: - -```yaml -# =================================== -# Event Presets -# =================================== - -welcome_email: - name: Send welcome email to user - event: RainLab\User\NotifyRules\UserRegisteredEvent - items: - - action: RainLab\Notify\NotifyRules\SendMailTemplateAction - mail_template: rainlab.user::mail.welcome - send_to_mode: user - conditions: - - condition: RainLab\Notify\NotifyRules\ExecutionContextCondition - subcondition: environment - operator: is - value: dev - condition_text: Application environment is dev -``` - -## Creating Event classes - -An event class is responsible for preparing the parameters passed to the conditions and actions. The static method `makeParamsFromEvent` will take the arguments provided by the system event and convert them in to parameters. - -```php -class UserActivatedEvent extends \RainLab\Notify\Classes\EventBase -{ - /** - * @var array Local conditions supported by this event. - */ - public $conditions = [ - \RainLab\User\NotifyRules\UserAttributeCondition::class - ]; - - /** - * Returns information about this event, including name and description. - */ - public function eventDetails() - { - return [ - 'name' => 'Activated', - 'description' => 'A user is activated', - 'group' => 'user' - ]; - } - - /** - * Defines the usable parameters provided by this class. - */ - public function defineParams() - { - return [ - 'name' => [ - 'title' => 'Name', - 'label' => 'Name of the user', - ], - // ... - ]; - } - - public static function makeParamsFromEvent(array $args, $eventName = null) - { - return [ - 'user' => array_get($args, 0) - ]; - } -} -``` - -## Creating Action classes - -Action classes define the final step in a notification and subsequently perform the notification itself. Some examples might be sending and email or writing to the database. - -```php -class SendMailTemplateAction extends \RainLab\Notify\Classes\ActionBase -{ - /** - * Returns information about this event, including name and description. - */ - public function actionDetails() - { - return [ - 'name' => 'Compose a mail message', - 'description' => 'Send a message to a recipient', - 'icon' => 'icon-envelope' - ]; - } - - /** - * Field configuration for the action. - */ - public function defineFormFields() - { - return 'fields.yaml'; - } - - public function getText() - { - $template = $this->host->template_name; - - return 'Send a message using '.$template; - } - - /** - * Triggers this action. - * @param array $params - * @return void - */ - public function triggerAction($params) - { - $email = 'test@email.tld'; - $template = $this->host->template_name; - - Mail::sendTo($email, $template, $params); - } -} -``` - -A form fields definition file is used to provide form fields when the action is established. These values are accessed from condition using the host model via the `$this->host` property. - -```yaml -# =================================== -# Field Definitions -# =================================== - -fields: - - template_name: - label: Template name - type: text -``` - -An action may choose to provide no form fields by simply returning false from the `defineFormFields` method. - -```php -public function defineFormFields() -{ - return false; -} -``` - -## Creating Condition classes - -A condition class should specify how it should appear in the user interface, providing a name, title and summary text. It also must declare an `isTrue` method for evaluating whether the condition is true or not. - -```php -class MyCondition extends \RainLab\Notify\Classes\ConditionBase -{ - /** - * Return either ConditionBase::TYPE_ANY or ConditionBase::TYPE_LOCAL - */ - public function getConditionType() - { - // If the condition should appear for all events - return ConditionBase::TYPE_ANY; - - // If the condition should appear only for some events - return ConditionBase::TYPE_LOCAL; - } - - /** - * Field configuration for the condition. - */ - public function defineFormFields() - { - return 'fields.yaml'; - } - - public function getName() - { - return 'My condition is checked'; - } - - public function getTitle() - { - return 'My condition'; - } - - public function getText() - { - $value = $this->host->mycondition; - - return 'My condition is '.$value; - } - - /** - * Checks whether the condition is TRUE for specified parameters - * @param array $params - * @return bool - */ - public function isTrue(&$params) - { - return true; - } -} -``` - -A form fields definition file is used to provide form fields when the condition is established. These values are accessed from condition using the host model via the `$this->host` property. - -```yaml -# =================================== -# Field Definitions -# =================================== - -fields: - - mycondition: - label: My condition - type: dropdown - options: - true: True - false: False -``` - -## Model attribute condition classes - -Model attribute conditions are designed specially for applying conditions to sets of model attributes. - -```php -class UserAttributeCondition extends \RainLab\Notify\Classes\ModelAttributesConditionBase -{ - protected $modelClass = \RainLab\User\Models\User::class; - - public function getGroupingTitle() - { - return 'User attribute'; - } - - public function getTitle() - { - return 'User attribute'; - } - - /** - * Checks whether the condition is TRUE for specified parameters - * @param array $params Specifies a list of parameters as an associative array. - * @return bool - */ - public function isTrue(&$params) - { - $hostObj = $this->host; - - $attribute = $hostObj->subcondition; - - if (!$user = array_get($params, 'user')) { - throw new ApplicationException('Error evaluating the user attribute condition: the user object is not found in the condition parameters.'); - } - - return parent::evalIsTrue($user); - } -} -``` - -An attributes definition file is used to specify which attributes should be included in the condition. - -```yaml -# =================================== -# Condition Attribute Definitions -# =================================== - -attributes: - - name: - label: Name - - email: - label: Email address - - country: - label: Country - type: relation - relation: - model: RainLab\Location\Models\Country - label: Name - nameFrom: name - keyFrom: id -``` - -## Save to database action - -There is a dedicated table in the database for storing events and their parameters. This table is accessed using the `RainLab\Notify\Models\Notification` model and can be referenced as a relation from your own models. In this example the `MyProject` model contains its own notification channel called `notifications`. - -```php -class MyProject extends Model -{ - // ... - - public $morphMany = [ - 'my_notifications' => [ - \RainLab\Notify\Models\Notification::class, - 'name' => 'notifiable' - ] - ]; -} -``` - -This channel should be registered with the `RainLab\Notify\NotifyRules\SaveDatabaseAction` so it appears as a related object when selecting the action. - -```php -SaveDatabaseAction::extend(function ($action) { - $action->addTableDefinition([ - 'label' => 'Project activity', - 'class' => MyProject::class, - 'relation' => 'my_notifications', - 'param' => 'project' - ]); -}); -``` - -The **label** is shown as the related object, the **class** references the model class, the **relation** refers to the relation name. The **param** defines the parameter name, passed to the triggering event. - -So essentially if you pass a `project` to the event parameters, or if `project` is a global parameter, a notification model is created with the parameters stored in the `data` attribute. Equivalent to the following code: - -```php -$myproject->my_notifications()->create([ - // ... - 'data' => $params -]); -``` - -## Dynamically adding conditions to events - -Events can be extended to include new local conditions. Simply add the condition class to the event `$conditions` array property. - -```php -UserActivatedEvent::extend(function($event) { - $event->conditions[] = \RainLab\UserPlus\NotifyRules\UserLocationAttributeCondition::class; -}); -``` diff --git a/plugins/rainlab/notify/classes/ActionBase.php b/plugins/rainlab/notify/classes/ActionBase.php deleted file mode 100644 index 20bec44..0000000 --- a/plugins/rainlab/notify/classes/ActionBase.php +++ /dev/null @@ -1,168 +0,0 @@ - 'Action', - 'description' => 'Action description', - 'icon' => 'icon-dot-circle-o' - ]; - } - - public function __construct($host = null) - { - /* - * Paths - */ - $this->viewPath = $this->configPath = $this->guessConfigPathFrom($this); - - /* - * Parse the config, if available - */ - if ($formFields = $this->defineFormFields()) { - $this->fieldConfig = $this->makeConfig($formFields); - } - - if (!$this->host = $host) { - return; - } - - $this->boot($host); - } - - /** - * Boot method called when the condition class is first loaded - * with an existing model. - * @return array - */ - public function boot($host) - { - // Set default data - if (!$host->exists) { - $this->initConfigData($host); - } - - // Apply validation rules - $host->rules = array_merge($host->rules, $this->defineValidationRules()); - } - - public function triggerAction($params) - { - } - - public function getTitle() - { - return $this->getActionName(); - } - - public function getText() - { - return $this->getActionDescription(); - } - - public function getActionName() - { - return array_get($this->actionDetails(), 'name'); - } - - public function getActionDescription() - { - return array_get($this->actionDetails(), 'description'); - } - - public function getActionIcon() - { - return array_get($this->actionDetails(), 'icon', 'icon-dot-circle-o'); - } - - /** - * Extra field configuration for the condition. - */ - public function defineFormFields() - { - return 'fields.yaml'; - } - - /** - * Determines if this action uses form fields. - * @return bool - */ - public function hasFieldConfig() - { - return !!$this->fieldConfig; - } - - /** - * Returns the field configuration used by this model. - */ - public function getFieldConfig() - { - return $this->fieldConfig; - } - - /** - * Initializes configuration data when the condition is first created. - * @param Model $host - */ - public function initConfigData($host) {} - - /** - * Defines validation rules for the custom fields. - * @return array - */ - public function defineValidationRules() - { - return []; - } - - /** - * Spins over types registered in plugin base class with `registerNotificationRules`. - * @return array - */ - public static function findActions() - { - $results = []; - $bundles = PluginManager::instance()->getRegistrationMethodValues('registerNotificationRules'); - - foreach ($bundles as $plugin => $bundle) { - foreach ((array) array_get($bundle, 'actions', []) as $conditionClass) { - if (!class_exists($conditionClass)) { - continue; - } - - $obj = new $conditionClass; - $results[$conditionClass] = $obj; - } - } - - return $results; - } -} diff --git a/plugins/rainlab/notify/classes/CompoundCondition.php b/plugins/rainlab/notify/classes/CompoundCondition.php deleted file mode 100644 index a0d5635..0000000 --- a/plugins/rainlab/notify/classes/CompoundCondition.php +++ /dev/null @@ -1,169 +0,0 @@ -host->condition_type == 0 - ? 'ALL of subconditions should be ' - : 'ANY of subconditions should be '; - - $result .= $this->host->condition == 'false' ? 'FALSE' : 'TRUE'; - - return $result; - } - - /** - * Returns the text to use when joining two rules within. - * @return string - */ - public function getJoinText() - { - return $this->host->condition_type == 0 ? 'AND' : 'OR'; - } - - /** - * Returns a list of condition types (`ConditionBase::TYPE_*` constants) - * that can be added to this compound condition - */ - public function getAllowedSubtypes() - { - return []; - } - - public function defineFormFields() - { - return 'fields.yaml'; - } - - public function initConfigData($host) - { - $host->condition_type = 0; - $host->condition = 'true'; - } - - public function getConditionOptions() - { - $options = [ - 'true' => 'TRUE', - 'false' => 'FALSE' - ]; - - return $options; - } - - public function getConditionTypeOptions() - { - $options = [ - '0' => 'ALL subconditions should meet the requirement', - '1' => 'ANY subconditions should meet the requirement' - ]; - - return $options; - } - - public function getChildOptions(array $options) - { - extract(array_merge([ - 'extraRules' => [], - ], $options)); - - $result = [ - 'Compound condition' => CompoundCondition::class - ]; - - $classes = $extraRules + self::findConditionsByType(ConditionBase::TYPE_ANY); - - $result = $this->addClassesSubconditions($classes, $result); - - return $result; - } - - protected function addClassesSubconditions($classes, $list) - { - foreach ($classes as $conditionClass => $obj) { - - $subConditions = $obj->listSubconditions(); - - if ($subConditions) { - $groupName = $obj->getGroupingTitle(); - - foreach ($subConditions as $name => $subcondition) { - if (!$groupName) { - $list[$name] = $conditionClass.':'.$subcondition; - } - else { - if (!array_key_exists($groupName, $list)) { - $list[$groupName] = []; - } - - $list[$groupName][$name] = $conditionClass.':'.$subcondition; - } - } - } - else { - $list[$obj->getName()] = $conditionClass; - } - } - - return $list; - } - - /** - * Checks whether the condition is TRUE for specified parameters. - * - * @param array $params - * @return bool - */ - public function isTrue(&$params) - { - $hostObj = $this->host; - - $requiredConditionValue = $hostObj->condition == 'true' ? true : false; - - foreach ($hostObj->children as $subcondition) { - $subconditionResult = $subcondition->getConditionObject()->isTrue($params) ? true : false; - - /* - * All - */ - if ($hostObj->condition_type == 0) { - if ($subconditionResult !== $requiredConditionValue) { - return false; - } - - } - /* - * Any - */ - else { - if ($subconditionResult === $requiredConditionValue) { - return true; - } - } - } - - /* - * All - */ - if ($hostObj->condition_type == 0) { - return true; - } - - return false; - } -} diff --git a/plugins/rainlab/notify/classes/ConditionBase.php b/plugins/rainlab/notify/classes/ConditionBase.php deleted file mode 100644 index c583fc1..0000000 --- a/plugins/rainlab/notify/classes/ConditionBase.php +++ /dev/null @@ -1,211 +0,0 @@ -viewPath = $this->configPath = $this->guessConfigPathFrom($this); - - /* - * Parse the config - */ - $this->fieldConfig = $this->makeConfig($this->defineFormFields()); - - if (!$this->host = $host) { - return; - } - - $this->boot($host); - } - - /** - * Boot method called when the condition class is first loaded - * with an existing model. - * @return array - */ - public function boot($host) - { - // Set default data - if (!$host->exists) { - $this->initConfigData($host); - } - - // Apply validation rules - $host->rules = array_merge($host->rules, $this->defineValidationRules()); - - // Inject view paths to the controller through the Form widget - $host->bindEvent('model.form.filterFields', function($form) { - $form->getController()->addViewPath($this->getViewPaths()); - }); - } - - /** - * Extra field configuration for the condition. - */ - public function defineFormFields() - { - return 'fields.yaml'; - } - - /** - * Initializes configuration data when the condition is first created. - * @param Model $host - */ - public function initConfigData($host) {} - - /** - * Defines validation rules for the custom fields. - * @return array - */ - public function defineValidationRules() - { - return []; - } - - public function getText() - { - return 'Condition text'; - } - - /** - * Returns a condition name for displaying in the condition selection drop-down menu - */ - public function getName() - { - return 'Condition'; - } - - /** - * Returns a condition title for displaying in the condition settings form - */ - public function getTitle() - { - return 'Condition'; - } - - /** - * This function should return one of the `ConditionBase::TYPE_*` constants - * depending on a place where the condition is valid - */ - public function getConditionType() - { - return ConditionBase::TYPE_ANY; - } - - public function listSubconditions() - { - return []; - } - - /** - * Returns a title to use for grouping subconditions - * in the Create Condition drop-down menu - */ - public function getGroupingTitle() - { - return null; - } - - /** - * Returns the field configuration used by this model. - */ - public function getFieldConfig() - { - return $this->fieldConfig; - } - - /** - * Spins over types registered in plugin base class with `registerNotificationRules`, - * checks if the condition type matches and adds it to an array that is returned. - * - * @param string $type Use `self::TYPE_*` constants - * @return array - */ - public static function findConditionsByType($type) - { - $results = []; - $bundles = PluginManager::instance()->getRegistrationMethodValues(static::$registrationMethod); - - foreach ($bundles as $plugin => $bundle) { - foreach ((array) array_get($bundle, 'conditions', []) as $conditionClass) { - if (!class_exists($conditionClass)) { - continue; - } - - $obj = new $conditionClass; - if ($obj->getConditionType() != $type) { - continue; - } - - $results[$conditionClass] = $obj; - } - } - - return $results; - } - - public function setFormFields($fields) - { - - } - - public function setCustomData() - { - } - - public function onPreRender($controller, $widget) - { - } - - /** - * Checks whether the condition is TRUE for specified parameters - * @param array $params - * @return bool - */ - public function isTrue(&$params) - { - return false; - } - - public function getChildOptions(array $options) - { - return []; - } -} diff --git a/plugins/rainlab/notify/classes/EventBase.php b/plugins/rainlab/notify/classes/EventBase.php deleted file mode 100644 index 1283a11..0000000 --- a/plugins/rainlab/notify/classes/EventBase.php +++ /dev/null @@ -1,237 +0,0 @@ - 'Event', - 'description' => 'Event description', - 'group' => 'groupcode' - ]; - } - - public function __construct($host = null) - { - $this->host = $host; - } - - /** - * Defines the parameters used by this class. - * This method should be used as an override in the extended class. - */ - public function defineParams() - { - return []; - } - - /** - * Local conditions supported by this event. - */ - public function defineConditions() - { - return $this->conditions; - } - - /** - * Sets multiple params. - * @param array $params - * @return void - */ - public function setParams($params) - { - $this->params = $params; - } - - /** - * Returns all params. - * @return array - */ - public function getParams() - { - return $this->params; - } - - /** - * Generates event parameters based on arguments from the triggering system event. - * @param array $args - * @param string $eventName - * @return void - */ - public static function makeParamsFromEvent(array $args, $eventName = null) - { - } - - public function getEventName() - { - return Lang::get(array_get($this->eventDetails(), 'name')); - } - - public function getEventDescription() - { - return Lang::get(array_get($this->eventDetails(), 'description')); - } - - public function getEventGroup() - { - return array_get($this->eventDetails(), 'group'); - } - - /** - * Resolves an event or action identifier from a class name or object. - * @param mixed Class name or object - * @return string Identifier in format of vendor-plugin-class - */ - public function getEventIdentifier() - { - $namespace = Str::normalizeClassName(get_called_class()); - if (strpos($namespace, '\\') === null) { - return $namespace; - } - - $parts = explode('\\', $namespace); - $class = array_pop($parts); - $slice = array_slice($parts, 1, 2); - $code = strtolower(implode('-', $slice) . '-' . $class); - - return $code; - } - - /** - * Spins over types registered in plugin base class with `registerNotificationRules`. - * @return array - */ - public static function findEvents() - { - $results = []; - $bundles = PluginManager::instance()->getRegistrationMethodValues('registerNotificationRules'); - - foreach ($bundles as $plugin => $bundle) { - foreach ((array) array_get($bundle, 'events', []) as $conditionClass) { - if (!class_exists($conditionClass)) { - continue; - } - - $obj = new $conditionClass; - $results[$conditionClass] = $obj; - } - } - - return $results; - } - - public static function findEventGroups() - { - $results = []; - $bundles = PluginManager::instance()->getRegistrationMethodValues('registerNotificationRules'); - - foreach ($bundles as $plugin => $bundle) { - if ($groups = array_get($bundle, 'groups')) { - $results += $groups; - } - } - - return $results; - } - - public static function findEventsByGroup($group) - { - $results = []; - - foreach (self::findEvents() as $conditionClass => $obj) { - if ($obj->getEventGroup() != $group) { - continue; - } - - $results[$conditionClass] = $obj; - } - - return $results; - } - - public static function findEventByIdentifier($identifier) - { - foreach (self::findEvents() as $class => $obj) { - if ($obj->getEventIdentifier() == $identifier) { - return $obj; - } - } - } - - /** - * Spins over preset registered in plugin base class with `registerNotificationRules`. - * @return array - */ - public static function findEventPresets() - { - $results = []; - $bundles = PluginManager::instance()->getRegistrationMethodValues('registerNotificationRules'); - - foreach ($bundles as $plugin => $bundle) { - if (!$presets = array_get($bundle, 'presets')) { - continue; - } - - if (!is_array($presets)) { - $presets = Yaml::parse(File::get(File::symbolizePath($presets))); - } - - if ($presets && is_array($presets)) { - $results += $presets; - } - } - - return $results; - } - - public static function findEventPresetsByClass($className) - { - $results = []; - - foreach (self::findEventPresets() as $code => $definition) { - if (!$eventClass = array_get($definition, 'event')) { - continue; - } - - if ($eventClass != $className) { - continue; - } - - $results[$code] = $definition; - } - - return $results; - } -} diff --git a/plugins/rainlab/notify/classes/EventParams.php b/plugins/rainlab/notify/classes/EventParams.php deleted file mode 100644 index cf17577..0000000 --- a/plugins/rainlab/notify/classes/EventParams.php +++ /dev/null @@ -1,59 +0,0 @@ -eventClass = $eventClass; - - $this->params = $this->serializeParams($params); - } - - /** - * Execute the job. - * - * @return void - */ - public function handle() - { - $this->delete(); - - Notifier::instance()->fireEvent($this->eventClass, $this->unserializeParams()); - } - - protected function serializeParams($params) - { - $result = []; - - foreach ($params as $param => $value) { - $result[$param] = $this->getSerializedPropertyValue($value); - } - - return $result; - } - - protected function unserializeParams() - { - $result = []; - - foreach ($this->params as $param => $value) { - $result[$param] = $this->getRestoredPropertyValue($value); - } - - return $result; - } -} diff --git a/plugins/rainlab/notify/classes/ModelAttributesConditionBase.php b/plugins/rainlab/notify/classes/ModelAttributesConditionBase.php deleted file mode 100644 index bfbf374..0000000 --- a/plugins/rainlab/notify/classes/ModelAttributesConditionBase.php +++ /dev/null @@ -1,731 +0,0 @@ - 'is', - 'is_not' => 'is not', - 'equals_or_greater' => 'equals or greater than', - 'equals_or_less' => 'equals or less than', - 'contains' => 'contains', - 'does_not_contain' => 'does not contain', - 'greater' => 'greater than', - 'less' => 'less than', - 'one_of' => 'is one of', - 'not_one_of' => 'is not one of' - ]; - - protected $modelObj = null; - protected $referenceInfo = null; - protected $modelAttributes = null; - - protected static $modelObjCache = []; - protected static $attributeControlTypeCache = []; - - public function __construct($host = null) - { - parent::__construct($host); - - /* - * This is used as a base class, so register view path from here too - */ - $this->addViewPath($this->guessViewPathFrom(__CLASS__)); - } - - public function initConfigData($host) - { - $host->operator = 'is'; - } - - public function setCustomData() - { - $this->host->condition_control_type = $this->evalControlType(); - } - - // - // Definitions - // - - /** - * This function should return one of the `ConditionBase::TYPE_*` constants - * depending on a place where the condition is valid - */ - public function getConditionType() - { - return ConditionBase::TYPE_LOCAL; - } - - public function defineModelAttributes($type = null) - { - return 'attributes.yaml'; - } - - public function defineValidationRules() - { - return [ - 'value' => 'required' - ]; - } - - public function defineFormFields() - { - return plugins_path('rainlab/notify/classes/modelattributesconditionbase/fields.yaml'); - } - - // - // Text helpers - // - - public function getText() - { - $host = $this->host; - $attributes = $this->listModelAttributes(); - - if (isset($attributes[$host->subcondition])) { - $result = $this->getConditionTextPrefix($host, $attributes); - } - else { - $result = 'Unknown attribute'; - } - - $result .= ' '.array_get($this->operators, $host->operator, $host->operator).' '; - - $controlType = $this->getValueControlType(); - - if ($controlType == 'text') { - $result .= $host->value; - } - else { - $textValue = $this->getCustomTextValue(); - if ($textValue !== false) { - return $result.' '.$textValue; - } - - $referenceInfo = $this->prepareReferenceListInfo(); - $modelObj = $referenceInfo->referenceModel; - - if (!count($referenceInfo->columns)) { - return $result; - } - - if (!strlen($host->value)) { - return $result .= '?'; - } - - $visibleField = $referenceInfo->primaryColumn; - - if ($controlType == 'dropdown') { - $obj = $modelObj->where('id', $host->value)->first(); - if ($obj) { - $result .= e($obj->{$visibleField}); - } - } - else { - $ids = explode(',', $host->value); - foreach ($ids as &$id) { - $id = trim(e($id)); - } - - $records = $modelObj - ->whereIn('id', $ids) - ->orderBy($visibleField) - ->get(); - - $recordNames = []; - foreach ($records as $record) { - $recordNames[] = $record->{$visibleField}; - } - - $result .= '('.implode(', ', $recordNames).')'; - } - } - - return $result; - } - - protected function getConditionTextPrefix($parametersHost, $attributes) - { - return $attributes[$parametersHost->subcondition]; - } - - public function getCustomTextValue() - { - return false; - } - - // - // Options - // - - public function getSubconditionOptions() - { - return $this->listModelAttributes(); - } - - public function getOperatorOptions() - { - $hostObj = $this->host; - $options = []; - $attribute = $hostObj->subcondition; - - $currentOperatorValue = $hostObj->operator; - - $model = $this->getModelObj(); - $definitions = $this->listModelAttributeInfo(); - - if (!isset($definitions[$attribute])) { - $options = ['none' => 'Unknown attribute selected']; - } - else { - $columnType = array_get($definitions[$attribute], 'type'); - - if ($columnType != ConditionBase::CAST_RELATION) { - if ($columnType == ConditionBase::CAST_STRING) { - $options = [ - 'is' => 'is', - 'is_not' => 'is not', - 'contains' => 'contains', - 'does_not_contain' => 'does not contain' - ]; - } - else { - $options = [ - 'is' => 'is', - 'is_not' => 'is not', - 'equals_or_greater' => 'equals or greater than', - 'equals_or_less' => 'equals or less than', - 'greater' => 'greater than', - 'less' => 'less than' - ]; - } - } - else { - $options = [ - 'is' => 'is', - 'is_not' => 'is not', - 'one_of' => 'is one of', - 'not_one_of' => 'is not one of' - ]; - } - } - - if (!array_key_exists($currentOperatorValue, $options)) { - $keys = array_keys($options); - if (count($keys)) { - $hostObj->operator = $options[$keys[0]]; - } - else { - $hostObj->operator = null; - } - } - - return $options; - } - - public function getValueDropdownOptions() - { - $hostObj = $this->host; - $attribute = $hostObj->subcondition; - $definitions = $this->listModelAttributeInfo(); - - if (!isset($definitions[$attribute])) { - return []; - } - - $columnType = array_get($definitions[$attribute], 'type'); - - if ($columnType != ConditionBase::CAST_RELATION) { - return []; - } - - $referenceInfo = $this->prepareReferenceListInfo(); - $referenceModel = $referenceInfo->referenceModel; - $nameFrom = $referenceInfo->primaryColumn; - $keyFrom = $referenceInfo->primaryKey; - - // Determine if the model uses a tree trait - $treeTraits = ['October\Rain\Database\Traits\NestedTree', 'October\Rain\Database\Traits\SimpleTree']; - $usesTree = count(array_intersect($treeTraits, class_uses($referenceModel))) > 0; - - $results = $referenceModel->get(); - - return $usesTree - ? $results->listsNested($nameFrom, $keyFrom) - : $results->lists($nameFrom, $keyFrom); - } - - // - // Control type - // - - protected function evalControlType() - { - $hostObj = $this->host; - $attribute = $hostObj->subcondition; - $operator = $hostObj->operator; - - $definitions = $this->listModelAttributeInfo(); - - if (!isset($definitions[$attribute])) { - return 'text'; - } - - $columnType = array_get($definitions[$attribute], 'type'); - - if ($columnType != ConditionBase::CAST_RELATION) { - return 'text'; - } - else { - if ($operator == 'is' || $operator == 'is_not') { - return 'dropdown'; - } - - return 'multi_value'; - } - } - - public function getValueControlType() - { - if (App::runningInBackend()) { - return $this->evalControlType(); - } - - $hostObj = $this->host; - - if ($controlType = $hostObj->condition_control_type) { - return $controlType; - } - - $controlType = $this->evalControlType(); - - $this->getModelObj() - ->where('id', $host->id) - ->update(['condition_control_type' => $controlType]); - - return $hostObj->condition_control_type = $controlType; - } - - // - // Attributes - // - - public function listSubconditions() - { - $attributes = $this->listModelAttributes(); - - $result = []; - - foreach ($attributes as $name => $code) { - $result[$code] = $name; - } - - return $result; - } - - /** - * Returns the supported attributes by a condition as an array. - * The key is the attribute and the value is the label. - * - * @return array - */ - protected function listModelAttributes() - { - $attributeInfo = $this->listModelAttributeInfo(); - - foreach ($attributeInfo as $attribute => $info) { - $attributes[$attribute] = array_get($info, 'label'); - } - - asort($attributes); - - return $attributes; - } - - protected function listModelAttributeInfo() - { - if ($this->modelAttributes) { - return $this->modelAttributes; - } - - $config = $this->makeConfig($this->defineModelAttributes($this->getConditionType())); - - $attributes = $config->attributes ?? []; - - /* - * Set defaults - */ - foreach ($attributes as $attribute => $info) { - if (!isset($info['type'])) { - $attributes[$attribute]['type'] = 'string'; - } - } - - return $this->modelAttributes = $attributes; - } - - // - // Relation based attributes - // - - public function getReferencePrimaryColumn($record) - { - $referenceInfo = $this->prepareReferenceListInfo(); - - return $record->{$referenceInfo->primaryColumn}; - } - - public function listSelectedReferenceRecords() - { - $referenceInfo = $this->prepareReferenceListInfo(); - $model = $referenceInfo->referenceModel; - - $value = $this->host->value; - $keys = strlen($value) ? explode(',', $value) : []; - - if (count($keys)) { - $model = $model->whereIn('id', $keys); - } - else { - $model = $model->whereRaw('id <> id'); - } - - $orderField = $referenceInfo->primaryColumn; - - return $model->orderBy($orderField)->get(); - } - - public function prepareReferenceListInfo() - { - if (!is_null($this->referenceInfo)) { - return $this->referenceInfo; - } - - $model = $this->getModelObj(); - $attribute = $this->host->subcondition; - $definitions = $this->listModelAttributeInfo(); - $definition = array_get($definitions, $attribute); - - $columns = array_get($definition, 'columns'); - $primaryColumn = array_get($definition, 'relation.nameFrom', 'name'); - - if ($model->hasRelation($attribute)) { - $relationType = $model->getRelationType($attribute); - $relationModel = $model->makeRelation($attribute); - $relationObject = $model->{$attribute}(); - - // Some simpler relations can specify a custom local or foreign "other" key, - // which can be detected and implemented here automagically. - $primaryKey = in_array($relationType, ['hasMany', 'belongsTo', 'hasOne']) - ? $relationObject->getOtherKey() - : $relationModel->getKeyName(); - } - elseif ($relationClass = array_get($definition, 'relation.model')) { - $relationModel = new $relationClass; - $primaryKey = array_get($definition, 'relation.keyFrom', 'id'); - } - else { - throw new SystemException(sprintf('Model %s does not contain a relation "%s"', get_class($model), $attribute)); - } - - if (!$columns) { - $columns = [ - $primaryColumn => [ - 'label' => array_get($definition, 'relation.label', '?'), - 'searchable' => true - ] - ]; - } - - $this->referenceInfo = []; - $this->referenceInfo['referenceModel'] = $relationModel; - $this->referenceInfo['primaryKey'] = $primaryKey; - $this->referenceInfo['primaryColumn'] = $primaryColumn; - $this->referenceInfo['columns'] = $columns; - - return $this->referenceInfo = (object) $this->referenceInfo; - } - - public function onPreRender($controller, $widget) - { - $controlType = $this->getValueControlType(); - - if ($controlType != 'multi_value') { - return; - } - - $selectionColumn = [ - '_select_record' => [ - 'label' => '', - 'sortable' => false, - 'type' => 'partial', - 'width' => '10px', - 'path' => plugins_path('rainlab/notify/classes/modelattributesconditionbase/_column_select_record.htm') - ] - ]; - - $referenceInfo = $this->prepareReferenceListInfo(); - $filterModel = $referenceInfo->referenceModel; - $filterColumns = $selectionColumn + $referenceInfo->columns; - - /* - * List widget - */ - $config = $this->makeConfig(); - $config->columns = $filterColumns; - $config->model = $filterModel; - $config->alias = $widget->alias . 'List'; - $config->showSetup = false; - $config->showCheckboxes = false; - $config->recordsPerPage = 6; - $listWidget = $controller->makeWidget('Backend\Widgets\Lists', $config); - - /* - * Search widget - */ - $config = $this->makeConfig(); - $config->alias = $widget->alias . 'Search'; - $config->growable = false; - $config->prompt = 'backend::lang.list.search_prompt'; - $searchWidget = $controller->makeWidget('Backend\Widgets\Search', $config); - $searchWidget->cssClasses[] = 'condition-filter-search'; - - $listWidget->bindToController(); - $searchWidget->bindToController(); - - /* - * Extend list query - */ - $listWidget->bindEvent('list.extendQueryBefore', function ($query) use ($filterModel) { - $this->prepareFilterQuery($query, $filterModel); - }); - - /* - * Link the Search Widget to the List Widget - */ - $listWidget->setSearchTerm($searchWidget->getActiveTerm()); - - $searchWidget->bindEvent('search.submit', function () use (&$searchWidget, $listWidget) { - $listWidget->setSearchTerm($searchWidget->getActiveTerm()); - return $listWidget->onRefresh(); - }); - - $controller->vars['listWidget'] = $listWidget; - $controller->vars['searchWidget'] = $searchWidget; - $controller->vars['filterHostModel'] = $this->host; - } - - public function prepareFilterQuery($query, $model) - { - } - - // - // Condition check - // - - /** - * Checks whether the condition is TRUE for a specified model - * @return bool - */ - public function evalIsTrue($model, $customValue = '__no_eval_value__') - { - $hostObj = $this->host; - - $operator = $hostObj->operator; - $attribute = $hostObj->subcondition; - - $conditionValue = $hostObj->value; - $conditionValue = trim(mb_strtolower($conditionValue)); - - $controlType = $this->getValueControlType(); - - if ($controlType == 'text') { - if ($customValue === self::NO_EVAL_VALUE) { - $modelValue = trim(mb_strtolower($model->{$attribute})); - } - else { - $modelValue = trim(mb_strtolower($customValue)); - } - - if ($operator == 'is') { - return $modelValue == $conditionValue; - } - - if ($operator == 'is_not') { - return $modelValue != $conditionValue; - } - - if ($operator == 'contains') { - return mb_strpos($modelValue, $conditionValue) !== false; - } - - if ($operator == 'does_not_contain') { - return mb_strpos($modelValue, $conditionValue) === false; - } - - if ($operator == 'equals_or_greater') { - return $modelValue >= $conditionValue; - } - - if ($operator == 'equals_or_less') { - return $modelValue <= $conditionValue; - } - - if ($operator == 'greater') { - return $modelValue > $conditionValue; - } - - if ($operator == 'less') { - return $modelValue < $conditionValue; - } - } - - if ($controlType == 'dropdown') { - if ($customValue === self::NO_EVAL_VALUE) { - $modelValue = $model->{$attribute}; - } - else { - $modelValue = $customValue; - } - - if ($operator == 'is') { - if ($modelValue == null) { - return false; - } - - if ($modelValue instanceof EloquentModel) { - return $modelValue->getKey() == $conditionValue; - } - - if ( - is_array($modelValue) && - count($modelValue) == 1 && - array_key_exists(0, $modelValue) - ) { - return $modelValue[0] == $conditionValue; - } - - if ($modelValue instanceof EloquentCollection) { - if ($modelValue->count() != 1) { - return false; - } - - return $modelValue[0]->getKey() == $conditionValue; - } - } - - if ($operator == 'is_not') { - if ($modelValue == null) { - return true; - } - - if ($modelValue instanceof EloquentModel) { - return $modelValue->getKey() != $conditionValue; - } - - if (is_array($modelValue)) { - if (count($modelValue) != 1) { - return true; - } - - if (!array_key_exists(0, $modelValue)) { - return true; - } - - return $modelValue[0] != $conditionValue; - } - - if ($modelValue instanceof EloquentCollection) { - if (!$modelValue->count() || $modelValue->count() > 1) { - return true; - } - - return $modelValue->first()->getKey() != $conditionValue; - } - } - } - - if ($controlType == 'multi_value') { - if ($customValue === self::NO_EVAL_VALUE) { - $modelValue = $model->{$attribute}; - } - else { - $modelValue = $customValue; - } - - if ( - (!$modelValue instanceof EloquentCollection) && - (!$modelValue instanceof EloquentModel) && - !is_array($modelValue) - ) { - return false; - } - - if (strlen($conditionValue)) { - $conditionValues = explode(',', $conditionValue); - foreach ($conditionValues as &$value) { - $value = trim($value); - } - } else { - $conditionValues = []; - } - - if ($modelValue instanceof EloquentCollection) { - $modelKeys = array_keys($modelValue->lists('id', 'id')); - } - elseif ($modelValue instanceof EloquentModel) { - $modelKeys = [$modelValue->getKey()]; - } - else { - $modelKeys = $modelValue; - } - - if ($operator == 'is') { - $operator = 'one_of'; - } - elseif ($operator == 'is_not') { - $operator = 'not_one_of'; - } - - if ($operator == 'one_of') { - return count(array_intersect($conditionValues, $modelKeys)) ? true : false; - } - - if ($operator == 'not_one_of') { - return count(array_intersect($conditionValues, $modelKeys)) ? false : true; - } - } - - return false; - } - - // - // Helpers - // - - public function getModelObj() - { - if ($this->modelObj === null) { - if (array_key_exists($this->modelClass, self::$modelObjCache)) { - $this->modelObj = self::$modelObjCache[$this->modelClass]; - } - else { - $this->modelObj = self::$modelObjCache[$this->modelClass] = new $this->modelClass; - } - } - - return $this->modelObj; - } -} diff --git a/plugins/rainlab/notify/classes/Notifier.php b/plugins/rainlab/notify/classes/Notifier.php deleted file mode 100644 index de0f520..0000000 --- a/plugins/rainlab/notify/classes/Notifier.php +++ /dev/null @@ -1,134 +0,0 @@ -registerGlobalParams([...]); - * }); - * - * @param callable $callback A callable function. - */ - public function registerCallback(callable $callback) - { - $this->callbacks[] = $callback; - } - - /** - * Helper to process callbacks once and once only. - * @return void - */ - protected function processCallbacks() - { - if ($this->registered) { - return; - } - - foreach ($this->callbacks as $callback) { - $callback($this); - } - - $this->registered = true; - } - - // - // Event binding - // - - public static function bindEvents(array $events) - { - foreach ($events as $event => $class) { - self::bindEvent($event, $class); - } - } - - public static function bindEvent($systemEventName, $notifyEventClass) - { - Event::listen($systemEventName, function() use ($notifyEventClass, $systemEventName) { - $params = $notifyEventClass::makeParamsFromEvent(func_get_args(), $systemEventName); - - self::instance()->queueEvent($notifyEventClass, $params); - }); - } - - public function queueEvent($eventClass, array $params) - { - $params += $this->getContextVars(); - - // Use queue - if (true) { - Queue::push(new EventParams($eventClass, $params)); - } - else { - $this->fireEvent($eventClass, $params); - } - } - - public function fireEvent($eventClass, array $params) - { - $models = NotificationRuleModel::listRulesForEvent($eventClass); - - foreach ($models as $model) { - $model->setParams($params); - $model->triggerRule(); - } - } - - public function registerGlobalParams(array $params) - { - if (!$this->registeredGlobalParams) { - $this->registeredGlobalParams = []; - } - - $this->registeredGlobalParams = $params + $this->registeredGlobalParams; - } - - public function getContextVars() - { - $this->processCallbacks(); - - $globals = $this->registeredGlobalParams ?: []; - - return [ - 'isBackend' => App::runningInBackend() ? 1 : 0, - 'isConsole' => App::runningInConsole() ? 1 : 0, - 'appLocale' => App::getLocale(), - 'sender' => null // unsafe:BackendAuth::getUser() - ] + $globals; - } -} diff --git a/plugins/rainlab/notify/classes/compoundcondition/fields.yaml b/plugins/rainlab/notify/classes/compoundcondition/fields.yaml deleted file mode 100644 index 2509f4c..0000000 --- a/plugins/rainlab/notify/classes/compoundcondition/fields.yaml +++ /dev/null @@ -1,14 +0,0 @@ -# =================================== -# Field Definitions -# =================================== - -fields: - condition_type: - label: Condition type - span: auto - type: dropdown - - condition: - label: Required value - span: auto - type: dropdown diff --git a/plugins/rainlab/notify/classes/modelattributesconditionbase/_column_select_record.htm b/plugins/rainlab/notify/classes/modelattributesconditionbase/_column_select_record.htm deleted file mode 100644 index a218745..0000000 --- a/plugins/rainlab/notify/classes/modelattributesconditionbase/_column_select_record.htm +++ /dev/null @@ -1,10 +0,0 @@ - - - - - diff --git a/plugins/rainlab/notify/classes/modelattributesconditionbase/_field_value.htm b/plugins/rainlab/notify/classes/modelattributesconditionbase/_field_value.htm deleted file mode 100644 index 1da7843..0000000 --- a/plugins/rainlab/notify/classes/modelattributesconditionbase/_field_value.htm +++ /dev/null @@ -1,107 +0,0 @@ -subcondition; - $controlType = $formModel->getValueControlType(); -?> - - - - - - getValueDropdownOptions(); - ?> - - - - listSelectedReferenceRecords(); - $hasData = $selectedRecords->count(); - ?> -
- -
- render() ?> - render() ?> -
- - -
-
- - - - - - - - - - - -
- - - - - - - getReferencePrimaryColumn($record)) ?> -
-
-
- - - - - - - -
- - diff --git a/plugins/rainlab/notify/classes/modelattributesconditionbase/fields.yaml b/plugins/rainlab/notify/classes/modelattributesconditionbase/fields.yaml deleted file mode 100644 index d0c4981..0000000 --- a/plugins/rainlab/notify/classes/modelattributesconditionbase/fields.yaml +++ /dev/null @@ -1,22 +0,0 @@ -# =================================== -# Field Definitions -# =================================== - -fields: - - subcondition: - label: Attribute - span: auto - type: dropdown - - operator: - label: Operator - span: auto - type: dropdown - dependsOn: subcondition - - value: - label: Value - dependsOn: [subcondition, operator] - type: partial - path: field_value diff --git a/plugins/rainlab/notify/composer.json b/plugins/rainlab/notify/composer.json deleted file mode 100644 index f55725b..0000000 --- a/plugins/rainlab/notify/composer.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "rainlab/notify-plugin", - "type": "october-plugin", - "description": "Notify plugin for October CMS", - "homepage": "https://octobercms.com/plugin/rainlab-pages", - "keywords": ["october", "octobercms", "pages"], - "license": "MIT", - "authors": [ - { - "name": "Alexey Bobkov", - "email": "aleksey.bobkov@gmail.com", - "role": "Co-founder" - }, - { - "name": "Samuel Georges", - "email": "daftspunky@gmail.com", - "role": "Co-founder" - } - ], - "require": { - "php": ">=5.5.9", - "composer/installers": "~1.0" - }, - "minimum-stability": "dev" -} diff --git a/plugins/rainlab/notify/controllers/Notifications.php b/plugins/rainlab/notify/controllers/Notifications.php deleted file mode 100644 index 4032113..0000000 --- a/plugins/rainlab/notify/controllers/Notifications.php +++ /dev/null @@ -1,137 +0,0 @@ -asExtension('ListController')->index(); - } - - public function create($eventAlias = null) - { - try { - if (!$eventAlias) { - throw new ApplicationException('Missing a rule code'); - } - - $this->eventAlias = $eventAlias; - $this->bodyClass = 'compact-container breadcrumb-fancy'; - $this->asExtension('FormController')->create(); - } - catch (Exception $ex) { - $this->handleError($ex); - } - } - - public function update($recordId = null, $context = null) - { - $this->bodyClass = 'compact-container breadcrumb-fancy'; - $this->asExtension('FormController')->update($recordId, $context); - } - - public function formExtendModel($model) - { - if (!$model->exists) { - $model->applyEventClass($this->getEventClass()); - $model->name = $model->getEventDescription(); - } - - return $model; - } - - // public function formBeforeSave($model) - // { - // $model->is_custom = 1; - // } - - public function index_onLoadRuleGroupForm() - { - try { - $groups = EventBase::findEventGroups(); - $this->vars['eventGroups'] = $groups; - } - catch (Exception $ex) { - $this->handleError($ex); - } - - return $this->makePartial('add_rule_group_form'); - } - - /** - * This handler requires the group code passed from `onLoadRuleGroupForm` - */ - public function index_onLoadRuleEventForm() - { - try { - if (!$code = post('code')) { - throw new ApplicationException('Missing event group code'); - } - - $events = EventBase::findEventsByGroup($code); - $this->vars['events'] = $events; - } - catch (Exception $ex) { - $this->handleError($ex); - } - - return $this->makePartial('add_rule_event_form'); - } - - protected function getEventClass() - { - $alias = post('event_alias', $this->eventAlias); - - if ($this->eventClass !== null) { - return $this->eventClass; - } - - if (!$event = EventBase::findEventByIdentifier($alias)) { - throw new ApplicationException('Unable to find event with alias: '. $alias); - } - - return $this->eventClass = get_class($event); - } -} diff --git a/plugins/rainlab/notify/controllers/notifications/_add_rule_event_form.htm b/plugins/rainlab/notify/controllers/notifications/_add_rule_event_form.htm deleted file mode 100644 index 6000aff..0000000 --- a/plugins/rainlab/notify/controllers/notifications/_add_rule_event_form.htm +++ /dev/null @@ -1,41 +0,0 @@ - 'addRuleEventForm']) ?> - - - - - diff --git a/plugins/rainlab/notify/controllers/notifications/_add_rule_group_form.htm b/plugins/rainlab/notify/controllers/notifications/_add_rule_group_form.htm deleted file mode 100644 index 49f4301..0000000 --- a/plugins/rainlab/notify/controllers/notifications/_add_rule_group_form.htm +++ /dev/null @@ -1,49 +0,0 @@ - 'addRuleGroupForm']) ?> - - - - - diff --git a/plugins/rainlab/notify/controllers/notifications/_form_toolbar.htm b/plugins/rainlab/notify/controllers/notifications/_form_toolbar.htm deleted file mode 100644 index 5afdc03..0000000 --- a/plugins/rainlab/notify/controllers/notifications/_form_toolbar.htm +++ /dev/null @@ -1,49 +0,0 @@ -formGetContext() == 'create'; - $pageUrl = isset($pageUrl) ? $pageUrl : null; -?> -
- - - data-request-data="redirect:0" - data-hotkey="ctrl+s, cmd+s"> - - - - - - - - - - - - - - - - - - - -
diff --git a/plugins/rainlab/notify/controllers/notifications/_list_toolbar.htm b/plugins/rainlab/notify/controllers/notifications/_list_toolbar.htm deleted file mode 100644 index ee4444b..0000000 --- a/plugins/rainlab/notify/controllers/notifications/_list_toolbar.htm +++ /dev/null @@ -1,9 +0,0 @@ -
- - New notification rule - -
diff --git a/plugins/rainlab/notify/controllers/notifications/config_form.yaml b/plugins/rainlab/notify/controllers/notifications/config_form.yaml deleted file mode 100644 index 83a4d35..0000000 --- a/plugins/rainlab/notify/controllers/notifications/config_form.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# =================================== -# Form Behavior Config -# =================================== - -name: rainlab.notify::lang.notifications.notification_rule -form: $/rainlab/notify/models/notificationrule/fields.yaml -modelClass: RainLab\Notify\Models\NotificationRule -defaultRedirect: rainlab/notify/notifications - -create: - redirect: rainlab/notify/notifications/update/:id - redirectClose: rainlab/notify/notifications - -update: - redirect: rainlab/notify/notifications - redirectClose: rainlab/notify/notifications diff --git a/plugins/rainlab/notify/controllers/notifications/config_list.yaml b/plugins/rainlab/notify/controllers/notifications/config_list.yaml deleted file mode 100644 index 1420bd2..0000000 --- a/plugins/rainlab/notify/controllers/notifications/config_list.yaml +++ /dev/null @@ -1,20 +0,0 @@ -# =================================== -# List Behavior Config -# =================================== - -title: rainlab.notify::lang.notifications.menu_label -list: $/rainlab/notify/models/notificationrule/columns.yaml -modelClass: RainLab\Notify\Models\NotificationRule -recordUrl: rainlab/notify/notifications/update/:id -noRecordsMessage: backend::lang.list.no_records -recordsPerPage: 30 -showSetup: true -showCheckboxes: true -defaultSort: - column: count - direction: desc - -toolbar: - buttons: list_toolbar - search: - prompt: backend::lang.list.search_prompt diff --git a/plugins/rainlab/notify/controllers/notifications/create.htm b/plugins/rainlab/notify/controllers/notifications/create.htm deleted file mode 100644 index 43df6f4..0000000 --- a/plugins/rainlab/notify/controllers/notifications/create.htm +++ /dev/null @@ -1,31 +0,0 @@ - - - - -fatalError): ?> - -
- 'layout', - 'data-change-monitor' => 'true', - 'data-window-close-confirm' => e(trans('rainlab.notify::lang.notifications.close_confirm')), - 'id' => 'post-form' - ]) ?> - - - formRender() ?> - - -
- - - -
-

fatalError)) ?>

-

-
- - diff --git a/plugins/rainlab/notify/controllers/notifications/update.htm b/plugins/rainlab/notify/controllers/notifications/update.htm deleted file mode 100644 index c87c74c..0000000 --- a/plugins/rainlab/notify/controllers/notifications/update.htm +++ /dev/null @@ -1,30 +0,0 @@ - - - - -fatalError): ?> - -
- 'layout', - 'data-change-monitor' => 'true', - 'data-window-close-confirm' => e(trans('rainlab.notify::lang.notifications.close_confirm')), - 'id' => 'post-form' - ]) ?> - - formRender() ?> - - -
- - - -
-

fatalError)) ?>

-

-
- - diff --git a/plugins/rainlab/notify/formwidgets/ActionBuilder.php b/plugins/rainlab/notify/formwidgets/ActionBuilder.php deleted file mode 100644 index 55343b5..0000000 --- a/plugins/rainlab/notify/formwidgets/ActionBuilder.php +++ /dev/null @@ -1,350 +0,0 @@ -fillFromConfig([ - // ]); - - if ($widget = $this->makeActionFormWidget()) { - $widget->bindToController(); - } - } - - /** - * {@inheritDoc} - */ - protected function loadAssets() - { - $this->addJs('js/actions.js', 'RainLab.Notify'); - $this->addCss('css/actions.css', 'RainLab.Notify'); - } - - /** - * {@inheritDoc} - */ - public function render() - { - $this->prepareVars(); - - return $this->makePartial('actions_container'); - } - - /** - * Prepares the list data - */ - public function prepareVars() - { - $this->vars['formModel'] = $this->model; - $this->vars['actions'] = $this->getActions(); - $this->vars['actionFormWidget'] = $this->actionFormWidget; - $this->vars['availableTags'] = $this->getAvailableTags(); - } - - /** - * @inheritDoc - */ - public function getSaveValue($value) - { - $this->model->bindEvent('model.afterSave', function() { - $this->processSave(); - }); - - return FormField::NO_SAVE_DATA; - } - - protected function processSave() - { - $cache = $this->getCacheActionDataPayload(); - - foreach ($cache as $id => $data) { - $action = $this->findActionObj($id); - - if ($attributes = $this->getCacheActionAttributes($action)) { - $action->fill($attributes); - } - - $action->save(null, $this->sessionKey); - } - } - - // - // AJAX - // - - public function onLoadCreateActionForm() - { - try { - $actions = ActionBase::findActions(); - $this->vars['actions'] = $actions; - } - catch (Exception $ex) { - $this->handleError($ex); - } - - return $this->makePartial('create_action_form'); - } - - public function onSaveAction() - { - $this->restoreCacheActionDataPayload(); - - $action = $this->findActionObj(); - - $data = post('Action', []); - $action->fill($data); - $action->validate(); - $action->action_text = $action->getActionObject()->getText(); - - $action->applyCustomData(); - - $this->setCacheActionData($action); - - return $this->renderActions($action); - } - - public function onLoadActionSetup() - { - try { - $action = $this->findActionObj(); - - $data = $this->getCacheActionAttributes($action); - - $this->actionFormWidget->setFormValues($data); - - $this->prepareVars(); - $this->vars['action'] = $action; - } - catch (Exception $ex) { - $this->handleError($ex); - } - - return $this->makePartial('action_settings_form'); - } - - public function onCreateAction() - { - if (!$className = post('action_class')) { - throw new ApplicationException('Please specify an action'); - } - - $this->restoreCacheActionDataPayload(); - - $newAction = $this->getRelationModel(); - $newAction->class_name = $className; - $newAction->save(); - - $this->model->rule_actions()->add($newAction, post('_session_key')); - - $this->vars['newActionId'] = $newAction->id; - - return $this->renderActions(); - } - - public function onDeleteAction() - { - $action = $this->findActionObj(); - - $this->model->rule_actions()->remove($action, post('_session_key')); - - return $this->renderActions(); - } - - public function onCancelActionSettings() - { - $action = $this->findActionObj(post('new_action_id')); - - $action->delete(); - - return $this->renderActions(); - } - - // - // Postback deferring - // - - public function getCacheActionAttributes($action) - { - return array_get($this->getCacheActionData($action), 'attributes'); - } - - public function getCacheActionTitle($action) - { - return array_get($this->getCacheActionData($action), 'title'); - } - - public function getCacheActionText($action) - { - return array_get($this->getCacheActionData($action), 'text'); - } - - public function getCacheActionData($action, $default = null) - { - $cache = post('action_data', []); - - if (is_array($cache) && array_key_exists($action->id, $cache)) { - return json_decode($cache[$action->id], true); - } - - if ($default === false) { - return null; - } - - return $this->makeCacheActionData($action); - } - - public function makeCacheActionData($action) - { - $data = [ - 'attributes' => $action->config_data, - 'title' => $action->getTitle(), - 'text' => $action->getText(), - ]; - - return $data; - } - - public function setCacheActionData($action) - { - $cache = post('action_data', []); - - $cache[$action->id] = json_encode($this->makeCacheActionData($action)); - - Request::merge([ - 'action_data' => $cache - ]); - } - - public function restoreCacheActionDataPayload() - { - Request::merge([ - 'action_data' => json_decode(post('current_action_data'), true) - ]); - } - - public function getCacheActionDataPayload() - { - return post('action_data', []); - } - - // - // Helpers - // - - protected function getAvailableTags() - { - $tags = []; - - if ($this->model->methodExists('defineParams')) { - $params = $this->model->defineParams(); - - foreach ($params as $param => $definition) { - $tags[$param] = array_get($definition, 'label'); - } - } - - return $tags; - } - - /** - * Updates the primary rule actions container - * @return array - */ - protected function renderActions() - { - $this->prepareVars(); - - return [ - '#'.$this->getId() => $this->makePartial('actions') - ]; - } - - protected function makeActionFormWidget() - { - if ($this->actionFormWidget !== null) { - return $this->actionFormWidget; - } - - if (!$model = $this->findActionObj(null, false)) { - return null; - } - - if (!$model->hasFieldConfig()) { - return null; - } - - $config = $model->getFieldConfig(); - $config->model = $model; - $config->alias = $this->alias . 'Form'; - $config->arrayName = 'Action'; - - $widget = $this->makeWidget('Backend\Widgets\Form', $config); - - return $this->actionFormWidget = $widget; - } - - protected function getActions() - { - if ($this->actionsCache !== false) { - return $this->actionsCache; - } - - $relationObject = $this->getRelationObject(); - $actions = $relationObject->withDeferred($this->sessionKey)->get(); - - return $this->actionsCache = $actions ?: null; - } - - protected function findActionObj($actionId = null, $throw = true) - { - $actionId = $actionId ? $actionId : post('current_action_id'); - - $action = null; - - if (strlen($actionId)) { - $action = $this->getRelationModel()->find($actionId); - } - - if ($throw && !$action) { - throw new ApplicationException('Action not found'); - } - - return $action; - } -} diff --git a/plugins/rainlab/notify/formwidgets/ConditionBuilder.php b/plugins/rainlab/notify/formwidgets/ConditionBuilder.php deleted file mode 100644 index 05ac6fb..0000000 --- a/plugins/rainlab/notify/formwidgets/ConditionBuilder.php +++ /dev/null @@ -1,454 +0,0 @@ -fillFromConfig([ - 'conditionsRuleType', - ]); - - if ($widget = $this->makeConditionFormWidget()) { - $widget->bindToController(); - } - - $this->initRootCondition(); - } - - /** - * {@inheritDoc} - */ - protected function loadAssets() - { - $this->addJs('js/conditions.js', 'RainLab.Notify'); - $this->addJs('js/conditions.multivalue.js', 'RainLab.Notify'); - $this->addCss('css/conditions.css', 'RainLab.Notify'); - } - - /** - * {@inheritDoc} - */ - public function render() - { - $this->prepareVars(); - - return $this->makePartial('conditions_container'); - } - - /** - * Prepares the list data - */ - public function prepareVars() - { - $this->vars['rootCondition'] = $this->getConditionsRoot(); - $this->vars['conditionFormWidget'] = $this->conditionFormWidget; - } - - public function initRootCondition() - { - if ($this->getConditionsRoot()) { - return; - } - - $relationObject = $this->getRelationObject(); - - $rootRule = $this->getRelationModel(); - $rootRule->rule_host_type = $this->conditionsRuleType; - $rootRule->class_name = $rootRule->getRootConditionClass(); - $rootRule->save(); - - $relationObject->add($rootRule, $this->sessionKey); - - $this->conditionsRoot = $rootRule; - } - - public function isRootCondition($condition) - { - if ($root = $this->getConditionsRoot()) { - return $condition->id === $root->id; - } - - return false; - } - - public function getConditionsRoot() - { - if ($this->conditionsRoot !== false) { - return $this->conditionsRoot; - } - - $relationObject = $this->getRelationObject(); - $rootCondition = $relationObject->withDeferred($this->sessionKey)->first(); - - return $this->conditionsRoot = $rootCondition ?: null; - } - - /** - * @inheritDoc - */ - public function getSaveValue($value) - { - $this->model->bindEvent('model.afterSave', function() { - $this->processSave(); - }); - - return FormField::NO_SAVE_DATA; - } - - protected function processSave() - { - $cache = $this->getCacheConditionDataPayload(); - - foreach ($cache as $id => $data) { - $condition = $this->findConditionObj($id); - $attributes = $this->getCacheConditionAttributes($condition); - $condition->fill($attributes); - $condition->save(null, $this->sessionKey.'_'.$condition->id); - } - } - - // - // AJAX - // - - public function onLoadConditionSetup() - { - try { - $condition = $this->findConditionObj(); - - $this->prepareVars(); - - $this->vars['condition'] = $condition; - } - catch (Exception $ex) { - $this->handleError($ex); - } - - return $this->makePartial('condition_settings_form'); - } - - public function onLoadCreateChildCondition() - { - try { - $condition = $this->findConditionObj(); - - /* - * Look up parents - */ - $parents = [$condition->id]; - $parentsArray = post('condition_parent_id', []); - $currentId = $condition->id; - - while (array_key_exists($currentId, $parentsArray) && $parentsArray[$currentId]) { - $parents[] = $currentId = $parentsArray[$currentId]; - } - - /* - * Custom rules provided by model - */ - $extraRules = []; - if ($this->model->methodExists('getExtraConditionRules')) { - $extraRules = $this->model->getExtraConditionRules(); - } - - /* - * Look up conditions - */ - $options = $condition->getChildOptions([ - 'ruleType' => $this->conditionsRuleType, - 'parentIds' => $parents, - 'extraRules' => $extraRules - ]); - - $this->prepareVars(); - $this->vars['condition'] = $condition; - $this->vars['options'] = $options; - } - catch (Exception $ex) { - $this->handleError($ex); - } - - return $this->makePartial('create_child_form'); - } - - public function onSaveCondition() - { - $this->restoreCacheConditionDataPayload(); - - $condition = $this->findConditionObj(); - - $data = post('Condition', []); - $condition->fill($data); - $condition->validate(); - $condition->condition_text = $condition->getConditionObject()->getText(); - - $condition->applyCustomData(); - - $this->setCacheConditionData($condition); - - return $this->renderConditions($condition); - } - - public function onCreateCondition() - { - if (!$className = post('condition_class')) { - throw new ValidationException(['condition_class' => 'Please specify a condition']); - } - - $this->restoreCacheConditionDataPayload(); - - $subcondition = null; - - $parts = explode(':', $className); - if (count($parts) > 1) { - $subcondition = $parts[1]; - $className = $parts[0]; - } - - $parentCondition = $this->findConditionObj(); - - $newCondition = $this->getRelationModel(); - $newCondition->class_name = $className; - $newCondition->rule_host_type = $parentCondition->rule_host_type; - - if ($subcondition) { - $newCondition->subcondition = $subcondition; - } - - $newCondition->save(); - - $parentCondition->children()->add($newCondition, post('_session_key').'_'.$parentCondition->id); - - $this->vars['newConditionId'] = $newCondition->id; - - return $this->renderConditions($parentCondition); - } - - public function onDeleteCondition() - { - $parentCondition = null; - - $condition = $this->findConditionObj(); - - if ($parentId = $this->getParentIdFromCondition($condition)) { - $parentCondition = $this->findConditionObj($parentId); - - if ($parentCondition) { - $parentCondition->children()->remove($condition, post('_session_key').'_'.$parentCondition->id); - } - } - - return $this->renderConditions($parentCondition); - } - - public function onCancelConditionSettings() - { - $condition = $this->findConditionObj(post('new_condition_id')); - - $condition->delete(); - - return $this->renderConditions(); - } - - // - // Postback deferring - // - - public function getCacheConditionAttributes($condition) - { - return array_get($this->getCacheConditionData($condition), 'attributes'); - } - - public function getCacheConditionText($condition) - { - return array_get($this->getCacheConditionData($condition), 'text'); - } - - public function getCacheConditionJoinText($condition) - { - return array_get($this->getCacheConditionData($condition), 'joinText'); - } - - public function getCacheConditionData($condition, $default = null) - { - $cache = post('condition_data', []); - - if (is_array($cache) && array_key_exists($condition->id, $cache)) { - return json_decode($cache[$condition->id], true); - } - - if ($default === false) { - return null; - } - - return $this->makeCacheConditionData($condition); - } - - public function makeCacheConditionData($condition) - { - $data = [ - 'attributes' => $condition->config_data, - 'text' => $condition->getText() - ]; - - if ($condition->isCompound()) { - $data['joinText'] = $condition->getJoinText(); - } - - return $data; - } - - public function setCacheConditionData($condition) - { - $cache = post('condition_data', []); - - $cache[$condition->id] = json_encode($this->makeCacheConditionData($condition)); - - Request::merge([ - 'condition_data' => $cache - ]); - } - - public function restoreCacheConditionDataPayload() - { - Request::merge([ - 'condition_data' => json_decode(post('current_condition_data', []), true) - ]); - } - - public function getCacheConditionDataPayload() - { - return post('condition_data'); - } - - // - // Helpers - // - - public function getParentIdFromCondition($condition) - { - if ($parentId = post('current_parent_id')) { - return $parentId; - } - - $parentIds = post('condition_parent_id', []); - - if (isset($parentIds[$condition->id])) { - return $parentIds[$condition->id]; - } - } - - /** - * Updates the primary rule conditions container - * @return array - */ - protected function renderConditions($currentCondition = null) - { - if ($currentCondition && $this->isRootCondition($currentCondition)) { - $condition = $currentCondition; - } - else { - $condition = $this->getConditionsRoot(); - } - - return [ - '#'.$this->getId() => $this->makePartial('conditions', ['condition' => $condition]) - ]; - } - - protected function makeConditionFormWidget() - { - if ($this->conditionFormWidget !== null) { - return $this->conditionFormWidget; - } - - if (!$model = $this->findConditionObj(null, false)) { - return null; - } - - $config = $model->getFieldConfig(); - $config->model = $model; - $config->alias = $this->alias . 'Form'; - $config->arrayName = 'Condition'; - - $widget = $this->makeWidget('Backend\Widgets\Form', $config); - - /* - * Set form values based on postback or cached attributes - */ - if (!$data = post('Condition')) { - $data = $this->getCacheConditionAttributes($model); - } - - $widget->setFormValues($data); - - /* - * Allow conditions to register their own widgets - */ - $model->onPreRender($this->controller, $this); - - return $this->conditionFormWidget = $widget; - } - - protected function findConditionObj($conditionId = null, $throw = true) - { - $conditionId = $conditionId ? $conditionId : post('current_condition_id'); - - $condition = null; - - if (strlen($conditionId)) { - $condition = $this->getRelationModel()->find($conditionId); - } - - if ($throw && !$condition) { - throw new ApplicationException('Condition not found'); - } - - return $condition; - } -} diff --git a/plugins/rainlab/notify/formwidgets/actionbuilder/assets/css/actions.css b/plugins/rainlab/notify/formwidgets/actionbuilder/assets/css/actions.css deleted file mode 100644 index 817a940..0000000 --- a/plugins/rainlab/notify/formwidgets/actionbuilder/assets/css/actions.css +++ /dev/null @@ -1,227 +0,0 @@ -.action-set { - margin-top: 10px; -} -.action-set ol { - margin: 0; - padding: 0; - list-style: none; -} -.action-set ol > li { - -webkit-transition: width 1s; - transition: width 1s; -} -.action-set ol > li > div { - font-size: 14px; - font-weight: normal; - position: relative; -} -.action-set ol > li > div > a, -.action-set ol > li > div div.content { - color: #2b3e50; - padding: 10px 45px 10px 91px; - display: block; - line-height: 150%; - text-decoration: none; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; -} -.action-set ol > li > div span.icon { - display: block; - position: absolute; - width: 22px; - height: 22px; - left: 20px; - top: 15px; - text-align: center; - font-weight: 500; - line-height: 22px; - color: #999; -} -.action-set ol > li > div span.icon > i { - line-height: 22px; - font-weight: normal; - font-size: 22px; - color: #999; -} -.action-set ol > li > div:not(.no-hover):hover, -.action-set ol > li > div.popover-highlight { - background-color: #4ea5e0 !important; -} -.action-set ol > li > div:not(.no-hover):hover span.icon > i, -.action-set ol > li > div.popover-highlight span.icon > i { - color: #fff !important; -} -.action-set ol > li > div:not(.no-hover):hover > a, -.action-set ol > li > div.popover-highlight > a { - color: #ffffff !important; -} -.action-set ol > li > div:not(.no-hover):hover:before, -.action-set ol > li > div.popover-highlight:before { - background-position: 0px -80px; -} -.action-set ol > li > div:not(.no-hover):hover:after, -.action-set ol > li > div.popover-highlight:after { - top: 0 !important; - bottom: 0 !important; -} -.action-set ol > li > div:not(.no-hover):hover span, -.action-set ol > li > div.popover-highlight span { - color: #ffffff !important; -} -.action-set ol > li > div:not(.no-hover):hover span.drag-handle, -.action-set ol > li > div.popover-highlight span.drag-handle { - cursor: move; - opacity: 1; - filter: alpha(opacity=100); -} -.action-set ol > li > div:not(.no-hover):active { - background-color: #3498db !important; -} -.action-set ol > li > div:not(.no-hover):active > a { - color: #ffffff !important; -} -.action-set ol > li > div span.icon:first-child { - font-size: 11px; - color: #ccc; -} -.action-set ol > li > div span.icon:first-child > i { - color: #ccc; - font-size: 15px; -} -.action-set ol > li > div span.icon:last-child { - left: 52px; -} -.action-set ol > li > div span.comment { - display: block; - font-weight: 400; - color: #95a5a6; - font-size: 13px; - margin-top: 2px; - overflow: hidden; - text-overflow: ellipsis; -} -.action-set ol > li > div > .subpanel { - right: 0; - top: 0; - height: 100%; - position: absolute; - z-index: 200; - padding: 0 20px; -} -.action-set ol > li > div > ul.submenu { - position: absolute; - right: 0; - top: 0; - padding: 0; - list-style: none; - z-index: 200; - height: 100%; - display: none; - margin: 0; - font-size: 0; -} -.action-set ol > li > div > ul.submenu li { - font-size: 12px; - height: 100%; - display: inline-block; - background: #2581b8; - border-right: 1px solid #328ec8; -} -.action-set ol > li > div > ul.submenu li p { - display: table; - height: 100%; - padding: 0; - margin: 0; -} -.action-set ol > li > div > ul.submenu li p a { - display: table-cell; - vertical-align: middle; - height: 100%; - padding: 0 20px; - font-size: 13px; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; - color: #ffffff; - text-decoration: none; -} -.action-set ol > li > div > ul.submenu li p a i.control-icon { - font-size: 22px; -} -.action-set ol > li > div:hover > ul.submenu { - display: block; -} -.action-set ol > li > div .checkbox { - position: absolute; - top: -2px; - right: 0; -} -.action-set ol > li > div .checkbox label { - margin-right: 0; -} -.action-set ol > li > div .checkbox label:before { - border-color: #cccccc; -} -.action-set ol > li > div.popover-highlight { - background-color: #4ea5e0 !important; -} -.action-set ol > li > div.popover-highlight:before { - background-position: 0px -80px; -} -.action-set ol > li > div.popover-highlight > a { - color: #ffffff !important; - cursor: default; -} -.action-set ol > li > div.popover-highlight span { - color: #ffffff !important; -} -.action-set ol > li > div.popover-highlight > ul.submenu, -.action-set ol > li > div.popover-highlight > span.drag-handle { - display: none !important; -} -.action-set ol > li.active > div { - background: #dddddd; -} -.action-set ol > li.active > div:after { - position: absolute; - width: 4px; - left: 0; - top: -1px; - bottom: -1px; - background: #e67e22; - display: block; - content: ' '; -} -.action-set ol > li.active > div > span.comment, -.action-set ol > li.active > div > span.expand { - color: #8f8f8f; -} -.action-set a.menu-control { - display: block; - margin: 20px; - padding: 13px 15px; - border: dotted 2px #ebebeb; - color: #bdc3c7; - font-size: 12px; - font-weight: 600; - text-transform: uppercase; - border-radius: 5px; - vertical-align: middle; -} -.action-set a.menu-control:hover, -.action-set a.menu-control:focus { - text-decoration: none; - background-color: #4ea5e0; - color: #ffffff; - border: none; - padding: 15px 17px; -} -.action-set a.menu-control:active { - background: #3498db; - color: #ffffff; -} -.action-set a.menu-control i { - margin-right: 10px; - font-size: 14px; -} diff --git a/plugins/rainlab/notify/formwidgets/actionbuilder/assets/js/actions.js b/plugins/rainlab/notify/formwidgets/actionbuilder/assets/js/actions.js deleted file mode 100644 index f2dbbeb..0000000 --- a/plugins/rainlab/notify/formwidgets/actionbuilder/assets/js/actions.js +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Global helpers - */ -function showActionSettings(id) { - var $control = $('[data-action-id='+id+']').closest('[data-control="ruleactions"]') - - $control.ruleActions('onShowNewActionSettings', id) -} - -/* - * Plugin definition - */ -+function ($) { "use strict"; - var Base = $.oc.foundation.base, - BaseProto = Base.prototype - - var RuleActions = function (element, options) { - this.$el = $(element) - this.options = options || {} - - $.oc.foundation.controlUtils.markDisposable(element) - Base.call(this) - this.init() - } - - RuleActions.prototype = Object.create(BaseProto) - RuleActions.prototype.constructor = RuleActions - - RuleActions.prototype.init = function() { - this.$el.on('click', '[data-actions-settings]', this.proxy(this.onShowSettings)) - this.$el.on('click', '[data-actions-delete]', this.proxy(this.onDeleteAction)) - this.$el.one('dispose-control', this.proxy(this.dispose)) - } - - RuleActions.prototype.dispose = function() { - this.$el.off('click', '[data-actions-settings]', this.proxy(this.onShowSettings)) - this.$el.off('click', '[data-actions-delete]', this.proxy(this.onDeleteAction)) - this.$el.off('dispose-control', this.proxy(this.dispose)) - this.$el.removeData('oc.ruleActions') - - this.$el = null - - // In some cases options could contain callbacks, - // so it's better to clean them up too. - this.options = null - - BaseProto.dispose.call(this) - } - - RuleActions.prototype.onDeleteAction = function(event) { - var $el = $(event.target), - actionId = getActionIdFromElement($el) - - $el.request(this.options.deleteHandler, { - data: { current_action_id: actionId }, - confirm: 'Do you really want to delete this action?' - }) - } - - RuleActions.prototype.onShowNewActionSettings = function(actionId) { - var $el = $('[data-action-id='+actionId+']') - - // Action does not use settings - if ($el.hasClass('no-form')) { - return - } - - $el.popup({ - handler: this.options.settingsHandler, - extraData: { current_action_id: actionId }, - size: 'giant' - }) - - // This will not fire on successful save because the target element - // is replaced by the time the popup loader has finished to call it - $el.one('hide.oc.popup', this.proxy(this.onCancelAction)) - } - - RuleActions.prototype.onCancelAction = function(event) { - var $el = $(event.target), - actionId = getActionIdFromElement($el) - - $el.request(this.options.cancelHandler, { - data: { new_action_id: actionId } - }) - - return false - } - - RuleActions.prototype.onShowSettings = function(event) { - var $el = $(event.target), - actionId = getActionIdFromElement($el) - - // Action does not use settings - if ($el.closest('li.action-item').hasClass('no-form')) { - return - } - - $el.popup({ - handler: this.options.settingsHandler, - extraData: { current_action_id: actionId }, - size: 'giant' - }) - - return false - } - - function getActionIdFromElement($el) { - var $item = $el.closest('li.action-item') - - return $item.data('action-id') - } - - RuleActions.DEFAULTS = { - settingsHandler: null, - deleteHandler: null, - cancelHandler: null, - createHandler: null - } - - // PLUGIN DEFINITION - // ============================ - - var old = $.fn.ruleActions - - $.fn.ruleActions = function (option) { - var args = Array.prototype.slice.call(arguments, 1), items, result - - items = this.each(function () { - var $this = $(this) - var data = $this.data('oc.ruleActions') - var options = $.extend({}, RuleActions.DEFAULTS, $this.data(), typeof option == 'object' && option) - if (!data) $this.data('oc.ruleActions', (data = new RuleActions(this, options))) - if (typeof option == 'string') result = data[option].apply(data, args) - if (typeof result != 'undefined') return false - }) - - return result ? result : items - } - - $.fn.ruleActions.Constructor = RuleActions - - $.fn.ruleActions.noConflict = function () { - $.fn.ruleActions = old - return this - } - - // Add this only if required - $(document).render(function (){ - $('[data-control="ruleactions"]').ruleActions() - }) - -}(window.jQuery); diff --git a/plugins/rainlab/notify/formwidgets/actionbuilder/assets/less/actions.less b/plugins/rainlab/notify/formwidgets/actionbuilder/assets/less/actions.less deleted file mode 100644 index 16440bb..0000000 --- a/plugins/rainlab/notify/formwidgets/actionbuilder/assets/less/actions.less +++ /dev/null @@ -1,273 +0,0 @@ -@import "../../../../../../../modules/backend/assets/less/core/boot.less"; - -// -// Actions -// -------------------------------------------------- - -@color-actions-item-bg: #ffffff; -@color-actions-item-title: #2b3e50; -@color-actions-item-comment: #95a5a6; -@color-actions-control: #bdc3c7; -@color-actions-hover-bg: @highlight-hover-bg; -@color-actions-hover-text: @highlight-hover-text; -@color-actions-active-bg: @highlight-active-bg; -@color-actions-active-text: @highlight-active-text; -@color-actions-item-active-comment: #8f8f8f; -@color-actions-submenu-text: #ffffff; -@color-actions-light-submenu-bg: #2581b8; -@color-actions-light-submenu-border: #328ec8; - -.action-set { - margin-top: 10px; - - ol { - margin: 0; - padding: 0; - list-style: none; - - > li { - .transition(width 1s); - - > div { - font-size: @font-size-base; - font-weight: normal; - position: relative; - - > a, div.content { - color: @color-actions-item-title; - padding: 10px 45px 10px 91px; - display: block; - line-height: 150%; - text-decoration: none; - .box-sizing(border-box); - } - - span.icon { - display: block; - position: absolute; - width: 22px; - height: 22px; - left: 20px; - top: 15px; - text-align: center; - font-weight: 500; - line-height: 22px; - color: #999; - - > i { - line-height: 22px; - font-weight: normal; - font-size: 22px; - color: #999; - } - } - - &:not(.no-hover):hover, &.popover-highlight { - background-color: @color-actions-hover-bg !important; - - span.icon > i { - color: #fff !important; - } - - > a { - color: @color-actions-hover-text !important; - } - - &:before { - background-position: 0px -80px; - } - - &:after { - top: 0 !important; - bottom: 0 !important; - } - - span { - color: @color-actions-hover-text !important; - - &.drag-handle { - cursor: move; - .opacity(1); - } - } - } - - &:not(.no-hover):active { - background-color: @color-actions-active-bg !important; - - > a { - color: @color-actions-active-text !important; - } - } - - span.icon:first-child { - font-size: 11px; - color: #ccc; - - > i { - color: #ccc; - font-size: 15px; - } - } - span.icon:last-child { - left: 52px; - } - - span.comment { - display: block; - font-weight: 400; - color: @color-actions-item-comment; - font-size: @font-size-base - 1; - margin-top: 2px; - overflow: hidden; - text-overflow: ellipsis; - } - - > .subpanel { - right: 0; - top: 0; - height: 100%; - position: absolute; - z-index: 200; - padding: 0 20px; - } - - > ul.submenu { - position: absolute; - right: 0; - top: 0; - padding: 0; - list-style: none; - z-index: 200; - height: 100%; - display: none; - margin: 0; - font-size: 0; - - li { - font-size: @font-size-base - 2; - height: 100%; - display: inline-block; - background: @color-actions-light-submenu-bg; - border-right: 1px solid @color-actions-light-submenu-border; - - p { - display: table; - height: 100%; - padding: 0; - margin: 0; - - a { - display: table-cell; - vertical-align: middle; - height: 100%; - padding: 0 20px; - font-size: @font-size-base - 1; - .box-sizing(border-box); - color: @color-actions-submenu-text; - text-decoration: none; - - i.control-icon { - font-size: 22px; - } - } - } - } - } - - &:hover { - > ul.submenu { - display: block; - } - } - - .checkbox { - position: absolute; - top: -2px; - right: 0; - - label { - margin-right: 0; - - &:before { - border-color: @color-filelist-cb-border; - } - } - } - - &.popover-highlight { - background-color: @color-actions-hover-bg !important; - - &:before { - background-position: 0px -80px; - } - - > a { - color: @color-actions-hover-text !important; - cursor: default; - } - - span { - color: @color-actions-hover-text !important; - } - - > ul.submenu, > span.drag-handle { - display: none !important; - } - } - } - - &.active { - > div { - background: @color-list-active; - - &:after { - position: absolute; - width: 4px; - left: 0; - top: -1px; - bottom: -1px; - background: @color-list-active-border; - display: block; - content: ' '; - } - - > span.comment, > span.expand { - color: @color-actions-item-active-comment; - } - } - } - } - } - - a.menu-control { - display: block; - margin: 20px; - padding: 13px 15px; - border: dotted 2px #ebebeb; - color: #bdc3c7; - font-size: @font-size-base - 2; - font-weight: 600; - text-transform: uppercase; - border-radius: 5px; - vertical-align: middle; - - &:hover, &:focus { - text-decoration: none; - background-color: @color-actions-hover-bg; - color: @color-actions-hover-text; - border: none; - padding: 15px 17px; - } - - &:active { - background: @color-actions-active-bg; - color: @color-actions-active-text; - } - - i { - margin-right: 10px; - font-size: 14px; - } - } -} \ No newline at end of file diff --git a/plugins/rainlab/notify/formwidgets/actionbuilder/partials/_action.htm b/plugins/rainlab/notify/formwidgets/actionbuilder/partials/_action.htm deleted file mode 100644 index aa071a8..0000000 --- a/plugins/rainlab/notify/formwidgets/actionbuilder/partials/_action.htm +++ /dev/null @@ -1,29 +0,0 @@ -
  • -
    -
    - - -
    - - getCacheActionTitle($action)) ?> - getCacheActionText($action)) ?> - - -
    - - -
  • diff --git a/plugins/rainlab/notify/formwidgets/actionbuilder/partials/_action_settings_form.htm b/plugins/rainlab/notify/formwidgets/actionbuilder/partials/_action_settings_form.htm deleted file mode 100644 index 993f2f3..0000000 --- a/plugins/rainlab/notify/formwidgets/actionbuilder/partials/_action_settings_form.htm +++ /dev/null @@ -1,71 +0,0 @@ - 'propertyForm']) ?> - - - - fatalError): ?> - - - - - - - - - - - - - - - diff --git a/plugins/rainlab/notify/formwidgets/actionbuilder/partials/_actions.htm b/plugins/rainlab/notify/formwidgets/actionbuilder/partials/_actions.htm deleted file mode 100644 index 89e3133..0000000 --- a/plugins/rainlab/notify/formwidgets/actionbuilder/partials/_actions.htm +++ /dev/null @@ -1,31 +0,0 @@ -
    -
      -
    1. -
      -
      - ON - -
      -
      - getEventName()) ?> - getEventDescription()) ?> -
      -
      -
    2. - - makePartial('action', ['action' => $action]) ?> - -
    - - - Add action - -
    - - - - diff --git a/plugins/rainlab/notify/formwidgets/actionbuilder/partials/_actions_container.htm b/plugins/rainlab/notify/formwidgets/actionbuilder/partials/_actions_container.htm deleted file mode 100644 index edee7b4..0000000 --- a/plugins/rainlab/notify/formwidgets/actionbuilder/partials/_actions_container.htm +++ /dev/null @@ -1,12 +0,0 @@ -
    -
    - makePartial('actions', ['actions' => $actions]) ?> -
    -
    diff --git a/plugins/rainlab/notify/formwidgets/actionbuilder/partials/_available_tags.htm b/plugins/rainlab/notify/formwidgets/actionbuilder/partials/_available_tags.htm deleted file mode 100644 index 652b10d..0000000 --- a/plugins/rainlab/notify/formwidgets/actionbuilder/partials/_available_tags.htm +++ /dev/null @@ -1,23 +0,0 @@ - -
    -

    These variables are available:

    -
    -
      - $description): ?> -
    • - {{ }} -
    • - -
    -
    -
    Click or drag these in to the content area
    -
    - -
    -
    This action does not provide any variables.
    -
    - diff --git a/plugins/rainlab/notify/formwidgets/actionbuilder/partials/_create_action_form.htm b/plugins/rainlab/notify/formwidgets/actionbuilder/partials/_create_action_form.htm deleted file mode 100644 index 6851c95..0000000 --- a/plugins/rainlab/notify/formwidgets/actionbuilder/partials/_create_action_form.htm +++ /dev/null @@ -1,48 +0,0 @@ - 'addRuleActionForm']) ?> - - - - - - - - diff --git a/plugins/rainlab/notify/formwidgets/conditionbuilder/assets/css/conditions.css b/plugins/rainlab/notify/formwidgets/conditionbuilder/assets/css/conditions.css deleted file mode 100644 index 84cba64..0000000 --- a/plugins/rainlab/notify/formwidgets/conditionbuilder/assets/css/conditions.css +++ /dev/null @@ -1,227 +0,0 @@ -ul.condition-set { - padding: 5px 0 0; - margin: 0; - list-style: none; -} -ul.condition-set ul { - padding: 0; - margin: 0; - list-style: none; -} -ul.condition-set li { - margin: 0; - padding: 0; -} -ul.condition-set .condition-item { - border-radius: 4px; -} -ul.condition-set .condition-item.is-root { - border-radius: 0; -} -ul.condition-set .condition-item.collapsed .compound-content { - border-left-color: transparent !important; -} -ul.condition-set .condition-item.collapsed .condition-set { - display: none; -} -ul.condition-set .condition-item.collapsed.is-inner .compound-add-item { - display: none; -} -ul.condition-set .condition-item .condition-delete { - position: absolute; - display: block; - width: 10px; - height: 10px; - right: 7px; - top: 7px; -} -ul.condition-set a.condition-collapse { - text-decoration: none; - display: block; - position: absolute; - right: 8px; - top: 2px; -} -ul.condition-set a.condition-collapse > i { - -webkit-transition: transform 0.3s; - transition: transform 0.3s; - width: 15px; - height: 15px; - color: #bdc3c7; - font-size: 12px; - display: block; -} -ul.condition-set a.condition-collapse:hover > i { - color: #999; -} -ul.condition-set li.collapsed a.condition-collapse > i { - -webkit-transform: scale(1, -1); - -ms-transform: scale(1, -1); - transform: scale(1, -1); -} -ul.condition-set .compound-join { - text-align: center; - padding: 3px 0 2px 0; -} -ul.condition-set .compound-join a { - color: #333333; - text-decoration: none; -} -ul.condition-set .compound-join a:hover { - text-decoration: underline; -} -ul.condition-set .condition-item.is-single { - padding: 8px 20px 9px 24px; - background: #fff; - border: 1px solid #eee; - position: relative; -} -ul.condition-set .condition-item.is-single:before { - font-family: FontAwesome; - font-weight: normal; - font-style: normal; - text-decoration: inherit; - -webkit-font-smoothing: antialiased; - *margin-right: .3em; - content: "\f126"; - line-height: 100%; - font-size: 16px; - color: #bdc3c7; - position: absolute; - width: 15px; - height: 15px; - left: 12px; - top: 11px; -} -ul.condition-set .condition-item.is-single .condition-text { - padding-left: 10px; -} -ul.condition-set .condition-item.is-single .condition-text a { - color: #333333; - text-decoration: none; -} -ul.condition-set .condition-item.is-single .condition-text a:hover { - text-decoration: underline; -} -ul.condition-set .condition-item.is-single .condition-text a span.operator { - font-weight: 500; -} -ul.condition-set .condition-item.is-single a.condition-delete { - right: 12px; - top: 9px; -} -ul.condition-set .condition-item.is-compound .compound-content { - position: relative; - border-left: 1px solid #dbdee0; - margin-left: 5px; -} -ul.condition-set .condition-item.is-compound .compound-content:before { - color: #bdc3c7; - font-family: FontAwesome; - font-weight: normal; - font-style: normal; - text-decoration: inherit; - -webkit-font-smoothing: antialiased; - *margin-right: .3em; - content: "\f111"; - font-size: 8px; - position: absolute; - left: -4px; - top: -2px; -} -ul.condition-set .condition-item.is-compound .compound-content h4 { - padding: 0 30px 5px 5px; - margin: 0; - position: relative; - top: -5px; - font-size: 13px; - line-height: 130%; - font-weight: 400; - color: #666; -} -ul.condition-set .condition-item.is-compound .compound-content h4 a.condition-text { - color: #333333; - padding-left: 10px; -} -ul.condition-set .condition-item.is-compound .compound-content h4 a.condition-text:hover { - text-decoration: underline; -} -ul.condition-set .condition-item.is-compound .compound-content .condition-set { - padding-left: 15px; -} -ul.condition-set .condition-item.is-compound .compound-add-item { - position: relative; - margin-top: 10px; - margin-left: 20px; - border: 2px dotted #e0e0e0; - border-radius: 5px; -} -ul.condition-set .condition-item.is-compound .compound-add-item:before { - color: #bdc3c7; - font-family: FontAwesome; - font-weight: normal; - font-style: normal; - text-decoration: inherit; - -webkit-font-smoothing: antialiased; - *margin-right: .3em; - content: "\f067"; - font-size: 16px; - position: absolute; - left: -23px; - top: -11px; -} -ul.condition-set .condition-item.is-compound .compound-add-item > a { - color: #bdc3c7; - text-align: center; - display: block; - text-decoration: none; - padding: 13px 15px; - text-transform: uppercase; - font-weight: 600; - font-size: 12px; -} -ul.condition-set .condition-item.is-compound .compound-add-item:hover, -ul.condition-set .condition-item.is-compound .compound-add-item:focus { - background-color: #4ea5e0; - border-color: #4ea5e0; -} -ul.condition-set .condition-item.is-compound .compound-add-item:hover:before, -ul.condition-set .condition-item.is-compound .compound-add-item:focus:before { - color: #999; -} -ul.condition-set .condition-item.is-compound .compound-add-item:hover > a, -ul.condition-set .condition-item.is-compound .compound-add-item:focus > a { - color: #ffffff; -} -ul.condition-set .condition-item.is-compound .compound-add-item:active { - background: #3498db; - border-color: #3498db; -} -ul.condition-set .condition-item.is-compound .compound-add-item:active > a { - color: #ffffff; -} -ul.condition-set .condition-item.is-compound.is-inner { - padding-right: 20px; -} -ul.condition-set .condition-item.is-compound.is-inner a.condition-delete-compound { - right: -7px; - top: 0; -} -.condition-multi-value .condition-filter-search { - background-position: right -81px !important; - border-top: none !important; - border-left: none !important; - border-right: none !important; - border-radius: 0; - padding-left: 20px; -} -.condition-multi-value .filter-list { - margin: 0 -20px; -} -.condition-multi-value .filter-list .list-footer { - padding-top: 0; - padding-bottom: 0; -} -.condition-multi-value .added-filter-list { - margin: 0 -20px; -} diff --git a/plugins/rainlab/notify/formwidgets/conditionbuilder/assets/js/conditions.js b/plugins/rainlab/notify/formwidgets/conditionbuilder/assets/js/conditions.js deleted file mode 100644 index a8f6051..0000000 --- a/plugins/rainlab/notify/formwidgets/conditionbuilder/assets/js/conditions.js +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Global helpers - */ -function showConditionSettings(id) { - var $control = $('[data-condition-id='+id+']').closest('[data-control="ruleconditions"]') - - $control.ruleConditions('onShowNewConditionSettings', id) -} - -/* - * Plugin definition - */ -+function ($) { "use strict"; - var Base = $.oc.foundation.base, - BaseProto = Base.prototype - - var RuleConditions = function (element, options) { - this.$el = $(element) - this.options = options || {} - - $.oc.foundation.controlUtils.markDisposable(element) - Base.call(this) - this.init() - } - - RuleConditions.prototype = Object.create(BaseProto) - RuleConditions.prototype.constructor = RuleConditions - - RuleConditions.prototype.init = function() { - this.$el.on('click', '[data-conditions-collapse]', this.proxy(this.onConditionsToggle)) - this.$el.on('click', '[data-conditions-settings]', this.proxy(this.onShowSettings)) - this.$el.on('click', '[data-conditions-create]', this.proxy(this.onCreateChildCondition)) - this.$el.on('click', '[data-conditions-delete]', this.proxy(this.onDeleteCondition)) - this.$el.one('dispose-control', this.proxy(this.dispose)) - } - - RuleConditions.prototype.dispose = function() { - this.$el.off('click', '[data-conditions-collapse]', this.proxy(this.onConditionsToggle)) - this.$el.off('click', '[data-conditions-settings]', this.proxy(this.onShowSettings)) - this.$el.off('click', '[data-conditions-create]', this.proxy(this.onCreateChildCondition)) - this.$el.off('click', '[data-conditions-delete]', this.proxy(this.onDeleteCondition)) - this.$el.off('dispose-control', this.proxy(this.dispose)) - this.$el.removeData('oc.ruleConditions') - - this.$el = null - - // In some cases options could contain callbacks, - // so it's better to clean them up too. - this.options = null - - BaseProto.dispose.call(this) - } - - RuleConditions.prototype.onDeleteCondition = function(event) { - var $el = $(event.target), - conditionId = getConditionIdFromElement($el) - - $el.request(this.options.deleteHandler, { - data: { current_condition_id: conditionId }, - confirm: 'Do you really want to delete this condition?' - }) - } - - RuleConditions.prototype.onCreateChildCondition = function(event) { - var $el = $(event.target), - conditionId = getConditionIdFromElement($el) - - $el.popup({ - handler: this.options.createHandler, - extraData: { current_condition_id: conditionId }, - size: 'large' - }) - - return false - } - - RuleConditions.prototype.onConditionsToggle = function(event) { - var $el = $(event.target), - $item = $el.closest('li'), - newStatusValue = $item.hasClass('collapsed') ? 0 : 1, - conditionId = getConditionIdFromElement($el) - - $el.request(this.options.collapseHandler, { - data: { - status: newStatusValue, - group: conditionId - } - }) - - if (newStatusValue) { - $el.parents('li:first').addClass('collapsed'); - } - else { - $el.parents('li:first').removeClass('collapsed'); - } - - return false - } - - RuleConditions.prototype.onShowNewConditionSettings = function(conditionId) { - var $el = $('[data-condition-id='+conditionId+']') - - $el.popup({ - handler: this.options.settingsHandler, - extraData: { current_condition_id: conditionId }, - size: 'large' - }) - - // This will not fire on successful save because the target element - // is replaced by the time the popup loader has finished to call it - $el.one('hide.oc.popup', this.proxy(this.onCancelCondition)) - } - - RuleConditions.prototype.onCancelCondition = function(event) { - var $el = $(event.target), - conditionId = getConditionIdFromElement($el) - - $el.request(this.options.cancelHandler, { - data: { new_condition_id: conditionId } - }) - - return false - } - - RuleConditions.prototype.onShowSettings = function(event) { - var $el = $(event.target), - conditionId = getConditionIdFromElement($el) - - $el.popup({ - handler: this.options.settingsHandler, - extraData: { current_condition_id: conditionId }, - size: 'large' - }) - - return false - } - - function getConditionIdFromElement($el) { - var $item = $el.closest('li.condition-item') - - return $item.data('condition-id') - } - - RuleConditions.DEFAULTS = { - collapseHandler: null, - settingsHandler: null, - deleteHandler: null, - cancelHandler: null, - createHandler: null - } - - // PLUGIN DEFINITION - // ============================ - - var old = $.fn.ruleConditions - - $.fn.ruleConditions = function (option) { - var args = Array.prototype.slice.call(arguments, 1), items, result - - items = this.each(function () { - var $this = $(this) - var data = $this.data('oc.ruleConditions') - var options = $.extend({}, RuleConditions.DEFAULTS, $this.data(), typeof option == 'object' && option) - if (!data) $this.data('oc.ruleConditions', (data = new RuleConditions(this, options))) - if (typeof option == 'string') result = data[option].apply(data, args) - if (typeof result != 'undefined') return false - }) - - return result ? result : items - } - - $.fn.ruleConditions.Constructor = RuleConditions - - $.fn.ruleConditions.noConflict = function () { - $.fn.ruleConditions = old - return this - } - - // Add this only if required - $(document).render(function (){ - $('[data-control="ruleconditions"]').ruleConditions() - }) - -}(window.jQuery); diff --git a/plugins/rainlab/notify/formwidgets/conditionbuilder/assets/js/conditions.multivalue.js b/plugins/rainlab/notify/formwidgets/conditionbuilder/assets/js/conditions.multivalue.js deleted file mode 100644 index f87e2f8..0000000 --- a/plugins/rainlab/notify/formwidgets/conditionbuilder/assets/js/conditions.multivalue.js +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Plugin definition - */ -+function ($) { "use strict"; - var Base = $.oc.foundation.base, - BaseProto = Base.prototype - - var ConditionMultiValue = function (element, options) { - this.$el = $(element) - this.options = options || {} - this.$template = $('[data-record-template]', this.$el) - this.$emptyTemplate = $('[data-empty-record-template]', this.$el) - this.$addedRecords = $('[data-added-records]', this.$el) - - $.oc.foundation.controlUtils.markDisposable(element) - Base.call(this) - - this.init() - this.recompileData() - } - - ConditionMultiValue.prototype = Object.create(BaseProto) - ConditionMultiValue.prototype.constructor = ConditionMultiValue - - ConditionMultiValue.prototype.init = function() { - this.$el.on('click', '[data-multivalue-add-record]', this.proxy(this.onAddRecord)) - this.$el.on('click', '[data-multivalue-remove-record]', this.proxy(this.onRemoveRecord)) - this.$el.one('dispose-control', this.proxy(this.dispose)) - } - - ConditionMultiValue.prototype.dispose = function() { - this.$el.off('click', '[data-multivalue-add-record]', this.proxy(this.onAddRecord)) - this.$el.off('click', '[data-multivalue-remove-record]', this.proxy(this.onRemoveRecord)) - this.$el.off('dispose-control', this.proxy(this.dispose)) - this.$el.removeData('oc.conditionMultiValue') - - this.$el = null - - // In some cases options could contain callbacks, - // so it's better to clean them up too. - this.options = null - - BaseProto.dispose.call(this) - } - - ConditionMultiValue.prototype.onAddRecord = function(event) { - var $el = $(event.target), - recordId = $el.closest('[data-record-key]').data('record-key'), - recordValue = $el.closest('a').data('record-value') - - if (!!$('[data-record-key='+recordId+']', this.$addedRecords).length) { - return - } - - this.$addedRecords.append(this.renderTemplate({ - key: recordId, - value: recordValue - })) - - this.recompileData() - } - - ConditionMultiValue.prototype.onRemoveRecord = function(event) { - var $el = $(event.target), - recordId = $el.closest('[data-record-key]').data('record-key') - - $('[data-record-key='+recordId+']', this.$addedRecords).remove() - - this.recompileData() - } - - ConditionMultiValue.prototype.recompileData = function(params) { - var $recordElements = $('[data-record-key]', this.$addedRecords), - hasData = !!$recordElements.length - - if (hasData) { - $('[data-no-record-data]', this.$addedRecords).remove() - } - else { - this.$addedRecords.append(this.renderEmptyTemplate()) - } - - if (this.options.dataLocker) { - var $locker = $(this.options.dataLocker), - selectedIds = [] - - $recordElements.each(function(key, record) { - selectedIds.push($(record).data('record-key')) - }) - - $locker.val(selectedIds.join(',')) - } - } - - ConditionMultiValue.prototype.renderTemplate = function(params) { - return Mustache.render(this.$template.html(), params) - } - - ConditionMultiValue.prototype.renderEmptyTemplate = function() { - return this.$emptyTemplate.html() - } - - ConditionMultiValue.DEFAULTS = { - dataLocker: null - } - - // PLUGIN DEFINITION - // ============================ - - var old = $.fn.conditionMultiValue - - $.fn.conditionMultiValue = function (option) { - var args = Array.prototype.slice.call(arguments, 1), items, result - - items = this.each(function () { - var $this = $(this) - var data = $this.data('oc.conditionMultiValue') - var options = $.extend({}, ConditionMultiValue.DEFAULTS, $this.data(), typeof option == 'object' && option) - if (!data) $this.data('oc.conditionMultiValue', (data = new ConditionMultiValue(this, options))) - if (typeof option == 'string') result = data[option].apply(data, args) - if (typeof result != 'undefined') return false - }) - - return result ? result : items - } - - $.fn.conditionMultiValue.Constructor = ConditionMultiValue - - $.fn.conditionMultiValue.noConflict = function () { - $.fn.conditionMultiValue = old - return this - } - - // Add this only if required - $(document).render(function (){ - $('[data-control="condition-multivalue"]').conditionMultiValue() - }) - -}(window.jQuery); diff --git a/plugins/rainlab/notify/formwidgets/conditionbuilder/assets/less/conditions.less b/plugins/rainlab/notify/formwidgets/conditionbuilder/assets/less/conditions.less deleted file mode 100644 index e406b20..0000000 --- a/plugins/rainlab/notify/formwidgets/conditionbuilder/assets/less/conditions.less +++ /dev/null @@ -1,286 +0,0 @@ -@import "../../../../../../../modules/backend/assets/less/core/boot.less"; - -// -// Conditions -// -------------------------------------------------- - -ul.condition-set { - padding: 5px 0 0; - margin: 0; - list-style: none; - - ul { - padding: 0; - margin: 0; - list-style: none; - } - - li { - margin: 0; - padding: 0; - } - - .condition-item { - border-radius: 4px; - - &.is-root { - border-radius: 0; - } - - &.is-inner {} - - &.collapsed { - .compound-content { - border-left-color: transparent !important; - } - - .condition-set { - display: none; - } - - &.is-inner .compound-add-item { - display: none; - } - } - - .condition-delete { - position: absolute; - display: block; - width: 10px; - height: 10px; - right: 7px; - top: 7px; - } - } - - // - // Collapse - // - - a.condition-collapse { - text-decoration: none; - display: block; - position: absolute; - right: 8px; - top: 2px; - - > i { - .transition(~'transform 0.3s'); - width: 15px; - height: 15px; - color: #bdc3c7; - font-size: 12px; - display: block; - } - - &:hover { - > i { - color: #999; - } - } - } - - li.collapsed a.condition-collapse { - > i { - .transform(scale(1,-1)); - } - } - - // - // Joins - // - - .compound-join { - text-align: center; - padding: 3px 0 2px 0; - a { - color: #333333; - text-decoration: none; - &:hover { - text-decoration: underline; - } - } - } - - // - // Single - // - - .condition-item.is-single { - padding: 8px 20px 9px 24px; - background: #fff; - border: 1px solid #eee; - position: relative; - - &:before { - .icon(@code-fork); - line-height: 100%; - font-size: 16px; - color: #bdc3c7; - - position: absolute; - width: 15px; - height: 15px; - left: 12px; - top: 11px; - } - - .condition-text { - padding-left: 10px; - - a { - color: #333333; - text-decoration: none; - &:hover { - text-decoration: underline; - } - - span.operator { - font-weight: 500; - } - } - } - - a.condition-delete { - right: 12px; - top: 9px; - } - } - - // - // Compound - // - - .condition-item.is-compound { - .compound-content { - position: relative; - border-left: 1px solid #dbdee0; - margin-left: 5px; - - &:before { - color: #bdc3c7; - .icon(@circle); - font-size: 8px; - position: absolute; - left: -4px; - top: -2px; - } - - h4 { - padding: 0 30px 5px 5px; - margin: 0; - position: relative; - top: -5px; - font-size: 13px; - line-height: 130%; - font-weight: 400; - color: #666; - a.condition-text { - color: #333333; - padding-left: 10px; - &:hover { - text-decoration: underline; - } - } - } - - .condition-set { - padding-left: 15px; - } - } - - .condition-item.is-compound { - - } - - .compound-add-item { - position: relative; - margin-top: 10px; - margin-left: 20px; - border: 2px dotted #e0e0e0; - border-radius: 5px; - - &:before { - color: #bdc3c7; - .icon(@plus); - font-size: 16px; - position: absolute; - left: -23px; - top: -11px; - } - - > a { - color: #bdc3c7; - text-align: center; - display: block; - text-decoration: none; - padding: 13px 15px; - text-transform: uppercase; - font-weight: 600; - font-size: @font-size-base - 2; - } - - &:hover, &:focus { - background-color: @highlight-hover-bg; - border-color: @highlight-hover-bg; - - &:before { - color: #999; - } - - > a { - color: @highlight-hover-text; - } - } - - &:active { - background: @highlight-active-bg; - border-color: @highlight-active-bg; - > a { - color: @highlight-active-text; - } - } - } - } - - // - // Compound (Inner) - // - - .condition-item.is-compound.is-inner { - padding-right: 20px; - - a.condition-delete-compound { - right: -7px; - top: 0; - } - } -} - -// -// Multi value -// - -.condition-multi-value { - .condition-filter-search { - background-position: right -81px !important; - border-top: none !important; - border-left: none !important; - border-right: none !important; - border-radius: 0; - padding-left: 20px; - } - - .filter-list { - margin: 0 -20px; - - .list-footer { - padding-top: 0; - padding-bottom: 0; - } - } - - .added-filter-list { - margin: 0 -20px; - } -} diff --git a/plugins/rainlab/notify/formwidgets/conditionbuilder/partials/_condition.htm b/plugins/rainlab/notify/formwidgets/conditionbuilder/partials/_condition.htm deleted file mode 100644 index ab063a6..0000000 --- a/plugins/rainlab/notify/formwidgets/conditionbuilder/partials/_condition.htm +++ /dev/null @@ -1,99 +0,0 @@ -isCompound(); - $isRoot = $treeLevel == 0; - $collapsed = $this->getCollapseStatus($condition->id, false); -?> -
  • - - - -
    -

    - - - - - - getCacheConditionText($condition)) ?> - - - - - - -

    -
      - children()->withDeferred($this->sessionKey.'_'.$condition->id)->get(); - $lastIndex = $children->count() - 1; - ?> - $childCondition): ?> - makePartial('condition', [ - 'condition' => $childCondition, - 'treeLevel' => $treeLevel + 1, - 'parentCondition' => $condition - ]) ?> - -
    • - - getCacheConditionJoinText($condition)) ?> - -
    • - - -
    -
    - - - - - - - - - - - - - - - - - - -
  • diff --git a/plugins/rainlab/notify/formwidgets/conditionbuilder/partials/_condition_settings_form.htm b/plugins/rainlab/notify/formwidgets/conditionbuilder/partials/_condition_settings_form.htm deleted file mode 100644 index 9d47550..0000000 --- a/plugins/rainlab/notify/formwidgets/conditionbuilder/partials/_condition_settings_form.htm +++ /dev/null @@ -1,68 +0,0 @@ - 'propertyForm']) ?> - - - - fatalError): ?> - - - - - - - - - - - - - - - - diff --git a/plugins/rainlab/notify/formwidgets/conditionbuilder/partials/_conditions.htm b/plugins/rainlab/notify/formwidgets/conditionbuilder/partials/_conditions.htm deleted file mode 100644 index 8cc8c4b..0000000 --- a/plugins/rainlab/notify/formwidgets/conditionbuilder/partials/_conditions.htm +++ /dev/null @@ -1,10 +0,0 @@ - - - - - diff --git a/plugins/rainlab/notify/formwidgets/conditionbuilder/partials/_conditions_container.htm b/plugins/rainlab/notify/formwidgets/conditionbuilder/partials/_conditions_container.htm deleted file mode 100644 index b11c83f..0000000 --- a/plugins/rainlab/notify/formwidgets/conditionbuilder/partials/_conditions_container.htm +++ /dev/null @@ -1,13 +0,0 @@ -
    -
    - makePartial('conditions', ['condition' => $rootCondition]) ?> -
    -
    diff --git a/plugins/rainlab/notify/formwidgets/conditionbuilder/partials/_create_child_form.htm b/plugins/rainlab/notify/formwidgets/conditionbuilder/partials/_create_child_form.htm deleted file mode 100644 index f7d0d8b..0000000 --- a/plugins/rainlab/notify/formwidgets/conditionbuilder/partials/_create_child_form.htm +++ /dev/null @@ -1,67 +0,0 @@ - 'propertyForm']) ?> - - - - fatalError): ?> - - - - - - - - - - - - - - - diff --git a/plugins/rainlab/notify/interfaces/Action.php b/plugins/rainlab/notify/interfaces/Action.php deleted file mode 100644 index 011cc13..0000000 --- a/plugins/rainlab/notify/interfaces/Action.php +++ /dev/null @@ -1,31 +0,0 @@ - [ - 'name' => 'Notify', - 'description' => 'Notification services', - ], - 'notifications' => [ - 'menu_label' => 'Notification rules', - 'menu_description' => 'Manage the events and actions that trigger notifications.', - 'name' => 'Name', - 'code' => 'Code', - 'notification_rule' => 'Notification rule', - 'add_notification_rule' => 'Add notification rule', - ], - 'action' => [ - 'add_notification_action' => 'Add notification action', - ], - 'permissions' => [ - 'manage_notifications' => 'Notifications management', - ], -]; diff --git a/plugins/rainlab/notify/lang/ro/lang.php b/plugins/rainlab/notify/lang/ro/lang.php deleted file mode 100644 index cfe1153..0000000 --- a/plugins/rainlab/notify/lang/ro/lang.php +++ /dev/null @@ -1,22 +0,0 @@ - [ - 'name' => 'Notificari', - 'description' => 'Servicii notificari', - ], - 'notifications' => [ - 'menu_label' => 'Reguli notificari', - 'menu_description' => 'Gestionati evenimentele si actiunile care declanșează notificari', - 'name' => 'Nume', - 'code' => 'Cod', - 'notification_rule' => 'Regula notificare', - 'add_notification_rule' => 'Adauga o regula pentru notificare', - ], - 'action' => [ - 'add_notification_action' => 'Adauga o actiune pentru notificare', - ], - 'permissions' => [ - 'manage_notifications' => 'Managementul notificarilor', - ], -]; diff --git a/plugins/rainlab/notify/lang/ru/lang.php b/plugins/rainlab/notify/lang/ru/lang.php deleted file mode 100644 index 1ce8b27..0000000 --- a/plugins/rainlab/notify/lang/ru/lang.php +++ /dev/null @@ -1,22 +0,0 @@ - [ - 'name' => 'Уведомления', - 'description' => 'Службы уведомлений', - ], - 'notifications' => [ - 'menu_label' => 'Правила уведомлений', - 'menu_description' => 'Управление событиями и действиями, которые вызывают уведомления.', - 'name' => 'Название', - 'code' => 'Код', - 'notification_rule' => 'Правило уведомления', - 'add_notification_rule' => 'Добавить правило', - ], - 'action' => [ - 'add_notification_action' => 'Добавить действие', - ], - 'permissions' => [ - 'manage_notifications' => 'Управление уведомлениями', - ], -]; diff --git a/plugins/rainlab/notify/lang/sl/lang.php b/plugins/rainlab/notify/lang/sl/lang.php deleted file mode 100644 index addc3ea..0000000 --- a/plugins/rainlab/notify/lang/sl/lang.php +++ /dev/null @@ -1,22 +0,0 @@ - [ - 'name' => 'Obvestila', - 'description' => 'Storitve obveščanja', - ], - 'notifications' => [ - 'menu_label' => 'Nastavitve obveščanja', - 'menu_description' => 'Upravljanje dogodkov in dejanj, ki prožijo obvestila.', - 'name' => 'Ime', - 'code' => 'Koda', - 'notification_rule' => 'Pravilo obveščanja', - 'add_notification_rule' => 'Dodaj pravilo obveščanja', - ], - 'action' => [ - 'add_notification_action' => 'Dodaj dejanje obveščanja', - ], - 'permissions' => [ - 'manage_notifications' => 'Upravljanje z nastavitvami obveščanja', - ], -]; diff --git a/plugins/rainlab/notify/lang/tr/lang.php b/plugins/rainlab/notify/lang/tr/lang.php deleted file mode 100644 index b64f80b..0000000 --- a/plugins/rainlab/notify/lang/tr/lang.php +++ /dev/null @@ -1,22 +0,0 @@ - [ - 'name' => 'Bildirim', - 'description' => 'Bildirim Servisi', - ], - 'notifications' => [ - 'menu_label' => 'Bildirim kuralları', - 'menu_description' => 'Bildirimleri tetikleyen olayları ve eylemleri yönetin.', - 'name' => 'İsim', - 'code' => 'Kod', - 'notification_rule' => 'Bildirim kuralı', - 'add_notification_rule' => 'Bildirim kuralı ekle', - ], - 'action' => [ - 'add_notification_action' => 'Bildirim eylemi ekle', - ], - 'permissions' => [ - 'manage_notifications' => 'Bildirim yönetimi', - ], -]; diff --git a/plugins/rainlab/notify/lang/zh-tw/lang.php b/plugins/rainlab/notify/lang/zh-tw/lang.php deleted file mode 100644 index bd5e943..0000000 --- a/plugins/rainlab/notify/lang/zh-tw/lang.php +++ /dev/null @@ -1,22 +0,0 @@ - [ - 'name' => '通知', - 'description' => '通知系統', - ], - 'notifications' => [ - 'menu_label' => '通知規則', - 'menu_description' => '管理觸發通知的事件及動作。', - 'name' => '名稱', - 'code' => '代碼', - 'notification_rule' => '通知規則', - 'add_notification_rule' => '新增通知規則', - ], - 'action' => [ - 'add_notification_action' => '新增通知動作', - ], - 'permissions' => [ - 'manage_notifications' => '管理通知功能', - ], -]; diff --git a/plugins/rainlab/notify/models/Notification.php b/plugins/rainlab/notify/models/Notification.php deleted file mode 100644 index 57aa20c..0000000 --- a/plugins/rainlab/notify/models/Notification.php +++ /dev/null @@ -1,249 +0,0 @@ - [], - ]; - - /** - * Mark the notification as read. - * - * @return void - */ - public function markAsRead() - { - if (is_null($this->read_at)) { - $this->forceFill(['read_at' => $this->freshTimestamp()])->save(); - } - } - - /** - * Determine if a notification has been read. - * - * @return bool - */ - public function read() - { - return $this->read_at !== null; - } - - /** - * Determine if a notification has not been read. - * - * @return bool - */ - public function unread() - { - return $this->read_at === null; - } - - /** - * Get the entity's unread notifications. - */ - public function scopeApplyUnread($query) - { - return $query->whereNull('read_at'); - } - - /** - * Get the entity's read notifications. - */ - public function scopeApplyRead($query) - { - return $query->whereNotNull('read_at'); - } - - /** - * Get the parsed body of the announcement. - * - * @return string - */ - public function getParsedBodyAttribute() - { - return Markdown::parse($this->body); - } - - /** - * Get the description of the notification - * - * @return string - */ - public function getDescriptionAttribute() - { - $e = new $this->event_type; - - if($e instanceof MessageReceivedEvent) { - - return trans('validation.new_message'); - - } elseif($e instanceof ProductReviewedEvent) { - - return trans('validation.product_reviewed'); - - } elseif($e instanceof PaymentReviewedEvent) { - - return trans('validation.payment_reviewed'); - } elseif($e instanceof PaymentGiftedEvent) { - - return trans('validation.payment_gifted'); - } - - return 'Unknown type notification'; - } - - /** - * Get the localized description of the notification for api - * - * @return string - */ - public function getDescriptionForApiAttribute() - { - $e = new $this->event_type; - - if($e instanceof MessageReceivedEvent) { - - return [ - 'ru' => trans('validation.new_message', [], 'ru'), - 'en' => trans('validation.new_message', [], 'en'), - 'tm' => trans('validation.new_message', [], 'tm'), - ]; - - } elseif($e instanceof ProductReviewedEvent) { - - return [ - 'ru' => trans('validation.product_reviewed', [], 'ru'), - 'en' => trans('validation.product_reviewed', [], 'en'), - 'tm' => trans('validation.product_reviewed', [], 'tm'), - ]; - - } elseif($e instanceof PaymentReviewedEvent) { - - return [ - 'ru' => trans('validation.payment_reviewed', [], 'ru'), - 'en' => trans('validation.payment_reviewed', [], 'en'), - 'tm' => trans('validation.payment_reviewed', [], 'tm'), - ]; - } elseif($e instanceof PaymentGiftedEvent) { - - return [ - 'ru' => trans('validation.payment_gifted', [], 'ru'), - 'en' => trans('validation.payment_gifted', [], 'en'), - 'tm' => trans('validation.payment_gifted', [], 'tm'), - ]; - } - - return 'Unknown type notification'; - } - - /** - * Get the screen where to redirect when clicking on the notification - * - * @return string - */ - public function getRedirectToScreenForApiAttribute() - { - $e = new $this->event_type; - - if($e instanceof MessageReceivedEvent) { - - return 'messages_screen'; - - } elseif($e instanceof ProductReviewedEvent) { - - return 'my_posts_screen'; - - } elseif($e instanceof PaymentReviewedEvent) { - - return 'balance_history_screen'; - - } elseif($e instanceof PaymentGiftedEvent) { - - return 'balance_history_screen'; - - } - - return 'main_screen'; - } - - /** - * Get the link where to redirect when the notification is clicked - * - * @return string - */ - public function getLinkAttribute() - { - $e = new $this->event_type; - - if($e instanceof MessageReceivedEvent) { - - return \Url::to('/messages'); - - } elseif($e instanceof ProductReviewedEvent) { - - return \Url::to('/my-posts'); - - } elseif($e instanceof PaymentReviewedEvent) { - - return \Url::to('/balans-taryhy'); - } elseif($e instanceof PaymentGiftedEvent) { - - return \Url::to('/balans-taryhy'); - } - - return \Url::to('/'); - } -} diff --git a/plugins/rainlab/notify/models/NotificationRule.php b/plugins/rainlab/notify/models/NotificationRule.php deleted file mode 100644 index 8db57a4..0000000 --- a/plugins/rainlab/notify/models/NotificationRule.php +++ /dev/null @@ -1,289 +0,0 @@ - 'required' - ]; - - /** - * @var array Relations - */ - public $hasMany = [ - 'rule_conditions' => [ - RuleCondition::class, - 'key' => 'rule_host_id', - 'conditions' => 'rule_parent_id is null', - 'delete' => true - ], - 'rule_actions' => [ - RuleAction::class, - 'key' => 'rule_host_id', - 'delete' => true - ], - ]; - - /** - * Kicks off this notification rule, fires the event to obtain its parameters, - * checks the rule conditions evaluate as true, then spins over each action. - */ - public function triggerRule() - { - $params = $this->getEventObject()->getParams(); - $rootCondition = $this->rule_conditions->first(); - - if ($rootCondition && !$rootCondition->getConditionObject()->isTrue($params)) { - return false; - } - - foreach ($this->rule_actions as $action) { - $action->setRelation('notification_rule', $this); - $action->triggerAction($params); - } - } - - /** - * Returns extra conditions provided by the event. - * @return array - */ - public function getExtraConditionRules() - { - $rules = []; - - $classes = $this->getEventObject()->defineConditions(); - - foreach ($classes as $class) { - $rules[$class] = new $class; - } - - return $rules; - } - - /** - * Extends this class with the event class - * @param string $class Class name - * @return boolean - */ - public function applyEventClass($class = null) - { - if (!$class) { - $class = $this->class_name; - } - - if (!$class) { - return false; - } - - if (!$this->isClassExtendedWith($class)) { - $this->extendClassWith($class); - } - - $this->class_name = $class; - $this->event_name = Lang::get(array_get($this->eventDetails(), 'name', 'Unknown')); - return true; - } - - /** - * Returns the event class extension object. - * @return \RainLab\Notify\Classes\NotificationEvent - */ - public function getEventObject() - { - $this->applyEventClass(); - - return $this->asExtension($this->getEventClass()); - } - - public function getEventClass() - { - return $this->class_name; - } - - // - // Events - // - - public function afterFetch() - { - $this->applyEventClass(); - } - - public function beforeValidate() - { - if (!$this->applyEventClass()) { - return; - } - } - - // - // Scopes - // - - public function scopeApplyEnabled($query) - { - return $query->where('is_enabled', true); - } - - public function scopeApplyClass($query, $class) - { - if (!is_string($class)) { - $class = get_class($class); - } - - return $query->where('class_name', $class); - } - - // - // Presets - // - - /** - * Returns an array of rule codes and descriptions. - * @return array - */ - public static function listRulesForEvent($eventClass) - { - $results = []; - - $dbRules = self::applyClass($eventClass)->get(); - $presets = (array) EventBase::findEventPresetsByClass($eventClass); - - foreach ($dbRules as $dbRule) { - if ($dbRule->code) { - unset($presets[$dbRule->code]); - } - - if ($dbRule->is_enabled) { - $results[] = $dbRule; - } - } - - foreach ($presets as $code => $preset) { - if ($newPreset = self::createFromPreset($code, $preset)) { - $results[] = $newPreset; - } - } - - return $results; - } - - /** - * Syncronise all file-based presets to the database. - * @return void - */ - public static function syncAll() - { - $presets = (array) EventBase::findEventPresets(); - $dbRules = self::where('code', '!=', '')->whereNotNull('code')->lists('is_custom', 'code'); - $newRules = array_diff_key($presets, $dbRules); - - /* - * Clean up non-customized templates - */ - foreach ($dbRules as $code => $isCustom) { - if ($isCustom) { - continue; - } - - if (!array_key_exists($code, $presets) && ($record = self::whereCode($code)->first())) { - $record->delete(); - } - } - - /* - * Create new rules - */ - foreach ($newRules as $code => $preset) { - self::createFromPreset($code, $preset); - } - } - - public static function createFromPreset($code, $preset) - { - $actions = array_get($preset, 'items'); - if (!$actions || !is_array($actions)) { - return; - } - - $newRule = new self; - $newRule->code = $code; - $newRule->is_enabled = 1; - $newRule->is_custom = 0; - $newRule->name = array_get($preset, 'name'); - $newRule->class_name = array_get($preset, 'event'); - $newRule->forceSave(); - - // Add the actions - foreach ($actions as $action) { - $params = array_except($action, 'action'); - - $newAction = new RuleAction; - $newAction->class_name = array_get($action, 'action'); - $newAction->notification_rule = $newRule; - $newAction->fill($params); - $newAction->forceSave(); - } - - // Add the conditions - $conditions = array_get($preset, 'conditions'); - if (!$conditions || !is_array($conditions)) { - return $newRule; - } - - // Create the root condition - $rootCondition = new RuleCondition(); - $rootCondition->rule_host_type = ConditionBase::TYPE_ANY; - $rootCondition->class_name = $rootCondition->getRootConditionClass(); - $rootCondition->notification_rule = $newRule; - $rootCondition->save(); - - // Add the sub conditions - foreach ($conditions as $condition) { - $params = array_except($condition, 'condition'); - $newCondition = new RuleCondition(); - $newCondition->class_name = array_get($condition, 'condition'); - $newCondition->parent = $rootCondition; - $newCondition->fill($params); - $newCondition->forceSave(); - } - - return $newRule; - } -} diff --git a/plugins/rainlab/notify/models/RuleAction.php b/plugins/rainlab/notify/models/RuleAction.php deleted file mode 100644 index 21a621f..0000000 --- a/plugins/rainlab/notify/models/RuleAction.php +++ /dev/null @@ -1,164 +0,0 @@ - [NotificationRule::class, 'key' => 'rule_host_id'], - ]; - - public function triggerAction($params) - { - try { - $this->getActionObject()->triggerAction($params); - } - catch (Exception $ex) { - // We could log the error here, for now we should suppress - // any exceptions to let other actions proceed as normal - traceLog('Error with ' . $this->getActionClass()); - traceLog($ex); - } - } - - /** - * Extends this model with the action class - * @param string $class Class name - * @return boolean - */ - public function applyActionClass($class = null) - { - if (!$class) { - $class = $this->class_name; - } - - if (!$class) { - return false; - } - - if (!$this->isClassExtendedWith($class)) { - $this->extendClassWith($class); - } - - $this->class_name = $class; - return true; - } - - public function beforeSave() - { - $this->setCustomData(); - } - - public function afterSave() - { - // Make sure that this record is removed from the DB after being removed from a rule - $removedFromRule = $this->rule_host_id === null && $this->getOriginal('rule_host_id'); - if ($removedFromRule && !$this->notification_rule()->withDeferred(post('_session_key'))->exists()) { - $this->delete(); - } - } - - public function applyCustomData() - { - $this->setCustomData(); - $this->loadCustomData(); - } - - protected function loadCustomData() - { - $this->setRawAttributes((array) $this->getAttributes() + (array) $this->config_data, true); - } - - protected function setCustomData() - { - if (!$actionObj = $this->getActionObject()) { - throw new SystemException(sprintf('Unable to find action object [%s]', $this->getActionClass())); - } - - /* - * Spin over each field and add it to config_data - */ - $config = $actionObj->getFieldConfig(); - - /* - * Action class has no fields - */ - if (!isset($config->fields)) { - return; - } - - $staticAttributes = ['action_text']; - - $fieldAttributes = array_merge($staticAttributes, array_keys($config->fields)); - - $dynamicAttributes = array_only($this->getAttributes(), $fieldAttributes); - - $this->config_data = $dynamicAttributes; - - $this->setRawAttributes(array_except($this->getAttributes(), $fieldAttributes)); - } - - public function afterFetch() - { - $this->applyActionClass(); - $this->loadCustomData(); - } - - public function getText() - { - if (strlen($this->action_text)) { - return $this->action_text; - } - - if ($actionObj = $this->getActionObject()) { - return $actionObj->getText(); - } - } - - public function getActionObject() - { - $this->applyActionClass(); - - return $this->asExtension($this->getActionClass()); - } - - public function getActionClass() - { - return $this->class_name; - } -} diff --git a/plugins/rainlab/notify/models/RuleCondition.php b/plugins/rainlab/notify/models/RuleCondition.php deleted file mode 100644 index 0282748..0000000 --- a/plugins/rainlab/notify/models/RuleCondition.php +++ /dev/null @@ -1,172 +0,0 @@ - [self::class, 'key' => 'rule_parent_id', 'delete' => true], - ]; - - public $belongsTo = [ - 'parent' => [self::class, 'key' => 'rule_parent_id'], - 'notification_rule' => [NotificationRule::class, 'key'=>'rule_host_id'] - ]; - - public function filterFields($fields, $context) - { - /* - * Let the condition contribute - */ - $this->getConditionObject()->setFormFields($fields); - } - - /** - * Extends this model with the condition class - * @param string $class Class name - * @return boolean - */ - public function applyConditionClass($class = null) - { - if (!$class) { - $class = $this->class_name; - } - - if (!$class) { - return false; - } - - if (!$this->isClassExtendedWith($class)) { - $this->extendClassWith($class); - } - - $this->class_name = $class; - return true; - } - - public function beforeSave() - { - $this->setCustomData(); - } - - public function applyCustomData() - { - $this->setCustomData(); - $this->loadCustomData(); - } - - protected function loadCustomData() - { - $this->setRawAttributes((array) $this->getAttributes() + (array) $this->config_data, true); - } - - protected function setCustomData() - { - /* - * Let the condition contribute - */ - $this->getConditionObject()->setCustomData($this); - - /* - * Spin over each field and add it to config_data - */ - $config = $this->getFieldConfig(); - - if (!isset($config->fields)) { - throw new SystemException('Condition class has no fields.'); - } - - $staticAttributes = ['condition_text']; - - $fieldAttributes = array_merge($staticAttributes, array_keys($config->fields)); - - $dynamicAttributes = array_only($this->getAttributes(), $fieldAttributes); - - $this->config_data = $dynamicAttributes; - - $this->setRawAttributes(array_except($this->getAttributes(), $fieldAttributes)); - } - - public function afterFetch() - { - $this->applyConditionClass(); - $this->loadCustomData(); - } - - public function afterSave() - { - // Make sure that this record is removed from the DB after being removed from a rule - $removedFromRule = $this->rule_parent_id === null && $this->getOriginal('rule_parent_id'); - if ($removedFromRule && !$this->notification_rule()->withDeferred(post('_session_key'))->exists()) { - $this->delete(); - } - } - - public function getText() - { - if (strlen($this->condition_text)) { - return $this->condition_text; - } - - if ($conditionObj = $this->getConditionObject()) { - return $conditionObj->getText(); - } - } - - public function isCompound() - { - return $this->getConditionObject() instanceof CompoundConditionInterface; - } - - public function getConditionObject() - { - $this->applyConditionClass(); - - return $this->asExtension($this->getConditionClass()); - } - - public function getConditionClass() - { - return $this->class_name; - } - - public function getRootConditionClass() - { - return CompoundCondition::class; - } -} diff --git a/plugins/rainlab/notify/models/notificationrule/columns.yaml b/plugins/rainlab/notify/models/notificationrule/columns.yaml deleted file mode 100644 index 6da7d0f..0000000 --- a/plugins/rainlab/notify/models/notificationrule/columns.yaml +++ /dev/null @@ -1,13 +0,0 @@ -# =================================== -# Column Definitions -# =================================== - -columns: - - name: - label: rainlab.notify::lang.notifications.name - searchable: true - - code: - label: rainlab.notify::lang.notifications.code - searchable: true diff --git a/plugins/rainlab/notify/models/notificationrule/fields.yaml b/plugins/rainlab/notify/models/notificationrule/fields.yaml deleted file mode 100644 index b0eec2a..0000000 --- a/plugins/rainlab/notify/models/notificationrule/fields.yaml +++ /dev/null @@ -1,47 +0,0 @@ -# =================================== -# Field Definitions -# =================================== - -fields: - name: - label: Name - placeholder: New notification rule name - attributes: - autofocus: 1 - - toolbar: - type: partial - path: form_toolbar - cssClass: collapse-visible - -tabs: - stretch: true - cssClass: master-area - paneCssClass: - 'Actions': 'pane-compact' - - fields: - rule_actions: - type: RainLab\Notify\FormWidgets\ActionBuilder - tab: Actions - - rule_conditions: - type: RainLab\Notify\FormWidgets\ConditionBuilder - tab: Conditions - - is_enabled: - label: Active - type: checkbox - tab: Settings - default: true - - description: - label: Description - type: textarea - size: tiny - tab: Settings - - code: - label: API Code - span: auto - tab: Settings diff --git a/plugins/rainlab/notify/models/ruleaction/columns.yaml b/plugins/rainlab/notify/models/ruleaction/columns.yaml deleted file mode 100644 index b11160b..0000000 --- a/plugins/rainlab/notify/models/ruleaction/columns.yaml +++ /dev/null @@ -1,8 +0,0 @@ -# =================================== -# List Column Definitions -# =================================== - -columns: - id: - label: ID - searchable: true diff --git a/plugins/rainlab/notify/models/ruleaction/fields.yaml b/plugins/rainlab/notify/models/ruleaction/fields.yaml deleted file mode 100644 index c611f31..0000000 --- a/plugins/rainlab/notify/models/ruleaction/fields.yaml +++ /dev/null @@ -1,8 +0,0 @@ -# =================================== -# Form Field Definitions -# =================================== - -fields: - id: - label: ID - disabled: true diff --git a/plugins/rainlab/notify/notifyrules/ExecutionContextCondition.php b/plugins/rainlab/notify/notifyrules/ExecutionContextCondition.php deleted file mode 100644 index 32369ca..0000000 --- a/plugins/rainlab/notify/notifyrules/ExecutionContextCondition.php +++ /dev/null @@ -1,136 +0,0 @@ - 'is', - 'is_not' => 'is not', - ]; - - public function getName() - { - return 'Event is triggered from environment'; - } - - public function getTitle() - { - return 'Execution context'; - } - - public function getText() - { - $host = $this->host; - $value = $host->value; - $attribute = $host->subcondition; - $subconditions = $this->getSubconditionOptions(); - - $result = array_get($subconditions, $attribute, 'Execution context'); - $result .= ' '.array_get($this->operators, $host->operator, $host->operator).' '; - - if ($attribute == 'locale' || $attribute == 'environment') { - $result .= strtolower($value) ?: '?'; - } - elseif ($value) { - $options = $this->getValueOptions(); - $result .= strtolower(array_get($options, $value)); - } - else { - $result .= '?'; - } - - return $result; - } - - /** - * Returns a title to use for grouping subconditions - * in the Create Condition drop-down menu - */ - public function getGroupingTitle() - { - return 'Execution context'; - } - - public function listSubconditions() - { - return array_flip($this->getSubconditionOptions()); - } - - public function initConfigData($host) - { - $host->operator = 'is'; - } - - public function setFormFields($fields) - { - $attribute = $fields->subcondition->value; - - if ($attribute == 'locale' || $attribute == 'environment') { - $fields->value->type = 'text'; - } - else { - $fields->value->type = 'dropdown'; - } - } - - public function getValueOptions() - { - $attribute = $this->host->subcondition; - $result = []; - - if ($attribute == 'context') { - $result = [ - 'backend' => 'Back-end area', - 'front' => 'Front-end website', - 'console' => 'Command line interface', - ]; - } - - if ($attribute == 'theme') { - foreach (Theme::all() as $theme) { - $result[$theme->getDirName()] = $theme->getDirName(); - } - } - - return $result; - } - - public function getSubconditionOptions() - { - return [ - 'environment' => 'Application environment', - 'context' => 'Request context', - 'theme' => 'Active theme', - 'locale' => 'Visitor locale', - ]; - } - - public function getOperatorOptions() - { - return $this->operators; - } - - /** - * Checks whether the condition is TRUE for specified parameters - * @param array $params - * @return bool - */ - public function isTrue(&$params) - { - $hostObj = $this->host; - $attribute = $hostObj->subcondition; - - $conditionValue = $hostObj->value; - $conditionValue = trim(mb_strtolower($conditionValue)); - - if ($attribute == 'locale') { - return array_get($params, 'appLocale') == $conditionValue; - } else if ($attribute === 'environment') { - return $conditionValue === \App::environment(); - } - - return false; - } -} diff --git a/plugins/rainlab/notify/notifyrules/SaveDatabaseAction.php b/plugins/rainlab/notify/notifyrules/SaveDatabaseAction.php deleted file mode 100644 index 44e8415..0000000 --- a/plugins/rainlab/notify/notifyrules/SaveDatabaseAction.php +++ /dev/null @@ -1,125 +0,0 @@ - 'Store in database', - 'description' => 'Log event data in the notifications activity log', - 'icon' => 'icon-database' - ]; - } - - public function defineFormFields() - { - return 'fields.yaml'; - } - - public function getText() - { - if ($this->host->related_object) { - $label = array_get($this->getRelatedObjectOptions(), $this->host->related_object); - - return 'Log event in the '.$label.' log'; - } - - return parent::getText(); - } - - /** - * Triggers this action. - * @param array $params - * @return void - */ - public function triggerAction($params) - { - if ( - (!$definition = array_get($this->tableDefinitions, $this->host->related_object)) || - (!$param = array_get($definition, 'param', 'user')) || - (!$value = array_get($params, $param)) - ) { - throw new ApplicationException('Error evaluating the save database action: the related object is not found in the action parameters.'); - } - - if (!$value instanceof EloquentModel) { - // @todo Perhaps value is an ID or a model array, - // look up model $definition[class] from ID ... - $model = array_get($definition,'class', User::class); - $value = $model::find($value); - - } - - $rule = $this->host->notification_rule; - $relation = array_get($definition, 'relation', 'notifications'); - - $value->$relation()->create([ - 'id' => Uuid::uuid4()->toString(), - 'event_type' => $rule->getEventClass(), - 'icon' => $this->host->icon, - 'type' => $this->host->type, - 'body' => $this->host->body, - 'data' => $this->getData($params), - 'read_at' => null, - ]); - } - - /** - * Get the data for the notification. - * - * @param array $notifiable - * @return array - */ - protected function getData($params) - { - // This should check for params that cannot be jsonable. - return $params; - } - - public function getRelatedObjectOptions() - { - $result = []; - - foreach ($this->tableDefinitions as $key => $definition) { - $result[$key] = array_get($definition, 'label'); - } - - return $result; - } - - public function getTableDefinitions() - { - return $this->tableDefinitions; - } - - public function addTableDefinition($options) - { - if (!$className = array_get($options, 'class')) { - throw new ApplicationException('Missing class name from table definition.'); - } - - $options = array_merge([ - 'label' => 'Undefined table', - 'class' => null, - 'param' => null, - 'relation' => 'notifications', - ], $options); - - $keyName = $className . '@' . array_get($options, 'relation'); - - $this->tableDefinitions[$keyName] = $options; - } -} diff --git a/plugins/rainlab/notify/notifyrules/SendMailTemplateAction.php b/plugins/rainlab/notify/notifyrules/SendMailTemplateAction.php deleted file mode 100644 index 231c9c9..0000000 --- a/plugins/rainlab/notify/notifyrules/SendMailTemplateAction.php +++ /dev/null @@ -1,223 +0,0 @@ - 'System default', - 'user' => 'User email address (if applicable)', - 'sender' => 'Sender user email address (if applicable)', - 'admin' => 'Back-end administrators', - 'custom' => 'Specific email address', - ]; - - /** - * Returns information about this event, including name and description. - */ - public function actionDetails() - { - return [ - 'name' => 'Compose a mail message', - 'description' => 'Send a message to a recipient', - 'icon' => 'icon-envelope' - ]; - } - - /** - * Triggers this action. - * @param array $params - * @return void - */ - public function triggerAction($params) - { - if($this->host->send_to_mode == 'user' && $params['user']) { - if(!$params['user']['email_verified']) - return; - } - $template = $this->host->mail_template; - - $recipient = $this->getRecipientAddress($params); - - $replyTo = $this->getReplyToAddress($params); - - if (!$recipient || !$template) { - throw new ApplicationException('Missing valid recipient or mail template'); - } - - Mail::sendTo($recipient, $template, $params, function($message) use ($replyTo) { - if ($replyTo) { - $message->replyTo($replyTo); - } - }); - } - - /** - * Field configuration for the action. - */ - public function defineFormFields() - { - return 'fields.yaml'; - } - - /** - * Defines validation rules for the custom fields. - * @return array - */ - public function defineValidationRules() - { - return [ - 'mail_template' => 'required', - 'send_to_mode' => 'required', - ]; - } - - public function getTitle() - { - if ($this->isAdminMode()) { - return 'Compose mail to administrators'; - } - - return parent::getTitle(); - } - - public function getActionIcon() - { - if ($this->isAdminMode()) { - return 'icon-envelope-square'; - } - - return parent::getActionIcon(); - } - - public function getText() - { - $hostObj = $this->host; - - $recipient = array_get($this->recipientModes, $hostObj->send_to_mode); - - if ($this->isAdminMode()) { - if ($groupId = $this->host->send_to_admin) { - if ($group = AdminGroupModel::find($groupId)) { - $adminText = $group->name; - } - else { - $adminText = '?'; - } - - $adminText .= ' admin group'; - } - else { - $adminText = 'all admins'; - } - return sprintf( - 'Send a message to %s using template %s', - $adminText, - $hostObj->mail_template - ); - } - - if ($hostObj->mail_template) { - return sprintf( - 'Send a message to %s using template %s', - mb_strtolower($recipient), - $hostObj->mail_template - ); - } - - return parent::getText(); - } - - public function getSendToAdminOptions() - { - $options = ['' => '- All administrators -']; - - $groups = AdminGroupModel::lists('name', 'id'); - - return $options + $groups; - } - - public function getSendToModeOptions() - { - $modes = $this->recipientModes; - - unset($modes['system']); - - return $modes; - } - - public function getReplyToModeOptions() - { - $modes = $this->recipientModes; - - unset($modes['admin']); - - return $modes; - } - - public function getMailTemplateOptions() - { - $codes = array_keys(MailTemplate::listAllTemplates()); - $result = array_combine($codes, $codes); - return $result; - } - - protected function getReplyToAddress($params) - { - $mode = $this->host->reply_to_mode; - - if ($mode == 'custom') { - return $this->host->reply_to_custom; - } - - if ($mode == 'user' || $mode == 'sender') { - $obj = array_get($params, $mode); - return $obj->email; - } - } - - protected function getRecipientAddress($params) - { - $mode = $this->host->send_to_mode; - - if ($mode == 'custom') { - return $this->host->send_to_custom; - } - - if ($mode == 'system') { - $name = Config::get('mail.from.name', 'Your Site'); - $address = Config::get('mail.from.address', 'admin@domain.tld'); - return [$address => $name]; - } - - if ($mode == 'admin') { - if ($groupId = $this->host->send_to_admin) { - if (!$group = AdminGroupModel::find($groupId)) { - throw new ApplicationException('Unable to find admin group with ID: '.$groupId); - } - - return $group->users->lists('full_name', 'email'); - } - else { - return AdminUserModel::all()->lists('full_name', 'email'); - } - } - - if ($mode == 'user' || $mode == 'sender') { - return array_get($params, $mode); - } - } - - protected function isAdminMode() - { - return $this->host->send_to_mode == 'admin'; - } -} diff --git a/plugins/rainlab/notify/notifyrules/executioncontextcondition/fields.yaml b/plugins/rainlab/notify/notifyrules/executioncontextcondition/fields.yaml deleted file mode 100644 index 9981f87..0000000 --- a/plugins/rainlab/notify/notifyrules/executioncontextcondition/fields.yaml +++ /dev/null @@ -1,21 +0,0 @@ -# =================================== -# Field Definitions -# =================================== - -fields: - - subcondition: - label: Attribute - span: auto - type: dropdown - - operator: - label: Operator - span: auto - type: dropdown - dependsOn: subcondition - - value: - label: Value - dependsOn: [subcondition, operator] - type: dropdown diff --git a/plugins/rainlab/notify/notifyrules/savedatabaseaction/fields.yaml b/plugins/rainlab/notify/notifyrules/savedatabaseaction/fields.yaml deleted file mode 100644 index 77c144f..0000000 --- a/plugins/rainlab/notify/notifyrules/savedatabaseaction/fields.yaml +++ /dev/null @@ -1,8 +0,0 @@ -# =================================== -# Field Definitions -# =================================== - -fields: - related_object: - label: Related object - type: dropdown diff --git a/plugins/rainlab/notify/notifyrules/sendmailtemplateaction/fields.yaml b/plugins/rainlab/notify/notifyrules/sendmailtemplateaction/fields.yaml deleted file mode 100644 index 13aa548..0000000 --- a/plugins/rainlab/notify/notifyrules/sendmailtemplateaction/fields.yaml +++ /dev/null @@ -1,42 +0,0 @@ -# =================================== -# Field Definitions -# =================================== - -fields: - mail_template: - label: Mail template - type: dropdown - placeholder: Select template - - send_to_mode: - label: Send to - type: radio - span: left - - send_to_custom: - cssClass: radio-align - trigger: - action: show - field: send_to_mode - condition: value[custom] - - send_to_admin: - label: Send to admin group - span: right - type: dropdown - trigger: - action: show - field: send_to_mode - condition: value[admin] - - reply_to_mode: - label: Reply-to address - type: radio - span: left - - reply_to_custom: - cssClass: radio-align - trigger: - action: show - field: reply_to_mode - condition: value[custom] diff --git a/plugins/rainlab/notify/updates/create_notification_rules_table.php b/plugins/rainlab/notify/updates/create_notification_rules_table.php deleted file mode 100644 index 2bcc6b0..0000000 --- a/plugins/rainlab/notify/updates/create_notification_rules_table.php +++ /dev/null @@ -1,29 +0,0 @@ -engine = 'InnoDB'; - $table->increments('id'); - $table->string('name')->nullable(); - $table->string('code')->index()->nullable(); - $table->string('class_name')->nullable(); - $table->text('description')->nullable(); - $table->mediumText('config_data')->nullable(); - $table->mediumText('condition_data')->nullable(); - $table->boolean('is_enabled')->default(0); - $table->boolean('is_custom')->default(1); - $table->timestamps(); - }); - } - - public function down() - { - Schema::dropIfExists('rainlab_notify_notification_rules'); - } -} diff --git a/plugins/rainlab/notify/updates/create_notifications_table.php b/plugins/rainlab/notify/updates/create_notifications_table.php deleted file mode 100644 index 4c73bb4..0000000 --- a/plugins/rainlab/notify/updates/create_notifications_table.php +++ /dev/null @@ -1,28 +0,0 @@ -uuid('id')->primary(); - $table->string('event_type'); - $table->morphs('notifiable'); - $table->string('icon')->nullable(); - $table->string('type')->nullable(); - $table->text('body')->nullable(); - $table->mediumText('data'); - $table->timestamp('read_at')->nullable(); - $table->timestamps(); - }); - } - - public function down() - { - Schema::dropIfExists('rainlab_notify_notifications'); - } -} diff --git a/plugins/rainlab/notify/updates/create_rule_actions_table.php b/plugins/rainlab/notify/updates/create_rule_actions_table.php deleted file mode 100644 index af89e41..0000000 --- a/plugins/rainlab/notify/updates/create_rule_actions_table.php +++ /dev/null @@ -1,25 +0,0 @@ -engine = 'InnoDB'; - $table->increments('id'); - $table->string('class_name')->nullable(); - $table->mediumText('config_data')->nullable(); - $table->integer('rule_host_id')->unsigned()->nullable()->index(); - $table->timestamps(); - }); - } - - public function down() - { - Schema::dropIfExists('rainlab_notify_rule_actions'); - } -} diff --git a/plugins/rainlab/notify/updates/create_rule_conditions_table.php b/plugins/rainlab/notify/updates/create_rule_conditions_table.php deleted file mode 100644 index 4a0211e..0000000 --- a/plugins/rainlab/notify/updates/create_rule_conditions_table.php +++ /dev/null @@ -1,29 +0,0 @@ -engine = 'InnoDB'; - $table->increments('id'); - $table->string('class_name')->nullable(); - $table->mediumText('config_data')->nullable(); - $table->string('condition_control_type', 100)->nullable(); - $table->string('rule_host_type', 100)->nullable(); - $table->integer('rule_host_id')->unsigned()->nullable()->index(); - $table->integer('rule_parent_id')->unsigned()->nullable()->index(); - $table->index(['rule_host_id', 'rule_host_type'], 'host_rule_id_type'); - $table->timestamps(); - }); - } - - public function down() - { - Schema::dropIfExists('rainlab_notify_rule_conditions'); - } -} diff --git a/plugins/rainlab/notify/updates/version.yaml b/plugins/rainlab/notify/updates/version.yaml deleted file mode 100644 index 2c184f4..0000000 --- a/plugins/rainlab/notify/updates/version.yaml +++ /dev/null @@ -1,9 +0,0 @@ -v1.0.1: - - First version of Notify - - create_notifications_table.php - - create_notification_rules_table.php - - create_rule_conditions_table.php - - create_rule_actions_table.php -v1.0.2: Fixes crashing bug. -v1.0.3: Added Turkish & Russian translations, various bug fixes. -v1.1.0: Fixes support for October CMS 2.0 diff --git a/plugins/rainlab/user/.gitignore b/plugins/rainlab/user/.gitignore new file mode 100644 index 0000000..77bed77 --- /dev/null +++ b/plugins/rainlab/user/.gitignore @@ -0,0 +1,3 @@ +.phpunit.result.cache +composer.lock +vendor diff --git a/plugins/rainlab/user/Plugin.php b/plugins/rainlab/user/Plugin.php index 8feafec..0152481 100644 --- a/plugins/rainlab/user/Plugin.php +++ b/plugins/rainlab/user/Plugin.php @@ -2,7 +2,6 @@ use App; use Auth; -use Carbon\Carbon; use Event; use Backend; use System\Classes\PluginBase; @@ -33,7 +32,7 @@ class Plugin extends PluginBase public function register() { $alias = AliasLoader::getInstance(); - $alias->alias('Auth', 'RainLab\User\Facades\Auth'); + $alias->alias('Auth', \RainLab\User\Facades\Auth::class); App::singleton('user.auth', function () { return \RainLab\User\Classes\AuthManager::instance(); @@ -70,8 +69,8 @@ class Plugin extends PluginBase public function registerComponents() { return [ - \RainLab\User\Components\Session::class => 'session', - \RainLab\User\Components\Account::class => 'account', + \RainLab\User\Components\Session::class => 'session', + \RainLab\User\Components\Account::class => 'account', \RainLab\User\Components\ResetPassword::class => 'resetPassword' ]; } @@ -116,12 +115,12 @@ class Plugin extends PluginBase 'url' => Backend::url('rainlab/user/users'), 'permissions' => ['rainlab.users.access_users'] ], - // 'usergroups' => [ - // 'label' => 'rainlab.user::lang.groups.menu_label', - // 'icon' => 'icon-users', - // 'url' => Backend::url('rainlab/user/usergroups'), - // 'permissions' => ['rainlab.users.access_groups'] - // ] + 'usergroups' => [ + 'label' => 'rainlab.user::lang.groups.menu_label', + 'icon' => 'icon-users', + 'url' => Backend::url('rainlab/user/usergroups'), + 'permissions' => ['rainlab.users.access_groups'] + ] ] ] ]; @@ -134,7 +133,7 @@ class Plugin extends PluginBase 'label' => 'rainlab.user::lang.settings.menu_label', 'description' => 'rainlab.user::lang.settings.menu_description', 'category' => SettingsManager::CATEGORY_USERS, - 'icon' => 'icon-cog', + 'icon' => class_exists('System') ? 'octo-icon-user-actions-key' : 'icon-cog', 'class' => 'RainLab\User\Models\Settings', 'order' => 500, 'permissions' => ['rainlab.users.access_settings'] @@ -191,28 +190,4 @@ class Plugin extends PluginBase ]); }); } - - public function registerListColumnTypes() - { - return [ - 'email_verified' => [$this, 'emailVerified'], - 'phone_verified' => [$this, 'phoneVerified'], - ]; - } - - public function emailVerified($value, $column, $record){ - switch ($value){ - case 0 : return 'Not verified'; - case 1 : return 'Verified'; - default : return $value; - } - } - - public function phoneVerified($value, $column, $record){ - switch ($value){ - case 0 : return 'Not verified'; - case 1 : return 'Verified'; - default : return $value; - } - } } diff --git a/plugins/rainlab/user/README.md b/plugins/rainlab/user/README.md index 80d3596..dd4604a 100644 --- a/plugins/rainlab/user/README.md +++ b/plugins/rainlab/user/README.md @@ -1,14 +1,25 @@ # Front-end user plugin -[![Build Status](https://img.shields.io/github/workflow/status/rainlab/user-plugin/Tests)](https://github.com/rainlab/user-plugin/actions) -[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/rainlab/user-plugin/blob/master/LICENCE.md) - Front-end user management for October CMS. ## Requirements This plugin requires the [Ajax Framework](https://octobercms.com/docs/cms/ajax) to be included in your layout/page in order to handle form requests. +## Installation Instructions + +Run the following to install this plugin: + +```bash +php artisan plugin:install RainLab.User +``` + +To uninstall this plugin: + +```bash +php artisan plugin:remove RainLab.User +``` + ## Managing users Users are managed on the Users tab found in the back-end. Each user provides minimal data fields - **Name**, **Surname**, **Email** and **Password**. The Name can represent either the person's first name or their full name, making the Surname field optional, depending on the complexity of your site. @@ -47,7 +58,17 @@ As a security precaution, you may restrict users from having sessions across mul #### Notifications -When a user is first activated -- either by registration, email confirmation or administrator approval -- they are sent a welcome email. To disable the welcome email, select "Do not send a notification" from the **Welcome mail template** dropdown. The default message template used is `rainlab.user::mail.welcome` and you can customize this by selecting **Mail > Mail Templates** from the settings menu. +This feature is implemented by the Notify plugin. How to use this feature: + +- Install the **RainLab.Notify** plugin +- Navigate to **Settings > Notification** rules +- Click **New notification rule** +- Select **User > Activated** +- Click **Add action** +- Select **Compose a mail message** +- Select **User email address** for the **Send to** field +- Here you may select the Mail template previously defined in the user settings. +- Click **Save** ## Extended features diff --git a/plugins/rainlab/user/assets/js/bulk-actions.js b/plugins/rainlab/user/assets/js/bulk-actions.js index d0e2089..69885f9 100644 --- a/plugins/rainlab/user/assets/js/bulk-actions.js +++ b/plugins/rainlab/user/assets/js/bulk-actions.js @@ -1,6 +1,6 @@ /* * Bulk actions plugin - * + * * Data attributes: * - data-control="bulk-actions" - enables the plugin on an element * @@ -53,12 +53,12 @@ } BulkActions.prototype.setActiveItem = function($el) { - this.$toggleBtn.blur() - this.activeAction = $el.data('action') - this.$primaryBtn.text($el.text()) - this.$primaryBtn.attr('class', this.baseCss) - this.$primaryBtn.addClass($el.attr('class')) - this.$primaryBtn.data('request-confirm', $el.data('confirm')) + this.$toggleBtn.blur(); + this.activeAction = $el.data('action'); + this.$primaryBtn.text($el.text()); + this.$primaryBtn.attr('class', this.baseCss); + this.$primaryBtn.addClass($el.attr('class')).removeClass('dropdown-item'); + this.$primaryBtn.data('request-confirm', $el.data('confirm')); } // BULK ACTIONS PLUGIN DEFINITION diff --git a/plugins/rainlab/user/classes/AuthManager.php b/plugins/rainlab/user/classes/AuthManager.php index 269955c..8cf5386 100644 --- a/plugins/rainlab/user/classes/AuthManager.php +++ b/plugins/rainlab/user/classes/AuthManager.php @@ -1,5 +1,6 @@ withTrashed(); + + // Extensibility + Event::fire('rainlab.user.extendUserAuthQuery', [$query]); } /** @@ -43,6 +47,25 @@ class AuthManager extends RainAuthManager return parent::register($credentials, $activate, $autoLogin); } + /** + * findUserByEmail finds a user by the email value, which includes + * deactivated (trashed) user records. + * @param string $email + * @return Authenticatable|null + */ + public function findUserByEmail($email) + { + if (!$email) { + return null; + } + + $query = $this->createUserModelQuery(); + + $user = $query->where('email', $email)->first(); + + return $this->validateUserModel($user) ? $user : null; + } + // // Guest users // @@ -60,10 +83,11 @@ class AuthManager extends RainAuthManager { $query = $this->createUserModelQuery(); - return $user = $query + return $query ->where('email', $email) ->where('is_guest', 1) - ->first(); + ->first() + ; } /** diff --git a/plugins/rainlab/user/components/Account.php b/plugins/rainlab/user/components/Account.php index cb3cd91..28b08d8 100644 --- a/plugins/rainlab/user/components/Account.php +++ b/plugins/rainlab/user/components/Account.php @@ -17,8 +17,6 @@ use Cms\Classes\ComponentBase; use RainLab\User\Models\User as UserModel; use RainLab\User\Models\Settings as UserSettings; use Exception; -use Throwable; -use TPS\Birzha\Classes\SMS; /** * Account component @@ -28,11 +26,6 @@ use TPS\Birzha\Classes\SMS; */ class Account extends ComponentBase { - /** - * Validation messages - */ - public $accountValidationMsgs; - public function componentDetails() { return [ @@ -56,6 +49,12 @@ class Account extends ComponentBase 'type' => 'string', 'default' => 'code' ], + 'activationPage' => [ + 'title' => /* Activation Page */'rainlab.user::lang.account.activation_page', + 'description' => /* Select a page to use for activating the user account */'rainlab.user::lang.account.activation_page_comment', + 'type' => 'dropdown', + 'default' => '' + ], 'forceSecure' => [ 'title' => /*Force secure protocol*/'rainlab.user::lang.account.force_secure', 'description' => /*Always redirect the URL with the HTTPS schema.*/'rainlab.user::lang.account.force_secure_desc', @@ -68,19 +67,28 @@ class Account extends ComponentBase 'type' => 'checkbox', 'default' => 0 ], - 'view' => [ - 'title' => 'View', - 'description' => 'Choose view type', - 'type' => 'dropdown', - 'options' => ['signin','signup','profile'], - 'default' => 'signin' - ] ]; } + /** + * getRedirectOptions + */ public function getRedirectOptions() { - return [''=>'- refresh page -', '0' => '- no redirect -'] + Page::sortBy('baseFileName')->lists('baseFileName', 'baseFileName'); + return [ + '' => '- refresh page -', + '0' => '- no redirect -' + ] + Page::sortBy('baseFileName')->lists('baseFileName', 'baseFileName'); + } + + /** + * getActivationPageOptions + */ + public function getActivationPageOptions() + { + return [ + '' => '- current page -', + ] + Page::sortBy('baseFileName')->lists('baseFileName', 'baseFileName'); } /** @@ -111,9 +119,9 @@ class Account extends ComponentBase /* * Activation code supplied */ - // if ($code = $this->activationCode()) { - // $this->onActivate($code); - // } + if ($code = $this->activationCode()) { + $this->onActivate($code); + } $this->prepareVars(); } @@ -177,6 +185,23 @@ class Account extends ComponentBase return UserSettings::get('remember_login', UserSettings::REMEMBER_ALWAYS); } + /** + * useRememberLogin returns true if persistent authentication should be used. + */ + protected function useRememberLogin(): bool + { + switch ($this->rememberLoginMode()) { + case UserSettings::REMEMBER_ALWAYS: + return true; + + case UserSettings::REMEMBER_NEVER: + return false; + + case UserSettings::REMEMBER_ASK: + return (bool) post('remember', false); + } + } + /** * Looks for the activation code from the URL parameter. If nothing * is found, the GET parameter 'activate' is used instead. @@ -213,7 +238,7 @@ class Account extends ComponentBase ? 'required|between:2,255' : 'required|email|between:6,255'; - $rules['password'] = 'required|between:4,255'; + $rules['password'] = 'required|between:' . UserModel::getMinPasswordLength() . ',255'; if (!array_key_exists('login', $data)) { $data['login'] = post('username', post('email')); @@ -221,7 +246,13 @@ class Account extends ComponentBase $data['login'] = trim($data['login']); - $validation = Validator::make($data, $rules); + $validation = Validator::make( + $data, + $rules, + $this->getValidatorMessages(), + $this->getCustomAttributes() + ); + if ($validation->fails()) { throw new ValidationException($validation); } @@ -230,31 +261,16 @@ class Account extends ComponentBase * Authenticate user */ $credentials = [ - 'login' => array_get($data, 'dial_code') . array_get($data, 'login'), + 'login' => array_get($data, 'login'), 'password' => array_get($data, 'password') ]; - /* - * Login remember mode - */ - switch ($this->rememberLoginMode()) { - case UserSettings::REMEMBER_ALWAYS: - $remember = true; - break; - case UserSettings::REMEMBER_NEVER: - $remember = false; - break; - case UserSettings::REMEMBER_ASK: - $remember = (bool) array_get($data, 'remember', false); - break; - } - Event::fire('rainlab.user.beforeAuthenticate', [$this, $credentials]); - $user = Auth::authenticate($credentials, $remember); + $user = Auth::authenticate($credentials, $this->useRememberLogin()); if ($user->isBanned()) { Auth::logout(); - throw new AuthException(/*Sorry, this user is currently not activated. Please contact us for further assistance.*/'rainlab.user::lang.account.banned'); + throw new AuthException(Lang::get(/*Sorry, this user is currently not activated. Please contact us for further assistance.*/'rainlab.user::lang.account.banned')); } /* @@ -272,12 +288,7 @@ class Account extends ComponentBase } } catch (Exception $ex) { - if ($ex instanceof AuthException) { - throw new ValidationException(['no_user' => trans('validation.no_user')]); - } - - // if (Request::ajax()) throw $ex; - if (Request::ajax()) info($ex); + if (Request::ajax()) throw $ex; else Flash::error($ex->getMessage()); } } @@ -305,27 +316,19 @@ class Account extends ComponentBase $data['password_confirmation'] = post('password'); } - $rules = array_merge((new UserModel)->rules, [ - 'username' => [ - 'required', - 'numeric', - 'unique' => function($attribute, $value, $fail) use($data) { - $u = UserModel::where('username', $data['dial_code'] . $value)->first(); - if(!is_null($u)) $fail(trans('validation.auth_profile.phone_number_unique')); - } - ], - ]); + $rules = (new UserModel)->rules; if ($this->loginAttribute() !== UserSettings::LOGIN_USERNAME) { unset($rules['username']); } - $validation = Validator::make($data, $rules, [ - 'username.required' => trans('validation.auth_profile.phone_number_required'), - 'username.numeric' => trans('validation.auth_profile.phone_number_numeric'), - 'username.digits_between' => trans('validation.auth_profile.phone_number_digits_between'), - 'username.unique' => trans('validation.auth_profile.phone_number_unique'), - ]); + $validation = Validator::make( + $data, + $rules, + $this->getValidatorMessages(), + $this->getCustomAttributes() + ); + if ($validation->fails()) { throw new ValidationException($validation); } @@ -346,9 +349,6 @@ class Account extends ComponentBase $automaticActivation = UserSettings::get('activate_mode') == UserSettings::ACTIVATE_AUTO; $userActivation = UserSettings::get('activate_mode') == UserSettings::ACTIVATE_USER; $adminActivation = UserSettings::get('activate_mode') == UserSettings::ACTIVATE_ADMIN; - // $user = Auth::register(array_merge($data, [ - // 'username' => $data['dial_code'] . $data['username'] - // ]), $automaticActivation); $user = Auth::register($data, $automaticActivation); Event::fire('rainlab.user.register', [$user, $data]); @@ -357,12 +357,13 @@ class Account extends ComponentBase * Activation is by the user, send the email */ if ($userActivation) { -// $this->sendActivationEmail($user); -// -// Flash::success(Lang::get(/*An activation email has been sent to your email address.*/'rainlab.user::lang.account.activation_email_sent')); - //todo open activation view + $this->sendActivationEmail($user); + + Flash::success(Lang::get(/*An activation email has been sent to your email address.*/'rainlab.user::lang.account.activation_email_sent')); } + $intended = false; + /* * Activation is by the admin, show message * For automatic email on account activation RainLab.Notify plugin is needed @@ -375,17 +376,16 @@ class Account extends ComponentBase * Automatically activated or not required, log the user in */ if ($automaticActivation || !$requireActivation) { - Auth::login($user); + Auth::login($user, $this->useRememberLogin()); + $intended = true; } /* * Redirect to the intended page after successful sign in */ - // if ($redirect = $this->makeRedirection(true)) { - // return $redirect; - // } - - return \Redirect::to('/profile'); + if ($redirect = $this->makeRedirection($intended)) { + return $redirect; + } } catch (Exception $ex) { if (Request::ajax()) throw $ex; @@ -393,108 +393,6 @@ class Account extends ComponentBase } } - /** - * Send sms with 6 digits code to user - */ - public function onSendSmsCode() - { - try { - if($this->user()->dial_code == '+993' && !$this->user()->phone_verified) { - $code = random_int(1000, 9999); - - $result = SMS::send(str_replace(array('+', ' ', '(' , ')', '-'), '', $this->user()->username), $code); - // $result = 0; - \Log::info('send sms result'); - \Log::info($result); - - switch ($result) { - case 0: - $this->user()->phone_activation_code = $code; - $this->user()->save(); - \Log::info('case 0'); - break; - case 1: - return \Redirect::to('/error'); - \Log::info('case 1'); - break; - - default: - return \Redirect::to('/error'); - \Log::info('case default'); - break; - } - } - } catch(Throwable $th) { - \Log::info($th); - return \Redirect::to('/error'); - } - - } - - /** - * Check SMS code sent by user - */ - public function onCheckSmsCode() - { - $data = post(); - - $validator = \Validator::make($data, [ - 'sms_code' => 'required|digits:4', - ]); - if($validator->fails()) { - throw new ValidationException($validator); - } - - if($this->user()->phone_activation_code == $data['sms_code']) { - $this->user()->phone_verified = true; - $this->user()->phone_activation_code = null; - $this->user()->save(); - - Flash::success(Lang::get('rainlab.user::lang.account.phone_verified_message')); - - return \Redirect::to('profile'); - } else { - Flash::error(Lang::get('rainlab.user::lang.account.phone_verification_code_invalid')); - - return \Redirect::to('profile'); - } - } - - /** - * Send email with the verification link to the user - */ - public function onSendEmailVerificationLink() - { - if(!$this->user()->email_verified) { - $code = sha1(time()); - $vars = [ - 'verification_link' => $this->controller->pageUrl('kabinet/verify_email.htm', [ - 'id' => $this->user()->id, 'code' => $code - ]) - ]; - - try { - \Mail::queue('tps.birzha::mail.' . app()->getLocale() . '.email_verify', $vars, function($message) { - $message->to($this->user()->email, 'Birzha User'); - $message->subject(\Lang::get('rainlab.user::lang.account.email_verification')); - }); - } catch(Throwable $th) { - \Log::info($th); - - Flash::error('Ошибка. Неверный Email.'); - - return \Redirect::to('profile'); - } - - $this->user()->email_activation_code = $code; - $this->user()->save(); - - Flash::success(\Lang::get('rainlab.user::lang.account.email_verification_check_message')); - - return \Redirect::to('profile'); - } - } - /** * Activate the user * @param string $code Activation code @@ -533,7 +431,7 @@ class Account extends ComponentBase /* * Sign in the user */ - Auth::login($user); + Auth::login($user, $this->useRememberLogin()); } catch (Exception $ex) { @@ -551,28 +449,7 @@ class Account extends ComponentBase return; } - $data = Input::except(['username']); - - $rules = [ - 'email' => 'required|between:6,191|email', - 'name' => 'required', - 'surname' => 'required', - // 'username' => 'required|digits_between:8,20|numeric', - 'iu_company' => 'max:191', - 'iu_about' => 'digits:6|numeric', - ]; - - $validation = Validator::make($data, $rules, [ - 'username.required' => trans('validation.auth_profile.phone_number_required'), - 'username.numeric' => trans('validation.auth_profile.phone_number_numeric'), - 'username.digits_between' => trans('validation.auth_profile.phone_number_digits_between'), - 'username.unique' => trans('validation.auth_profile.phone_number_unique'), - 'zip.digits' => trans('validation.auth_profile.iu_about_digits'), - 'company.max' => trans('validation.auth_profile.iu_company_max'), - ]); - if ($validation->fails()) { - throw new ValidationException($validation); - } + $data = post(); if ($this->updateRequiresPassword()) { if (!$user->checkHashValue('password', $data['password_current'])) { @@ -584,11 +461,6 @@ class Account extends ComponentBase $user->avatar = Input::file('avatar'); } - if($user->email != $data['email']) { - $user->email_verified = false; - $user->save(); - } - $user->fill($data); $user->save(); @@ -596,9 +468,14 @@ class Account extends ComponentBase * Password has changed, reauthenticate the user */ if (array_key_exists('password', $data) && strlen($data['password'])) { - Auth::login($user->reload(), true); + Auth::login($user->reload(), $this->useRememberLogin()); } + /* + * Update Event to hook into the plugins function + */ + Event::fire('rainlab.user.update', [$user, $data]); + Flash::success(post('flash', Lang::get(/*Settings successfully saved!*/'rainlab.user::lang.account.success_saved'))); /* @@ -728,12 +605,13 @@ class Account extends ComponentBase { $method = $intended ? 'intended' : 'to'; - $property = trim((string) $this->property('redirect')); + $property = post('redirect', $this->property('redirect')); // No redirect if ($property === '0') { return; } + // Refresh page if ($property === '') { return Redirect::refresh(); @@ -741,7 +619,7 @@ class Account extends ComponentBase $redirectUrl = $this->pageUrl($property) ?: $property; - if ($redirectUrl = post('redirect', $redirectUrl)) { + if ($redirectUrl) { return Redirect::$method($redirectUrl); } } @@ -776,4 +654,26 @@ class Account extends ComponentBase return UserModel::isRegisterThrottled(Request::ip()); } + + /** + * getValidatorMessages + */ + protected function getValidatorMessages(): array + { + return (array) (new UserModel)->customMessages; + } + + /** + * getCustomAttributes + */ + protected function getCustomAttributes(): array + { + return [ + 'login' => $this->loginAttributeLabel(), + 'password' => Lang::get('rainlab.user::lang.account.password'), + 'email' => Lang::get('rainlab.user::lang.account.email'), + 'username' => Lang::get('rainlab.user::lang.user.username'), + 'name' => Lang::get('rainlab.user::lang.account.full_name') + ]; + } } diff --git a/plugins/rainlab/user/components/ResetPassword.php b/plugins/rainlab/user/components/ResetPassword.php index 9d6e8fb..7966b10 100644 --- a/plugins/rainlab/user/components/ResetPassword.php +++ b/plugins/rainlab/user/components/ResetPassword.php @@ -6,11 +6,12 @@ use Mail; use Validator; use ValidationException; use ApplicationException; +use Cms\Classes\Page; use Cms\Classes\ComponentBase; use RainLab\User\Models\User as UserModel; /** - * Password reset workflow + * ResetPassword controls the password reset workflow * * When a user has forgotten their password, they are able to reset it using * a unique token that, sent to their email address upon request. @@ -33,10 +34,26 @@ class ResetPassword extends ComponentBase 'description' => /*The page URL parameter used for the reset code*/'rainlab.user::lang.reset_password.code_param_desc', 'type' => 'string', 'default' => 'code' - ] + ], + 'resetPage' => [ + 'title' => /* Reset Page */'rainlab.user::lang.account.reset_page', + 'description' => /* Select a page to use for resetting the account password */'rainlab.user::lang.account.reset_page_comment', + 'type' => 'dropdown', + 'default' => '' + ], ]; } + /** + * getResetPageOptions + */ + public function getResetPageOptions() + { + return [ + '' => '- current page -', + ] + Page::sortBy('baseFileName')->lists('baseFileName', 'baseFileName'); + } + // // Properties // @@ -74,8 +91,8 @@ class ResetPassword extends ComponentBase throw new ValidationException($validation); } - $user = UserModel::findByEmail(post('email')); - if (!$user || $user->is_guest) { + $user = Auth::findUserByEmail(post('email')); + if (!$user || $user->is_guest || $user->trashed()) { throw new ApplicationException(Lang::get(/*A user was not found with the given credentials.*/'rainlab.user::lang.account.invalid_user')); } @@ -90,7 +107,7 @@ class ResetPassword extends ComponentBase 'code' => $code ]; - Mail::queue('tps.birzha::mail.' . app()->getLocale() . '.reset_password', $data, function($message) use ($user) { + Mail::send('rainlab.user::mail.restore', $data, function($message) use ($user) { $message->to($user->email, $user->full_name); }); } @@ -133,6 +150,11 @@ class ResetPassword extends ComponentBase if (!$user->attemptResetPassword($code, post('password'))) { throw new ValidationException($errorFields); } + + // Check needed for compatibility with legacy systems + if (method_exists(\RainLab\User\Classes\AuthManager::class, 'clearThrottleForUserId')) { + Auth::clearThrottleForUserId($user->id); + } } // @@ -140,7 +162,7 @@ class ResetPassword extends ComponentBase // /** - * Returns a link used to reset the user account. + * makeResetUrl returns a link used to reset the user account. * @return string */ protected function makeResetUrl($code) @@ -149,10 +171,14 @@ class ResetPassword extends ComponentBase $this->property('paramCode') => $code ]; + // Locate the current page + $url = ''; + if ($pageName = $this->property('resetPage')) { $url = $this->pageUrl($pageName, $params); } - else { + + if (!$url) { $url = $this->currentPageUrl($params); } diff --git a/plugins/rainlab/user/components/Session.php b/plugins/rainlab/user/components/Session.php index 0236cfe..0b140af 100644 --- a/plugins/rainlab/user/components/Session.php +++ b/plugins/rainlab/user/components/Session.php @@ -5,15 +5,14 @@ use Auth; use Event; use Flash; use Request; -use Response; use Redirect; use Cms\Classes\Page; use Cms\Classes\ComponentBase; use RainLab\User\Models\UserGroup; -use ValidationException; +use SystemException; /** - * User session + * Session component * * This will inject the user object to every page and provide the ability for * the user to sign out. This can also be used to restrict access to pages. @@ -62,11 +61,17 @@ class Session extends ComponentBase ]; } + /** + * getRedirectOptions + */ public function getRedirectOptions() { return [''=>'- none -'] + Page::sortBy('baseFileName')->lists('baseFileName', 'baseFileName'); } + /** + * getAllowedUserGroupsOptions + */ public function getAllowedUserGroupsOptions() { return UserGroup::lists('name','code'); @@ -77,9 +82,12 @@ class Session extends ComponentBase */ public function init() { - if (Request::ajax() && !$this->checkUserSecurity()) { - abort(403, 'Access denied'); - } + // Inject security logic pre-AJAX + $this->controller->bindEvent('page.init', function() { + if (Request::ajax() && ($redirect = $this->checkUserSecurityRedirect())) { + return ['X_OCTOBER_REDIRECT' => $redirect->getTargetUrl()]; + } + }); } /** @@ -87,13 +95,8 @@ class Session extends ComponentBase */ public function onRun() { - if (!$this->checkUserSecurity()) { - if (empty($this->property('redirect'))) { - throw new \InvalidArgumentException('Redirect property is empty'); - } - - $redirectUrl = $this->controller->pageUrl($this->property('redirect')); - return Redirect::guest($redirectUrl); + if ($redirect = $this->checkUserSecurityRedirect()) { + return $redirect; } $this->page['user'] = $this->user(); @@ -172,13 +175,31 @@ class Session extends ComponentBase } /** - * Checks if the user can access this page based on the security rules - * @return bool + * checkUserSecurityRedirect will return a redirect if the user cannot access the page. */ - protected function checkUserSecurity() + protected function checkUserSecurityRedirect() + { + // No security layer enabled + if ($this->checkUserSecurity()) { + return; + } + + if (!$this->property('redirect')) { + throw new SystemException('Redirect property is empty on Session component.'); + } + + $redirectUrl = $this->controller->pageUrl($this->property('redirect')); + + return Redirect::guest($redirectUrl); + } + + /** + * checkUserSecurity checks if the user can access this page based on the security rules. + */ + protected function checkUserSecurity(): bool { $allowedGroup = $this->property('security', self::ALLOW_ALL); - $allowedUserGroups = $this->property('allowedUserGroups', []); + $allowedUserGroups = (array) $this->property('allowedUserGroups', []); $isAuthenticated = Auth::check(); if ($isAuthenticated) { diff --git a/plugins/rainlab/user/components/resetpassword/check.htm b/plugins/rainlab/user/components/resetpassword/check.htm deleted file mode 100644 index f0472f3..0000000 --- a/plugins/rainlab/user/components/resetpassword/check.htm +++ /dev/null @@ -1,5 +0,0 @@ -
    -
    - {{ 'auth.password_reset_check'|_ }} -
    -
    \ No newline at end of file diff --git a/plugins/rainlab/user/components/resetpassword/complete.htm b/plugins/rainlab/user/components/resetpassword/complete.htm index e625cd2..d0d0baa 100644 --- a/plugins/rainlab/user/components/resetpassword/complete.htm +++ b/plugins/rainlab/user/components/resetpassword/complete.htm @@ -1,14 +1 @@ -
    -
    - {{ 'auth.password_reset_complete'|_ }} -
    -
    - -
    - -
    -
    -
    \ No newline at end of file +

    Password reset complete, you may now sign in.

    \ No newline at end of file diff --git a/plugins/rainlab/user/components/resetpassword/default.htm b/plugins/rainlab/user/components/resetpassword/default.htm index 385dc70..b2eed57 100644 --- a/plugins/rainlab/user/components/resetpassword/default.htm +++ b/plugins/rainlab/user/components/resetpassword/default.htm @@ -1,12 +1,7 @@ -
    -
    -
    - {% if __SELF__.code == null %} - {% partial __SELF__ ~ '::restore' %} - {% else %} - {% partial __SELF__ ~ '::reset' %} - {% endif %} -
    -
    -
    - +
    + {% if __SELF__.code == null %} + {% partial __SELF__ ~ '::restore' %} + {% else %} + {% partial __SELF__ ~ '::reset' %} + {% endif %} +
    \ No newline at end of file diff --git a/plugins/rainlab/user/components/resetpassword/reset.htm b/plugins/rainlab/user/components/resetpassword/reset.htm index 3626ca6..78c62da 100644 --- a/plugins/rainlab/user/components/resetpassword/reset.htm +++ b/plugins/rainlab/user/components/resetpassword/reset.htm @@ -1,22 +1,19 @@ -
    -
    - {{ 'account.new_password'|_ }} +

    + Please check your email for the activation code. +

    + +
    +
    + +
    - -
    - -
    -
    - -
    +
    + + +
    -
    - -
    -
    -
    - + + diff --git a/plugins/rainlab/user/components/resetpassword/restore.htm b/plugins/rainlab/user/components/resetpassword/restore.htm index ad5afb1..e51eb02 100644 --- a/plugins/rainlab/user/components/resetpassword/restore.htm +++ b/plugins/rainlab/user/components/resetpassword/restore.htm @@ -1,17 +1,14 @@ -
    -
    - {{ 'auth.password_reset'|_ }} +

    + Lost your password? No problem! Enter your email address to verify your account. +

    + +
    +
    + +
    - -
    - -
    -
    - -
    - -
    -
    \ No newline at end of file + + + diff --git a/plugins/rainlab/user/composer.json b/plugins/rainlab/user/composer.json index 779cb43..0b4f218 100644 --- a/plugins/rainlab/user/composer.json +++ b/plugins/rainlab/user/composer.json @@ -1,8 +1,25 @@ { "name": "rainlab/user-plugin", "type": "october-plugin", - "description": "None", + "description": "User plugin for October CMS", + "homepage": "https://octobercms.com/plugin/rainlab-user", + "keywords": ["october", "octobercms", "user"], + "license": "MIT", + "authors": [ + { + "name": "Alexey Bobkov", + "email": "aleksey.bobkov@gmail.com", + "role": "Co-founder" + }, + { + "name": "Samuel Georges", + "email": "daftspunky@gmail.com", + "role": "Co-founder" + } + ], "require": { + "php": ">=5.5.9", "composer/installers": "~1.0" - } -} \ No newline at end of file + }, + "minimum-stability": "dev" +} diff --git a/plugins/rainlab/user/config/config.php b/plugins/rainlab/user/config/config.php index d00b4b1..2fef283 100644 --- a/plugins/rainlab/user/config/config.php +++ b/plugins/rainlab/user/config/config.php @@ -64,7 +64,7 @@ return [ | */ - 'minPasswordLength' => 6, + 'minPasswordLength' => 8, /* |-------------------------------------------------------------------------- diff --git a/plugins/rainlab/user/controllers/Users.php b/plugins/rainlab/user/controllers/Users.php index 159e4ef..a0b8a5b 100644 --- a/plugins/rainlab/user/controllers/Users.php +++ b/plugins/rainlab/user/controllers/Users.php @@ -279,6 +279,7 @@ class Users extends Controller break; case 'deactivate': + $user->clearPersistCode(); $user->delete(); break; diff --git a/plugins/rainlab/user/controllers/users/_convert_guest_form.htm b/plugins/rainlab/user/controllers/users/_convert_guest_form.htm index cc86b72..270df82 100644 --- a/plugins/rainlab/user/controllers/users/_convert_guest_form.htm +++ b/plugins/rainlab/user/controllers/users/_convert_guest_form.htm @@ -1,16 +1,15 @@ 'convertGuestForm']) ?> - @@ -36,7 +35,7 @@ class="btn btn-primary" data-popup-load-indicator data-request="onConvertGuest"> - Convert to registered + Convert to Registered
    diff --git a/plugins/tps/birzha/controllers/usersliders/config_form.yaml b/plugins/tps/birzha/controllers/usersliders/config_form.yaml new file mode 100644 index 0000000..d1d5a42 --- /dev/null +++ b/plugins/tps/birzha/controllers/usersliders/config_form.yaml @@ -0,0 +1,10 @@ +name: UserSliders +form: $/tps/birzha/models/usersliders/fields.yaml +modelClass: TPS\Birzha\Models\UserSliders +defaultRedirect: tps/birzha/usersliders +create: + redirect: 'tps/birzha/usersliders/update/:id' + redirectClose: tps/birzha/usersliders +update: + redirect: tps/birzha/usersliders + redirectClose: tps/birzha/usersliders diff --git a/plugins/tps/birzha/controllers/usersliders/config_list.yaml b/plugins/tps/birzha/controllers/usersliders/config_list.yaml new file mode 100644 index 0000000..969728b --- /dev/null +++ b/plugins/tps/birzha/controllers/usersliders/config_list.yaml @@ -0,0 +1,12 @@ +list: $/tps/birzha/models/usersliders/columns.yaml +modelClass: TPS\Birzha\Models\UserSliders +title: UserSliders +noRecordsMessage: 'backend::lang.list.no_records' +showSetup: true +showCheckboxes: true +recordsPerPage: 20 +toolbar: + buttons: list_toolbar + search: + prompt: 'backend::lang.list.search_prompt' +recordUrl: 'tps/birzha/usersliders/update/:id' diff --git a/plugins/tps/birzha/controllers/usersliders/create.htm b/plugins/tps/birzha/controllers/usersliders/create.htm new file mode 100644 index 0000000..4a68670 --- /dev/null +++ b/plugins/tps/birzha/controllers/usersliders/create.htm @@ -0,0 +1,46 @@ + + + + +fatalError): ?> + + 'layout']) ?> + +
    + formRender() ?> +
    + +
    +
    + + + + + +
    +
    + + + + +

    fatalError)) ?>

    +

    + \ No newline at end of file diff --git a/plugins/rainlab/notify/controllers/notifications/index.htm b/plugins/tps/birzha/controllers/usersliders/index.htm similarity index 96% rename from plugins/rainlab/notify/controllers/notifications/index.htm rename to plugins/tps/birzha/controllers/usersliders/index.htm index 766877d..ea43a36 100644 --- a/plugins/rainlab/notify/controllers/notifications/index.htm +++ b/plugins/tps/birzha/controllers/usersliders/index.htm @@ -1,2 +1 @@ - listRender() ?> diff --git a/plugins/tps/birzha/controllers/usersliders/preview.htm b/plugins/tps/birzha/controllers/usersliders/preview.htm new file mode 100644 index 0000000..17c1892 --- /dev/null +++ b/plugins/tps/birzha/controllers/usersliders/preview.htm @@ -0,0 +1,22 @@ + + + + +fatalError): ?> + +
    + formRenderPreview() ?> +
    + + +

    fatalError) ?>

    + + +

    + + + +

    \ No newline at end of file diff --git a/plugins/tps/birzha/controllers/usersliders/update.htm b/plugins/tps/birzha/controllers/usersliders/update.htm new file mode 100644 index 0000000..d6777f2 --- /dev/null +++ b/plugins/tps/birzha/controllers/usersliders/update.htm @@ -0,0 +1,54 @@ + + + + +fatalError): ?> + + 'layout']) ?> + +
    + formRender() ?> +
    + +
    +
    + + + + + + + +
    +
    + + + +

    fatalError)) ?>

    +

    + \ No newline at end of file diff --git a/plugins/tps/birzha/models/Category.php b/plugins/tps/birzha/models/Category.php index 7316448..c5857d5 100644 --- a/plugins/tps/birzha/models/Category.php +++ b/plugins/tps/birzha/models/Category.php @@ -30,6 +30,7 @@ class Category extends Model */ public $rules = [ 'name' => 'required', + 'sort_order' => 'required', 'slug' => ['required', 'regex:/^[a-z0-9\/\:_\-\*\[\]\+\?\|]*$/i', 'unique:tps_birzha_categories'], 'status' => 'required', ]; @@ -37,7 +38,16 @@ class Category extends Model public $translatable = ['name',['slug', 'index' => true]]; public $belongsToMany = [ - 'products' => ['TPS\Birzha\Models\Product','table'=>'tps_birzha_product_categories'] + 'products' => [ + 'TPS\Birzha\Models\Product', + 'table'=>'tps_birzha_product_categories' + ], + 'users' => [ + 'TPS\Birzha\Models\Category', + 'table'=>'tps_birzha_users_categories', + 'delete' => true, + 'softDelete' => true + ], ]; public function scopeActive($query) diff --git a/plugins/tps/birzha/models/UserSliders.php b/plugins/tps/birzha/models/UserSliders.php new file mode 100644 index 0000000..aff0144 --- /dev/null +++ b/plugins/tps/birzha/models/UserSliders.php @@ -0,0 +1,30 @@ + ['RainLab\User\Models\User', 'key' => 'user_id'], + ]; + /** + * @var string The database table used by the model. + */ + public $table = 'tps_birzha_user_sliders'; + + /** + * @var array Validation rules + */ + public $rules = [ + ]; +} diff --git a/plugins/tps/birzha/models/UsersCategory.php b/plugins/tps/birzha/models/UsersCategory.php new file mode 100644 index 0000000..905955d --- /dev/null +++ b/plugins/tps/birzha/models/UsersCategory.php @@ -0,0 +1,27 @@ +engine = 'InnoDB'; + $table->increments('id')->unsigned(); + $table->integer('user_id')->nullable(); + $table->string('img')->nullable(); + $table->string('note')->nullable(); + }); + } + + public function down() + { + Schema::dropIfExists('tps_birzha_user_sliders'); + } +} diff --git a/plugins/tps/birzha/updates/builder_table_create_tps_birzha_users_categories.php b/plugins/tps/birzha/updates/builder_table_create_tps_birzha_users_categories.php new file mode 100644 index 0000000..f65c2a0 --- /dev/null +++ b/plugins/tps/birzha/updates/builder_table_create_tps_birzha_users_categories.php @@ -0,0 +1,26 @@ +engine = 'InnoDB'; + $table->increments('id')->unsigned(); + $table->timestamp('created_at')->nullable(); + $table->timestamp('updated_at')->nullable(); + $table->timestamp('deleted_at')->nullable(); + $table->integer('user_id'); + $table->integer('category_id'); + }); + } + + public function down() + { + Schema::dropIfExists('tps_birzha_users_categories'); + } +} diff --git a/plugins/tps/birzha/updates/builder_table_update_tps_birzha_user_sliders.php b/plugins/tps/birzha/updates/builder_table_update_tps_birzha_user_sliders.php new file mode 100644 index 0000000..a10a611 --- /dev/null +++ b/plugins/tps/birzha/updates/builder_table_update_tps_birzha_user_sliders.php @@ -0,0 +1,27 @@ +timestamp('created_at')->nullable(); + $table->timestamp('updated_at')->nullable(); + $table->timestamp('deleted_at')->nullable(); + }); + } + + public function down() + { + Schema::table('tps_birzha_user_sliders', function($table) + { + $table->dropColumn('created_at'); + $table->dropColumn('updated_at'); + $table->dropColumn('deleted_at'); + }); + } +} diff --git a/plugins/tps/birzha/updates/builder_table_update_tps_birzha_user_sliders_2.php b/plugins/tps/birzha/updates/builder_table_update_tps_birzha_user_sliders_2.php new file mode 100644 index 0000000..73561a6 --- /dev/null +++ b/plugins/tps/birzha/updates/builder_table_update_tps_birzha_user_sliders_2.php @@ -0,0 +1,23 @@ +renameColumn('user_id', 'user'); + }); + } + + public function down() + { + Schema::table('tps_birzha_user_sliders', function($table) + { + $table->renameColumn('user', 'user_id'); + }); + } +} diff --git a/plugins/tps/birzha/updates/builder_table_update_tps_birzha_user_sliders_3.php b/plugins/tps/birzha/updates/builder_table_update_tps_birzha_user_sliders_3.php new file mode 100644 index 0000000..f10506d --- /dev/null +++ b/plugins/tps/birzha/updates/builder_table_update_tps_birzha_user_sliders_3.php @@ -0,0 +1,23 @@ +renameColumn('user', 'user_id'); + }); + } + + public function down() + { + Schema::table('tps_birzha_user_sliders', function($table) + { + $table->renameColumn('user_id', 'user'); + }); + } +} diff --git a/plugins/tps/birzha/updates/builder_table_update_tps_birzha_user_sliders_4.php b/plugins/tps/birzha/updates/builder_table_update_tps_birzha_user_sliders_4.php new file mode 100644 index 0000000..70bdc1f --- /dev/null +++ b/plugins/tps/birzha/updates/builder_table_update_tps_birzha_user_sliders_4.php @@ -0,0 +1,23 @@ +renameColumn('user_id', 'user'); + }); + } + + public function down() + { + Schema::table('tps_birzha_user_sliders', function($table) + { + $table->renameColumn('user', 'user_id'); + }); + } +} diff --git a/plugins/tps/birzha/updates/builder_table_update_tps_birzha_user_sliders_5.php b/plugins/tps/birzha/updates/builder_table_update_tps_birzha_user_sliders_5.php new file mode 100644 index 0000000..0c0d096 --- /dev/null +++ b/plugins/tps/birzha/updates/builder_table_update_tps_birzha_user_sliders_5.php @@ -0,0 +1,23 @@ +renameColumn('user', 'user_id'); + }); + } + + public function down() + { + Schema::table('tps_birzha_user_sliders', function($table) + { + $table->renameColumn('user_id', 'user'); + }); + } +} diff --git a/plugins/tps/birzha/updates/builder_table_update_tps_birzha_users_categories.php b/plugins/tps/birzha/updates/builder_table_update_tps_birzha_users_categories.php new file mode 100644 index 0000000..e0abc44 --- /dev/null +++ b/plugins/tps/birzha/updates/builder_table_update_tps_birzha_users_categories.php @@ -0,0 +1,27 @@ +dropColumn('created_at'); + $table->dropColumn('updated_at'); + $table->dropColumn('deleted_at'); + }); + } + + public function down() + { + Schema::table('tps_birzha_users_categories', function($table) + { + $table->timestamp('created_at')->nullable(); + $table->timestamp('updated_at')->nullable(); + $table->timestamp('deleted_at')->nullable(); + }); + } +} diff --git a/plugins/tps/birzha/updates/version.yaml b/plugins/tps/birzha/updates/version.yaml index 56e4c42..688fbf2 100644 --- a/plugins/tps/birzha/updates/version.yaml +++ b/plugins/tps/birzha/updates/version.yaml @@ -311,3 +311,27 @@ 1.0.110: - 'Updated table tps_birzha_categories' - builder_table_update_tps_birzha_categories_2.php +1.0.111: + - 'Created table tps_birzha_users_categories' + - builder_table_create_tps_birzha_users_categories.php +1.0.112: + - 'Updated table tps_birzha_users_categories' + - builder_table_update_tps_birzha_users_categories.php +1.0.113: + - 'Created table tps_birzha_user_sliders' + - builder_table_create_tps_birzha_user_sliders.php +1.0.114: + - 'Updated table tps_birzha_user_sliders' + - builder_table_update_tps_birzha_user_sliders.php +1.0.115: + - 'Updated table tps_birzha_user_sliders' + - builder_table_update_tps_birzha_user_sliders_2.php +1.0.116: + - 'Updated table tps_birzha_user_sliders' + - builder_table_update_tps_birzha_user_sliders_3.php +1.0.117: + - 'Updated table tps_birzha_user_sliders' + - builder_table_update_tps_birzha_user_sliders_4.php +1.0.118: + - 'Updated table tps_birzha_user_sliders' + - builder_table_update_tps_birzha_user_sliders_5.php diff --git a/plugins/vdomah/jwtauth/routes.php b/plugins/vdomah/jwtauth/routes.php index 09132cb..2cac5bb 100644 --- a/plugins/vdomah/jwtauth/routes.php +++ b/plugins/vdomah/jwtauth/routes.php @@ -1,61 +1,10 @@ 'api'], function() { - Route::post('auth-for-make-requests', function (Request $request) { - if (Settings::get('is_login_disabled')) - App::abort(404, 'Page not found'); - - $login_fields = Settings::get('login_fields', ['email', 'password']); - - $credentials = Input::only($login_fields); - // $username = $credentials['username']; - - try { - // verify the credentials and create a token for the user - if (! $token = JWTAuth::attempt($credentials)) { - return response()->json(['error' => [ - 'ru' => trans('validation.no_user', [], 'ru'), - 'en' => trans('validation.no_user', [], 'en'), - 'tm' => trans('validation.no_user', [], 'tm'), - ]], 401); - } - } catch (JWTException $e) { - // something went wrong - return response()->json(['error' => 'could_not_create_token'], 500); - } - - $userModel = JWTAuth::authenticate($token); - - // if user is not activated, he will not get token - if(!$userModel->is_activated) { - return response()->json(['error' => 'Not activated'], 403); - } - - if ($userModel->methodExists('getAuthApiSigninAttributes')) { - $user = $userModel->getAuthApiSigninAttributes(); - } else { - $user = [ - 'id' => $userModel->id, - 'name' => $userModel->name, - 'surname' => $userModel->surname, - 'username' => $userModel->username, - 'email' => $userModel->email, - 'is_activated' => $userModel->is_activated, - 'user_balance' => $userModel->user_balance, - 'email_verified' => $userModel->email_verified, - 'phone_verified' => $userModel->phone_verified - ]; - } - // if no errors are encountered we can return a JWT - return response()->json(compact('token', 'user')); - }); - Route::post('login', function (Request $request) { if (Settings::get('is_login_disabled')) App::abort(404, 'Page not found'); @@ -63,16 +12,11 @@ Route::group(['prefix' => 'api'], function() { $login_fields = Settings::get('login_fields', ['email', 'password']); $credentials = Input::only($login_fields); - $username = $credentials['username']; try { // verify the credentials and create a token for the user - if (! $token = JWTAuth::attempt(array_merge($credentials, ['username' => $credentials['dial_code'] . $username]))) { - return response()->json(['error' => [ - 'ru' => trans('validation.no_user', [], 'ru'), - 'en' => trans('validation.no_user', [], 'en'), - 'tm' => trans('validation.no_user', [], 'tm'), - ]], 401); + if (! $token = JWTAuth::attempt($credentials)) { + return response()->json(['error' => 'invalid_credentials'], 401); } } catch (JWTException $e) { // something went wrong @@ -81,11 +25,6 @@ Route::group(['prefix' => 'api'], function() { $userModel = JWTAuth::authenticate($token); - // if user is not activated, he will not get token - if(!$userModel->is_activated) { - return response()->json(['error' => 'Not activated'], 403); - } - if ($userModel->methodExists('getAuthApiSigninAttributes')) { $user = $userModel->getAuthApiSigninAttributes(); } else { @@ -96,9 +35,6 @@ Route::group(['prefix' => 'api'], function() { 'username' => $userModel->username, 'email' => $userModel->email, 'is_activated' => $userModel->is_activated, - 'user_balance' => $userModel->user_balance, - 'email_verified' => $userModel->email_verified, - 'phone_verified' => $userModel->phone_verified ]; } // if no errors are encountered we can return a JWT @@ -109,14 +45,7 @@ Route::group(['prefix' => 'api'], function() { if (Settings::get('is_refresh_disabled')) App::abort(404, 'Page not found'); - $validation = \Validator::make($request->all(), [ - 'token' => 'required' - ]); - if ($validation->fails()) { - return response()->json(['error' => $validation->errors()], 400); - } - - $token = $request->get('token'); + $token = Request::get('token'); try { // attempt to refresh the JWT @@ -157,68 +86,8 @@ Route::group(['prefix' => 'api'], function() { $login_fields = Settings::get('signup_fields', ['email', 'password', 'password_confirmation']); $credentials = Input::only($login_fields); - $rules = [ - 'email' => 'required|between:6,191|email|unique:users', - 'username' => 'required|numeric|unique:users', - 'dial_code' => 'required', - 'password' => 'required:create|between:8,255', - ]; - - $messages = [ - 'email.unique' => [ - 'ru' => trans('validation.api.email_already_exists', [], 'ru'), - 'en' => trans('validation.api.email_already_exists', [], 'en'), - 'tm' => trans('validation.api.email_already_exists', [], 'tm'), - ], - 'username.unique' => [ - 'ru' => trans('validation.api.phone_already_exists', [], 'ru'), - 'en' => trans('validation.api.phone_already_exists', [], 'en'), - 'tm' => trans('validation.api.phone_already_exists', [], 'tm'), - ], - ]; - - /** - * initial validation - - * $credentials['dial_code'], $credentials['username'] can throw error if not set - */ - $validation = \Validator::make($credentials, $rules, $messages); - if ($validation->fails()) { - - $errorResponse = $validation->errors(); - - $errorResponse = reset($errorResponse); - - return Response::json(['error' => reset($errorResponse)[0]], 400); - } - - // dial_code should be concatenated with username in order to check - validate - // if a user (with dial_code + username) already exists - $credentialsToValidate = array_merge($credentials,[ - 'username' => $credentials['dial_code'] . $credentials['username'] - ]); - - $validation = \Validator::make($credentialsToValidate, $rules, $messages); - if ($validation->fails()) { - - $errorResponse = $validation->errors(); - - $errorResponse = reset($errorResponse); - - return Response::json(['error' => reset($errorResponse)[0]], 400); - } - - /** - * activation is set to be automatic - */ - $automaticActivation = UserSettings::get('activate_mode') == UserSettings::ACTIVATE_AUTO; - try { - // password_confirmation is required - // but not used when signing up like on web-site - if (!array_key_exists('password_confirmation', $credentials) && array_key_exists('password', $credentials)) { - $credentials['password_confirmation'] = $credentials['password']; - } - $userModel = Auth::register($credentials, $automaticActivation); + $userModel = UserModel::create($credentials); if ($userModel->methodExists('getAuthApiSignupAttributes')) { $user = $userModel->getAuthApiSignupAttributes(); @@ -228,132 +97,16 @@ Route::group(['prefix' => 'api'], function() { 'name' => $userModel->name, 'surname' => $userModel->surname, 'username' => $userModel->username, - 'dial_code' => $userModel->dial_code, 'email' => $userModel->email, 'is_activated' => $userModel->is_activated, - 'user_balance' => $userModel->user_balance, - 'email_verified' => $userModel->email_verified, - 'phone_verified' => $userModel->phone_verified ]; } } catch (Exception $e) { - - \Log::info($e->getMessage()); - - return Response::json(['error' => [ - 'ru' => trans('validation.api.sign_up_excp', [], 'ru'), - 'en' => trans('validation.api.sign_up_excp', [], 'en'), - 'tm' => trans('validation.api.sign_up_excp', [], 'tm'), - ]], 401); + return Response::json(['error' => $e->getMessage()], 401); } $token = JWTAuth::fromUser($userModel); - - Event::fire('rainlab.user.register', $userModel); return Response::json(compact('token', 'user')); }); - - Route::get('me', function() { - - $me = \JWTAuth::parseToken()->authenticate() - ->only(['name','surname','email','username','is_activated','phone','company','street_addr','city','mobile','user_balance','email_verified','phone_verified', 'zip']); - - return Response::json(compact('me')); - - })->middleware('\Tymon\JWTAuth\Middleware\GetUserFromToken'); - - Route::post('me', function(Request $request) { - - $me = \JWTAuth::parseToken()->authenticate(); - if(!$me) { - return Response::json(['error' => 'Not found'], 404); - } - - $data = Input::except(['username']); - - $rules = [ - 'email' => 'required|between:6,191|email', - 'name' => 'required', - 'surname' => 'required', - // 'username' => 'required|digits_between:8,20|numeric', - 'company' => 'max:191', - ]; - - $validation = \Validator::make($data, $rules,(new UserModel)->messages); - if ($validation->fails()) { - return Response::json(['error' => $validation->errors()], 400); - } - - /** - * If password in input data, add rules for password - */ - if (array_key_exists('password', $data) && strlen($data['password'])) { - $rules = [ - 'password' => 'required:create|between:8,255|confirmed', - 'password_confirmation' => 'required_with:password|between:8,255' - ]; - - $validation = \Validator::make($data, $rules,(new UserModel)->messages); - if ($validation->fails()) { - return Response::json(['error' => $validation->errors()], 400); - } - } - - if($me->email != $data['email']) { - $me->email_verified = false; - $me->save(); - } - - $me->fill($data); - $me->save(); - - /* - * Password has changed, reauthenticate the user - send new token - */ - if (array_key_exists('password', $data) && strlen($data['password'])) { - - $credentials['username'] = $me->username; - $credentials['password'] = $data['password']; - - try { - // verify the credentials and create a token for the user - if (! $token = JWTAuth::attempt($credentials)) { - return response()->json(['error' => 'invalid_credentials'], 401); - } - } catch (JWTException $e) { - // something went wrong - return response()->json(['error' => 'could_not_create_token'], 500); - } - - $userModel = JWTAuth::authenticate($token); - - // if user is not activated, he will not get token - if(!$userModel->is_activated) { - return response()->json(['error' => 'Not activated'], 403); - } - - if ($userModel->methodExists('getAuthApiSigninAttributes')) { - $user = $userModel->getAuthApiSigninAttributes(); - } else { - $user = [ - 'id' => $userModel->id, - 'name' => $userModel->name, - 'surname' => $userModel->surname, - 'username' => $userModel->username, - 'email' => $userModel->email, - 'is_activated' => $userModel->is_activated, - 'user_balance' => $userModel->user_balance, - 'email_verified' => $userModel->email_verified, - 'phone_verified' => $userModel->phone_verified - ]; - } - // if no errors are encountered we can return a JWT - return response()->json(compact('token', 'user')); - - } - - return Response::json(compact('me')); - - })->middleware('\Tymon\JWTAuth\Middleware\GetUserFromToken'); });