mirror of
https://github.com/BookStackApp/BookStack.git
synced 2026-02-18 03:09:40 +03:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
598758b991 | ||
|
|
9926e23bc8 | ||
|
|
6638ee47d3 | ||
|
|
5d3264bc63 | ||
|
|
d71f819f95 | ||
|
|
80f844139c | ||
|
|
9eecaea31a | ||
|
|
ee13509760 | ||
|
|
82d7bb1f32 | ||
|
|
492e2f173e |
@@ -208,7 +208,7 @@ class BookController extends Controller
|
||||
}
|
||||
|
||||
// Update permissions on changed models
|
||||
$this->entityRepo->buildJointPermissions($updatedModels);
|
||||
if (count($updatedModels) === 0) $this->entityRepo->buildJointPermissions($updatedModels);
|
||||
|
||||
return redirect($book->getUrl());
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ class Kernel extends HttpKernel
|
||||
*/
|
||||
protected $middleware = [
|
||||
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -24,8 +26,6 @@ class Kernel extends HttpKernel
|
||||
'web' => [
|
||||
\BookStack\Http\Middleware\EncryptCookies::class,
|
||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
\BookStack\Http\Middleware\VerifyCsrfToken::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
\BookStack\Http\Middleware\Localization::class
|
||||
|
||||
@@ -332,12 +332,12 @@ class EntityRepo
|
||||
$parents[$key] = $entities[$index];
|
||||
$parents[$key]->setAttribute('pages', collect());
|
||||
}
|
||||
if ($entities[$index]->chapter_id === 0) $tree[] = $entities[$index];
|
||||
if ($entities[$index]->chapter_id === 0 || $entities[$index]->chapter_id === '0') $tree[] = $entities[$index];
|
||||
$entities[$index]->book = $book;
|
||||
}
|
||||
|
||||
foreach ($entities as $entity) {
|
||||
if ($entity->chapter_id === 0) continue;
|
||||
if ($entity->chapter_id === 0 || $entity->chapter_id === '0') continue;
|
||||
$parentKey = 'BookStack\\Chapter:' . $entity->chapter_id;
|
||||
$chapter = $parents[$parentKey];
|
||||
$chapter->pages->push($entity);
|
||||
|
||||
@@ -243,13 +243,14 @@ class PermissionService
|
||||
*/
|
||||
protected function deleteManyJointPermissionsForEntities($entities)
|
||||
{
|
||||
if (count($entities) === 0) return;
|
||||
$query = $this->jointPermission->newQuery();
|
||||
foreach ($entities as $entity) {
|
||||
$query->orWhere(function($query) use ($entity) {
|
||||
$query->where('entity_id', '=', $entity->id)
|
||||
->where('entity_type', '=', $entity->getMorphClass());
|
||||
});
|
||||
}
|
||||
foreach ($entities as $entity) {
|
||||
$query->orWhere(function($query) use ($entity) {
|
||||
$query->where('entity_id', '=', $entity->id)
|
||||
->where('entity_type', '=', $entity->getMorphClass());
|
||||
});
|
||||
}
|
||||
$query->delete();
|
||||
}
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
|
||||
if ($imageId === 0 || $imageId === '0' || $imageId === null) return $default;
|
||||
|
||||
try {
|
||||
$avatar = baseUrl($this->avatar->getThumb($size, $size, false));
|
||||
$avatar = $this->avatar ? baseUrl($this->avatar->getThumb($size, $size, false)) : $default;
|
||||
} catch (\Exception $err) {
|
||||
$avatar = $default;
|
||||
}
|
||||
|
||||
@@ -37,6 +37,15 @@ function user()
|
||||
return auth()->user() ?: \BookStack\User::getDefault();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if current user is a signed in user.
|
||||
* @return bool
|
||||
*/
|
||||
function signedInUser()
|
||||
{
|
||||
return auth()->user() && !auth()->user()->isDefault();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the current user has a permission.
|
||||
* If an ownable element is passed in the jointPermissions are checked against
|
||||
|
||||
@@ -47,7 +47,9 @@
|
||||
],
|
||||
"post-install-cmd": [
|
||||
"Illuminate\\Foundation\\ComposerScripts::postInstall",
|
||||
"php artisan optimize"
|
||||
"php artisan optimize",
|
||||
"php artisan cache:clear",
|
||||
"php artisan view:clear"
|
||||
],
|
||||
"post-update-cmd": [
|
||||
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
|
||||
|
||||
2
public/css/export-styles.css
vendored
2
public/css/export-styles.css
vendored
File diff suppressed because one or more lines are too long
2
public/css/styles.css
vendored
2
public/css/styles.css
vendored
File diff suppressed because one or more lines are too long
@@ -119,6 +119,11 @@ sup, .superscript {
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
sub, .subscript {
|
||||
vertical-align: sub;
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
pre {
|
||||
font-family: monospace;
|
||||
white-space:pre;
|
||||
|
||||
@@ -55,15 +55,15 @@
|
||||
<div class="float right">
|
||||
<div class="links text-center">
|
||||
<a href="{{ baseUrl('/books') }}"><i class="zmdi zmdi-book"></i>{{ trans('entities.books') }}</a>
|
||||
@if(isset($currentUser) && userCan('settings-manage'))
|
||||
@if(signedInUser() && userCan('settings-manage'))
|
||||
<a href="{{ baseUrl('/settings') }}"><i class="zmdi zmdi-settings"></i>{{ trans('settings.settings') }}</a>
|
||||
@endif
|
||||
@if(!isset($signedIn) || !$signedIn)
|
||||
@if(!signedInUser())
|
||||
<a href="{{ baseUrl('/login') }}"><i class="zmdi zmdi-sign-in"></i>{{ trans('auth.log_in') }}</a>
|
||||
@endif
|
||||
</div>
|
||||
@if(isset($signedIn) && $signedIn)
|
||||
@include('partials._header-dropdown', ['currentUser' => $currentUser])
|
||||
@if(signedInUser())
|
||||
@include('partials._header-dropdown', ['currentUser' => user()])
|
||||
@endif
|
||||
|
||||
</div>
|
||||
|
||||
@@ -10,22 +10,24 @@
|
||||
<p>{{ trans('errors.sorry_page_not_found') }}</p>
|
||||
<p><a href="{{ baseUrl('/') }}" class="button">{{ trans('errors.return_home') }}</a></p>
|
||||
|
||||
<hr>
|
||||
@if (setting('app-public') || !user()->isDefault())
|
||||
<hr>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<h3 class="text-muted">{{ trans('entities.pages_popular') }}</h3>
|
||||
@include('partials.entity-list', ['entities' => Views::getPopular(10, 0, [\BookStack\Page::class]), 'style' => 'compact'])
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<h3 class="text-muted">{{ trans('entities.pages_popular') }}</h3>
|
||||
@include('partials.entity-list', ['entities' => Views::getPopular(10, 0, [\BookStack\Page::class]), 'style' => 'compact'])
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<h3 class="text-muted">{{ trans('entities.books_popular') }}</h3>
|
||||
@include('partials.entity-list', ['entities' => Views::getPopular(10, 0, [\BookStack\Book::class]), 'style' => 'compact'])
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<h3 class="text-muted">{{ trans('entities.chapters_popular') }}</h3>
|
||||
@include('partials.entity-list', ['entities' => Views::getPopular(10, 0, [\BookStack\Chapter::class]), 'style' => 'compact'])
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<h3 class="text-muted">{{ trans('entities.books_popular') }}</h3>
|
||||
@include('partials.entity-list', ['entities' => Views::getPopular(10, 0, [\BookStack\Book::class]), 'style' => 'compact'])
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<h3 class="text-muted">{{ trans('entities.chapters_popular') }}</h3>
|
||||
@include('partials.entity-list', ['entities' => Views::getPopular(10, 0, [\BookStack\Chapter::class]), 'style' => 'compact'])
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
@stop
|
||||
@@ -80,4 +80,14 @@ class PublicActionTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_content_not_listed_on_404_for_public_users()
|
||||
{
|
||||
$page = \BookStack\Page::first();
|
||||
$this->asAdmin()->visit($page->getUrl());
|
||||
Auth::logout();
|
||||
view()->share('pageTitle', '');
|
||||
$this->forceVisit('/cats/dogs/hippos');
|
||||
$this->dontSee($page->name);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user