diff --git a/database/migrations/2018_09_14_091046_create_album_permissions_cache_table.php b/database/migrations/2018_09_14_091046_create_album_permissions_cache_table.php new file mode 100644 index 0000000..ab1c524 --- /dev/null +++ b/database/migrations/2018_09_14_091046_create_album_permissions_cache_table.php @@ -0,0 +1,42 @@ +unsignedInteger('user_id'); + $table->unsignedInteger('album_id'); + $table->unsignedInteger('permission_id'); + + $table->foreign('user_id') + ->references('id')->on('users') + ->onDelete('cascade'); + $table->foreign('album_id') + ->references('id')->on('albums') + ->onDelete('cascade'); + $table->foreign('permission_id') + ->references('id')->on('permissions') + ->onDelete('no action'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('album_permissions_cache'); + } +} diff --git a/resources/assets/js/admin.js b/resources/assets/js/admin.js index 69500bd..4d948d6 100644 --- a/resources/assets/js/admin.js +++ b/resources/assets/js/admin.js @@ -44,4 +44,38 @@ function AboutViewModel(urls) { ); } }; +} + +/** + * This model is used by admin/settings.blade.php. + * @constructor + */ +function SettingsViewModel(urls) { + this.el = '#settings-app'; + + this.data = { + is_rebuilding_permissions_cache: false + }; + + this.methods = { + rebuildPermissionsCache: function () { + var self = this; + + $.ajax( + urls.rebuild_permissions_cache, + { + complete: function() { + self.is_rebuilding_permissions_cache = false; + }, + dataType: 'json', + error: function (xhr, textStatus, errorThrown) { + }, + method: 'GET', + success: function (data) { + alert('success'); + } + } + ); + } + }; } \ No newline at end of file diff --git a/resources/lang/en/admin.php b/resources/lang/en/admin.php index 9358efc..3cfe68d 100644 --- a/resources/lang/en/admin.php +++ b/resources/lang/en/admin.php @@ -209,6 +209,9 @@ return [ 'analytics_enable_visitor_hits' => 'Enable built-in visitor hit tracking', 'analytics_enable_visitor_hits_description' => 'Visitor hits to the public gallery will be recorded in the Blue Twilight database, allowing for analysis such as the most popular album/photo.', 'analytics_tab' => 'Analytics', + 'permissions_cache' => 'Permissions Cache', + 'permissions_cache_intro' => 'Blue Twilight maintains the permissions each user has to albums in the database. If you feel these aren\'t correct based on what\'s configured, you can rebuild the cache by clicking the button below.', + 'rebuild_permissions_cache' => 'Rebuild Permissions Cache', 'security_allow_self_registration' => 'Allow self-registration', 'security_allow_self_registration_description' => 'With this option enabled, users can sign up for their own accounts. You can grant permissions to accounts to allow users to upload their own photos or manage yours.', 'social_facebook' => 'Facebook', diff --git a/resources/views/themes/base/admin/settings.blade.php b/resources/views/themes/base/admin/settings.blade.php index 89deec9..e16249a 100644 --- a/resources/views/themes/base/admin/settings.blade.php +++ b/resources/views/themes/base/admin/settings.blade.php @@ -10,7 +10,7 @@ @section('content')
-
+

@yield('title')

@lang('admin.settings_intro')

@@ -239,7 +239,9 @@
-
+
+ +
@lang('admin.settings_recaptcha')
@@ -265,7 +267,9 @@
-
+
+ +
@lang('admin.settings_image_protection')
@@ -284,6 +288,14 @@
+ +
+ +
+ @lang('admin.settings.permissions_cache') +

@lang('admin.settings.permissions_cache_intro')

+ +
{{-- Analytics --}} @@ -479,7 +491,13 @@ @push('scripts')