Merge photo comments feature #114
9
app/AlbumDefaultGroupPermission.php
Normal file
9
app/AlbumDefaultGroupPermission.php
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class AlbumDefaultGroupPermission extends Model
|
||||||
|
{
|
||||||
|
}
|
9
app/AlbumDefaultUserPermission.php
Normal file
9
app/AlbumDefaultUserPermission.php
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class AlbumDefaultUserPermission extends Model
|
||||||
|
{
|
||||||
|
}
|
@ -3,6 +3,8 @@
|
|||||||
namespace App\Http\Controllers\Admin;
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
use App\Album;
|
use App\Album;
|
||||||
|
use App\AlbumDefaultGroupPermission;
|
||||||
|
use App\AlbumDefaultUserPermission;
|
||||||
use App\AlbumRedirect;
|
use App\AlbumRedirect;
|
||||||
use App\Facade\Theme;
|
use App\Facade\Theme;
|
||||||
use App\Facade\UserConfig;
|
use App\Facade\UserConfig;
|
||||||
@ -83,6 +85,41 @@ class AlbumController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function defaultPermissions()
|
||||||
|
{
|
||||||
|
$this->authorizeAccessToAdminPanel('admin:manage-albums');
|
||||||
|
|
||||||
|
$addNewGroups = [];
|
||||||
|
$existingGroups = [];
|
||||||
|
foreach (Group::orderBy('name')->get() as $group)
|
||||||
|
{
|
||||||
|
if (AlbumDefaultGroupPermission::where('group_id', $group->id)->count() == 0)
|
||||||
|
{
|
||||||
|
$addNewGroups[] = $group;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$existingGroups[] = $group;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$existingUsers = [];
|
||||||
|
foreach (User::orderBy('name')->get() as $user)
|
||||||
|
{
|
||||||
|
if (AlbumDefaultUserPermission::where('user_id', $user->id)->count() > 0)
|
||||||
|
{
|
||||||
|
$existingUsers[] = $user;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Theme::render('admin.album_default_permissions', [
|
||||||
|
'add_new_groups' => $addNewGroups,
|
||||||
|
'all_permissions' => Permission::where('section', 'album')->get(),
|
||||||
|
'existing_groups' => $existingGroups,
|
||||||
|
'existing_users' => $existingUsers
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
public function delete($id)
|
public function delete($id)
|
||||||
{
|
{
|
||||||
$this->authorizeAccessToAdminPanel('admin:manage-albums');
|
$this->authorizeAccessToAdminPanel('admin:manage-albums');
|
||||||
|
@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class CreateAlbumDefaultGroupPermissionsTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('album_default_group_permissions', function (Blueprint $table) {
|
||||||
|
$table->unsignedInteger('group_id');
|
||||||
|
$table->unsignedInteger('permission_id');
|
||||||
|
|
||||||
|
$table->foreign('group_id')
|
||||||
|
->references('id')->on('groups')
|
||||||
|
->onDelete('cascade');
|
||||||
|
$table->foreign('permission_id')
|
||||||
|
->references('id')->on('permissions')
|
||||||
|
->onDelete('no action');
|
||||||
|
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('album_default_group_permissions');
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class CreateAlbumDefaultUserPermissionsTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('album_default_user_permissions', function (Blueprint $table) {
|
||||||
|
$table->unsignedInteger('user_id');
|
||||||
|
$table->unsignedInteger('permission_id');
|
||||||
|
|
||||||
|
$table->foreign('user_id')
|
||||||
|
->references('id')->on('users')
|
||||||
|
->onDelete('cascade');
|
||||||
|
$table->foreign('permission_id')
|
||||||
|
->references('id')->on('permissions')
|
||||||
|
->onDelete('no action');
|
||||||
|
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('album_default_user_permissions');
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class CreateAlbumDefaultAnonymousPermissionsTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('album_default_anonymous_permissions', function (Blueprint $table) {
|
||||||
|
$table->unsignedInteger('permission_id');
|
||||||
|
|
||||||
|
$table->foreign('permission_id')
|
||||||
|
->references('id')->on('permissions')
|
||||||
|
->onDelete('no action');
|
||||||
|
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('album_default_anonymous_permissions');
|
||||||
|
}
|
||||||
|
}
|
@ -81,6 +81,11 @@ return [
|
|||||||
'create_user_title' => 'Create a user account',
|
'create_user_title' => 'Create a user account',
|
||||||
'danger_zone_heading' => 'Danger zone',
|
'danger_zone_heading' => 'Danger zone',
|
||||||
'danger_zone_intro' => 'The options below WILL cause data loss - please be careful!',
|
'danger_zone_intro' => 'The options below WILL cause data loss - please be careful!',
|
||||||
|
'default_album_permissions' => [
|
||||||
|
'intro' => 'An album can inherit its security permissions from its parent album. Top-level albums, however, do not have a parent album, so they can be set to inherit the default permissions you set here.',
|
||||||
|
'intro_2' => 'When you create a new album, if you choose not to inherit its permissions, the permissions you set here will be copied into tbe new album as a starting point.',
|
||||||
|
'title' => 'Default Album Permissions'
|
||||||
|
],
|
||||||
'default_storage_legend' => 'Default storage location for new albums.',
|
'default_storage_legend' => 'Default storage location for new albums.',
|
||||||
'delete_album' => 'Delete album :name',
|
'delete_album' => 'Delete album :name',
|
||||||
'delete_album_confirm' => 'Are you sure you want to permanently delete this album and all its contents?',
|
'delete_album_confirm' => 'Are you sure you want to permanently delete this album and all its contents?',
|
||||||
|
@ -9,6 +9,7 @@ return [
|
|||||||
'create_group' => 'Create group',
|
'create_group' => 'Create group',
|
||||||
'create_storage' => 'Create storage',
|
'create_storage' => 'Create storage',
|
||||||
'create_user' => 'Create user',
|
'create_user' => 'Create user',
|
||||||
|
'default_album_permissions' => 'Default album permissions',
|
||||||
'delete_album' => 'Delete album',
|
'delete_album' => 'Delete album',
|
||||||
'delete_group' => 'Delete group',
|
'delete_group' => 'Delete group',
|
||||||
'delete_label' => 'Delete label',
|
'delete_label' => 'Delete label',
|
||||||
|
@ -0,0 +1,105 @@
|
|||||||
|
@extends(Theme::viewName('layout'))
|
||||||
|
@section('title', 'Gallery Admin')
|
||||||
|
|
||||||
|
@section('breadcrumb')
|
||||||
|
<li class="breadcrumb-item"><a href="{{ route('home') }}"><i class="fa fa-fw fa-home"></i></a></li>
|
||||||
|
<li class="breadcrumb-item"><a href="{{ route('admin') }}">@lang('navigation.breadcrumb.admin')</a></li>
|
||||||
|
<li class="breadcrumb-item"><a href="{{ route('admin.settings') }}">@lang('navigation.breadcrumb.settings')</a></li>
|
||||||
|
<li class="breadcrumb-item active">@lang('navigation.breadcrumb.default_album_permissions')</li>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
<h1>@lang('admin.default_album_permissions.title')</h1>
|
||||||
|
<div class="alert alert-info mb-4">
|
||||||
|
<p><i class="fa fa-fw fa-info"></i>@lang('admin.default_album_permissions.intro')</p>
|
||||||
|
<p class="mb-0">@lang('admin.default_album_permissions.intro_2')</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form action="{{ route('albums.set_default_group_permissions') }}" method="post">
|
||||||
|
{{ csrf_field() }}
|
||||||
|
|
||||||
|
@if (count($existing_groups) > 0)
|
||||||
|
<div id="groups-accordion" role="tablist" aria-multiselectable="true">
|
||||||
|
@foreach ($existing_groups as $group)
|
||||||
|
@include(Theme::viewName('partials.album_permissions'), [
|
||||||
|
'key_id' => 'group_' . $group->id,
|
||||||
|
'object_id' => $group->id,
|
||||||
|
'title' => $group->name,
|
||||||
|
'callback' => [$album, 'doesGroupHavePermission'],
|
||||||
|
'callback_object' => $group,
|
||||||
|
'parent_id' => 'groups-accordion'
|
||||||
|
])
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<div class="row mt-3">
|
||||||
|
<div class="col-md-4">
|
||||||
|
<select class="form-control" name="group_id" style="margin-bottom: 2px;"@if (count($add_new_groups) == 0) disabled="disabled"@endif>
|
||||||
|
@foreach ($add_new_groups as $group)
|
||||||
|
<option value="{{ $group->id }}">{{ $group->name }}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-2">
|
||||||
|
<button type="submit" name="action" value="add_group" class="btn btn-primary">Assign Permissions</button>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 text-right">
|
||||||
|
<button type="submit" name="action" value="update_group_permissions" class="btn btn-success">
|
||||||
|
<i class="fa fa-fw fa-check"></i> @lang('forms.save_action')
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<hr/>
|
||||||
|
|
||||||
|
<h5 style="font-weight: bold;">@lang('admin.security_users_heading')</h5>
|
||||||
|
|
||||||
|
<form action="{{ route('albums.set_default_user_permissions') }}" method="post">
|
||||||
|
{{ csrf_field() }}
|
||||||
|
|
||||||
|
<div id="users-accordion" role="tablist" aria-multiselectable="true">
|
||||||
|
{{-- Anonymous users --}}
|
||||||
|
@include(Theme::viewName('partials.album_permissions'), [
|
||||||
|
'key_id' => 'anonymous',
|
||||||
|
'object_id' => 'anonymous',
|
||||||
|
'title' => trans('admin.anonymous_users'),
|
||||||
|
'callback' => [$album, 'doesUserHavePermission'],
|
||||||
|
'callback_object' => null,
|
||||||
|
'parent_id' => 'users-accordion'
|
||||||
|
])
|
||||||
|
|
||||||
|
@foreach ($existing_users as $user)
|
||||||
|
@include(Theme::viewName('partials.album_permissions'), [
|
||||||
|
'key_id' => 'user_' . $user->id,
|
||||||
|
'object_id' => $user->id,
|
||||||
|
'title' => $user->name,
|
||||||
|
'callback' => [$album, 'doesUserHavePermission'],
|
||||||
|
'callback_object' => $user,
|
||||||
|
'parent_id' => 'users-accordion'
|
||||||
|
])
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row mt-3">
|
||||||
|
<div class="col-md-4">
|
||||||
|
<input class="form-control" name="user_name" id="user-search-textbox" size="20" style="margin-bottom: 2px;" />
|
||||||
|
<input type="hidden" name="user_id" id="user-id-field" />
|
||||||
|
</div>
|
||||||
|
<div class="col-md-2">
|
||||||
|
<button type="submit" name="action" value="add_user" class="btn btn-primary">Assign Permissions</button>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 text-right">
|
||||||
|
<button type="submit" name="action" value="update_user_permissions" class="btn btn-success">
|
||||||
|
<i class="fa fa-fw fa-check"></i> @lang('forms.save_action')
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
@ -27,6 +27,9 @@ Route::group(['prefix' => 'admin'], function () {
|
|||||||
Route::post('statistics/save', 'Admin\StatisticsController@save')->name('admin.statistics.save');
|
Route::post('statistics/save', 'Admin\StatisticsController@save')->name('admin.statistics.save');
|
||||||
|
|
||||||
// Album management
|
// Album management
|
||||||
|
Route::get('albums/default-permissions', 'Admin\AlbumController@defaultPermissions')->name('albums.defaultPermissions');
|
||||||
|
Route::post('albums/set-default-group-permissions', 'Admin\AlbumController@setDefaultGroupPermissions')->name('albums.set_default_group_permissions');
|
||||||
|
Route::post('albums/set-default-user-permissions', 'Admin\AlbumController@setDefaultUserPermissions')->name('albums.set_default_user_permissions');
|
||||||
Route::get('albums/{id}/analyse/{queue_token}', 'Admin\AlbumController@analyse')->name('albums.analyse');
|
Route::get('albums/{id}/analyse/{queue_token}', 'Admin\AlbumController@analyse')->name('albums.analyse');
|
||||||
Route::get('albums/{id}/delete', 'Admin\AlbumController@delete')->name('albums.delete');
|
Route::get('albums/{id}/delete', 'Admin\AlbumController@delete')->name('albums.delete');
|
||||||
Route::get('/albums/{id}/metadata', 'Admin\AlbumController@metadata')->name('albums.metadata');
|
Route::get('/albums/{id}/metadata', 'Admin\AlbumController@metadata')->name('albums.metadata');
|
||||||
|
Loading…
Reference in New Issue
Block a user