]> BookStack Code Mirror - bookstack/commitdiff
Apply fixes from StyleCI 2820/head
authorDan Brown <redacted>
Sat, 26 Jun 2021 15:23:15 +0000 (15:23 +0000)
committerStyleCI Bot <redacted>
Sat, 26 Jun 2021 15:23:15 +0000 (15:23 +0000)
349 files changed:
app/Actions/Activity.php
app/Actions/ActivityService.php
app/Actions/ActivityType.php
app/Actions/Comment.php
app/Actions/CommentRepo.php
app/Actions/Favourite.php
app/Actions/Tag.php
app/Actions/TagRepo.php
app/Actions/View.php
app/Api/ApiDocsGenerator.php
app/Api/ApiToken.php
app/Api/ApiTokenGuard.php
app/Api/ListingResponseBuilder.php
app/Application.php
app/Auth/Access/EmailConfirmationService.php
app/Auth/Access/ExternalAuthService.php
app/Auth/Access/ExternalBaseUserProvider.php
app/Auth/Access/Guards/ExternalBaseSessionGuard.php
app/Auth/Access/Guards/LdapSessionGuard.php
app/Auth/Access/Guards/Saml2SessionGuard.php
app/Auth/Access/Ldap.php
app/Auth/Access/LdapService.php
app/Auth/Access/RegistrationService.php
app/Auth/Access/Saml2Service.php
app/Auth/Access/SocialAuthService.php
app/Auth/Access/UserInviteService.php
app/Auth/Access/UserTokenService.php
app/Auth/Permissions/EntityPermission.php
app/Auth/Permissions/JointPermission.php
app/Auth/Permissions/PermissionService.php
app/Auth/Permissions/PermissionsRepo.php
app/Auth/Permissions/RolePermission.php
app/Auth/Role.php
app/Auth/SocialAccount.php
app/Auth/User.php
app/Auth/UserRepo.php
app/Config/api.php
app/Config/app.php
app/Config/auth.php
app/Config/broadcasting.php
app/Config/cache.php
app/Config/database.php
app/Config/debugbar.php
app/Config/dompdf.php
app/Config/filesystems.php
app/Config/hashing.php
app/Config/logging.php
app/Config/mail.php
app/Config/queue.php
app/Config/saml2.php
app/Config/services.php
app/Config/session.php
app/Config/setting-defaults.php
app/Config/snappy.php
app/Console/Commands/CleanupImages.php
app/Console/Commands/ClearViews.php
app/Console/Commands/CopyShelfPermissions.php
app/Console/Commands/CreateAdmin.php
app/Console/Commands/DeleteUsers.php
app/Console/Commands/UpdateUrl.php
app/Console/Commands/UpgradeDatabaseEncoding.php
app/Console/Kernel.php
app/Entities/BreadcrumbsViewComposer.php
app/Entities/EntityProvider.php
app/Entities/Models/Book.php
app/Entities/Models/BookChild.php
app/Entities/Models/Bookshelf.php
app/Entities/Models/Chapter.php
app/Entities/Models/Deletion.php
app/Entities/Models/Entity.php
app/Entities/Models/HasCoverImage.php
app/Entities/Models/Page.php
app/Entities/Models/PageRevision.php
app/Entities/Models/SearchTerm.php
app/Entities/Queries/EntityQuery.php
app/Entities/Queries/Popular.php
app/Entities/Queries/RecentlyViewed.php
app/Entities/Queries/TopFavourites.php
app/Entities/Repos/BaseRepo.php
app/Entities/Repos/BookRepo.php
app/Entities/Repos/BookshelfRepo.php
app/Entities/Repos/ChapterRepo.php
app/Entities/Repos/PageRepo.php
app/Entities/Tools/BookContents.php
app/Entities/Tools/ExportFormatter.php
app/Entities/Tools/Markdown/CustomParagraphConverter.php
app/Entities/Tools/Markdown/CustomStrikeThroughExtension.php
app/Entities/Tools/Markdown/CustomStrikethroughRenderer.php
app/Entities/Tools/Markdown/HtmlToMarkdown.php
app/Entities/Tools/NextPreviousContentLocator.php
app/Entities/Tools/PageContent.php
app/Entities/Tools/PageEditActivity.php
app/Entities/Tools/PermissionsUpdater.php
app/Entities/Tools/SearchIndex.php
app/Entities/Tools/SearchOptions.php
app/Entities/Tools/SearchRunner.php
app/Entities/Tools/ShelfContext.php
app/Entities/Tools/SiblingFetcher.php
app/Entities/Tools/SlugGenerator.php
app/Entities/Tools/TrashCan.php
app/Exceptions/ApiAuthException.php
app/Exceptions/ConfirmationEmailException.php
app/Exceptions/FileUploadException.php
app/Exceptions/Handler.php
app/Exceptions/HttpFetchException.php
app/Exceptions/ImageUploadException.php
app/Exceptions/JsonDebugException.php
app/Exceptions/LdapException.php
app/Exceptions/LoginAttemptEmailNeededException.php
app/Exceptions/LoginAttemptException.php
app/Exceptions/MoveOperationException.php
app/Exceptions/NotFoundException.php
app/Exceptions/NotifyException.php
app/Exceptions/PermissionsException.php
app/Exceptions/PrettyException.php
app/Exceptions/SamlException.php
app/Exceptions/SocialDriverNotConfigured.php
app/Exceptions/SocialSignInAccountNotUsed.php
app/Exceptions/SocialSignInException.php
app/Exceptions/SortOperationException.php
app/Exceptions/UnauthorizedException.php
app/Exceptions/UserRegistrationException.php
app/Exceptions/UserTokenExpiredException.php
app/Exceptions/UserTokenNotFoundException.php
app/Exceptions/UserUpdateException.php
app/Facades/Activity.php
app/Facades/Permissions.php
app/Facades/Theme.php
app/Http/Controllers/Api/ApiController.php
app/Http/Controllers/Api/ApiDocsController.php
app/Http/Controllers/Api/BookApiController.php
app/Http/Controllers/Api/BookExportApiController.php
app/Http/Controllers/Api/BookshelfApiController.php
app/Http/Controllers/Api/ChapterApiController.php
app/Http/Controllers/Api/ChapterExportApiController.php
app/Http/Controllers/Api/PageApiController.php
app/Http/Controllers/Api/PageExportApiController.php
app/Http/Controllers/AttachmentController.php
app/Http/Controllers/AuditLogController.php
app/Http/Controllers/Auth/ConfirmEmailController.php
app/Http/Controllers/Auth/ForgotPasswordController.php
app/Http/Controllers/Auth/LoginController.php
app/Http/Controllers/Auth/RegisterController.php
app/Http/Controllers/Auth/ResetPasswordController.php
app/Http/Controllers/Auth/Saml2Controller.php
app/Http/Controllers/Auth/SocialController.php
app/Http/Controllers/Auth/UserInviteController.php
app/Http/Controllers/BookController.php
app/Http/Controllers/BookExportController.php
app/Http/Controllers/BookSortController.php
app/Http/Controllers/BookshelfController.php
app/Http/Controllers/ChapterController.php
app/Http/Controllers/ChapterExportController.php
app/Http/Controllers/CommentController.php
app/Http/Controllers/Controller.php
app/Http/Controllers/FavouriteController.php
app/Http/Controllers/HomeController.php
app/Http/Controllers/Images/DrawioImageController.php
app/Http/Controllers/Images/GalleryImageController.php
app/Http/Controllers/Images/ImageController.php
app/Http/Controllers/MaintenanceController.php
app/Http/Controllers/PageController.php
app/Http/Controllers/PageExportController.php
app/Http/Controllers/PageRevisionController.php
app/Http/Controllers/PageTemplateController.php
app/Http/Controllers/RecycleBinController.php
app/Http/Controllers/RoleController.php
app/Http/Controllers/SearchController.php
app/Http/Controllers/SettingController.php
app/Http/Controllers/StatusController.php
app/Http/Controllers/TagController.php
app/Http/Controllers/UserApiTokenController.php
app/Http/Controllers/UserController.php
app/Http/Controllers/UserProfileController.php
app/Http/Controllers/UserSearchController.php
app/Http/Kernel.php
app/Http/Middleware/ApiAuthenticate.php
app/Http/Middleware/Authenticate.php
app/Http/Middleware/CheckGuard.php
app/Http/Middleware/ChecksForEmailConfirmation.php
app/Http/Middleware/ControlIframeSecurity.php
app/Http/Middleware/Localization.php
app/Http/Middleware/PermissionMiddleware.php
app/Http/Middleware/RedirectIfAuthenticated.php
app/Http/Middleware/RunThemeActions.php
app/Http/Middleware/ThrottleApiRequests.php
app/Http/Middleware/TrustProxies.php
app/Http/Middleware/VerifyCsrfToken.php
app/Http/Request.php
app/Interfaces/Favouritable.php
app/Interfaces/Sluggable.php
app/Interfaces/Viewable.php
app/Model.php
app/Notifications/ConfirmEmail.php
app/Notifications/MailNotification.php
app/Notifications/ResetPassword.php
app/Notifications/TestEmail.php
app/Notifications/UserInvite.php
app/Providers/AppServiceProvider.php
app/Providers/AuthServiceProvider.php
app/Providers/CustomValidationServiceProvider.php
app/Providers/PaginationServiceProvider.php
app/Providers/RouteServiceProvider.php
app/Providers/ThemeServiceProvider.php
app/Providers/TranslationServiceProvider.php
app/Settings/Setting.php
app/Settings/SettingService.php
app/Theming/ThemeEvents.php
app/Theming/ThemeService.php
app/Traits/HasCreatorAndUpdater.php
app/Traits/HasOwner.php
app/Translation/FileLoader.php
app/Uploads/Attachment.php
app/Uploads/AttachmentService.php
app/Uploads/HttpFetcher.php
app/Uploads/Image.php
app/Uploads/ImageRepo.php
app/Uploads/ImageService.php
app/Uploads/UserAvatars.php
app/Util/HtmlContentFilter.php
app/helpers.php
database/factories/ModelFactory.php
database/migrations/2014_10_12_000000_create_users_table.php
database/migrations/2014_10_12_100000_create_password_resets_table.php
database/migrations/2015_07_12_114933_create_books_table.php
database/migrations/2015_07_12_190027_create_pages_table.php
database/migrations/2015_07_13_172121_create_images_table.php
database/migrations/2015_07_27_172342_create_chapters_table.php
database/migrations/2015_08_08_200447_add_users_to_entities.php
database/migrations/2015_08_09_093534_create_page_revisions_table.php
database/migrations/2015_08_16_142133_create_activities_table.php
database/migrations/2015_08_29_105422_add_roles_and_permissions.php
database/migrations/2015_08_30_125859_create_settings_table.php
database/migrations/2015_08_31_175240_add_search_indexes.php
database/migrations/2015_09_04_165821_create_social_accounts_table.php
database/migrations/2015_09_05_164707_add_email_confirmation_table.php
database/migrations/2015_11_21_145609_create_views_table.php
database/migrations/2015_11_26_221857_add_entity_indexes.php
database/migrations/2015_12_05_145049_fulltext_weighting.php
database/migrations/2015_12_07_195238_add_image_upload_types.php
database/migrations/2015_12_09_195748_add_user_avatars.php
database/migrations/2016_01_11_210908_add_external_auth_to_users.php
database/migrations/2016_02_25_184030_add_slug_to_revisions.php
database/migrations/2016_02_27_120329_update_permissions_and_roles.php
database/migrations/2016_02_28_084200_add_entity_access_controls.php
database/migrations/2016_03_09_203143_add_page_revision_types.php
database/migrations/2016_03_13_082138_add_page_drafts.php
database/migrations/2016_03_25_123157_add_markdown_support.php
database/migrations/2016_04_09_100730_add_view_permissions_to_roles.php
database/migrations/2016_04_20_192649_create_joint_permissions_table.php
database/migrations/2016_05_06_185215_create_tags_table.php
database/migrations/2016_07_07_181521_add_summary_to_page_revisions.php
database/migrations/2016_09_29_101449_remove_hidden_roles.php
database/migrations/2016_10_09_142037_create_attachments_table.php
database/migrations/2017_01_21_163556_create_cache_table.php
database/migrations/2017_01_21_163602_create_sessions_table.php
database/migrations/2017_03_19_091553_create_search_index_table.php
database/migrations/2017_04_20_185112_add_revision_counts.php
database/migrations/2017_08_01_130541_create_comments_table.php
database/migrations/2017_08_29_102650_add_cover_image_display.php
database/migrations/2018_07_15_173514_add_role_external_auth_id.php
database/migrations/2018_08_04_115700_create_bookshelves_table.php
database/migrations/2019_07_07_112515_add_template_support.php
database/migrations/2019_08_17_140214_add_user_invites_table.php
database/migrations/2019_12_29_120917_add_api_auth.php
database/migrations/2020_08_04_131052_remove_role_name_field.php
database/migrations/2020_09_19_094251_add_activity_indexes.php
database/migrations/2020_09_27_210059_add_entity_soft_deletes.php
database/migrations/2020_11_07_232321_simplify_activities_table.php
database/migrations/2020_12_30_173528_add_owned_by_field_to_entities.php
database/seeds/DatabaseSeeder.php
database/seeds/DummyContentSeeder.php
public/index.php
routes/api.php
routes/web.php
server.php
tests/ActivityTrackingTest.php
tests/Api/ApiAuthTest.php
tests/Api/ApiConfigTest.php
tests/Api/ApiDocsTest.php
tests/Api/ApiListingTest.php
tests/Api/BooksApiTest.php
tests/Api/ChaptersApiTest.php
tests/Api/PagesApiTest.php
tests/Api/ShelvesApiTest.php
tests/Api/TestsApi.php
tests/AuditLogTest.php
tests/Auth/AuthTest.php
tests/Auth/LdapTest.php
tests/Auth/Saml2Test.php
tests/Auth/SocialAuthTest.php
tests/Auth/UserInviteTest.php
tests/BrowserKitTest.php
tests/Commands/AddAdminCommandTest.php
tests/Commands/ClearActivityCommandTest.php
tests/Commands/ClearRevisionsCommandTest.php
tests/Commands/ClearViewsCommandTest.php
tests/Commands/CopyShelfPermissionsCommandTest.php
tests/Commands/RegenerateCommentContentCommandTest.php
tests/Commands/RegeneratePermissionsCommandTest.php
tests/Commands/UpdateUrlCommandTest.php
tests/CreatesApplication.php
tests/Entity/BookShelfTest.php
tests/Entity/BookTest.php
tests/Entity/ChapterTest.php
tests/Entity/CommentSettingTest.php
tests/Entity/CommentTest.php
tests/Entity/EntitySearchTest.php
tests/Entity/EntityTest.php
tests/Entity/ExportTest.php
tests/Entity/MarkdownTest.php
tests/Entity/PageContentTest.php
tests/Entity/PageDraftTest.php
tests/Entity/PageRevisionTest.php
tests/Entity/PageTemplateTest.php
tests/Entity/PageTest.php
tests/Entity/SearchOptionsTest.php
tests/Entity/SortTest.php
tests/Entity/TagTest.php
tests/ErrorTest.php
tests/FavouriteTest.php
tests/FooterLinksTest.php
tests/HomepageTest.php
tests/LanguageTest.php
tests/OpenGraphTest.php
tests/Permissions/EntityOwnerChangeTest.php
tests/Permissions/EntityPermissionsTest.php
tests/Permissions/ExportPermissionsTest.php
tests/Permissions/RolesTest.php
tests/PublicActionTest.php
tests/RecycleBinTest.php
tests/SecurityHeaderTest.php
tests/SharedTestHelpers.php
tests/StatusTest.php
tests/TestCase.php
tests/TestEmailTest.php
tests/TestResponse.php
tests/ThemeTest.php
tests/Unit/ConfigTest.php
tests/Unit/UrlTest.php
tests/Uploads/AttachmentTest.php
tests/Uploads/AvatarTest.php
tests/Uploads/DrawioTest.php
tests/Uploads/ImageTest.php
tests/Uploads/UsesImages.php
tests/User/UserApiTokenTest.php
tests/User/UserManagementTest.php
tests/User/UserPreferencesTest.php
tests/User/UserProfileTest.php

index c8590f0b25d12dc8f4f29210e51cd3c8b28de897..6a8a9bcd07bbd66c673bf919f2213112f13be90e 100644 (file)
@@ -11,16 +11,15 @@ use Illuminate\Support\Str;
 
 /**
  * @property string $type
 
 /**
  * @property string $type
- * @property User $user
+ * @property User   $user
  * @property Entity $entity
  * @property string $detail
  * @property string $entity_type
  * @property Entity $entity
  * @property string $detail
  * @property string $entity_type
- * @property int $entity_id
- * @property int $user_id
+ * @property int    $entity_id
+ * @property int    $user_id
  */
 class Activity extends Model
 {
  */
 class Activity extends Model
 {
-
     /**
      * Get the entity for this activity.
      */
     /**
      * Get the entity for this activity.
      */
@@ -29,6 +28,7 @@ class Activity extends Model
         if ($this->entity_type === '') {
             $this->entity_type = null;
         }
         if ($this->entity_type === '') {
             $this->entity_type = null;
         }
+
         return $this->morphTo('entity');
     }
 
         return $this->morphTo('entity');
     }
 
@@ -54,7 +54,7 @@ class Activity extends Model
     public function isForEntity(): bool
     {
         return Str::startsWith($this->type, [
     public function isForEntity(): bool
     {
         return Str::startsWith($this->type, [
-            'page_', 'chapter_', 'book_', 'bookshelf_'
+            'page_', 'chapter_', 'book_', 'bookshelf_',
         ]);
     }
 
         ]);
     }
 
index 73f827e70e329186d9a8fc8d2ecf6749f919da6c..dce7dc7b2595df00a1652bcfbcce7124de811b62 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Actions;
+<?php
+
+namespace BookStack\Actions;
 
 use BookStack\Auth\Permissions\PermissionService;
 use BookStack\Auth\User;
 
 use BookStack\Auth\Permissions\PermissionService;
 use BookStack\Auth\User;
@@ -33,6 +35,7 @@ class ActivityService
 
     /**
      * Add a generic activity event to the database.
 
     /**
      * Add a generic activity event to the database.
+     *
      * @param string|Loggable $detail
      */
     public function add(string $type, $detail = '')
      * @param string|Loggable $detail
      */
     public function add(string $type, $detail = '')
@@ -54,7 +57,7 @@ class ActivityService
     {
         return $this->activity->newInstance()->forceFill([
             'type'     => strtolower($type),
     {
         return $this->activity->newInstance()->forceFill([
             'type'     => strtolower($type),
-            'user_id' => user()->id,
+            'user_id'  => user()->id,
         ]);
     }
 
         ]);
     }
 
@@ -67,8 +70,8 @@ class ActivityService
     {
         $entity->activity()->update([
             'detail'       => $entity->name,
     {
         $entity->activity()->update([
             'detail'       => $entity->name,
-            'entity_id'   => null,
-            'entity_type' => null,
+            'entity_id'    => null,
+            'entity_type'  => null,
         ]);
     }
 
         ]);
     }
 
@@ -98,10 +101,10 @@ class ActivityService
         $queryIds = [$entity->getMorphClass() => [$entity->id]];
 
         if ($entity->isA('book')) {
         $queryIds = [$entity->getMorphClass() => [$entity->id]];
 
         if ($entity->isA('book')) {
-            $queryIds[(new Chapter)->getMorphClass()] = $entity->chapters()->visible()->pluck('id');
+            $queryIds[(new Chapter())->getMorphClass()] = $entity->chapters()->visible()->pluck('id');
         }
         if ($entity->isA('book') || $entity->isA('chapter')) {
         }
         if ($entity->isA('book') || $entity->isA('chapter')) {
-            $queryIds[(new Page)->getMorphClass()] = $entity->pages()->visible()->pluck('id');
+            $queryIds[(new Page())->getMorphClass()] = $entity->pages()->visible()->pluck('id');
         }
 
         $query = $this->activity->newQuery();
         }
 
         $query = $this->activity->newQuery();
@@ -143,7 +146,9 @@ class ActivityService
 
     /**
      * Filters out similar activity.
 
     /**
      * Filters out similar activity.
+     *
      * @param Activity[] $activities
      * @param Activity[] $activities
+     *
      * @return array
      */
     protected function filterSimilar(iterable $activities): array
      * @return array
      */
     protected function filterSimilar(iterable $activities): array
@@ -185,7 +190,7 @@ class ActivityService
             return;
         }
 
             return;
         }
 
-        $message = str_replace("%u", $username, $message);
+        $message = str_replace('%u', $username, $message);
         $channel = config('logging.failed_login.channel');
         Log::channel($channel)->warning($message);
     }
         $channel = config('logging.failed_login.channel');
         Log::channel($channel)->warning($message);
     }
index ec02bed25483696747c9fceceb6f9b560e4da819..a19f143b7be0d3dacfc5f46b865db67f9c83c084 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Actions;
+<?php
+
+namespace BookStack\Actions;
 
 class ActivityType
 {
 
 class ActivityType
 {
index f5269e2534d7a8ea2cbc77cbfdefa5adac815847..ef390939e2fe7f65c98a151364ced89788294864 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Actions;
+<?php
+
+namespace BookStack\Actions;
 
 use BookStack\Model;
 use BookStack\Traits\HasCreatorAndUpdater;
 
 use BookStack\Model;
 use BookStack\Traits\HasCreatorAndUpdater;
@@ -18,7 +20,7 @@ class Comment extends Model
     protected $appends = ['created', 'updated'];
 
     /**
     protected $appends = ['created', 'updated'];
 
     /**
-     * Get the entity that this comment belongs to
+     * Get the entity that this comment belongs to.
      */
     public function entity(): MorphTo
     {
      */
     public function entity(): MorphTo
     {
@@ -35,6 +37,7 @@ class Comment extends Model
 
     /**
      * Get created date as a relative diff.
 
     /**
      * Get created date as a relative diff.
+     *
      * @return mixed
      */
     public function getCreatedAttribute()
      * @return mixed
      */
     public function getCreatedAttribute()
@@ -44,6 +47,7 @@ class Comment extends Model
 
     /**
      * Get updated date as a relative diff.
 
     /**
      * Get updated date as a relative diff.
+     *
      * @return mixed
      */
     public function getUpdatedAttribute()
      * @return mixed
      */
     public function getUpdatedAttribute()
index 13a83e7fdd247064983c64928811b49db2ba4ca1..85fb6498a92bca35897e65845f00b87e2ba64a95 100644 (file)
@@ -1,21 +1,21 @@
-<?php namespace BookStack\Actions;
+<?php
+
+namespace BookStack\Actions;
 
 use BookStack\Entities\Models\Entity;
 
 use BookStack\Entities\Models\Entity;
-use League\CommonMark\CommonMarkConverter;
 use BookStack\Facades\Activity as ActivityService;
 use BookStack\Facades\Activity as ActivityService;
+use League\CommonMark\CommonMarkConverter;
 
 /**
 
 /**
- * Class CommentRepo
+ * Class CommentRepo.
  */
 class CommentRepo
 {
  */
 class CommentRepo
 {
-
     /**
     /**
-     * @var Comment $comment
+     * @var Comment
      */
     protected $comment;
 
      */
     protected $comment;
 
-
     public function __construct(Comment $comment)
     {
         $this->comment = $comment;
     public function __construct(Comment $comment)
     {
         $this->comment = $comment;
@@ -46,6 +46,7 @@ class CommentRepo
 
         $entity->comments()->save($comment);
         ActivityService::addForEntity($entity, ActivityType::COMMENTED_ON);
 
         $entity->comments()->save($comment);
         ActivityService::addForEntity($entity, ActivityType::COMMENTED_ON);
+
         return $comment;
     }
 
         return $comment;
     }
 
@@ -58,6 +59,7 @@ class CommentRepo
         $comment->text = $text;
         $comment->html = $this->commentToHtml($text);
         $comment->save();
         $comment->text = $text;
         $comment->html = $this->commentToHtml($text);
         $comment->save();
+
         return $comment;
     }
 
         return $comment;
     }
 
@@ -75,8 +77,8 @@ class CommentRepo
     public function commentToHtml(string $commentText): string
     {
         $converter = new CommonMarkConverter([
     public function commentToHtml(string $commentText): string
     {
         $converter = new CommonMarkConverter([
-            'html_input' => 'strip',
-            'max_nesting_level' => 10,
+            'html_input'         => 'strip',
+            'max_nesting_level'  => 10,
             'allow_unsafe_links' => false,
         ]);
 
             'allow_unsafe_links' => false,
         ]);
 
@@ -89,6 +91,7 @@ class CommentRepo
     protected function getNextLocalId(Entity $entity): int
     {
         $comments = $entity->comments(false)->orderBy('local_id', 'desc')->first();
     protected function getNextLocalId(Entity $entity): int
     {
         $comments = $entity->comments(false)->orderBy('local_id', 'desc')->first();
+
         return ($comments->local_id ?? 0) + 1;
     }
 }
         return ($comments->local_id ?? 0) + 1;
     }
 }
index 107a7657844132e8869d2b6f4f91daf3b67a9ab2..f4589418226d5875b908a82a33e3aff1d9870aa6 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Actions;
+<?php
+
+namespace BookStack\Actions;
 
 use BookStack\Model;
 use Illuminate\Database\Eloquent\Relations\MorphTo;
 
 use BookStack\Model;
 use Illuminate\Database\Eloquent\Relations\MorphTo;
index f73b2ed2d25423e55a044ac78f4a23327c5ef895..ce0954f00cd347c50e21806caa8949d256a863cd 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Actions;
+<?php
+
+namespace BookStack\Actions;
 
 use BookStack\Model;
 use Illuminate\Database\Eloquent\Relations\MorphTo;
 
 use BookStack\Model;
 use Illuminate\Database\Eloquent\Relations\MorphTo;
@@ -9,7 +11,7 @@ class Tag extends Model
     protected $hidden = ['id', 'entity_id', 'entity_type', 'created_at', 'updated_at'];
 
     /**
     protected $hidden = ['id', 'entity_id', 'entity_type', 'created_at', 'updated_at'];
 
     /**
-     * Get the entity that this tag belongs to
+     * Get the entity that this tag belongs to.
      */
     public function entity(): MorphTo
     {
      */
     public function entity(): MorphTo
     {
@@ -21,7 +23,7 @@ class Tag extends Model
      */
     public function nameUrl(): string
     {
      */
     public function nameUrl(): string
     {
-        return url('/search?term=%5B' . urlencode($this->name) .'%5D');
+        return url('/search?term=%5B' . urlencode($this->name) . '%5D');
     }
 
     /**
     }
 
     /**
@@ -29,6 +31,6 @@ class Tag extends Model
      */
     public function valueUrl(): string
     {
      */
     public function valueUrl(): string
     {
-        return url('/search?term=%5B' . urlencode($this->name) .'%3D' . urlencode($this->value) . '%5D');
+        return url('/search?term=%5B' . urlencode($this->name) . '%3D' . urlencode($this->value) . '%5D');
     }
 }
     }
 }
index c80e8abe3225e70a121aca5d21873ec1fda1a6a7..ca65b78e8e2dab7b7742204f6decd8e0c5a908f2 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Actions;
+<?php
+
+namespace BookStack\Actions;
 
 use BookStack\Auth\Permissions\PermissionService;
 use BookStack\Entities\Models\Entity;
 
 use BookStack\Auth\Permissions\PermissionService;
 use BookStack\Entities\Models\Entity;
@@ -7,7 +9,6 @@ use Illuminate\Support\Collection;
 
 class TagRepo
 {
 
 class TagRepo
 {
-
     protected $tag;
     protected $permissionService;
 
     protected $tag;
     protected $permissionService;
 
@@ -37,6 +38,7 @@ class TagRepo
         }
 
         $query = $this->permissionService->filterRestrictedEntityRelations($query, 'tags', 'entity_id', 'entity_type');
         }
 
         $query = $this->permissionService->filterRestrictedEntityRelations($query, 'tags', 'entity_id', 'entity_type');
+
         return $query->get(['name'])->pluck('name');
     }
 
         return $query->get(['name'])->pluck('name');
     }
 
@@ -62,11 +64,12 @@ class TagRepo
         }
 
         $query = $this->permissionService->filterRestrictedEntityRelations($query, 'tags', 'entity_id', 'entity_type');
         }
 
         $query = $this->permissionService->filterRestrictedEntityRelations($query, 'tags', 'entity_id', 'entity_type');
+
         return $query->get(['value'])->pluck('value');
     }
 
     /**
         return $query->get(['value'])->pluck('value');
     }
 
     /**
-     * Save an array of tags to an entity
+     * Save an array of tags to an entity.
      */
     public function saveTagsToEntity(Entity $entity, array $tags = []): iterable
     {
      */
     public function saveTagsToEntity(Entity $entity, array $tags = []): iterable
     {
@@ -89,6 +92,7 @@ class TagRepo
     {
         $name = trim($input['name']);
         $value = isset($input['value']) ? trim($input['value']) : '';
     {
         $name = trim($input['name']);
         $value = isset($input['value']) ? trim($input['value']) : '';
+
         return $this->tag->newInstance(['name' => $name, 'value' => $value]);
     }
 }
         return $this->tag->newInstance(['name' => $name, 'value' => $value]);
     }
 }
index de30900c76f2a6d4600a75f726dd9645fe7713ff..16961bd914bef8b29fc659d6f689fd7f56b99376 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Actions;
+<?php
+
+namespace BookStack\Actions;
 
 use BookStack\Interfaces\Viewable;
 use BookStack\Model;
 
 use BookStack\Interfaces\Viewable;
 use BookStack\Model;
@@ -16,7 +18,6 @@ use Illuminate\Database\Eloquent\Relations\MorphTo;
  */
 class View extends Model
 {
  */
 class View extends Model
 {
-
     protected $fillable = ['user_id', 'views'];
 
     /**
     protected $fillable = ['user_id', 'views'];
 
     /**
index 8b520eda2b7432e67c49228e73a349495993fa83..0ed7e6712d3106c93d52478c1b362fa0adbc3cab 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Api;
+<?php
+
+namespace BookStack\Api;
 
 use BookStack\Http\Controllers\Api\ApiController;
 use Illuminate\Contracts\Container\BindingResolutionException;
 
 use BookStack\Http\Controllers\Api\ApiController;
 use Illuminate\Contracts\Container\BindingResolutionException;
@@ -12,7 +14,6 @@ use ReflectionMethod;
 
 class ApiDocsGenerator
 {
 
 class ApiDocsGenerator
 {
-
     protected $reflectionClasses = [];
     protected $controllerClasses = [];
 
     protected $reflectionClasses = [];
     protected $controllerClasses = [];
 
@@ -30,6 +31,7 @@ class ApiDocsGenerator
             $docs = (new static())->generate();
             Cache::put($cacheKey, $docs, 60 * 24);
         }
             $docs = (new static())->generate();
             Cache::put($cacheKey, $docs, 60 * 24);
         }
+
         return $docs;
     }
 
         return $docs;
     }
 
@@ -42,6 +44,7 @@ class ApiDocsGenerator
         $apiRoutes = $this->loadDetailsFromControllers($apiRoutes);
         $apiRoutes = $this->loadDetailsFromFiles($apiRoutes);
         $apiRoutes = $apiRoutes->groupBy('base_model');
         $apiRoutes = $this->loadDetailsFromControllers($apiRoutes);
         $apiRoutes = $this->loadDetailsFromFiles($apiRoutes);
         $apiRoutes = $apiRoutes->groupBy('base_model');
+
         return $apiRoutes;
     }
 
         return $apiRoutes;
     }
 
@@ -57,6 +60,7 @@ class ApiDocsGenerator
                 $exampleContent = file_exists($exampleFile) ? file_get_contents($exampleFile) : null;
                 $route["example_{$exampleType}"] = $exampleContent;
             }
                 $exampleContent = file_exists($exampleFile) ? file_get_contents($exampleFile) : null;
                 $route["example_{$exampleType}"] = $exampleContent;
             }
+
             return $route;
         });
     }
             return $route;
         });
     }
@@ -71,12 +75,14 @@ class ApiDocsGenerator
             $comment = $method->getDocComment();
             $route['description'] = $comment ? $this->parseDescriptionFromMethodComment($comment) : null;
             $route['body_params'] = $this->getBodyParamsFromClass($route['controller'], $route['controller_method']);
             $comment = $method->getDocComment();
             $route['description'] = $comment ? $this->parseDescriptionFromMethodComment($comment) : null;
             $route['body_params'] = $this->getBodyParamsFromClass($route['controller'], $route['controller_method']);
+
             return $route;
         });
     }
 
     /**
      * Load body params and their rules by inspecting the given class and method name.
             return $route;
         });
     }
 
     /**
      * Load body params and their rules by inspecting the given class and method name.
+     *
      * @throws BindingResolutionException
      */
     protected function getBodyParamsFromClass(string $className, string $methodName): ?array
      * @throws BindingResolutionException
      */
     protected function getBodyParamsFromClass(string $className, string $methodName): ?array
@@ -92,6 +98,7 @@ class ApiDocsGenerator
         foreach ($rules as $param => $ruleString) {
             $rules[$param] = explode('|', $ruleString);
         }
         foreach ($rules as $param => $ruleString) {
             $rules[$param] = explode('|', $ruleString);
         }
+
         return count($rules) > 0 ? $rules : null;
     }
 
         return count($rules) > 0 ? $rules : null;
     }
 
@@ -102,11 +109,13 @@ class ApiDocsGenerator
     {
         $matches = [];
         preg_match_all('/^\s*?\*\s((?![@\s]).*?)$/m', $comment, $matches);
     {
         $matches = [];
         preg_match_all('/^\s*?\*\s((?![@\s]).*?)$/m', $comment, $matches);
+
         return implode(' ', $matches[1] ?? []);
     }
 
     /**
      * Get a reflection method from the given class name and method name.
         return implode(' ', $matches[1] ?? []);
     }
 
     /**
      * Get a reflection method from the given class name and method name.
+     *
      * @throws ReflectionException
      */
     protected function getReflectionMethod(string $className, string $methodName): ReflectionMethod
      * @throws ReflectionException
      */
     protected function getReflectionMethod(string $className, string $methodName): ReflectionMethod
@@ -131,14 +140,15 @@ class ApiDocsGenerator
             [$controller, $controllerMethod] = explode('@', $route->action['uses']);
             $baseModelName = explode('.', explode('/', $route->uri)[1])[0];
             $shortName = $baseModelName . '-' . $controllerMethod;
             [$controller, $controllerMethod] = explode('@', $route->action['uses']);
             $baseModelName = explode('.', explode('/', $route->uri)[1])[0];
             $shortName = $baseModelName . '-' . $controllerMethod;
+
             return [
             return [
-                'name' => $shortName,
-                'uri' => $route->uri,
-                'method' => $route->methods[0],
-                'controller' => $controller,
-                'controller_method' => $controllerMethod,
+                'name'                    => $shortName,
+                'uri'                     => $route->uri,
+                'method'                  => $route->methods[0],
+                'controller'              => $controller,
+                'controller_method'       => $controllerMethod,
                 'controller_method_kebab' => Str::kebab($controllerMethod),
                 'controller_method_kebab' => Str::kebab($controllerMethod),
-                'base_model' => $baseModelName,
+                'base_model'              => $baseModelName,
             ];
         });
     }
             ];
         });
     }
index defaa7e954af69354fc3f3c637720f392fbc005c..f44fde19aa3689eff26ef91f2f1f22e3c856caf5 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Api;
+<?php
+
+namespace BookStack\Api;
 
 use BookStack\Auth\User;
 use BookStack\Interfaces\Loggable;
 
 use BookStack\Auth\User;
 use BookStack\Interfaces\Loggable;
@@ -7,19 +9,20 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
 use Illuminate\Support\Carbon;
 
 /**
 use Illuminate\Support\Carbon;
 
 /**
- * Class ApiToken
- * @property int $id
+ * Class ApiToken.
+ *
+ * @property int    $id
  * @property string $token_id
  * @property string $secret
  * @property string $name
  * @property Carbon $expires_at
  * @property string $token_id
  * @property string $secret
  * @property string $name
  * @property Carbon $expires_at
- * @property User $user
+ * @property User   $user
  */
 class ApiToken extends Model implements Loggable
 {
     protected $fillable = ['name', 'expires_at'];
     protected $casts = [
  */
 class ApiToken extends Model implements Loggable
 {
     protected $fillable = ['name', 'expires_at'];
     protected $casts = [
-        'expires_at' => 'date:Y-m-d'
+        'expires_at' => 'date:Y-m-d',
     ];
 
     /**
     ];
 
     /**
index 59ab72f4eb8509be037704fdddff907bda4403b4..75ed5cb3567b041afaf599b4dc17c20735e2207a 100644 (file)
@@ -12,7 +12,6 @@ use Symfony\Component\HttpFoundation\Request;
 
 class ApiTokenGuard implements Guard
 {
 
 class ApiTokenGuard implements Guard
 {
-
     use GuardHelpers;
 
     /**
     use GuardHelpers;
 
     /**
@@ -20,9 +19,9 @@ class ApiTokenGuard implements Guard
      */
     protected $request;
 
      */
     protected $request;
 
-
     /**
      * The last auth exception thrown in this request.
     /**
      * The last auth exception thrown in this request.
+     *
      * @var ApiAuthException
      */
     protected $lastAuthException;
      * @var ApiAuthException
      */
     protected $lastAuthException;
@@ -34,7 +33,7 @@ class ApiTokenGuard implements Guard
     {
         $this->request = $request;
     }
     {
         $this->request = $request;
     }
-    
+
     /**
      * @inheritDoc
      */
     /**
      * @inheritDoc
      */
@@ -47,6 +46,7 @@ class ApiTokenGuard implements Guard
         }
 
         $user = null;
         }
 
         $user = null;
+
         try {
             $user = $this->getAuthorisedUserFromRequest();
         } catch (ApiAuthException $exception) {
         try {
             $user = $this->getAuthorisedUserFromRequest();
         } catch (ApiAuthException $exception) {
@@ -54,19 +54,20 @@ class ApiTokenGuard implements Guard
         }
 
         $this->user = $user;
         }
 
         $this->user = $user;
+
         return $user;
     }
 
     /**
      * Determine if current user is authenticated. If not, throw an exception.
      *
         return $user;
     }
 
     /**
      * Determine if current user is authenticated. If not, throw an exception.
      *
-     * @return \Illuminate\Contracts\Auth\Authenticatable
-     *
      * @throws ApiAuthException
      * @throws ApiAuthException
+     *
+     * @return \Illuminate\Contracts\Auth\Authenticatable
      */
     public function authenticate()
     {
      */
     public function authenticate()
     {
-        if (! is_null($user = $this->user())) {
+        if (!is_null($user = $this->user())) {
             return $user;
         }
 
             return $user;
         }
 
@@ -79,6 +80,7 @@ class ApiTokenGuard implements Guard
 
     /**
      * Check the API token in the request and fetch a valid authorised user.
 
     /**
      * Check the API token in the request and fetch a valid authorised user.
+     *
      * @throws ApiAuthException
      */
     protected function getAuthorisedUserFromRequest(): Authenticatable
      * @throws ApiAuthException
      */
     protected function getAuthorisedUserFromRequest(): Authenticatable
@@ -98,6 +100,7 @@ class ApiTokenGuard implements Guard
 
     /**
      * Validate the format of the token header value string.
 
     /**
      * Validate the format of the token header value string.
+     *
      * @throws ApiAuthException
      */
     protected function validateTokenHeaderValue(string $authToken): void
      * @throws ApiAuthException
      */
     protected function validateTokenHeaderValue(string $authToken): void
@@ -114,6 +117,7 @@ class ApiTokenGuard implements Guard
     /**
      * Validate the given secret against the given token and ensure the token
      * currently has access to the instance API.
     /**
      * Validate the given secret against the given token and ensure the token
      * currently has access to the instance API.
+     *
      * @throws ApiAuthException
      */
     protected function validateToken(?ApiToken $token, string $secret): void
      * @throws ApiAuthException
      */
     protected function validateToken(?ApiToken $token, string $secret): void
index df4cb8bf1ae98904622a7cc2fbaa6770f197604a..02b3f680cf0a3bc1f362313468dfad88ff7401a0 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Api;
+<?php
+
+namespace BookStack\Api;
 
 use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Database\Eloquent\Collection;
 
 use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Database\Eloquent\Collection;
@@ -6,7 +8,6 @@ use Illuminate\Http\Request;
 
 class ListingResponseBuilder
 {
 
 class ListingResponseBuilder
 {
-
     protected $query;
     protected $request;
     protected $fields;
     protected $query;
     protected $request;
     protected $fields;
@@ -18,7 +19,7 @@ class ListingResponseBuilder
         'lt'   => '<',
         'gte'  => '>=',
         'lte'  => '<=',
         'lt'   => '<',
         'gte'  => '>=',
         'lte'  => '<=',
-        'like' => 'like'
+        'like' => 'like',
     ];
 
     /**
     ];
 
     /**
@@ -42,7 +43,7 @@ class ListingResponseBuilder
         $data = $this->fetchData($filteredQuery);
 
         return response()->json([
         $data = $this->fetchData($filteredQuery);
 
         return response()->json([
-            'data' => $data,
+            'data'  => $data,
             'total' => $total,
         ]);
     }
             'total' => $total,
         ]);
     }
@@ -54,6 +55,7 @@ class ListingResponseBuilder
     {
         $query = $this->countAndOffsetQuery($query);
         $query = $this->sortQuery($query);
     {
         $query = $this->countAndOffsetQuery($query);
         $query = $this->sortQuery($query);
+
         return $query->get($this->fields);
     }
 
         return $query->get($this->fields);
     }
 
@@ -95,6 +97,7 @@ class ListingResponseBuilder
         }
 
         $queryOperator = $this->filterOperators[$filterOperator];
         }
 
         $queryOperator = $this->filterOperators[$filterOperator];
+
         return [$field, $queryOperator, $value];
     }
 
         return [$field, $queryOperator, $value];
     }
 
index 499fdeaa691ce8a0442b2494c9f46b09edf42f27..d409d14bc26906dd853d7bcf7f570d2d6b9efd5e 100644 (file)
@@ -4,11 +4,11 @@ namespace BookStack;
 
 class Application extends \Illuminate\Foundation\Application
 {
 
 class Application extends \Illuminate\Foundation\Application
 {
-
     /**
      * Get the path to the application configuration files.
      *
     /**
      * Get the path to the application configuration files.
      *
-     * @param  string  $path Optionally, a path to append to the config path
+     * @param string $path Optionally, a path to append to the config path
+     *
      * @return string
      */
     public function configPath($path = '')
      * @return string
      */
     public function configPath($path = '')
@@ -18,6 +18,6 @@ class Application extends \Illuminate\Foundation\Application
             . 'app'
             . DIRECTORY_SEPARATOR
             . 'Config'
             . 'app'
             . DIRECTORY_SEPARATOR
             . 'Config'
-            . ($path ? DIRECTORY_SEPARATOR.$path : $path);
+            . ($path ? DIRECTORY_SEPARATOR . $path : $path);
     }
 }
     }
 }
index 9aa3b9b98b56cf0d56453ae9e2de18c48c4d4524..3425c1e720de0416f066018f436e15c9c06eae54 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Auth\Access;
+<?php
+
+namespace BookStack\Auth\Access;
 
 use BookStack\Auth\User;
 use BookStack\Exceptions\ConfirmationEmailException;
 
 use BookStack\Auth\User;
 use BookStack\Exceptions\ConfirmationEmailException;
@@ -12,7 +14,9 @@ class EmailConfirmationService extends UserTokenService
     /**
      * Create new confirmation for a user,
      * Also removes any existing old ones.
     /**
      * Create new confirmation for a user,
      * Also removes any existing old ones.
+     *
      * @param User $user
      * @param User $user
+     *
      * @throws ConfirmationEmailException
      */
     public function sendConfirmation(User $user)
      * @throws ConfirmationEmailException
      */
     public function sendConfirmation(User $user)
@@ -29,9 +33,10 @@ class EmailConfirmationService extends UserTokenService
 
     /**
      * Check if confirmation is required in this instance.
 
     /**
      * Check if confirmation is required in this instance.
+     *
      * @return bool
      */
      * @return bool
      */
-    public function confirmationRequired() : bool
+    public function confirmationRequired(): bool
     {
         return setting('registration-confirmation')
             || setting('registration-restrict');
     {
         return setting('registration-confirmation')
             || setting('registration-restrict');
index 4c71db21adff7a559b929353ec4974512c16df14..7bd3679ac0653829989a090778ed7e0062bc2c4e 100644 (file)
@@ -1,10 +1,10 @@
-<?php namespace BookStack\Auth\Access;
+<?php
+
+namespace BookStack\Auth\Access;
 
 use BookStack\Auth\Role;
 use BookStack\Auth\User;
 
 use BookStack\Auth\Role;
 use BookStack\Auth\User;
-use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Support\Collection;
 use Illuminate\Support\Collection;
-use Illuminate\Support\Facades\DB;
 
 class ExternalAuthService
 {
 
 class ExternalAuthService
 {
@@ -19,6 +19,7 @@ class ExternalAuthService
         }
 
         $roleName = str_replace(' ', '-', trim(strtolower($role->display_name)));
         }
 
         $roleName = str_replace(' ', '-', trim(strtolower($role->display_name)));
+
         return in_array($roleName, $groupNames);
     }
 
         return in_array($roleName, $groupNames);
     }
 
@@ -57,7 +58,7 @@ class ExternalAuthService
     }
 
     /**
     }
 
     /**
-     * Sync the groups to the user roles for the current user
+     * Sync the groups to the user roles for the current user.
      */
     public function syncWithGroups(User $user, array $userGroups): void
     {
      */
     public function syncWithGroups(User $user, array $userGroups): void
     {
index 69295ee4e900188cc2c7c3097b0a3c3379195b57..fde610c3e18746f33b616c4b309a91327eb77d91 100644 (file)
@@ -7,7 +7,6 @@ use Illuminate\Contracts\Auth\UserProvider;
 
 class ExternalBaseUserProvider implements UserProvider
 {
 
 class ExternalBaseUserProvider implements UserProvider
 {
-
     /**
      * The user model.
      *
     /**
      * The user model.
      *
@@ -17,7 +16,8 @@ class ExternalBaseUserProvider implements UserProvider
 
     /**
      * LdapUserProvider constructor.
 
     /**
      * LdapUserProvider constructor.
-     * @param             $model
+     *
+     * @param $model
      */
     public function __construct(string $model)
     {
      */
     public function __construct(string $model)
     {
@@ -32,13 +32,15 @@ class ExternalBaseUserProvider implements UserProvider
     public function createModel()
     {
         $class = '\\' . ltrim($this->model, '\\');
     public function createModel()
     {
         $class = '\\' . ltrim($this->model, '\\');
-        return new $class;
+
+        return new $class();
     }
 
     /**
      * Retrieve a user by their unique identifier.
      *
     }
 
     /**
      * Retrieve a user by their unique identifier.
      *
-     * @param  mixed $identifier
+     * @param mixed $identifier
+     *
      * @return \Illuminate\Contracts\Auth\Authenticatable|null
      */
     public function retrieveById($identifier)
      * @return \Illuminate\Contracts\Auth\Authenticatable|null
      */
     public function retrieveById($identifier)
@@ -49,8 +51,9 @@ class ExternalBaseUserProvider implements UserProvider
     /**
      * Retrieve a user by their unique identifier and "remember me" token.
      *
     /**
      * Retrieve a user by their unique identifier and "remember me" token.
      *
-     * @param  mixed  $identifier
-     * @param  string $token
+     * @param mixed  $identifier
+     * @param string $token
+     *
      * @return \Illuminate\Contracts\Auth\Authenticatable|null
      */
     public function retrieveByToken($identifier, $token)
      * @return \Illuminate\Contracts\Auth\Authenticatable|null
      */
     public function retrieveByToken($identifier, $token)
@@ -58,12 +61,12 @@ class ExternalBaseUserProvider implements UserProvider
         return null;
     }
 
         return null;
     }
 
-
     /**
      * Update the "remember me" token for the given user in storage.
      *
     /**
      * Update the "remember me" token for the given user in storage.
      *
-     * @param  \Illuminate\Contracts\Auth\Authenticatable $user
-     * @param  string                                     $token
+     * @param \Illuminate\Contracts\Auth\Authenticatable $user
+     * @param string                                     $token
+     *
      * @return void
      */
     public function updateRememberToken(Authenticatable $user, $token)
      * @return void
      */
     public function updateRememberToken(Authenticatable $user, $token)
@@ -74,13 +77,15 @@ class ExternalBaseUserProvider implements UserProvider
     /**
      * Retrieve a user by the given credentials.
      *
     /**
      * Retrieve a user by the given credentials.
      *
-     * @param  array $credentials
+     * @param array $credentials
+     *
      * @return \Illuminate\Contracts\Auth\Authenticatable|null
      */
     public function retrieveByCredentials(array $credentials)
     {
         // Search current user base by looking up a uid
         $model = $this->createModel();
      * @return \Illuminate\Contracts\Auth\Authenticatable|null
      */
     public function retrieveByCredentials(array $credentials)
     {
         // Search current user base by looking up a uid
         $model = $this->createModel();
+
         return $model->newQuery()
             ->where('external_auth_id', $credentials['external_auth_id'])
             ->first();
         return $model->newQuery()
             ->where('external_auth_id', $credentials['external_auth_id'])
             ->first();
@@ -89,8 +94,9 @@ class ExternalBaseUserProvider implements UserProvider
     /**
      * Validate a user against the given credentials.
      *
     /**
      * Validate a user against the given credentials.
      *
-     * @param  \Illuminate\Contracts\Auth\Authenticatable $user
-     * @param  array                                      $credentials
+     * @param \Illuminate\Contracts\Auth\Authenticatable $user
+     * @param array                                      $credentials
+     *
      * @return bool
      */
     public function validateCredentials(Authenticatable $user, array $credentials)
      * @return bool
      */
     public function validateCredentials(Authenticatable $user, array $credentials)
index b133754d8e932f43c750ab40b35fab224904d107..9c3b47e977dde54bca48f7a387cc4d3046bdac79 100644 (file)
@@ -84,7 +84,7 @@ class ExternalBaseSessionGuard implements StatefulGuard
         // If we've already retrieved the user for the current request we can just
         // return it back immediately. We do not want to fetch the user data on
         // every call to this method because that would be tremendously slow.
         // If we've already retrieved the user for the current request we can just
         // return it back immediately. We do not want to fetch the user data on
         // every call to this method because that would be tremendously slow.
-        if (! is_null($this->user)) {
+        if (!is_null($this->user)) {
             return $this->user;
         }
 
             return $this->user;
         }
 
@@ -92,7 +92,7 @@ class ExternalBaseSessionGuard implements StatefulGuard
 
         // First we will try to load the user using the
         // identifier in the session if one exists.
 
         // First we will try to load the user using the
         // identifier in the session if one exists.
-        if (! is_null($id)) {
+        if (!is_null($id)) {
             $this->user = $this->provider->retrieveById($id);
         }
 
             $this->user = $this->provider->retrieveById($id);
         }
 
@@ -118,7 +118,8 @@ class ExternalBaseSessionGuard implements StatefulGuard
     /**
      * Log a user into the application without sessions or cookies.
      *
     /**
      * Log a user into the application without sessions or cookies.
      *
-     * @param  array  $credentials
+     * @param array $credentials
+     *
      * @return bool
      */
     public function once(array $credentials = [])
      * @return bool
      */
     public function once(array $credentials = [])
@@ -135,12 +136,13 @@ class ExternalBaseSessionGuard implements StatefulGuard
     /**
      * Log the given user ID into the application without sessions or cookies.
      *
     /**
      * Log the given user ID into the application without sessions or cookies.
      *
-     * @param  mixed  $id
+     * @param mixed $id
+     *
      * @return \Illuminate\Contracts\Auth\Authenticatable|false
      */
     public function onceUsingId($id)
     {
      * @return \Illuminate\Contracts\Auth\Authenticatable|false
      */
     public function onceUsingId($id)
     {
-        if (! is_null($user = $this->provider->retrieveById($id))) {
+        if (!is_null($user = $this->provider->retrieveById($id))) {
             $this->setUser($user);
 
             return $user;
             $this->setUser($user);
 
             return $user;
@@ -152,7 +154,8 @@ class ExternalBaseSessionGuard implements StatefulGuard
     /**
      * Validate a user's credentials.
      *
     /**
      * Validate a user's credentials.
      *
-     * @param  array  $credentials
+     * @param array $credentials
+     *
      * @return bool
      */
     public function validate(array $credentials = [])
      * @return bool
      */
     public function validate(array $credentials = [])
@@ -160,12 +163,12 @@ class ExternalBaseSessionGuard implements StatefulGuard
         return false;
     }
 
         return false;
     }
 
-
     /**
      * Attempt to authenticate a user using the given credentials.
      *
     /**
      * Attempt to authenticate a user using the given credentials.
      *
-     * @param  array  $credentials
-     * @param  bool  $remember
+     * @param array $credentials
+     * @param bool  $remember
+     *
      * @return bool
      */
     public function attempt(array $credentials = [], $remember = false)
      * @return bool
      */
     public function attempt(array $credentials = [], $remember = false)
@@ -176,13 +179,14 @@ class ExternalBaseSessionGuard implements StatefulGuard
     /**
      * Log the given user ID into the application.
      *
     /**
      * Log the given user ID into the application.
      *
-     * @param  mixed  $id
-     * @param  bool  $remember
+     * @param mixed $id
+     * @param bool  $remember
+     *
      * @return \Illuminate\Contracts\Auth\Authenticatable|false
      */
     public function loginUsingId($id, $remember = false)
     {
      * @return \Illuminate\Contracts\Auth\Authenticatable|false
      */
     public function loginUsingId($id, $remember = false)
     {
-        if (! is_null($user = $this->provider->retrieveById($id))) {
+        if (!is_null($user = $this->provider->retrieveById($id))) {
             $this->login($user, $remember);
 
             return $user;
             $this->login($user, $remember);
 
             return $user;
@@ -194,8 +198,9 @@ class ExternalBaseSessionGuard implements StatefulGuard
     /**
      * Log a user into the application.
      *
     /**
      * Log a user into the application.
      *
-     * @param  \Illuminate\Contracts\Auth\Authenticatable  $user
-     * @param  bool  $remember
+     * @param \Illuminate\Contracts\Auth\Authenticatable $user
+     * @param bool                                       $remember
+     *
      * @return void
      */
     public function login(AuthenticatableContract $user, $remember = false)
      * @return void
      */
     public function login(AuthenticatableContract $user, $remember = false)
@@ -208,7 +213,8 @@ class ExternalBaseSessionGuard implements StatefulGuard
     /**
      * Update the session with the given ID.
      *
     /**
      * Update the session with the given ID.
      *
-     * @param  string  $id
+     * @param string $id
+     *
      * @return void
      */
     protected function updateSession($id)
      * @return void
      */
     protected function updateSession($id)
@@ -262,7 +268,7 @@ class ExternalBaseSessionGuard implements StatefulGuard
      */
     public function getName()
     {
      */
     public function getName()
     {
-        return 'login_'.$this->name.'_'.sha1(static::class);
+        return 'login_' . $this->name . '_' . sha1(static::class);
     }
 
     /**
     }
 
     /**
@@ -288,7 +294,8 @@ class ExternalBaseSessionGuard implements StatefulGuard
     /**
      * Set the current user.
      *
     /**
      * Set the current user.
      *
-     * @param  \Illuminate\Contracts\Auth\Authenticatable  $user
+     * @param \Illuminate\Contracts\Auth\Authenticatable $user
+     *
      * @return $this
      */
     public function setUser(AuthenticatableContract $user)
      * @return $this
      */
     public function setUser(AuthenticatableContract $user)
index 71417aed2607d007fc0858039fe3df50e5265f86..7f6965937a19929a43124c508de406e8c61eb90a 100644 (file)
@@ -6,8 +6,8 @@ use BookStack\Auth\Access\LdapService;
 use BookStack\Auth\Access\RegistrationService;
 use BookStack\Auth\User;
 use BookStack\Exceptions\LdapException;
 use BookStack\Auth\Access\RegistrationService;
 use BookStack\Auth\User;
 use BookStack\Exceptions\LdapException;
-use BookStack\Exceptions\LoginAttemptException;
 use BookStack\Exceptions\LoginAttemptEmailNeededException;
 use BookStack\Exceptions\LoginAttemptEmailNeededException;
+use BookStack\Exceptions\LoginAttemptException;
 use BookStack\Exceptions\UserRegistrationException;
 use Illuminate\Contracts\Auth\UserProvider;
 use Illuminate\Contracts\Session\Session;
 use BookStack\Exceptions\UserRegistrationException;
 use Illuminate\Contracts\Auth\UserProvider;
 use Illuminate\Contracts\Session\Session;
@@ -15,7 +15,6 @@ use Illuminate\Support\Str;
 
 class LdapSessionGuard extends ExternalBaseSessionGuard
 {
 
 class LdapSessionGuard extends ExternalBaseSessionGuard
 {
-
     protected $ldapService;
 
     /**
     protected $ldapService;
 
     /**
@@ -36,8 +35,10 @@ class LdapSessionGuard extends ExternalBaseSessionGuard
      * Validate a user's credentials.
      *
      * @param array $credentials
      * Validate a user's credentials.
      *
      * @param array $credentials
-     * @return bool
+     *
      * @throws LdapException
      * @throws LdapException
+     *
+     * @return bool
      */
     public function validate(array $credentials = [])
     {
      */
     public function validate(array $credentials = [])
     {
@@ -45,7 +46,7 @@ class LdapSessionGuard extends ExternalBaseSessionGuard
 
         if (isset($userDetails['uid'])) {
             $this->lastAttempted = $this->provider->retrieveByCredentials([
 
         if (isset($userDetails['uid'])) {
             $this->lastAttempted = $this->provider->retrieveByCredentials([
-                'external_auth_id' => $userDetails['uid']
+                'external_auth_id' => $userDetails['uid'],
             ]);
         }
 
             ]);
         }
 
@@ -56,10 +57,12 @@ class LdapSessionGuard extends ExternalBaseSessionGuard
      * Attempt to authenticate a user using the given credentials.
      *
      * @param array $credentials
      * Attempt to authenticate a user using the given credentials.
      *
      * @param array $credentials
-     * @param bool $remember
-     * @return bool
+     * @param bool  $remember
+     *
      * @throws LoginAttemptException
      * @throws LdapException
      * @throws LoginAttemptException
      * @throws LdapException
+     *
+     * @return bool
      */
     public function attempt(array $credentials = [], $remember = false)
     {
      */
     public function attempt(array $credentials = [], $remember = false)
     {
@@ -69,7 +72,7 @@ class LdapSessionGuard extends ExternalBaseSessionGuard
         $user = null;
         if (isset($userDetails['uid'])) {
             $this->lastAttempted = $user = $this->provider->retrieveByCredentials([
         $user = null;
         if (isset($userDetails['uid'])) {
             $this->lastAttempted = $user = $this->provider->retrieveByCredentials([
-                'external_auth_id' => $userDetails['uid']
+                'external_auth_id' => $userDetails['uid'],
             ]);
         }
 
             ]);
         }
 
@@ -96,11 +99,13 @@ class LdapSessionGuard extends ExternalBaseSessionGuard
         }
 
         $this->login($user, $remember);
         }
 
         $this->login($user, $remember);
+
         return true;
     }
 
     /**
         return true;
     }
 
     /**
-     * Create a new user from the given ldap credentials and login credentials
+     * Create a new user from the given ldap credentials and login credentials.
+     *
      * @throws LoginAttemptEmailNeededException
      * @throws LoginAttemptException
      * @throws UserRegistrationException
      * @throws LoginAttemptEmailNeededException
      * @throws LoginAttemptException
      * @throws UserRegistrationException
@@ -114,14 +119,15 @@ class LdapSessionGuard extends ExternalBaseSessionGuard
         }
 
         $details = [
         }
 
         $details = [
-            'name' => $ldapUserDetails['name'],
-            'email' => $ldapUserDetails['email'] ?: $credentials['email'],
+            'name'             => $ldapUserDetails['name'],
+            'email'            => $ldapUserDetails['email'] ?: $credentials['email'],
             'external_auth_id' => $ldapUserDetails['uid'],
             'external_auth_id' => $ldapUserDetails['uid'],
-            'password' => Str::random(32),
+            'password'         => Str::random(32),
         ];
 
         $user = $this->registrationService->registerUser($details, null, false);
         $this->ldapService->saveAndAttachAvatar($user, $ldapUserDetails);
         ];
 
         $user = $this->registrationService->registerUser($details, null, false);
         $this->ldapService->saveAndAttachAvatar($user, $ldapUserDetails);
+
         return $user;
     }
 }
         return $user;
     }
 }
index 044c2f3833f3b2f4652bf22c210c775efbc1b583..eacd5d21e702f13efcbc654589a932a945131661 100644 (file)
@@ -3,7 +3,7 @@
 namespace BookStack\Auth\Access\Guards;
 
 /**
 namespace BookStack\Auth\Access\Guards;
 
 /**
- * Saml2 Session Guard
+ * Saml2 Session Guard.
  *
  * The saml2 login process is async in nature meaning it does not fit very well
  * into the default laravel 'Guard' auth flow. Instead most of the logic is done
  *
  * The saml2 login process is async in nature meaning it does not fit very well
  * into the default laravel 'Guard' auth flow. Instead most of the logic is done
@@ -16,6 +16,7 @@ class Saml2SessionGuard extends ExternalBaseSessionGuard
      * Validate a user's credentials.
      *
      * @param array $credentials
      * Validate a user's credentials.
      *
      * @param array $credentials
+     *
      * @return bool
      */
     public function validate(array $credentials = [])
      * @return bool
      */
     public function validate(array $credentials = [])
@@ -27,7 +28,8 @@ class Saml2SessionGuard extends ExternalBaseSessionGuard
      * Attempt to authenticate a user using the given credentials.
      *
      * @param array $credentials
      * Attempt to authenticate a user using the given credentials.
      *
      * @param array $credentials
-     * @param bool $remember
+     * @param bool  $remember
+     *
      * @return bool
      */
     public function attempt(array $credentials = [], $remember = false)
      * @return bool
      */
     public function attempt(array $credentials = [], $remember = false)
index 352231df54a8e3633a68fbcacb52fc07c332f92f..b5c70e498c0b4581dae5b6772ecee6f4c20696ca 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Auth\Access;
+<?php
+
+namespace BookStack\Auth\Access;
 
 /**
  * Class Ldap
 
 /**
  * Class Ldap
@@ -7,11 +9,12 @@
  */
 class Ldap
 {
  */
 class Ldap
 {
-
     /**
      * Connect to a LDAP server.
     /**
      * Connect to a LDAP server.
+     *
      * @param string $hostName
      * @param int    $port
      * @param string $hostName
      * @param int    $port
+     *
      * @return resource
      */
     public function connect($hostName, $port)
      * @return resource
      */
     public function connect($hostName, $port)
@@ -21,9 +24,11 @@ class Ldap
 
     /**
      * Set the value of a LDAP option for the given connection.
 
     /**
      * Set the value of a LDAP option for the given connection.
+     *
      * @param resource $ldapConnection
      * @param resource $ldapConnection
-     * @param int $option
-     * @param mixed $value
+     * @param int      $option
+     * @param mixed    $value
+     *
      * @return bool
      */
     public function setOption($ldapConnection, $option, $value)
      * @return bool
      */
     public function setOption($ldapConnection, $option, $value)
@@ -41,8 +46,10 @@ class Ldap
 
     /**
      * Set the version number for the given ldap connection.
 
     /**
      * Set the version number for the given ldap connection.
+     *
      * @param $ldapConnection
      * @param $version
      * @param $ldapConnection
      * @param $version
+     *
      * @return bool
      */
     public function setVersion($ldapConnection, $version)
      * @return bool
      */
     public function setVersion($ldapConnection, $version)
@@ -52,10 +59,12 @@ class Ldap
 
     /**
      * Search LDAP tree using the provided filter.
 
     /**
      * Search LDAP tree using the provided filter.
+     *
      * @param resource   $ldapConnection
      * @param string     $baseDn
      * @param string     $filter
      * @param array|null $attributes
      * @param resource   $ldapConnection
      * @param string     $baseDn
      * @param string     $filter
      * @param array|null $attributes
+     *
      * @return resource
      */
     public function search($ldapConnection, $baseDn, $filter, array $attributes = null)
      * @return resource
      */
     public function search($ldapConnection, $baseDn, $filter, array $attributes = null)
@@ -65,8 +74,10 @@ class Ldap
 
     /**
      * Get entries from an ldap search result.
 
     /**
      * Get entries from an ldap search result.
+     *
      * @param resource $ldapConnection
      * @param resource $ldapSearchResult
      * @param resource $ldapConnection
      * @param resource $ldapSearchResult
+     *
      * @return array
      */
     public function getEntries($ldapConnection, $ldapSearchResult)
      * @return array
      */
     public function getEntries($ldapConnection, $ldapSearchResult)
@@ -76,23 +87,28 @@ class Ldap
 
     /**
      * Search and get entries immediately.
 
     /**
      * Search and get entries immediately.
+     *
      * @param resource   $ldapConnection
      * @param string     $baseDn
      * @param string     $filter
      * @param array|null $attributes
      * @param resource   $ldapConnection
      * @param string     $baseDn
      * @param string     $filter
      * @param array|null $attributes
+     *
      * @return resource
      */
     public function searchAndGetEntries($ldapConnection, $baseDn, $filter, array $attributes = null)
     {
         $search = $this->search($ldapConnection, $baseDn, $filter, $attributes);
      * @return resource
      */
     public function searchAndGetEntries($ldapConnection, $baseDn, $filter, array $attributes = null)
     {
         $search = $this->search($ldapConnection, $baseDn, $filter, $attributes);
+
         return $this->getEntries($ldapConnection, $search);
     }
 
     /**
      * Bind to LDAP directory.
         return $this->getEntries($ldapConnection, $search);
     }
 
     /**
      * Bind to LDAP directory.
+     *
      * @param resource $ldapConnection
      * @param string   $bindRdn
      * @param string   $bindPassword
      * @param resource $ldapConnection
      * @param string   $bindRdn
      * @param string   $bindPassword
+     *
      * @return bool
      */
     public function bind($ldapConnection, $bindRdn = null, $bindPassword = null)
      * @return bool
      */
     public function bind($ldapConnection, $bindRdn = null, $bindPassword = null)
@@ -102,8 +118,10 @@ class Ldap
 
     /**
      * Explode a LDAP dn string into an array of components.
 
     /**
      * Explode a LDAP dn string into an array of components.
+     *
      * @param string $dn
      * @param string $dn
-     * @param int $withAttrib
+     * @param int    $withAttrib
+     *
      * @return array
      */
     public function explodeDn(string $dn, int $withAttrib)
      * @return array
      */
     public function explodeDn(string $dn, int $withAttrib)
@@ -113,12 +131,14 @@ class Ldap
 
     /**
      * Escape a string for use in an LDAP filter.
 
     /**
      * Escape a string for use in an LDAP filter.
+     *
      * @param string $value
      * @param string $ignore
      * @param string $value
      * @param string $ignore
-     * @param int $flags
+     * @param int    $flags
+     *
      * @return string
      */
      * @return string
      */
-    public function escape(string $value, string $ignore = "", int $flags = 0)
+    public function escape(string $value, string $ignore = '', int $flags = 0)
     {
         return ldap_escape($value, $ignore, $flags);
     }
     {
         return ldap_escape($value, $ignore, $flags);
     }
index 2f632b0b533e8534ae44835920a5279727da7338..7bfdb5328d874e5296f0227253a45475b2baddd5 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Auth\Access;
+<?php
+
+namespace BookStack\Auth\Access;
 
 use BookStack\Auth\User;
 use BookStack\Exceptions\JsonDebugException;
 
 use BookStack\Auth\User;
 use BookStack\Exceptions\JsonDebugException;
@@ -13,7 +15,6 @@ use Illuminate\Support\Facades\Log;
  */
 class LdapService extends ExternalAuthService
 {
  */
 class LdapService extends ExternalAuthService
 {
-
     protected $ldap;
     protected $ldapConnection;
     protected $userAvatars;
     protected $ldap;
     protected $ldapConnection;
     protected $userAvatars;
@@ -33,6 +34,7 @@ class LdapService extends ExternalAuthService
 
     /**
      * Check if groups should be synced.
 
     /**
      * Check if groups should be synced.
+     *
      * @return bool
      */
     public function shouldSyncGroups()
      * @return bool
      */
     public function shouldSyncGroups()
@@ -42,6 +44,7 @@ class LdapService extends ExternalAuthService
 
     /**
      * Search for attributes for a specific user on the ldap.
 
     /**
      * Search for attributes for a specific user on the ldap.
+     *
      * @throws LdapException
      */
     private function getUserWithAttributes(string $userName, array $attributes): ?array
      * @throws LdapException
      */
     private function getUserWithAttributes(string $userName, array $attributes): ?array
@@ -73,6 +76,7 @@ class LdapService extends ExternalAuthService
     /**
      * Get the details of a user from LDAP using the given username.
      * User found via configurable user filter.
     /**
      * Get the details of a user from LDAP using the given username.
      * User found via configurable user filter.
+     *
      * @throws LdapException
      */
     public function getUserDetails(string $userName): ?array
      * @throws LdapException
      */
     public function getUserDetails(string $userName): ?array
@@ -92,16 +96,16 @@ class LdapService extends ExternalAuthService
 
         $userCn = $this->getUserResponseProperty($user, 'cn', null);
         $formatted = [
 
         $userCn = $this->getUserResponseProperty($user, 'cn', null);
         $formatted = [
-            'uid' => $this->getUserResponseProperty($user, $idAttr, $user['dn']),
-            'name' => $this->getUserResponseProperty($user, $displayNameAttr, $userCn),
-            'dn' => $user['dn'],
+            'uid'   => $this->getUserResponseProperty($user, $idAttr, $user['dn']),
+            'name'  => $this->getUserResponseProperty($user, $displayNameAttr, $userCn),
+            'dn'    => $user['dn'],
             'email' => $this->getUserResponseProperty($user, $emailAttr, null),
             'avatar'=> $thumbnailAttr ? $this->getUserResponseProperty($user, $thumbnailAttr, null) : null,
         ];
 
         if ($this->config['dump_user_details']) {
             throw new JsonDebugException([
             'email' => $this->getUserResponseProperty($user, $emailAttr, null),
             'avatar'=> $thumbnailAttr ? $this->getUserResponseProperty($user, $thumbnailAttr, null) : null,
         ];
 
         if ($this->config['dump_user_details']) {
             throw new JsonDebugException([
-                'details_from_ldap' => $user,
+                'details_from_ldap'        => $user,
                 'details_bookstack_parsed' => $formatted,
             ]);
         }
                 'details_bookstack_parsed' => $formatted,
             ]);
         }
@@ -137,6 +141,7 @@ class LdapService extends ExternalAuthService
 
     /**
      * Check if the given credentials are valid for the given user.
 
     /**
      * Check if the given credentials are valid for the given user.
+     *
      * @throws LdapException
      */
     public function validateUserCredentials(?array $ldapUserDetails, string $password): bool
      * @throws LdapException
      */
     public function validateUserCredentials(?array $ldapUserDetails, string $password): bool
@@ -146,6 +151,7 @@ class LdapService extends ExternalAuthService
         }
 
         $ldapConnection = $this->getConnection();
         }
 
         $ldapConnection = $this->getConnection();
+
         try {
             $ldapBind = $this->ldap->bind($ldapConnection, $ldapUserDetails['dn'], $password);
         } catch (ErrorException $e) {
         try {
             $ldapBind = $this->ldap->bind($ldapConnection, $ldapUserDetails['dn'], $password);
         } catch (ErrorException $e) {
@@ -158,7 +164,9 @@ class LdapService extends ExternalAuthService
     /**
      * Bind the system user to the LDAP connection using the given credentials
      * otherwise anonymous access is attempted.
     /**
      * Bind the system user to the LDAP connection using the given credentials
      * otherwise anonymous access is attempted.
+     *
      * @param $connection
      * @param $connection
+     *
      * @throws LdapException
      */
     protected function bindSystemUser($connection)
      * @throws LdapException
      */
     protected function bindSystemUser($connection)
@@ -181,8 +189,10 @@ class LdapService extends ExternalAuthService
     /**
      * Get the connection to the LDAP server.
      * Creates a new connection if one does not exist.
     /**
      * Get the connection to the LDAP server.
      * Creates a new connection if one does not exist.
-     * @return resource
+     *
      * @throws LdapException
      * @throws LdapException
+     *
+     * @return resource
      */
     protected function getConnection()
     {
      */
     protected function getConnection()
     {
@@ -222,6 +232,7 @@ class LdapService extends ExternalAuthService
         }
 
         $this->ldapConnection = $ldapConnection;
         }
 
         $this->ldapConnection = $ldapConnection;
+
         return $this->ldapConnection;
     }
 
         return $this->ldapConnection;
     }
 
@@ -241,6 +252,7 @@ class LdapService extends ExternalAuthService
         // Otherwise, extract the port out
         $hostName = $serverNameParts[0];
         $ldapPort = (count($serverNameParts) > 1) ? intval($serverNameParts[1]) : 389;
         // Otherwise, extract the port out
         $hostName = $serverNameParts[0];
         $ldapPort = (count($serverNameParts) > 1) ? intval($serverNameParts[1]) : 389;
+
         return ['host' => $hostName, 'port' => $ldapPort];
     }
 
         return ['host' => $hostName, 'port' => $ldapPort];
     }
 
@@ -254,11 +266,13 @@ class LdapService extends ExternalAuthService
             $newKey = '${' . $key . '}';
             $newAttrs[$newKey] = $this->ldap->escape($attrText);
         }
             $newKey = '${' . $key . '}';
             $newAttrs[$newKey] = $this->ldap->escape($attrText);
         }
+
         return strtr($filterString, $newAttrs);
     }
 
     /**
      * Get the groups a user is a part of on ldap.
         return strtr($filterString, $newAttrs);
     }
 
     /**
      * Get the groups a user is a part of on ldap.
+     *
      * @throws LdapException
      */
     public function getUserGroups(string $userName): array
      * @throws LdapException
      */
     public function getUserGroups(string $userName): array
@@ -272,11 +286,13 @@ class LdapService extends ExternalAuthService
 
         $userGroups = $this->groupFilter($user);
         $userGroups = $this->getGroupsRecursive($userGroups, []);
 
         $userGroups = $this->groupFilter($user);
         $userGroups = $this->getGroupsRecursive($userGroups, []);
+
         return $userGroups;
     }
 
     /**
      * Get the parent groups of an array of groups.
         return $userGroups;
     }
 
     /**
      * Get the parent groups of an array of groups.
+     *
      * @throws LdapException
      */
     private function getGroupsRecursive(array $groupsArray, array $checked): array
      * @throws LdapException
      */
     private function getGroupsRecursive(array $groupsArray, array $checked): array
@@ -303,6 +319,7 @@ class LdapService extends ExternalAuthService
 
     /**
      * Get the parent groups of a single group.
 
     /**
      * Get the parent groups of a single group.
+     *
      * @throws LdapException
      */
     private function getGroupGroups(string $groupName): array
      * @throws LdapException
      */
     private function getGroupGroups(string $groupName): array
@@ -336,7 +353,7 @@ class LdapService extends ExternalAuthService
         $count = 0;
 
         if (isset($userGroupSearchResponse[$groupsAttr]['count'])) {
         $count = 0;
 
         if (isset($userGroupSearchResponse[$groupsAttr]['count'])) {
-            $count = (int)$userGroupSearchResponse[$groupsAttr]['count'];
+            $count = (int) $userGroupSearchResponse[$groupsAttr]['count'];
         }
 
         for ($i = 0; $i < $count; $i++) {
         }
 
         for ($i = 0; $i < $count; $i++) {
@@ -351,6 +368,7 @@ class LdapService extends ExternalAuthService
 
     /**
      * Sync the LDAP groups to the user roles for the current user.
 
     /**
      * Sync the LDAP groups to the user roles for the current user.
+     *
      * @throws LdapException
      */
     public function syncGroups(User $user, string $username)
      * @throws LdapException
      */
     public function syncGroups(User $user, string $username)
index 68b17771d628552fe57a1d40fe7301774d43adb9..16e3edbb44e8dc799c4bd3939a358d5d3b9b28df 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Auth\Access;
+<?php
+
+namespace BookStack\Auth\Access;
 
 use BookStack\Actions\ActivityType;
 use BookStack\Auth\SocialAccount;
 
 use BookStack\Actions\ActivityType;
 use BookStack\Auth\SocialAccount;
@@ -12,7 +14,6 @@ use Exception;
 
 class RegistrationService
 {
 
 class RegistrationService
 {
-
     protected $userRepo;
     protected $emailConfirmationService;
 
     protected $userRepo;
     protected $emailConfirmationService;
 
@@ -27,6 +28,7 @@ class RegistrationService
 
     /**
      * Check whether or not registrations are allowed in the app settings.
 
     /**
      * Check whether or not registrations are allowed in the app settings.
+     *
      * @throws UserRegistrationException
      */
     public function ensureRegistrationAllowed()
      * @throws UserRegistrationException
      */
     public function ensureRegistrationAllowed()
@@ -44,11 +46,13 @@ class RegistrationService
     {
         $authMethod = config('auth.method');
         $authMethodsWithRegistration = ['standard'];
     {
         $authMethod = config('auth.method');
         $authMethodsWithRegistration = ['standard'];
+
         return in_array($authMethod, $authMethodsWithRegistration) && setting('registration-enabled');
     }
 
     /**
      * The registrations flow for all users.
         return in_array($authMethod, $authMethodsWithRegistration) && setting('registration-enabled');
     }
 
     /**
      * The registrations flow for all users.
+     *
      * @throws UserRegistrationException
      */
     public function registerUser(array $userData, ?SocialAccount $socialAccount = null, bool $emailConfirmed = false): User
      * @throws UserRegistrationException
      */
     public function registerUser(array $userData, ?SocialAccount $socialAccount = null, bool $emailConfirmed = false): User
@@ -84,6 +88,7 @@ class RegistrationService
                 session()->flash('sent-email-confirmation', true);
             } catch (Exception $e) {
                 $message = trans('auth.email_confirm_send_error');
                 session()->flash('sent-email-confirmation', true);
             } catch (Exception $e) {
                 $message = trans('auth.email_confirm_send_error');
+
                 throw new UserRegistrationException($message, '/register/confirm');
             }
         }
                 throw new UserRegistrationException($message, '/register/confirm');
             }
         }
@@ -94,6 +99,7 @@ class RegistrationService
     /**
      * Ensure that the given email meets any active email domain registration restrictions.
      * Throws if restrictions are active and the email does not match an allowed domain.
     /**
      * Ensure that the given email meets any active email domain registration restrictions.
      * Throws if restrictions are active and the email does not match an allowed domain.
+     *
      * @throws UserRegistrationException
      */
     protected function ensureEmailDomainAllowed(string $userEmail): void
      * @throws UserRegistrationException
      */
     protected function ensureEmailDomainAllowed(string $userEmail): void
@@ -105,9 +111,10 @@ class RegistrationService
         }
 
         $restrictedEmailDomains = explode(',', str_replace(' ', '', $registrationRestrict));
         }
 
         $restrictedEmailDomains = explode(',', str_replace(' ', '', $registrationRestrict));
-        $userEmailDomain = $domain = mb_substr(mb_strrchr($userEmail, "@"), 1);
+        $userEmailDomain = $domain = mb_substr(mb_strrchr($userEmail, '@'), 1);
         if (!in_array($userEmailDomain, $restrictedEmailDomains)) {
             $redirect = $this->registrationAllowed() ? '/register' : '/login';
         if (!in_array($userEmailDomain, $restrictedEmailDomains)) {
             $redirect = $this->registrationAllowed() ? '/register' : '/login';
+
             throw new UserRegistrationException(trans('auth.registration_email_domain_invalid'), $redirect);
         }
     }
             throw new UserRegistrationException(trans('auth.registration_email_domain_invalid'), $redirect);
         }
     }
index 105853997cd4d939c3fefe66678915dea89bdaa9..28d4d40303242bca8f96c8c60b173dc721279873 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Auth\Access;
+<?php
+
+namespace BookStack\Auth\Access;
 
 use BookStack\Actions\ActivityType;
 use BookStack\Auth\User;
 
 use BookStack\Actions\ActivityType;
 use BookStack\Auth\User;
@@ -37,20 +39,23 @@ class Saml2Service extends ExternalAuthService
 
     /**
      * Initiate a login flow.
 
     /**
      * Initiate a login flow.
+     *
      * @throws Error
      */
     public function login(): array
     {
         $toolKit = $this->getToolkit();
         $returnRoute = url('/saml2/acs');
      * @throws Error
      */
     public function login(): array
     {
         $toolKit = $this->getToolkit();
         $returnRoute = url('/saml2/acs');
+
         return [
             'url' => $toolKit->login($returnRoute, [], false, false, true),
         return [
             'url' => $toolKit->login($returnRoute, [], false, false, true),
-            'id' => $toolKit->getLastRequestID(),
+            'id'  => $toolKit->getLastRequestID(),
         ];
     }
 
     /**
      * Initiate a logout flow.
         ];
     }
 
     /**
      * Initiate a logout flow.
+     *
      * @throws Error
      */
     public function logout(): array
      * @throws Error
      */
     public function logout(): array
@@ -78,6 +83,7 @@ class Saml2Service extends ExternalAuthService
      * Process the ACS response from the idp and return the
      * matching, or new if registration active, user matched to the idp.
      * Returns null if not authenticated.
      * Process the ACS response from the idp and return the
      * matching, or new if registration active, user matched to the idp.
      * Returns null if not authenticated.
+     *
      * @throws Error
      * @throws SamlException
      * @throws ValidationError
      * @throws Error
      * @throws SamlException
      * @throws ValidationError
@@ -92,7 +98,7 @@ class Saml2Service extends ExternalAuthService
 
         if (!empty($errors)) {
             throw new Error(
 
         if (!empty($errors)) {
             throw new Error(
-                'Invalid ACS Response: '.implode(', ', $errors)
+                'Invalid ACS Response: ' . implode(', ', $errors)
             );
         }
 
             );
         }
 
@@ -108,6 +114,7 @@ class Saml2Service extends ExternalAuthService
 
     /**
      * Process a response for the single logout service.
 
     /**
      * Process a response for the single logout service.
+     *
      * @throws Error
      */
     public function processSlsResponse(?string $requestId): ?string
      * @throws Error
      */
     public function processSlsResponse(?string $requestId): ?string
@@ -119,11 +126,12 @@ class Saml2Service extends ExternalAuthService
 
         if (!empty($errors)) {
             throw new Error(
 
         if (!empty($errors)) {
             throw new Error(
-                'Invalid SLS Response: '.implode(', ', $errors)
+                'Invalid SLS Response: ' . implode(', ', $errors)
             );
         }
 
         $this->actionLogout();
             );
         }
 
         $this->actionLogout();
+
         return $redirect;
     }
 
         return $redirect;
     }
 
@@ -138,6 +146,7 @@ class Saml2Service extends ExternalAuthService
 
     /**
      * Get the metadata for this service provider.
 
     /**
      * Get the metadata for this service provider.
+     *
      * @throws Error
      */
     public function metadata(): string
      * @throws Error
      */
     public function metadata(): string
@@ -149,7 +158,7 @@ class Saml2Service extends ExternalAuthService
 
         if (!empty($errors)) {
             throw new Error(
 
         if (!empty($errors)) {
             throw new Error(
-                'Invalid SP metadata: '.implode(', ', $errors),
+                'Invalid SP metadata: ' . implode(', ', $errors),
                 Error::METADATA_SP_INVALID
             );
         }
                 Error::METADATA_SP_INVALID
             );
         }
@@ -159,6 +168,7 @@ class Saml2Service extends ExternalAuthService
 
     /**
      * Load the underlying Onelogin SAML2 toolkit.
 
     /**
      * Load the underlying Onelogin SAML2 toolkit.
+     *
      * @throws Error
      * @throws Exception
      */
      * @throws Error
      * @throws Exception
      */
@@ -178,6 +188,7 @@ class Saml2Service extends ExternalAuthService
 
         $spSettings = $this->loadOneloginServiceProviderDetails();
         $settings = array_replace_recursive($settings, $spSettings, $metaDataSettings, $overrides);
 
         $spSettings = $this->loadOneloginServiceProviderDetails();
         $settings = array_replace_recursive($settings, $spSettings, $metaDataSettings, $overrides);
+
         return new Auth($settings);
     }
 
         return new Auth($settings);
     }
 
@@ -187,18 +198,18 @@ class Saml2Service extends ExternalAuthService
     protected function loadOneloginServiceProviderDetails(): array
     {
         $spDetails = [
     protected function loadOneloginServiceProviderDetails(): array
     {
         $spDetails = [
-            'entityId' => url('/saml2/metadata'),
+            'entityId'                 => url('/saml2/metadata'),
             'assertionConsumerService' => [
                 'url' => url('/saml2/acs'),
             ],
             'singleLogoutService' => [
             'assertionConsumerService' => [
                 'url' => url('/saml2/acs'),
             ],
             'singleLogoutService' => [
-                'url' => url('/saml2/sls')
+                'url' => url('/saml2/sls'),
             ],
         ];
 
         return [
             'baseurl' => url('/saml2'),
             ],
         ];
 
         return [
             'baseurl' => url('/saml2'),
-            'sp' => $spDetails
+            'sp'      => $spDetails,
         ];
     }
 
         ];
     }
 
@@ -211,7 +222,7 @@ class Saml2Service extends ExternalAuthService
     }
 
     /**
     }
 
     /**
-     * Calculate the display name
+     * Calculate the display name.
      */
     protected function getUserDisplayName(array $samlAttributes, string $defaultValue): string
     {
      */
     protected function getUserDisplayName(array $samlAttributes, string $defaultValue): string
     {
@@ -261,9 +272,9 @@ class Saml2Service extends ExternalAuthService
 
         return [
             'external_id' => $externalId,
 
         return [
             'external_id' => $externalId,
-            'name' => $this->getUserDisplayName($samlAttributes, $externalId),
-            'email' => $email,
-            'saml_id' => $samlID,
+            'name'        => $this->getUserDisplayName($samlAttributes, $externalId),
+            'email'       => $email,
+            'saml_id'     => $samlID,
         ];
     }
 
         ];
     }
 
@@ -297,6 +308,7 @@ class Saml2Service extends ExternalAuthService
                 $data = $data[0];
                 break;
         }
                 $data = $data[0];
                 break;
         }
+
         return $data;
     }
 
         return $data;
     }
 
@@ -315,6 +327,7 @@ class Saml2Service extends ExternalAuthService
 
     /**
      * Get the user from the database for the specified details.
 
     /**
      * Get the user from the database for the specified details.
+     *
      * @throws UserRegistrationException
      */
     protected function getOrRegisterUser(array $userDetails): ?User
      * @throws UserRegistrationException
      */
     protected function getOrRegisterUser(array $userDetails): ?User
@@ -325,9 +338,9 @@ class Saml2Service extends ExternalAuthService
 
         if (is_null($user)) {
             $userData = [
 
         if (is_null($user)) {
             $userData = [
-                'name' => $userDetails['name'],
-                'email' => $userDetails['email'],
-                'password' => Str::random(32),
+                'name'             => $userDetails['name'],
+                'email'            => $userDetails['email'],
+                'password'         => Str::random(32),
                 'external_auth_id' => $userDetails['external_id'],
             ];
 
                 'external_auth_id' => $userDetails['external_id'],
             ];
 
@@ -340,6 +353,7 @@ class Saml2Service extends ExternalAuthService
     /**
      * Process the SAML response for a user. Login the user when
      * they exist, optionally registering them automatically.
     /**
      * Process the SAML response for a user. Login the user when
      * they exist, optionally registering them automatically.
+     *
      * @throws SamlException
      * @throws JsonDebugException
      * @throws UserRegistrationException
      * @throws SamlException
      * @throws JsonDebugException
      * @throws UserRegistrationException
@@ -351,8 +365,8 @@ class Saml2Service extends ExternalAuthService
 
         if ($this->config['dump_user_details']) {
             throw new JsonDebugException([
 
         if ($this->config['dump_user_details']) {
             throw new JsonDebugException([
-                'id_from_idp' => $samlID,
-                'attrs_from_idp' => $samlAttributes,
+                'id_from_idp'         => $samlID,
+                'attrs_from_idp'      => $samlAttributes,
                 'attrs_after_parsing' => $userDetails,
             ]);
         }
                 'attrs_after_parsing' => $userDetails,
             ]);
         }
@@ -378,6 +392,7 @@ class Saml2Service extends ExternalAuthService
         auth()->login($user);
         Activity::add(ActivityType::AUTH_LOGIN, "saml2; {$user->logDescriptor()}");
         Theme::dispatch(ThemeEvents::AUTH_LOGIN, 'saml2', $user);
         auth()->login($user);
         Activity::add(ActivityType::AUTH_LOGIN, "saml2; {$user->logDescriptor()}");
         Theme::dispatch(ThemeEvents::AUTH_LOGIN, 'saml2', $user);
+
         return $user;
     }
 }
         return $user;
     }
 }
index a03eb2b1d97d662421f6b41a451dc5f33674fe6a..2f1a6876a13e5a753d5d437dd24e49a36fda81a7 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Auth\Access;
+<?php
+
+namespace BookStack\Auth\Access;
 
 use BookStack\Actions\ActivityType;
 use BookStack\Auth\SocialAccount;
 
 use BookStack\Actions\ActivityType;
 use BookStack\Auth\SocialAccount;
@@ -21,12 +23,14 @@ class SocialAuthService
 {
     /**
      * The core socialite library used.
 {
     /**
      * The core socialite library used.
+     *
      * @var Socialite
      */
     protected $socialite;
 
     /**
      * The default built-in social drivers we support.
      * @var Socialite
      */
     protected $socialite;
 
     /**
      * The default built-in social drivers we support.
+     *
      * @var string[]
      */
     protected $validSocialDrivers = [
      * @var string[]
      */
     protected $validSocialDrivers = [
@@ -39,7 +43,7 @@ class SocialAuthService
         'okta',
         'gitlab',
         'twitch',
         'okta',
         'gitlab',
         'twitch',
-        'discord'
+        'discord',
     ];
 
     /**
     ];
 
     /**
@@ -47,6 +51,7 @@ class SocialAuthService
      * for an initial redirect action.
      * Array is keyed by social driver name.
      * Callbacks are passed an instance of the driver.
      * for an initial redirect action.
      * Array is keyed by social driver name.
      * Callbacks are passed an instance of the driver.
+     *
      * @var array<string, callable>
      */
     protected $configureForRedirectCallbacks = [];
      * @var array<string, callable>
      */
     protected $configureForRedirectCallbacks = [];
@@ -61,26 +66,31 @@ class SocialAuthService
 
     /**
      * Start the social login path.
 
     /**
      * Start the social login path.
+     *
      * @throws SocialDriverNotConfigured
      */
     public function startLogIn(string $socialDriver): RedirectResponse
     {
         $driver = $this->validateDriver($socialDriver);
      * @throws SocialDriverNotConfigured
      */
     public function startLogIn(string $socialDriver): RedirectResponse
     {
         $driver = $this->validateDriver($socialDriver);
+
         return $this->getDriverForRedirect($driver)->redirect();
     }
 
     /**
         return $this->getDriverForRedirect($driver)->redirect();
     }
 
     /**
-     * Start the social registration process
+     * Start the social registration process.
+     *
      * @throws SocialDriverNotConfigured
      */
     public function startRegister(string $socialDriver): RedirectResponse
     {
         $driver = $this->validateDriver($socialDriver);
      * @throws SocialDriverNotConfigured
      */
     public function startRegister(string $socialDriver): RedirectResponse
     {
         $driver = $this->validateDriver($socialDriver);
+
         return $this->getDriverForRedirect($driver)->redirect();
     }
 
     /**
      * Handle the social registration process on callback.
         return $this->getDriverForRedirect($driver)->redirect();
     }
 
     /**
      * Handle the social registration process on callback.
+     *
      * @throws UserRegistrationException
      */
     public function handleRegistrationCallback(string $socialDriver, SocialUser $socialUser): SocialUser
      * @throws UserRegistrationException
      */
     public function handleRegistrationCallback(string $socialDriver, SocialUser $socialUser): SocialUser
@@ -92,6 +102,7 @@ class SocialAuthService
 
         if (User::query()->where('email', '=', $socialUser->getEmail())->exists()) {
             $email = $socialUser->getEmail();
 
         if (User::query()->where('email', '=', $socialUser->getEmail())->exists()) {
             $email = $socialUser->getEmail();
+
             throw new UserRegistrationException(trans('errors.error_user_exists_different_creds', ['email' => $email]), '/login');
         }
 
             throw new UserRegistrationException(trans('errors.error_user_exists_different_creds', ['email' => $email]), '/login');
         }
 
@@ -100,16 +111,19 @@ class SocialAuthService
 
     /**
      * Get the social user details via the social driver.
 
     /**
      * Get the social user details via the social driver.
+     *
      * @throws SocialDriverNotConfigured
      */
     public function getSocialUser(string $socialDriver): SocialUser
     {
         $driver = $this->validateDriver($socialDriver);
      * @throws SocialDriverNotConfigured
      */
     public function getSocialUser(string $socialDriver): SocialUser
     {
         $driver = $this->validateDriver($socialDriver);
+
         return $this->socialite->driver($driver)->user();
     }
 
     /**
      * Handle the login process on a oAuth callback.
         return $this->socialite->driver($driver)->user();
     }
 
     /**
      * Handle the login process on a oAuth callback.
+     *
      * @throws SocialSignInAccountNotUsed
      */
     public function handleLoginCallback(string $socialDriver, SocialUser $socialUser)
      * @throws SocialSignInAccountNotUsed
      */
     public function handleLoginCallback(string $socialDriver, SocialUser $socialUser)
@@ -128,6 +142,7 @@ class SocialAuthService
             auth()->login($socialAccount->user);
             Activity::add(ActivityType::AUTH_LOGIN, $socialAccount);
             Theme::dispatch(ThemeEvents::AUTH_LOGIN, $socialDriver, $socialAccount->user);
             auth()->login($socialAccount->user);
             Activity::add(ActivityType::AUTH_LOGIN, $socialAccount);
             Theme::dispatch(ThemeEvents::AUTH_LOGIN, $socialDriver, $socialAccount->user);
+
             return redirect()->intended('/');
         }
 
             return redirect()->intended('/');
         }
 
@@ -137,18 +152,21 @@ class SocialAuthService
             $account = $this->newSocialAccount($socialDriver, $socialUser);
             $currentUser->socialAccounts()->save($account);
             session()->flash('success', trans('settings.users_social_connected', ['socialAccount' => $titleCaseDriver]));
             $account = $this->newSocialAccount($socialDriver, $socialUser);
             $currentUser->socialAccounts()->save($account);
             session()->flash('success', trans('settings.users_social_connected', ['socialAccount' => $titleCaseDriver]));
+
             return redirect($currentUser->getEditUrl());
         }
 
         // When a user is logged in and the social account exists and is already linked to the current user.
         if ($isLoggedIn && $socialAccount !== null && $socialAccount->user->id === $currentUser->id) {
             session()->flash('error', trans('errors.social_account_existing', ['socialAccount' => $titleCaseDriver]));
             return redirect($currentUser->getEditUrl());
         }
 
         // When a user is logged in and the social account exists and is already linked to the current user.
         if ($isLoggedIn && $socialAccount !== null && $socialAccount->user->id === $currentUser->id) {
             session()->flash('error', trans('errors.social_account_existing', ['socialAccount' => $titleCaseDriver]));
+
             return redirect($currentUser->getEditUrl());
         }
 
         // When a user is logged in, A social account exists but the users do not match.
         if ($isLoggedIn && $socialAccount !== null && $socialAccount->user->id != $currentUser->id) {
             session()->flash('error', trans('errors.social_account_already_used_existing', ['socialAccount' => $titleCaseDriver]));
             return redirect($currentUser->getEditUrl());
         }
 
         // When a user is logged in, A social account exists but the users do not match.
         if ($isLoggedIn && $socialAccount !== null && $socialAccount->user->id != $currentUser->id) {
             session()->flash('error', trans('errors.social_account_already_used_existing', ['socialAccount' => $titleCaseDriver]));
+
             return redirect($currentUser->getEditUrl());
         }
 
             return redirect($currentUser->getEditUrl());
         }
 
@@ -163,6 +181,7 @@ class SocialAuthService
 
     /**
      * Ensure the social driver is correct and supported.
 
     /**
      * Ensure the social driver is correct and supported.
+     *
      * @throws SocialDriverNotConfigured
      */
     protected function validateDriver(string $socialDriver): string
      * @throws SocialDriverNotConfigured
      */
     protected function validateDriver(string $socialDriver): string
@@ -188,6 +207,7 @@ class SocialAuthService
         $lowerName = strtolower($driver);
         $configPrefix = 'services.' . $lowerName . '.';
         $config = [config($configPrefix . 'client_id'), config($configPrefix . 'client_secret'), config('services.callback_url')];
         $lowerName = strtolower($driver);
         $configPrefix = 'services.' . $lowerName . '.';
         $config = [config($configPrefix . 'client_id'), config($configPrefix . 'client_secret'), config('services.callback_url')];
+
         return !in_array(false, $config) && !in_array(null, $config);
     }
 
         return !in_array(false, $config) && !in_array(null, $config);
     }
 
@@ -237,9 +257,9 @@ class SocialAuthService
     public function newSocialAccount(string $socialDriver, SocialUser $socialUser): SocialAccount
     {
         return new SocialAccount([
     public function newSocialAccount(string $socialDriver, SocialUser $socialUser): SocialAccount
     {
         return new SocialAccount([
-            'driver' => $socialDriver,
+            'driver'    => $socialDriver,
             'driver_id' => $socialUser->getId(),
             'driver_id' => $socialUser->getId(),
-            'avatar' => $socialUser->getAvatar()
+            'avatar'    => $socialUser->getAvatar(),
         ]);
     }
 
         ]);
     }
 
@@ -252,7 +272,7 @@ class SocialAuthService
     }
 
     /**
     }
 
     /**
-     * Provide redirect options per service for the Laravel Socialite driver
+     * Provide redirect options per service for the Laravel Socialite driver.
      */
     protected function getDriverForRedirect(string $driverName): Provider
     {
      */
     protected function getDriverForRedirect(string $driverName): Provider
     {
index 20519fc7d4b98ae9f772a5387deb7fdfe9b84984..d884cd6369317ac5cd832e6dff63ea6636a6cbf9 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Auth\Access;
+<?php
+
+namespace BookStack\Auth\Access;
 
 use BookStack\Auth\User;
 use BookStack\Notifications\UserInvite;
 
 use BookStack\Auth\User;
 use BookStack\Notifications\UserInvite;
@@ -11,6 +13,7 @@ class UserInviteService extends UserTokenService
     /**
      * Send an invitation to a user to sign into BookStack
      * Removes existing invitation tokens.
     /**
      * Send an invitation to a user to sign into BookStack
      * Removes existing invitation tokens.
+     *
      * @param User $user
      */
     public function sendInvitation(User $user)
      * @param User $user
      */
     public function sendInvitation(User $user)
index a1defbf62d439a4bdacdef971271db1dde532afd..565dcb948b4caab36ee2056784d200241417fa27 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Auth\Access;
+<?php
+
+namespace BookStack\Auth\Access;
 
 use BookStack\Auth\User;
 use BookStack\Exceptions\UserTokenExpiredException;
 
 use BookStack\Auth\User;
 use BookStack\Exceptions\UserTokenExpiredException;
@@ -10,15 +12,16 @@ use stdClass;
 
 class UserTokenService
 {
 
 class UserTokenService
 {
-
     /**
      * Name of table where user tokens are stored.
     /**
      * Name of table where user tokens are stored.
+     *
      * @var string
      */
     protected $tokenTable = 'user_tokens';
 
     /**
      * Token expiry time in hours.
      * @var string
      */
     protected $tokenTable = 'user_tokens';
 
     /**
      * Token expiry time in hours.
+     *
      * @var int
      */
     protected $expiryTime = 24;
      * @var int
      */
     protected $expiryTime = 24;
@@ -27,6 +30,7 @@ class UserTokenService
 
     /**
      * UserTokenService constructor.
 
     /**
      * UserTokenService constructor.
+     *
      * @param Database $db
      */
     public function __construct(Database $db)
      * @param Database $db
      */
     public function __construct(Database $db)
@@ -36,7 +40,9 @@ class UserTokenService
 
     /**
      * Delete all email confirmations that belong to a user.
 
     /**
      * Delete all email confirmations that belong to a user.
+     *
      * @param User $user
      * @param User $user
+     *
      * @return mixed
      */
     public function deleteByUser(User $user)
      * @return mixed
      */
     public function deleteByUser(User $user)
@@ -48,12 +54,15 @@ class UserTokenService
 
     /**
      * Get the user id from a token, while check the token exists and has not expired.
 
     /**
      * Get the user id from a token, while check the token exists and has not expired.
+     *
      * @param string $token
      * @param string $token
-     * @return int
+     *
      * @throws UserTokenNotFoundException
      * @throws UserTokenExpiredException
      * @throws UserTokenNotFoundException
      * @throws UserTokenExpiredException
+     *
+     * @return int
      */
      */
-    public function checkTokenAndGetUserId(string $token) : int
+    public function checkTokenAndGetUserId(string $token): int
     {
         $entry = $this->getEntryByToken($token);
 
     {
         $entry = $this->getEntryByToken($token);
 
@@ -70,40 +79,47 @@ class UserTokenService
 
     /**
      * Creates a unique token within the email confirmation database.
 
     /**
      * Creates a unique token within the email confirmation database.
+     *
      * @return string
      */
      * @return string
      */
-    protected function generateToken() : string
+    protected function generateToken(): string
     {
         $token = Str::random(24);
         while ($this->tokenExists($token)) {
             $token = Str::random(25);
         }
     {
         $token = Str::random(24);
         while ($this->tokenExists($token)) {
             $token = Str::random(25);
         }
+
         return $token;
     }
 
     /**
      * Generate and store a token for the given user.
         return $token;
     }
 
     /**
      * Generate and store a token for the given user.
+     *
      * @param User $user
      * @param User $user
+     *
      * @return string
      */
      * @return string
      */
-    protected function createTokenForUser(User $user) : string
+    protected function createTokenForUser(User $user): string
     {
         $token = $this->generateToken();
         $this->db->table($this->tokenTable)->insert([
     {
         $token = $this->generateToken();
         $this->db->table($this->tokenTable)->insert([
-            'user_id' => $user->id,
-            'token' => $token,
+            'user_id'    => $user->id,
+            'token'      => $token,
             'created_at' => Carbon::now(),
             'created_at' => Carbon::now(),
-            'updated_at' => Carbon::now()
+            'updated_at' => Carbon::now(),
         ]);
         ]);
+
         return $token;
     }
 
     /**
      * Check if the given token exists.
         return $token;
     }
 
     /**
      * Check if the given token exists.
+     *
      * @param string $token
      * @param string $token
+     *
      * @return bool
      */
      * @return bool
      */
-    protected function tokenExists(string $token) : bool
+    protected function tokenExists(string $token): bool
     {
         return $this->db->table($this->tokenTable)
             ->where('token', '=', $token)->exists();
     {
         return $this->db->table($this->tokenTable)
             ->where('token', '=', $token)->exists();
@@ -111,7 +127,9 @@ class UserTokenService
 
     /**
      * Get a token entry for the given token.
 
     /**
      * Get a token entry for the given token.
+     *
      * @param string $token
      * @param string $token
+     *
      * @return object|null
      */
     protected function getEntryByToken(string $token)
      * @return object|null
      */
     protected function getEntryByToken(string $token)
@@ -123,10 +141,12 @@ class UserTokenService
 
     /**
      * Check if the given token entry has expired.
 
     /**
      * Check if the given token entry has expired.
+     *
      * @param stdClass $tokenEntry
      * @param stdClass $tokenEntry
+     *
      * @return bool
      */
      * @return bool
      */
-    protected function entryExpired(stdClass $tokenEntry) : bool
+    protected function entryExpired(stdClass $tokenEntry): bool
     {
         return Carbon::now()->subHours($this->expiryTime)
             ->gt(new Carbon($tokenEntry->created_at));
     {
         return Carbon::now()->subHours($this->expiryTime)
             ->gt(new Carbon($tokenEntry->created_at));
index ef61e03ceb24d27edb289166d1ec744a95034f67..131771a38b7dbee24453440d6b6fd31e72adf594 100644 (file)
@@ -1,15 +1,17 @@
-<?php namespace BookStack\Auth\Permissions;
+<?php
+
+namespace BookStack\Auth\Permissions;
 
 use BookStack\Model;
 
 class EntityPermission extends Model
 {
 
 use BookStack\Model;
 
 class EntityPermission extends Model
 {
-
     protected $fillable = ['role_id', 'action'];
     public $timestamps = false;
 
     /**
      * Get all this restriction's attached entity.
     protected $fillable = ['role_id', 'action'];
     public $timestamps = false;
 
     /**
      * Get all this restriction's attached entity.
+     *
      * @return \Illuminate\Database\Eloquent\Relations\MorphTo
      */
     public function restrictable()
      * @return \Illuminate\Database\Eloquent\Relations\MorphTo
      */
     public function restrictable()
index 6f7fa582b83a6610b57813bc009fd44582761ab3..e10c560d0fdcfee557690939ad23328093689dcc 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Auth\Permissions;
+<?php
+
+namespace BookStack\Auth\Permissions;
 
 use BookStack\Auth\Role;
 use BookStack\Entities\Models\Entity;
 
 use BookStack\Auth\Role;
 use BookStack\Entities\Models\Entity;
index 4565986535d6240a9a0c80211bc61f0929117aa6..f84f518944ab81f2d95e8fee776f7e00b8cde8ba 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Auth\Permissions;
+<?php
+
+namespace BookStack\Auth\Permissions;
 
 use BookStack\Auth\Role;
 use BookStack\Auth\User;
 
 use BookStack\Auth\Role;
 use BookStack\Auth\User;
@@ -48,7 +50,7 @@ class PermissionService
     }
 
     /**
     }
 
     /**
-     * Set the database connection
+     * Set the database connection.
      */
     public function setConnection(Connection $connection)
     {
      */
     public function setConnection(Connection $connection)
     {
@@ -56,7 +58,8 @@ class PermissionService
     }
 
     /**
     }
 
     /**
-     * Prepare the local entity cache and ensure it's empty
+     * Prepare the local entity cache and ensure it's empty.
+     *
      * @param Entity[] $entities
      */
     protected function readyEntityCache(array $entities = [])
      * @param Entity[] $entities
      */
     protected function readyEntityCache(array $entities = [])
@@ -73,7 +76,7 @@ class PermissionService
     }
 
     /**
     }
 
     /**
-     * Get a book via ID, Checks local cache
+     * Get a book via ID, Checks local cache.
      */
     protected function getBook(int $bookId): ?Book
     {
      */
     protected function getBook(int $bookId): ?Book
     {
@@ -85,7 +88,7 @@ class PermissionService
     }
 
     /**
     }
 
     /**
-     * Get a chapter via ID, Checks local cache
+     * Get a chapter via ID, Checks local cache.
      */
     protected function getChapter(int $chapterId): ?Chapter
     {
      */
     protected function getChapter(int $chapterId): ?Chapter
     {
@@ -151,12 +154,13 @@ class PermissionService
                 },
                 'pages' => function ($query) {
                     $query->withTrashed()->select(['id', 'restricted', 'owned_by', 'book_id', 'chapter_id']);
                 },
                 'pages' => function ($query) {
                     $query->withTrashed()->select(['id', 'restricted', 'owned_by', 'book_id', 'chapter_id']);
-                }
+                },
             ]);
     }
 
     /**
      * Build joint permissions for the given shelf and role combinations.
             ]);
     }
 
     /**
      * Build joint permissions for the given shelf and role combinations.
+     *
      * @throws Throwable
      */
     protected function buildJointPermissionsForShelves(EloquentCollection $shelves, array $roles, bool $deleteOld = false)
      * @throws Throwable
      */
     protected function buildJointPermissionsForShelves(EloquentCollection $shelves, array $roles, bool $deleteOld = false)
@@ -169,6 +173,7 @@ class PermissionService
 
     /**
      * Build joint permissions for the given book and role combinations.
 
     /**
      * Build joint permissions for the given book and role combinations.
+     *
      * @throws Throwable
      */
     protected function buildJointPermissionsForBooks(EloquentCollection $books, array $roles, bool $deleteOld = false)
      * @throws Throwable
      */
     protected function buildJointPermissionsForBooks(EloquentCollection $books, array $roles, bool $deleteOld = false)
@@ -193,6 +198,7 @@ class PermissionService
 
     /**
      * Rebuild the entity jointPermissions for a particular entity.
 
     /**
      * Rebuild the entity jointPermissions for a particular entity.
+     *
      * @throws Throwable
      */
     public function buildJointPermissionsForEntity(Entity $entity)
      * @throws Throwable
      */
     public function buildJointPermissionsForEntity(Entity $entity)
@@ -201,6 +207,7 @@ class PermissionService
         if ($entity instanceof Book) {
             $books = $this->bookFetchQuery()->where('id', '=', $entity->id)->get();
             $this->buildJointPermissionsForBooks($books, Role::query()->get()->all(), true);
         if ($entity instanceof Book) {
             $books = $this->bookFetchQuery()->where('id', '=', $entity->id)->get();
             $this->buildJointPermissionsForBooks($books, Role::query()->get()->all(), true);
+
             return;
         }
 
             return;
         }
 
@@ -224,6 +231,7 @@ class PermissionService
 
     /**
      * Rebuild the entity jointPermissions for a collection of entities.
 
     /**
      * Rebuild the entity jointPermissions for a collection of entities.
+     *
      * @throws Throwable
      */
     public function buildJointPermissionsForEntities(array $entities)
      * @throws Throwable
      */
     public function buildJointPermissionsForEntities(array $entities)
@@ -263,6 +271,7 @@ class PermissionService
 
     /**
      * Delete all of the entity jointPermissions for a list of entities.
 
     /**
      * Delete all of the entity jointPermissions for a list of entities.
+     *
      * @param Role[] $roles
      */
     protected function deleteManyJointPermissionsForRoles($roles)
      * @param Role[] $roles
      */
     protected function deleteManyJointPermissionsForRoles($roles)
@@ -275,7 +284,9 @@ class PermissionService
 
     /**
      * Delete the entity jointPermissions for a particular entity.
 
     /**
      * Delete the entity jointPermissions for a particular entity.
+     *
      * @param Entity $entity
      * @param Entity $entity
+     *
      * @throws Throwable
      */
     public function deleteJointPermissionsForEntity(Entity $entity)
      * @throws Throwable
      */
     public function deleteJointPermissionsForEntity(Entity $entity)
@@ -285,7 +296,9 @@ class PermissionService
 
     /**
      * Delete all of the entity jointPermissions for a list of entities.
 
     /**
      * Delete all of the entity jointPermissions for a list of entities.
+     *
      * @param Entity[] $entities
      * @param Entity[] $entities
+     *
      * @throws Throwable
      */
     protected function deleteManyJointPermissionsForEntities(array $entities)
      * @throws Throwable
      */
     protected function deleteManyJointPermissionsForEntities(array $entities)
@@ -295,7 +308,6 @@ class PermissionService
         }
 
         $this->db->transaction(function () use ($entities) {
         }
 
         $this->db->transaction(function () use ($entities) {
-
             foreach (array_chunk($entities, 1000) as $entityChunk) {
                 $query = $this->db->table('joint_permissions');
                 foreach ($entityChunk as $entity) {
             foreach (array_chunk($entities, 1000) as $entityChunk) {
                 $query = $this->db->table('joint_permissions');
                 foreach ($entityChunk as $entity) {
@@ -311,8 +323,10 @@ class PermissionService
 
     /**
      * Create & Save entity jointPermissions for many entities and roles.
 
     /**
      * Create & Save entity jointPermissions for many entities and roles.
+     *
      * @param Entity[] $entities
      * @param Entity[] $entities
-     * @param Role[] $roles
+     * @param Role[]   $roles
+     *
      * @throws Throwable
      */
     protected function createManyJointPermissions(array $entities, array $roles)
      * @throws Throwable
      */
     protected function createManyJointPermissions(array $entities, array $roles)
@@ -363,7 +377,6 @@ class PermissionService
         });
     }
 
         });
     }
 
-
     /**
      * Get the actions related to an entity.
      */
     /**
      * Get the actions related to an entity.
      */
@@ -376,6 +389,7 @@ class PermissionService
         if ($entity instanceof Book) {
             $baseActions[] = 'chapter-create';
         }
         if ($entity instanceof Book) {
             $baseActions[] = 'chapter-create';
         }
+
         return $baseActions;
     }
 
         return $baseActions;
     }
 
@@ -397,6 +411,7 @@ class PermissionService
 
         if ($entity->restricted) {
             $hasAccess = $this->mapHasActiveRestriction($permissionMap, $entity, $role, $restrictionAction);
 
         if ($entity->restricted) {
             $hasAccess = $this->mapHasActiveRestriction($permissionMap, $entity, $role, $restrictionAction);
+
             return $this->createJointPermissionDataArray($entity, $role, $action, $hasAccess, $hasAccess);
         }
 
             return $this->createJointPermissionDataArray($entity, $role, $action, $hasAccess, $hasAccess);
         }
 
@@ -433,6 +448,7 @@ class PermissionService
     protected function mapHasActiveRestriction(array $entityMap, Entity $entity, Role $role, string $action): bool
     {
         $key = $entity->getMorphClass() . ':' . $entity->getRawAttribute('id') . ':' . $role->getRawAttribute('id') . ':' . $action;
     protected function mapHasActiveRestriction(array $entityMap, Entity $entity, Role $role, string $action): bool
     {
         $key = $entity->getMorphClass() . ':' . $entity->getRawAttribute('id') . ':' . $role->getRawAttribute('id') . ':' . $action;
+
         return $entityMap[$key] ?? false;
     }
 
         return $entityMap[$key] ?? false;
     }
 
@@ -443,18 +459,19 @@ class PermissionService
     protected function createJointPermissionDataArray(Entity $entity, Role $role, string $action, bool $permissionAll, bool $permissionOwn): array
     {
         return [
     protected function createJointPermissionDataArray(Entity $entity, Role $role, string $action, bool $permissionAll, bool $permissionOwn): array
     {
         return [
-            'role_id' => $role->getRawAttribute('id'),
-            'entity_id' => $entity->getRawAttribute('id'),
-            'entity_type' => $entity->getMorphClass(),
-            'action' => $action,
-            'has_permission' => $permissionAll,
+            'role_id'            => $role->getRawAttribute('id'),
+            'entity_id'          => $entity->getRawAttribute('id'),
+            'entity_type'        => $entity->getMorphClass(),
+            'action'             => $action,
+            'has_permission'     => $permissionAll,
             'has_permission_own' => $permissionOwn,
             'has_permission_own' => $permissionOwn,
-            'owned_by' => $entity->getRawAttribute('owned_by'),
+            'owned_by'           => $entity->getRawAttribute('owned_by'),
         ];
     }
 
     /**
      * Checks if an entity has a restriction set upon it.
         ];
     }
 
     /**
      * Checks if an entity has a restriction set upon it.
+     *
      * @param HasCreatorAndUpdater|HasOwner $ownable
      */
     public function checkOwnableUserAccess(Model $ownable, string $permission): bool
      * @param HasCreatorAndUpdater|HasOwner $ownable
      */
     public function checkOwnableUserAccess(Model $ownable, string $permission): bool
@@ -473,7 +490,8 @@ class PermissionService
             $ownPermission = $user && $user->can($permission . '-own');
             $ownerField = ($ownable instanceof Entity) ? 'owned_by' : 'created_by';
             $isOwner = $user && $user->id === $ownable->$ownerField;
             $ownPermission = $user && $user->can($permission . '-own');
             $ownerField = ($ownable instanceof Entity) ? 'owned_by' : 'created_by';
             $isOwner = $user && $user->id === $ownable->$ownerField;
-            return ($allPermission || ($isOwner && $ownPermission));
+
+            return $allPermission || ($isOwner && $ownPermission);
         }
 
         // Handle abnormal create jointPermissions
         }
 
         // Handle abnormal create jointPermissions
@@ -483,6 +501,7 @@ class PermissionService
 
         $hasAccess = $this->entityRestrictionQuery($baseQuery, $action)->count() > 0;
         $this->clean();
 
         $hasAccess = $this->entityRestrictionQuery($baseQuery, $action)->count() > 0;
         $this->clean();
+
         return $hasAccess;
     }
 
         return $hasAccess;
     }
 
@@ -509,6 +528,7 @@ class PermissionService
 
         $hasPermission = $permissionQuery->count() > 0;
         $this->clean();
 
         $hasPermission = $permissionQuery->count() > 0;
         $this->clean();
+
         return $hasPermission;
     }
 
         return $hasPermission;
     }
 
@@ -529,6 +549,7 @@ class PermissionService
         });
 
         $this->clean();
         });
 
         $this->clean();
+
         return $q;
     }
 
         return $q;
     }
 
@@ -539,6 +560,7 @@ class PermissionService
     public function restrictEntityQuery(Builder $query, string $ability = 'view'): Builder
     {
         $this->clean();
     public function restrictEntityQuery(Builder $query, string $ability = 'view'): Builder
     {
         $this->clean();
+
         return $query->where(function (Builder $parentQuery) use ($ability) {
             $parentQuery->whereHas('jointPermissions', function (Builder $permissionQuery) use ($ability) {
                 $permissionQuery->whereIn('role_id', $this->getCurrentUserRoles())
         return $query->where(function (Builder $parentQuery) use ($ability) {
             $parentQuery->whereHas('jointPermissions', function (Builder $permissionQuery) use ($ability) {
                 $permissionQuery->whereIn('role_id', $this->getCurrentUserRoles())
@@ -580,6 +602,7 @@ class PermissionService
 
     /**
      * Filter items that have entities set as a polymorphic relation.
 
     /**
      * Filter items that have entities set as a polymorphic relation.
+     *
      * @param Builder|\Illuminate\Database\Query\Builder $query
      */
     public function filterRestrictedEntityRelations($query, string $tableName, string $entityIdColumn, string $entityTypeColumn, string $action = 'view')
      * @param Builder|\Illuminate\Database\Query\Builder $query
      */
     public function filterRestrictedEntityRelations($query, string $tableName, string $entityIdColumn, string $entityTypeColumn, string $action = 'view')
@@ -600,6 +623,7 @@ class PermissionService
         });
 
         $this->clean();
         });
 
         $this->clean();
+
         return $q;
     }
 
         return $q;
     }
 
@@ -628,12 +652,14 @@ class PermissionService
         });
 
         $this->clean();
         });
 
         $this->clean();
+
         return $q;
     }
 
     /**
      * Add the query for checking the given user id has permission
      * within the join_permissions table.
         return $q;
     }
 
     /**
      * Add the query for checking the given user id has permission
      * within the join_permissions table.
+     *
      * @param QueryBuilder|Builder $query
      */
     protected function addJointHasPermissionCheck($query, int $userIdToCheck)
      * @param QueryBuilder|Builder $query
      */
     protected function addJointHasPermissionCheck($query, int $userIdToCheck)
@@ -645,7 +671,7 @@ class PermissionService
     }
 
     /**
     }
 
     /**
-     * Get the current user
+     * Get the current user.
      */
     private function currentUser(): User
     {
      */
     private function currentUser(): User
     {
index f54612a4339a3423557a994a3fa876636215799b..4d191679da64b7125ed9c2a895275aef53144e40 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Auth\Permissions;
+<?php
+
+namespace BookStack\Auth\Permissions;
 
 use BookStack\Actions\ActivityType;
 use BookStack\Auth\Role;
 
 use BookStack\Actions\ActivityType;
 use BookStack\Auth\Role;
@@ -9,7 +11,6 @@ use Illuminate\Database\Eloquent\Collection;
 
 class PermissionsRepo
 {
 
 class PermissionsRepo
 {
-
     protected $permission;
     protected $role;
     protected $permissionService;
     protected $permission;
     protected $role;
     protected $permissionService;
@@ -62,6 +63,7 @@ class PermissionsRepo
         $this->assignRolePermissions($role, $permissions);
         $this->permissionService->buildJointPermissionForRole($role);
         Activity::add(ActivityType::ROLE_CREATE, $role);
         $this->assignRolePermissions($role, $permissions);
         $this->permissionService->buildJointPermissionForRole($role);
         Activity::add(ActivityType::ROLE_CREATE, $role);
+
         return $role;
     }
 
         return $role;
     }
 
@@ -116,6 +118,7 @@ class PermissionsRepo
      * Check it's not an admin role or set as default before deleting.
      * If an migration Role ID is specified the users assign to the current role
      * will be added to the role of the specified id.
      * Check it's not an admin role or set as default before deleting.
      * If an migration Role ID is specified the users assign to the current role
      * will be added to the role of the specified id.
+     *
      * @throws PermissionsException
      * @throws Exception
      */
      * @throws PermissionsException
      * @throws Exception
      */
@@ -127,7 +130,7 @@ class PermissionsRepo
         // Prevent deleting admin role or default registration role.
         if ($role->system_name && in_array($role->system_name, $this->systemRoles)) {
             throw new PermissionsException(trans('errors.role_system_cannot_be_deleted'));
         // Prevent deleting admin role or default registration role.
         if ($role->system_name && in_array($role->system_name, $this->systemRoles)) {
             throw new PermissionsException(trans('errors.role_system_cannot_be_deleted'));
-        } else if ($role->id === intval(setting('registration-role'))) {
+        } elseif ($role->id === intval(setting('registration-role'))) {
             throw new PermissionsException(trans('errors.role_registration_default_cannot_delete'));
         }
 
             throw new PermissionsException(trans('errors.role_registration_default_cannot_delete'));
         }
 
index 7f44ff8152b5a23b759b5fce3a83238da01855f9..0a0e6ff17f531a3d16b3fab542716a84487dbc94 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Auth\Permissions;
+<?php
+
+namespace BookStack\Auth\Permissions;
 
 use BookStack\Auth\Role;
 use BookStack\Model;
 
 use BookStack\Auth\Role;
 use BookStack\Model;
@@ -18,7 +20,9 @@ class RolePermission extends Model
 
     /**
      * Get the permission object by name.
 
     /**
      * Get the permission object by name.
+     *
      * @param $name
      * @param $name
+     *
      * @return mixed
      */
     public static function getByName($name)
      * @return mixed
      */
     public static function getByName($name)
index 59b1f547c13f527b7f9bd19d524525a9415e1972..94ba39d1d1f15fb7952f51fa18664a6440e3ae95 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Auth;
+<?php
+
+namespace BookStack\Auth;
 
 use BookStack\Auth\Permissions\JointPermission;
 use BookStack\Auth\Permissions\RolePermission;
 
 use BookStack\Auth\Permissions\JointPermission;
 use BookStack\Auth\Permissions\RolePermission;
@@ -9,8 +11,9 @@ use Illuminate\Database\Eloquent\Relations\BelongsToMany;
 use Illuminate\Database\Eloquent\Relations\HasMany;
 
 /**
 use Illuminate\Database\Eloquent\Relations\HasMany;
 
 /**
- * Class Role
- * @property int $id
+ * Class Role.
+ *
+ * @property int    $id
  * @property string $display_name
  * @property string $description
  * @property string $external_auth_id
  * @property string $display_name
  * @property string $description
  * @property string $external_auth_id
@@ -18,7 +21,6 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
  */
 class Role extends Model implements Loggable
 {
  */
 class Role extends Model implements Loggable
 {
-
     protected $fillable = ['display_name', 'description', 'external_auth_id'];
 
     /**
     protected $fillable = ['display_name', 'description', 'external_auth_id'];
 
     /**
@@ -56,6 +58,7 @@ class Role extends Model implements Loggable
                 return true;
             }
         }
                 return true;
             }
         }
+
         return false;
     }
 
         return false;
     }
 
index 116cdc8546957a4071ad54bbc52aba5b8b6ede6c..f076ecdd440577e1f2dae85c9b676d649021416e 100644 (file)
@@ -1,16 +1,18 @@
-<?php namespace BookStack\Auth;
+<?php
+
+namespace BookStack\Auth;
 
 use BookStack\Interfaces\Loggable;
 use BookStack\Model;
 
 /**
 
 use BookStack\Interfaces\Loggable;
 use BookStack\Model;
 
 /**
- * Class SocialAccount
+ * Class SocialAccount.
+ *
  * @property string $driver
  * @property string $driver
- * @property User $user
+ * @property User   $user
  */
 class SocialAccount extends Model implements Loggable
 {
  */
 class SocialAccount extends Model implements Loggable
 {
-
     protected $fillable = ['user_id', 'driver', 'driver_id', 'timestamps'];
 
     public function user()
     protected $fillable = ['user_id', 'driver', 'driver_id', 'timestamps'];
 
     public function user()
index 2f3c00a4b51346e1e333304318fed80fa2872032..1a3560691d4db8792c2fe18f52322c608f956dac 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Auth;
+<?php
+
+namespace BookStack\Auth;
 
 use BookStack\Actions\Favourite;
 use BookStack\Api\ApiToken;
 
 use BookStack\Actions\Favourite;
 use BookStack\Api\ApiToken;
@@ -22,32 +24,37 @@ use Illuminate\Notifications\Notifiable;
 use Illuminate\Support\Collection;
 
 /**
 use Illuminate\Support\Collection;
 
 /**
- * Class User
- * @property string $id
- * @property string $name
- * @property string $slug
- * @property string $email
- * @property string $password
- * @property Carbon $created_at
- * @property Carbon $updated_at
- * @property bool $email_confirmed
- * @property int $image_id
- * @property string $external_auth_id
- * @property string $system_name
+ * Class User.
+ *
+ * @property string     $id
+ * @property string     $name
+ * @property string     $slug
+ * @property string     $email
+ * @property string     $password
+ * @property Carbon     $created_at
+ * @property Carbon     $updated_at
+ * @property bool       $email_confirmed
+ * @property int        $image_id
+ * @property string     $external_auth_id
+ * @property string     $system_name
  * @property Collection $roles
  */
 class User extends Model implements AuthenticatableContract, CanResetPasswordContract, Loggable, Sluggable
 {
  * @property Collection $roles
  */
 class User extends Model implements AuthenticatableContract, CanResetPasswordContract, Loggable, Sluggable
 {
-    use Authenticatable, CanResetPassword, Notifiable;
+    use Authenticatable;
+    use CanResetPassword;
+    use Notifiable;
 
     /**
      * The database table used by the model.
 
     /**
      * The database table used by the model.
+     *
      * @var string
      */
     protected $table = 'users';
 
     /**
      * The attributes that are mass assignable.
      * @var string
      */
     protected $table = 'users';
 
     /**
      * The attributes that are mass assignable.
+     *
      * @var array
      */
     protected $fillable = ['name', 'email'];
      * @var array
      */
     protected $fillable = ['name', 'email'];
@@ -56,6 +63,7 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
 
     /**
      * The attributes excluded from the model's JSON form.
 
     /**
      * The attributes excluded from the model's JSON form.
+     *
      * @var array
      */
     protected $hidden = [
      * @var array
      */
     protected $hidden = [
@@ -65,12 +73,14 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
 
     /**
      * This holds the user's permissions when loaded.
 
     /**
      * This holds the user's permissions when loaded.
+     *
      * @var ?Collection
      */
     protected $permissions;
 
     /**
      * This holds the default user when loaded.
      * @var ?Collection
      */
     protected $permissions;
 
     /**
      * This holds the default user when loaded.
+     *
      * @var null|User
      */
     protected static $defaultUser = null;
      * @var null|User
      */
     protected static $defaultUser = null;
@@ -83,8 +93,9 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
         if (!is_null(static::$defaultUser)) {
             return static::$defaultUser;
         }
         if (!is_null(static::$defaultUser)) {
             return static::$defaultUser;
         }
-        
+
         static::$defaultUser = static::query()->where('system_name', '=', 'public')->first();
         static::$defaultUser = static::query()->where('system_name', '=', 'public')->first();
+
         return static::$defaultUser;
     }
 
         return static::$defaultUser;
     }
 
@@ -98,13 +109,15 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
 
     /**
      * The roles that belong to the user.
 
     /**
      * The roles that belong to the user.
+     *
      * @return BelongsToMany
      */
     public function roles()
     {
         if ($this->id === 0) {
      * @return BelongsToMany
      */
     public function roles()
     {
         if ($this->id === 0) {
-            return ;
+            return;
         }
         }
+
         return $this->belongsToMany(Role::class);
     }
 
         return $this->belongsToMany(Role::class);
     }
 
@@ -194,7 +207,9 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
     /**
      * Check if the user has a social account,
      * If a driver is passed it checks for that single account type.
     /**
      * Check if the user has a social account,
      * If a driver is passed it checks for that single account type.
+     *
      * @param bool|string $socialDriver
      * @param bool|string $socialDriver
+     *
      * @return bool
      */
     public function hasSocialAccount($socialDriver = false)
      * @return bool
      */
     public function hasSocialAccount($socialDriver = false)
@@ -207,7 +222,7 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
     }
 
     /**
     }
 
     /**
-     * Returns a URL to the user's avatar
+     * Returns a URL to the user's avatar.
      */
     public function getAvatar(int $size = 50): string
     {
      */
     public function getAvatar(int $size = 50): string
     {
@@ -222,6 +237,7 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
         } catch (Exception $err) {
             $avatar = $default;
         }
         } catch (Exception $err) {
             $avatar = $default;
         }
+
         return $avatar;
     }
 
         return $avatar;
     }
 
@@ -268,6 +284,7 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
     public function getEditUrl(string $path = ''): string
     {
         $uri = '/settings/users/' . $this->id . '/' . trim($path, '/');
     public function getEditUrl(string $path = ''): string
     {
         $uri = '/settings/users/' . $this->id . '/' . trim($path, '/');
+
         return url(rtrim($uri, '/'));
     }
 
         return url(rtrim($uri, '/'));
     }
 
@@ -298,7 +315,9 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
 
     /**
      * Send the password reset notification.
 
     /**
      * Send the password reset notification.
-     * @param  string  $token
+     *
+     * @param string $token
+     *
      * @return void
      */
     public function sendPasswordResetNotification($token)
      * @return void
      */
     public function sendPasswordResetNotification($token)
@@ -320,6 +339,7 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
     public function refreshSlug(): string
     {
         $this->slug = app(SlugGenerator::class)->generate($this);
     public function refreshSlug(): string
     {
         $this->slug = app(SlugGenerator::class)->generate($this);
+
         return $this->slug;
     }
 }
         return $this->slug;
     }
 }
index 15ce2cbc9bb28d2b9aaf52208cc4fc0d488a358d..61ca12dcc8f7d00e410170e0567e3b107ca0dc86 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Auth;
+<?php
+
+namespace BookStack\Auth;
 
 use Activity;
 use BookStack\Entities\EntityProvider;
 
 use Activity;
 use BookStack\Entities\EntityProvider;
@@ -82,7 +84,7 @@ class UserRepo
         return $query->paginate($count);
     }
 
         return $query->paginate($count);
     }
 
-     /**
+    /**
      * Creates a new user and attaches a role to them.
      */
     public function registerNew(array $data, bool $emailConfirmed = false): User
      * Creates a new user and attaches a role to them.
      */
     public function registerNew(array $data, bool $emailConfirmed = false): User
@@ -96,6 +98,7 @@ class UserRepo
 
     /**
      * Assign a user to a system-level role.
 
     /**
      * Assign a user to a system-level role.
+     *
      * @throws NotFoundException
      */
     public function attachSystemRole(User $user, string $systemRoleName)
      * @throws NotFoundException
      */
     public function attachSystemRole(User $user, string $systemRoleName)
@@ -126,6 +129,7 @@ class UserRepo
 
     /**
      * Set the assigned user roles via an array of role IDs.
 
     /**
      * Set the assigned user roles via an array of role IDs.
+     *
      * @throws UserUpdateException
      */
     public function setUserRoles(User $user, array $roles)
      * @throws UserUpdateException
      */
     public function setUserRoles(User $user, array $roles)
@@ -141,7 +145,7 @@ class UserRepo
      * Check if the given user is the last admin and their new roles no longer
      * contains the admin role.
      */
      * Check if the given user is the last admin and their new roles no longer
      * contains the admin role.
      */
-    protected function demotingLastAdmin(User $user, array $newRoles) : bool
+    protected function demotingLastAdmin(User $user, array $newRoles): bool
     {
         if ($this->isOnlyAdmin($user)) {
             $adminRole = Role::getSystemRole('admin');
     {
         if ($this->isOnlyAdmin($user)) {
             $adminRole = Role::getSystemRole('admin');
@@ -159,10 +163,10 @@ class UserRepo
     public function create(array $data, bool $emailConfirmed = false): User
     {
         $details = [
     public function create(array $data, bool $emailConfirmed = false): User
     {
         $details = [
-            'name'     => $data['name'],
-            'email'    => $data['email'],
-            'password' => bcrypt($data['password']),
-            'email_confirmed' => $emailConfirmed,
+            'name'             => $data['name'],
+            'email'            => $data['email'],
+            'password'         => bcrypt($data['password']),
+            'email_confirmed'  => $emailConfirmed,
             'external_auth_id' => $data['external_auth_id'] ?? '',
         ];
 
             'external_auth_id' => $data['external_auth_id'] ?? '',
         ];
 
@@ -176,6 +180,7 @@ class UserRepo
 
     /**
      * Remove the given user from storage, Delete all related content.
 
     /**
      * Remove the given user from storage, Delete all related content.
+     *
      * @throws Exception
      */
     public function destroy(User $user, ?int $newOwnerId = null)
      * @throws Exception
      */
     public function destroy(User $user, ?int $newOwnerId = null)
@@ -184,7 +189,7 @@ class UserRepo
         $user->apiTokens()->delete();
         $user->favourites()->delete();
         $user->delete();
         $user->apiTokens()->delete();
         $user->favourites()->delete();
         $user->delete();
-        
+
         // Delete user profile images
         $this->userAvatar->destroyAllForUser($user);
 
         // Delete user profile images
         $this->userAvatar->destroyAllForUser($user);
 
@@ -201,7 +206,7 @@ class UserRepo
      */
     protected function migrateOwnership(User $fromUser, User $toUser)
     {
      */
     protected function migrateOwnership(User $fromUser, User $toUser)
     {
-        $entities = (new EntityProvider)->all();
+        $entities = (new EntityProvider())->all();
         foreach ($entities as $instance) {
             $instance->newQuery()->where('owned_by', '=', $fromUser->id)
                 ->update(['owned_by' => $toUser->id]);
         foreach ($entities as $instance) {
             $instance->newQuery()->where('owned_by', '=', $fromUser->id)
                 ->update(['owned_by' => $toUser->id]);
@@ -242,11 +247,12 @@ class UserRepo
     public function getAssetCounts(User $user): array
     {
         $createdBy = ['created_by' => $user->id];
     public function getAssetCounts(User $user): array
     {
         $createdBy = ['created_by' => $user->id];
+
         return [
         return [
-            'pages'    =>  Page::visible()->where($createdBy)->count(),
-            'chapters'    =>  Chapter::visible()->where($createdBy)->count(),
-            'books'    =>  Book::visible()->where($createdBy)->count(),
-            'shelves'    =>  Bookshelf::visible()->where($createdBy)->count(),
+            'pages'       => Page::visible()->where($createdBy)->count(),
+            'chapters'    => Chapter::visible()->where($createdBy)->count(),
+            'books'       => Book::visible()->where($createdBy)->count(),
+            'shelves'     => Bookshelf::visible()->where($createdBy)->count(),
         ];
     }
 
         ];
     }
 
index 6afea2dc89d293b7fcf16d4129e3241301072c9a..03f191fee3b18228913cf9387a8d7f3096399a2e 100644 (file)
@@ -18,6 +18,6 @@ return [
     'max_item_count' => env('API_MAX_ITEM_COUNT', 500),
 
     // The number of API requests that can be made per minute by a single user.
     'max_item_count' => env('API_MAX_ITEM_COUNT', 500),
 
     // The number of API requests that can be made per minute by a single user.
-    'requests_per_minute' => env('API_REQUESTS_PER_MIN', 180)
+    'requests_per_minute' => env('API_REQUESTS_PER_MIN', 180),
 
 ];
 
 ];
index 550c98b0a6f00c98a87dd2f5deb5dba76733ddf0..9d8ba7eb2d0d71f9dbaee50be53a9c91783bf80e 100755 (executable)
@@ -56,7 +56,7 @@ return [
     'locale' => env('APP_LANG', 'en'),
 
     // Locales available
     'locale' => env('APP_LANG', 'en'),
 
     // Locales available
-    'locales' => ['en', 'ar', 'bg', 'bs', 'ca', 'cs', 'da', 'de', 'de_informal', 'es', 'es_AR', 'fa', 'fr', 'he', 'hr', 'hu', 'id', 'it', 'ja', 'ko', 'lv', 'nl', 'nb', 'pt', 'pt_BR', 'sk', 'sl', 'sv', 'pl',  'ru', 'th', 'tr', 'uk', 'vi', 'zh_CN', 'zh_TW',],
+    'locales' => ['en', 'ar', 'bg', 'bs', 'ca', 'cs', 'da', 'de', 'de_informal', 'es', 'es_AR', 'fa', 'fr', 'he', 'hr', 'hu', 'id', 'it', 'ja', 'ko', 'lv', 'nl', 'nb', 'pt', 'pt_BR', 'sk', 'sl', 'sv', 'pl',  'ru', 'th', 'tr', 'uk', 'vi', 'zh_CN', 'zh_TW'],
 
     //  Application Fallback Locale
     'fallback_locale' => 'en',
 
     //  Application Fallback Locale
     'fallback_locale' => 'en',
@@ -140,52 +140,52 @@ return [
     'aliases' => [
 
         // Laravel
     'aliases' => [
 
         // Laravel
-        'App'       => Illuminate\Support\Facades\App::class,
-        'Arr'       => Illuminate\Support\Arr::class,
-        'Artisan'   => Illuminate\Support\Facades\Artisan::class,
-        'Auth'      => Illuminate\Support\Facades\Auth::class,
-        'Blade'     => Illuminate\Support\Facades\Blade::class,
-        'Bus'       => Illuminate\Support\Facades\Bus::class,
-        'Cache'     => Illuminate\Support\Facades\Cache::class,
-        'Config'    => Illuminate\Support\Facades\Config::class,
-        'Cookie'    => Illuminate\Support\Facades\Cookie::class,
-        'Crypt'     => Illuminate\Support\Facades\Crypt::class,
-        'DB'        => Illuminate\Support\Facades\DB::class,
-        'Eloquent'  => Illuminate\Database\Eloquent\Model::class,
-        'Event'     => Illuminate\Support\Facades\Event::class,
-        'File'      => Illuminate\Support\Facades\File::class,
-        'Hash'      => Illuminate\Support\Facades\Hash::class,
-        'Input'     => Illuminate\Support\Facades\Input::class,
-        'Inspiring' => Illuminate\Foundation\Inspiring::class,
-        'Lang'      => Illuminate\Support\Facades\Lang::class,
-        'Log'       => Illuminate\Support\Facades\Log::class,
-        'Mail'      => Illuminate\Support\Facades\Mail::class,
+        'App'          => Illuminate\Support\Facades\App::class,
+        'Arr'          => Illuminate\Support\Arr::class,
+        'Artisan'      => Illuminate\Support\Facades\Artisan::class,
+        'Auth'         => Illuminate\Support\Facades\Auth::class,
+        'Blade'        => Illuminate\Support\Facades\Blade::class,
+        'Bus'          => Illuminate\Support\Facades\Bus::class,
+        'Cache'        => Illuminate\Support\Facades\Cache::class,
+        'Config'       => Illuminate\Support\Facades\Config::class,
+        'Cookie'       => Illuminate\Support\Facades\Cookie::class,
+        'Crypt'        => Illuminate\Support\Facades\Crypt::class,
+        'DB'           => Illuminate\Support\Facades\DB::class,
+        'Eloquent'     => Illuminate\Database\Eloquent\Model::class,
+        'Event'        => Illuminate\Support\Facades\Event::class,
+        'File'         => Illuminate\Support\Facades\File::class,
+        'Hash'         => Illuminate\Support\Facades\Hash::class,
+        'Input'        => Illuminate\Support\Facades\Input::class,
+        'Inspiring'    => Illuminate\Foundation\Inspiring::class,
+        'Lang'         => Illuminate\Support\Facades\Lang::class,
+        'Log'          => Illuminate\Support\Facades\Log::class,
+        'Mail'         => Illuminate\Support\Facades\Mail::class,
         'Notification' => Illuminate\Support\Facades\Notification::class,
         'Notification' => Illuminate\Support\Facades\Notification::class,
-        'Password'  => Illuminate\Support\Facades\Password::class,
-        'Queue'     => Illuminate\Support\Facades\Queue::class,
-        'Redirect'  => Illuminate\Support\Facades\Redirect::class,
-        'Redis'     => Illuminate\Support\Facades\Redis::class,
-        'Request'   => Illuminate\Support\Facades\Request::class,
-        'Response'  => Illuminate\Support\Facades\Response::class,
-        'Route'     => Illuminate\Support\Facades\Route::class,
-        'Schema'    => Illuminate\Support\Facades\Schema::class,
-        'Session'   => Illuminate\Support\Facades\Session::class,
-        'Storage'   => Illuminate\Support\Facades\Storage::class,
-        'Str'       => Illuminate\Support\Str::class,
-        'URL'       => Illuminate\Support\Facades\URL::class,
-        'Validator' => Illuminate\Support\Facades\Validator::class,
-        'View'      => Illuminate\Support\Facades\View::class,
-        'Socialite' => Laravel\Socialite\Facades\Socialite::class,
+        'Password'     => Illuminate\Support\Facades\Password::class,
+        'Queue'        => Illuminate\Support\Facades\Queue::class,
+        'Redirect'     => Illuminate\Support\Facades\Redirect::class,
+        'Redis'        => Illuminate\Support\Facades\Redis::class,
+        'Request'      => Illuminate\Support\Facades\Request::class,
+        'Response'     => Illuminate\Support\Facades\Response::class,
+        'Route'        => Illuminate\Support\Facades\Route::class,
+        'Schema'       => Illuminate\Support\Facades\Schema::class,
+        'Session'      => Illuminate\Support\Facades\Session::class,
+        'Storage'      => Illuminate\Support\Facades\Storage::class,
+        'Str'          => Illuminate\Support\Str::class,
+        'URL'          => Illuminate\Support\Facades\URL::class,
+        'Validator'    => Illuminate\Support\Facades\Validator::class,
+        'View'         => Illuminate\Support\Facades\View::class,
+        'Socialite'    => Laravel\Socialite\Facades\Socialite::class,
 
         // Third Party
         'ImageTool' => Intervention\Image\Facades\Image::class,
 
         // Third Party
         'ImageTool' => Intervention\Image\Facades\Image::class,
-        'DomPDF' => Barryvdh\DomPDF\Facade::class,
+        'DomPDF'    => Barryvdh\DomPDF\Facade::class,
         'SnappyPDF' => Barryvdh\Snappy\Facades\SnappyPdf::class,
 
         // Custom BookStack
         'SnappyPDF' => Barryvdh\Snappy\Facades\SnappyPdf::class,
 
         // Custom BookStack
-        'Activity' => BookStack\Facades\Activity::class,
+        'Activity'    => BookStack\Facades\Activity::class,
         'Permissions' => BookStack\Facades\Permissions::class,
         'Permissions' => BookStack\Facades\Permissions::class,
-        'Theme'    => BookStack\Facades\Theme::class,
+        'Theme'       => BookStack\Facades\Theme::class,
     ],
 
     // Proxy configuration
     ],
 
     // Proxy configuration
index 51b152ff184805e67e5addd1573a6e2258c51e9d..404b5352dcc2b45537d4407a634171cee7a6c69e 100644 (file)
@@ -18,7 +18,7 @@ return [
     // This option controls the default authentication "guard" and password
     // reset options for your application.
     'defaults' => [
     // This option controls the default authentication "guard" and password
     // reset options for your application.
     'defaults' => [
-        'guard' => env('AUTH_METHOD', 'standard'),
+        'guard'     => env('AUTH_METHOD', 'standard'),
         'passwords' => 'users',
     ],
 
         'passwords' => 'users',
     ],
 
@@ -29,15 +29,15 @@ return [
     // Supported drivers: "session", "api-token", "ldap-session"
     'guards' => [
         'standard' => [
     // Supported drivers: "session", "api-token", "ldap-session"
     'guards' => [
         'standard' => [
-            'driver' => 'session',
+            'driver'   => 'session',
             'provider' => 'users',
         ],
         'ldap' => [
             'provider' => 'users',
         ],
         'ldap' => [
-            'driver' => 'ldap-session',
+            'driver'   => 'ldap-session',
             'provider' => 'external',
         ],
         'saml2' => [
             'provider' => 'external',
         ],
         'saml2' => [
-            'driver' => 'saml2-session',
+            'driver'   => 'saml2-session',
             'provider' => 'external',
         ],
         'api' => [
             'provider' => 'external',
         ],
         'api' => [
@@ -52,11 +52,11 @@ return [
     'providers' => [
         'users' => [
             'driver' => 'eloquent',
     'providers' => [
         'users' => [
             'driver' => 'eloquent',
-            'model' => \BookStack\Auth\User::class,
+            'model'  => \BookStack\Auth\User::class,
         ],
         'external' => [
             'driver' => 'external-users',
         ],
         'external' => [
             'driver' => 'external-users',
-            'model' => \BookStack\Auth\User::class,
+            'model'  => \BookStack\Auth\User::class,
         ],
     ],
 
         ],
     ],
 
@@ -67,9 +67,9 @@ return [
     'passwords' => [
         'users' => [
             'provider' => 'users',
     'passwords' => [
         'users' => [
             'provider' => 'users',
-            'email' => 'emails.password',
-            'table' => 'password_resets',
-            'expire' => 60,
+            'email'    => 'emails.password',
+            'table'    => 'password_resets',
+            'expire'   => 60,
         ],
     ],
 
         ],
     ],
 
index 7aaaa5693fe1cf907e07da54880710f802c9694a..5e929d3730faa5fd4e53f95a056782937531c981 100644 (file)
@@ -23,18 +23,18 @@ return [
     'connections' => [
 
         'pusher' => [
     'connections' => [
 
         'pusher' => [
-            'driver' => 'pusher',
-            'key' => env('PUSHER_APP_KEY'),
-            'secret' => env('PUSHER_APP_SECRET'),
-            'app_id' => env('PUSHER_APP_ID'),
+            'driver'  => 'pusher',
+            'key'     => env('PUSHER_APP_KEY'),
+            'secret'  => env('PUSHER_APP_SECRET'),
+            'app_id'  => env('PUSHER_APP_ID'),
             'options' => [
                 'cluster' => env('PUSHER_APP_CLUSTER'),
             'options' => [
                 'cluster' => env('PUSHER_APP_CLUSTER'),
-                'useTLS' => true,
+                'useTLS'  => true,
             ],
         ],
 
         'redis' => [
             ],
         ],
 
         'redis' => [
-            'driver' => 'redis',
+            'driver'     => 'redis',
             'connection' => 'default',
         ],
 
             'connection' => 'default',
         ],
 
@@ -46,7 +46,6 @@ return [
             'driver' => 'null',
         ],
 
             'driver' => 'null',
         ],
 
-
     ],
 
 ];
     ],
 
 ];
index 33d3a1a0bb7b02e6471f1088492fa7b5078e0519..f9b7ed1d20ecb9ff295f6bc94ce7657583b778ee 100644 (file)
@@ -42,8 +42,8 @@ return [
         ],
 
         'database' => [
         ],
 
         'database' => [
-            'driver' => 'database',
-            'table'  => 'cache',
+            'driver'     => 'database',
+            'table'      => 'cache',
             'connection' => null,
         ],
 
             'connection' => null,
         ],
 
@@ -58,7 +58,7 @@ return [
         ],
 
         'redis' => [
         ],
 
         'redis' => [
-            'driver' => 'redis',
+            'driver'     => 'redis',
             'connection' => 'default',
         ],
 
             'connection' => 'default',
         ],
 
index 170666ddba86465e0b0a8a66b972116eab52b524..7fb51a13bf0664c3994447d2df4cf20591dccdc8 100644 (file)
@@ -59,38 +59,38 @@ return [
     'connections' => [
 
         'mysql' => [
     'connections' => [
 
         'mysql' => [
-            'driver'    => 'mysql',
-            'url' => env('DATABASE_URL'),
-            'host'      => $mysql_host,
-            'database'  => env('DB_DATABASE', 'forge'),
-            'username'  => env('DB_USERNAME', 'forge'),
-            'password'  => env('DB_PASSWORD', ''),
-            'unix_socket' => env('DB_SOCKET', ''),
-            'port'      => $mysql_port,
-            'charset'   => 'utf8mb4',
-            'collation' => 'utf8mb4_unicode_ci',
-            'prefix'    => '',
+            'driver'         => 'mysql',
+            'url'            => env('DATABASE_URL'),
+            'host'           => $mysql_host,
+            'database'       => env('DB_DATABASE', 'forge'),
+            'username'       => env('DB_USERNAME', 'forge'),
+            'password'       => env('DB_PASSWORD', ''),
+            'unix_socket'    => env('DB_SOCKET', ''),
+            'port'           => $mysql_port,
+            'charset'        => 'utf8mb4',
+            'collation'      => 'utf8mb4_unicode_ci',
+            'prefix'         => '',
             'prefix_indexes' => true,
             'prefix_indexes' => true,
-            'strict'    => false,
-            'engine' => null,
-            'options' => extension_loaded('pdo_mysql') ? array_filter([
+            'strict'         => false,
+            'engine'         => null,
+            'options'        => extension_loaded('pdo_mysql') ? array_filter([
                 PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
             ]) : [],
         ],
 
         'mysql_testing' => [
                 PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
             ]) : [],
         ],
 
         'mysql_testing' => [
-            'driver'    => 'mysql',
-            'url' => env('TEST_DATABASE_URL'),
-            'host'      => '127.0.0.1',
-            'database'  => 'bookstack-test',
-            'username'  => env('MYSQL_USER', 'bookstack-test'),
-            'password'  => env('MYSQL_PASSWORD', 'bookstack-test'),
-            'port'      => $mysql_port,
-            'charset'   => 'utf8mb4',
-            'collation' => 'utf8mb4_unicode_ci',
-            'prefix'    => '',
+            'driver'         => 'mysql',
+            'url'            => env('TEST_DATABASE_URL'),
+            'host'           => '127.0.0.1',
+            'database'       => 'bookstack-test',
+            'username'       => env('MYSQL_USER', 'bookstack-test'),
+            'password'       => env('MYSQL_PASSWORD', 'bookstack-test'),
+            'port'           => $mysql_port,
+            'charset'        => 'utf8mb4',
+            'collation'      => 'utf8mb4_unicode_ci',
+            'prefix'         => '',
             'prefix_indexes' => true,
             'prefix_indexes' => true,
-            'strict'    => false,
+            'strict'         => false,
         ],
 
     ],
         ],
 
     ],
index fe624eb7d460c2fa185344f7dd86f3d1906e1bcb..53b5a087249cc7a52d2174c397b32a3da65830ab 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 /**
 <?php
 
 /**
- * Debugbar Configuration Options
+ * Debugbar Configuration Options.
  *
  * Changes to these config files are not supported by BookStack and may break upon updates.
  * Configuration should be altered via the `.env` file or environment variables.
  *
  * Changes to these config files are not supported by BookStack and may break upon updates.
  * Configuration should be altered via the `.env` file or environment variables.
 
 return [
 
 
 return [
 
-     // Debugbar is enabled by default, when debug is set to true in app.php.
-     // You can override the value by setting enable to true or false instead of null.
-     //
-     // You can provide an array of URI's that must be ignored (eg. 'api/*')
+    // Debugbar is enabled by default, when debug is set to true in app.php.
+    // You can override the value by setting enable to true or false instead of null.
+    //
+    // You can provide an array of URI's that must be ignored (eg. 'api/*')
     'enabled' => env('DEBUGBAR_ENABLED', false),
     'enabled' => env('DEBUGBAR_ENABLED', false),
-    'except' => [
-        'telescope*'
+    'except'  => [
+        'telescope*',
     ],
 
     ],
 
-
-     // DebugBar stores data for session/ajax requests.
-     // You can disable this, so the debugbar stores data in headers/session,
-     // but this can cause problems with large data collectors.
-     // By default, file storage (in the storage folder) is used. Redis and PDO
-     // can also be used. For PDO, run the package migrations first.
+    // DebugBar stores data for session/ajax requests.
+    // You can disable this, so the debugbar stores data in headers/session,
+    // but this can cause problems with large data collectors.
+    // By default, file storage (in the storage folder) is used. Redis and PDO
+    // can also be used. For PDO, run the package migrations first.
     'storage' => [
         'enabled'    => true,
         'driver'     => 'file', // redis, file, pdo, custom
         'path'       => storage_path('debugbar'), // For file driver
         'connection' => null,   // Leave null for default connection (Redis/PDO)
     'storage' => [
         'enabled'    => true,
         'driver'     => 'file', // redis, file, pdo, custom
         'path'       => storage_path('debugbar'), // For file driver
         'connection' => null,   // Leave null for default connection (Redis/PDO)
-        'provider'   => '' // Instance of StorageInterface for custom driver
+        'provider'   => '', // Instance of StorageInterface for custom driver
     ],
 
     ],
 
-     // Vendor files are included by default, but can be set to false.
-     // This can also be set to 'js' or 'css', to only include javascript or css vendor files.
-     // Vendor files are for css: font-awesome (including fonts) and highlight.js (css files)
-     // and for js: jquery and and highlight.js
-     // So if you want syntax highlighting, set it to true.
-     // jQuery is set to not conflict with existing jQuery scripts.
+    // Vendor files are included by default, but can be set to false.
+    // This can also be set to 'js' or 'css', to only include javascript or css vendor files.
+    // Vendor files are for css: font-awesome (including fonts) and highlight.js (css files)
+    // and for js: jquery and and highlight.js
+    // So if you want syntax highlighting, set it to true.
+    // jQuery is set to not conflict with existing jQuery scripts.
     'include_vendors' => true,
 
     'include_vendors' => true,
 
-     // The Debugbar can capture Ajax requests and display them. If you don't want this (ie. because of errors),
-     // you can use this option to disable sending the data through the headers.
-     // Optionally, you can also send ServerTiming headers on ajax requests for the Chrome DevTools.
+    // The Debugbar can capture Ajax requests and display them. If you don't want this (ie. because of errors),
+    // you can use this option to disable sending the data through the headers.
+    // Optionally, you can also send ServerTiming headers on ajax requests for the Chrome DevTools.
 
 
-    'capture_ajax' => true,
+    'capture_ajax'    => true,
     'add_ajax_timing' => false,
 
     'add_ajax_timing' => false,
 
-     // When enabled, the Debugbar shows deprecated warnings for Symfony components
-     // in the Messages tab.
+    // When enabled, the Debugbar shows deprecated warnings for Symfony components
+    // in the Messages tab.
     'error_handler' => false,
 
     'error_handler' => false,
 
-     // The Debugbar can emulate the Clockwork headers, so you can use the Chrome
-     // Extension, without the server-side code. It uses Debugbar collectors instead.
+    // The Debugbar can emulate the Clockwork headers, so you can use the Chrome
+    // Extension, without the server-side code. It uses Debugbar collectors instead.
     'clockwork' => false,
 
     'clockwork' => false,
 
-     // Enable/disable DataCollectors
+    // Enable/disable DataCollectors
     'collectors' => [
         'phpinfo'         => true,  // Php version
         'messages'        => true,  // Messages
     'collectors' => [
         'phpinfo'         => true,  // Php version
         'messages'        => true,  // Messages
@@ -82,7 +81,7 @@ return [
         'models'          => true, // Display models
     ],
 
         'models'          => true, // Display models
     ],
 
-     // Configure some DataCollectors
+    // Configure some DataCollectors
     'options' => [
         'auth' => [
             'show_name' => true,   // Also show the users name/email in the debugbar
     'options' => [
         'auth' => [
             'show_name' => true,   // Also show the users name/email in the debugbar
@@ -91,43 +90,43 @@ return [
             'with_params'       => true,   // Render SQL with the parameters substituted
             'backtrace'         => true,   // Use a backtrace to find the origin of the query in your files.
             'timeline'          => false,  // Add the queries to the timeline
             'with_params'       => true,   // Render SQL with the parameters substituted
             'backtrace'         => true,   // Use a backtrace to find the origin of the query in your files.
             'timeline'          => false,  // Add the queries to the timeline
-            'explain' => [                 // Show EXPLAIN output on queries
+            'explain'           => [                 // Show EXPLAIN output on queries
                 'enabled' => false,
                 'enabled' => false,
-                'types' => ['SELECT'],     // ['SELECT', 'INSERT', 'UPDATE', 'DELETE']; for MySQL 5.6.3+
+                'types'   => ['SELECT'],     // ['SELECT', 'INSERT', 'UPDATE', 'DELETE']; for MySQL 5.6.3+
             ],
             'hints'             => true,    // Show hints for common mistakes
         ],
         'mail' => [
             ],
             'hints'             => true,    // Show hints for common mistakes
         ],
         'mail' => [
-            'full_log' => false
+            'full_log' => false,
         ],
         'views' => [
             'data' => false,    //Note: Can slow down the application, because the data can be quite large..
         ],
         'route' => [
         ],
         'views' => [
             'data' => false,    //Note: Can slow down the application, because the data can be quite large..
         ],
         'route' => [
-            'label' => true  // show complete route on bar
+            'label' => true,  // show complete route on bar
         ],
         'logs' => [
         ],
         'logs' => [
-            'file' => null
+            'file' => null,
         ],
         'cache' => [
         ],
         'cache' => [
-            'values' => true // collect cache values
+            'values' => true, // collect cache values
         ],
     ],
 
         ],
     ],
 
-     // Inject Debugbar into the response
-     // Usually, the debugbar is added just before </body>, by listening to the
-     // Response after the App is done. If you disable this, you have to add them
-     // in your template yourself. See http://phpdebugbar.com/docs/rendering.html
+    // Inject Debugbar into the response
+    // Usually, the debugbar is added just before </body>, by listening to the
+    // Response after the App is done. If you disable this, you have to add them
+    // in your template yourself. See http://phpdebugbar.com/docs/rendering.html
     'inject' => true,
 
     'inject' => true,
 
-     // DebugBar route prefix
-     // Sometimes you want to set route prefix to be used by DebugBar to load
-     // its resources from. Usually the need comes from misconfigured web server or
-     // from trying to overcome bugs like this: http://trac.nginx.org/nginx/ticket/97
+    // DebugBar route prefix
+    // Sometimes you want to set route prefix to be used by DebugBar to load
+    // its resources from. Usually the need comes from misconfigured web server or
+    // from trying to overcome bugs like this: http://trac.nginx.org/nginx/ticket/97
     'route_prefix' => '_debugbar',
 
     'route_prefix' => '_debugbar',
 
-     // DebugBar route domain
-     // By default DebugBar route served from the same domain that request served.
-     // To override default domain, specify it as a non-empty value.
+    // DebugBar route domain
+    // By default DebugBar route served from the same domain that request served.
+    // To override default domain, specify it as a non-empty value.
     'route_domain' => env('APP_URL', '') === 'http://bookstack.dev' ? '' : env('APP_URL', ''),
 ];
     'route_domain' => env('APP_URL', '') === 'http://bookstack.dev' ? '' : env('APP_URL', ''),
 ];
index 094739cd9e22314cf67664814b5605692677d62e..71ea716f38729b6073ae96c48eb07c1bafd2a755 100644 (file)
 
 return [
 
 
 return [
 
-
     'show_warnings' => false,   // Throw an Exception on warnings from dompdf
     'show_warnings' => false,   // Throw an Exception on warnings from dompdf
-    'orientation' => 'portrait',
-    'defines' => [
+    'orientation'   => 'portrait',
+    'defines'       => [
         /**
         /**
-         * The location of the DOMPDF font directory
+         * The location of the DOMPDF font directory.
          *
          * The location of the directory where DOMPDF will store fonts and font metrics
          * Note: This directory must exist and be writable by the webserver process.
          *
          * The location of the directory where DOMPDF will store fonts and font metrics
          * Note: This directory must exist and be writable by the webserver process.
@@ -38,17 +37,17 @@ return [
          * Times-Roman, Times-Bold, Times-BoldItalic, Times-Italic,
          * Symbol, ZapfDingbats.
          */
          * Times-Roman, Times-Bold, Times-BoldItalic, Times-Italic,
          * Symbol, ZapfDingbats.
          */
-        "DOMPDF_FONT_DIR" => storage_path('fonts/'),  // advised by dompdf (https://github.com/dompdf/dompdf/pull/782)
+        'DOMPDF_FONT_DIR' => storage_path('fonts/'),  // advised by dompdf (https://github.com/dompdf/dompdf/pull/782)
 
         /**
 
         /**
-         * The location of the DOMPDF font cache directory
+         * The location of the DOMPDF font cache directory.
          *
          * This directory contains the cached font metrics for the fonts used by DOMPDF.
          * This directory can be the same as DOMPDF_FONT_DIR
          *
          * Note: This directory must exist and be writable by the webserver process.
          */
          *
          * This directory contains the cached font metrics for the fonts used by DOMPDF.
          * This directory can be the same as DOMPDF_FONT_DIR
          *
          * Note: This directory must exist and be writable by the webserver process.
          */
-        "DOMPDF_FONT_CACHE" => storage_path('fonts/'),
+        'DOMPDF_FONT_CACHE' => storage_path('fonts/'),
 
         /**
          * The location of a temporary directory.
 
         /**
          * The location of a temporary directory.
@@ -57,10 +56,10 @@ return [
          * The temporary directory is required to download remote images and when
          * using the PFDLib back end.
          */
          * The temporary directory is required to download remote images and when
          * using the PFDLib back end.
          */
-        "DOMPDF_TEMP_DIR" => sys_get_temp_dir(),
+        'DOMPDF_TEMP_DIR' => sys_get_temp_dir(),
 
         /**
 
         /**
-         * ==== IMPORTANT ====
+         * ==== IMPORTANT ====.
          *
          * dompdf's "chroot": Prevents dompdf from accessing system files or other
          * files on the webserver.  All local files opened by dompdf must be in a
          *
          * dompdf's "chroot": Prevents dompdf from accessing system files or other
          * files on the webserver.  All local files opened by dompdf must be in a
@@ -71,7 +70,7 @@ return [
          * direct class use like:
          * $dompdf = new DOMPDF();  $dompdf->load_html($htmldata); $dompdf->render(); $pdfdata = $dompdf->output();
          */
          * direct class use like:
          * $dompdf = new DOMPDF();  $dompdf->load_html($htmldata); $dompdf->render(); $pdfdata = $dompdf->output();
          */
-        "DOMPDF_CHROOT" => realpath(base_path()),
+        'DOMPDF_CHROOT' => realpath(base_path()),
 
         /**
          * Whether to use Unicode fonts or not.
 
         /**
          * Whether to use Unicode fonts or not.
@@ -82,20 +81,19 @@ return [
          * When enabled, dompdf can support all Unicode glyphs. Any glyphs used in a
          * document must be present in your fonts, however.
          */
          * When enabled, dompdf can support all Unicode glyphs. Any glyphs used in a
          * document must be present in your fonts, however.
          */
-        "DOMPDF_UNICODE_ENABLED" => true,
+        'DOMPDF_UNICODE_ENABLED' => true,
 
         /**
          * Whether to enable font subsetting or not.
          */
 
         /**
          * Whether to enable font subsetting or not.
          */
-        "DOMPDF_ENABLE_FONTSUBSETTING" => false,
+        'DOMPDF_ENABLE_FONTSUBSETTING' => false,
 
         /**
 
         /**
-         * The PDF rendering backend to use
+         * The PDF rendering backend to use.
          *
          * Valid settings are 'PDFLib', 'CPDF' (the bundled R&OS PDF class), 'GD' and
          * 'auto'. 'auto' will look for PDFLib and use it if found, or if not it will
          *
          * Valid settings are 'PDFLib', 'CPDF' (the bundled R&OS PDF class), 'GD' and
          * 'auto'. 'auto' will look for PDFLib and use it if found, or if not it will
-         * fall back on CPDF. 'GD' renders PDFs to graphic files. {@link
-         * Canvas_Factory} ultimately determines which rendering class to instantiate
+         * fall back on CPDF. 'GD' renders PDFs to graphic files. {@link * Canvas_Factory} ultimately determines which rendering class to instantiate
          * based on this setting.
          *
          * Both PDFLib & CPDF rendering backends provide sufficient rendering
          * based on this setting.
          *
          * Both PDFLib & CPDF rendering backends provide sufficient rendering
@@ -117,10 +115,10 @@ return [
          * @link http://www.ros.co.nz/pdf
          * @link http://www.php.net/image
          */
          * @link http://www.ros.co.nz/pdf
          * @link http://www.php.net/image
          */
-        "DOMPDF_PDF_BACKEND" => "CPDF",
+        'DOMPDF_PDF_BACKEND' => 'CPDF',
 
         /**
 
         /**
-         * PDFlib license key
+         * PDFlib license key.
          *
          * If you are using a licensed, commercial version of PDFlib, specify
          * your license key here.  If you are using PDFlib-Lite or are evaluating
          *
          * If you are using a licensed, commercial version of PDFlib, specify
          * your license key here.  If you are using PDFlib-Lite or are evaluating
@@ -143,7 +141,7 @@ return [
          * the desired content might be different (e.g. screen or projection view of html file).
          * Therefore allow specification of content here.
          */
          * the desired content might be different (e.g. screen or projection view of html file).
          * Therefore allow specification of content here.
          */
-        "DOMPDF_DEFAULT_MEDIA_TYPE" => "print",
+        'DOMPDF_DEFAULT_MEDIA_TYPE' => 'print',
 
         /**
          * The default paper size.
 
         /**
          * The default paper size.
@@ -152,18 +150,19 @@ return [
          *
          * @see CPDF_Adapter::PAPER_SIZES for valid sizes ('letter', 'legal', 'A4', etc.)
          */
          *
          * @see CPDF_Adapter::PAPER_SIZES for valid sizes ('letter', 'legal', 'A4', etc.)
          */
-        "DOMPDF_DEFAULT_PAPER_SIZE" => "a4",
+        'DOMPDF_DEFAULT_PAPER_SIZE' => 'a4',
 
         /**
 
         /**
-         * The default font family
+         * The default font family.
          *
          * Used if no suitable fonts can be found. This must exist in the font folder.
          *
          * Used if no suitable fonts can be found. This must exist in the font folder.
+         *
          * @var string
          */
          * @var string
          */
-        "DOMPDF_DEFAULT_FONT" => "dejavu sans",
+        'DOMPDF_DEFAULT_FONT' => 'dejavu sans',
 
         /**
 
         /**
-         * Image DPI setting
+         * Image DPI setting.
          *
          * This setting determines the default DPI setting for images and fonts.  The
          * DPI may be overridden for inline images by explictly setting the
          *
          * This setting determines the default DPI setting for images and fonts.  The
          * DPI may be overridden for inline images by explictly setting the
@@ -195,10 +194,10 @@ return [
          *
          * @var int
          */
          *
          * @var int
          */
-        "DOMPDF_DPI" => 96,
+        'DOMPDF_DPI' => 96,
 
         /**
 
         /**
-         * Enable inline PHP
+         * Enable inline PHP.
          *
          * If this setting is set to true then DOMPDF will automatically evaluate
          * inline PHP contained within <script type="text/php"> ... </script> tags.
          *
          * If this setting is set to true then DOMPDF will automatically evaluate
          * inline PHP contained within <script type="text/php"> ... </script> tags.
@@ -209,20 +208,20 @@ return [
          *
          * @var bool
          */
          *
          * @var bool
          */
-        "DOMPDF_ENABLE_PHP" => false,
+        'DOMPDF_ENABLE_PHP' => false,
 
         /**
 
         /**
-         * Enable inline Javascript
+         * Enable inline Javascript.
          *
          * If this setting is set to true then DOMPDF will automatically insert
          * JavaScript code contained within <script type="text/javascript"> ... </script> tags.
          *
          * @var bool
          */
          *
          * If this setting is set to true then DOMPDF will automatically insert
          * JavaScript code contained within <script type="text/javascript"> ... </script> tags.
          *
          * @var bool
          */
-        "DOMPDF_ENABLE_JAVASCRIPT" => false,
+        'DOMPDF_ENABLE_JAVASCRIPT' => false,
 
         /**
 
         /**
-         * Enable remote file access
+         * Enable remote file access.
          *
          * If this setting is set to true, DOMPDF will access remote sites for
          * images and CSS files as required.
          *
          * If this setting is set to true, DOMPDF will access remote sites for
          * images and CSS files as required.
@@ -238,29 +237,27 @@ return [
          *
          * @var bool
          */
          *
          * @var bool
          */
-        "DOMPDF_ENABLE_REMOTE" => true,
+        'DOMPDF_ENABLE_REMOTE' => true,
 
         /**
 
         /**
-         * A ratio applied to the fonts height to be more like browsers' line height
+         * A ratio applied to the fonts height to be more like browsers' line height.
          */
          */
-        "DOMPDF_FONT_HEIGHT_RATIO" => 1.1,
+        'DOMPDF_FONT_HEIGHT_RATIO' => 1.1,
 
         /**
 
         /**
-         * Enable CSS float
+         * Enable CSS float.
          *
          * Allows people to disabled CSS float support
          *
          * Allows people to disabled CSS float support
+         *
          * @var bool
          */
          * @var bool
          */
-        "DOMPDF_ENABLE_CSS_FLOAT" => true,
-
+        'DOMPDF_ENABLE_CSS_FLOAT' => true,
 
         /**
 
         /**
-         * Use the more-than-experimental HTML5 Lib parser
+         * Use the more-than-experimental HTML5 Lib parser.
          */
          */
-        "DOMPDF_ENABLE_HTML5PARSER" => true,
-
+        'DOMPDF_ENABLE_HTML5PARSER' => true,
 
     ],
 
 
     ],
 
-
 ];
 ];
index 30a5c53691d3a514d852d9d7fbe8f697d7d9321d..95fc35c2a8c0b702ee2cc8743a39425f9416b369 100644 (file)
@@ -34,7 +34,7 @@ return [
 
         'local' => [
             'driver' => 'local',
 
         'local' => [
             'driver' => 'local',
-            'root' => public_path(),
+            'root'   => public_path(),
         ],
 
         'local_secure' => [
         ],
 
         'local_secure' => [
@@ -43,12 +43,12 @@ return [
         ],
 
         's3' => [
         ],
 
         's3' => [
-            'driver' => 's3',
-            'key'    => env('STORAGE_S3_KEY', 'your-key'),
-            'secret' => env('STORAGE_S3_SECRET', 'your-secret'),
-            'region' => env('STORAGE_S3_REGION', 'your-region'),
-            'bucket' => env('STORAGE_S3_BUCKET', 'your-bucket'),
-            'endpoint' => env('STORAGE_S3_ENDPOINT', null),
+            'driver'                  => 's3',
+            'key'                     => env('STORAGE_S3_KEY', 'your-key'),
+            'secret'                  => env('STORAGE_S3_SECRET', 'your-secret'),
+            'region'                  => env('STORAGE_S3_REGION', 'your-region'),
+            'bucket'                  => env('STORAGE_S3_BUCKET', 'your-bucket'),
+            'endpoint'                => env('STORAGE_S3_ENDPOINT', null),
             'use_path_style_endpoint' => env('STORAGE_S3_ENDPOINT', null) !== null,
         ],
 
             'use_path_style_endpoint' => env('STORAGE_S3_ENDPOINT', null) !== null,
         ],
 
index 756718ce2bd7239fdd63720661a679db103e6501..585ee094ccb2858c90c41de587757cb87bfca9b0 100644 (file)
@@ -29,9 +29,9 @@ return [
     // passwords are hashed using the Argon algorithm. These will allow you
     // to control the amount of time it takes to hash the given password.
     'argon' => [
     // passwords are hashed using the Argon algorithm. These will allow you
     // to control the amount of time it takes to hash the given password.
     'argon' => [
-        'memory' => 1024,
+        'memory'  => 1024,
         'threads' => 2,
         'threads' => 2,
-        'time' => 2,
+        'time'    => 2,
     ],
 
 ];
     ],
 
 ];
index afd56e48256e492a069e1ea996942c6d73940e2e..220aa0607044482d1b213d6c4f3ec34a911596fe 100644 (file)
@@ -30,66 +30,66 @@ return [
     //                    "custom", "stack"
     'channels' => [
         'stack' => [
     //                    "custom", "stack"
     'channels' => [
         'stack' => [
-            'driver' => 'stack',
-            'channels' => ['daily'],
+            'driver'            => 'stack',
+            'channels'          => ['daily'],
             'ignore_exceptions' => false,
         ],
 
         'single' => [
             'driver' => 'single',
             'ignore_exceptions' => false,
         ],
 
         'single' => [
             'driver' => 'single',
-            'path' => storage_path('logs/laravel.log'),
-            'level' => 'debug',
-            'days' => 14,
+            'path'   => storage_path('logs/laravel.log'),
+            'level'  => 'debug',
+            'days'   => 14,
         ],
 
         'daily' => [
             'driver' => 'daily',
         ],
 
         'daily' => [
             'driver' => 'daily',
-            'path' => storage_path('logs/laravel.log'),
-            'level' => 'debug',
-            'days' => 7,
+            'path'   => storage_path('logs/laravel.log'),
+            'level'  => 'debug',
+            'days'   => 7,
         ],
 
         'slack' => [
         ],
 
         'slack' => [
-            'driver' => 'slack',
-            'url' => env('LOG_SLACK_WEBHOOK_URL'),
+            'driver'   => 'slack',
+            'url'      => env('LOG_SLACK_WEBHOOK_URL'),
             'username' => 'Laravel Log',
             'username' => 'Laravel Log',
-            'emoji' => ':boom:',
-            'level' => 'critical',
+            'emoji'    => ':boom:',
+            'level'    => 'critical',
         ],
 
         'stderr' => [
         ],
 
         'stderr' => [
-            'driver' => 'monolog',
+            'driver'  => 'monolog',
             'handler' => StreamHandler::class,
             'handler' => StreamHandler::class,
-            'with' => [
+            'with'    => [
                 'stream' => 'php://stderr',
             ],
         ],
 
         'syslog' => [
             'driver' => 'syslog',
                 'stream' => 'php://stderr',
             ],
         ],
 
         'syslog' => [
             'driver' => 'syslog',
-            'level' => 'debug',
+            'level'  => 'debug',
         ],
 
         'errorlog' => [
             'driver' => 'errorlog',
         ],
 
         'errorlog' => [
             'driver' => 'errorlog',
-            'level' => 'debug',
+            'level'  => 'debug',
         ],
 
         // Custom errorlog implementation that logs out a plain,
         // non-formatted message intended for the webserver log.
         'errorlog_plain_webserver' => [
         ],
 
         // Custom errorlog implementation that logs out a plain,
         // non-formatted message intended for the webserver log.
         'errorlog_plain_webserver' => [
-            'driver' => 'monolog',
-            'level' => 'debug',
-            'handler' => ErrorLogHandler::class,
-            'handler_with' => [4],
-            'formatter' => LineFormatter::class,
+            'driver'         => 'monolog',
+            'level'          => 'debug',
+            'handler'        => ErrorLogHandler::class,
+            'handler_with'   => [4],
+            'formatter'      => LineFormatter::class,
             'formatter_with' => [
             'formatter_with' => [
-                'format' => "%message%",
+                'format' => '%message%',
             ],
         ],
 
         'null' => [
             ],
         ],
 
         'null' => [
-            'driver' => 'monolog',
+            'driver'  => 'monolog',
             'handler' => NullHandler::class,
         ],
 
             'handler' => NullHandler::class,
         ],
 
@@ -101,7 +101,6 @@ return [
         ],
     ],
 
         ],
     ],
 
-
     // Failed Login Message
     // Allows a configurable message to be logged when a login request fails.
     'failed_login' => [
     // Failed Login Message
     // Allows a configurable message to be logged when a login request fails.
     'failed_login' => [
index abdbd382c862a36ec0c769729d0de87dbad9660d..34b28fe2a6b87b20059b7fc0aecfe1fff3f1a1e0 100644 (file)
@@ -23,7 +23,7 @@ return [
     // Global "From" address & name
     'from' => [
         'address' => env('MAIL_FROM', '[email protected]'),
     // Global "From" address & name
     'from' => [
         'address' => env('MAIL_FROM', '[email protected]'),
-        'name' => env('MAIL_FROM_NAME', 'BookStack')
+        'name'    => env('MAIL_FROM_NAME', 'BookStack'),
     ],
 
     // Email encryption protocol
     ],
 
     // Email encryption protocol
index 46f6962c5f327f4fd644f029d3159eece4f6701a..0c79fcdd20ce3a51e876cf0cc30f46a2f4b76482 100644 (file)
@@ -17,24 +17,23 @@ return [
     // Queue connection configuration
     'connections' => [
 
     // Queue connection configuration
     'connections' => [
 
-
         'sync' => [
             'driver' => 'sync',
         ],
 
         'database' => [
         'sync' => [
             'driver' => 'sync',
         ],
 
         'database' => [
-            'driver' => 'database',
-            'table' => 'jobs',
-            'queue' => 'default',
+            'driver'      => 'database',
+            'table'       => 'jobs',
+            'queue'       => 'default',
             'retry_after' => 90,
         ],
 
         'redis' => [
             'retry_after' => 90,
         ],
 
         'redis' => [
-            'driver' => 'redis',
-            'connection' => 'default',
-            'queue' => env('REDIS_QUEUE', 'default'),
+            'driver'      => 'redis',
+            'connection'  => 'default',
+            'queue'       => env('REDIS_QUEUE', 'default'),
             'retry_after' => 90,
             'retry_after' => 90,
-            'block_for' => null,
+            'block_for'   => null,
         ],
 
     ],
         ],
 
     ],
index 8ba96954905f029c5883c3b4bd5616945d9cfe5a..fe311057c1b1a3a14507334f2f422747de9e573c 100644 (file)
@@ -31,7 +31,6 @@ return [
     // Overrides, in JSON format, to the configuration passed to underlying onelogin library.
     'onelogin_overrides' => env('SAML2_ONELOGIN_OVERRIDES', null),
 
     // Overrides, in JSON format, to the configuration passed to underlying onelogin library.
     'onelogin_overrides' => env('SAML2_ONELOGIN_OVERRIDES', null),
 
-
     'onelogin' => [
         // If 'strict' is True, then the PHP Toolkit will reject unsigned
         // or unencrypted messages if it expects them signed or encrypted
     'onelogin' => [
         // If 'strict' is True, then the PHP Toolkit will reject unsigned
         // or unencrypted messages if it expects them signed or encrypted
@@ -81,7 +80,7 @@ return [
             'NameIDFormat' => 'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress',
             // Usually x509cert and privateKey of the SP are provided by files placed at
             // the certs folder. But we can also provide them with the following parameters
             'NameIDFormat' => 'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress',
             // Usually x509cert and privateKey of the SP are provided by files placed at
             // the certs folder. But we can also provide them with the following parameters
-            'x509cert' => '',
+            'x509cert'   => '',
             'privateKey' => '',
         ],
         // Identity Provider Data that we want connect with our SP
             'privateKey' => '',
         ],
         // Identity Provider Data that we want connect with our SP
index 0f9f78d1e53eda3e4625fafdd8e3c964ef1a728e..2d7253fb81e71edc3c593102003a08ceb98b7bc1 100644 (file)
@@ -28,16 +28,16 @@ return [
         'redirect'      => env('APP_URL') . '/login/service/github/callback',
         'name'          => 'GitHub',
         'auto_register' => env('GITHUB_AUTO_REGISTER', false),
         'redirect'      => env('APP_URL') . '/login/service/github/callback',
         'name'          => 'GitHub',
         'auto_register' => env('GITHUB_AUTO_REGISTER', false),
-        'auto_confirm' => env('GITHUB_AUTO_CONFIRM_EMAIL', false),
+        'auto_confirm'  => env('GITHUB_AUTO_CONFIRM_EMAIL', false),
     ],
 
     'google'   => [
     ],
 
     'google'   => [
-        'client_id'     => env('GOOGLE_APP_ID', false),
-        'client_secret' => env('GOOGLE_APP_SECRET', false),
-        'redirect'      => env('APP_URL') . '/login/service/google/callback',
-        'name'          => 'Google',
-        'auto_register' => env('GOOGLE_AUTO_REGISTER', false),
-        'auto_confirm' => env('GOOGLE_AUTO_CONFIRM_EMAIL', false),
+        'client_id'      => env('GOOGLE_APP_ID', false),
+        'client_secret'  => env('GOOGLE_APP_SECRET', false),
+        'redirect'       => env('APP_URL') . '/login/service/google/callback',
+        'name'           => 'Google',
+        'auto_register'  => env('GOOGLE_AUTO_REGISTER', false),
+        'auto_confirm'   => env('GOOGLE_AUTO_CONFIRM_EMAIL', false),
         'select_account' => env('GOOGLE_SELECT_ACCOUNT', false),
     ],
 
         'select_account' => env('GOOGLE_SELECT_ACCOUNT', false),
     ],
 
@@ -47,7 +47,7 @@ return [
         'redirect'      => env('APP_URL') . '/login/service/slack/callback',
         'name'          => 'Slack',
         'auto_register' => env('SLACK_AUTO_REGISTER', false),
         'redirect'      => env('APP_URL') . '/login/service/slack/callback',
         'name'          => 'Slack',
         'auto_register' => env('SLACK_AUTO_REGISTER', false),
-        'auto_confirm' => env('SLACK_AUTO_CONFIRM_EMAIL', false),
+        'auto_confirm'  => env('SLACK_AUTO_CONFIRM_EMAIL', false),
     ],
 
     'facebook'   => [
     ],
 
     'facebook'   => [
@@ -56,7 +56,7 @@ return [
         'redirect'      => env('APP_URL') . '/login/service/facebook/callback',
         'name'          => 'Facebook',
         'auto_register' => env('FACEBOOK_AUTO_REGISTER', false),
         'redirect'      => env('APP_URL') . '/login/service/facebook/callback',
         'name'          => 'Facebook',
         'auto_register' => env('FACEBOOK_AUTO_REGISTER', false),
-        'auto_confirm' => env('FACEBOOK_AUTO_CONFIRM_EMAIL', false),
+        'auto_confirm'  => env('FACEBOOK_AUTO_CONFIRM_EMAIL', false),
     ],
 
     'twitter'   => [
     ],
 
     'twitter'   => [
@@ -65,27 +65,27 @@ return [
         'redirect'      => env('APP_URL') . '/login/service/twitter/callback',
         'name'          => 'Twitter',
         'auto_register' => env('TWITTER_AUTO_REGISTER', false),
         'redirect'      => env('APP_URL') . '/login/service/twitter/callback',
         'name'          => 'Twitter',
         'auto_register' => env('TWITTER_AUTO_REGISTER', false),
-        'auto_confirm' => env('TWITTER_AUTO_CONFIRM_EMAIL', false),
+        'auto_confirm'  => env('TWITTER_AUTO_CONFIRM_EMAIL', false),
     ],
 
     'azure'   => [
         'client_id'     => env('AZURE_APP_ID', false),
         'client_secret' => env('AZURE_APP_SECRET', false),
     ],
 
     'azure'   => [
         'client_id'     => env('AZURE_APP_ID', false),
         'client_secret' => env('AZURE_APP_SECRET', false),
-        'tenant'       => env('AZURE_TENANT', false),
+        'tenant'        => env('AZURE_TENANT', false),
         'redirect'      => env('APP_URL') . '/login/service/azure/callback',
         'name'          => 'Microsoft Azure',
         'auto_register' => env('AZURE_AUTO_REGISTER', false),
         'redirect'      => env('APP_URL') . '/login/service/azure/callback',
         'name'          => 'Microsoft Azure',
         'auto_register' => env('AZURE_AUTO_REGISTER', false),
-        'auto_confirm' => env('AZURE_AUTO_CONFIRM_EMAIL', false),
+        'auto_confirm'  => env('AZURE_AUTO_CONFIRM_EMAIL', false),
     ],
 
     'okta' => [
     ],
 
     'okta' => [
-        'client_id' => env('OKTA_APP_ID'),
+        'client_id'     => env('OKTA_APP_ID'),
         'client_secret' => env('OKTA_APP_SECRET'),
         'client_secret' => env('OKTA_APP_SECRET'),
-        'redirect' => env('APP_URL') . '/login/service/okta/callback',
-        'base_url' => env('OKTA_BASE_URL'),
+        'redirect'      => env('APP_URL') . '/login/service/okta/callback',
+        'base_url'      => env('OKTA_BASE_URL'),
         'name'          => 'Okta',
         'auto_register' => env('OKTA_AUTO_REGISTER', false),
         'name'          => 'Okta',
         'auto_register' => env('OKTA_AUTO_REGISTER', false),
-        'auto_confirm' => env('OKTA_AUTO_CONFIRM_EMAIL', false),
+        'auto_confirm'  => env('OKTA_AUTO_CONFIRM_EMAIL', false),
     ],
 
     'gitlab' => [
     ],
 
     'gitlab' => [
@@ -95,45 +95,45 @@ return [
         'instance_uri'  => env('GITLAB_BASE_URI'), // Needed only for self hosted instances
         'name'          => 'GitLab',
         'auto_register' => env('GITLAB_AUTO_REGISTER', false),
         'instance_uri'  => env('GITLAB_BASE_URI'), // Needed only for self hosted instances
         'name'          => 'GitLab',
         'auto_register' => env('GITLAB_AUTO_REGISTER', false),
-        'auto_confirm' => env('GITLAB_AUTO_CONFIRM_EMAIL', false),
+        'auto_confirm'  => env('GITLAB_AUTO_CONFIRM_EMAIL', false),
     ],
 
     'twitch' => [
     ],
 
     'twitch' => [
-        'client_id' => env('TWITCH_APP_ID'),
+        'client_id'     => env('TWITCH_APP_ID'),
         'client_secret' => env('TWITCH_APP_SECRET'),
         'client_secret' => env('TWITCH_APP_SECRET'),
-        'redirect' => env('APP_URL') . '/login/service/twitch/callback',
+        'redirect'      => env('APP_URL') . '/login/service/twitch/callback',
         'name'          => 'Twitch',
         'auto_register' => env('TWITCH_AUTO_REGISTER', false),
         'name'          => 'Twitch',
         'auto_register' => env('TWITCH_AUTO_REGISTER', false),
-        'auto_confirm' => env('TWITCH_AUTO_CONFIRM_EMAIL', false),
+        'auto_confirm'  => env('TWITCH_AUTO_CONFIRM_EMAIL', false),
     ],
 
     'discord' => [
     ],
 
     'discord' => [
-        'client_id' => env('DISCORD_APP_ID'),
+        'client_id'     => env('DISCORD_APP_ID'),
         'client_secret' => env('DISCORD_APP_SECRET'),
         'client_secret' => env('DISCORD_APP_SECRET'),
-        'redirect' => env('APP_URL') . '/login/service/discord/callback',
-        'name' => 'Discord',
+        'redirect'      => env('APP_URL') . '/login/service/discord/callback',
+        'name'          => 'Discord',
         'auto_register' => env('DISCORD_AUTO_REGISTER', false),
         'auto_register' => env('DISCORD_AUTO_REGISTER', false),
-        'auto_confirm' => env('DISCORD_AUTO_CONFIRM_EMAIL', false),
+        'auto_confirm'  => env('DISCORD_AUTO_CONFIRM_EMAIL', false),
     ],
 
     'ldap' => [
     ],
 
     'ldap' => [
-        'server' => env('LDAP_SERVER', false),
-        'dump_user_details' => env('LDAP_DUMP_USER_DETAILS', false),
-        'dn' => env('LDAP_DN', false),
-        'pass' => env('LDAP_PASS', false),
-        'base_dn' => env('LDAP_BASE_DN', false),
-        'user_filter' => env('LDAP_USER_FILTER', '(&(uid=${user}))'),
-        'version' => env('LDAP_VERSION', false),
-        'id_attribute' => env('LDAP_ID_ATTRIBUTE', 'uid'),
-        'email_attribute' => env('LDAP_EMAIL_ATTRIBUTE', 'mail'),
+        'server'                 => env('LDAP_SERVER', false),
+        'dump_user_details'      => env('LDAP_DUMP_USER_DETAILS', false),
+        'dn'                     => env('LDAP_DN', false),
+        'pass'                   => env('LDAP_PASS', false),
+        'base_dn'                => env('LDAP_BASE_DN', false),
+        'user_filter'            => env('LDAP_USER_FILTER', '(&(uid=${user}))'),
+        'version'                => env('LDAP_VERSION', false),
+        'id_attribute'           => env('LDAP_ID_ATTRIBUTE', 'uid'),
+        'email_attribute'        => env('LDAP_EMAIL_ATTRIBUTE', 'mail'),
         'display_name_attribute' => env('LDAP_DISPLAY_NAME_ATTRIBUTE', 'cn'),
         'display_name_attribute' => env('LDAP_DISPLAY_NAME_ATTRIBUTE', 'cn'),
-        'follow_referrals' => env('LDAP_FOLLOW_REFERRALS', false),
-        'user_to_groups' => env('LDAP_USER_TO_GROUPS', false),
-        'group_attribute' => env('LDAP_GROUP_ATTRIBUTE', 'memberOf'),
-        'remove_from_groups' => env('LDAP_REMOVE_FROM_GROUPS', false),
-        'tls_insecure' => env('LDAP_TLS_INSECURE', false),
-        'start_tls' => env('LDAP_START_TLS', false),
-        'thumbnail_attribute' => env('LDAP_THUMBNAIL_ATTRIBUTE', null),
+        'follow_referrals'       => env('LDAP_FOLLOW_REFERRALS', false),
+        'user_to_groups'         => env('LDAP_USER_TO_GROUPS', false),
+        'group_attribute'        => env('LDAP_GROUP_ATTRIBUTE', 'memberOf'),
+        'remove_from_groups'     => env('LDAP_REMOVE_FROM_GROUPS', false),
+        'tls_insecure'           => env('LDAP_TLS_INSECURE', false),
+        'start_tls'              => env('LDAP_START_TLS', false),
+        'thumbnail_attribute'    => env('LDAP_THUMBNAIL_ATTRIBUTE', null),
     ],
 
 ];
     ],
 
 ];
index c750e1ef9a4ff48f93eb836dbdd182ea63a1a14f..4bbb789010ff341a0cf6d6b505201412a5b76819 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
 <?php
 
-use \Illuminate\Support\Str;
+use Illuminate\Support\Str;
 
 /**
  * Session configuration options.
 
 /**
  * Session configuration options.
index 879c636bcda2c2f4961cf3687fccf3f4eb0860b7..cb6082c528619ba420d8e1d657704d9350038b0d 100644 (file)
@@ -26,10 +26,10 @@ return [
 
     // User-level default settings
     'user' => [
 
     // User-level default settings
     'user' => [
-        'dark-mode-enabled' => env('APP_DEFAULT_DARK_MODE', false),
+        'dark-mode-enabled'     => env('APP_DEFAULT_DARK_MODE', false),
         'bookshelves_view_type' => env('APP_VIEWS_BOOKSHELVES', 'grid'),
         'bookshelves_view_type' => env('APP_VIEWS_BOOKSHELVES', 'grid'),
-        'bookshelf_view_type' =>env('APP_VIEWS_BOOKSHELF', 'grid'),
-        'books_view_type' => env('APP_VIEWS_BOOKS', 'grid'),
+        'bookshelf_view_type'   => env('APP_VIEWS_BOOKSHELF', 'grid'),
+        'books_view_type'       => env('APP_VIEWS_BOOKS', 'grid'),
     ],
 
 ];
     ],
 
 ];
index f347eda23349264d1b3d4118afadbedde0a5990a..0f012bef6cfd52004e8ff233b9169d22ec8f5bff 100644 (file)
@@ -14,7 +14,7 @@ return [
         'binary'  => file_exists(base_path('wkhtmltopdf')) ? base_path('wkhtmltopdf') : env('WKHTMLTOPDF', false),
         'timeout' => false,
         'options' => [
         'binary'  => file_exists(base_path('wkhtmltopdf')) ? base_path('wkhtmltopdf') : env('WKHTMLTOPDF', false),
         'timeout' => false,
         'options' => [
-            'outline' => true
+            'outline' => true,
         ],
         'env'     => [],
     ],
         ],
         'env'     => [],
     ],
index 93ca367a2102739b7067ddac3dfd9416749b6514..7221501979a529861e8e505ce66f9f79d7771160 100644 (file)
@@ -25,11 +25,11 @@ class CleanupImages extends Command
      */
     protected $description = 'Cleanup images and drawings';
 
      */
     protected $description = 'Cleanup images and drawings';
 
-
     protected $imageService;
 
     /**
      * Create a new command instance.
     protected $imageService;
 
     /**
      * Create a new command instance.
+     *
      * @param \BookStack\Uploads\ImageService $imageService
      */
     public function __construct(ImageService $imageService)
      * @param \BookStack\Uploads\ImageService $imageService
      */
     public function __construct(ImageService $imageService)
@@ -63,6 +63,7 @@ class CleanupImages extends Command
             $this->comment($deleteCount . ' images found that would have been deleted');
             $this->showDeletedImages($deleted);
             $this->comment('Run with -f or --force to perform deletions');
             $this->comment($deleteCount . ' images found that would have been deleted');
             $this->showDeletedImages($deleted);
             $this->comment('Run with -f or --force to perform deletions');
+
             return;
         }
 
             return;
         }
 
index 693d9363973e8229bb37a3037db667de862b1f85..0fc6c0195663755e2f1072444ef72452158075c6 100644 (file)
@@ -23,7 +23,6 @@ class ClearViews extends Command
 
     /**
      * Create a new command instance.
 
     /**
      * Create a new command instance.
-     *
      */
     public function __construct()
     {
      */
     public function __construct()
     {
index d220c59f9ea7cedbf0a77c6e6ccb3bab27d7496e..32adf06839c82d8a78acb8f8ab6e02c621c3d298 100644 (file)
@@ -54,13 +54,14 @@ class CopyShelfPermissions extends Command
 
         if (!$cascadeAll && !$shelfSlug) {
             $this->error('Either a --slug or --all option must be provided.');
 
         if (!$cascadeAll && !$shelfSlug) {
             $this->error('Either a --slug or --all option must be provided.');
+
             return;
         }
 
         if ($cascadeAll) {
             $continue = $this->confirm(
             return;
         }
 
         if ($cascadeAll) {
             $continue = $this->confirm(
-                'Permission settings for all shelves will be cascaded. '.
-                        'Books assigned to multiple shelves will receive only the permissions of it\'s last processed shelf. '.
+                'Permission settings for all shelves will be cascaded. ' .
+                        'Books assigned to multiple shelves will receive only the permissions of it\'s last processed shelf. ' .
                         'Are you sure you want to proceed?'
             );
 
                         'Are you sure you want to proceed?'
             );
 
index 3d1a3dca08db4045e528bfcab92c13984cbdeff9..a0fb8f31506899d83a2af899efb3d3613300ee41 100644 (file)
@@ -38,8 +38,9 @@ class CreateAdmin extends Command
     /**
      * Execute the console command.
      *
     /**
      * Execute the console command.
      *
-     * @return mixed
      * @throws \BookStack\Exceptions\NotFoundException
      * @throws \BookStack\Exceptions\NotFoundException
+     *
+     * @return mixed
      */
     public function handle()
     {
      */
     public function handle()
     {
@@ -71,7 +72,6 @@ class CreateAdmin extends Command
             return $this->error('Invalid password provided, Must be at least 5 characters');
         }
 
             return $this->error('Invalid password provided, Must be at least 5 characters');
         }
 
-
         $user = $this->userRepo->create(['email' => $email, 'name' => $name, 'password' => $password]);
         $this->userRepo->attachSystemRole($user, 'admin');
         $this->userRepo->downloadAndAssignUserAvatar($user);
         $user = $this->userRepo->create(['email' => $email, 'name' => $name, 'password' => $password]);
         $this->userRepo->attachSystemRole($user, 'admin');
         $this->userRepo->downloadAndAssignUserAvatar($user);
index c73c883de2d2bd75535f817e5c10e03eff3e9ff4..5627dd1f80456a7066110833642ed131db4d2d11 100644 (file)
@@ -8,7 +8,6 @@ use Illuminate\Console\Command;
 
 class DeleteUsers extends Command
 {
 
 class DeleteUsers extends Command
 {
-
     /**
      * The name and signature of the console command.
      *
     /**
      * The name and signature of the console command.
      *
@@ -47,7 +46,7 @@ class DeleteUsers extends Command
                     continue;
                 }
                 $this->userRepo->destroy($user);
                     continue;
                 }
                 $this->userRepo->destroy($user);
-                ++$numDeleted;
+                $numDeleted++;
             }
             $this->info("Deleted $numDeleted of $totalUsers total users.");
         } else {
             }
             $this->info("Deleted $numDeleted of $totalUsers total users.");
         } else {
index 2a16884680729e3dc502909cdc71d76addb70177..a4bb6cf228874f1d4b928c7faedc6baa704b27d0 100644 (file)
@@ -4,7 +4,6 @@ namespace BookStack\Console\Commands;
 
 use Illuminate\Console\Command;
 use Illuminate\Database\Connection;
 
 use Illuminate\Console\Command;
 use Illuminate\Database\Connection;
-use Illuminate\Support\Facades\DB;
 
 class UpdateUrl extends Command
 {
 
 class UpdateUrl extends Command
 {
@@ -49,7 +48,8 @@ class UpdateUrl extends Command
 
         $urlPattern = '/https?:\/\/(.+)/';
         if (!preg_match($urlPattern, $oldUrl) || !preg_match($urlPattern, $newUrl)) {
 
         $urlPattern = '/https?:\/\/(.+)/';
         if (!preg_match($urlPattern, $oldUrl) || !preg_match($urlPattern, $newUrl)) {
-            $this->error("The given urls are expected to be full urls starting with http:// or https://");
+            $this->error('The given urls are expected to be full urls starting with http:// or https://');
+
             return 1;
         }
 
             return 1;
         }
 
@@ -58,11 +58,11 @@ class UpdateUrl extends Command
         }
 
         $columnsToUpdateByTable = [
         }
 
         $columnsToUpdateByTable = [
-            "attachments" => ["path"],
-            "pages" => ["html", "text", "markdown"],
-            "images" => ["url"],
-            "settings" => ["value"],
-            "comments" => ["html", "text"],
+            'attachments' => ['path'],
+            'pages'       => ['html', 'text', 'markdown'],
+            'images'      => ['url'],
+            'settings'    => ['value'],
+            'comments'    => ['html', 'text'],
         ];
 
         foreach ($columnsToUpdateByTable as $table => $columns) {
         ];
 
         foreach ($columnsToUpdateByTable as $table => $columns) {
@@ -73,7 +73,7 @@ class UpdateUrl extends Command
         }
 
         $jsonColumnsToUpdateByTable = [
         }
 
         $jsonColumnsToUpdateByTable = [
-            "settings" => ["value"],
+            'settings' => ['value'],
         ];
 
         foreach ($jsonColumnsToUpdateByTable as $table => $columns) {
         ];
 
         foreach ($jsonColumnsToUpdateByTable as $table => $columns) {
@@ -85,10 +85,11 @@ class UpdateUrl extends Command
             }
         }
 
             }
         }
 
-        $this->info("URL update procedure complete.");
+        $this->info('URL update procedure complete.');
         $this->info('============================================================================');
         $this->info('Be sure to run "php artisan cache:clear" to clear any old URLs in the cache.');
         $this->info('============================================================================');
         $this->info('============================================================================');
         $this->info('Be sure to run "php artisan cache:clear" to clear any old URLs in the cache.');
         $this->info('============================================================================');
+
         return 0;
     }
 
         return 0;
     }
 
@@ -100,8 +101,9 @@ class UpdateUrl extends Command
     {
         $oldQuoted = $this->db->getPdo()->quote($oldUrl);
         $newQuoted = $this->db->getPdo()->quote($newUrl);
     {
         $oldQuoted = $this->db->getPdo()->quote($oldUrl);
         $newQuoted = $this->db->getPdo()->quote($newUrl);
+
         return $this->db->table($table)->update([
         return $this->db->table($table)->update([
-            $column => $this->db->raw("REPLACE({$column}, {$oldQuoted}, {$newQuoted})")
+            $column => $this->db->raw("REPLACE({$column}, {$oldQuoted}, {$newQuoted})"),
         ]);
     }
 
         ]);
     }
 
@@ -112,8 +114,8 @@ class UpdateUrl extends Command
     protected function checkUserOkayToProceed(string $oldUrl, string $newUrl): bool
     {
         $dangerWarning = "This will search for \"{$oldUrl}\" in your database and replace it with  \"{$newUrl}\".\n";
     protected function checkUserOkayToProceed(string $oldUrl, string $newUrl): bool
     {
         $dangerWarning = "This will search for \"{$oldUrl}\" in your database and replace it with  \"{$newUrl}\".\n";
-        $dangerWarning .= "Are you sure you want to proceed?";
-        $backupConfirmation = "This operation could cause issues if used incorrectly. Have you made a backup of your existing database?";
+        $dangerWarning .= 'Are you sure you want to proceed?';
+        $backupConfirmation = 'This operation could cause issues if used incorrectly. Have you made a backup of your existing database?';
 
         return $this->confirm($dangerWarning) && $this->confirm($backupConfirmation);
     }
 
         return $this->confirm($dangerWarning) && $this->confirm($backupConfirmation);
     }
index a17fc952351df5103709c0c2406f8287ac140215..32808729a545a47904457cb7af9bb67f557178e9 100644 (file)
@@ -23,7 +23,6 @@ class UpgradeDatabaseEncoding extends Command
 
     /**
      * Create a new command instance.
 
     /**
      * Create a new command instance.
-     *
      */
     public function __construct()
     {
      */
     public function __construct()
     {
@@ -44,12 +43,12 @@ class UpgradeDatabaseEncoding extends Command
 
         $database = DB::getDatabaseName();
         $tables = DB::select('SHOW TABLES');
 
         $database = DB::getDatabaseName();
         $tables = DB::select('SHOW TABLES');
-        $this->line('ALTER DATABASE `'.$database.'` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
-        $this->line('USE `'.$database.'`;');
+        $this->line('ALTER DATABASE `' . $database . '` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
+        $this->line('USE `' . $database . '`;');
         $key = 'Tables_in_' . $database;
         foreach ($tables as $table) {
             $tableName = $table->$key;
         $key = 'Tables_in_' . $database;
         foreach ($tables as $table) {
             $tableName = $table->$key;
-            $this->line('ALTER TABLE `'.$tableName.'` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
+            $this->line('ALTER TABLE `' . $tableName . '` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
         }
 
         DB::setDefaultConnection($connection);
         }
 
         DB::setDefaultConnection($connection);
index e75d93801632b972df5787dafe8094cea2fbc943..11c8018c8d6fca1cec1191c011938d20c2478fe1 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Console;
+<?php
+
+namespace BookStack\Console;
 
 use Illuminate\Console\Scheduling\Schedule;
 use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
 
 use Illuminate\Console\Scheduling\Schedule;
 use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
@@ -17,7 +19,8 @@ class Kernel extends ConsoleKernel
     /**
      * Define the application's command schedule.
      *
     /**
      * Define the application's command schedule.
      *
-     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
+     * @param \Illuminate\Console\Scheduling\Schedule $schedule
+     *
      * @return void
      */
     protected function schedule(Schedule $schedule)
      * @return void
      */
     protected function schedule(Schedule $schedule)
@@ -32,6 +35,6 @@ class Kernel extends ConsoleKernel
      */
     protected function commands()
     {
      */
     protected function commands()
     {
-        $this->load(__DIR__.'/Commands');
+        $this->load(__DIR__ . '/Commands');
     }
 }
     }
 }
index cf7cf296c94fdbd8cdcb3b7dffd59767cb8000ad..797162dfb4fb586e8c0b536bb22bd0dea548bd38 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Entities;
+<?php
+
+namespace BookStack\Entities;
 
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Tools\ShelfContext;
 
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Tools\ShelfContext;
@@ -6,11 +8,11 @@ use Illuminate\View\View;
 
 class BreadcrumbsViewComposer
 {
 
 class BreadcrumbsViewComposer
 {
-
     protected $entityContextManager;
 
     /**
      * BreadcrumbsViewComposer constructor.
     protected $entityContextManager;
 
     /**
      * BreadcrumbsViewComposer constructor.
+     *
      * @param ShelfContext $entityContextManager
      */
     public function __construct(ShelfContext $entityContextManager)
      * @param ShelfContext $entityContextManager
      */
     public function __construct(ShelfContext $entityContextManager)
@@ -20,6 +22,7 @@ class BreadcrumbsViewComposer
 
     /**
      * Modify data when the view is composed.
 
     /**
      * Modify data when the view is composed.
+     *
      * @param View $view
      */
     public function compose(View $view)
      * @param View $view
      */
     public function compose(View $view)
index c77a57d61a5710edf652082839492a394c21a341..aaf392c7b2782b7f54199d4d7398ce8a3059c7d8 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Entities;
+<?php
+
+namespace BookStack\Entities;
 
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Bookshelf;
 
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Bookshelf;
@@ -8,7 +10,7 @@ use BookStack\Entities\Models\Page;
 use BookStack\Entities\Models\PageRevision;
 
 /**
 use BookStack\Entities\Models\PageRevision;
 
 /**
- * Class EntityProvider
+ * Class EntityProvider.
  *
  * Provides access to the core entity models.
  * Wrapped up in this provider since they are often used together
  *
  * Provides access to the core entity models.
  * Wrapped up in this provider since they are often used together
@@ -16,7 +18,6 @@ use BookStack\Entities\Models\PageRevision;
  */
 class EntityProvider
 {
  */
 class EntityProvider
 {
-
     /**
      * @var Bookshelf
      */
     /**
      * @var Bookshelf
      */
@@ -42,7 +43,6 @@ class EntityProvider
      */
     public $pageRevision;
 
      */
     public $pageRevision;
 
-
     public function __construct()
     {
         $this->bookshelf = new Bookshelf();
     public function __construct()
     {
         $this->bookshelf = new Bookshelf();
@@ -55,15 +55,16 @@ class EntityProvider
     /**
      * Fetch all core entity types as an associated array
      * with their basic names as the keys.
     /**
      * Fetch all core entity types as an associated array
      * with their basic names as the keys.
+     *
      * @return array<Entity>
      */
     public function all(): array
     {
         return [
             'bookshelf' => $this->bookshelf,
      * @return array<Entity>
      */
     public function all(): array
     {
         return [
             'bookshelf' => $this->bookshelf,
-            'book' => $this->book,
-            'chapter' => $this->chapter,
-            'page' => $this->page,
+            'book'      => $this->book,
+            'chapter'   => $this->chapter,
+            'page'      => $this->page,
         ];
     }
 
         ];
     }
 
@@ -73,6 +74,7 @@ class EntityProvider
     public function get(string $type): Entity
     {
         $type = strtolower($type);
     public function get(string $type): Entity
     {
         $type = strtolower($type);
+
         return $this->all()[$type];
     }
 
         return $this->all()[$type];
     }
 
@@ -86,6 +88,7 @@ class EntityProvider
             $model = $this->get($type);
             $morphClasses[] = $model->getMorphClass();
         }
             $model = $this->get($type);
             $morphClasses[] = $model->getMorphClass();
         }
+
         return $morphClasses;
     }
 }
         return $morphClasses;
     }
 }
index 6c56767655c894b22c548e7ff552a07f36940ea6..df30c1c714abb4fff2ddd9d92e2b3c4fa6119623 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Entities\Models;
+<?php
+
+namespace BookStack\Entities\Models;
 
 use BookStack\Uploads\Image;
 use Exception;
 
 use BookStack\Uploads\Image;
 use Exception;
@@ -8,9 +10,10 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
 use Illuminate\Support\Collection;
 
 /**
 use Illuminate\Support\Collection;
 
 /**
- * Class Book
- * @property string $description
- * @property int $image_id
+ * Class Book.
+ *
+ * @property string     $description
+ * @property int        $image_id
  * @property Image|null $cover
  */
 class Book extends Entity implements HasCoverImage
  * @property Image|null $cover
  */
 class Book extends Entity implements HasCoverImage
@@ -30,8 +33,10 @@ class Book extends Entity implements HasCoverImage
 
     /**
      * Returns book cover image, if book cover not exists return default cover image.
 
     /**
      * Returns book cover image, if book cover not exists return default cover image.
-     * @param int $width - Width of the image
+     *
+     * @param int $width  - Width of the image
      * @param int $height - Height of the image
      * @param int $height - Height of the image
+     *
      * @return string
      */
     public function getBookCover($width = 440, $height = 250)
      * @return string
      */
     public function getBookCover($width = 440, $height = 250)
@@ -46,11 +51,12 @@ class Book extends Entity implements HasCoverImage
         } catch (Exception $err) {
             $cover = $default;
         }
         } catch (Exception $err) {
             $cover = $default;
         }
+
         return $cover;
     }
 
     /**
         return $cover;
     }
 
     /**
-     * Get the cover image of the book
+     * Get the cover image of the book.
      */
     public function cover(): BelongsTo
     {
      */
     public function cover(): BelongsTo
     {
@@ -67,6 +73,7 @@ class Book extends Entity implements HasCoverImage
 
     /**
      * Get all pages within this book.
 
     /**
      * Get all pages within this book.
+     *
      * @return HasMany
      */
     public function pages()
      * @return HasMany
      */
     public function pages()
@@ -76,6 +83,7 @@ class Book extends Entity implements HasCoverImage
 
     /**
      * Get the direct child pages of this book.
 
     /**
      * Get the direct child pages of this book.
+     *
      * @return HasMany
      */
     public function directPages()
      * @return HasMany
      */
     public function directPages()
@@ -85,6 +93,7 @@ class Book extends Entity implements HasCoverImage
 
     /**
      * Get all chapters within this book.
 
     /**
      * Get all chapters within this book.
+     *
      * @return HasMany
      */
     public function chapters()
      * @return HasMany
      */
     public function chapters()
@@ -94,6 +103,7 @@ class Book extends Entity implements HasCoverImage
 
     /**
      * Get the shelves this book is contained within.
 
     /**
      * Get the shelves this book is contained within.
+     *
      * @return BelongsToMany
      */
     public function shelves()
      * @return BelongsToMany
      */
     public function shelves()
@@ -103,12 +113,14 @@ class Book extends Entity implements HasCoverImage
 
     /**
      * Get the direct child items within this book.
 
     /**
      * Get the direct child items within this book.
+     *
      * @return Collection
      */
     public function getDirectChildren(): Collection
     {
         $pages = $this->directPages()->visible()->get();
         $chapters = $this->chapters()->visible()->get();
      * @return Collection
      */
     public function getDirectChildren(): Collection
     {
         $pages = $this->directPages()->visible()->get();
         $chapters = $this->chapters()->visible()->get();
+
         return $pages->concat($chapters)->sortBy('priority')->sortByDesc('draft');
     }
 }
         return $pages->concat($chapters)->sortBy('priority')->sortByDesc('draft');
     }
 }
index c73fa3959423598da0e1619c07d9720760374a39..f61878208eac80fbdb84d0dfa2e2810bf4e63910 100644 (file)
@@ -1,18 +1,21 @@
-<?php namespace BookStack\Entities\Models;
+<?php
+
+namespace BookStack\Entities\Models;
 
 use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Database\Eloquent\Relations\BelongsTo;
 
 /**
 
 use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Database\Eloquent\Relations\BelongsTo;
 
 /**
- * Class BookChild
- * @property int $book_id
- * @property int $priority
+ * Class BookChild.
+ *
+ * @property int  $book_id
+ * @property int  $priority
  * @property Book $book
  * @property Book $book
+ *
  * @method Builder whereSlugs(string $bookSlug, string $childSlug)
  */
 abstract class BookChild extends Entity
 {
  * @method Builder whereSlugs(string $bookSlug, string $childSlug)
  */
 abstract class BookChild extends Entity
 {
-
     /**
      * Scope a query to find items where the the child has the given childSlug
      * where its parent has the bookSlug.
     /**
      * Scope a query to find items where the the child has the given childSlug
      * where its parent has the bookSlug.
index 8ffd06d2e2f1b9d22dee6cabb23318976c85ddac..f427baf49fcea4c0bb616eb9270302ffd6f85728 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Entities\Models;
+<?php
+
+namespace BookStack\Entities\Models;
 
 use BookStack\Uploads\Image;
 use Illuminate\Database\Eloquent\Relations\BelongsTo;
 
 use BookStack\Uploads\Image;
 use Illuminate\Database\Eloquent\Relations\BelongsTo;
@@ -17,6 +19,7 @@ class Bookshelf extends Entity implements HasCoverImage
     /**
      * Get the books in this shelf.
      * Should not be used directly since does not take into account permissions.
     /**
      * Get the books in this shelf.
      * Should not be used directly since does not take into account permissions.
+     *
      * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
      */
     public function books()
      * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
      */
     public function books()
@@ -44,8 +47,10 @@ class Bookshelf extends Entity implements HasCoverImage
 
     /**
      * Returns BookShelf cover image, if cover does not exists return default cover image.
 
     /**
      * Returns BookShelf cover image, if cover does not exists return default cover image.
-     * @param int $width - Width of the image
+     *
+     * @param int $width  - Width of the image
      * @param int $height - Height of the image
      * @param int $height - Height of the image
+     *
      * @return string
      */
     public function getBookCover($width = 440, $height = 250)
      * @return string
      */
     public function getBookCover($width = 440, $height = 250)
@@ -61,11 +66,12 @@ class Bookshelf extends Entity implements HasCoverImage
         } catch (\Exception $err) {
             $cover = $default;
         }
         } catch (\Exception $err) {
             $cover = $default;
         }
+
         return $cover;
     }
 
     /**
         return $cover;
     }
 
     /**
-     * Get the cover image of the shelf
+     * Get the cover image of the shelf.
      */
     public function cover(): BelongsTo
     {
      */
     public function cover(): BelongsTo
     {
@@ -82,7 +88,9 @@ class Bookshelf extends Entity implements HasCoverImage
 
     /**
      * Check if this shelf contains the given book.
 
     /**
      * Check if this shelf contains the given book.
+     *
      * @param Book $book
      * @param Book $book
+     *
      * @return bool
      */
     public function contains(Book $book): bool
      * @return bool
      */
     public function contains(Book $book): bool
@@ -92,6 +100,7 @@ class Bookshelf extends Entity implements HasCoverImage
 
     /**
      * Add a book to the end of this shelf.
 
     /**
      * Add a book to the end of this shelf.
+     *
      * @param Book $book
      */
     public function appendBook(Book $book)
      * @param Book $book
      */
     public function appendBook(Book $book)
index 1810685335bf6910dc2486eb6410fa47e88edcca..fd818b703736b9fe9e7bacd0f67fc5848e94a47c 100644 (file)
@@ -1,9 +1,12 @@
-<?php namespace BookStack\Entities\Models;
+<?php
+
+namespace BookStack\Entities\Models;
 
 use Illuminate\Support\Collection;
 
 /**
 
 use Illuminate\Support\Collection;
 
 /**
- * Class Chapter
+ * Class Chapter.
+ *
  * @property Collection<Page> $pages
  * @property mixed description
  */
  * @property Collection<Page> $pages
  * @property mixed description
  */
@@ -16,7 +19,9 @@ class Chapter extends BookChild
 
     /**
      * Get the pages that this chapter contains.
 
     /**
      * Get the pages that this chapter contains.
+     *
      * @param string $dir
      * @param string $dir
+     *
      * @return mixed
      */
     public function pages($dir = 'ASC')
      * @return mixed
      */
     public function pages($dir = 'ASC')
index 2295a5e214bbf055293386be366aed2817c688dd..764c4a1e30ea4cb4b713231c88ae606942dcea06 100644 (file)
@@ -1,7 +1,8 @@
-<?php namespace BookStack\Entities\Models;
+<?php
+
+namespace BookStack\Entities\Models;
 
 use BookStack\Auth\User;
 
 use BookStack\Auth\User;
-use BookStack\Entities\Models\Entity;
 use BookStack\Interfaces\Loggable;
 use Illuminate\Database\Eloquent\Model;
 use Illuminate\Database\Eloquent\Relations\BelongsTo;
 use BookStack\Interfaces\Loggable;
 use Illuminate\Database\Eloquent\Model;
 use Illuminate\Database\Eloquent\Relations\BelongsTo;
@@ -12,7 +13,6 @@ use Illuminate\Database\Eloquent\Relations\MorphTo;
  */
 class Deletion extends Model implements Loggable
 {
  */
 class Deletion extends Model implements Loggable
 {
-
     /**
      * Get the related deletable record.
      */
     /**
      * Get the related deletable record.
      */
@@ -35,17 +35,19 @@ class Deletion extends Model implements Loggable
     public static function createForEntity(Entity $entity): Deletion
     {
         $record = (new self())->forceFill([
     public static function createForEntity(Entity $entity): Deletion
     {
         $record = (new self())->forceFill([
-            'deleted_by' => user()->id,
+            'deleted_by'     => user()->id,
             'deletable_type' => $entity->getMorphClass(),
             'deletable_type' => $entity->getMorphClass(),
-            'deletable_id' => $entity->id,
+            'deletable_id'   => $entity->id,
         ]);
         $record->save();
         ]);
         $record->save();
+
         return $record;
     }
 
     public function logDescriptor(): string
     {
         $deletable = $this->deletable()->first();
         return $record;
     }
 
     public function logDescriptor(): string
     {
         $deletable = $this->deletable()->first();
+
         return "Deletion ({$this->id}) for {$deletable->getType()} ({$deletable->id}) {$deletable->name}";
     }
 
         return "Deletion ({$this->id}) for {$deletable->getType()} ({$deletable->id}) {$deletable->name}";
     }
 
index caa25d6784257af16ddea48c65eb296c5ad634ee..a02926c4dee341aa6d89d16f94fb425434c95bbb 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Entities\Models;
+<?php
+
+namespace BookStack\Entities\Models;
 
 use BookStack\Actions\Activity;
 use BookStack\Actions\Comment;
 
 use BookStack\Actions\Activity;
 use BookStack\Actions\Comment;
@@ -27,15 +29,16 @@ use Illuminate\Database\Eloquent\SoftDeletes;
  * The base class for book-like items such as pages, chapters & books.
  * This is not a database model in itself but extended.
  *
  * The base class for book-like items such as pages, chapters & books.
  * This is not a database model in itself but extended.
  *
- * @property int $id
- * @property string $name
- * @property string $slug
- * @property Carbon $created_at
- * @property Carbon $updated_at
- * @property int $created_by
- * @property int $updated_by
- * @property boolean $restricted
+ * @property int        $id
+ * @property string     $name
+ * @property string     $slug
+ * @property Carbon     $created_at
+ * @property Carbon     $updated_at
+ * @property int        $created_by
+ * @property int        $updated_by
+ * @property bool       $restricted
  * @property Collection $tags
  * @property Collection $tags
+ *
  * @method static Entity|Builder visible()
  * @method static Entity|Builder hasPermission(string $permission)
  * @method static Builder withLastView()
  * @method static Entity|Builder visible()
  * @method static Entity|Builder hasPermission(string $permission)
  * @method static Builder withLastView()
@@ -154,11 +157,12 @@ abstract class Entity extends Model implements Sluggable, Favouritable, Viewable
     }
 
     /**
     }
 
     /**
-     * Get the comments for an entity
+     * Get the comments for an entity.
      */
     public function comments(bool $orderByCreated = true): MorphMany
     {
         $query = $this->morphMany(Comment::class, 'entity');
      */
     public function comments(bool $orderByCreated = true): MorphMany
     {
         $query = $this->morphMany(Comment::class, 'entity');
+
         return $orderByCreated ? $query->orderBy('created_at', 'asc') : $query;
     }
 
         return $orderByCreated ? $query->orderBy('created_at', 'asc') : $query;
     }
 
@@ -205,7 +209,7 @@ abstract class Entity extends Model implements Sluggable, Favouritable, Viewable
 
     /**
      * Check if this instance or class is a certain type of entity.
 
     /**
      * Check if this instance or class is a certain type of entity.
-     * Examples of $type are 'page', 'book', 'chapter'
+     * Examples of $type are 'page', 'book', 'chapter'.
      */
     public static function isA(string $type): bool
     {
      */
     public static function isA(string $type): bool
     {
@@ -218,6 +222,7 @@ abstract class Entity extends Model implements Sluggable, Favouritable, Viewable
     public static function getType(): string
     {
         $className = array_slice(explode('\\', static::class), -1, 1)[0];
     public static function getType(): string
     {
         $className = array_slice(explode('\\', static::class), -1, 1)[0];
+
         return strtolower($className);
     }
 
         return strtolower($className);
     }
 
@@ -229,6 +234,7 @@ abstract class Entity extends Model implements Sluggable, Favouritable, Viewable
         if (mb_strlen($this->name) <= $length) {
             return $this->name;
         }
         if (mb_strlen($this->name) <= $length) {
             return $this->name;
         }
+
         return mb_substr($this->name, 0, $length - 3) . '...';
     }
 
         return mb_substr($this->name, 0, $length - 3) . '...';
     }
 
@@ -248,14 +254,14 @@ abstract class Entity extends Model implements Sluggable, Favouritable, Viewable
         $text = $this->getText();
 
         if (mb_strlen($text) > $length) {
         $text = $this->getText();
 
         if (mb_strlen($text) > $length) {
-            $text = mb_substr($text, 0, $length-3) . '...';
+            $text = mb_substr($text, 0, $length - 3) . '...';
         }
 
         return trim($text);
     }
 
     /**
         }
 
         return trim($text);
     }
 
     /**
-     * Get the url of this entity
+     * Get the url of this entity.
      */
     abstract public function getUrl(string $path = '/'): string;
 
      */
     abstract public function getUrl(string $path = '/'): string;
 
@@ -272,6 +278,7 @@ abstract class Entity extends Model implements Sluggable, Favouritable, Viewable
         if ($this instanceof Chapter) {
             return $this->book()->withTrashed()->first();
         }
         if ($this instanceof Chapter) {
             return $this->book()->withTrashed()->first();
         }
+
         return null;
     }
 
         return null;
     }
 
@@ -285,7 +292,7 @@ abstract class Entity extends Model implements Sluggable, Favouritable, Viewable
     }
 
     /**
     }
 
     /**
-     * Index the current entity for search
+     * Index the current entity for search.
      */
     public function indexForSearch()
     {
      */
     public function indexForSearch()
     {
@@ -298,6 +305,7 @@ abstract class Entity extends Model implements Sluggable, Favouritable, Viewable
     public function refreshSlug(): string
     {
         $this->slug = app(SlugGenerator::class)->generate($this);
     public function refreshSlug(): string
     {
         $this->slug = app(SlugGenerator::class)->generate($this);
+
         return $this->slug;
     }
 
         return $this->slug;
     }
 
index f3a486d1877f32a2ef3fcf9f2145868d94337005..f665efce6d24c8ec6ebb9a25f5f05f92613b80e2 100644 (file)
@@ -1,13 +1,11 @@
 <?php
 
 <?php
 
-
 namespace BookStack\Entities\Models;
 
 use Illuminate\Database\Eloquent\Relations\BelongsTo;
 
 interface HasCoverImage
 {
 namespace BookStack\Entities\Models;
 
 use Illuminate\Database\Eloquent\Relations\BelongsTo;
 
 interface HasCoverImage
 {
-
     /**
      * Get the cover image for this item.
      */
     /**
      * Get the cover image for this item.
      */
index 93fb218932cf6e9f2796fce7f3aaac8586c43490..123600539b053f71b7a428d408e75e80cbfe95a6 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Entities\Models;
+<?php
+
+namespace BookStack\Entities\Models;
 
 use BookStack\Entities\Tools\PageContent;
 use BookStack\Uploads\Attachment;
 
 use BookStack\Entities\Tools\PageContent;
 use BookStack\Uploads\Attachment;
@@ -9,15 +11,16 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
 use Permissions;
 
 /**
 use Permissions;
 
 /**
- * Class Page
- * @property int $chapter_id
- * @property string $html
- * @property string $markdown
- * @property string $text
- * @property bool $template
- * @property bool $draft
- * @property int $revision_count
- * @property Chapter $chapter
+ * Class Page.
+ *
+ * @property int        $chapter_id
+ * @property string     $html
+ * @property string     $markdown
+ * @property string     $text
+ * @property bool       $template
+ * @property bool       $draft
+ * @property int        $revision_count
+ * @property Chapter    $chapter
  * @property Collection $attachments
  */
 class Page extends BookChild
  * @property Collection $attachments
  */
 class Page extends BookChild
@@ -31,7 +34,7 @@ class Page extends BookChild
     protected $hidden = ['html', 'markdown', 'text', 'restricted', 'pivot', 'deleted_at'];
 
     protected $casts = [
     protected $hidden = ['html', 'markdown', 'text', 'restricted', 'pivot', 'deleted_at'];
 
     protected $casts = [
-        'draft' => 'boolean',
+        'draft'    => 'boolean',
         'template' => 'boolean',
     ];
 
         'template' => 'boolean',
     ];
 
@@ -41,22 +44,26 @@ class Page extends BookChild
     public function scopeVisible(Builder $query): Builder
     {
         $query = Permissions::enforceDraftVisibilityOnQuery($query);
     public function scopeVisible(Builder $query): Builder
     {
         $query = Permissions::enforceDraftVisibilityOnQuery($query);
+
         return parent::scopeVisible($query);
     }
 
     /**
      * Converts this page into a simplified array.
         return parent::scopeVisible($query);
     }
 
     /**
      * Converts this page into a simplified array.
+     *
      * @return mixed
      */
     public function toSimpleArray()
     {
         $array = array_intersect_key($this->toArray(), array_flip($this->simpleAttributes));
         $array['url'] = $this->getUrl();
      * @return mixed
      */
     public function toSimpleArray()
     {
         $array = array_intersect_key($this->toArray(), array_flip($this->simpleAttributes));
         $array['url'] = $this->getUrl();
+
         return $array;
     }
 
     /**
      * Get the chapter that this page is in, If applicable.
         return $array;
     }
 
     /**
      * Get the chapter that this page is in, If applicable.
+     *
      * @return BelongsTo
      */
     public function chapter()
      * @return BelongsTo
      */
     public function chapter()
@@ -66,6 +73,7 @@ class Page extends BookChild
 
     /**
      * Check if this page has a chapter.
 
     /**
      * Check if this page has a chapter.
+     *
      * @return bool
      */
     public function hasChapter()
      * @return bool
      */
     public function hasChapter()
@@ -96,6 +104,7 @@ class Page extends BookChild
 
     /**
      * Get the attachments assigned to this page.
 
     /**
      * Get the attachments assigned to this page.
+     *
      * @return HasMany
      */
     public function attachments()
      * @return HasMany
      */
     public function attachments()
@@ -120,7 +129,8 @@ class Page extends BookChild
     }
 
     /**
     }
 
     /**
-     * Get the current revision for the page if existing
+     * Get the current revision for the page if existing.
+     *
      * @return PageRevision|null
      */
     public function getCurrentRevision()
      * @return PageRevision|null
      */
     public function getCurrentRevision()
@@ -136,6 +146,7 @@ class Page extends BookChild
         $refreshed = $this->refresh()->unsetRelations()->load(['tags', 'createdBy', 'updatedBy', 'ownedBy']);
         $refreshed->setHidden(array_diff($refreshed->getHidden(), ['html', 'markdown']));
         $refreshed->html = (new PageContent($refreshed))->render();
         $refreshed = $this->refresh()->unsetRelations()->load(['tags', 'createdBy', 'updatedBy', 'ownedBy']);
         $refreshed->setHidden(array_diff($refreshed->getHidden(), ['html', 'markdown']));
         $refreshed->html = (new PageContent($refreshed))->render();
+
         return $refreshed;
     }
 }
         return $refreshed;
     }
 }
index 76a3b15ffd44ea64e176eb1020773dc0ca41ec70..c1a74f66b2a92d5664a48ebb0649a1365539e17b 100644 (file)
@@ -1,29 +1,32 @@
-<?php namespace BookStack\Entities\Models;
+<?php
+
+namespace BookStack\Entities\Models;
 
 use BookStack\Auth\User;
 
 use BookStack\Auth\User;
-use BookStack\Entities\Models\Page;
 use BookStack\Model;
 use Carbon\Carbon;
 
 /**
 use BookStack\Model;
 use Carbon\Carbon;
 
 /**
- * Class PageRevision
- * @property int $page_id
+ * Class PageRevision.
+ *
+ * @property int    $page_id
  * @property string $slug
  * @property string $book_slug
  * @property string $slug
  * @property string $book_slug
- * @property int $created_by
+ * @property int    $created_by
  * @property Carbon $created_at
  * @property string $type
  * @property string $summary
  * @property string $markdown
  * @property string $html
  * @property Carbon $created_at
  * @property string $type
  * @property string $summary
  * @property string $markdown
  * @property string $html
- * @property int $revision_number
+ * @property int    $revision_number
  */
 class PageRevision extends Model
 {
     protected $fillable = ['name', 'html', 'text', 'markdown', 'summary'];
 
     /**
  */
 class PageRevision extends Model
 {
     protected $fillable = ['name', 'html', 'text', 'markdown', 'summary'];
 
     /**
-     * Get the user that created the page revision
+     * Get the user that created the page revision.
+     *
      * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
      */
     public function createdBy()
      * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
      */
     public function createdBy()
@@ -33,6 +36,7 @@ class PageRevision extends Model
 
     /**
      * Get the page this revision originates from.
 
     /**
      * Get the page this revision originates from.
+     *
      * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
      */
     public function page()
      * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
      */
     public function page()
@@ -42,7 +46,9 @@ class PageRevision extends Model
 
     /**
      * Get the url for this revision.
 
     /**
      * Get the url for this revision.
+     *
      * @param null|string $path
      * @param null|string $path
+     *
      * @return string
      */
     public function getUrl($path = null)
      * @return string
      */
     public function getUrl($path = null)
@@ -51,11 +57,13 @@ class PageRevision extends Model
         if ($path) {
             return $url . '/' . trim($path, '/');
         }
         if ($path) {
             return $url . '/' . trim($path, '/');
         }
+
         return $url;
     }
 
     /**
         return $url;
     }
 
     /**
-     * Get the previous revision for the same page if existing
+     * Get the previous revision for the same page if existing.
+     *
      * @return \BookStack\Entities\PageRevision|null
      */
     public function getPrevious()
      * @return \BookStack\Entities\PageRevision|null
      */
     public function getPrevious()
@@ -74,8 +82,10 @@ class PageRevision extends Model
     /**
      * Allows checking of the exact class, Used to check entity type.
      * Included here to align with entities in similar use cases.
     /**
      * Allows checking of the exact class, Used to check entity type.
      * Included here to align with entities in similar use cases.
-     * (Yup, Bit of an awkward hack)
+     * (Yup, Bit of an awkward hack).
+     *
      * @param $type
      * @param $type
+     *
      * @return bool
      */
     public static function isA($type)
      * @return bool
      */
     public static function isA($type)
index f55cb8407b34c9ce5b4a1bf672178f320c840db5..4ec8d6c45ac1ad027322d0ccbb26fec418e9e468 100644 (file)
@@ -1,15 +1,17 @@
-<?php namespace BookStack\Entities\Models;
+<?php
+
+namespace BookStack\Entities\Models;
 
 use BookStack\Model;
 
 class SearchTerm extends Model
 {
 
 use BookStack\Model;
 
 class SearchTerm extends Model
 {
-
     protected $fillable = ['term', 'entity_id', 'entity_type', 'score'];
     public $timestamps = false;
 
     /**
     protected $fillable = ['term', 'entity_id', 'entity_type', 'score'];
     public $timestamps = false;
 
     /**
-     * Get the entity that this term belongs to
+     * Get the entity that this term belongs to.
+     *
      * @return \Illuminate\Database\Eloquent\Relations\MorphTo
      */
     public function entity()
      * @return \Illuminate\Database\Eloquent\Relations\MorphTo
      */
     public function entity()
index bd920c3a5c3aa173579ccdb580f1c872235c36b5..76ab16ffc827f1373a186d41118fca54205e0239 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Entities\Queries;
+<?php
+
+namespace BookStack\Entities\Queries;
 
 use BookStack\Auth\Permissions\PermissionService;
 use BookStack\Entities\EntityProvider;
 
 use BookStack\Auth\Permissions\PermissionService;
 use BookStack\Entities\EntityProvider;
@@ -14,4 +16,4 @@ abstract class EntityQuery
     {
         return app()->make(EntityProvider::class);
     }
     {
         return app()->make(EntityProvider::class);
     }
-}
\ No newline at end of file
+}
index 98db2fe62720dd0cb389a7970210cb402ba06161..e6b22a1c95fb12880e163674b093c9adbd0ae3a3 100644 (file)
@@ -1,5 +1,6 @@
-<?php namespace BookStack\Entities\Queries;
+<?php
 
 
+namespace BookStack\Entities\Queries;
 
 use BookStack\Actions\View;
 use Illuminate\Support\Facades\DB;
 
 use BookStack\Actions\View;
 use Illuminate\Support\Facades\DB;
@@ -25,5 +26,4 @@ class Popular extends EntityQuery
             ->pluck('viewable')
             ->filter();
     }
             ->pluck('viewable')
             ->filter();
     }
-
-}
\ No newline at end of file
+}
index d528fea4470788e8f347f0a2098ca375196220be..5a29ecd7240c865c66738334e9c8f9dbff2fea7e 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Entities\Queries;
+<?php
+
+namespace BookStack\Entities\Queries;
 
 use BookStack\Actions\View;
 use Illuminate\Support\Collection;
 
 use BookStack\Actions\View;
 use Illuminate\Support\Collection;
index 1434180d33f09583eab01fa00b87b8b570f07867..7522a894daa71b95bf6a85f806cbf52be6913a92 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Entities\Queries;
+<?php
+
+namespace BookStack\Entities\Queries;
 
 use BookStack\Actions\Favourite;
 use Illuminate\Database\Query\JoinClause;
 
 use BookStack\Actions\Favourite;
 use Illuminate\Database\Query\JoinClause;
index 8b2e70074fe09a3b95c8688b81061f90fef2760c..5699185031b12129de12f622c375f4a48980b4ac 100644 (file)
@@ -2,24 +2,18 @@
 
 namespace BookStack\Entities\Repos;
 
 
 namespace BookStack\Entities\Repos;
 
-use BookStack\Actions\ActivityType;
 use BookStack\Actions\TagRepo;
 use BookStack\Actions\TagRepo;
-use BookStack\Auth\User;
 use BookStack\Entities\Models\Entity;
 use BookStack\Entities\Models\HasCoverImage;
 use BookStack\Exceptions\ImageUploadException;
 use BookStack\Entities\Models\Entity;
 use BookStack\Entities\Models\HasCoverImage;
 use BookStack\Exceptions\ImageUploadException;
-use BookStack\Facades\Activity;
 use BookStack\Uploads\ImageRepo;
 use Illuminate\Http\UploadedFile;
 use BookStack\Uploads\ImageRepo;
 use Illuminate\Http\UploadedFile;
-use Illuminate\Support\Collection;
 
 class BaseRepo
 {
 
 class BaseRepo
 {
-
     protected $tagRepo;
     protected $imageRepo;
 
     protected $tagRepo;
     protected $imageRepo;
 
-
     public function __construct(TagRepo $tagRepo, ImageRepo $imageRepo)
     {
         $this->tagRepo = $tagRepo;
     public function __construct(TagRepo $tagRepo, ImageRepo $imageRepo)
     {
         $this->tagRepo = $tagRepo;
@@ -27,7 +21,7 @@ class BaseRepo
     }
 
     /**
     }
 
     /**
-     * Create a new entity in the system
+     * Create a new entity in the system.
      */
     public function create(Entity $entity, array $input)
     {
      */
     public function create(Entity $entity, array $input)
     {
@@ -35,7 +29,7 @@ class BaseRepo
         $entity->forceFill([
             'created_by' => user()->id,
             'updated_by' => user()->id,
         $entity->forceFill([
             'created_by' => user()->id,
             'updated_by' => user()->id,
-            'owned_by' => user()->id,
+            'owned_by'   => user()->id,
         ]);
         $entity->refreshSlug();
         $entity->save();
         ]);
         $entity->refreshSlug();
         $entity->save();
@@ -72,6 +66,7 @@ class BaseRepo
 
     /**
      * Update the given items' cover image, or clear it.
 
     /**
      * Update the given items' cover image, or clear it.
+     *
      * @throws ImageUploadException
      * @throws \Exception
      */
      * @throws ImageUploadException
      * @throws \Exception
      */
index 27d0b407541d02857d8aec46cadbeb71cf7bc840..a692bbaf75a8bf4dca27a62a8b6c133ecc7437de 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Entities\Repos;
+<?php
+
+namespace BookStack\Entities\Repos;
 
 use BookStack\Actions\ActivityType;
 use BookStack\Actions\TagRepo;
 
 use BookStack\Actions\ActivityType;
 use BookStack\Actions\TagRepo;
@@ -15,7 +17,6 @@ use Illuminate\Support\Collection;
 
 class BookRepo
 {
 
 class BookRepo
 {
-
     protected $baseRepo;
     protected $tagRepo;
     protected $imageRepo;
     protected $baseRepo;
     protected $tagRepo;
     protected $imageRepo;
@@ -84,13 +85,14 @@ class BookRepo
     }
 
     /**
     }
 
     /**
-     * Create a new book in the system
+     * Create a new book in the system.
      */
     public function create(array $input): Book
     {
         $book = new Book();
         $this->baseRepo->create($book, $input);
         Activity::addForEntity($book, ActivityType::BOOK_CREATE);
      */
     public function create(array $input): Book
     {
         $book = new Book();
         $this->baseRepo->create($book, $input);
         Activity::addForEntity($book, ActivityType::BOOK_CREATE);
+
         return $book;
     }
 
         return $book;
     }
 
@@ -101,11 +103,13 @@ class BookRepo
     {
         $this->baseRepo->update($book, $input);
         Activity::addForEntity($book, ActivityType::BOOK_UPDATE);
     {
         $this->baseRepo->update($book, $input);
         Activity::addForEntity($book, ActivityType::BOOK_UPDATE);
+
         return $book;
     }
 
     /**
      * Update the given book's cover image, or clear it.
         return $book;
     }
 
     /**
      * Update the given book's cover image, or clear it.
+     *
      * @throws ImageUploadException
      * @throws Exception
      */
      * @throws ImageUploadException
      * @throws Exception
      */
@@ -116,6 +120,7 @@ class BookRepo
 
     /**
      * Remove a book from the system.
 
     /**
      * Remove a book from the system.
+     *
      * @throws Exception
      */
     public function destroy(Book $book)
      * @throws Exception
      */
     public function destroy(Book $book)
index 649f4b0c461c0b461701bd26508af44fe0ab43c2..3990bfbdcf02f5fc2f74a546f9045d200af1a4ac 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Entities\Repos;
+<?php
+
+namespace BookStack\Entities\Repos;
 
 use BookStack\Actions\ActivityType;
 use BookStack\Entities\Models\Book;
 
 use BookStack\Actions\ActivityType;
 use BookStack\Entities\Models\Book;
@@ -89,6 +91,7 @@ class BookshelfRepo
         $this->baseRepo->create($shelf, $input);
         $this->updateBooks($shelf, $bookIds);
         Activity::addForEntity($shelf, ActivityType::BOOKSHELF_CREATE);
         $this->baseRepo->create($shelf, $input);
         $this->updateBooks($shelf, $bookIds);
         Activity::addForEntity($shelf, ActivityType::BOOKSHELF_CREATE);
+
         return $shelf;
     }
 
         return $shelf;
     }
 
@@ -104,6 +107,7 @@ class BookshelfRepo
         }
 
         Activity::addForEntity($shelf, ActivityType::BOOKSHELF_UPDATE);
         }
 
         Activity::addForEntity($shelf, ActivityType::BOOKSHELF_UPDATE);
+
         return $shelf;
     }
 
         return $shelf;
     }
 
@@ -129,6 +133,7 @@ class BookshelfRepo
 
     /**
      * Update the given shelf cover image, or clear it.
 
     /**
      * Update the given shelf cover image, or clear it.
+     *
      * @throws ImageUploadException
      * @throws Exception
      */
      * @throws ImageUploadException
      * @throws Exception
      */
@@ -164,6 +169,7 @@ class BookshelfRepo
 
     /**
      * Remove a bookshelf from the system.
 
     /**
      * Remove a bookshelf from the system.
+     *
      * @throws Exception
      */
     public function destroy(Bookshelf $shelf)
      * @throws Exception
      */
     public function destroy(Bookshelf $shelf)
index d56874e0d54a9b647ce59f4a84add65fa793f302..68330dd57bf5a02135db0765280fccd730e09bbe 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Entities\Repos;
+<?php
+
+namespace BookStack\Entities\Repos;
 
 use BookStack\Actions\ActivityType;
 use BookStack\Entities\Models\Book;
 
 use BookStack\Actions\ActivityType;
 use BookStack\Entities\Models\Book;
@@ -9,11 +11,9 @@ use BookStack\Exceptions\MoveOperationException;
 use BookStack\Exceptions\NotFoundException;
 use BookStack\Facades\Activity;
 use Exception;
 use BookStack\Exceptions\NotFoundException;
 use BookStack\Facades\Activity;
 use Exception;
-use Illuminate\Support\Collection;
 
 class ChapterRepo
 {
 
 class ChapterRepo
 {
-
     protected $baseRepo;
 
     /**
     protected $baseRepo;
 
     /**
@@ -26,6 +26,7 @@ class ChapterRepo
 
     /**
      * Get a chapter via the slug.
 
     /**
      * Get a chapter via the slug.
+     *
      * @throws NotFoundException
      */
     public function getBySlug(string $bookSlug, string $chapterSlug): Chapter
      * @throws NotFoundException
      */
     public function getBySlug(string $bookSlug, string $chapterSlug): Chapter
@@ -49,6 +50,7 @@ class ChapterRepo
         $chapter->priority = (new BookContents($parentBook))->getLastPriority() + 1;
         $this->baseRepo->create($chapter, $input);
         Activity::addForEntity($chapter, ActivityType::CHAPTER_CREATE);
         $chapter->priority = (new BookContents($parentBook))->getLastPriority() + 1;
         $this->baseRepo->create($chapter, $input);
         Activity::addForEntity($chapter, ActivityType::CHAPTER_CREATE);
+
         return $chapter;
     }
 
         return $chapter;
     }
 
@@ -59,11 +61,13 @@ class ChapterRepo
     {
         $this->baseRepo->update($chapter, $input);
         Activity::addForEntity($chapter, ActivityType::CHAPTER_UPDATE);
     {
         $this->baseRepo->update($chapter, $input);
         Activity::addForEntity($chapter, ActivityType::CHAPTER_UPDATE);
+
         return $chapter;
     }
 
     /**
      * Remove a chapter from the system.
         return $chapter;
     }
 
     /**
      * Remove a chapter from the system.
+     *
      * @throws Exception
      */
     public function destroy(Chapter $chapter)
      * @throws Exception
      */
     public function destroy(Chapter $chapter)
@@ -77,7 +81,8 @@ class ChapterRepo
     /**
      * Move the given chapter into a new parent book.
      * The $parentIdentifier must be a string of the following format:
     /**
      * Move the given chapter into a new parent book.
      * The $parentIdentifier must be a string of the following format:
-     * 'book:<id>' (book:5)
+     * 'book:<id>' (book:5).
+     *
      * @throws MoveOperationException
      */
     public function move(Chapter $chapter, string $parentIdentifier): Book
      * @throws MoveOperationException
      */
     public function move(Chapter $chapter, string $parentIdentifier): Book
index 5eb882a026a3f803369b56b06b6334c46e8773c9..28949b2dd7e3dd35f80d915fb053fd3918e5dfba 100644 (file)
@@ -1,14 +1,16 @@
-<?php namespace BookStack\Entities\Repos;
+<?php
+
+namespace BookStack\Entities\Repos;
 
 use BookStack\Actions\ActivityType;
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Chapter;
 use BookStack\Entities\Models\Entity;
 
 use BookStack\Actions\ActivityType;
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Chapter;
 use BookStack\Entities\Models\Entity;
+use BookStack\Entities\Models\Page;
+use BookStack\Entities\Models\PageRevision;
 use BookStack\Entities\Tools\BookContents;
 use BookStack\Entities\Tools\PageContent;
 use BookStack\Entities\Tools\TrashCan;
 use BookStack\Entities\Tools\BookContents;
 use BookStack\Entities\Tools\PageContent;
 use BookStack\Entities\Tools\TrashCan;
-use BookStack\Entities\Models\Page;
-use BookStack\Entities\Models\PageRevision;
 use BookStack\Exceptions\MoveOperationException;
 use BookStack\Exceptions\NotFoundException;
 use BookStack\Exceptions\PermissionsException;
 use BookStack\Exceptions\MoveOperationException;
 use BookStack\Exceptions\NotFoundException;
 use BookStack\Exceptions\PermissionsException;
@@ -16,11 +18,9 @@ use BookStack\Facades\Activity;
 use Exception;
 use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Pagination\LengthAwarePaginator;
 use Exception;
 use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Pagination\LengthAwarePaginator;
-use Illuminate\Support\Collection;
 
 class PageRepo
 {
 
 class PageRepo
 {
-
     protected $baseRepo;
 
     /**
     protected $baseRepo;
 
     /**
@@ -33,6 +33,7 @@ class PageRepo
 
     /**
      * Get a page by ID.
 
     /**
      * Get a page by ID.
+     *
      * @throws NotFoundException
      */
     public function getById(int $id, array $relations = ['book']): Page
      * @throws NotFoundException
      */
     public function getById(int $id, array $relations = ['book']): Page
@@ -48,6 +49,7 @@ class PageRepo
 
     /**
      * Get a page its book and own slug.
 
     /**
      * Get a page its book and own slug.
+     *
      * @throws NotFoundException
      */
     public function getBySlug(string $bookSlug, string $pageSlug): Page
      * @throws NotFoundException
      */
     public function getBySlug(string $bookSlug, string $pageSlug): Page
@@ -77,6 +79,7 @@ class PageRepo
             ->orderBy('created_at', 'desc')
             ->with('page')
             ->first();
             ->orderBy('created_at', 'desc')
             ->with('page')
             ->first();
+
         return $revision ? $revision->page : null;
     }
 
         return $revision ? $revision->page : null;
     }
 
@@ -119,6 +122,7 @@ class PageRepo
     public function getUserDraft(Page $page): ?PageRevision
     {
         $revision = $this->getUserDraftQuery($page)->first();
     public function getUserDraft(Page $page): ?PageRevision
     {
         $revision = $this->getUserDraftQuery($page)->first();
+
         return $revision;
     }
 
         return $revision;
     }
 
@@ -128,11 +132,11 @@ class PageRepo
     public function getNewDraftPage(Entity $parent)
     {
         $page = (new Page())->forceFill([
     public function getNewDraftPage(Entity $parent)
     {
         $page = (new Page())->forceFill([
-            'name' => trans('entities.pages_initial_name'),
+            'name'       => trans('entities.pages_initial_name'),
             'created_by' => user()->id,
             'created_by' => user()->id,
-            'owned_by' => user()->id,
+            'owned_by'   => user()->id,
             'updated_by' => user()->id,
             'updated_by' => user()->id,
-            'draft' => true,
+            'draft'      => true,
         ]);
 
         if ($parent instanceof Chapter) {
         ]);
 
         if ($parent instanceof Chapter) {
@@ -144,6 +148,7 @@ class PageRepo
 
         $page->save();
         $page->refresh()->rebuildPermissions();
 
         $page->save();
         $page->refresh()->rebuildPermissions();
+
         return $page;
     }
 
         return $page;
     }
 
@@ -166,6 +171,7 @@ class PageRepo
         $draft->refresh();
 
         Activity::addForEntity($draft, ActivityType::PAGE_CREATE);
         $draft->refresh();
 
         Activity::addForEntity($draft, ActivityType::PAGE_CREATE);
+
         return $draft;
     }
 
         return $draft;
     }
 
@@ -190,7 +196,7 @@ class PageRepo
         $this->getUserDraftQuery($page)->delete();
 
         // Save a revision after updating
         $this->getUserDraftQuery($page)->delete();
 
         // Save a revision after updating
-        $summary = trim($input['summary'] ?? "");
+        $summary = trim($input['summary'] ?? '');
         $htmlChanged = isset($input['html']) && $input['html'] !== $oldHtml;
         $nameChanged = isset($input['name']) && $input['name'] !== $oldName;
         $markdownChanged = isset($input['markdown']) && $input['markdown'] !== $oldMarkdown;
         $htmlChanged = isset($input['html']) && $input['html'] !== $oldHtml;
         $nameChanged = isset($input['name']) && $input['name'] !== $oldName;
         $markdownChanged = isset($input['markdown']) && $input['markdown'] !== $oldMarkdown;
@@ -199,6 +205,7 @@ class PageRepo
         }
 
         Activity::addForEntity($page, ActivityType::PAGE_UPDATE);
         }
 
         Activity::addForEntity($page, ActivityType::PAGE_UPDATE);
+
         return $page;
     }
 
         return $page;
     }
 
@@ -234,6 +241,7 @@ class PageRepo
         $revision->save();
 
         $this->deleteOldRevisions($page);
         $revision->save();
 
         $this->deleteOldRevisions($page);
+
         return $revision;
     }
 
         return $revision;
     }
 
@@ -249,6 +257,7 @@ class PageRepo
             }
             $page->fill($input);
             $page->save();
             }
             $page->fill($input);
             $page->save();
+
             return $page;
         }
 
             return $page;
         }
 
@@ -260,11 +269,13 @@ class PageRepo
         }
 
         $draft->save();
         }
 
         $draft->save();
+
         return $draft;
     }
 
     /**
      * Destroy a page from the system.
         return $draft;
     }
 
     /**
      * Destroy a page from the system.
+     *
      * @throws Exception
      */
     public function destroy(Page $page)
      * @throws Exception
      */
     public function destroy(Page $page)
@@ -291,7 +302,7 @@ class PageRepo
         } else {
             $content->setNewHTML($revision->html);
         }
         } else {
             $content->setNewHTML($revision->html);
         }
-        
+
         $page->updated_by = user()->id;
         $page->refreshSlug();
         $page->save();
         $page->updated_by = user()->id;
         $page->refreshSlug();
         $page->save();
@@ -301,13 +312,15 @@ class PageRepo
         $this->savePageRevision($page, $summary);
 
         Activity::addForEntity($page, ActivityType::PAGE_RESTORE);
         $this->savePageRevision($page, $summary);
 
         Activity::addForEntity($page, ActivityType::PAGE_RESTORE);
+
         return $page;
     }
 
     /**
      * Move the given page into a new parent book or chapter.
      * The $parentIdentifier must be a string of the following format:
         return $page;
     }
 
     /**
      * Move the given page into a new parent book or chapter.
      * The $parentIdentifier must be a string of the following format:
-     * 'book:<id>' (book:5)
+     * 'book:<id>' (book:5).
+     *
      * @throws MoveOperationException
      * @throws PermissionsException
      */
      * @throws MoveOperationException
      * @throws PermissionsException
      */
@@ -327,12 +340,14 @@ class PageRepo
         $page->rebuildPermissions();
 
         Activity::addForEntity($page, ActivityType::PAGE_MOVE);
         $page->rebuildPermissions();
 
         Activity::addForEntity($page, ActivityType::PAGE_MOVE);
+
         return $parent;
     }
 
     /**
      * Copy an existing page in the system.
      * Optionally providing a new parent via string identifier and a new name.
         return $parent;
     }
 
     /**
      * Copy an existing page in the system.
      * Optionally providing a new parent via string identifier and a new name.
+     *
      * @throws MoveOperationException
      * @throws PermissionsException
      */
      * @throws MoveOperationException
      * @throws PermissionsException
      */
@@ -369,7 +384,8 @@ class PageRepo
     /**
      * Find a page parent entity via a identifier string in the format:
      * {type}:{id}
     /**
      * Find a page parent entity via a identifier string in the format:
      * {type}:{id}
-     * Example: (book:5)
+     * Example: (book:5).
+     *
      * @throws MoveOperationException
      */
     protected function findParentByIdentifier(string $identifier): ?Entity
      * @throws MoveOperationException
      */
     protected function findParentByIdentifier(string $identifier): ?Entity
@@ -383,6 +399,7 @@ class PageRepo
         }
 
         $parentClass = $entityType === 'book' ? Book::class : Chapter::class;
         }
 
         $parentClass = $entityType === 'book' ? Book::class : Chapter::class;
+
         return $parentClass::visible()->where('id', '=', $entityId)->first();
     }
 
         return $parentClass::visible()->where('id', '=', $entityId)->first();
     }
 
@@ -420,6 +437,7 @@ class PageRepo
         $draft->book_slug = $page->book->slug;
         $draft->created_by = user()->id;
         $draft->type = 'update_draft';
         $draft->book_slug = $page->book->slug;
         $draft->created_by = user()->id;
         $draft->type = 'update_draft';
+
         return $draft;
     }
 
         return $draft;
     }
 
@@ -445,13 +463,14 @@ class PageRepo
     }
 
     /**
     }
 
     /**
-     * Get a new priority for a page
+     * Get a new priority for a page.
      */
     protected function getNewPriority(Page $page): int
     {
         $parent = $page->getParent();
         if ($parent instanceof Chapter) {
             $lastPage = $parent->pages('desc')->first();
      */
     protected function getNewPriority(Page $page): int
     {
         $parent = $page->getParent();
         if ($parent instanceof Chapter) {
             $lastPage = $parent->pages('desc')->first();
+
             return $lastPage ? $lastPage->priority + 1 : 0;
         }
 
             return $lastPage ? $lastPage->priority + 1 : 0;
         }
 
index 71c8f8393a22dff67f95a4ec931ce236d4641b49..af7746e561c135bb85c7d6d1c15892d4864aa420 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Entities\Tools;
+<?php
+
+namespace BookStack\Entities\Tools;
 
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\BookChild;
 
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\BookChild;
@@ -10,7 +12,6 @@ use Illuminate\Support\Collection;
 
 class BookContents
 {
 
 class BookContents
 {
-
     /**
      * @var Book
      */
     /**
      * @var Book
      */
@@ -35,6 +36,7 @@ class BookContents
             ->where('chapter_id', '=', 0)->max('priority');
         $maxChapter = Chapter::visible()->where('book_id', '=', $this->book->id)
             ->max('priority');
             ->where('chapter_id', '=', 0)->max('priority');
         $maxChapter = Chapter::visible()->where('book_id', '=', $this->book->id)
             ->max('priority');
+
         return max($maxChapter, $maxPage, 1);
     }
 
         return max($maxChapter, $maxPage, 1);
     }
 
@@ -83,6 +85,7 @@ class BookContents
             if (isset($entity['draft']) && $entity['draft']) {
                 return -100;
             }
             if (isset($entity['draft']) && $entity['draft']) {
                 return -100;
             }
+
             return $entity['priority'] ?? 0;
         };
     }
             return $entity['priority'] ?? 0;
         };
     }
@@ -110,9 +113,10 @@ class BookContents
      *     +"parentChapter": false (ID of parent chapter, as string, or false)
      *     +"type": "page" (Entity type of item)
      *     +"book": "1" (Id of book to place item in)
      *     +"parentChapter": false (ID of parent chapter, as string, or false)
      *     +"type": "page" (Entity type of item)
      *     +"book": "1" (Id of book to place item in)
-     *   }
+     *   }.
      *
      * Returns a list of books that were involved in the operation.
      *
      * Returns a list of books that were involved in the operation.
+     *
      * @throws SortOperationException
      */
     public function sortUsingMap(Collection $sortMap): Collection
      * @throws SortOperationException
      */
     public function sortUsingMap(Collection $sortMap): Collection
@@ -190,6 +194,7 @@ class BookContents
     /**
      * Get the books involved in a sort.
      * The given sort map should have its models loaded first.
     /**
      * Get the books involved in a sort.
      * The given sort map should have its models loaded first.
+     *
      * @throws SortOperationException
      */
     protected function getBooksInvolvedInSort(Collection $sortMap): Collection
      * @throws SortOperationException
      */
     protected function getBooksInvolvedInSort(Collection $sortMap): Collection
@@ -202,7 +207,7 @@ class BookContents
         $books = Book::hasPermission('update')->whereIn('id', $bookIdsInvolved)->get();
 
         if (count($books) !== count($bookIdsInvolved)) {
         $books = Book::hasPermission('update')->whereIn('id', $bookIdsInvolved)->get();
 
         if (count($books) !== count($bookIdsInvolved)) {
-            throw new SortOperationException("Could not find all books requested in sort operation");
+            throw new SortOperationException('Could not find all books requested in sort operation');
         }
 
         return $books;
         }
 
         return $books;
index 9317b04316b5b4bb4c3d4feac62977e42785b0c3..c299f9c71937cd279182249dbfa9d1aba3a79839 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Entities\Tools;
+<?php
+
+namespace BookStack\Entities\Tools;
 
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Chapter;
 
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Chapter;
@@ -12,7 +14,6 @@ use Throwable;
 
 class ExportFormatter
 {
 
 class ExportFormatter
 {
-
     protected $imageService;
 
     /**
     protected $imageService;
 
     /**
@@ -26,20 +27,23 @@ class ExportFormatter
     /**
      * Convert a page to a self-contained HTML file.
      * Includes required CSS & image content. Images are base64 encoded into the HTML.
     /**
      * Convert a page to a self-contained HTML file.
      * Includes required CSS & image content. Images are base64 encoded into the HTML.
+     *
      * @throws Throwable
      */
     public function pageToContainedHtml(Page $page)
     {
         $page->html = (new PageContent($page))->render();
         $pageHtml = view('pages.export', [
      * @throws Throwable
      */
     public function pageToContainedHtml(Page $page)
     {
         $page->html = (new PageContent($page))->render();
         $pageHtml = view('pages.export', [
-            'page' => $page,
+            'page'   => $page,
             'format' => 'html',
         ])->render();
             'format' => 'html',
         ])->render();
+
         return $this->containHtml($pageHtml);
     }
 
     /**
      * Convert a chapter to a self-contained HTML file.
         return $this->containHtml($pageHtml);
     }
 
     /**
      * Convert a chapter to a self-contained HTML file.
+     *
      * @throws Throwable
      */
     public function chapterToContainedHtml(Chapter $chapter)
      * @throws Throwable
      */
     public function chapterToContainedHtml(Chapter $chapter)
@@ -50,43 +54,49 @@ class ExportFormatter
         });
         $html = view('chapters.export', [
             'chapter' => $chapter,
         });
         $html = view('chapters.export', [
             'chapter' => $chapter,
-            'pages' => $pages,
-            'format' => 'html',
+            'pages'   => $pages,
+            'format'  => 'html',
         ])->render();
         ])->render();
+
         return $this->containHtml($html);
     }
 
     /**
      * Convert a book to a self-contained HTML file.
         return $this->containHtml($html);
     }
 
     /**
      * Convert a book to a self-contained HTML file.
+     *
      * @throws Throwable
      */
     public function bookToContainedHtml(Book $book)
     {
         $bookTree = (new BookContents($book))->getTree(false, true);
         $html = view('books.export', [
      * @throws Throwable
      */
     public function bookToContainedHtml(Book $book)
     {
         $bookTree = (new BookContents($book))->getTree(false, true);
         $html = view('books.export', [
-            'book' => $book,
+            'book'         => $book,
             'bookChildren' => $bookTree,
             'bookChildren' => $bookTree,
-            'format' => 'html',
+            'format'       => 'html',
         ])->render();
         ])->render();
+
         return $this->containHtml($html);
     }
 
     /**
      * Convert a page to a PDF file.
         return $this->containHtml($html);
     }
 
     /**
      * Convert a page to a PDF file.
+     *
      * @throws Throwable
      */
     public function pageToPdf(Page $page)
     {
         $page->html = (new PageContent($page))->render();
         $html = view('pages.export', [
      * @throws Throwable
      */
     public function pageToPdf(Page $page)
     {
         $page->html = (new PageContent($page))->render();
         $html = view('pages.export', [
-            'page' => $page,
+            'page'   => $page,
             'format' => 'pdf',
         ])->render();
             'format' => 'pdf',
         ])->render();
+
         return $this->htmlToPdf($html);
     }
 
     /**
      * Convert a chapter to a PDF file.
         return $this->htmlToPdf($html);
     }
 
     /**
      * Convert a chapter to a PDF file.
+     *
      * @throws Throwable
      */
     public function chapterToPdf(Chapter $chapter)
      * @throws Throwable
      */
     public function chapterToPdf(Chapter $chapter)
@@ -98,8 +108,8 @@ class ExportFormatter
 
         $html = view('chapters.export', [
             'chapter' => $chapter,
 
         $html = view('chapters.export', [
             'chapter' => $chapter,
-            'pages' => $pages,
-            'format' => 'pdf',
+            'pages'   => $pages,
+            'format'  => 'pdf',
         ])->render();
 
         return $this->htmlToPdf($html);
         ])->render();
 
         return $this->htmlToPdf($html);
@@ -107,21 +117,24 @@ class ExportFormatter
 
     /**
      * Convert a book to a PDF file.
 
     /**
      * Convert a book to a PDF file.
+     *
      * @throws Throwable
      */
     public function bookToPdf(Book $book)
     {
         $bookTree = (new BookContents($book))->getTree(false, true);
         $html = view('books.export', [
      * @throws Throwable
      */
     public function bookToPdf(Book $book)
     {
         $bookTree = (new BookContents($book))->getTree(false, true);
         $html = view('books.export', [
-            'book' => $book,
+            'book'         => $book,
             'bookChildren' => $bookTree,
             'bookChildren' => $bookTree,
-            'format' => 'pdf',
+            'format'       => 'pdf',
         ])->render();
         ])->render();
+
         return $this->htmlToPdf($html);
     }
 
     /**
      * Convert normal web-page HTML to a PDF.
         return $this->htmlToPdf($html);
     }
 
     /**
      * Convert normal web-page HTML to a PDF.
+     *
      * @throws Exception
      */
     protected function htmlToPdf(string $html): string
      * @throws Exception
      */
     protected function htmlToPdf(string $html): string
@@ -134,11 +147,13 @@ class ExportFormatter
         } else {
             $pdf = DomPDF::loadHTML($containedHtml);
         }
         } else {
             $pdf = DomPDF::loadHTML($containedHtml);
         }
+
         return $pdf->output();
     }
 
     /**
      * Bundle of the contents of a html file to be self-contained.
         return $pdf->output();
     }
 
     /**
      * Bundle of the contents of a html file to be self-contained.
+     *
      * @throws Exception
      */
     protected function containHtml(string $htmlContent): string
      * @throws Exception
      */
     protected function containHtml(string $htmlContent): string
@@ -195,6 +210,7 @@ class ExportFormatter
         $text = html_entity_decode($text);
         // Add title
         $text = $page->name . "\n\n" . $text;
         $text = html_entity_decode($text);
         // Add title
         $text = $page->name . "\n\n" . $text;
+
         return $text;
     }
 
         return $text;
     }
 
@@ -208,6 +224,7 @@ class ExportFormatter
         foreach ($chapter->getVisiblePages() as $page) {
             $text .= $this->pageToPlainText($page);
         }
         foreach ($chapter->getVisiblePages() as $page) {
             $text .= $this->pageToPlainText($page);
         }
+
         return $text;
     }
 
         return $text;
     }
 
@@ -225,6 +242,7 @@ class ExportFormatter
                 $text .= $this->pageToPlainText($bookChild);
             }
         }
                 $text .= $this->pageToPlainText($bookChild);
             }
         }
+
         return $text;
     }
 
         return $text;
     }
 
@@ -234,10 +252,10 @@ class ExportFormatter
     public function pageToMarkdown(Page $page): string
     {
         if ($page->markdown) {
     public function pageToMarkdown(Page $page): string
     {
         if ($page->markdown) {
-            return "# " . $page->name . "\n\n" . $page->markdown;
+            return '# ' . $page->name . "\n\n" . $page->markdown;
         }
 
         }
 
-        return "# " . $page->name . "\n\n" . (new HtmlToMarkdown($page->html))->convert();
+        return '# ' . $page->name . "\n\n" . (new HtmlToMarkdown($page->html))->convert();
     }
 
     /**
     }
 
     /**
@@ -245,11 +263,12 @@ class ExportFormatter
      */
     public function chapterToMarkdown(Chapter $chapter): string
     {
      */
     public function chapterToMarkdown(Chapter $chapter): string
     {
-        $text = "# " . $chapter->name . "\n\n";
+        $text = '# ' . $chapter->name . "\n\n";
         $text .= $chapter->description . "\n\n";
         foreach ($chapter->pages as $page) {
             $text .= $this->pageToMarkdown($page) . "\n\n";
         }
         $text .= $chapter->description . "\n\n";
         foreach ($chapter->pages as $page) {
             $text .= $this->pageToMarkdown($page) . "\n\n";
         }
+
         return $text;
     }
 
         return $text;
     }
 
@@ -259,7 +278,7 @@ class ExportFormatter
     public function bookToMarkdown(Book $book): string
     {
         $bookTree = (new BookContents($book))->getTree(false, true);
     public function bookToMarkdown(Book $book): string
     {
         $bookTree = (new BookContents($book))->getTree(false, true);
-        $text = "# " . $book->name . "\n\n";
+        $text = '# ' . $book->name . "\n\n";
         foreach ($bookTree as $bookChild) {
             if ($bookChild instanceof Chapter) {
                 $text .= $this->chapterToMarkdown($bookChild);
         foreach ($bookTree as $bookChild) {
             if ($bookChild instanceof Chapter) {
                 $text .= $this->chapterToMarkdown($bookChild);
@@ -267,6 +286,7 @@ class ExportFormatter
                 $text .= $this->pageToMarkdown($bookChild);
             }
         }
                 $text .= $this->pageToMarkdown($bookChild);
             }
         }
+
         return $text;
     }
 }
         return $text;
     }
 }
index 1af7702613d3ff18d4ad2c867667be1a51d56846..bd493aa03670b50dbcb5027676762b47e6086b5b 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Entities\Tools\Markdown;
+<?php
+
+namespace BookStack\Entities\Tools\Markdown;
 
 use League\HTMLToMarkdown\Converter\ParagraphConverter;
 use League\HTMLToMarkdown\ElementInterface;
 
 use League\HTMLToMarkdown\Converter\ParagraphConverter;
 use League\HTMLToMarkdown\ElementInterface;
index d4984ef081dd4965e23e697a7ced6dace0e67c37..a8ccfc4f9bfc116933d80f2486fc9eedd889bb46 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Entities\Tools\Markdown;
+<?php
+
+namespace BookStack\Entities\Tools\Markdown;
 
 use League\CommonMark\ConfigurableEnvironmentInterface;
 use League\CommonMark\Extension\ExtensionInterface;
 
 use League\CommonMark\ConfigurableEnvironmentInterface;
 use League\CommonMark\Extension\ExtensionInterface;
@@ -7,7 +9,6 @@ use League\CommonMark\Extension\Strikethrough\StrikethroughDelimiterProcessor;
 
 class CustomStrikeThroughExtension implements ExtensionInterface
 {
 
 class CustomStrikeThroughExtension implements ExtensionInterface
 {
-
     public function register(ConfigurableEnvironmentInterface $environment)
     {
         $environment->addDelimiterProcessor(new StrikethroughDelimiterProcessor());
     public function register(ConfigurableEnvironmentInterface $environment)
     {
         $environment->addDelimiterProcessor(new StrikethroughDelimiterProcessor());
index 7de95c2637b057ecfcaca84864e3b84f4b873270..ca9f434af0fae8d0a318e73d6e8e9bcac17892b2 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Entities\Tools\Markdown;
+<?php
+
+namespace BookStack\Entities\Tools\Markdown;
 
 use League\CommonMark\ElementRendererInterface;
 use League\CommonMark\Extension\Strikethrough\Strikethrough;
 
 use League\CommonMark\ElementRendererInterface;
 use League\CommonMark\Extension\Strikethrough\Strikethrough;
index c56119fe19cec8eb4437fdf2321236067980388f..e8804690c652a4e98acda01c80ab7eef33551a39 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Entities\Tools\Markdown;
+<?php
+
+namespace BookStack\Entities\Tools\Markdown;
 
 use League\HTMLToMarkdown\Converter\BlockquoteConverter;
 use League\HTMLToMarkdown\Converter\CodeConverter;
 
 use League\HTMLToMarkdown\Converter\BlockquoteConverter;
 use League\HTMLToMarkdown\Converter\CodeConverter;
@@ -27,12 +29,13 @@ class HtmlToMarkdown
     }
 
     /**
     }
 
     /**
-     * Run the conversion
+     * Run the conversion.
      */
     public function convert(): string
     {
         $converter = new HtmlConverter($this->getConverterEnvironment());
         $html = $this->prepareHtml($this->html);
      */
     public function convert(): string
     {
         $converter = new HtmlConverter($this->getConverterEnvironment());
         $html = $this->prepareHtml($this->html);
+
         return $converter->convert($html);
     }
 
         return $converter->convert($html);
     }
 
@@ -54,19 +57,19 @@ class HtmlToMarkdown
     protected function getConverterEnvironment(): Environment
     {
         $environment = new Environment([
     protected function getConverterEnvironment(): Environment
     {
         $environment = new Environment([
-            'header_style' => 'atx', // Set to 'atx' to output H1 and H2 headers as # Header1 and ## Header2
-            'suppress_errors' => true, // Set to false to show warnings when loading malformed HTML
-            'strip_tags' => false, // Set to true to strip tags that don't have markdown equivalents. N.B. Strips tags, not their content. Useful to clean MS Word HTML output.
+            'header_style'            => 'atx', // Set to 'atx' to output H1 and H2 headers as # Header1 and ## Header2
+            'suppress_errors'         => true, // Set to false to show warnings when loading malformed HTML
+            'strip_tags'              => false, // Set to true to strip tags that don't have markdown equivalents. N.B. Strips tags, not their content. Useful to clean MS Word HTML output.
             'strip_placeholder_links' => false, // Set to true to remove <a> that doesn't have href.
             'strip_placeholder_links' => false, // Set to true to remove <a> that doesn't have href.
-            'bold_style' => '**', // DEPRECATED: Set to '__' if you prefer the underlined style
-            'italic_style' => '*', // DEPRECATED: Set to '_' if you prefer the underlined style
-            'remove_nodes' => '', // space-separated list of dom nodes that should be removed. example: 'meta style script'
-            'hard_break' => false, // Set to true to turn <br> into `\n` instead of `  \n`
-            'list_item_style' => '-', // Set the default character for each <li> in a <ul>. Can be '-', '*', or '+'
-            'preserve_comments' => false, // Set to true to preserve comments, or set to an array of strings to preserve specific comments
-            'use_autolinks' => false, // Set to true to use simple link syntax if possible. Will always use []() if set to false
-            'table_pipe_escape' => '\|', // Replacement string for pipe characters inside markdown table cells
-            'table_caption_side' => 'top', // Set to 'top' or 'bottom' to show <caption> content before or after table, null to suppress
+            'bold_style'              => '**', // DEPRECATED: Set to '__' if you prefer the underlined style
+            'italic_style'            => '*', // DEPRECATED: Set to '_' if you prefer the underlined style
+            'remove_nodes'            => '', // space-separated list of dom nodes that should be removed. example: 'meta style script'
+            'hard_break'              => false, // Set to true to turn <br> into `\n` instead of `  \n`
+            'list_item_style'         => '-', // Set the default character for each <li> in a <ul>. Can be '-', '*', or '+'
+            'preserve_comments'       => false, // Set to true to preserve comments, or set to an array of strings to preserve specific comments
+            'use_autolinks'           => false, // Set to true to use simple link syntax if possible. Will always use []() if set to false
+            'table_pipe_escape'       => '\|', // Replacement string for pipe characters inside markdown table cells
+            'table_caption_side'      => 'top', // Set to 'top' or 'bottom' to show <caption> content before or after table, null to suppress
         ]);
 
         $environment->addConverter(new BlockquoteConverter());
         ]);
 
         $environment->addConverter(new BlockquoteConverter());
index bfb0f4a9d017791cc5ae9963e303cca18b7e339f..f70abd9b6fb37b40d4522300d32b90b9d3ac3a83 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Entities\Tools;
+<?php
+
+namespace BookStack\Entities\Tools;
 
 use BookStack\Entities\Models\BookChild;
 use BookStack\Entities\Models\Entity;
 
 use BookStack\Entities\Models\BookChild;
 use BookStack\Entities\Models\Entity;
@@ -48,6 +50,7 @@ class NextPreviousContentLocator
             return get_class($entity) === get_class($this->relativeBookItem)
                 && $entity->id === $this->relativeBookItem->id;
         });
             return get_class($entity) === get_class($this->relativeBookItem)
                 && $entity->id === $this->relativeBookItem->id;
         });
+
         return $index === false ? null : $index;
     }
 
         return $index === false ? null : $index;
     }
 
@@ -64,6 +67,7 @@ class NextPreviousContentLocator
             $childPages = $item->visible_pages ?? [];
             $flatOrdered = $flatOrdered->concat($childPages);
         }
             $childPages = $item->visible_pages ?? [];
             $flatOrdered = $flatOrdered->concat($childPages);
         }
+
         return $flatOrdered;
     }
 }
         return $flatOrdered;
     }
 }
index 381ef172b47105939740a31ae807a7fbff865f10..9a53e2d2458f88646f4ab941cb001bf6b2ea516b 100644 (file)
@@ -1,12 +1,14 @@
-<?php namespace BookStack\Entities\Tools;
+<?php
+
+namespace BookStack\Entities\Tools;
 
 use BookStack\Entities\Models\Page;
 use BookStack\Entities\Tools\Markdown\CustomStrikeThroughExtension;
 use BookStack\Exceptions\ImageUploadException;
 use BookStack\Facades\Theme;
 use BookStack\Theming\ThemeEvents;
 
 use BookStack\Entities\Models\Page;
 use BookStack\Entities\Tools\Markdown\CustomStrikeThroughExtension;
 use BookStack\Exceptions\ImageUploadException;
 use BookStack\Facades\Theme;
 use BookStack\Theming\ThemeEvents;
-use BookStack\Util\HtmlContentFilter;
 use BookStack\Uploads\ImageRepo;
 use BookStack\Uploads\ImageRepo;
+use BookStack\Util\HtmlContentFilter;
 use DOMDocument;
 use DOMNodeList;
 use DOMXPath;
 use DOMDocument;
 use DOMNodeList;
 use DOMXPath;
@@ -18,7 +20,6 @@ use League\CommonMark\Extension\TaskList\TaskListExtension;
 
 class PageContent
 {
 
 class PageContent
 {
-
     protected $page;
 
     /**
     protected $page;
 
     /**
@@ -62,11 +63,12 @@ class PageContent
         $environment->addExtension(new CustomStrikeThroughExtension());
         $environment = Theme::dispatch(ThemeEvents::COMMONMARK_ENVIRONMENT_CONFIGURE, $environment) ?? $environment;
         $converter = new CommonMarkConverter([], $environment);
         $environment->addExtension(new CustomStrikeThroughExtension());
         $environment = Theme::dispatch(ThemeEvents::COMMONMARK_ENVIRONMENT_CONFIGURE, $environment) ?? $environment;
         $converter = new CommonMarkConverter([], $environment);
+
         return $converter->convertToHtml($markdown);
     }
 
     /**
         return $converter->convertToHtml($markdown);
     }
 
     /**
-     * Convert all base64 image data to saved images
+     * Convert all base64 image data to saved images.
      */
     public function extractBase64Images(Page $page, string $htmlText): string
     {
      */
     public function extractBase64Images(Page $page, string $htmlText): string
     {
@@ -97,6 +99,7 @@ class PageContent
 
             // Save image from data with a random name
             $imageName = 'embedded-image-' . Str::random(8) . '.' . $extension;
 
             // Save image from data with a random name
             $imageName = 'embedded-image-' . Str::random(8) . '.' . $extension;
+
             try {
                 $image = $imageRepo->saveNewFromData($imageName, base64_decode($base64ImageData), 'gallery', $page->id);
                 $imageNode->setAttribute('src', $image->url);
             try {
                 $image = $imageRepo->saveNewFromData($imageName, base64_decode($base64ImageData), 'gallery', $page->id);
                 $imageNode->setAttribute('src', $image->url);
@@ -171,7 +174,7 @@ class PageContent
     /**
      * Set a unique id on the given DOMElement.
      * A map for existing ID's should be passed in to check for current existence.
     /**
      * Set a unique id on the given DOMElement.
      * A map for existing ID's should be passed in to check for current existence.
-     * Returns a pair of strings in the format [old_id, new_id]
+     * Returns a pair of strings in the format [old_id, new_id].
      */
     protected function setUniqueId(\DOMNode $element, array &$idMap): array
     {
      */
     protected function setUniqueId(\DOMNode $element, array &$idMap): array
     {
@@ -183,6 +186,7 @@ class PageContent
         $existingId = $element->getAttribute('id');
         if (strpos($existingId, 'bkmrk') === 0 && !isset($idMap[$existingId])) {
             $idMap[$existingId] = true;
         $existingId = $element->getAttribute('id');
         if (strpos($existingId, 'bkmrk') === 0 && !isset($idMap[$existingId])) {
             $idMap[$existingId] = true;
+
             return [$existingId, $existingId];
         }
 
             return [$existingId, $existingId];
         }
 
@@ -200,6 +204,7 @@ class PageContent
 
         $element->setAttribute('id', $newId);
         $idMap[$newId] = true;
 
         $element->setAttribute('id', $newId);
         $idMap[$newId] = true;
+
         return [$existingId, $newId];
     }
 
         return [$existingId, $newId];
     }
 
@@ -209,11 +214,12 @@ class PageContent
     protected function toPlainText(): string
     {
         $html = $this->render(true);
     protected function toPlainText(): string
     {
         $html = $this->render(true);
+
         return html_entity_decode(strip_tags($html));
     }
 
     /**
         return html_entity_decode(strip_tags($html));
     }
 
     /**
-     * Render the page for viewing
+     * Render the page for viewing.
      */
     public function render(bool $blankIncludes = false): string
     {
      */
     public function render(bool $blankIncludes = false): string
     {
@@ -233,7 +239,7 @@ class PageContent
     }
 
     /**
     }
 
     /**
-     * Parse the headers on the page to get a navigation menu
+     * Parse the headers on the page to get a navigation menu.
      */
     public function getNavigation(string $htmlContent): array
     {
      */
     public function getNavigation(string $htmlContent): array
     {
@@ -243,7 +249,7 @@ class PageContent
 
         $doc = $this->loadDocumentFromHtml($htmlContent);
         $xPath = new DOMXPath($doc);
 
         $doc = $this->loadDocumentFromHtml($htmlContent);
         $xPath = new DOMXPath($doc);
-        $headers = $xPath->query("//h1|//h2|//h3|//h4|//h5|//h6");
+        $headers = $xPath->query('//h1|//h2|//h3|//h4|//h5|//h6');
 
         return $headers ? $this->headerNodesToLevelList($headers) : [];
     }
 
         return $headers ? $this->headerNodesToLevelList($headers) : [];
     }
@@ -260,9 +266,9 @@ class PageContent
 
             return [
                 'nodeName' => strtolower($header->nodeName),
 
             return [
                 'nodeName' => strtolower($header->nodeName),
-                'level' => intval(str_replace('h', '', $header->nodeName)),
-                'link' => '#' . $header->getAttribute('id'),
-                'text' => $text,
+                'level'    => intval(str_replace('h', '', $header->nodeName)),
+                'link'     => '#' . $header->getAttribute('id'),
+                'text'     => $text,
             ];
         })->filter(function ($header) {
             return mb_strlen($header['text']) > 0;
             ];
         })->filter(function ($header) {
             return mb_strlen($header['text']) > 0;
@@ -272,6 +278,7 @@ class PageContent
         $levelChange = ($tree->pluck('level')->min() - 1);
         $tree = $tree->map(function ($header) use ($levelChange) {
             $header['level'] -= ($levelChange);
         $levelChange = ($tree->pluck('level')->min() - 1);
         $tree = $tree->map(function ($header) use ($levelChange) {
             $header['level'] -= ($levelChange);
+
             return $header;
         });
 
             return $header;
         });
 
@@ -325,7 +332,6 @@ class PageContent
         return $html;
     }
 
         return $html;
     }
 
-
     /**
      * Fetch the content from a specific section of the given page.
      */
     /**
      * Fetch the content from a specific section of the given page.
      */
@@ -365,6 +371,7 @@ class PageContent
         $doc = new DOMDocument();
         $html = '<body>' . $html . '</body>';
         $doc->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'));
         $doc = new DOMDocument();
         $html = '<body>' . $html . '</body>';
         $doc->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'));
+
         return $doc;
     }
 }
         return $doc;
     }
 }
index 79de5c827987e8d1f9a4041d70d2598839c2c87c..a88dea8307767b2afe5a770f30f60296271634e0 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Entities\Tools;
+<?php
+
+namespace BookStack\Entities\Tools;
 
 use BookStack\Entities\Models\Page;
 use BookStack\Entities\Models\PageRevision;
 
 use BookStack\Entities\Models\Page;
 use BookStack\Entities\Models\PageRevision;
@@ -7,7 +9,6 @@ use Illuminate\Database\Eloquent\Builder;
 
 class PageEditActivity
 {
 
 class PageEditActivity
 {
-
     protected $page;
 
     /**
     protected $page;
 
     /**
@@ -20,6 +21,7 @@ class PageEditActivity
 
     /**
      * Check if there's active editing being performed on this page.
 
     /**
      * Check if there's active editing being performed on this page.
+     *
      * @return bool
      */
     public function hasActiveEditing(): bool
      * @return bool
      */
     public function hasActiveEditing(): bool
@@ -35,14 +37,17 @@ class PageEditActivity
         $pageDraftEdits = $this->activePageEditingQuery(60)->get();
         $count = $pageDraftEdits->count();
 
         $pageDraftEdits = $this->activePageEditingQuery(60)->get();
         $count = $pageDraftEdits->count();
 
-        $userMessage = $count > 1 ? trans('entities.pages_draft_edit_active.start_a', ['count' => $count]): trans('entities.pages_draft_edit_active.start_b', ['userName' => $pageDraftEdits->first()->createdBy->name]);
+        $userMessage = $count > 1 ? trans('entities.pages_draft_edit_active.start_a', ['count' => $count]) : trans('entities.pages_draft_edit_active.start_b', ['userName' => $pageDraftEdits->first()->createdBy->name]);
         $timeMessage = trans('entities.pages_draft_edit_active.time_b', ['minCount'=> 60]);
         $timeMessage = trans('entities.pages_draft_edit_active.time_b', ['minCount'=> 60]);
+
         return trans('entities.pages_draft_edit_active.message', ['start' => $userMessage, 'time' => $timeMessage]);
     }
 
     /**
      * Get the message to show when the user will be editing one of their drafts.
         return trans('entities.pages_draft_edit_active.message', ['start' => $userMessage, 'time' => $timeMessage]);
     }
 
     /**
      * Get the message to show when the user will be editing one of their drafts.
+     *
      * @param PageRevision $draft
      * @param PageRevision $draft
+     *
      * @return string
      */
     public function getEditingActiveDraftMessage(PageRevision $draft): string
      * @return string
      */
     public function getEditingActiveDraftMessage(PageRevision $draft): string
@@ -51,6 +56,7 @@ class PageEditActivity
         if ($draft->page->updated_at->timestamp <= $draft->updated_at->timestamp) {
             return $message;
         }
         if ($draft->page->updated_at->timestamp <= $draft->updated_at->timestamp) {
             return $message;
         }
+
         return $message . "\n" . trans('entities.pages_draft_edited_notification');
     }
 
         return $message . "\n" . trans('entities.pages_draft_edited_notification');
     }
 
index 8a27ce75b6f2722aace9c279dda670267db03804..4e8351776d89a041e640e5a24b4a73d6da644d0f 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Entities\Tools;
+<?php
+
+namespace BookStack\Entities\Tools;
 
 use BookStack\Actions\ActivityType;
 use BookStack\Auth\User;
 
 use BookStack\Actions\ActivityType;
 use BookStack\Auth\User;
@@ -9,7 +11,6 @@ use Illuminate\Support\Collection;
 
 class PermissionsUpdater
 {
 
 class PermissionsUpdater
 {
-
     /**
      * Update an entities permissions from a permission form submit request.
      */
     /**
      * Update an entities permissions from a permission form submit request.
      */
@@ -60,8 +61,8 @@ class PermissionsUpdater
             return collect($restrictions)->keys()->map(function ($action) use ($roleId) {
                 return [
                     'role_id' => $roleId,
             return collect($restrictions)->keys()->map(function ($action) use ($roleId) {
                 return [
                     'role_id' => $roleId,
-                    'action' => strtolower($action),
-                ] ;
+                    'action'  => strtolower($action),
+                ];
             });
         });
     }
             });
         });
     }
index 81a5022ce33c4f5ccc87ac6902305bcac0c65fac..cc0b32d6a00f1437ce2845b3f1e107aae663f39f 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Entities\Tools;
+<?php
+
+namespace BookStack\Entities\Tools;
 
 use BookStack\Entities\EntityProvider;
 use BookStack\Entities\Models\Entity;
 
 use BookStack\Entities\EntityProvider;
 use BookStack\Entities\Models\Entity;
@@ -17,14 +19,12 @@ class SearchIndex
      */
     protected $entityProvider;
 
      */
     protected $entityProvider;
 
-
     public function __construct(SearchTerm $searchTerm, EntityProvider $entityProvider)
     {
         $this->searchTerm = $searchTerm;
         $this->entityProvider = $entityProvider;
     }
 
     public function __construct(SearchTerm $searchTerm, EntityProvider $entityProvider)
     {
         $this->searchTerm = $searchTerm;
         $this->entityProvider = $entityProvider;
     }
 
-
     /**
      * Index the given entity.
      */
     /**
      * Index the given entity.
      */
@@ -42,7 +42,8 @@ class SearchIndex
     }
 
     /**
     }
 
     /**
-     * Index multiple Entities at once
+     * Index multiple Entities at once.
+     *
      * @param Entity[] $entities
      */
     protected function indexEntities(array $entities)
      * @param Entity[] $entities
      */
     protected function indexEntities(array $entities)
@@ -110,8 +111,8 @@ class SearchIndex
         $terms = [];
         foreach ($tokenMap as $token => $count) {
             $terms[] = [
         $terms = [];
         foreach ($tokenMap as $token => $count) {
             $terms[] = [
-                'term' => $token,
-                'score' => $count * $scoreAdjustment
+                'term'  => $token,
+                'score' => $count * $scoreAdjustment,
             ];
         }
 
             ];
         }
 
index 6c03c57a6105ce7a36e4c311e2b2f75ba3b13149..7913e096979e63174bfe6a36e3e104e31f8c9776 100644 (file)
@@ -1,10 +1,11 @@
-<?php namespace BookStack\Entities\Tools;
+<?php
+
+namespace BookStack\Entities\Tools;
 
 use Illuminate\Http\Request;
 
 class SearchOptions
 {
 
 use Illuminate\Http\Request;
 
 class SearchOptions
 {
-
     /**
      * @var array
      */
     /**
      * @var array
      */
@@ -35,6 +36,7 @@ class SearchOptions
         foreach ($decoded as $type => $value) {
             $instance->$type = $value;
         }
         foreach ($decoded as $type => $value) {
             $instance->$type = $value;
         }
+
         return $instance;
     }
 
         return $instance;
     }
 
@@ -67,6 +69,7 @@ class SearchOptions
         if (isset($inputs['types']) && count($inputs['types']) < 4) {
             $instance->filters['type'] = implode('|', $inputs['types']);
         }
         if (isset($inputs['types']) && count($inputs['types']) < 4) {
             $instance->filters['type'] = implode('|', $inputs['types']);
         }
+
         return $instance;
     }
 
         return $instance;
     }
 
@@ -77,15 +80,15 @@ class SearchOptions
     {
         $terms = [
             'searches' => [],
     {
         $terms = [
             'searches' => [],
-            'exacts' => [],
-            'tags' => [],
-            'filters' => []
+            'exacts'   => [],
+            'tags'     => [],
+            'filters'  => [],
         ];
 
         $patterns = [
         ];
 
         $patterns = [
-            'exacts' => '/"(.*?)"/',
-            'tags' => '/\[(.*?)\]/',
-            'filters' => '/\{(.*?)\}/'
+            'exacts'  => '/"(.*?)"/',
+            'tags'    => '/\[(.*?)\]/',
+            'filters' => '/\{(.*?)\}/',
         ];
 
         // Parse special terms
         ];
 
         // Parse special terms
index fc127f9068a49075d8cd14c2ad0e87968f96dd5b..8e18408bd70b10864dbaea09fac3f8c902cd638c 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Entities\Tools;
+<?php
+
+namespace BookStack\Entities\Tools;
 
 use BookStack\Auth\Permissions\PermissionService;
 use BookStack\Auth\User;
 
 use BookStack\Auth\Permissions\PermissionService;
 use BookStack\Auth\User;
@@ -13,7 +15,6 @@ use Illuminate\Support\Str;
 
 class SearchRunner
 {
 
 class SearchRunner
 {
-
     /**
      * @var EntityProvider
      */
     /**
      * @var EntityProvider
      */
@@ -29,14 +30,13 @@ class SearchRunner
      */
     protected $permissionService;
 
      */
     protected $permissionService;
 
-
     /**
     /**
-     * Acceptable operators to be used in a query
+     * Acceptable operators to be used in a query.
+     *
      * @var array
      */
     protected $queryOperators = ['<=', '>=', '=', '<', '>', 'like', '!='];
 
      * @var array
      */
     protected $queryOperators = ['<=', '>=', '=', '<', '>', 'like', '!='];
 
-
     public function __construct(EntityProvider $entityProvider, Connection $db, PermissionService $permissionService)
     {
         $this->entityProvider = $entityProvider;
     public function __construct(EntityProvider $entityProvider, Connection $db, PermissionService $permissionService)
     {
         $this->entityProvider = $entityProvider;
@@ -56,7 +56,7 @@ class SearchRunner
 
         if ($entityType !== 'all') {
             $entityTypesToSearch = $entityType;
 
         if ($entityType !== 'all') {
             $entityTypesToSearch = $entityType;
-        } else if (isset($searchOpts->filters['type'])) {
+        } elseif (isset($searchOpts->filters['type'])) {
             $entityTypesToSearch = explode('|', $searchOpts->filters['type']);
         }
 
             $entityTypesToSearch = explode('|', $searchOpts->filters['type']);
         }
 
@@ -78,16 +78,15 @@ class SearchRunner
         }
 
         return [
         }
 
         return [
-            'total' => $total,
-            'count' => count($results),
+            'total'    => $total,
+            'count'    => count($results),
             'has_more' => $hasMore,
             'has_more' => $hasMore,
-            'results' => $results->sortByDesc('score')->values(),
+            'results'  => $results->sortByDesc('score')->values(),
         ];
     }
 
         ];
     }
 
-
     /**
     /**
-     * Search a book for entities
+     * Search a book for entities.
      */
     public function searchBook(int $bookId, string $searchString): Collection
     {
      */
     public function searchBook(int $bookId, string $searchString): Collection
     {
@@ -108,12 +107,13 @@ class SearchRunner
     }
 
     /**
     }
 
     /**
-     * Search a chapter for entities
+     * Search a chapter for entities.
      */
     public function searchChapter(int $chapterId, string $searchString): Collection
     {
         $opts = SearchOptions::fromString($searchString);
         $pages = $this->buildEntitySearchQuery($opts, 'page')->where('chapter_id', '=', $chapterId)->take(20)->get();
      */
     public function searchChapter(int $chapterId, string $searchString): Collection
     {
         $opts = SearchOptions::fromString($searchString);
         $pages = $this->buildEntitySearchQuery($opts, 'page')->where('chapter_id', '=', $chapterId)->take(20)->get();
+
         return $pages->sortByDesc('score');
     }
 
         return $pages->sortByDesc('score');
     }
 
@@ -121,6 +121,7 @@ class SearchRunner
      * Search across a particular entity type.
      * Setting getCount = true will return the total
      * matching instead of the items themselves.
      * Search across a particular entity type.
      * Setting getCount = true will return the total
      * matching instead of the items themselves.
+     *
      * @return \Illuminate\Database\Eloquent\Collection|int|static[]
      */
     protected function searchEntityTable(SearchOptions $searchOpts, string $entityType = 'page', int $page = 1, int $count = 20, string $action = 'view', bool $getCount = false)
      * @return \Illuminate\Database\Eloquent\Collection|int|static[]
      */
     protected function searchEntityTable(SearchOptions $searchOpts, string $entityType = 'page', int $page = 1, int $count = 20, string $action = 'view', bool $getCount = false)
@@ -130,12 +131,13 @@ class SearchRunner
             return $query->count();
         }
 
             return $query->count();
         }
 
-        $query = $query->skip(($page-1) * $count)->take($count);
+        $query = $query->skip(($page - 1) * $count)->take($count);
+
         return $query->get();
     }
 
     /**
         return $query->get();
     }
 
     /**
-     * Create a search query for an entity
+     * Create a search query for an entity.
      */
     protected function buildEntitySearchQuery(SearchOptions $searchOpts, string $entityType = 'page', string $action = 'view'): EloquentBuilder
     {
      */
     protected function buildEntitySearchQuery(SearchOptions $searchOpts, string $entityType = 'page', string $action = 'view'): EloquentBuilder
     {
@@ -149,20 +151,20 @@ class SearchRunner
             $subQuery->where('entity_type', '=', $entity->getMorphClass());
             $subQuery->where(function (Builder $query) use ($searchOpts) {
                 foreach ($searchOpts->searches as $inputTerm) {
             $subQuery->where('entity_type', '=', $entity->getMorphClass());
             $subQuery->where(function (Builder $query) use ($searchOpts) {
                 foreach ($searchOpts->searches as $inputTerm) {
-                    $query->orWhere('term', 'like', $inputTerm .'%');
+                    $query->orWhere('term', 'like', $inputTerm . '%');
                 }
             })->groupBy('entity_type', 'entity_id');
             $entitySelect->join($this->db->raw('(' . $subQuery->toSql() . ') as s'), function (JoinClause $join) {
                 $join->on('id', '=', 'entity_id');
                 }
             })->groupBy('entity_type', 'entity_id');
             $entitySelect->join($this->db->raw('(' . $subQuery->toSql() . ') as s'), function (JoinClause $join) {
                 $join->on('id', '=', 'entity_id');
-            })->selectRaw($entity->getTable().'.*, s.score')->orderBy('score', 'desc');
+            })->selectRaw($entity->getTable() . '.*, s.score')->orderBy('score', 'desc');
             $entitySelect->mergeBindings($subQuery);
         }
 
         // Handle exact term matching
         foreach ($searchOpts->exacts as $inputTerm) {
             $entitySelect->where(function (EloquentBuilder $query) use ($inputTerm, $entity) {
             $entitySelect->mergeBindings($subQuery);
         }
 
         // Handle exact term matching
         foreach ($searchOpts->exacts as $inputTerm) {
             $entitySelect->where(function (EloquentBuilder $query) use ($inputTerm, $entity) {
-                $query->where('name', 'like', '%'.$inputTerm .'%')
-                    ->orWhere($entity->textField, 'like', '%'.$inputTerm .'%');
+                $query->where('name', 'like', '%' . $inputTerm . '%')
+                    ->orWhere($entity->textField, 'like', '%' . $inputTerm . '%');
             });
         }
 
             });
         }
 
@@ -191,6 +193,7 @@ class SearchRunner
         foreach ($this->queryOperators as $operator) {
             $escapedOperators[] = preg_quote($operator);
         }
         foreach ($this->queryOperators as $operator) {
             $escapedOperators[] = preg_quote($operator);
         }
+
         return join('|', $escapedOperators);
     }
 
         return join('|', $escapedOperators);
     }
 
@@ -199,7 +202,7 @@ class SearchRunner
      */
     protected function applyTagSearch(EloquentBuilder $query, string $tagTerm): EloquentBuilder
     {
      */
     protected function applyTagSearch(EloquentBuilder $query, string $tagTerm): EloquentBuilder
     {
-        preg_match("/^(.*?)((".$this->getRegexEscapedOperators().")(.*?))?$/", $tagTerm, $tagSplit);
+        preg_match('/^(.*?)((' . $this->getRegexEscapedOperators() . ')(.*?))?$/', $tagTerm, $tagSplit);
         $query->whereHas('tags', function (EloquentBuilder $query) use ($tagSplit) {
             $tagName = $tagSplit[1];
             $tagOperator = count($tagSplit) > 2 ? $tagSplit[3] : '';
         $query->whereHas('tags', function (EloquentBuilder $query) use ($tagSplit) {
             $tagName = $tagSplit[1];
             $tagOperator = count($tagSplit) > 2 ? $tagSplit[3] : '';
@@ -222,13 +225,13 @@ class SearchRunner
                 $query->where('name', '=', $tagName);
             }
         });
                 $query->where('name', '=', $tagName);
             }
         });
+
         return $query;
     }
 
     /**
         return $query;
     }
 
     /**
-     * Custom entity search filters
+     * Custom entity search filters.
      */
      */
-
     protected function filterUpdatedAfter(EloquentBuilder $query, Entity $model, $input)
     {
         try {
     protected function filterUpdatedAfter(EloquentBuilder $query, Entity $model, $input)
     {
         try {
@@ -298,7 +301,7 @@ class SearchRunner
 
     protected function filterInName(EloquentBuilder $query, Entity $model, $input)
     {
 
     protected function filterInName(EloquentBuilder $query, Entity $model, $input)
     {
-        $query->where('name', 'like', '%' .$input. '%');
+        $query->where('name', 'like', '%' . $input . '%');
     }
 
     protected function filterInTitle(EloquentBuilder $query, Entity $model, $input)
     }
 
     protected function filterInTitle(EloquentBuilder $query, Entity $model, $input)
@@ -308,7 +311,7 @@ class SearchRunner
 
     protected function filterInBody(EloquentBuilder $query, Entity $model, $input)
     {
 
     protected function filterInBody(EloquentBuilder $query, Entity $model, $input)
     {
-        $query->where($model->textField, 'like', '%' .$input. '%');
+        $query->where($model->textField, 'like', '%' . $input . '%');
     }
 
     protected function filterIsRestricted(EloquentBuilder $query, Entity $model, $input)
     }
 
     protected function filterIsRestricted(EloquentBuilder $query, Entity $model, $input)
@@ -338,16 +341,14 @@ class SearchRunner
         }
     }
 
         }
     }
 
-
     /**
     /**
-     * Sorting filter options
+     * Sorting filter options.
      */
      */
-
     protected function sortByLastCommented(EloquentBuilder $query, Entity $model)
     {
         $commentsTable = $this->db->getTablePrefix() . 'comments';
         $morphClass = str_replace('\\', '\\\\', $model->getMorphClass());
     protected function sortByLastCommented(EloquentBuilder $query, Entity $model)
     {
         $commentsTable = $this->db->getTablePrefix() . 'comments';
         $morphClass = str_replace('\\', '\\\\', $model->getMorphClass());
-        $commentQuery = $this->db->raw('(SELECT c1.entity_id, c1.entity_type, c1.created_at as last_commented FROM '.$commentsTable.' c1 LEFT JOIN '.$commentsTable.' c2 ON (c1.entity_id = c2.entity_id AND c1.entity_type = c2.entity_type AND c1.created_at < c2.created_at) WHERE c1.entity_type = \''. $morphClass .'\' AND c2.created_at IS NULL) as comments');
+        $commentQuery = $this->db->raw('(SELECT c1.entity_id, c1.entity_type, c1.created_at as last_commented FROM ' . $commentsTable . ' c1 LEFT JOIN ' . $commentsTable . ' c2 ON (c1.entity_id = c2.entity_id AND c1.entity_type = c2.entity_type AND c1.created_at < c2.created_at) WHERE c1.entity_type = \'' . $morphClass . '\' AND c2.created_at IS NULL) as comments');
 
         $query->join($commentQuery, $model->getTable() . '.id', '=', 'comments.entity_id')->orderBy('last_commented', 'desc');
     }
 
         $query->join($commentQuery, $model->getTable() . '.id', '=', 'comments.entity_id')->orderBy('last_commented', 'desc');
     }
index f3849bbb4741e8c075c122bca3274f242f6d0e28..50d7981716e68c7dd662e982e22b115d64a0b4f2 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Entities\Tools;
+<?php
+
+namespace BookStack\Entities\Tools;
 
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Bookshelf;
 
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Bookshelf;
index 6964fa2e62419e111531cfbb006c008cfc6fb8a0..e9dad0e134f4f0629182e064e97f68d8b9193328 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Entities\Tools;
+<?php
+
+namespace BookStack\Entities\Tools;
 
 use BookStack\Entities\EntityProvider;
 use BookStack\Entities\Models\Book;
 
 use BookStack\Entities\EntityProvider;
 use BookStack\Entities\Models\Book;
@@ -7,13 +9,12 @@ use Illuminate\Support\Collection;
 
 class SiblingFetcher
 {
 
 class SiblingFetcher
 {
-
     /**
      * Search among the siblings of the entity of given type and id.
      */
     public function fetch(string $entityType, int $entityId): Collection
     {
     /**
      * Search among the siblings of the entity of given type and id.
      */
     public function fetch(string $entityType, int $entityId): Collection
     {
-        $entity = (new EntityProvider)->get($entityType)->visible()->findOrFail($entityId);
+        $entity = (new EntityProvider())->get($entityType)->visible()->findOrFail($entityId);
         $entities = [];
 
         // Page in chapter
         $entities = [];
 
         // Page in chapter
@@ -29,7 +30,7 @@ class SiblingFetcher
         // Book
         // Gets just the books in a shelf if shelf is in context
         if ($entity->isA('book')) {
         // Book
         // Gets just the books in a shelf if shelf is in context
         if ($entity->isA('book')) {
-            $contextShelf = (new ShelfContext)->getContextualShelfForBook($entity);
+            $contextShelf = (new ShelfContext())->getContextualShelfForBook($entity);
             if ($contextShelf) {
                 $entities = $contextShelf->visibleBooks()->get();
             } else {
             if ($contextShelf) {
                 $entities = $contextShelf->visibleBooks()->get();
             } else {
index 4501279f2a31d3c367e6a2ce34be9f1afedaf639..52e5700da24b94c9e1e6fb31d744f9958f189834 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Entities\Tools;
+<?php
+
+namespace BookStack\Entities\Tools;
 
 use BookStack\Entities\Models\BookChild;
 use BookStack\Interfaces\Sluggable;
 
 use BookStack\Entities\Models\BookChild;
 use BookStack\Interfaces\Sluggable;
@@ -6,7 +8,6 @@ use Illuminate\Support\Str;
 
 class SlugGenerator
 {
 
 class SlugGenerator
 {
-
     /**
      * Generate a fresh slug for the given entity.
      * The slug will generated so it does not conflict within the same parent item.
     /**
      * Generate a fresh slug for the given entity.
      * The slug will generated so it does not conflict within the same parent item.
@@ -17,6 +18,7 @@ class SlugGenerator
         while ($this->slugInUse($slug, $model)) {
             $slug .= '-' . Str::random(3);
         }
         while ($this->slugInUse($slug, $model)) {
             $slug .= '-' . Str::random(3);
         }
+
         return $slug;
     }
 
         return $slug;
     }
 
@@ -26,9 +28,10 @@ class SlugGenerator
     protected function formatNameAsSlug(string $name): string
     {
         $slug = Str::slug($name);
     protected function formatNameAsSlug(string $name): string
     {
         $slug = Str::slug($name);
-        if ($slug === "") {
+        if ($slug === '') {
             $slug = substr(md5(rand(1, 500)), 0, 5);
         }
             $slug = substr(md5(rand(1, 500)), 0, 5);
         }
+
         return $slug;
     }
 
         return $slug;
     }
 
index 0b6081ae46a1208cc9d74b384b61a1c15f5efde3..82569278e121915f546960a70a5dbc1faf44488a 100644 (file)
@@ -1,11 +1,13 @@
-<?php namespace BookStack\Entities\Tools;
+<?php
 
 
+namespace BookStack\Entities\Tools;
+
+use BookStack\Entities\EntityProvider;
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Bookshelf;
 use BookStack\Entities\Models\Chapter;
 use BookStack\Entities\Models\Deletion;
 use BookStack\Entities\Models\Entity;
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Bookshelf;
 use BookStack\Entities\Models\Chapter;
 use BookStack\Entities\Models\Deletion;
 use BookStack\Entities\Models\Entity;
-use BookStack\Entities\EntityProvider;
 use BookStack\Entities\Models\HasCoverImage;
 use BookStack\Entities\Models\Page;
 use BookStack\Exceptions\NotifyException;
 use BookStack\Entities\Models\HasCoverImage;
 use BookStack\Entities\Models\Page;
 use BookStack\Exceptions\NotifyException;
@@ -17,7 +19,6 @@ use Illuminate\Support\Carbon;
 
 class TrashCan
 {
 
 class TrashCan
 {
-
     /**
      * Send a shelf to the recycle bin.
      */
     /**
      * Send a shelf to the recycle bin.
      */
@@ -29,6 +30,7 @@ class TrashCan
 
     /**
      * Send a book to the recycle bin.
 
     /**
      * Send a book to the recycle bin.
+     *
      * @throws Exception
      */
     public function softDestroyBook(Book $book)
      * @throws Exception
      */
     public function softDestroyBook(Book $book)
@@ -48,6 +50,7 @@ class TrashCan
 
     /**
      * Send a chapter to the recycle bin.
 
     /**
      * Send a chapter to the recycle bin.
+     *
      * @throws Exception
      */
     public function softDestroyChapter(Chapter $chapter, bool $recordDelete = true)
      * @throws Exception
      */
     public function softDestroyChapter(Chapter $chapter, bool $recordDelete = true)
@@ -67,6 +70,7 @@ class TrashCan
 
     /**
      * Send a page to the recycle bin.
 
     /**
      * Send a page to the recycle bin.
+     *
      * @throws Exception
      */
     public function softDestroyPage(Page $page, bool $recordDelete = true)
      * @throws Exception
      */
     public function softDestroyPage(Page $page, bool $recordDelete = true)
@@ -89,18 +93,21 @@ class TrashCan
 
     /**
      * Remove a bookshelf from the system.
 
     /**
      * Remove a bookshelf from the system.
+     *
      * @throws Exception
      */
     protected function destroyShelf(Bookshelf $shelf): int
     {
         $this->destroyCommonRelations($shelf);
         $shelf->forceDelete();
      * @throws Exception
      */
     protected function destroyShelf(Bookshelf $shelf): int
     {
         $this->destroyCommonRelations($shelf);
         $shelf->forceDelete();
+
         return 1;
     }
 
     /**
      * Remove a book from the system.
      * Destroys any child chapters and pages.
         return 1;
     }
 
     /**
      * Remove a book from the system.
      * Destroys any child chapters and pages.
+     *
      * @throws Exception
      */
     protected function destroyBook(Book $book): int
      * @throws Exception
      */
     protected function destroyBook(Book $book): int
@@ -120,12 +127,14 @@ class TrashCan
 
         $this->destroyCommonRelations($book);
         $book->forceDelete();
 
         $this->destroyCommonRelations($book);
         $book->forceDelete();
+
         return $count + 1;
     }
 
     /**
      * Remove a chapter from the system.
      * Destroys all pages within.
         return $count + 1;
     }
 
     /**
      * Remove a chapter from the system.
      * Destroys all pages within.
+     *
      * @throws Exception
      */
     protected function destroyChapter(Chapter $chapter): int
      * @throws Exception
      */
     protected function destroyChapter(Chapter $chapter): int
@@ -141,11 +150,13 @@ class TrashCan
 
         $this->destroyCommonRelations($chapter);
         $chapter->forceDelete();
 
         $this->destroyCommonRelations($chapter);
         $chapter->forceDelete();
+
         return $count + 1;
     }
 
     /**
      * Remove a page from the system.
         return $count + 1;
     }
 
     /**
      * Remove a page from the system.
+     *
      * @throws Exception
      */
     protected function destroyPage(Page $page): int
      * @throws Exception
      */
     protected function destroyPage(Page $page): int
@@ -160,6 +171,7 @@ class TrashCan
         }
 
         $page->forceDelete();
         }
 
         $page->forceDelete();
+
         return 1;
     }
 
         return 1;
     }
 
@@ -172,7 +184,7 @@ class TrashCan
         $counts = [];
 
         /** @var Entity $instance */
         $counts = [];
 
         /** @var Entity $instance */
-        foreach ((new EntityProvider)->all() as $key => $instance) {
+        foreach ((new EntityProvider())->all() as $key => $instance) {
             $counts[$key] = $instance->newQuery()->onlyTrashed()->count();
         }
 
             $counts[$key] = $instance->newQuery()->onlyTrashed()->count();
         }
 
@@ -181,6 +193,7 @@ class TrashCan
 
     /**
      * Destroy all items that have pending deletions.
 
     /**
      * Destroy all items that have pending deletions.
+     *
      * @throws Exception
      */
     public function empty(): int
      * @throws Exception
      */
     public function empty(): int
@@ -190,11 +203,13 @@ class TrashCan
         foreach ($deletions as $deletion) {
             $deleteCount += $this->destroyFromDeletion($deletion);
         }
         foreach ($deletions as $deletion) {
             $deleteCount += $this->destroyFromDeletion($deletion);
         }
+
         return $deleteCount;
     }
 
     /**
      * Destroy an element from the given deletion model.
         return $deleteCount;
     }
 
     /**
      * Destroy an element from the given deletion model.
+     *
      * @throws Exception
      */
     public function destroyFromDeletion(Deletion $deletion): int
      * @throws Exception
      */
     public function destroyFromDeletion(Deletion $deletion): int
@@ -207,11 +222,13 @@ class TrashCan
             $count = $this->destroyEntity($deletion->deletable);
         }
         $deletion->delete();
             $count = $this->destroyEntity($deletion->deletable);
         }
         $deletion->delete();
+
         return $count;
     }
 
     /**
      * Restore the content within the given deletion.
         return $count;
     }
 
     /**
      * Restore the content within the given deletion.
+     *
      * @throws Exception
      */
     public function restoreFromDeletion(Deletion $deletion): int
      * @throws Exception
      */
     public function restoreFromDeletion(Deletion $deletion): int
@@ -229,6 +246,7 @@ class TrashCan
         }
 
         $deletion->delete();
         }
 
         $deletion->delete();
+
         return $restoreCount;
     }
 
         return $restoreCount;
     }
 
@@ -236,6 +254,7 @@ class TrashCan
      * Automatically clear old content from the recycle bin
      * depending on the configured lifetime.
      * Returns the total number of deleted elements.
      * Automatically clear old content from the recycle bin
      * depending on the configured lifetime.
      * Returns the total number of deleted elements.
+     *
      * @throws Exception
      */
     public function autoClearOld(): int
      * @throws Exception
      */
     public function autoClearOld(): int
@@ -287,6 +306,7 @@ class TrashCan
 
     /**
      * Destroy the given entity.
 
     /**
      * Destroy the given entity.
+     *
      * @throws Exception
      */
     protected function destroyEntity(Entity $entity): int
      * @throws Exception
      */
     protected function destroyEntity(Entity $entity): int
index 36ea8be9de5dc8b2bbe3232483b25c3da68ad491..360370de4109e723ed3446d5ff9de901fcc80556 100644 (file)
@@ -4,5 +4,4 @@ namespace BookStack\Exceptions;
 
 class ApiAuthException extends UnauthorizedException
 {
 
 class ApiAuthException extends UnauthorizedException
 {
-
 }
 }
index 71407b3c0f1fe95167f2b272e266ae13c46840af..c39d4f592338add9044763811f48f923af30f878 100644 (file)
@@ -1,6 +1,7 @@
-<?php namespace BookStack\Exceptions;
+<?php
+
+namespace BookStack\Exceptions;
 
 class ConfirmationEmailException extends NotifyException
 {
 
 class ConfirmationEmailException extends NotifyException
 {
-
 }
 }
index f5f0971f2aadf42517724e2c5bc4bf67639eb7d0..1182a758ec25f1b93676fc321657f49f8fe9816b 100644 (file)
@@ -1,6 +1,7 @@
-<?php namespace BookStack\Exceptions;
+<?php
+
+namespace BookStack\Exceptions;
 
 class FileUploadException extends PrettyException
 {
 
 class FileUploadException extends PrettyException
 {
-
 }
 }
index a06c0fdbc103821792a62c86625354096d05a481..2d40f44769127062ea294a7ba12603cf3ad6b05f 100644 (file)
@@ -35,9 +35,10 @@ class Handler extends ExceptionHandler
      * Report or log an exception.
      *
      * @param Exception $exception
      * Report or log an exception.
      *
      * @param Exception $exception
-     * @return void
      *
      * @throws Exception
      *
      * @throws Exception
+     *
+     * @return void
      */
     public function report(Exception $exception)
     {
      */
     public function report(Exception $exception)
     {
@@ -47,8 +48,9 @@ class Handler extends ExceptionHandler
     /**
      * Render an exception into an HTTP response.
      *
     /**
      * Render an exception into an HTTP response.
      *
-     * @param  \Illuminate\Http\Request $request
-     * @param Exception $e
+     * @param \Illuminate\Http\Request $request
+     * @param Exception                $e
+     *
      * @return \Illuminate\Http\Response
      */
     public function render($request, Exception $e)
      * @return \Illuminate\Http\Response
      */
     public function render($request, Exception $e)
@@ -83,7 +85,7 @@ class Handler extends ExceptionHandler
         $responseData = [
             'error' => [
                 'message' => $e->getMessage(),
         $responseData = [
             'error' => [
                 'message' => $e->getMessage(),
-            ]
+            ],
         ];
 
         if ($e instanceof ValidationException) {
         ];
 
         if ($e instanceof ValidationException) {
@@ -92,14 +94,16 @@ class Handler extends ExceptionHandler
         }
 
         $responseData['error']['code'] = $code;
         }
 
         $responseData['error']['code'] = $code;
+
         return new JsonResponse($responseData, $code, $headers);
     }
 
     /**
      * Convert an authentication exception into an unauthenticated response.
      *
         return new JsonResponse($responseData, $code, $headers);
     }
 
     /**
      * Convert an authentication exception into an unauthenticated response.
      *
-     * @param  \Illuminate\Http\Request  $request
-     * @param  \Illuminate\Auth\AuthenticationException  $exception
+     * @param \Illuminate\Http\Request                 $request
+     * @param \Illuminate\Auth\AuthenticationException $exception
+     *
      * @return \Illuminate\Http\Response
      */
     protected function unauthenticated($request, AuthenticationException $exception)
      * @return \Illuminate\Http\Response
      */
     protected function unauthenticated($request, AuthenticationException $exception)
@@ -114,8 +118,9 @@ class Handler extends ExceptionHandler
     /**
      * Convert a validation exception into a JSON response.
      *
     /**
      * Convert a validation exception into a JSON response.
      *
-     * @param  \Illuminate\Http\Request  $request
-     * @param  \Illuminate\Validation\ValidationException  $exception
+     * @param \Illuminate\Http\Request                   $request
+     * @param \Illuminate\Validation\ValidationException $exception
+     *
      * @return \Illuminate\Http\JsonResponse
      */
     protected function invalidJson($request, ValidationException $exception)
      * @return \Illuminate\Http\JsonResponse
      */
     protected function invalidJson($request, ValidationException $exception)
index 2a34bbc626b7c91c44b1bd8d17f6e39db4fcb5df..4ad45d92a35a8449f35e8c8f8ee8db44ce17f4df 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Exceptions;
+<?php
+
+namespace BookStack\Exceptions;
 
 use Exception;
 
 
 use Exception;
 
index c64dddaa2b16356f42eeb4d2c0b8d2cb181c4f47..fbc1624226f09d793adc6959357442c4b64e5b40 100644 (file)
@@ -1,6 +1,7 @@
-<?php namespace BookStack\Exceptions;
+<?php
+
+namespace BookStack\Exceptions;
 
 class ImageUploadException extends PrettyException
 {
 
 class ImageUploadException extends PrettyException
 {
-
 }
 }
index e155579d601366292cdc88e5e7ae106c4e38949f..e037fcb8e9041dd7bcb4f8115af350b299cb148d 100644 (file)
@@ -1,10 +1,11 @@
-<?php namespace BookStack\Exceptions;
+<?php
+
+namespace BookStack\Exceptions;
 
 use Exception;
 
 class JsonDebugException extends Exception
 {
 
 use Exception;
 
 class JsonDebugException extends Exception
 {
-
     protected $data;
 
     /**
     protected $data;
 
     /**
index f95e991d3c5bec2f350d1e6cb0c3cc8bf0dd0fb9..6383f68bd4f641bbe83787088edf8726276242cf 100644 (file)
@@ -1,6 +1,7 @@
-<?php namespace BookStack\Exceptions;
+<?php
+
+namespace BookStack\Exceptions;
 
 class LdapException extends PrettyException
 {
 
 class LdapException extends PrettyException
 {
-
 }
 }
index 7ffb0c0658c959214e26010f9fe25485805a1b81..e4cb62c86ef4ff124254b018d21fa7f77dab2f6b 100644 (file)
@@ -1,6 +1,7 @@
-<?php namespace BookStack\Exceptions;
+<?php
+
+namespace BookStack\Exceptions;
 
 class LoginAttemptEmailNeededException extends LoginAttemptException
 {
 
 class LoginAttemptEmailNeededException extends LoginAttemptException
 {
-
 }
 }
index 22cc980a01757f623dea76bbaa7c216efa0602d9..1dd28d3ea29d3dfd7cfd53cb758fdeda3b14accf 100644 (file)
@@ -1,6 +1,7 @@
-<?php namespace BookStack\Exceptions;
+<?php
+
+namespace BookStack\Exceptions;
 
 class LoginAttemptException extends \Exception
 {
 
 class LoginAttemptException extends \Exception
 {
-
 }
 }
index c237dfad3b4c1530877cc4dd10ccbb6017c379f8..47e0e7aa2226ba18e308434d146a92d3034a76b3 100644 (file)
@@ -1,8 +1,9 @@
-<?php namespace BookStack\Exceptions;
+<?php
+
+namespace BookStack\Exceptions;
 
 use Exception;
 
 class MoveOperationException extends Exception
 {
 
 use Exception;
 
 class MoveOperationException extends Exception
 {
-
 }
 }
index 94a4054152b6e9a1c3ad1e78d622ad1b0136eac0..016ee597f5528adeed9e40095bb3138777a30de0 100644 (file)
@@ -1,8 +1,9 @@
-<?php namespace BookStack\Exceptions;
+<?php
+
+namespace BookStack\Exceptions;
 
 class NotFoundException extends PrettyException
 {
 
 class NotFoundException extends PrettyException
 {
-
     /**
      * NotFoundException constructor.
      */
     /**
      * NotFoundException constructor.
      */
index efca625708b75ef2509d4f9790664c8ab3c18d24..ef9a441010f687ba66325fb061a1237ae253e737 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Exceptions;
+<?php
+
+namespace BookStack\Exceptions;
 
 use Exception;
 use Illuminate\Contracts\Support\Responsable;
 
 use Exception;
 use Illuminate\Contracts\Support\Responsable;
@@ -11,7 +13,7 @@ class NotifyException extends Exception implements Responsable
     /**
      * NotifyException constructor.
      */
     /**
      * NotifyException constructor.
      */
-    public function __construct(string $message, string $redirectLocation = "/")
+    public function __construct(string $message, string $redirectLocation = '/')
     {
         $this->message = $message;
         $this->redirectLocation = $redirectLocation;
     {
         $this->message = $message;
         $this->redirectLocation = $redirectLocation;
@@ -20,6 +22,7 @@ class NotifyException extends Exception implements Responsable
 
     /**
      * Send the response for this type of exception.
 
     /**
      * Send the response for this type of exception.
+     *
      * @inheritdoc
      */
     public function toResponse($request)
      * @inheritdoc
      */
     public function toResponse($request)
index e2a8c53b4bcd927ff912495c16f013162866dc1b..64da55d21f4df08c153a049aef207c46575ba3d6 100644 (file)
@@ -1,8 +1,9 @@
-<?php namespace BookStack\Exceptions;
+<?php
+
+namespace BookStack\Exceptions;
 
 use Exception;
 
 class PermissionsException extends Exception
 {
 
 use Exception;
 
 class PermissionsException extends Exception
 {
-
 }
 }
index 8ed135de7c11f0e3c0b89a3845e4dc4d77cfca1c..33c1471f2849b69fd0ee667ca81d2e372700af02 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Exceptions;
+<?php
+
+namespace BookStack\Exceptions;
 
 use Exception;
 use Illuminate\Contracts\Support\Responsable;
 
 use Exception;
 use Illuminate\Contracts\Support\Responsable;
@@ -17,27 +19,31 @@ class PrettyException extends Exception implements Responsable
 
     /**
      * Render a response for when this exception occurs.
 
     /**
      * Render a response for when this exception occurs.
+     *
      * @inheritdoc
      */
     public function toResponse($request)
     {
         $code = ($this->getCode() === 0) ? 500 : $this->getCode();
      * @inheritdoc
      */
     public function toResponse($request)
     {
         $code = ($this->getCode() === 0) ? 500 : $this->getCode();
+
         return response()->view('errors.' . $code, [
         return response()->view('errors.' . $code, [
-            'message' => $this->getMessage(),
+            'message'  => $this->getMessage(),
             'subtitle' => $this->subtitle,
             'subtitle' => $this->subtitle,
-            'details' => $this->details,
+            'details'  => $this->details,
         ], $code);
     }
 
     public function setSubtitle(string $subtitle): self
     {
         $this->subtitle = $subtitle;
         ], $code);
     }
 
     public function setSubtitle(string $subtitle): self
     {
         $this->subtitle = $subtitle;
+
         return $this;
     }
 
     public function setDetails(string $details): self
     {
         $this->details = $details;
         return $this;
     }
 
     public function setDetails(string $details): self
     {
         $this->details = $details;
+
         return $this;
     }
 }
         return $this;
     }
 }
index 13db23f27bbd02ddb7fe5479f7892f1e9d4038c8..417fe1c663dc970cab051d8aebfd45adcb484eb4 100644 (file)
@@ -1,6 +1,7 @@
-<?php namespace BookStack\Exceptions;
+<?php
+
+namespace BookStack\Exceptions;
 
 class SamlException extends NotifyException
 {
 
 class SamlException extends NotifyException
 {
-
 }
 }
index 1a5984c12df7b8a2967a455109e94433370314fb..c6f182b5556eadf9064855d9ec222b4290567bd9 100644 (file)
@@ -1,6 +1,7 @@
-<?php namespace BookStack\Exceptions;
+<?php
+
+namespace BookStack\Exceptions;
 
 class SocialDriverNotConfigured extends PrettyException
 {
 
 class SocialDriverNotConfigured extends PrettyException
 {
-
 }
 }
index 7eaa72bd55c50f5dced1cf6e9ddad862d49220bc..77701528aaea7963342c233cba5c8d8dce903340 100644 (file)
@@ -1,6 +1,7 @@
-<?php namespace BookStack\Exceptions;
+<?php
+
+namespace BookStack\Exceptions;
 
 class SocialSignInAccountNotUsed extends SocialSignInException
 {
 
 class SocialSignInAccountNotUsed extends SocialSignInException
 {
-
 }
 }
index 734b46e5f501537d964de82c1e634087ceeea02a..859d23cc3ef00ff227548d9de9da8e5f70fb6fe9 100644 (file)
@@ -1,6 +1,7 @@
-<?php namespace BookStack\Exceptions;
+<?php
+
+namespace BookStack\Exceptions;
 
 class SocialSignInException extends NotifyException
 {
 
 class SocialSignInException extends NotifyException
 {
-
 }
 }
index 8f91217f62bbf8188bf98bbb7a25eead371f9b33..ade9e47d21672b0cb52e42eb0d27202a52e363ff 100644 (file)
@@ -1,8 +1,9 @@
-<?php namespace BookStack\Exceptions;
+<?php
+
+namespace BookStack\Exceptions;
 
 use Exception;
 
 class SortOperationException extends Exception
 {
 
 use Exception;
 
 class SortOperationException extends Exception
 {
-
 }
 }
index a13ba3a55d807033b7b79a19d8684396a4649d7c..5c73ca02c6843f99aba269e12c06ffbcd45ceb57 100644 (file)
@@ -6,7 +6,6 @@ use Exception;
 
 class UnauthorizedException extends Exception
 {
 
 class UnauthorizedException extends Exception
 {
-
     /**
      * ApiAuthException constructor.
      */
     /**
      * ApiAuthException constructor.
      */
index 953abb96db2caac51abfa8298619033f28eccb78..e7ddb81c26e84c46da533404a23acc4a978353fd 100644 (file)
@@ -1,6 +1,7 @@
-<?php namespace BookStack\Exceptions;
+<?php
+
+namespace BookStack\Exceptions;
 
 class UserRegistrationException extends NotifyException
 {
 
 class UserRegistrationException extends NotifyException
 {
-
 }
 }
index e19707457a33e47bfee00c944b667bdd9af60a5c..635337c3d072c14eb50344af154f30befc7dc71b 100644 (file)
@@ -1,14 +1,16 @@
-<?php namespace BookStack\Exceptions;
+<?php
+
+namespace BookStack\Exceptions;
 
 class UserTokenExpiredException extends \Exception
 {
 
 class UserTokenExpiredException extends \Exception
 {
-
     public $userId;
 
     /**
      * UserTokenExpiredException constructor.
     public $userId;
 
     /**
      * UserTokenExpiredException constructor.
+     *
      * @param string $message
      * @param string $message
-     * @param int $userId
+     * @param int    $userId
      */
     public function __construct(string $message, int $userId)
     {
      */
     public function __construct(string $message, int $userId)
     {
index 3ed53f72ab42e706db04e51cc9a23b48f45e11c6..db3df8a149f496cae319c8a464a82ca8a0f116bb 100644 (file)
@@ -1,6 +1,7 @@
-<?php namespace BookStack\Exceptions;
+<?php
+
+namespace BookStack\Exceptions;
 
 class UserTokenNotFoundException extends \Exception
 {
 
 class UserTokenNotFoundException extends \Exception
 {
-
 }
 }
index 81e95b16fd201a3ae7ccd1d58ea8dac242823323..af2c3e201b85097aae14b8ab94c337f81767f591 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Exceptions;
+<?php
+
+namespace BookStack\Exceptions;
 
 class UserUpdateException extends NotifyException
 {
 
 class UserUpdateException extends NotifyException
 {
index 30e4b785fdb0bdb6712fcc8b448070bd23ba7345..76493efd79adfd2061cc7ba38580bee9548b3d78 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Facades;
+<?php
+
+namespace BookStack\Facades;
 
 use Illuminate\Support\Facades\Facade;
 
 
 use Illuminate\Support\Facades\Facade;
 
index c552d7cdb03d59ca512abe9419c0b554f5596be6..74cbe46fef330eec9874157d3b5d58f10fafb609 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Facades;
+<?php
+
+namespace BookStack\Facades;
 
 use Illuminate\Support\Facades\Facade;
 
 
 use Illuminate\Support\Facades\Facade;
 
index 9f4f61ecb47cfeb3938a6e399d3906e9bc7cdce2..79867ae6d6aca53a7cd2698e0a42b61e06ccaa42 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Facades;
+<?php
+
+namespace BookStack\Facades;
 
 use BookStack\Theming\ThemeService;
 use Illuminate\Support\Facades\Facade;
 
 use BookStack\Theming\ThemeService;
 use Illuminate\Support\Facades\Facade;
index f143ea5cd50a3d33f9a66ae58464a71b8bf9066c..fc9788b06e340d405eb73b9d56fd5c1fb4290c5f 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Http\Controllers\Api;
+<?php
+
+namespace BookStack\Http\Controllers\Api;
 
 use BookStack\Api\ListingResponseBuilder;
 use BookStack\Http\Controllers\Controller;
 
 use BookStack\Api\ListingResponseBuilder;
 use BookStack\Http\Controllers\Controller;
@@ -7,7 +9,6 @@ use Illuminate\Http\JsonResponse;
 
 abstract class ApiController extends Controller
 {
 
 abstract class ApiController extends Controller
 {
-
     protected $rules = [];
 
     /**
     protected $rules = [];
 
     /**
@@ -17,6 +18,7 @@ abstract class ApiController extends Controller
     protected function apiListingResponse(Builder $query, array $fields): JsonResponse
     {
         $listing = new ListingResponseBuilder($query, request(), $fields);
     protected function apiListingResponse(Builder $query, array $fields): JsonResponse
     {
         $listing = new ListingResponseBuilder($query, request(), $fields);
+
         return $listing->toResponse();
     }
 
         return $listing->toResponse();
     }
 
index c63ca698cc53808edad9c279f7066af417fcad39..a1453e7684bb0c4bb7e55534bf1eb2f8e268effe 100644 (file)
@@ -1,10 +1,11 @@
-<?php namespace BookStack\Http\Controllers\Api;
+<?php
+
+namespace BookStack\Http\Controllers\Api;
 
 use BookStack\Api\ApiDocsGenerator;
 
 class ApiDocsController extends ApiController
 {
 
 use BookStack\Api\ApiDocsGenerator;
 
 class ApiDocsController extends ApiController
 {
-
     /**
      * Load the docs page for the API.
      */
     /**
      * Load the docs page for the API.
      */
@@ -12,6 +13,7 @@ class ApiDocsController extends ApiController
     {
         $docs = ApiDocsGenerator::generateConsideringCache();
         $this->setPageTitle(trans('settings.users_api_tokens_docs'));
     {
         $docs = ApiDocsGenerator::generateConsideringCache();
         $this->setPageTitle(trans('settings.users_api_tokens_docs'));
+
         return view('api-docs.index', [
             'docs' => $docs,
         ]);
         return view('api-docs.index', [
             'docs' => $docs,
         ]);
@@ -23,6 +25,7 @@ class ApiDocsController extends ApiController
     public function json()
     {
         $docs = ApiDocsGenerator::generateConsideringCache();
     public function json()
     {
         $docs = ApiDocsGenerator::generateConsideringCache();
+
         return response()->json($docs);
     }
 }
         return response()->json($docs);
     }
 }
index 81ac9c7aa6c56e44bd2551e379d37e1f75ec5882..abe23f45dbef180506055a57b6aa21305a1d3565 100644 (file)
@@ -1,27 +1,26 @@
-<?php namespace BookStack\Http\Controllers\Api;
+<?php
+
+namespace BookStack\Http\Controllers\Api;
 
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Repos\BookRepo;
 
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Repos\BookRepo;
-use BookStack\Exceptions\NotifyException;
-use Illuminate\Contracts\Container\BindingResolutionException;
 use Illuminate\Http\Request;
 use Illuminate\Validation\ValidationException;
 
 class BookApiController extends ApiController
 {
 use Illuminate\Http\Request;
 use Illuminate\Validation\ValidationException;
 
 class BookApiController extends ApiController
 {
-
     protected $bookRepo;
 
     protected $rules = [
         'create' => [
     protected $bookRepo;
 
     protected $rules = [
         'create' => [
-            'name' => 'required|string|max:255',
+            'name'        => 'required|string|max:255',
             'description' => 'string|max:1000',
             'description' => 'string|max:1000',
-            'tags' => 'array',
+            'tags'        => 'array',
         ],
         'update' => [
         ],
         'update' => [
-            'name' => 'string|min:1|max:255',
+            'name'        => 'string|min:1|max:255',
             'description' => 'string|max:1000',
             'description' => 'string|max:1000',
-            'tags' => 'array',
+            'tags'        => 'array',
         ],
     ];
 
         ],
     ];
 
@@ -36,6 +35,7 @@ class BookApiController extends ApiController
     public function list()
     {
         $books = Book::visible();
     public function list()
     {
         $books = Book::visible();
+
         return $this->apiListingResponse($books, [
             'id', 'name', 'slug', 'description', 'created_at', 'updated_at', 'created_by', 'updated_by', 'owned_by', 'image_id',
         ]);
         return $this->apiListingResponse($books, [
             'id', 'name', 'slug', 'description', 'created_at', 'updated_at', 'created_by', 'updated_by', 'owned_by', 'image_id',
         ]);
@@ -43,6 +43,7 @@ class BookApiController extends ApiController
 
     /**
      * Create a new book in the system.
 
     /**
      * Create a new book in the system.
+     *
      * @throws ValidationException
      */
     public function create(Request $request)
      * @throws ValidationException
      */
     public function create(Request $request)
@@ -51,6 +52,7 @@ class BookApiController extends ApiController
         $requestData = $this->validate($request, $this->rules['create']);
 
         $book = $this->bookRepo->create($requestData);
         $requestData = $this->validate($request, $this->rules['create']);
 
         $book = $this->bookRepo->create($requestData);
+
         return response()->json($book);
     }
 
         return response()->json($book);
     }
 
@@ -60,11 +62,13 @@ class BookApiController extends ApiController
     public function read(string $id)
     {
         $book = Book::visible()->with(['tags', 'cover', 'createdBy', 'updatedBy', 'ownedBy'])->findOrFail($id);
     public function read(string $id)
     {
         $book = Book::visible()->with(['tags', 'cover', 'createdBy', 'updatedBy', 'ownedBy'])->findOrFail($id);
+
         return response()->json($book);
     }
 
     /**
      * Update the details of a single book.
         return response()->json($book);
     }
 
     /**
      * Update the details of a single book.
+     *
      * @throws ValidationException
      */
     public function update(Request $request, string $id)
      * @throws ValidationException
      */
     public function update(Request $request, string $id)
@@ -81,6 +85,7 @@ class BookApiController extends ApiController
     /**
      * Delete a single book.
      * This will typically send the book to the recycle bin.
     /**
      * Delete a single book.
      * This will typically send the book to the recycle bin.
+     *
      * @throws \Exception
      */
     public function delete(string $id)
      * @throws \Exception
      */
     public function delete(string $id)
@@ -89,6 +94,7 @@ class BookApiController extends ApiController
         $this->checkOwnablePermission('book-delete', $book);
 
         $this->bookRepo->destroy($book);
         $this->checkOwnablePermission('book-delete', $book);
 
         $this->bookRepo->destroy($book);
+
         return response('', 204);
     }
 }
         return response('', 204);
     }
 }
index 24cba9df374a83ba00f1aa9fbefb43594f8d7499..c7d121f88636cec083594f2c5f376eb2f6e273b8 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Http\Controllers\Api;
+<?php
+
+namespace BookStack\Http\Controllers\Api;
 
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Tools\ExportFormatter;
 
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Tools\ExportFormatter;
@@ -15,23 +17,27 @@ class BookExportApiController extends ApiController
 
     /**
      * Export a book as a PDF file.
 
     /**
      * Export a book as a PDF file.
+     *
      * @throws Throwable
      */
     public function exportPdf(int $id)
     {
         $book = Book::visible()->findOrFail($id);
         $pdfContent = $this->exportFormatter->bookToPdf($book);
      * @throws Throwable
      */
     public function exportPdf(int $id)
     {
         $book = Book::visible()->findOrFail($id);
         $pdfContent = $this->exportFormatter->bookToPdf($book);
+
         return $this->downloadResponse($pdfContent, $book->slug . '.pdf');
     }
 
     /**
      * Export a book as a contained HTML file.
         return $this->downloadResponse($pdfContent, $book->slug . '.pdf');
     }
 
     /**
      * Export a book as a contained HTML file.
+     *
      * @throws Throwable
      */
     public function exportHtml(int $id)
     {
         $book = Book::visible()->findOrFail($id);
         $htmlContent = $this->exportFormatter->bookToContainedHtml($book);
      * @throws Throwable
      */
     public function exportHtml(int $id)
     {
         $book = Book::visible()->findOrFail($id);
         $htmlContent = $this->exportFormatter->bookToContainedHtml($book);
+
         return $this->downloadResponse($htmlContent, $book->slug . '.html');
     }
 
         return $this->downloadResponse($htmlContent, $book->slug . '.html');
     }
 
@@ -42,6 +48,7 @@ class BookExportApiController extends ApiController
     {
         $book = Book::visible()->findOrFail($id);
         $textContent = $this->exportFormatter->bookToPlainText($book);
     {
         $book = Book::visible()->findOrFail($id);
         $textContent = $this->exportFormatter->bookToPlainText($book);
+
         return $this->downloadResponse($textContent, $book->slug . '.txt');
     }
 
         return $this->downloadResponse($textContent, $book->slug . '.txt');
     }
 
@@ -52,6 +59,7 @@ class BookExportApiController extends ApiController
     {
         $book = Book::visible()->findOrFail($id);
         $markdown = $this->exportFormatter->bookToMarkdown($book);
     {
         $book = Book::visible()->findOrFail($id);
         $markdown = $this->exportFormatter->bookToMarkdown($book);
+
         return $this->downloadResponse($markdown, $book->slug . '.md');
     }
 }
         return $this->downloadResponse($markdown, $book->slug . '.md');
     }
 }
index 4ce93defa9e152d7b7837cae05618277fccab0ba..c29e5b0ae4c2d656843a6789503b619a278431aa 100644 (file)
@@ -1,7 +1,9 @@
-<?php namespace BookStack\Http\Controllers\Api;
+<?php
+
+namespace BookStack\Http\Controllers\Api;
 
 
-use BookStack\Entities\Repos\BookshelfRepo;
 use BookStack\Entities\Models\Bookshelf;
 use BookStack\Entities\Models\Bookshelf;
+use BookStack\Entities\Repos\BookshelfRepo;
 use Exception;
 use Illuminate\Database\Eloquent\Relations\BelongsToMany;
 use Illuminate\Http\Request;
 use Exception;
 use Illuminate\Database\Eloquent\Relations\BelongsToMany;
 use Illuminate\Http\Request;
@@ -9,7 +11,6 @@ use Illuminate\Validation\ValidationException;
 
 class BookshelfApiController extends ApiController
 {
 
 class BookshelfApiController extends ApiController
 {
-
     /**
      * @var BookshelfRepo
      */
     /**
      * @var BookshelfRepo
      */
@@ -17,14 +18,14 @@ class BookshelfApiController extends ApiController
 
     protected $rules = [
         'create' => [
 
     protected $rules = [
         'create' => [
-            'name' => 'required|string|max:255',
+            'name'        => 'required|string|max:255',
             'description' => 'string|max:1000',
             'description' => 'string|max:1000',
-            'books' => 'array',
+            'books'       => 'array',
         ],
         'update' => [
         ],
         'update' => [
-            'name' => 'string|min:1|max:255',
+            'name'        => 'string|min:1|max:255',
             'description' => 'string|max:1000',
             'description' => 'string|max:1000',
-            'books' => 'array',
+            'books'       => 'array',
         ],
     ];
 
         ],
     ];
 
@@ -42,6 +43,7 @@ class BookshelfApiController extends ApiController
     public function list()
     {
         $shelves = Bookshelf::visible();
     public function list()
     {
         $shelves = Bookshelf::visible();
+
         return $this->apiListingResponse($shelves, [
             'id', 'name', 'slug', 'description', 'created_at', 'updated_at', 'created_by', 'updated_by', 'owned_by', 'image_id',
         ]);
         return $this->apiListingResponse($shelves, [
             'id', 'name', 'slug', 'description', 'created_at', 'updated_at', 'created_by', 'updated_by', 'owned_by', 'image_id',
         ]);
@@ -51,6 +53,7 @@ class BookshelfApiController extends ApiController
      * Create a new shelf in the system.
      * An array of books IDs can be provided in the request. These
      * will be added to the shelf in the same order as provided.
      * Create a new shelf in the system.
      * An array of books IDs can be provided in the request. These
      * will be added to the shelf in the same order as provided.
+     *
      * @throws ValidationException
      */
     public function create(Request $request)
      * @throws ValidationException
      */
     public function create(Request $request)
@@ -73,8 +76,9 @@ class BookshelfApiController extends ApiController
             'tags', 'cover', 'createdBy', 'updatedBy', 'ownedBy',
             'books' => function (BelongsToMany $query) {
                 $query->visible()->get(['id', 'name', 'slug']);
             'tags', 'cover', 'createdBy', 'updatedBy', 'ownedBy',
             'books' => function (BelongsToMany $query) {
                 $query->visible()->get(['id', 'name', 'slug']);
-            }
+            },
         ])->findOrFail($id);
         ])->findOrFail($id);
+
         return response()->json($shelf);
     }
 
         return response()->json($shelf);
     }
 
@@ -83,6 +87,7 @@ class BookshelfApiController extends ApiController
      * An array of books IDs can be provided in the request. These
      * will be added to the shelf in the same order as provided and overwrite
      * any existing book assignments.
      * An array of books IDs can be provided in the request. These
      * will be added to the shelf in the same order as provided and overwrite
      * any existing book assignments.
+     *
      * @throws ValidationException
      */
     public function update(Request $request, string $id)
      * @throws ValidationException
      */
     public function update(Request $request, string $id)
@@ -94,14 +99,14 @@ class BookshelfApiController extends ApiController
         $bookIds = $request->get('books', null);
 
         $shelf = $this->bookshelfRepo->update($shelf, $requestData, $bookIds);
         $bookIds = $request->get('books', null);
 
         $shelf = $this->bookshelfRepo->update($shelf, $requestData, $bookIds);
+
         return response()->json($shelf);
     }
 
         return response()->json($shelf);
     }
 
-
-
     /**
      * Delete a single shelf.
      * This will typically send the shelf to the recycle bin.
     /**
      * Delete a single shelf.
      * This will typically send the shelf to the recycle bin.
+     *
      * @throws Exception
      */
     public function delete(string $id)
      * @throws Exception
      */
     public function delete(string $id)
@@ -110,6 +115,7 @@ class BookshelfApiController extends ApiController
         $this->checkOwnablePermission('bookshelf-delete', $shelf);
 
         $this->bookshelfRepo->destroy($shelf);
         $this->checkOwnablePermission('bookshelf-delete', $shelf);
 
         $this->bookshelfRepo->destroy($shelf);
+
         return response('', 204);
     }
 }
         return response('', 204);
     }
 }
index e58c1c8e147dd6b8549ef10135fb9c1fa7c17730..13b3f9821171c77f664f94e7349f4a860abe76d3 100644 (file)
@@ -1,10 +1,10 @@
-<?php namespace BookStack\Http\Controllers\Api;
+<?php
+
+namespace BookStack\Http\Controllers\Api;
 
 
-use BookStack\Actions\ActivityType;
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Chapter;
 use BookStack\Entities\Repos\ChapterRepo;
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Chapter;
 use BookStack\Entities\Repos\ChapterRepo;
-use BookStack\Facades\Activity;
 use Illuminate\Database\Eloquent\Relations\HasMany;
 use Illuminate\Http\Request;
 
 use Illuminate\Database\Eloquent\Relations\HasMany;
 use Illuminate\Http\Request;
 
@@ -14,16 +14,16 @@ class ChapterApiController extends ApiController
 
     protected $rules = [
         'create' => [
 
     protected $rules = [
         'create' => [
-            'book_id' => 'required|integer',
-            'name' => 'required|string|max:255',
+            'book_id'     => 'required|integer',
+            'name'        => 'required|string|max:255',
             'description' => 'string|max:1000',
             'description' => 'string|max:1000',
-            'tags' => 'array',
+            'tags'        => 'array',
         ],
         'update' => [
         ],
         'update' => [
-            'book_id' => 'integer',
-            'name' => 'string|min:1|max:255',
+            'book_id'     => 'integer',
+            'name'        => 'string|min:1|max:255',
             'description' => 'string|max:1000',
             'description' => 'string|max:1000',
-            'tags' => 'array',
+            'tags'        => 'array',
         ],
     ];
 
         ],
     ];
 
@@ -41,6 +41,7 @@ class ChapterApiController extends ApiController
     public function list()
     {
         $chapters = Chapter::visible();
     public function list()
     {
         $chapters = Chapter::visible();
+
         return $this->apiListingResponse($chapters, [
             'id', 'book_id', 'name', 'slug', 'description', 'priority',
             'created_at', 'updated_at', 'created_by', 'updated_by', 'owned_by',
         return $this->apiListingResponse($chapters, [
             'id', 'book_id', 'name', 'slug', 'description', 'priority',
             'created_at', 'updated_at', 'created_by', 'updated_by', 'owned_by',
@@ -59,6 +60,7 @@ class ChapterApiController extends ApiController
         $this->checkOwnablePermission('chapter-create', $book);
 
         $chapter = $this->chapterRepo->create($request->all(), $book);
         $this->checkOwnablePermission('chapter-create', $book);
 
         $chapter = $this->chapterRepo->create($request->all(), $book);
+
         return response()->json($chapter->load(['tags']));
     }
 
         return response()->json($chapter->load(['tags']));
     }
 
@@ -70,6 +72,7 @@ class ChapterApiController extends ApiController
         $chapter = Chapter::visible()->with(['tags', 'createdBy', 'updatedBy', 'ownedBy', 'pages' => function (HasMany $query) {
             $query->visible()->get(['id', 'name', 'slug']);
         }])->findOrFail($id);
         $chapter = Chapter::visible()->with(['tags', 'createdBy', 'updatedBy', 'ownedBy', 'pages' => function (HasMany $query) {
             $query->visible()->get(['id', 'name', 'slug']);
         }])->findOrFail($id);
+
         return response()->json($chapter);
     }
 
         return response()->json($chapter);
     }
 
@@ -82,6 +85,7 @@ class ChapterApiController extends ApiController
         $this->checkOwnablePermission('chapter-update', $chapter);
 
         $updatedChapter = $this->chapterRepo->update($chapter, $request->all());
         $this->checkOwnablePermission('chapter-update', $chapter);
 
         $updatedChapter = $this->chapterRepo->update($chapter, $request->all());
+
         return response()->json($updatedChapter->load(['tags']));
     }
 
         return response()->json($updatedChapter->load(['tags']));
     }
 
@@ -95,6 +99,7 @@ class ChapterApiController extends ApiController
         $this->checkOwnablePermission('chapter-delete', $chapter);
 
         $this->chapterRepo->destroy($chapter);
         $this->checkOwnablePermission('chapter-delete', $chapter);
 
         $this->chapterRepo->destroy($chapter);
+
         return response('', 204);
     }
 }
         return response('', 204);
     }
 }
index a4c349f4ef4aa06276adf98089531566a4c25617..5dfcea344def1508548f1209f1bb9eac2835d43f 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Http\Controllers\Api;
+<?php
+
+namespace BookStack\Http\Controllers\Api;
 
 use BookStack\Entities\Models\Chapter;
 use BookStack\Entities\Tools\ExportFormatter;
 
 use BookStack\Entities\Models\Chapter;
 use BookStack\Entities\Tools\ExportFormatter;
@@ -18,23 +20,27 @@ class ChapterExportApiController extends ApiController
 
     /**
      * Export a chapter as a PDF file.
 
     /**
      * Export a chapter as a PDF file.
+     *
      * @throws Throwable
      */
     public function exportPdf(int $id)
     {
         $chapter = Chapter::visible()->findOrFail($id);
         $pdfContent = $this->exportFormatter->chapterToPdf($chapter);
      * @throws Throwable
      */
     public function exportPdf(int $id)
     {
         $chapter = Chapter::visible()->findOrFail($id);
         $pdfContent = $this->exportFormatter->chapterToPdf($chapter);
+
         return $this->downloadResponse($pdfContent, $chapter->slug . '.pdf');
     }
 
     /**
      * Export a chapter as a contained HTML file.
         return $this->downloadResponse($pdfContent, $chapter->slug . '.pdf');
     }
 
     /**
      * Export a chapter as a contained HTML file.
+     *
      * @throws Throwable
      */
     public function exportHtml(int $id)
     {
         $chapter = Chapter::visible()->findOrFail($id);
         $htmlContent = $this->exportFormatter->chapterToContainedHtml($chapter);
      * @throws Throwable
      */
     public function exportHtml(int $id)
     {
         $chapter = Chapter::visible()->findOrFail($id);
         $htmlContent = $this->exportFormatter->chapterToContainedHtml($chapter);
+
         return $this->downloadResponse($htmlContent, $chapter->slug . '.html');
     }
 
         return $this->downloadResponse($htmlContent, $chapter->slug . '.html');
     }
 
@@ -45,6 +51,7 @@ class ChapterExportApiController extends ApiController
     {
         $chapter = Chapter::visible()->findOrFail($id);
         $textContent = $this->exportFormatter->chapterToPlainText($chapter);
     {
         $chapter = Chapter::visible()->findOrFail($id);
         $textContent = $this->exportFormatter->chapterToPlainText($chapter);
+
         return $this->downloadResponse($textContent, $chapter->slug . '.txt');
     }
 
         return $this->downloadResponse($textContent, $chapter->slug . '.txt');
     }
 
@@ -55,6 +62,7 @@ class ChapterExportApiController extends ApiController
     {
         $chapter = Chapter::visible()->findOrFail($id);
         $markdown = $this->exportFormatter->chapterToMarkdown($chapter);
     {
         $chapter = Chapter::visible()->findOrFail($id);
         $markdown = $this->exportFormatter->chapterToMarkdown($chapter);
+
         return $this->downloadResponse($markdown, $chapter->slug . '.md');
     }
 }
         return $this->downloadResponse($markdown, $chapter->slug . '.md');
     }
 }
index fd4a16effeb56dce464f9ebeef2a427eb6ecce3e..f698627a7e8ac1f63e2d7aee1d60651b5a2f883d 100644 (file)
@@ -16,20 +16,20 @@ class PageApiController extends ApiController
 
     protected $rules = [
         'create' => [
 
     protected $rules = [
         'create' => [
-            'book_id' => 'required_without:chapter_id|integer',
+            'book_id'    => 'required_without:chapter_id|integer',
             'chapter_id' => 'required_without:book_id|integer',
             'chapter_id' => 'required_without:book_id|integer',
-            'name' => 'required|string|max:255',
-            'html' => 'required_without:markdown|string',
-            'markdown' => 'required_without:html|string',
-            'tags' => 'array',
+            'name'       => 'required|string|max:255',
+            'html'       => 'required_without:markdown|string',
+            'markdown'   => 'required_without:html|string',
+            'tags'       => 'array',
         ],
         'update' => [
         ],
         'update' => [
-            'book_id' => 'required|integer',
+            'book_id'    => 'required|integer',
             'chapter_id' => 'required|integer',
             'chapter_id' => 'required|integer',
-            'name' => 'string|min:1|max:255',
-            'html' => 'string',
-            'markdown' => 'string',
-            'tags' => 'array',
+            'name'       => 'string|min:1|max:255',
+            'html'       => 'string',
+            'markdown'   => 'string',
+            'tags'       => 'array',
         ],
     ];
 
         ],
     ];
 
@@ -44,6 +44,7 @@ class PageApiController extends ApiController
     public function list()
     {
         $pages = Page::visible();
     public function list()
     {
         $pages = Page::visible();
+
         return $this->apiListingResponse($pages, [
             'id', 'book_id', 'chapter_id', 'name', 'slug', 'priority',
             'draft', 'template',
         return $this->apiListingResponse($pages, [
             'id', 'book_id', 'chapter_id', 'name', 'slug', 'priority',
             'draft', 'template',
@@ -89,6 +90,7 @@ class PageApiController extends ApiController
     public function read(string $id)
     {
         $page = $this->pageRepo->getById($id, []);
     public function read(string $id)
     {
         $page = $this->pageRepo->getById($id, []);
+
         return response()->json($page->forJsonDisplay());
     }
 
         return response()->json($page->forJsonDisplay());
     }
 
@@ -107,12 +109,13 @@ class PageApiController extends ApiController
         $parent = null;
         if ($request->has('chapter_id')) {
             $parent = Chapter::visible()->findOrFail($request->get('chapter_id'));
         $parent = null;
         if ($request->has('chapter_id')) {
             $parent = Chapter::visible()->findOrFail($request->get('chapter_id'));
-        } else if ($request->has('book_id')) {
+        } elseif ($request->has('book_id')) {
             $parent = Book::visible()->findOrFail($request->get('book_id'));
         }
 
         if ($parent && !$parent->matches($page->getParent())) {
             $this->checkOwnablePermission('page-delete', $page);
             $parent = Book::visible()->findOrFail($request->get('book_id'));
         }
 
         if ($parent && !$parent->matches($page->getParent())) {
             $this->checkOwnablePermission('page-delete', $page);
+
             try {
                 $this->pageRepo->move($page, $parent->getType() . ':' . $parent->id);
             } catch (Exception $exception) {
             try {
                 $this->pageRepo->move($page, $parent->getType() . ':' . $parent->id);
             } catch (Exception $exception) {
@@ -125,6 +128,7 @@ class PageApiController extends ApiController
         }
 
         $updatedPage = $this->pageRepo->update($page, $request->all());
         }
 
         $updatedPage = $this->pageRepo->update($page, $request->all());
+
         return response()->json($updatedPage->forJsonDisplay());
     }
 
         return response()->json($updatedPage->forJsonDisplay());
     }
 
@@ -138,6 +142,7 @@ class PageApiController extends ApiController
         $this->checkOwnablePermission('page-delete', $page);
 
         $this->pageRepo->destroy($page);
         $this->checkOwnablePermission('page-delete', $page);
 
         $this->pageRepo->destroy($page);
+
         return response('', 204);
     }
 }
         return response('', 204);
     }
 }
index bf43016c2258d137d33fc6248d3b4021330e0c27..7cee2fbe7cc24510be06df1cd2c1483aa68cb066 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Http\Controllers\Api;
+<?php
+
+namespace BookStack\Http\Controllers\Api;
 
 use BookStack\Entities\Models\Page;
 use BookStack\Entities\Tools\ExportFormatter;
 
 use BookStack\Entities\Models\Page;
 use BookStack\Entities\Tools\ExportFormatter;
@@ -15,23 +17,27 @@ class PageExportApiController extends ApiController
 
     /**
      * Export a page as a PDF file.
 
     /**
      * Export a page as a PDF file.
+     *
      * @throws Throwable
      */
     public function exportPdf(int $id)
     {
         $page = Page::visible()->findOrFail($id);
         $pdfContent = $this->exportFormatter->pageToPdf($page);
      * @throws Throwable
      */
     public function exportPdf(int $id)
     {
         $page = Page::visible()->findOrFail($id);
         $pdfContent = $this->exportFormatter->pageToPdf($page);
+
         return $this->downloadResponse($pdfContent, $page->slug . '.pdf');
     }
 
     /**
      * Export a page as a contained HTML file.
         return $this->downloadResponse($pdfContent, $page->slug . '.pdf');
     }
 
     /**
      * Export a page as a contained HTML file.
+     *
      * @throws Throwable
      */
     public function exportHtml(int $id)
     {
         $page = Page::visible()->findOrFail($id);
         $htmlContent = $this->exportFormatter->pageToContainedHtml($page);
      * @throws Throwable
      */
     public function exportHtml(int $id)
     {
         $page = Page::visible()->findOrFail($id);
         $htmlContent = $this->exportFormatter->pageToContainedHtml($page);
+
         return $this->downloadResponse($htmlContent, $page->slug . '.html');
     }
 
         return $this->downloadResponse($htmlContent, $page->slug . '.html');
     }
 
@@ -42,6 +48,7 @@ class PageExportApiController extends ApiController
     {
         $page = Page::visible()->findOrFail($id);
         $textContent = $this->exportFormatter->pageToPlainText($page);
     {
         $page = Page::visible()->findOrFail($id);
         $textContent = $this->exportFormatter->pageToPlainText($page);
+
         return $this->downloadResponse($textContent, $page->slug . '.txt');
     }
 
         return $this->downloadResponse($textContent, $page->slug . '.txt');
     }
 
@@ -52,6 +59,7 @@ class PageExportApiController extends ApiController
     {
         $page = Page::visible()->findOrFail($id);
         $markdown = $this->exportFormatter->pageToMarkdown($page);
     {
         $page = Page::visible()->findOrFail($id);
         $markdown = $this->exportFormatter->pageToMarkdown($page);
+
         return $this->downloadResponse($markdown, $page->slug . '.md');
     }
 }
         return $this->downloadResponse($markdown, $page->slug . '.md');
     }
 }
index be20cda93de55506206f6305f5c07b414de5b6e9..046b8c19dc83478c59c92b587f97e71ffc51d484 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Http\Controllers;
+<?php
+
+namespace BookStack\Http\Controllers;
 
 use BookStack\Entities\Repos\PageRepo;
 use BookStack\Exceptions\FileUploadException;
 
 use BookStack\Entities\Repos\PageRepo;
 use BookStack\Exceptions\FileUploadException;
@@ -25,9 +27,9 @@ class AttachmentController extends Controller
         $this->pageRepo = $pageRepo;
     }
 
         $this->pageRepo = $pageRepo;
     }
 
-
     /**
      * Endpoint at which attachments are uploaded to.
     /**
      * Endpoint at which attachments are uploaded to.
+     *
      * @throws ValidationException
      * @throws NotFoundException
      */
      * @throws ValidationException
      * @throws NotFoundException
      */
@@ -35,7 +37,7 @@ class AttachmentController extends Controller
     {
         $this->validate($request, [
             'uploaded_to' => 'required|integer|exists:pages,id',
     {
         $this->validate($request, [
             'uploaded_to' => 'required|integer|exists:pages,id',
-            'file' => 'required|file'
+            'file'        => 'required|file',
         ]);
 
         $pageId = $request->get('uploaded_to');
         ]);
 
         $pageId = $request->get('uploaded_to');
@@ -57,12 +59,13 @@ class AttachmentController extends Controller
 
     /**
      * Update an uploaded attachment.
 
     /**
      * Update an uploaded attachment.
+     *
      * @throws ValidationException
      */
     public function uploadUpdate(Request $request, $attachmentId)
     {
         $this->validate($request, [
      * @throws ValidationException
      */
     public function uploadUpdate(Request $request, $attachmentId)
     {
         $this->validate($request, [
-            'file' => 'required|file'
+            'file' => 'required|file',
         ]);
 
         $attachment = Attachment::query()->findOrFail($attachmentId);
         ]);
 
         $attachment = Attachment::query()->findOrFail($attachmentId);
@@ -83,6 +86,7 @@ class AttachmentController extends Controller
 
     /**
      * Get the update form for an attachment.
 
     /**
      * Get the update form for an attachment.
+     *
      * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
      */
     public function getUpdateForm(string $attachmentId)
      * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
      */
     public function getUpdateForm(string $attachmentId)
@@ -104,15 +108,16 @@ class AttachmentController extends Controller
     {
         /** @var Attachment $attachment */
         $attachment = Attachment::query()->findOrFail($attachmentId);
     {
         /** @var Attachment $attachment */
         $attachment = Attachment::query()->findOrFail($attachmentId);
+
         try {
             $this->validate($request, [
                 'attachment_edit_name' => 'required|string|min:1|max:255',
         try {
             $this->validate($request, [
                 'attachment_edit_name' => 'required|string|min:1|max:255',
-                'attachment_edit_url' =>  'string|min:1|max:255|safe_url'
+                'attachment_edit_url'  => 'string|min:1|max:255|safe_url',
             ]);
         } catch (ValidationException $exception) {
             return response()->view('attachments.manager-edit-form', array_merge($request->only(['attachment_edit_name', 'attachment_edit_url']), [
                 'attachment' => $attachment,
             ]);
         } catch (ValidationException $exception) {
             return response()->view('attachments.manager-edit-form', array_merge($request->only(['attachment_edit_name', 'attachment_edit_url']), [
                 'attachment' => $attachment,
-                'errors' => new MessageBag($exception->errors()),
+                'errors'     => new MessageBag($exception->errors()),
             ]), 422);
         }
 
             ]), 422);
         }
 
@@ -132,6 +137,7 @@ class AttachmentController extends Controller
 
     /**
      * Attach a link to a page.
 
     /**
      * Attach a link to a page.
+     *
      * @throws NotFoundException
      */
     public function attachLink(Request $request)
      * @throws NotFoundException
      */
     public function attachLink(Request $request)
@@ -141,8 +147,8 @@ class AttachmentController extends Controller
         try {
             $this->validate($request, [
                 'attachment_link_uploaded_to' => 'required|integer|exists:pages,id',
         try {
             $this->validate($request, [
                 'attachment_link_uploaded_to' => 'required|integer|exists:pages,id',
-                'attachment_link_name' => 'required|string|min:1|max:255',
-                'attachment_link_url' =>  'required|string|min:1|max:255|safe_url'
+                'attachment_link_name'        => 'required|string|min:1|max:255',
+                'attachment_link_url'         => 'required|string|min:1|max:255|safe_url',
             ]);
         } catch (ValidationException $exception) {
             return response()->view('attachments.manager-link-form', array_merge($request->only(['attachment_link_name', 'attachment_link_url']), [
             ]);
         } catch (ValidationException $exception) {
             return response()->view('attachments.manager-link-form', array_merge($request->only(['attachment_link_name', 'attachment_link_url']), [
@@ -172,6 +178,7 @@ class AttachmentController extends Controller
     {
         $page = $this->pageRepo->getById($pageId);
         $this->checkOwnablePermission('page-view', $page);
     {
         $page = $this->pageRepo->getById($pageId);
         $this->checkOwnablePermission('page-view', $page);
+
         return view('attachments.manager-list', [
             'attachments' => $page->attachments->all(),
         ]);
         return view('attachments.manager-list', [
             'attachments' => $page->attachments->all(),
         ]);
@@ -179,6 +186,7 @@ class AttachmentController extends Controller
 
     /**
      * Update the attachment sorting.
 
     /**
      * Update the attachment sorting.
+     *
      * @throws ValidationException
      * @throws NotFoundException
      */
      * @throws ValidationException
      * @throws NotFoundException
      */
@@ -192,11 +200,13 @@ class AttachmentController extends Controller
 
         $attachmentOrder = $request->get('order');
         $this->attachmentService->updateFileOrderWithinPage($attachmentOrder, $pageId);
 
         $attachmentOrder = $request->get('order');
         $this->attachmentService->updateFileOrderWithinPage($attachmentOrder, $pageId);
+
         return response()->json(['message' => trans('entities.attachments_order_updated')]);
     }
 
     /**
      * Get an attachment from storage.
         return response()->json(['message' => trans('entities.attachments_order_updated')]);
     }
 
     /**
      * Get an attachment from storage.
+     *
      * @throws FileNotFoundException
      * @throws NotFoundException
      */
      * @throws FileNotFoundException
      * @throws NotFoundException
      */
@@ -204,6 +214,7 @@ class AttachmentController extends Controller
     {
         /** @var Attachment $attachment */
         $attachment = Attachment::query()->findOrFail($attachmentId);
     {
         /** @var Attachment $attachment */
         $attachment = Attachment::query()->findOrFail($attachmentId);
+
         try {
             $page = $this->pageRepo->getById($attachment->uploaded_to);
         } catch (NotFoundException $exception) {
         try {
             $page = $this->pageRepo->getById($attachment->uploaded_to);
         } catch (NotFoundException $exception) {
@@ -222,11 +233,13 @@ class AttachmentController extends Controller
         if ($request->get('open') === 'true') {
             return $this->inlineDownloadResponse($attachmentContents, $fileName);
         }
         if ($request->get('open') === 'true') {
             return $this->inlineDownloadResponse($attachmentContents, $fileName);
         }
+
         return $this->downloadResponse($attachmentContents, $fileName);
     }
 
     /**
      * Delete a specific attachment in the system.
         return $this->downloadResponse($attachmentContents, $fileName);
     }
 
     /**
      * Delete a specific attachment in the system.
+     *
      * @throws Exception
      */
     public function delete(string $attachmentId)
      * @throws Exception
      */
     public function delete(string $attachmentId)
@@ -235,6 +248,7 @@ class AttachmentController extends Controller
         $attachment = Attachment::query()->findOrFail($attachmentId);
         $this->checkOwnablePermission('attachment-delete', $attachment);
         $this->attachmentService->deleteFile($attachment);
         $attachment = Attachment::query()->findOrFail($attachmentId);
         $this->checkOwnablePermission('attachment-delete', $attachment);
         $this->attachmentService->deleteFile($attachment);
+
         return response()->json(['message' => trans('entities.attachments_deleted')]);
     }
 }
         return response()->json(['message' => trans('entities.attachments_deleted')]);
     }
 }
index f73ee4a20d227e0907ba51b7f07e8273ee580e04..11efbfc23d7f81960aa08b3f757cb7c09f7cb53a 100644 (file)
@@ -8,19 +8,18 @@ use Illuminate\Support\Facades\DB;
 
 class AuditLogController extends Controller
 {
 
 class AuditLogController extends Controller
 {
-
     public function index(Request $request)
     {
         $this->checkPermission('settings-manage');
         $this->checkPermission('users-manage');
 
         $listDetails = [
     public function index(Request $request)
     {
         $this->checkPermission('settings-manage');
         $this->checkPermission('users-manage');
 
         $listDetails = [
-            'order' => $request->get('order', 'desc'),
-            'event' => $request->get('event', ''),
-            'sort' => $request->get('sort', 'created_at'),
+            'order'     => $request->get('order', 'desc'),
+            'event'     => $request->get('event', ''),
+            'sort'      => $request->get('sort', 'created_at'),
             'date_from' => $request->get('date_from', ''),
             'date_from' => $request->get('date_from', ''),
-            'date_to' => $request->get('date_to', ''),
-            'user' => $request->get('user', ''),
+            'date_to'   => $request->get('date_to', ''),
+            'user'      => $request->get('user', ''),
         ];
 
         $query = Activity::query()
         ];
 
         $query = Activity::query()
@@ -28,7 +27,7 @@ class AuditLogController extends Controller
                 'entity' => function ($query) {
                     $query->withTrashed();
                 },
                 'entity' => function ($query) {
                     $query->withTrashed();
                 },
-                'user'
+                'user',
             ])
             ->orderBy($listDetails['sort'], $listDetails['order']);
 
             ])
             ->orderBy($listDetails['sort'], $listDetails['order']);
 
@@ -51,9 +50,10 @@ class AuditLogController extends Controller
 
         $types = DB::table('activities')->select('type')->distinct()->pluck('type');
         $this->setPageTitle(trans('settings.audit'));
 
         $types = DB::table('activities')->select('type')->distinct()->pluck('type');
         $this->setPageTitle(trans('settings.audit'));
+
         return view('settings.audit', [
         return view('settings.audit', [
-            'activities' => $activities,
-            'listDetails' => $listDetails,
+            'activities'    => $activities,
+            'listDetails'   => $listDetails,
             'activityTypes' => $types,
         ]);
     }
             'activityTypes' => $types,
         ]);
     }
index 6e6a0e779d0871e49e9863ffd76a5f8373288395..63f220a68e5630e106fcf51dbc4488ea0a65db04 100644 (file)
@@ -31,7 +31,6 @@ class ConfirmEmailController extends Controller
         $this->userRepo = $userRepo;
     }
 
         $this->userRepo = $userRepo;
     }
 
-
     /**
      * Show the page to tell the user to check their email
      * and confirm their address.
     /**
      * Show the page to tell the user to check their email
      * and confirm their address.
@@ -44,6 +43,7 @@ class ConfirmEmailController extends Controller
     /**
      * Shows a notice that a user's email address has not been confirmed,
      * Also has the option to re-send the confirmation email.
     /**
      * Shows a notice that a user's email address has not been confirmed,
      * Also has the option to re-send the confirmation email.
+     *
      * @return View
      */
     public function showAwaiting()
      * @return View
      */
     public function showAwaiting()
@@ -53,10 +53,13 @@ class ConfirmEmailController extends Controller
 
     /**
      * Confirms an email via a token and logs the user into the system.
 
     /**
      * Confirms an email via a token and logs the user into the system.
+     *
      * @param $token
      * @param $token
-     * @return RedirectResponse|Redirector
+     *
      * @throws ConfirmationEmailException
      * @throws Exception
      * @throws ConfirmationEmailException
      * @throws Exception
+     *
+     * @return RedirectResponse|Redirector
      */
     public function confirm($token)
     {
      */
     public function confirm($token)
     {
@@ -65,6 +68,7 @@ class ConfirmEmailController extends Controller
         } catch (Exception $exception) {
             if ($exception instanceof UserTokenNotFoundException) {
                 $this->showErrorNotification(trans('errors.email_confirmation_invalid'));
         } catch (Exception $exception) {
             if ($exception instanceof UserTokenNotFoundException) {
                 $this->showErrorNotification(trans('errors.email_confirmation_invalid'));
+
                 return redirect('/register');
             }
 
                 return redirect('/register');
             }
 
@@ -72,6 +76,7 @@ class ConfirmEmailController extends Controller
                 $user = $this->userRepo->getById($exception->userId);
                 $this->emailConfirmationService->sendConfirmation($user);
                 $this->showErrorNotification(trans('errors.email_confirmation_expired'));
                 $user = $this->userRepo->getById($exception->userId);
                 $this->emailConfirmationService->sendConfirmation($user);
                 $this->showErrorNotification(trans('errors.email_confirmation_expired'));
+
                 return redirect('/register/confirm');
             }
 
                 return redirect('/register/confirm');
             }
 
@@ -91,16 +96,17 @@ class ConfirmEmailController extends Controller
         return redirect('/');
     }
 
         return redirect('/');
     }
 
-
     /**
     /**
-     * Resend the confirmation email
+     * Resend the confirmation email.
+     *
      * @param Request $request
      * @param Request $request
+     *
      * @return View
      */
     public function resend(Request $request)
     {
         $this->validate($request, [
      * @return View
      */
     public function resend(Request $request)
     {
         $this->validate($request, [
-            'email' => 'required|email|exists:users,email'
+            'email' => 'required|email|exists:users,email',
         ]);
         $user = $this->userRepo->getByEmail($request->get('email'));
 
         ]);
         $user = $this->userRepo->getByEmail($request->get('email'));
 
@@ -108,10 +114,12 @@ class ConfirmEmailController extends Controller
             $this->emailConfirmationService->sendConfirmation($user);
         } catch (Exception $e) {
             $this->showErrorNotification(trans('auth.email_confirm_send_error'));
             $this->emailConfirmationService->sendConfirmation($user);
         } catch (Exception $e) {
             $this->showErrorNotification(trans('auth.email_confirm_send_error'));
+
             return redirect('/register/confirm');
         }
 
         $this->showSuccessNotification(trans('auth.email_confirm_resent'));
             return redirect('/register/confirm');
         }
 
         $this->showSuccessNotification(trans('auth.email_confirm_resent'));
+
         return redirect('/register/confirm');
     }
 }
         return redirect('/register/confirm');
     }
 }
index 5a033c6aad57d89fe7067b1c65016c200e327439..3df0608f87ffad7f09754ce2f24e6d82694b716b 100644 (file)
@@ -34,11 +34,11 @@ class ForgotPasswordController extends Controller
         $this->middleware('guard:standard');
     }
 
         $this->middleware('guard:standard');
     }
 
-
     /**
      * Send a reset link to the given user.
      *
     /**
      * Send a reset link to the given user.
      *
-     * @param  \Illuminate\Http\Request  $request
+     * @param \Illuminate\Http\Request $request
+     *
      * @return \Illuminate\Http\RedirectResponse
      */
     public function sendResetLinkEmail(Request $request)
      * @return \Illuminate\Http\RedirectResponse
      */
     public function sendResetLinkEmail(Request $request)
@@ -59,6 +59,7 @@ class ForgotPasswordController extends Controller
         if ($response === Password::RESET_LINK_SENT || $response === Password::INVALID_USER) {
             $message = trans('auth.reset_password_sent', ['email' => $request->get('email')]);
             $this->showSuccessNotification($message);
         if ($response === Password::RESET_LINK_SENT || $response === Password::INVALID_USER) {
             $message = trans('auth.reset_password_sent', ['email' => $request->get('email')]);
             $this->showSuccessNotification($message);
+
             return back()->with('status', trans($response));
         }
 
             return back()->with('status', trans($response));
         }
 
index 16f7fc010adeedfe754269d93492209894d85706..5154f7e97d8d64c0748daa4b2304b315756d77e5 100644 (file)
@@ -30,7 +30,7 @@ class LoginController extends Controller
     use AuthenticatesUsers;
 
     /**
     use AuthenticatesUsers;
 
     /**
-     * Redirection paths
+     * Redirection paths.
      */
     protected $redirectTo = '/';
     protected $redirectPath = '/';
      */
     protected $redirectTo = '/';
     protected $redirectPath = '/';
@@ -74,8 +74,8 @@ class LoginController extends Controller
 
         if ($request->has('email')) {
             session()->flashInput([
 
         if ($request->has('email')) {
             session()->flashInput([
-                'email' => $request->get('email'),
-                'password' => (config('app.env') === 'demo') ? $request->get('password', '') : ''
+                'email'    => $request->get('email'),
+                'password' => (config('app.env') === 'demo') ? $request->get('password', '') : '',
             ]);
         }
 
             ]);
         }
 
@@ -89,18 +89,19 @@ class LoginController extends Controller
         }
 
         return view('auth.login', [
         }
 
         return view('auth.login', [
-          'socialDrivers' => $socialDrivers,
-          'authMethod' => $authMethod,
+            'socialDrivers' => $socialDrivers,
+            'authMethod'    => $authMethod,
         ]);
     }
 
     /**
      * Handle a login request to the application.
      *
         ]);
     }
 
     /**
      * Handle a login request to the application.
      *
-     * @param  \Illuminate\Http\Request  $request
-     * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\Response|\Illuminate\Http\JsonResponse
+     * @param \Illuminate\Http\Request $request
      *
      * @throws \Illuminate\Validation\ValidationException
      *
      * @throws \Illuminate\Validation\ValidationException
+     *
+     * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\Response|\Illuminate\Http\JsonResponse
      */
     public function login(Request $request)
     {
      */
     public function login(Request $request)
     {
@@ -115,6 +116,7 @@ class LoginController extends Controller
             $this->fireLockoutEvent($request);
 
             Activity::logFailedLogin($username);
             $this->fireLockoutEvent($request);
 
             Activity::logFailedLogin($username);
+
             return $this->sendLockoutResponse($request);
         }
 
             return $this->sendLockoutResponse($request);
         }
 
@@ -124,6 +126,7 @@ class LoginController extends Controller
             }
         } catch (LoginAttemptException $exception) {
             Activity::logFailedLogin($username);
             }
         } catch (LoginAttemptException $exception) {
             Activity::logFailedLogin($username);
+
             return $this->sendLoginAttemptExceptionResponse($exception, $request);
         }
 
             return $this->sendLoginAttemptExceptionResponse($exception, $request);
         }
 
@@ -133,14 +136,16 @@ class LoginController extends Controller
         $this->incrementLoginAttempts($request);
 
         Activity::logFailedLogin($username);
         $this->incrementLoginAttempts($request);
 
         Activity::logFailedLogin($username);
+
         return $this->sendFailedLoginResponse($request);
     }
 
     /**
      * The user has been authenticated.
      *
         return $this->sendFailedLoginResponse($request);
     }
 
     /**
      * The user has been authenticated.
      *
-     * @param  \Illuminate\Http\Request  $request
-     * @param  mixed  $user
+     * @param \Illuminate\Http\Request $request
+     * @param mixed                    $user
+     *
      * @return mixed
      */
     protected function authenticated(Request $request, $user)
      * @return mixed
      */
     protected function authenticated(Request $request, $user)
@@ -155,16 +160,18 @@ class LoginController extends Controller
 
         Theme::dispatch(ThemeEvents::AUTH_LOGIN, auth()->getDefaultDriver(), $user);
         $this->logActivity(ActivityType::AUTH_LOGIN, $user);
 
         Theme::dispatch(ThemeEvents::AUTH_LOGIN, auth()->getDefaultDriver(), $user);
         $this->logActivity(ActivityType::AUTH_LOGIN, $user);
+
         return redirect()->intended($this->redirectPath());
     }
 
     /**
      * Validate the user login request.
      *
         return redirect()->intended($this->redirectPath());
     }
 
     /**
      * Validate the user login request.
      *
-     * @param  \Illuminate\Http\Request  $request
-     * @return void
+     * @param \Illuminate\Http\Request $request
      *
      * @throws \Illuminate\Validation\ValidationException
      *
      * @throws \Illuminate\Validation\ValidationException
+     *
+     * @return void
      */
     protected function validateLogin(Request $request)
     {
      */
     protected function validateLogin(Request $request)
     {
@@ -203,10 +210,11 @@ class LoginController extends Controller
     /**
      * Get the failed login response instance.
      *
     /**
      * Get the failed login response instance.
      *
-     * @param  \Illuminate\Http\Request  $request
-     * @return \Symfony\Component\HttpFoundation\Response
+     * @param \Illuminate\Http\Request $request
      *
      * @throws \Illuminate\Validation\ValidationException
      *
      * @throws \Illuminate\Validation\ValidationException
+     *
+     * @return \Symfony\Component\HttpFoundation\Response
      */
     protected function sendFailedLoginResponse(Request $request)
     {
      */
     protected function sendFailedLoginResponse(Request $request)
     {
index 7d7d8732b5f1e37d1177b230f8229b9d65b9c07f..1728ece3271aef723d0190fe8a2585bb5489be8a 100644 (file)
@@ -64,20 +64,22 @@ class RegisterController extends Controller
     protected function validator(array $data)
     {
         return Validator::make($data, [
     protected function validator(array $data)
     {
         return Validator::make($data, [
-            'name' => 'required|min:2|max:255',
-            'email' => 'required|email|max:255|unique:users',
+            'name'     => 'required|min:2|max:255',
+            'email'    => 'required|email|max:255|unique:users',
             'password' => 'required|min:8',
         ]);
     }
 
     /**
      * Show the application registration form.
             'password' => 'required|min:8',
         ]);
     }
 
     /**
      * Show the application registration form.
+     *
      * @throws UserRegistrationException
      */
     public function getRegister()
     {
         $this->registrationService->ensureRegistrationAllowed();
         $socialDrivers = $this->socialAuthService->getActiveDrivers();
      * @throws UserRegistrationException
      */
     public function getRegister()
     {
         $this->registrationService->ensureRegistrationAllowed();
         $socialDrivers = $this->socialAuthService->getActiveDrivers();
+
         return view('auth.register', [
             'socialDrivers' => $socialDrivers,
         ]);
         return view('auth.register', [
             'socialDrivers' => $socialDrivers,
         ]);
@@ -85,6 +87,7 @@ class RegisterController extends Controller
 
     /**
      * Handle a registration request for the application.
 
     /**
      * Handle a registration request for the application.
+     *
      * @throws UserRegistrationException
      */
     public function postRegister(Request $request)
      * @throws UserRegistrationException
      */
     public function postRegister(Request $request)
@@ -102,23 +105,27 @@ class RegisterController extends Controller
             if ($exception->getMessage()) {
                 $this->showErrorNotification($exception->getMessage());
             }
             if ($exception->getMessage()) {
                 $this->showErrorNotification($exception->getMessage());
             }
+
             return redirect($exception->redirectLocation);
         }
 
         $this->showSuccessNotification(trans('auth.register_success'));
             return redirect($exception->redirectLocation);
         }
 
         $this->showSuccessNotification(trans('auth.register_success'));
+
         return redirect($this->redirectPath());
     }
 
     /**
      * Create a new user instance after a valid registration.
         return redirect($this->redirectPath());
     }
 
     /**
      * Create a new user instance after a valid registration.
-     * @param  array  $data
+     *
+     * @param array $data
+     *
      * @return User
      */
     protected function create(array $data)
     {
         return User::create([
      * @return User
      */
     protected function create(array $data)
     {
         return User::create([
-            'name' => $data['name'],
-            'email' => $data['email'],
+            'name'     => $data['name'],
+            'email'    => $data['email'],
             'password' => Hash::make($data['password']),
         ]);
     }
             'password' => Hash::make($data['password']),
         ]);
     }
index 59e9ab79baa7cb146ed7582e1fc50cd88a7d9e31..a31529b119b502b2fbddc0d3779b147e628ba043 100644 (file)
@@ -40,7 +40,8 @@ class ResetPasswordController extends Controller
      * Get the response for a successful password reset.
      *
      * @param Request $request
      * Get the response for a successful password reset.
      *
      * @param Request $request
-     * @param string $response
+     * @param string  $response
+     *
      * @return \Illuminate\Http\Response
      */
     protected function sendResetResponse(Request $request, $response)
      * @return \Illuminate\Http\Response
      */
     protected function sendResetResponse(Request $request, $response)
@@ -48,6 +49,7 @@ class ResetPasswordController extends Controller
         $message = trans('auth.reset_password_success');
         $this->showSuccessNotification($message);
         $this->logActivity(ActivityType::AUTH_PASSWORD_RESET_UPDATE, user());
         $message = trans('auth.reset_password_success');
         $this->showSuccessNotification($message);
         $this->logActivity(ActivityType::AUTH_PASSWORD_RESET_UPDATE, user());
+
         return redirect($this->redirectPath())
             ->with('status', trans($response));
     }
         return redirect($this->redirectPath())
             ->with('status', trans($response));
     }
@@ -55,8 +57,9 @@ class ResetPasswordController extends Controller
     /**
      * Get the response for a failed password reset.
      *
     /**
      * Get the response for a failed password reset.
      *
-     * @param  \Illuminate\Http\Request  $request
-     * @param  string  $response
+     * @param \Illuminate\Http\Request $request
+     * @param string                   $response
+     *
      * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
      */
     protected function sendResetFailedResponse(Request $request, $response)
      * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
      */
     protected function sendResetFailedResponse(Request $request, $response)
index dc7814c4b173055bdb07c5c4a0e298249c113e65..14eb65b717de6076ecbd76f1d352b877146c95f7 100644 (file)
@@ -7,7 +7,6 @@ use BookStack\Http\Controllers\Controller;
 
 class Saml2Controller extends Controller
 {
 
 class Saml2Controller extends Controller
 {
-
     protected $samlService;
 
     /**
     protected $samlService;
 
     /**
@@ -50,8 +49,9 @@ class Saml2Controller extends Controller
     public function metadata()
     {
         $metaData = $this->samlService->metadata();
     public function metadata()
     {
         $metaData = $this->samlService->metadata();
+
         return response()->make($metaData, 200, [
         return response()->make($metaData, 200, [
-            'Content-Type' => 'text/xml'
+            'Content-Type' => 'text/xml',
         ]);
     }
 
         ]);
     }
 
@@ -63,6 +63,7 @@ class Saml2Controller extends Controller
     {
         $requestId = session()->pull('saml2_logout_request_id', null);
         $redirect = $this->samlService->processSlsResponse($requestId) ?? '/';
     {
         $requestId = session()->pull('saml2_logout_request_id', null);
         $redirect = $this->samlService->processSlsResponse($requestId) ?? '/';
+
         return redirect($redirect);
     }
 
         return redirect($redirect);
     }
 
@@ -77,6 +78,7 @@ class Saml2Controller extends Controller
         $user = $this->samlService->processAcsResponse($requestId);
         if ($user === null) {
             $this->showErrorNotification(trans('errors.saml_fail_authed', ['system' => config('saml2.name')]));
         $user = $this->samlService->processAcsResponse($requestId);
         if ($user === null) {
             $this->showErrorNotification(trans('errors.saml_fail_authed', ['system' => config('saml2.name')]));
+
             return redirect('/login');
         }
 
             return redirect('/login');
         }
 
index 447f0afc9358f85eb8e7975ea08930878c332c1a..1d1468698734ce8d61e5d415838af11212e4e0f6 100644 (file)
@@ -18,7 +18,6 @@ use Laravel\Socialite\Contracts\User as SocialUser;
 
 class SocialController extends Controller
 {
 
 class SocialController extends Controller
 {
-
     protected $socialAuthService;
     protected $registrationService;
 
     protected $socialAuthService;
     protected $registrationService;
 
@@ -34,16 +33,19 @@ class SocialController extends Controller
 
     /**
      * Redirect to the relevant social site.
 
     /**
      * Redirect to the relevant social site.
+     *
      * @throws SocialDriverNotConfigured
      */
     public function login(string $socialDriver)
     {
         session()->put('social-callback', 'login');
      * @throws SocialDriverNotConfigured
      */
     public function login(string $socialDriver)
     {
         session()->put('social-callback', 'login');
+
         return $this->socialAuthService->startLogIn($socialDriver);
     }
 
     /**
      * Redirect to the social site for authentication intended to register.
         return $this->socialAuthService->startLogIn($socialDriver);
     }
 
     /**
      * Redirect to the social site for authentication intended to register.
+     *
      * @throws SocialDriverNotConfigured
      * @throws UserRegistrationException
      */
      * @throws SocialDriverNotConfigured
      * @throws UserRegistrationException
      */
@@ -51,11 +53,13 @@ class SocialController extends Controller
     {
         $this->registrationService->ensureRegistrationAllowed();
         session()->put('social-callback', 'register');
     {
         $this->registrationService->ensureRegistrationAllowed();
         session()->put('social-callback', 'register');
+
         return $this->socialAuthService->startRegister($socialDriver);
     }
 
     /**
      * The callback for social login services.
         return $this->socialAuthService->startRegister($socialDriver);
     }
 
     /**
      * The callback for social login services.
+     *
      * @throws SocialSignInException
      * @throws SocialDriverNotConfigured
      * @throws UserRegistrationException
      * @throws SocialSignInException
      * @throws SocialDriverNotConfigured
      * @throws UserRegistrationException
@@ -70,7 +74,7 @@ class SocialController extends Controller
         if ($request->has('error') && $request->has('error_description')) {
             throw new SocialSignInException(trans('errors.social_login_bad_response', [
                 'socialAccount' => $socialDriver,
         if ($request->has('error') && $request->has('error_description')) {
             throw new SocialSignInException(trans('errors.social_login_bad_response', [
                 'socialAccount' => $socialDriver,
-                'error' => $request->get('error_description'),
+                'error'         => $request->get('error_description'),
             ]), '/login');
         }
 
             ]), '/login');
         }
 
@@ -85,6 +89,7 @@ class SocialController extends Controller
                 if ($this->socialAuthService->driverAutoRegisterEnabled($socialDriver)) {
                     return $this->socialRegisterCallback($socialDriver, $socialUser);
                 }
                 if ($this->socialAuthService->driverAutoRegisterEnabled($socialDriver)) {
                     return $this->socialRegisterCallback($socialDriver, $socialUser);
                 }
+
                 throw $exception;
             }
         }
                 throw $exception;
             }
         }
@@ -103,11 +108,13 @@ class SocialController extends Controller
     {
         $this->socialAuthService->detachSocialAccount($socialDriver);
         session()->flash('success', trans('settings.users_social_disconnected', ['socialAccount' => Str::title($socialDriver)]));
     {
         $this->socialAuthService->detachSocialAccount($socialDriver);
         session()->flash('success', trans('settings.users_social_disconnected', ['socialAccount' => Str::title($socialDriver)]));
+
         return redirect(user()->getEditUrl());
     }
 
     /**
      * Register a new user after a registration callback.
         return redirect(user()->getEditUrl());
     }
 
     /**
      * Register a new user after a registration callback.
+     *
      * @throws UserRegistrationException
      */
     protected function socialRegisterCallback(string $socialDriver, SocialUser $socialUser)
      * @throws UserRegistrationException
      */
     protected function socialRegisterCallback(string $socialDriver, SocialUser $socialUser)
@@ -118,9 +125,9 @@ class SocialController extends Controller
 
         // Create an array of the user data to create a new user instance
         $userData = [
 
         // Create an array of the user data to create a new user instance
         $userData = [
-            'name' => $socialUser->getName(),
-            'email' => $socialUser->getEmail(),
-            'password' => Str::random(32)
+            'name'     => $socialUser->getName(),
+            'email'    => $socialUser->getEmail(),
+            'password' => Str::random(32),
         ];
 
         // Take name from email address if empty
         ];
 
         // Take name from email address if empty
@@ -134,6 +141,7 @@ class SocialController extends Controller
         $this->logActivity(ActivityType::AUTH_LOGIN, $user);
 
         $this->showSuccessNotification(trans('auth.register_success'));
         $this->logActivity(ActivityType::AUTH_LOGIN, $user);
 
         $this->showSuccessNotification(trans('auth.register_success'));
+
         return redirect('/');
     }
 }
         return redirect('/');
     }
 }
index ab745224836d4e82477e0513999d049c07a4528f..253e2550713b00ded9e5b6720a617cb891d706f6 100644 (file)
@@ -34,6 +34,7 @@ class UserInviteController extends Controller
 
     /**
      * Show the page for the user to set the password for their account.
 
     /**
      * Show the page for the user to set the password for their account.
+     *
      * @throws Exception
      */
     public function showSetPassword(string $token)
      * @throws Exception
      */
     public function showSetPassword(string $token)
@@ -51,12 +52,13 @@ class UserInviteController extends Controller
 
     /**
      * Sets the password for an invited user and then grants them access.
 
     /**
      * Sets the password for an invited user and then grants them access.
+     *
      * @throws Exception
      */
     public function setPassword(Request $request, string $token)
     {
         $this->validate($request, [
      * @throws Exception
      */
     public function setPassword(Request $request, string $token)
     {
         $this->validate($request, [
-            'password' => 'required|min:8'
+            'password' => 'required|min:8',
         ]);
 
         try {
         ]);
 
         try {
@@ -81,8 +83,10 @@ class UserInviteController extends Controller
 
     /**
      * Check and validate the exception thrown when checking an invite token.
 
     /**
      * Check and validate the exception thrown when checking an invite token.
-     * @return RedirectResponse|Redirector
+     *
      * @throws Exception
      * @throws Exception
+     *
+     * @return RedirectResponse|Redirector
      */
     protected function handleTokenException(Exception $exception)
     {
      */
     protected function handleTokenException(Exception $exception)
     {
@@ -92,6 +96,7 @@ class UserInviteController extends Controller
 
         if ($exception instanceof UserTokenExpiredException) {
             $this->showErrorNotification(trans('errors.invite_token_expired'));
 
         if ($exception instanceof UserTokenExpiredException) {
             $this->showErrorNotification(trans('errors.invite_token_expired'));
+
             return redirect('/password/email');
         }
 
             return redirect('/password/email');
         }
 
index 64ae982d565a35707cbdef1d0e417366cc7df2f5..7c099377cb6eebddc1338d0e59616ddc468c2722 100644 (file)
@@ -1,13 +1,15 @@
-<?php namespace BookStack\Http\Controllers;
+<?php
+
+namespace BookStack\Http\Controllers;
 
 use Activity;
 use BookStack\Actions\ActivityType;
 use BookStack\Actions\View;
 
 use Activity;
 use BookStack\Actions\ActivityType;
 use BookStack\Actions\View;
-use BookStack\Entities\Tools\BookContents;
 use BookStack\Entities\Models\Bookshelf;
 use BookStack\Entities\Models\Bookshelf;
+use BookStack\Entities\Repos\BookRepo;
+use BookStack\Entities\Tools\BookContents;
 use BookStack\Entities\Tools\PermissionsUpdater;
 use BookStack\Entities\Tools\ShelfContext;
 use BookStack\Entities\Tools\PermissionsUpdater;
 use BookStack\Entities\Tools\ShelfContext;
-use BookStack\Entities\Repos\BookRepo;
 use BookStack\Exceptions\ImageUploadException;
 use Illuminate\Http\Request;
 use Illuminate\Validation\ValidationException;
 use BookStack\Exceptions\ImageUploadException;
 use Illuminate\Http\Request;
 use Illuminate\Validation\ValidationException;
@@ -15,7 +17,6 @@ use Throwable;
 
 class BookController extends Controller
 {
 
 class BookController extends Controller
 {
-
     protected $bookRepo;
     protected $entityContextManager;
 
     protected $bookRepo;
     protected $entityContextManager;
 
@@ -42,14 +43,15 @@ class BookController extends Controller
         $this->entityContextManager->clearShelfContext();
 
         $this->setPageTitle(trans('entities.books'));
         $this->entityContextManager->clearShelfContext();
 
         $this->setPageTitle(trans('entities.books'));
+
         return view('books.index', [
         return view('books.index', [
-            'books' => $books,
+            'books'   => $books,
             'recents' => $recents,
             'popular' => $popular,
             'recents' => $recents,
             'popular' => $popular,
-            'new' => $new,
-            'view' => $view,
-            'sort' => $sort,
-            'order' => $order,
+            'new'     => $new,
+            'view'    => $view,
+            'sort'    => $sort,
+            'order'   => $order,
         ]);
     }
 
         ]);
     }
 
@@ -67,13 +69,15 @@ class BookController extends Controller
         }
 
         $this->setPageTitle(trans('entities.books_create'));
         }
 
         $this->setPageTitle(trans('entities.books_create'));
+
         return view('books.create', [
         return view('books.create', [
-            'bookshelf' => $bookshelf
+            'bookshelf' => $bookshelf,
         ]);
     }
 
     /**
      * Store a newly created book in storage.
         ]);
     }
 
     /**
      * Store a newly created book in storage.
+     *
      * @throws ImageUploadException
      * @throws ValidationException
      */
      * @throws ImageUploadException
      * @throws ValidationException
      */
@@ -81,9 +85,9 @@ class BookController extends Controller
     {
         $this->checkPermission('book-create-all');
         $this->validate($request, [
     {
         $this->checkPermission('book-create-all');
         $this->validate($request, [
-            'name' => 'required|string|max:255',
+            'name'        => 'required|string|max:255',
             'description' => 'string|max:1000',
             'description' => 'string|max:1000',
-            'image' => 'nullable|' . $this->getImageValidationRules(),
+            'image'       => 'nullable|' . $this->getImageValidationRules(),
         ]);
 
         $bookshelf = null;
         ]);
 
         $bookshelf = null;
@@ -118,12 +122,13 @@ class BookController extends Controller
         }
 
         $this->setPageTitle($book->getShortName());
         }
 
         $this->setPageTitle($book->getShortName());
+
         return view('books.show', [
         return view('books.show', [
-            'book' => $book,
-            'current' => $book,
-            'bookChildren' => $bookChildren,
+            'book'              => $book,
+            'current'           => $book,
+            'bookChildren'      => $bookChildren,
             'bookParentShelves' => $bookParentShelves,
             'bookParentShelves' => $bookParentShelves,
-            'activity' => Activity::entityActivity($book, 20, 1)
+            'activity'          => Activity::entityActivity($book, 20, 1),
         ]);
     }
 
         ]);
     }
 
@@ -135,11 +140,13 @@ class BookController extends Controller
         $book = $this->bookRepo->getBySlug($slug);
         $this->checkOwnablePermission('book-update', $book);
         $this->setPageTitle(trans('entities.books_edit_named', ['bookName'=>$book->getShortName()]));
         $book = $this->bookRepo->getBySlug($slug);
         $this->checkOwnablePermission('book-update', $book);
         $this->setPageTitle(trans('entities.books_edit_named', ['bookName'=>$book->getShortName()]));
+
         return view('books.edit', ['book' => $book, 'current' => $book]);
     }
 
     /**
      * Update the specified book in storage.
         return view('books.edit', ['book' => $book, 'current' => $book]);
     }
 
     /**
      * Update the specified book in storage.
+     *
      * @throws ImageUploadException
      * @throws ValidationException
      * @throws Throwable
      * @throws ImageUploadException
      * @throws ValidationException
      * @throws Throwable
@@ -149,9 +156,9 @@ class BookController extends Controller
         $book = $this->bookRepo->getBySlug($slug);
         $this->checkOwnablePermission('book-update', $book);
         $this->validate($request, [
         $book = $this->bookRepo->getBySlug($slug);
         $this->checkOwnablePermission('book-update', $book);
         $this->validate($request, [
-            'name' => 'required|string|max:255',
+            'name'        => 'required|string|max:255',
             'description' => 'string|max:1000',
             'description' => 'string|max:1000',
-            'image' => 'nullable|' . $this->getImageValidationRules(),
+            'image'       => 'nullable|' . $this->getImageValidationRules(),
         ]);
 
         $book = $this->bookRepo->update($book, $request->all());
         ]);
 
         $book = $this->bookRepo->update($book, $request->all());
@@ -169,11 +176,13 @@ class BookController extends Controller
         $book = $this->bookRepo->getBySlug($bookSlug);
         $this->checkOwnablePermission('book-delete', $book);
         $this->setPageTitle(trans('entities.books_delete_named', ['bookName' => $book->getShortName()]));
         $book = $this->bookRepo->getBySlug($bookSlug);
         $this->checkOwnablePermission('book-delete', $book);
         $this->setPageTitle(trans('entities.books_delete_named', ['bookName' => $book->getShortName()]));
+
         return view('books.delete', ['book' => $book, 'current' => $book]);
     }
 
     /**
      * Remove the specified book from the system.
         return view('books.delete', ['book' => $book, 'current' => $book]);
     }
 
     /**
      * Remove the specified book from the system.
+     *
      * @throws Throwable
      */
     public function destroy(string $bookSlug)
      * @throws Throwable
      */
     public function destroy(string $bookSlug)
@@ -201,6 +210,7 @@ class BookController extends Controller
 
     /**
      * Set the restrictions for this book.
 
     /**
      * Set the restrictions for this book.
+     *
      * @throws Throwable
      */
     public function permissions(Request $request, PermissionsUpdater $permissionsUpdater, string $bookSlug)
      * @throws Throwable
      */
     public function permissions(Request $request, PermissionsUpdater $permissionsUpdater, string $bookSlug)
@@ -211,6 +221,7 @@ class BookController extends Controller
         $permissionsUpdater->updateFromPermissionsForm($book, $request);
 
         $this->showSuccessNotification(trans('entities.books_permissions_updated'));
         $permissionsUpdater->updateFromPermissionsForm($book, $request);
 
         $this->showSuccessNotification(trans('entities.books_permissions_updated'));
+
         return redirect($book->getUrl());
     }
 }
         return redirect($book->getUrl());
     }
 }
index 6d334ca737d62a3079d0695ee79a2601f252d923..5e6d7c6adc8f22f970550814825c43f3451fb2a3 100644 (file)
@@ -2,13 +2,12 @@
 
 namespace BookStack\Http\Controllers;
 
 
 namespace BookStack\Http\Controllers;
 
-use BookStack\Entities\Tools\ExportFormatter;
 use BookStack\Entities\Repos\BookRepo;
 use BookStack\Entities\Repos\BookRepo;
+use BookStack\Entities\Tools\ExportFormatter;
 use Throwable;
 
 class BookExportController extends Controller
 {
 use Throwable;
 
 class BookExportController extends Controller
 {
-
     protected $bookRepo;
     protected $exportFormatter;
 
     protected $bookRepo;
     protected $exportFormatter;
 
@@ -23,23 +22,27 @@ class BookExportController extends Controller
 
     /**
      * Export a book as a PDF file.
 
     /**
      * Export a book as a PDF file.
+     *
      * @throws Throwable
      */
     public function pdf(string $bookSlug)
     {
         $book = $this->bookRepo->getBySlug($bookSlug);
         $pdfContent = $this->exportFormatter->bookToPdf($book);
      * @throws Throwable
      */
     public function pdf(string $bookSlug)
     {
         $book = $this->bookRepo->getBySlug($bookSlug);
         $pdfContent = $this->exportFormatter->bookToPdf($book);
+
         return $this->downloadResponse($pdfContent, $bookSlug . '.pdf');
     }
 
     /**
      * Export a book as a contained HTML file.
         return $this->downloadResponse($pdfContent, $bookSlug . '.pdf');
     }
 
     /**
      * Export a book as a contained HTML file.
+     *
      * @throws Throwable
      */
     public function html(string $bookSlug)
     {
         $book = $this->bookRepo->getBySlug($bookSlug);
         $htmlContent = $this->exportFormatter->bookToContainedHtml($book);
      * @throws Throwable
      */
     public function html(string $bookSlug)
     {
         $book = $this->bookRepo->getBySlug($bookSlug);
         $htmlContent = $this->exportFormatter->bookToContainedHtml($book);
+
         return $this->downloadResponse($htmlContent, $bookSlug . '.html');
     }
 
         return $this->downloadResponse($htmlContent, $bookSlug . '.html');
     }
 
@@ -50,6 +53,7 @@ class BookExportController extends Controller
     {
         $book = $this->bookRepo->getBySlug($bookSlug);
         $textContent = $this->exportFormatter->bookToPlainText($book);
     {
         $book = $this->bookRepo->getBySlug($bookSlug);
         $textContent = $this->exportFormatter->bookToPlainText($book);
+
         return $this->downloadResponse($textContent, $bookSlug . '.txt');
     }
 
         return $this->downloadResponse($textContent, $bookSlug . '.txt');
     }
 
@@ -60,6 +64,7 @@ class BookExportController extends Controller
     {
         $book = $this->bookRepo->getBySlug($bookSlug);
         $textContent = $this->exportFormatter->bookToMarkdown($book);
     {
         $book = $this->bookRepo->getBySlug($bookSlug);
         $textContent = $this->exportFormatter->bookToMarkdown($book);
+
         return $this->downloadResponse($textContent, $bookSlug . '.md');
     }
 }
         return $this->downloadResponse($textContent, $bookSlug . '.md');
     }
 }
index 6d3199cbee990fe90b484c2b3a3bc6d4c73a54b8..bc67a8e1cc6c1cff00641a6c731d6dec3b7b578f 100644 (file)
@@ -4,15 +4,14 @@ namespace BookStack\Http\Controllers;
 
 use BookStack\Actions\ActivityType;
 use BookStack\Entities\Models\Book;
 
 use BookStack\Actions\ActivityType;
 use BookStack\Entities\Models\Book;
-use BookStack\Entities\Tools\BookContents;
 use BookStack\Entities\Repos\BookRepo;
 use BookStack\Entities\Repos\BookRepo;
+use BookStack\Entities\Tools\BookContents;
 use BookStack\Exceptions\SortOperationException;
 use BookStack\Facades\Activity;
 use Illuminate\Http\Request;
 
 class BookSortController extends Controller
 {
 use BookStack\Exceptions\SortOperationException;
 use BookStack\Facades\Activity;
 use Illuminate\Http\Request;
 
 class BookSortController extends Controller
 {
-
     protected $bookRepo;
 
     public function __construct(BookRepo $bookRepo)
     protected $bookRepo;
 
     public function __construct(BookRepo $bookRepo)
@@ -31,6 +30,7 @@ class BookSortController extends Controller
         $bookChildren = (new BookContents($book))->getTree(false);
 
         $this->setPageTitle(trans('entities.books_sort_named', ['bookName'=>$book->getShortName()]));
         $bookChildren = (new BookContents($book))->getTree(false);
 
         $this->setPageTitle(trans('entities.books_sort_named', ['bookName'=>$book->getShortName()]));
+
         return view('books.sort', ['book' => $book, 'current' => $book, 'bookChildren' => $bookChildren]);
     }
 
         return view('books.sort', ['book' => $book, 'current' => $book, 'bookChildren' => $bookChildren]);
     }
 
@@ -42,6 +42,7 @@ class BookSortController extends Controller
     {
         $book = $this->bookRepo->getBySlug($bookSlug);
         $bookChildren = (new BookContents($book))->getTree();
     {
         $book = $this->bookRepo->getBySlug($bookSlug);
         $bookChildren = (new BookContents($book))->getTree();
+
         return view('books.sort-box', ['book' => $book, 'bookChildren' => $bookChildren]);
     }
 
         return view('books.sort-box', ['book' => $book, 'bookChildren' => $bookChildren]);
     }
 
index b4795db09029d3c6ea2d6a8136c98c8ee66bb039..da16d782281241112989661ee37c44d93a82bbf4 100644 (file)
@@ -1,22 +1,22 @@
-<?php namespace BookStack\Http\Controllers;
+<?php
+
+namespace BookStack\Http\Controllers;
 
 use Activity;
 use BookStack\Actions\View;
 use BookStack\Entities\Models\Book;
 
 use Activity;
 use BookStack\Actions\View;
 use BookStack\Entities\Models\Book;
+use BookStack\Entities\Repos\BookshelfRepo;
 use BookStack\Entities\Tools\PermissionsUpdater;
 use BookStack\Entities\Tools\ShelfContext;
 use BookStack\Entities\Tools\PermissionsUpdater;
 use BookStack\Entities\Tools\ShelfContext;
-use BookStack\Entities\Repos\BookshelfRepo;
 use BookStack\Exceptions\ImageUploadException;
 use BookStack\Exceptions\NotFoundException;
 use BookStack\Uploads\ImageRepo;
 use Exception;
 use Illuminate\Http\Request;
 use Illuminate\Validation\ValidationException;
 use BookStack\Exceptions\ImageUploadException;
 use BookStack\Exceptions\NotFoundException;
 use BookStack\Uploads\ImageRepo;
 use Exception;
 use Illuminate\Http\Request;
 use Illuminate\Validation\ValidationException;
-use Views;
 
 class BookshelfController extends Controller
 {
 
 class BookshelfController extends Controller
 {
-
     protected $bookshelfRepo;
     protected $entityContextManager;
     protected $imageRepo;
     protected $bookshelfRepo;
     protected $entityContextManager;
     protected $imageRepo;
@@ -37,7 +37,7 @@ class BookshelfController extends Controller
         $sort = setting()->getForCurrentUser('bookshelves_sort', 'name');
         $order = setting()->getForCurrentUser('bookshelves_sort_order', 'asc');
         $sortOptions = [
         $sort = setting()->getForCurrentUser('bookshelves_sort', 'name');
         $order = setting()->getForCurrentUser('bookshelves_sort_order', 'asc');
         $sortOptions = [
-            'name' => trans('common.sort_name'),
+            'name'       => trans('common.sort_name'),
             'created_at' => trans('common.sort_created_at'),
             'updated_at' => trans('common.sort_updated_at'),
         ];
             'created_at' => trans('common.sort_created_at'),
             'updated_at' => trans('common.sort_updated_at'),
         ];
@@ -49,14 +49,15 @@ class BookshelfController extends Controller
 
         $this->entityContextManager->clearShelfContext();
         $this->setPageTitle(trans('entities.shelves'));
 
         $this->entityContextManager->clearShelfContext();
         $this->setPageTitle(trans('entities.shelves'));
+
         return view('shelves.index', [
         return view('shelves.index', [
-            'shelves' => $shelves,
-            'recents' => $recents,
-            'popular' => $popular,
-            'new' => $new,
-            'view' => $view,
-            'sort' => $sort,
-            'order' => $order,
+            'shelves'     => $shelves,
+            'recents'     => $recents,
+            'popular'     => $popular,
+            'new'         => $new,
+            'view'        => $view,
+            'sort'        => $sort,
+            'order'       => $order,
             'sortOptions' => $sortOptions,
         ]);
     }
             'sortOptions' => $sortOptions,
         ]);
     }
@@ -69,11 +70,13 @@ class BookshelfController extends Controller
         $this->checkPermission('bookshelf-create-all');
         $books = Book::hasPermission('update')->get();
         $this->setPageTitle(trans('entities.shelves_create'));
         $this->checkPermission('bookshelf-create-all');
         $books = Book::hasPermission('update')->get();
         $this->setPageTitle(trans('entities.shelves_create'));
+
         return view('shelves.create', ['books' => $books]);
     }
 
     /**
      * Store a newly created bookshelf in storage.
         return view('shelves.create', ['books' => $books]);
     }
 
     /**
      * Store a newly created bookshelf in storage.
+     *
      * @throws ValidationException
      * @throws ImageUploadException
      */
      * @throws ValidationException
      * @throws ImageUploadException
      */
@@ -81,9 +84,9 @@ class BookshelfController extends Controller
     {
         $this->checkPermission('bookshelf-create-all');
         $this->validate($request, [
     {
         $this->checkPermission('bookshelf-create-all');
         $this->validate($request, [
-            'name' => 'required|string|max:255',
+            'name'        => 'required|string|max:255',
             'description' => 'string|max:1000',
             'description' => 'string|max:1000',
-            'image' => 'nullable|' . $this->getImageValidationRules(),
+            'image'       => 'nullable|' . $this->getImageValidationRules(),
         ]);
 
         $bookIds = explode(',', $request->get('books', ''));
         ]);
 
         $bookIds = explode(',', $request->get('books', ''));
@@ -95,6 +98,7 @@ class BookshelfController extends Controller
 
     /**
      * Display the bookshelf of the given slug.
 
     /**
      * Display the bookshelf of the given slug.
+     *
      * @throws NotFoundException
      */
     public function show(string $slug)
      * @throws NotFoundException
      */
     public function show(string $slug)
@@ -115,13 +119,14 @@ class BookshelfController extends Controller
         $view = setting()->getForCurrentUser('bookshelf_view_type');
 
         $this->setPageTitle($shelf->getShortName());
         $view = setting()->getForCurrentUser('bookshelf_view_type');
 
         $this->setPageTitle($shelf->getShortName());
+
         return view('shelves.show', [
         return view('shelves.show', [
-            'shelf' => $shelf,
+            'shelf'                   => $shelf,
             'sortedVisibleShelfBooks' => $sortedVisibleShelfBooks,
             'sortedVisibleShelfBooks' => $sortedVisibleShelfBooks,
-            'view' => $view,
-            'activity' => Activity::entityActivity($shelf, 20, 1),
-            'order' => $order,
-            'sort' => $sort
+            'view'                    => $view,
+            'activity'                => Activity::entityActivity($shelf, 20, 1),
+            'order'                   => $order,
+            'sort'                    => $sort,
         ]);
     }
 
         ]);
     }
 
@@ -137,6 +142,7 @@ class BookshelfController extends Controller
         $books = Book::hasPermission('update')->whereNotIn('id', $shelfBookIds)->get();
 
         $this->setPageTitle(trans('entities.shelves_edit_named', ['name' => $shelf->getShortName()]));
         $books = Book::hasPermission('update')->whereNotIn('id', $shelfBookIds)->get();
 
         $this->setPageTitle(trans('entities.shelves_edit_named', ['name' => $shelf->getShortName()]));
+
         return view('shelves.edit', [
             'shelf' => $shelf,
             'books' => $books,
         return view('shelves.edit', [
             'shelf' => $shelf,
             'books' => $books,
@@ -145,6 +151,7 @@ class BookshelfController extends Controller
 
     /**
      * Update the specified bookshelf in storage.
 
     /**
      * Update the specified bookshelf in storage.
+     *
      * @throws ValidationException
      * @throws ImageUploadException
      * @throws NotFoundException
      * @throws ValidationException
      * @throws ImageUploadException
      * @throws NotFoundException
@@ -154,12 +161,11 @@ class BookshelfController extends Controller
         $shelf = $this->bookshelfRepo->getBySlug($slug);
         $this->checkOwnablePermission('bookshelf-update', $shelf);
         $this->validate($request, [
         $shelf = $this->bookshelfRepo->getBySlug($slug);
         $this->checkOwnablePermission('bookshelf-update', $shelf);
         $this->validate($request, [
-            'name' => 'required|string|max:255',
+            'name'        => 'required|string|max:255',
             'description' => 'string|max:1000',
             'description' => 'string|max:1000',
-            'image' => 'nullable|' . $this->getImageValidationRules(),
+            'image'       => 'nullable|' . $this->getImageValidationRules(),
         ]);
 
         ]);
 
-
         $bookIds = explode(',', $request->get('books', ''));
         $shelf = $this->bookshelfRepo->update($shelf, $request->all(), $bookIds);
         $resetCover = $request->has('image_reset');
         $bookIds = explode(',', $request->get('books', ''));
         $shelf = $this->bookshelfRepo->update($shelf, $request->all(), $bookIds);
         $resetCover = $request->has('image_reset');
@@ -169,7 +175,7 @@ class BookshelfController extends Controller
     }
 
     /**
     }
 
     /**
-     * Shows the page to confirm deletion
+     * Shows the page to confirm deletion.
      */
     public function showDelete(string $slug)
     {
      */
     public function showDelete(string $slug)
     {
@@ -177,11 +183,13 @@ class BookshelfController extends Controller
         $this->checkOwnablePermission('bookshelf-delete', $shelf);
 
         $this->setPageTitle(trans('entities.shelves_delete_named', ['name' => $shelf->getShortName()]));
         $this->checkOwnablePermission('bookshelf-delete', $shelf);
 
         $this->setPageTitle(trans('entities.shelves_delete_named', ['name' => $shelf->getShortName()]));
+
         return view('shelves.delete', ['shelf' => $shelf]);
     }
 
     /**
      * Remove the specified bookshelf from storage.
         return view('shelves.delete', ['shelf' => $shelf]);
     }
 
     /**
      * Remove the specified bookshelf from storage.
+     *
      * @throws Exception
      */
     public function destroy(string $slug)
      * @throws Exception
      */
     public function destroy(string $slug)
@@ -218,6 +226,7 @@ class BookshelfController extends Controller
         $permissionsUpdater->updateFromPermissionsForm($shelf, $request);
 
         $this->showSuccessNotification(trans('entities.shelves_permissions_updated'));
         $permissionsUpdater->updateFromPermissionsForm($shelf, $request);
 
         $this->showSuccessNotification(trans('entities.shelves_permissions_updated'));
+
         return redirect($shelf->getUrl());
     }
 
         return redirect($shelf->getUrl());
     }
 
@@ -231,6 +240,7 @@ class BookshelfController extends Controller
 
         $updateCount = $this->bookshelfRepo->copyDownPermissions($shelf);
         $this->showSuccessNotification(trans('entities.shelves_copy_permission_success', ['count' => $updateCount]));
 
         $updateCount = $this->bookshelfRepo->copyDownPermissions($shelf);
         $this->showSuccessNotification(trans('entities.shelves_copy_permission_success', ['count' => $updateCount]));
+
         return redirect($shelf->getUrl());
     }
 }
         return redirect($shelf->getUrl());
     }
 }
index d65b43cc12e701782628e838353f44dfc0fb6cb2..b27fb4f7747f99ff5e60f72723f3d6eebe47944b 100644 (file)
@@ -1,9 +1,11 @@
-<?php namespace BookStack\Http\Controllers;
+<?php
+
+namespace BookStack\Http\Controllers;
 
 use BookStack\Actions\View;
 use BookStack\Entities\Models\Book;
 
 use BookStack\Actions\View;
 use BookStack\Entities\Models\Book;
-use BookStack\Entities\Tools\BookContents;
 use BookStack\Entities\Repos\ChapterRepo;
 use BookStack\Entities\Repos\ChapterRepo;
+use BookStack\Entities\Tools\BookContents;
 use BookStack\Entities\Tools\NextPreviousContentLocator;
 use BookStack\Entities\Tools\PermissionsUpdater;
 use BookStack\Exceptions\MoveOperationException;
 use BookStack\Entities\Tools\NextPreviousContentLocator;
 use BookStack\Entities\Tools\PermissionsUpdater;
 use BookStack\Exceptions\MoveOperationException;
@@ -14,7 +16,6 @@ use Throwable;
 
 class ChapterController extends Controller
 {
 
 class ChapterController extends Controller
 {
-
     protected $chapterRepo;
 
     /**
     protected $chapterRepo;
 
     /**
@@ -34,17 +35,19 @@ class ChapterController extends Controller
         $this->checkOwnablePermission('chapter-create', $book);
 
         $this->setPageTitle(trans('entities.chapters_create'));
         $this->checkOwnablePermission('chapter-create', $book);
 
         $this->setPageTitle(trans('entities.chapters_create'));
+
         return view('chapters.create', ['book' => $book, 'current' => $book]);
     }
 
     /**
      * Store a newly created chapter in storage.
         return view('chapters.create', ['book' => $book, 'current' => $book]);
     }
 
     /**
      * Store a newly created chapter in storage.
+     *
      * @throws ValidationException
      */
     public function store(Request $request, string $bookSlug)
     {
         $this->validate($request, [
      * @throws ValidationException
      */
     public function store(Request $request, string $bookSlug)
     {
         $this->validate($request, [
-            'name' => 'required|string|max:255'
+            'name' => 'required|string|max:255',
         ]);
 
         $book = Book::visible()->where('slug', '=', $bookSlug)->firstOrFail();
         ]);
 
         $book = Book::visible()->where('slug', '=', $bookSlug)->firstOrFail();
@@ -69,14 +72,15 @@ class ChapterController extends Controller
         View::incrementFor($chapter);
 
         $this->setPageTitle($chapter->getShortName());
         View::incrementFor($chapter);
 
         $this->setPageTitle($chapter->getShortName());
+
         return view('chapters.show', [
         return view('chapters.show', [
-            'book' => $chapter->book,
-            'chapter' => $chapter,
-            'current' => $chapter,
+            'book'        => $chapter->book,
+            'chapter'     => $chapter,
+            'current'     => $chapter,
             'sidebarTree' => $sidebarTree,
             'sidebarTree' => $sidebarTree,
-            'pages' => $pages,
-            'next' => $nextPreviousLocator->getNext(),
-            'previous' => $nextPreviousLocator->getPrevious(),
+            'pages'       => $pages,
+            'next'        => $nextPreviousLocator->getNext(),
+            'previous'    => $nextPreviousLocator->getPrevious(),
         ]);
     }
 
         ]);
     }
 
@@ -89,11 +93,13 @@ class ChapterController extends Controller
         $this->checkOwnablePermission('chapter-update', $chapter);
 
         $this->setPageTitle(trans('entities.chapters_edit_named', ['chapterName' => $chapter->getShortName()]));
         $this->checkOwnablePermission('chapter-update', $chapter);
 
         $this->setPageTitle(trans('entities.chapters_edit_named', ['chapterName' => $chapter->getShortName()]));
+
         return view('chapters.edit', ['book' => $chapter->book, 'chapter' => $chapter, 'current' => $chapter]);
     }
 
     /**
      * Update the specified chapter in storage.
         return view('chapters.edit', ['book' => $chapter->book, 'chapter' => $chapter, 'current' => $chapter]);
     }
 
     /**
      * Update the specified chapter in storage.
+     *
      * @throws NotFoundException
      */
     public function update(Request $request, string $bookSlug, string $chapterSlug)
      * @throws NotFoundException
      */
     public function update(Request $request, string $bookSlug, string $chapterSlug)
@@ -108,6 +114,7 @@ class ChapterController extends Controller
 
     /**
      * Shows the page to confirm deletion of this chapter.
 
     /**
      * Shows the page to confirm deletion of this chapter.
+     *
      * @throws NotFoundException
      */
     public function showDelete(string $bookSlug, string $chapterSlug)
      * @throws NotFoundException
      */
     public function showDelete(string $bookSlug, string $chapterSlug)
@@ -116,11 +123,13 @@ class ChapterController extends Controller
         $this->checkOwnablePermission('chapter-delete', $chapter);
 
         $this->setPageTitle(trans('entities.chapters_delete_named', ['chapterName' => $chapter->getShortName()]));
         $this->checkOwnablePermission('chapter-delete', $chapter);
 
         $this->setPageTitle(trans('entities.chapters_delete_named', ['chapterName' => $chapter->getShortName()]));
+
         return view('chapters.delete', ['book' => $chapter->book, 'chapter' => $chapter, 'current' => $chapter]);
     }
 
     /**
      * Remove the specified chapter from storage.
         return view('chapters.delete', ['book' => $chapter->book, 'chapter' => $chapter, 'current' => $chapter]);
     }
 
     /**
      * Remove the specified chapter from storage.
+     *
      * @throws NotFoundException
      * @throws Throwable
      */
      * @throws NotFoundException
      * @throws Throwable
      */
@@ -136,6 +145,7 @@ class ChapterController extends Controller
 
     /**
      * Show the page for moving a chapter.
 
     /**
      * Show the page for moving a chapter.
+     *
      * @throws NotFoundException
      */
     public function showMove(string $bookSlug, string $chapterSlug)
      * @throws NotFoundException
      */
     public function showMove(string $bookSlug, string $chapterSlug)
@@ -147,12 +157,13 @@ class ChapterController extends Controller
 
         return view('chapters.move', [
             'chapter' => $chapter,
 
         return view('chapters.move', [
             'chapter' => $chapter,
-            'book' => $chapter->book
+            'book'    => $chapter->book,
         ]);
     }
 
     /**
      * Perform the move action for a chapter.
         ]);
     }
 
     /**
      * Perform the move action for a chapter.
+     *
      * @throws NotFoundException
      */
     public function move(Request $request, string $bookSlug, string $chapterSlug)
      * @throws NotFoundException
      */
     public function move(Request $request, string $bookSlug, string $chapterSlug)
@@ -170,15 +181,18 @@ class ChapterController extends Controller
             $newBook = $this->chapterRepo->move($chapter, $entitySelection);
         } catch (MoveOperationException $exception) {
             $this->showErrorNotification(trans('errors.selected_book_not_found'));
             $newBook = $this->chapterRepo->move($chapter, $entitySelection);
         } catch (MoveOperationException $exception) {
             $this->showErrorNotification(trans('errors.selected_book_not_found'));
+
             return redirect()->back();
         }
 
         $this->showSuccessNotification(trans('entities.chapter_move_success', ['bookName' => $newBook->name]));
             return redirect()->back();
         }
 
         $this->showSuccessNotification(trans('entities.chapter_move_success', ['bookName' => $newBook->name]));
+
         return redirect($chapter->getUrl());
     }
 
     /**
      * Show the Restrictions view.
         return redirect($chapter->getUrl());
     }
 
     /**
      * Show the Restrictions view.
+     *
      * @throws NotFoundException
      */
     public function showPermissions(string $bookSlug, string $chapterSlug)
      * @throws NotFoundException
      */
     public function showPermissions(string $bookSlug, string $chapterSlug)
@@ -193,6 +207,7 @@ class ChapterController extends Controller
 
     /**
      * Set the restrictions for this chapter.
 
     /**
      * Set the restrictions for this chapter.
+     *
      * @throws NotFoundException
      */
     public function permissions(Request $request, PermissionsUpdater $permissionsUpdater, string $bookSlug, string $chapterSlug)
      * @throws NotFoundException
      */
     public function permissions(Request $request, PermissionsUpdater $permissionsUpdater, string $bookSlug, string $chapterSlug)
@@ -203,6 +218,7 @@ class ChapterController extends Controller
         $permissionsUpdater->updateFromPermissionsForm($chapter, $request);
 
         $this->showSuccessNotification(trans('entities.chapters_permissions_success'));
         $permissionsUpdater->updateFromPermissionsForm($chapter, $request);
 
         $this->showSuccessNotification(trans('entities.chapters_permissions_success'));
+
         return redirect($chapter->getUrl());
     }
 }
         return redirect($chapter->getUrl());
     }
 }
index b934eefce616f68269449c418f2574d7381b4b64..2758496d2062b307964774e4a669ff8884cd75bc 100644 (file)
@@ -1,13 +1,14 @@
-<?php namespace BookStack\Http\Controllers;
+<?php
+
+namespace BookStack\Http\Controllers;
 
 
-use BookStack\Entities\Tools\ExportFormatter;
 use BookStack\Entities\Repos\ChapterRepo;
 use BookStack\Entities\Repos\ChapterRepo;
+use BookStack\Entities\Tools\ExportFormatter;
 use BookStack\Exceptions\NotFoundException;
 use Throwable;
 
 class ChapterExportController extends Controller
 {
 use BookStack\Exceptions\NotFoundException;
 use Throwable;
 
 class ChapterExportController extends Controller
 {
-
     protected $chapterRepo;
     protected $exportFormatter;
 
     protected $chapterRepo;
     protected $exportFormatter;
 
@@ -22,6 +23,7 @@ class ChapterExportController extends Controller
 
     /**
      * Exports a chapter to pdf.
 
     /**
      * Exports a chapter to pdf.
+     *
      * @throws NotFoundException
      * @throws Throwable
      */
      * @throws NotFoundException
      * @throws Throwable
      */
@@ -29,11 +31,13 @@ class ChapterExportController extends Controller
     {
         $chapter = $this->chapterRepo->getBySlug($bookSlug, $chapterSlug);
         $pdfContent = $this->exportFormatter->chapterToPdf($chapter);
     {
         $chapter = $this->chapterRepo->getBySlug($bookSlug, $chapterSlug);
         $pdfContent = $this->exportFormatter->chapterToPdf($chapter);
+
         return $this->downloadResponse($pdfContent, $chapterSlug . '.pdf');
     }
 
     /**
      * Export a chapter to a self-contained HTML file.
         return $this->downloadResponse($pdfContent, $chapterSlug . '.pdf');
     }
 
     /**
      * Export a chapter to a self-contained HTML file.
+     *
      * @throws NotFoundException
      * @throws Throwable
      */
      * @throws NotFoundException
      * @throws Throwable
      */
@@ -41,22 +45,26 @@ class ChapterExportController extends Controller
     {
         $chapter = $this->chapterRepo->getBySlug($bookSlug, $chapterSlug);
         $containedHtml = $this->exportFormatter->chapterToContainedHtml($chapter);
     {
         $chapter = $this->chapterRepo->getBySlug($bookSlug, $chapterSlug);
         $containedHtml = $this->exportFormatter->chapterToContainedHtml($chapter);
+
         return $this->downloadResponse($containedHtml, $chapterSlug . '.html');
     }
 
     /**
      * Export a chapter to a simple plaintext .txt file.
         return $this->downloadResponse($containedHtml, $chapterSlug . '.html');
     }
 
     /**
      * Export a chapter to a simple plaintext .txt file.
+     *
      * @throws NotFoundException
      */
     public function plainText(string $bookSlug, string $chapterSlug)
     {
         $chapter = $this->chapterRepo->getBySlug($bookSlug, $chapterSlug);
         $chapterText = $this->exportFormatter->chapterToPlainText($chapter);
      * @throws NotFoundException
      */
     public function plainText(string $bookSlug, string $chapterSlug)
     {
         $chapter = $this->chapterRepo->getBySlug($bookSlug, $chapterSlug);
         $chapterText = $this->exportFormatter->chapterToPlainText($chapter);
+
         return $this->downloadResponse($chapterText, $chapterSlug . '.txt');
     }
 
     /**
      * Export a chapter to a simple markdown file.
         return $this->downloadResponse($chapterText, $chapterSlug . '.txt');
     }
 
     /**
      * Export a chapter to a simple markdown file.
+     *
      * @throws NotFoundException
      */
     public function markdown(string $bookSlug, string $chapterSlug)
      * @throws NotFoundException
      */
     public function markdown(string $bookSlug, string $chapterSlug)
@@ -64,6 +72,7 @@ class ChapterExportController extends Controller
         // TODO: This should probably export to a zip file.
         $chapter = $this->chapterRepo->getBySlug($bookSlug, $chapterSlug);
         $chapterText = $this->exportFormatter->chapterToMarkdown($chapter);
         // TODO: This should probably export to a zip file.
         $chapter = $this->chapterRepo->getBySlug($bookSlug, $chapterSlug);
         $chapterText = $this->exportFormatter->chapterToMarkdown($chapter);
+
         return $this->downloadResponse($chapterText, $chapterSlug . '.md');
     }
 }
         return $this->downloadResponse($chapterText, $chapterSlug . '.md');
     }
 }
index bf1a76f518f3ce70f2792bd1138bc309ca961d4d..dfe468f5f6f0992f9ebe73d0639567e8dec40141 100644 (file)
@@ -1,7 +1,7 @@
-<?php namespace BookStack\Http\Controllers;
+<?php
+
+namespace BookStack\Http\Controllers;
 
 
-use Activity;
-use BookStack\Actions\ActivityType;
 use BookStack\Actions\CommentRepo;
 use BookStack\Entities\Models\Page;
 use Illuminate\Http\Request;
 use BookStack\Actions\CommentRepo;
 use BookStack\Entities\Models\Page;
 use Illuminate\Http\Request;
@@ -17,13 +17,14 @@ class CommentController extends Controller
     }
 
     /**
     }
 
     /**
-     * Save a new comment for a Page
+     * Save a new comment for a Page.
+     *
      * @throws ValidationException
      */
     public function savePageComment(Request $request, int $pageId)
     {
         $this->validate($request, [
      * @throws ValidationException
      */
     public function savePageComment(Request $request, int $pageId)
     {
         $this->validate($request, [
-            'text' => 'required|string',
+            'text'      => 'required|string',
             'parent_id' => 'nullable|integer',
         ]);
 
             'parent_id' => 'nullable|integer',
         ]);
 
@@ -40,11 +41,13 @@ class CommentController extends Controller
         // Create a new comment.
         $this->checkPermission('comment-create-all');
         $comment = $this->commentRepo->create($page, $request->get('text'), $request->get('parent_id'));
         // Create a new comment.
         $this->checkPermission('comment-create-all');
         $comment = $this->commentRepo->create($page, $request->get('text'), $request->get('parent_id'));
+
         return view('comments.comment', ['comment' => $comment]);
     }
 
     /**
      * Update an existing comment.
         return view('comments.comment', ['comment' => $comment]);
     }
 
     /**
      * Update an existing comment.
+     *
      * @throws ValidationException
      */
     public function update(Request $request, int $commentId)
      * @throws ValidationException
      */
     public function update(Request $request, int $commentId)
@@ -58,6 +61,7 @@ class CommentController extends Controller
         $this->checkOwnablePermission('comment-update', $comment);
 
         $comment = $this->commentRepo->update($comment, $request->get('text'));
         $this->checkOwnablePermission('comment-update', $comment);
 
         $comment = $this->commentRepo->update($comment, $request->get('text'));
+
         return view('comments.comment', ['comment' => $comment]);
     }
 
         return view('comments.comment', ['comment' => $comment]);
     }
 
@@ -70,6 +74,7 @@ class CommentController extends Controller
         $this->checkOwnablePermission('comment-delete', $comment);
 
         $this->commentRepo->delete($comment);
         $this->checkOwnablePermission('comment-delete', $comment);
 
         $this->commentRepo->delete($comment);
+
         return response()->json(['message' => trans('entities.comment_deleted')]);
     }
 }
         return response()->json(['message' => trans('entities.comment_deleted')]);
     }
 }
index 47b03b28d48aaa29610ef562635670af6adbb630..283a01cfb6a8852f23c0d73c9ef975189572492c 100644 (file)
@@ -4,7 +4,6 @@ namespace BookStack\Http\Controllers;
 
 use BookStack\Facades\Activity;
 use BookStack\Interfaces\Loggable;
 
 use BookStack\Facades\Activity;
 use BookStack\Interfaces\Loggable;
-use BookStack\HasCreatorAndUpdater;
 use BookStack\Model;
 use finfo;
 use Illuminate\Foundation\Bus\DispatchesJobs;
 use BookStack\Model;
 use finfo;
 use Illuminate\Foundation\Bus\DispatchesJobs;
@@ -16,7 +15,8 @@ use Illuminate\Routing\Controller as BaseController;
 
 abstract class Controller extends BaseController
 {
 
 abstract class Controller extends BaseController
 {
-    use DispatchesJobs, ValidatesRequests;
+    use DispatchesJobs;
+    use ValidatesRequests;
 
     /**
      * Check if the current user is signed in.
 
     /**
      * Check if the current user is signed in.
@@ -106,7 +106,7 @@ abstract class Controller extends BaseController
     /**
      * Send back a json error message.
      */
     /**
      * Send back a json error message.
      */
-    protected function jsonError(string $messageText = "", int $statusCode = 500): JsonResponse
+    protected function jsonError(string $messageText = '', int $statusCode = 500): JsonResponse
     {
         return response()->json(['message' => $messageText, 'status' => 'error'], $statusCode);
     }
     {
         return response()->json(['message' => $messageText, 'status' => 'error'], $statusCode);
     }
@@ -118,7 +118,7 @@ abstract class Controller extends BaseController
     {
         return response()->make($content, 200, [
             'Content-Type'        => 'application/octet-stream',
     {
         return response()->make($content, 200, [
             'Content-Type'        => 'application/octet-stream',
-            'Content-Disposition' => 'attachment; filename="' . $fileName . '"'
+            'Content-Disposition' => 'attachment; filename="' . $fileName . '"',
         ]);
     }
 
         ]);
     }
 
@@ -130,9 +130,10 @@ abstract class Controller extends BaseController
     {
         $finfo = new finfo(FILEINFO_MIME_TYPE);
         $mime = $finfo->buffer($content) ?: 'application/octet-stream';
     {
         $finfo = new finfo(FILEINFO_MIME_TYPE);
         $mime = $finfo->buffer($content) ?: 'application/octet-stream';
+
         return response()->make($content, 200, [
             'Content-Type'        => $mime,
         return response()->make($content, 200, [
             'Content-Type'        => $mime,
-            'Content-Disposition' => 'inline; filename="' . $fileName . '"'
+            'Content-Disposition' => 'inline; filename="' . $fileName . '"',
         ]);
     }
 
         ]);
     }
 
@@ -162,6 +163,7 @@ abstract class Controller extends BaseController
 
     /**
      * Log an activity in the system.
 
     /**
      * Log an activity in the system.
+     *
      * @param string|Loggable
      */
     protected function logActivity(string $type, $detail = ''): void
      * @param string|Loggable
      */
     protected function logActivity(string $type, $detail = ''): void
index f4aeb4faa1389c16f484fbaed3113a283b07aa7d..a990ff825789f0bc6ed544ebf606e3dfa4d6aeb5 100644 (file)
@@ -17,13 +17,13 @@ class FavouriteController extends Controller
     {
         $viewCount = 20;
         $page = intval($request->get('page', 1));
     {
         $viewCount = 20;
         $page = intval($request->get('page', 1));
-        $favourites = (new TopFavourites)->run($viewCount + 1, (($page - 1) * $viewCount));
+        $favourites = (new TopFavourites())->run($viewCount + 1, (($page - 1) * $viewCount));
 
 
-        $hasMoreLink = ($favourites->count() > $viewCount) ? url("/favourites?page=" . ($page+1)) : null;
+        $hasMoreLink = ($favourites->count() > $viewCount) ? url('/favourites?page=' . ($page + 1)) : null;
 
         return view('common.detailed-listing-with-more', [
 
         return view('common.detailed-listing-with-more', [
-            'title' => trans('entities.my_favourites'),
-            'entities' => $favourites->slice(0, $viewCount),
+            'title'       => trans('entities.my_favourites'),
+            'entities'    => $favourites->slice(0, $viewCount),
             'hasMoreLink' => $hasMoreLink,
         ]);
     }
             'hasMoreLink' => $hasMoreLink,
         ]);
     }
@@ -41,6 +41,7 @@ class FavouriteController extends Controller
         $this->showSuccessNotification(trans('activities.favourite_add_notification', [
             'name' => $favouritable->name,
         ]));
         $this->showSuccessNotification(trans('activities.favourite_add_notification', [
             'name' => $favouritable->name,
         ]));
+
         return redirect()->back();
     }
 
         return redirect()->back();
     }
 
@@ -57,6 +58,7 @@ class FavouriteController extends Controller
         $this->showSuccessNotification(trans('activities.favourite_remove_notification', [
             'name' => $favouritable->name,
         ]));
         $this->showSuccessNotification(trans('activities.favourite_remove_notification', [
             'name' => $favouritable->name,
         ]));
+
         return redirect()->back();
     }
 
         return redirect()->back();
     }
 
@@ -68,7 +70,7 @@ class FavouriteController extends Controller
     {
         $modelInfo = $this->validate($request, [
             'type' => 'required|string',
     {
         $modelInfo = $this->validate($request, [
             'type' => 'required|string',
-            'id' => 'required|integer',
+            'id'   => 'required|integer',
         ]);
 
         if (!class_exists($modelInfo['type'])) {
         ]);
 
         if (!class_exists($modelInfo['type'])) {
@@ -76,8 +78,8 @@ class FavouriteController extends Controller
         }
 
         /** @var Model $model */
         }
 
         /** @var Model $model */
-        $model = new $modelInfo['type'];
-        if (! $model instanceof Favouritable) {
+        $model = new $modelInfo['type']();
+        if (!$model instanceof Favouritable) {
             throw new \Exception('Model not favouritable');
         }
 
             throw new \Exception('Model not favouritable');
         }
 
index 7bc17052652aa65652b762c9335aee9fd72eaf4f..4a71b56b9c1d44b41820ccd66242406181a3ac2d 100644 (file)
@@ -1,18 +1,19 @@
-<?php namespace BookStack\Http\Controllers;
+<?php
+
+namespace BookStack\Http\Controllers;
 
 use Activity;
 use BookStack\Entities\Models\Book;
 
 use Activity;
 use BookStack\Entities\Models\Book;
+use BookStack\Entities\Models\Page;
 use BookStack\Entities\Queries\RecentlyViewed;
 use BookStack\Entities\Queries\TopFavourites;
 use BookStack\Entities\Queries\RecentlyViewed;
 use BookStack\Entities\Queries\TopFavourites;
-use BookStack\Entities\Tools\PageContent;
-use BookStack\Entities\Models\Page;
 use BookStack\Entities\Repos\BookRepo;
 use BookStack\Entities\Repos\BookshelfRepo;
 use BookStack\Entities\Repos\BookRepo;
 use BookStack\Entities\Repos\BookshelfRepo;
+use BookStack\Entities\Tools\PageContent;
 use Views;
 
 class HomeController extends Controller
 {
 use Views;
 
 class HomeController extends Controller
 {
-
     /**
      * Display the homepage.
      */
     /**
      * Display the homepage.
      */
@@ -33,9 +34,9 @@ class HomeController extends Controller
 
         $recentFactor = count($draftPages) > 0 ? 0.5 : 1;
         $recents = $this->isSignedIn() ?
 
         $recentFactor = count($draftPages) > 0 ? 0.5 : 1;
         $recents = $this->isSignedIn() ?
-            (new RecentlyViewed)->run(12*$recentFactor, 1)
+            (new RecentlyViewed())->run(12 * $recentFactor, 1)
             : Book::visible()->orderBy('created_at', 'desc')->take(12 * $recentFactor)->get();
             : Book::visible()->orderBy('created_at', 'desc')->take(12 * $recentFactor)->get();
-        $favourites = (new TopFavourites)->run(6);
+        $favourites = (new TopFavourites())->run(6);
         $recentlyUpdatedPages = Page::visible()->with('book')
             ->where('draft', false)
             ->orderBy('updated_at', 'desc')
         $recentlyUpdatedPages = Page::visible()->with('book')
             ->where('draft', false)
             ->orderBy('updated_at', 'desc')
@@ -49,11 +50,11 @@ class HomeController extends Controller
         }
 
         $commonData = [
         }
 
         $commonData = [
-            'activity' => $activity,
-            'recents' => $recents,
+            'activity'             => $activity,
+            'recents'              => $recents,
             'recentlyUpdatedPages' => $recentlyUpdatedPages,
             'recentlyUpdatedPages' => $recentlyUpdatedPages,
-            'draftPages' => $draftPages,
-            'favourites' => $favourites,
+            'draftPages'           => $draftPages,
+            'favourites'           => $favourites,
         ];
 
         // Add required list ordering & sorting for books & shelves views.
         ];
 
         // Add required list ordering & sorting for books & shelves views.
@@ -64,15 +65,15 @@ class HomeController extends Controller
             $order = setting()->getForCurrentUser($key . '_sort_order', 'asc');
 
             $sortOptions = [
             $order = setting()->getForCurrentUser($key . '_sort_order', 'asc');
 
             $sortOptions = [
-                'name' => trans('common.sort_name'),
+                'name'       => trans('common.sort_name'),
                 'created_at' => trans('common.sort_created_at'),
                 'updated_at' => trans('common.sort_updated_at'),
             ];
 
             $commonData = array_merge($commonData, [
                 'created_at' => trans('common.sort_created_at'),
                 'updated_at' => trans('common.sort_updated_at'),
             ];
 
             $commonData = array_merge($commonData, [
-                'view' => $view,
-                'sort' => $sort,
-                'order' => $order,
+                'view'        => $view,
+                'sort'        => $sort,
+                'order'       => $order,
                 'sortOptions' => $sortOptions,
             ]);
         }
                 'sortOptions' => $sortOptions,
             ]);
         }
@@ -80,6 +81,7 @@ class HomeController extends Controller
         if ($homepageOption === 'bookshelves') {
             $shelves = app(BookshelfRepo::class)->getAllPaginated(18, $commonData['sort'], $commonData['order']);
             $data = array_merge($commonData, ['shelves' => $shelves]);
         if ($homepageOption === 'bookshelves') {
             $shelves = app(BookshelfRepo::class)->getAllPaginated(18, $commonData['sort'], $commonData['order']);
             $data = array_merge($commonData, ['shelves' => $shelves]);
+
             return view('common.home-shelves', $data);
         }
 
             return view('common.home-shelves', $data);
         }
 
@@ -87,6 +89,7 @@ class HomeController extends Controller
             $bookRepo = app(BookRepo::class);
             $books = $bookRepo->getAllPaginated(18, $commonData['sort'], $commonData['order']);
             $data = array_merge($commonData, ['books' => $books]);
             $bookRepo = app(BookRepo::class);
             $books = $bookRepo->getAllPaginated(18, $commonData['sort'], $commonData['order']);
             $data = array_merge($commonData, ['books' => $books]);
+
             return view('common.home-book', $data);
         }
 
             return view('common.home-book', $data);
         }
 
@@ -96,6 +99,7 @@ class HomeController extends Controller
             $customHomepage = Page::query()->where('draft', '=', false)->findOrFail($id);
             $pageContent = new PageContent($customHomepage);
             $customHomepage->html = $pageContent->render(true);
             $customHomepage = Page::query()->where('draft', '=', false)->findOrFail($id);
             $pageContent = new PageContent($customHomepage);
             $customHomepage->html = $pageContent->render(true);
+
             return view('common.home-custom', array_merge($commonData, ['customHomepage' => $customHomepage]));
         }
 
             return view('common.home-custom', array_merge($commonData, ['customHomepage' => $customHomepage]));
         }
 
@@ -104,6 +108,7 @@ class HomeController extends Controller
 
     /**
      * Get custom head HTML, Used in ajax calls to show in editor.
 
     /**
      * Get custom head HTML, Used in ajax calls to show in editor.
+     *
      * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
      */
     public function customHeadContent()
      * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
      */
     public function customHeadContent()
@@ -112,7 +117,7 @@ class HomeController extends Controller
     }
 
     /**
     }
 
     /**
-     * Show the view for /robots.txt
+     * Show the view for /robots.txt.
      */
     public function getRobots()
     {
      */
     public function getRobots()
     {
index 462ab68f6f32f66ee44ef4439d2448ff62e2c12e..2a4576df1d55f6c5253fb2065b8f2548a0b8f2c2 100644 (file)
@@ -3,10 +3,10 @@
 namespace BookStack\Http\Controllers\Images;
 
 use BookStack\Exceptions\ImageUploadException;
 namespace BookStack\Http\Controllers\Images;
 
 use BookStack\Exceptions\ImageUploadException;
+use BookStack\Http\Controllers\Controller;
 use BookStack\Uploads\ImageRepo;
 use Exception;
 use Illuminate\Http\Request;
 use BookStack\Uploads\ImageRepo;
 use Exception;
 use Illuminate\Http\Request;
-use BookStack\Http\Controllers\Controller;
 
 class DrawioImageController extends Controller
 {
 
 class DrawioImageController extends Controller
 {
@@ -29,21 +29,23 @@ class DrawioImageController extends Controller
         $parentTypeFilter = $request->get('filter_type', null);
 
         $imgData = $this->imageRepo->getEntityFiltered('drawio', $parentTypeFilter, $page, 24, $uploadedToFilter, $searchTerm);
         $parentTypeFilter = $request->get('filter_type', null);
 
         $imgData = $this->imageRepo->getEntityFiltered('drawio', $parentTypeFilter, $page, 24, $uploadedToFilter, $searchTerm);
+
         return view('components.image-manager-list', [
         return view('components.image-manager-list', [
-            'images' => $imgData['images'],
+            'images'  => $imgData['images'],
             'hasMore' => $imgData['has_more'],
         ]);
     }
 
     /**
      * Store a new gallery image in the system.
             'hasMore' => $imgData['has_more'],
         ]);
     }
 
     /**
      * Store a new gallery image in the system.
+     *
      * @throws Exception
      */
     public function create(Request $request)
     {
         $this->validate($request, [
      * @throws Exception
      */
     public function create(Request $request)
     {
         $this->validate($request, [
-            'image' => 'required|string',
-            'uploaded_to' => 'required|integer'
+            'image'       => 'required|string',
+            'uploaded_to' => 'required|integer',
         ]);
 
         $this->checkPermission('image-create-all');
         ]);
 
         $this->checkPermission('image-create-all');
@@ -67,16 +69,16 @@ class DrawioImageController extends Controller
         $image = $this->imageRepo->getById($id);
         $page = $image->getPage();
         if ($image === null || $image->type !== 'drawio' || !userCan('page-view', $page)) {
         $image = $this->imageRepo->getById($id);
         $page = $image->getPage();
         if ($image === null || $image->type !== 'drawio' || !userCan('page-view', $page)) {
-            return $this->jsonError("Image data could not be found");
+            return $this->jsonError('Image data could not be found');
         }
 
         $imageData = $this->imageRepo->getImageData($image);
         if ($imageData === null) {
         }
 
         $imageData = $this->imageRepo->getImageData($image);
         if ($imageData === null) {
-            return $this->jsonError("Image data could not be found");
+            return $this->jsonError('Image data could not be found');
         }
 
         return response()->json([
         }
 
         return response()->json([
-            'content' => base64_encode($imageData)
+            'content' => base64_encode($imageData),
         ]);
     }
 }
         ]);
     }
 }
index c3ad0b7b261fe6d5946de46eacf5f263715e7470..0f0b330eebf66a29b20cea8b071f261d64169459 100644 (file)
@@ -3,9 +3,9 @@
 namespace BookStack\Http\Controllers\Images;
 
 use BookStack\Exceptions\ImageUploadException;
 namespace BookStack\Http\Controllers\Images;
 
 use BookStack\Exceptions\ImageUploadException;
+use BookStack\Http\Controllers\Controller;
 use BookStack\Uploads\ImageRepo;
 use Illuminate\Http\Request;
 use BookStack\Uploads\ImageRepo;
 use Illuminate\Http\Request;
-use BookStack\Http\Controllers\Controller;
 use Illuminate\Validation\ValidationException;
 
 class GalleryImageController extends Controller
 use Illuminate\Validation\ValidationException;
 
 class GalleryImageController extends Controller
@@ -32,21 +32,23 @@ class GalleryImageController extends Controller
         $parentTypeFilter = $request->get('filter_type', null);
 
         $imgData = $this->imageRepo->getEntityFiltered('gallery', $parentTypeFilter, $page, 24, $uploadedToFilter, $searchTerm);
         $parentTypeFilter = $request->get('filter_type', null);
 
         $imgData = $this->imageRepo->getEntityFiltered('gallery', $parentTypeFilter, $page, 24, $uploadedToFilter, $searchTerm);
+
         return view('components.image-manager-list', [
         return view('components.image-manager-list', [
-            'images' => $imgData['images'],
+            'images'  => $imgData['images'],
             'hasMore' => $imgData['has_more'],
         ]);
     }
 
     /**
      * Store a new gallery image in the system.
             'hasMore' => $imgData['has_more'],
         ]);
     }
 
     /**
      * Store a new gallery image in the system.
+     *
      * @throws ValidationException
      */
     public function create(Request $request)
     {
         $this->checkPermission('image-create-all');
         $this->validate($request, [
      * @throws ValidationException
      */
     public function create(Request $request)
     {
         $this->checkPermission('image-create-all');
         $this->validate($request, [
-            'file' => $this->getImageValidationRules()
+            'file' => $this->getImageValidationRules(),
         ]);
 
         try {
         ]);
 
         try {
index 1eb8917b360edb2fb90ddaff26eff1e2028d137a..4c97378879bd6833cf001a288bfb440993d028bb 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Http\Controllers\Images;
+<?php
+
+namespace BookStack\Http\Controllers\Images;
 
 use BookStack\Exceptions\ImageUploadException;
 use BookStack\Exceptions\NotFoundException;
 
 use BookStack\Exceptions\ImageUploadException;
 use BookStack\Exceptions\NotFoundException;
@@ -28,6 +30,7 @@ class ImageController extends Controller
 
     /**
      * Provide an image file from storage.
 
     /**
      * Provide an image file from storage.
+     *
      * @throws NotFoundException
      */
     public function showImage(string $path)
      * @throws NotFoundException
      */
     public function showImage(string $path)
@@ -42,16 +45,16 @@ class ImageController extends Controller
         return response()->file($path);
     }
 
         return response()->file($path);
     }
 
-
     /**
     /**
-     * Update image details
+     * Update image details.
+     *
      * @throws ImageUploadException
      * @throws ValidationException
      */
     public function update(Request $request, string $id)
     {
         $this->validate($request, [
      * @throws ImageUploadException
      * @throws ValidationException
      */
     public function update(Request $request, string $id)
     {
         $this->validate($request, [
-            'name' => 'required|min:2|string'
+            'name' => 'required|min:2|string',
         ]);
 
         $image = $this->imageRepo->getById($id);
         ]);
 
         $image = $this->imageRepo->getById($id);
@@ -61,14 +64,16 @@ class ImageController extends Controller
         $image = $this->imageRepo->updateImageDetails($image, $request->all());
 
         $this->imageRepo->loadThumbs($image);
         $image = $this->imageRepo->updateImageDetails($image, $request->all());
 
         $this->imageRepo->loadThumbs($image);
+
         return view('components.image-manager-form', [
         return view('components.image-manager-form', [
-            'image' => $image,
+            'image'          => $image,
             'dependantPages' => null,
         ]);
     }
 
     /**
      * Get the form for editing the given image.
             'dependantPages' => null,
         ]);
     }
 
     /**
      * Get the form for editing the given image.
+     *
      * @throws Exception
      */
     public function edit(Request $request, string $id)
      * @throws Exception
      */
     public function edit(Request $request, string $id)
@@ -81,14 +86,16 @@ class ImageController extends Controller
         }
 
         $this->imageRepo->loadThumbs($image);
         }
 
         $this->imageRepo->loadThumbs($image);
+
         return view('components.image-manager-form', [
         return view('components.image-manager-form', [
-            'image' => $image,
+            'image'          => $image,
             'dependantPages' => $dependantPages ?? null,
         ]);
     }
 
     /**
             'dependantPages' => $dependantPages ?? null,
         ]);
     }
 
     /**
-     * Deletes an image and all thumbnail/image files
+     * Deletes an image and all thumbnail/image files.
+     *
      * @throws Exception
      */
     public function destroy(string $id)
      * @throws Exception
      */
     public function destroy(string $id)
@@ -98,6 +105,7 @@ class ImageController extends Controller
         $this->checkImagePermission($image);
 
         $this->imageRepo->destroyImage($image);
         $this->checkImagePermission($image);
 
         $this->imageRepo->destroyImage($image);
+
         return response('');
     }
 
         return response('');
     }
 
index 3354a148cfd1f08a628b0f30c0f15d7a4f15b21b..d6abe468298170833f33477b95eb471a95331186 100644 (file)
@@ -25,7 +25,7 @@ class MaintenanceController extends Controller
         $recycleStats = (new TrashCan())->getTrashedCounts();
 
         return view('settings.maintenance', [
         $recycleStats = (new TrashCan())->getTrashedCounts();
 
         return view('settings.maintenance', [
-            'version' => $version,
+            'version'      => $version,
             'recycleStats' => $recycleStats,
         ]);
     }
             'recycleStats' => $recycleStats,
         ]);
     }
@@ -45,6 +45,7 @@ class MaintenanceController extends Controller
         $deleteCount = count($imagesToDelete);
         if ($deleteCount === 0) {
             $this->showWarningNotification(trans('settings.maint_image_cleanup_nothing_found'));
         $deleteCount = count($imagesToDelete);
         if ($deleteCount === 0) {
             $this->showWarningNotification(trans('settings.maint_image_cleanup_nothing_found'));
+
             return redirect('/settings/maintenance')->withInput();
         }
 
             return redirect('/settings/maintenance')->withInput();
         }
 
index 31ee4e970bd4952c9a9613863a723d33f7972560..853ac28fc4c770501f056d4972acfc2c4399f4aa 100644 (file)
@@ -1,12 +1,14 @@
-<?php namespace BookStack\Http\Controllers;
+<?php
+
+namespace BookStack\Http\Controllers;
 
 use BookStack\Actions\View;
 
 use BookStack\Actions\View;
+use BookStack\Entities\Models\Page;
+use BookStack\Entities\Repos\PageRepo;
 use BookStack\Entities\Tools\BookContents;
 use BookStack\Entities\Tools\NextPreviousContentLocator;
 use BookStack\Entities\Tools\PageContent;
 use BookStack\Entities\Tools\PageEditActivity;
 use BookStack\Entities\Tools\BookContents;
 use BookStack\Entities\Tools\NextPreviousContentLocator;
 use BookStack\Entities\Tools\PageContent;
 use BookStack\Entities\Tools\PageEditActivity;
-use BookStack\Entities\Models\Page;
-use BookStack\Entities\Repos\PageRepo;
 use BookStack\Entities\Tools\PermissionsUpdater;
 use BookStack\Exceptions\NotFoundException;
 use BookStack\Exceptions\PermissionsException;
 use BookStack\Entities\Tools\PermissionsUpdater;
 use BookStack\Exceptions\NotFoundException;
 use BookStack\Exceptions\PermissionsException;
@@ -17,7 +19,6 @@ use Throwable;
 
 class PageController extends Controller
 {
 
 class PageController extends Controller
 {
-
     protected $pageRepo;
 
     /**
     protected $pageRepo;
 
     /**
@@ -30,6 +31,7 @@ class PageController extends Controller
 
     /**
      * Show the form for creating a new page.
 
     /**
      * Show the form for creating a new page.
+     *
      * @throws Throwable
      */
     public function create(string $bookSlug, string $chapterSlug = null)
      * @throws Throwable
      */
     public function create(string $bookSlug, string $chapterSlug = null)
@@ -40,22 +42,25 @@ class PageController extends Controller
         // Redirect to draft edit screen if signed in
         if ($this->isSignedIn()) {
             $draft = $this->pageRepo->getNewDraftPage($parent);
         // Redirect to draft edit screen if signed in
         if ($this->isSignedIn()) {
             $draft = $this->pageRepo->getNewDraftPage($parent);
+
             return redirect($draft->getUrl());
         }
 
         // Otherwise show the edit view if they're a guest
         $this->setPageTitle(trans('entities.pages_new'));
             return redirect($draft->getUrl());
         }
 
         // Otherwise show the edit view if they're a guest
         $this->setPageTitle(trans('entities.pages_new'));
+
         return view('pages.guest-create', ['parent' => $parent]);
     }
 
     /**
      * Create a new page as a guest user.
         return view('pages.guest-create', ['parent' => $parent]);
     }
 
     /**
      * Create a new page as a guest user.
+     *
      * @throws ValidationException
      */
     public function createAsGuest(Request $request, string $bookSlug, string $chapterSlug = null)
     {
         $this->validate($request, [
      * @throws ValidationException
      */
     public function createAsGuest(Request $request, string $bookSlug, string $chapterSlug = null)
     {
         $this->validate($request, [
-            'name' => 'required|string|max:255'
+            'name' => 'required|string|max:255',
         ]);
 
         $parent = $this->pageRepo->getParentFromSlugs($bookSlug, $chapterSlug);
         ]);
 
         $parent = $this->pageRepo->getParentFromSlugs($bookSlug, $chapterSlug);
@@ -64,7 +69,7 @@ class PageController extends Controller
         $page = $this->pageRepo->getNewDraftPage($parent);
         $this->pageRepo->publishDraft($page, [
             'name' => $request->get('name'),
         $page = $this->pageRepo->getNewDraftPage($parent);
         $this->pageRepo->publishDraft($page, [
             'name' => $request->get('name'),
-            'html' => ''
+            'html' => '',
         ]);
 
         return redirect($page->getUrl('/edit'));
         ]);
 
         return redirect($page->getUrl('/edit'));
@@ -72,6 +77,7 @@ class PageController extends Controller
 
     /**
      * Show form to continue editing a draft page.
 
     /**
      * Show form to continue editing a draft page.
+     *
      * @throws NotFoundException
      */
     public function editDraft(string $bookSlug, int $pageId)
      * @throws NotFoundException
      */
     public function editDraft(string $bookSlug, int $pageId)
@@ -84,23 +90,24 @@ class PageController extends Controller
         $templates = $this->pageRepo->getTemplates(10);
 
         return view('pages.edit', [
         $templates = $this->pageRepo->getTemplates(10);
 
         return view('pages.edit', [
-            'page' => $draft,
-            'book' => $draft->book,
-            'isDraft' => true,
+            'page'          => $draft,
+            'book'          => $draft->book,
+            'isDraft'       => true,
             'draftsEnabled' => $draftsEnabled,
             'draftsEnabled' => $draftsEnabled,
-            'templates' => $templates,
+            'templates'     => $templates,
         ]);
     }
 
     /**
      * Store a new page by changing a draft into a page.
         ]);
     }
 
     /**
      * Store a new page by changing a draft into a page.
+     *
      * @throws NotFoundException
      * @throws ValidationException
      */
     public function store(Request $request, string $bookSlug, int $pageId)
     {
         $this->validate($request, [
      * @throws NotFoundException
      * @throws ValidationException
      */
     public function store(Request $request, string $bookSlug, int $pageId)
     {
         $this->validate($request, [
-            'name' => 'required|string|max:255'
+            'name' => 'required|string|max:255',
         ]);
         $draftPage = $this->pageRepo->getById($pageId);
         $this->checkOwnablePermission('page-create', $draftPage->getParent());
         ]);
         $draftPage = $this->pageRepo->getById($pageId);
         $this->checkOwnablePermission('page-create', $draftPage->getParent());
@@ -113,6 +120,7 @@ class PageController extends Controller
     /**
      * Display the specified page.
      * If the page is not found via the slug the revisions are searched for a match.
     /**
      * Display the specified page.
      * If the page is not found via the slug the revisions are searched for a match.
+     *
      * @throws NotFoundException
      */
     public function show(string $bookSlug, string $pageSlug)
      * @throws NotFoundException
      */
     public function show(string $bookSlug, string $pageSlug)
@@ -146,20 +154,22 @@ class PageController extends Controller
 
         View::incrementFor($page);
         $this->setPageTitle($page->getShortName());
 
         View::incrementFor($page);
         $this->setPageTitle($page->getShortName());
+
         return view('pages.show', [
         return view('pages.show', [
-            'page' => $page,
-            'book' => $page->book,
-            'current' => $page,
-            'sidebarTree' => $sidebarTree,
+            'page'            => $page,
+            'book'            => $page->book,
+            'current'         => $page,
+            'sidebarTree'     => $sidebarTree,
             'commentsEnabled' => $commentsEnabled,
             'commentsEnabled' => $commentsEnabled,
-            'pageNav' => $pageNav,
-            'next' => $nextPreviousLocator->getNext(),
-            'previous' => $nextPreviousLocator->getPrevious(),
+            'pageNav'         => $pageNav,
+            'next'            => $nextPreviousLocator->getNext(),
+            'previous'        => $nextPreviousLocator->getPrevious(),
         ]);
     }
 
     /**
      * Get page from an ajax request.
         ]);
     }
 
     /**
      * Get page from an ajax request.
+     *
      * @throws NotFoundException
      */
     public function getPageAjax(int $pageId)
      * @throws NotFoundException
      */
     public function getPageAjax(int $pageId)
@@ -167,11 +177,13 @@ class PageController extends Controller
         $page = $this->pageRepo->getById($pageId);
         $page->setHidden(array_diff($page->getHidden(), ['html', 'markdown']));
         $page->addHidden(['book']);
         $page = $this->pageRepo->getById($pageId);
         $page->setHidden(array_diff($page->getHidden(), ['html', 'markdown']));
         $page->addHidden(['book']);
+
         return response()->json($page);
     }
 
     /**
      * Show the form for editing the specified page.
         return response()->json($page);
     }
 
     /**
      * Show the form for editing the specified page.
+     *
      * @throws NotFoundException
      */
     public function edit(string $bookSlug, string $pageSlug)
      * @throws NotFoundException
      */
     public function edit(string $bookSlug, string $pageSlug)
@@ -203,24 +215,26 @@ class PageController extends Controller
         $templates = $this->pageRepo->getTemplates(10);
         $draftsEnabled = $this->isSignedIn();
         $this->setPageTitle(trans('entities.pages_editing_named', ['pageName' => $page->getShortName()]));
         $templates = $this->pageRepo->getTemplates(10);
         $draftsEnabled = $this->isSignedIn();
         $this->setPageTitle(trans('entities.pages_editing_named', ['pageName' => $page->getShortName()]));
+
         return view('pages.edit', [
         return view('pages.edit', [
-            'page' => $page,
-            'book' => $page->book,
-            'current' => $page,
+            'page'          => $page,
+            'book'          => $page->book,
+            'current'       => $page,
             'draftsEnabled' => $draftsEnabled,
             'draftsEnabled' => $draftsEnabled,
-            'templates' => $templates,
+            'templates'     => $templates,
         ]);
     }
 
     /**
      * Update the specified page in storage.
         ]);
     }
 
     /**
      * Update the specified page in storage.
+     *
      * @throws ValidationException
      * @throws NotFoundException
      */
     public function update(Request $request, string $bookSlug, string $pageSlug)
     {
         $this->validate($request, [
      * @throws ValidationException
      * @throws NotFoundException
      */
     public function update(Request $request, string $bookSlug, string $pageSlug)
     {
         $this->validate($request, [
-            'name' => 'required|string|max:255'
+            'name' => 'required|string|max:255',
         ]);
         $page = $this->pageRepo->getBySlug($bookSlug, $pageSlug);
         $this->checkOwnablePermission('page-update', $page);
         ]);
         $page = $this->pageRepo->getBySlug($bookSlug, $pageSlug);
         $this->checkOwnablePermission('page-update', $page);
@@ -232,6 +246,7 @@ class PageController extends Controller
 
     /**
      * Save a draft update as a revision.
 
     /**
      * Save a draft update as a revision.
+     *
      * @throws NotFoundException
      */
     public function saveDraft(Request $request, int $pageId)
      * @throws NotFoundException
      */
     public function saveDraft(Request $request, int $pageId)
@@ -246,25 +261,29 @@ class PageController extends Controller
         $draft = $this->pageRepo->updatePageDraft($page, $request->only(['name', 'html', 'markdown']));
 
         $updateTime = $draft->updated_at->timestamp;
         $draft = $this->pageRepo->updatePageDraft($page, $request->only(['name', 'html', 'markdown']));
 
         $updateTime = $draft->updated_at->timestamp;
+
         return response()->json([
         return response()->json([
-            'status' => 'success',
-            'message' => trans('entities.pages_edit_draft_save_at'),
-            'timestamp' => $updateTime
+            'status'    => 'success',
+            'message'   => trans('entities.pages_edit_draft_save_at'),
+            'timestamp' => $updateTime,
         ]);
     }
 
     /**
      * Redirect from a special link url which uses the page id rather than the name.
         ]);
     }
 
     /**
      * Redirect from a special link url which uses the page id rather than the name.
+     *
      * @throws NotFoundException
      */
     public function redirectFromLink(int $pageId)
     {
         $page = $this->pageRepo->getById($pageId);
      * @throws NotFoundException
      */
     public function redirectFromLink(int $pageId)
     {
         $page = $this->pageRepo->getById($pageId);
+
         return redirect($page->getUrl());
     }
 
     /**
      * Show the deletion page for the specified page.
         return redirect($page->getUrl());
     }
 
     /**
      * Show the deletion page for the specified page.
+     *
      * @throws NotFoundException
      */
     public function showDelete(string $bookSlug, string $pageSlug)
      * @throws NotFoundException
      */
     public function showDelete(string $bookSlug, string $pageSlug)
@@ -272,15 +291,17 @@ class PageController extends Controller
         $page = $this->pageRepo->getBySlug($bookSlug, $pageSlug);
         $this->checkOwnablePermission('page-delete', $page);
         $this->setPageTitle(trans('entities.pages_delete_named', ['pageName' => $page->getShortName()]));
         $page = $this->pageRepo->getBySlug($bookSlug, $pageSlug);
         $this->checkOwnablePermission('page-delete', $page);
         $this->setPageTitle(trans('entities.pages_delete_named', ['pageName' => $page->getShortName()]));
+
         return view('pages.delete', [
         return view('pages.delete', [
-            'book' => $page->book,
-            'page' => $page,
-            'current' => $page
+            'book'    => $page->book,
+            'page'    => $page,
+            'current' => $page,
         ]);
     }
 
     /**
      * Show the deletion page for the specified page.
         ]);
     }
 
     /**
      * Show the deletion page for the specified page.
+     *
      * @throws NotFoundException
      */
     public function showDeleteDraft(string $bookSlug, int $pageId)
      * @throws NotFoundException
      */
     public function showDeleteDraft(string $bookSlug, int $pageId)
@@ -288,15 +309,17 @@ class PageController extends Controller
         $page = $this->pageRepo->getById($pageId);
         $this->checkOwnablePermission('page-update', $page);
         $this->setPageTitle(trans('entities.pages_delete_draft_named', ['pageName' => $page->getShortName()]));
         $page = $this->pageRepo->getById($pageId);
         $this->checkOwnablePermission('page-update', $page);
         $this->setPageTitle(trans('entities.pages_delete_draft_named', ['pageName' => $page->getShortName()]));
+
         return view('pages.delete', [
         return view('pages.delete', [
-            'book' => $page->book,
-            'page' => $page,
-            'current' => $page
+            'book'    => $page->book,
+            'page'    => $page,
+            'current' => $page,
         ]);
     }
 
     /**
      * Remove the specified page from storage.
         ]);
     }
 
     /**
      * Remove the specified page from storage.
+     *
      * @throws NotFoundException
      * @throws Throwable
      */
      * @throws NotFoundException
      * @throws Throwable
      */
@@ -313,6 +336,7 @@ class PageController extends Controller
 
     /**
      * Remove the specified draft page from storage.
 
     /**
      * Remove the specified draft page from storage.
+     *
      * @throws NotFoundException
      * @throws Throwable
      */
      * @throws NotFoundException
      * @throws Throwable
      */
@@ -330,6 +354,7 @@ class PageController extends Controller
         if ($chapter && userCan('view', $chapter)) {
             return redirect($chapter->getUrl());
         }
         if ($chapter && userCan('view', $chapter)) {
             return redirect($chapter->getUrl());
         }
+
         return redirect($book->getUrl());
     }
 
         return redirect($book->getUrl());
     }
 
@@ -343,13 +368,14 @@ class PageController extends Controller
             ->setPath(url('/pages/recently-updated'));
 
         return view('common.detailed-listing-paginated', [
             ->setPath(url('/pages/recently-updated'));
 
         return view('common.detailed-listing-paginated', [
-            'title' => trans('entities.recently_updated_pages'),
-            'entities' => $pages
+            'title'    => trans('entities.recently_updated_pages'),
+            'entities' => $pages,
         ]);
     }
 
     /**
      * Show the view to choose a new parent to move a page into.
         ]);
     }
 
     /**
      * Show the view to choose a new parent to move a page into.
+     *
      * @throws NotFoundException
      */
     public function showMove(string $bookSlug, string $pageSlug)
      * @throws NotFoundException
      */
     public function showMove(string $bookSlug, string $pageSlug)
@@ -357,14 +383,16 @@ class PageController extends Controller
         $page = $this->pageRepo->getBySlug($bookSlug, $pageSlug);
         $this->checkOwnablePermission('page-update', $page);
         $this->checkOwnablePermission('page-delete', $page);
         $page = $this->pageRepo->getBySlug($bookSlug, $pageSlug);
         $this->checkOwnablePermission('page-update', $page);
         $this->checkOwnablePermission('page-delete', $page);
+
         return view('pages.move', [
             'book' => $page->book,
         return view('pages.move', [
             'book' => $page->book,
-            'page' => $page
+            'page' => $page,
         ]);
     }
 
     /**
      * Does the action of moving the location of a page.
         ]);
     }
 
     /**
      * Does the action of moving the location of a page.
+     *
      * @throws NotFoundException
      * @throws Throwable
      */
      * @throws NotFoundException
      * @throws Throwable
      */
@@ -387,15 +415,18 @@ class PageController extends Controller
             }
 
             $this->showErrorNotification(trans('errors.selected_book_chapter_not_found'));
             }
 
             $this->showErrorNotification(trans('errors.selected_book_chapter_not_found'));
+
             return redirect()->back();
         }
 
         $this->showSuccessNotification(trans('entities.pages_move_success', ['parentName' => $parent->name]));
             return redirect()->back();
         }
 
         $this->showSuccessNotification(trans('entities.pages_move_success', ['parentName' => $parent->name]));
+
         return redirect($page->getUrl());
     }
 
     /**
      * Show the view to copy a page.
         return redirect($page->getUrl());
     }
 
     /**
      * Show the view to copy a page.
+     *
      * @throws NotFoundException
      */
     public function showCopy(string $bookSlug, string $pageSlug)
      * @throws NotFoundException
      */
     public function showCopy(string $bookSlug, string $pageSlug)
@@ -403,15 +434,16 @@ class PageController extends Controller
         $page = $this->pageRepo->getBySlug($bookSlug, $pageSlug);
         $this->checkOwnablePermission('page-view', $page);
         session()->flashInput(['name' => $page->name]);
         $page = $this->pageRepo->getBySlug($bookSlug, $pageSlug);
         $this->checkOwnablePermission('page-view', $page);
         session()->flashInput(['name' => $page->name]);
+
         return view('pages.copy', [
             'book' => $page->book,
         return view('pages.copy', [
             'book' => $page->book,
-            'page' => $page
+            'page' => $page,
         ]);
     }
 
         ]);
     }
 
-
     /**
      * Create a copy of a page within the requested target destination.
     /**
      * Create a copy of a page within the requested target destination.
+     *
      * @throws NotFoundException
      * @throws Throwable
      */
      * @throws NotFoundException
      * @throws Throwable
      */
@@ -431,21 +463,25 @@ class PageController extends Controller
             }
 
             $this->showErrorNotification(trans('errors.selected_book_chapter_not_found'));
             }
 
             $this->showErrorNotification(trans('errors.selected_book_chapter_not_found'));
+
             return redirect()->back();
         }
 
         $this->showSuccessNotification(trans('entities.pages_copy_success'));
             return redirect()->back();
         }
 
         $this->showSuccessNotification(trans('entities.pages_copy_success'));
+
         return redirect($pageCopy->getUrl());
     }
 
     /**
      * Show the Permissions view.
         return redirect($pageCopy->getUrl());
     }
 
     /**
      * Show the Permissions view.
+     *
      * @throws NotFoundException
      */
     public function showPermissions(string $bookSlug, string $pageSlug)
     {
         $page = $this->pageRepo->getBySlug($bookSlug, $pageSlug);
         $this->checkOwnablePermission('restrictions-manage', $page);
      * @throws NotFoundException
      */
     public function showPermissions(string $bookSlug, string $pageSlug)
     {
         $page = $this->pageRepo->getBySlug($bookSlug, $pageSlug);
         $this->checkOwnablePermission('restrictions-manage', $page);
+
         return view('pages.permissions', [
             'page' => $page,
         ]);
         return view('pages.permissions', [
             'page' => $page,
         ]);
@@ -453,6 +489,7 @@ class PageController extends Controller
 
     /**
      * Set the permissions for this page.
 
     /**
      * Set the permissions for this page.
+     *
      * @throws NotFoundException
      * @throws Throwable
      */
      * @throws NotFoundException
      * @throws Throwable
      */
@@ -464,6 +501,7 @@ class PageController extends Controller
         $permissionsUpdater->updateFromPermissionsForm($page, $request);
 
         $this->showSuccessNotification(trans('entities.pages_permissions_success'));
         $permissionsUpdater->updateFromPermissionsForm($page, $request);
 
         $this->showSuccessNotification(trans('entities.pages_permissions_success'));
+
         return redirect($page->getUrl());
     }
 }
         return redirect($page->getUrl());
     }
 }
index f5dcf7117ae823f2d14e502bc39557cd02b09dd4..5a331521674dfa85cb9e22f4c4f7a97cb5dc01f4 100644 (file)
@@ -2,15 +2,14 @@
 
 namespace BookStack\Http\Controllers;
 
 
 namespace BookStack\Http\Controllers;
 
+use BookStack\Entities\Repos\PageRepo;
 use BookStack\Entities\Tools\ExportFormatter;
 use BookStack\Entities\Tools\PageContent;
 use BookStack\Entities\Tools\ExportFormatter;
 use BookStack\Entities\Tools\PageContent;
-use BookStack\Entities\Repos\PageRepo;
 use BookStack\Exceptions\NotFoundException;
 use Throwable;
 
 class PageExportController extends Controller
 {
 use BookStack\Exceptions\NotFoundException;
 use Throwable;
 
 class PageExportController extends Controller
 {
-
     protected $pageRepo;
     protected $exportFormatter;
 
     protected $pageRepo;
     protected $exportFormatter;
 
@@ -25,7 +24,8 @@ class PageExportController extends Controller
 
     /**
      * Exports a page to a PDF.
 
     /**
      * Exports a page to a PDF.
-     * https://github.com/barryvdh/laravel-dompdf
+     * https://github.com/barryvdh/laravel-dompdf.
+     *
      * @throws NotFoundException
      * @throws Throwable
      */
      * @throws NotFoundException
      * @throws Throwable
      */
@@ -34,11 +34,13 @@ class PageExportController extends Controller
         $page = $this->pageRepo->getBySlug($bookSlug, $pageSlug);
         $page->html = (new PageContent($page))->render();
         $pdfContent = $this->exportFormatter->pageToPdf($page);
         $page = $this->pageRepo->getBySlug($bookSlug, $pageSlug);
         $page->html = (new PageContent($page))->render();
         $pdfContent = $this->exportFormatter->pageToPdf($page);
+
         return $this->downloadResponse($pdfContent, $pageSlug . '.pdf');
     }
 
     /**
      * Export a page to a self-contained HTML file.
         return $this->downloadResponse($pdfContent, $pageSlug . '.pdf');
     }
 
     /**
      * Export a page to a self-contained HTML file.
+     *
      * @throws NotFoundException
      * @throws Throwable
      */
      * @throws NotFoundException
      * @throws Throwable
      */
@@ -47,28 +49,33 @@ class PageExportController extends Controller
         $page = $this->pageRepo->getBySlug($bookSlug, $pageSlug);
         $page->html = (new PageContent($page))->render();
         $containedHtml = $this->exportFormatter->pageToContainedHtml($page);
         $page = $this->pageRepo->getBySlug($bookSlug, $pageSlug);
         $page->html = (new PageContent($page))->render();
         $containedHtml = $this->exportFormatter->pageToContainedHtml($page);
+
         return $this->downloadResponse($containedHtml, $pageSlug . '.html');
     }
 
     /**
      * Export a page to a simple plaintext .txt file.
         return $this->downloadResponse($containedHtml, $pageSlug . '.html');
     }
 
     /**
      * Export a page to a simple plaintext .txt file.
+     *
      * @throws NotFoundException
      */
     public function plainText(string $bookSlug, string $pageSlug)
     {
         $page = $this->pageRepo->getBySlug($bookSlug, $pageSlug);
         $pageText = $this->exportFormatter->pageToPlainText($page);
      * @throws NotFoundException
      */
     public function plainText(string $bookSlug, string $pageSlug)
     {
         $page = $this->pageRepo->getBySlug($bookSlug, $pageSlug);
         $pageText = $this->exportFormatter->pageToPlainText($page);
+
         return $this->downloadResponse($pageText, $pageSlug . '.txt');
     }
 
     /**
      * Export a page to a simple markdown .md file.
         return $this->downloadResponse($pageText, $pageSlug . '.txt');
     }
 
     /**
      * Export a page to a simple markdown .md file.
+     *
      * @throws NotFoundException
      */
     public function markdown(string $bookSlug, string $pageSlug)
     {
         $page = $this->pageRepo->getBySlug($bookSlug, $pageSlug);
         $pageText = $this->exportFormatter->pageToMarkdown($page);
      * @throws NotFoundException
      */
     public function markdown(string $bookSlug, string $pageSlug)
     {
         $page = $this->pageRepo->getBySlug($bookSlug, $pageSlug);
         $pageText = $this->exportFormatter->pageToMarkdown($page);
+
         return $this->downloadResponse($pageText, $pageSlug . '.md');
     }
 }
         return $this->downloadResponse($pageText, $pageSlug . '.md');
     }
 }
index 4c43330164b743133490dbdf8e764cdfc2836383..d595a6e26fd797cb0c7693f473e0680a168caf3e 100644 (file)
@@ -1,13 +1,14 @@
-<?php namespace BookStack\Http\Controllers;
+<?php
+
+namespace BookStack\Http\Controllers;
 
 
-use BookStack\Entities\Tools\PageContent;
 use BookStack\Entities\Repos\PageRepo;
 use BookStack\Entities\Repos\PageRepo;
+use BookStack\Entities\Tools\PageContent;
 use BookStack\Exceptions\NotFoundException;
 use Ssddanbrown\HtmlDiff\Diff;
 
 class PageRevisionController extends Controller
 {
 use BookStack\Exceptions\NotFoundException;
 use Ssddanbrown\HtmlDiff\Diff;
 
 class PageRevisionController extends Controller
 {
-
     protected $pageRepo;
 
     /**
     protected $pageRepo;
 
     /**
@@ -20,20 +21,23 @@ class PageRevisionController extends Controller
 
     /**
      * Shows the last revisions for this page.
 
     /**
      * Shows the last revisions for this page.
+     *
      * @throws NotFoundException
      */
     public function index(string $bookSlug, string $pageSlug)
     {
         $page = $this->pageRepo->getBySlug($bookSlug, $pageSlug);
         $this->setPageTitle(trans('entities.pages_revisions_named', ['pageName'=>$page->getShortName()]));
      * @throws NotFoundException
      */
     public function index(string $bookSlug, string $pageSlug)
     {
         $page = $this->pageRepo->getBySlug($bookSlug, $pageSlug);
         $this->setPageTitle(trans('entities.pages_revisions_named', ['pageName'=>$page->getShortName()]));
+
         return view('pages.revisions', [
         return view('pages.revisions', [
-            'page' => $page,
-            'current' => $page
+            'page'    => $page,
+            'current' => $page,
         ]);
     }
 
     /**
      * Shows a preview of a single revision.
         ]);
     }
 
     /**
      * Shows a preview of a single revision.
+     *
      * @throws NotFoundException
      */
     public function show(string $bookSlug, string $pageSlug, int $revisionId)
      * @throws NotFoundException
      */
     public function show(string $bookSlug, string $pageSlug, int $revisionId)
@@ -50,16 +54,18 @@ class PageRevisionController extends Controller
         $page->html = (new PageContent($page))->render();
 
         $this->setPageTitle(trans('entities.pages_revision_named', ['pageName' => $page->getShortName()]));
         $page->html = (new PageContent($page))->render();
 
         $this->setPageTitle(trans('entities.pages_revision_named', ['pageName' => $page->getShortName()]));
+
         return view('pages.revision', [
         return view('pages.revision', [
-            'page' => $page,
-            'book' => $page->book,
-            'diff' => null,
-            'revision' => $revision
+            'page'     => $page,
+            'book'     => $page->book,
+            'diff'     => null,
+            'revision' => $revision,
         ]);
     }
 
     /**
      * Shows the changes of a single revision.
         ]);
     }
 
     /**
      * Shows the changes of a single revision.
+     *
      * @throws NotFoundException
      */
     public function changes(string $bookSlug, string $pageSlug, int $revisionId)
      * @throws NotFoundException
      */
     public function changes(string $bookSlug, string $pageSlug, int $revisionId)
@@ -81,15 +87,16 @@ class PageRevisionController extends Controller
         $this->setPageTitle(trans('entities.pages_revision_named', ['pageName'=>$page->getShortName()]));
 
         return view('pages.revision', [
         $this->setPageTitle(trans('entities.pages_revision_named', ['pageName'=>$page->getShortName()]));
 
         return view('pages.revision', [
-            'page' => $page,
-            'book' => $page->book,
-            'diff' => $diff,
-            'revision' => $revision
+            'page'     => $page,
+            'book'     => $page->book,
+            'diff'     => $diff,
+            'revision' => $revision,
         ]);
     }
 
     /**
      * Restores a page using the content of the specified revision.
         ]);
     }
 
     /**
      * Restores a page using the content of the specified revision.
+     *
      * @throws NotFoundException
      */
     public function restore(string $bookSlug, string $pageSlug, int $revisionId)
      * @throws NotFoundException
      */
     public function restore(string $bookSlug, string $pageSlug, int $revisionId)
@@ -104,6 +111,7 @@ class PageRevisionController extends Controller
 
     /**
      * Deletes a revision using the id of the specified revision.
 
     /**
      * Deletes a revision using the id of the specified revision.
+     *
      * @throws NotFoundException
      */
     public function destroy(string $bookSlug, string $pageSlug, int $revId)
      * @throws NotFoundException
      */
     public function destroy(string $bookSlug, string $pageSlug, int $revId)
@@ -122,11 +130,13 @@ class PageRevisionController extends Controller
         // Check if its the latest revision, cannot delete latest revision.
         if (intval($currentRevision->id) === intval($revId)) {
             $this->showErrorNotification(trans('entities.revision_cannot_delete_latest'));
         // Check if its the latest revision, cannot delete latest revision.
         if (intval($currentRevision->id) === intval($revId)) {
             $this->showErrorNotification(trans('entities.revision_cannot_delete_latest'));
+
             return redirect($page->getUrl('/revisions'));
         }
 
         $revision->delete();
         $this->showSuccessNotification(trans('entities.revision_delete_success'));
             return redirect($page->getUrl('/revisions'));
         }
 
         $revision->delete();
         $this->showSuccessNotification(trans('entities.revision_delete_success'));
+
         return redirect($page->getUrl('/revisions'));
     }
 }
         return redirect($page->getUrl('/revisions'));
     }
 }
index 2307bc0d52c09b5bd6ee1411f795ac83c11f8e0a..232d0d4427a84d4ec28632d42b0af87224f92fe6 100644 (file)
@@ -11,7 +11,7 @@ class PageTemplateController extends Controller
     protected $pageRepo;
 
     /**
     protected $pageRepo;
 
     /**
-     * PageTemplateController constructor
+     * PageTemplateController constructor.
      */
     public function __construct(PageRepo $pageRepo)
     {
      */
     public function __construct(PageRepo $pageRepo)
     {
@@ -32,12 +32,13 @@ class PageTemplateController extends Controller
         }
 
         return view('pages.template-manager-list', [
         }
 
         return view('pages.template-manager-list', [
-            'templates' => $templates
+            'templates' => $templates,
         ]);
     }
 
     /**
      * Get the content of a template.
         ]);
     }
 
     /**
      * Get the content of a template.
+     *
      * @throws NotFoundException
      */
     public function get(int $templateId)
      * @throws NotFoundException
      */
     public function get(int $templateId)
@@ -49,7 +50,7 @@ class PageTemplateController extends Controller
         }
 
         return response()->json([
         }
 
         return response()->json([
-            'html' => $page->html,
+            'html'     => $page->html,
             'markdown' => $page->markdown,
         ]);
     }
             'markdown' => $page->markdown,
         ]);
     }
index 3126460080b62fea60f0cad128e72de74ed6269d..1736023a5047db5d7ed9049ac7fd50d855f805f5 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Http\Controllers;
+<?php
+
+namespace BookStack\Http\Controllers;
 
 use BookStack\Actions\ActivityType;
 use BookStack\Entities\Models\Deletion;
 
 use BookStack\Actions\ActivityType;
 use BookStack\Entities\Models\Deletion;
@@ -7,7 +9,6 @@ use BookStack\Entities\Tools\TrashCan;
 
 class RecycleBinController extends Controller
 {
 
 class RecycleBinController extends Controller
 {
-
     protected $recycleBinBaseUrl = '/settings/recycle-bin';
 
     /**
     protected $recycleBinBaseUrl = '/settings/recycle-bin';
 
     /**
@@ -19,11 +20,11 @@ class RecycleBinController extends Controller
         $this->middleware(function ($request, $next) {
             $this->checkPermission('settings-manage');
             $this->checkPermission('restrictions-manage-all');
         $this->middleware(function ($request, $next) {
             $this->checkPermission('settings-manage');
             $this->checkPermission('restrictions-manage-all');
+
             return $next($request);
         });
     }
 
             return $next($request);
         });
     }
 
-
     /**
      * Show the top-level listing for the recycle bin.
      */
     /**
      * Show the top-level listing for the recycle bin.
      */
@@ -32,6 +33,7 @@ class RecycleBinController extends Controller
         $deletions = Deletion::query()->with(['deletable', 'deleter'])->paginate(10);
 
         $this->setPageTitle(trans('settings.recycle_bin'));
         $deletions = Deletion::query()->with(['deletable', 'deleter'])->paginate(10);
 
         $this->setPageTitle(trans('settings.recycle_bin'));
+
         return view('settings.recycle-bin.index', [
             'deletions' => $deletions,
         ]);
         return view('settings.recycle-bin.index', [
             'deletions' => $deletions,
         ]);
@@ -60,13 +62,14 @@ class RecycleBinController extends Controller
         $parentDeletion = ($currentDeletable === $deletion->deletable) ? null : $currentDeletable->deletions()->first();
 
         return view('settings.recycle-bin.restore', [
         $parentDeletion = ($currentDeletable === $deletion->deletable) ? null : $currentDeletable->deletions()->first();
 
         return view('settings.recycle-bin.restore', [
-            'deletion' => $deletion,
+            'deletion'       => $deletion,
             'parentDeletion' => $parentDeletion,
         ]);
     }
 
     /**
      * Restore the element attached to the given deletion.
             'parentDeletion' => $parentDeletion,
         ]);
     }
 
     /**
      * Restore the element attached to the given deletion.
+     *
      * @throws \Exception
      */
     public function restore(string $id)
      * @throws \Exception
      */
     public function restore(string $id)
@@ -77,6 +80,7 @@ class RecycleBinController extends Controller
         $restoreCount = (new TrashCan())->restoreFromDeletion($deletion);
 
         $this->showSuccessNotification(trans('settings.recycle_bin_restore_notification', ['count' => $restoreCount]));
         $restoreCount = (new TrashCan())->restoreFromDeletion($deletion);
 
         $this->showSuccessNotification(trans('settings.recycle_bin_restore_notification', ['count' => $restoreCount]));
+
         return redirect($this->recycleBinBaseUrl);
     }
 
         return redirect($this->recycleBinBaseUrl);
     }
 
@@ -95,6 +99,7 @@ class RecycleBinController extends Controller
 
     /**
      * Permanently delete the content associated with the given deletion.
 
     /**
      * Permanently delete the content associated with the given deletion.
+     *
      * @throws \Exception
      */
     public function destroy(string $id)
      * @throws \Exception
      */
     public function destroy(string $id)
@@ -105,11 +110,13 @@ class RecycleBinController extends Controller
         $deleteCount = (new TrashCan())->destroyFromDeletion($deletion);
 
         $this->showSuccessNotification(trans('settings.recycle_bin_destroy_notification', ['count' => $deleteCount]));
         $deleteCount = (new TrashCan())->destroyFromDeletion($deletion);
 
         $this->showSuccessNotification(trans('settings.recycle_bin_destroy_notification', ['count' => $deleteCount]));
+
         return redirect($this->recycleBinBaseUrl);
     }
 
     /**
      * Empty out the recycle bin.
         return redirect($this->recycleBinBaseUrl);
     }
 
     /**
      * Empty out the recycle bin.
+     *
      * @throws \Exception
      */
     public function empty()
      * @throws \Exception
      */
     public function empty()
@@ -118,6 +125,7 @@ class RecycleBinController extends Controller
 
         $this->logActivity(ActivityType::RECYCLE_BIN_EMPTY);
         $this->showSuccessNotification(trans('settings.recycle_bin_destroy_notification', ['count' => $deleteCount]));
 
         $this->logActivity(ActivityType::RECYCLE_BIN_EMPTY);
         $this->showSuccessNotification(trans('settings.recycle_bin_destroy_notification', ['count' => $deleteCount]));
+
         return redirect($this->recycleBinBaseUrl);
     }
 }
         return redirect($this->recycleBinBaseUrl);
     }
 }
index e16a724a48c49fa419506a997ace27310af607b1..06a30e99dd5c5ff2a43c0cbb3b68d68bd0312b50 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Http\Controllers;
+<?php
+
+namespace BookStack\Http\Controllers;
 
 use BookStack\Auth\Permissions\PermissionsRepo;
 use BookStack\Exceptions\PermissionsException;
 
 use BookStack\Auth\Permissions\PermissionsRepo;
 use BookStack\Exceptions\PermissionsException;
@@ -8,7 +10,6 @@ use Illuminate\Validation\ValidationException;
 
 class RoleController extends Controller
 {
 
 class RoleController extends Controller
 {
-
     protected $permissionsRepo;
 
     /**
     protected $permissionsRepo;
 
     /**
@@ -26,15 +27,17 @@ class RoleController extends Controller
     {
         $this->checkPermission('user-roles-manage');
         $roles = $this->permissionsRepo->getAllRoles();
     {
         $this->checkPermission('user-roles-manage');
         $roles = $this->permissionsRepo->getAllRoles();
+
         return view('settings.roles.index', ['roles' => $roles]);
     }
 
     /**
         return view('settings.roles.index', ['roles' => $roles]);
     }
 
     /**
-     * Show the form to create a new role
+     * Show the form to create a new role.
      */
     public function create()
     {
         $this->checkPermission('user-roles-manage');
      */
     public function create()
     {
         $this->checkPermission('user-roles-manage');
+
         return view('settings.roles.create');
     }
 
         return view('settings.roles.create');
     }
 
@@ -46,16 +49,18 @@ class RoleController extends Controller
         $this->checkPermission('user-roles-manage');
         $this->validate($request, [
             'display_name' => 'required|min:3|max:180',
         $this->checkPermission('user-roles-manage');
         $this->validate($request, [
             'display_name' => 'required|min:3|max:180',
-            'description' => 'max:180'
+            'description'  => 'max:180',
         ]);
 
         $this->permissionsRepo->saveNewRole($request->all());
         $this->showSuccessNotification(trans('settings.role_create_success'));
         ]);
 
         $this->permissionsRepo->saveNewRole($request->all());
         $this->showSuccessNotification(trans('settings.role_create_success'));
+
         return redirect('/settings/roles');
     }
 
     /**
      * Show the form for editing a user role.
         return redirect('/settings/roles');
     }
 
     /**
      * Show the form for editing a user role.
+     *
      * @throws PermissionsException
      */
     public function edit(string $id)
      * @throws PermissionsException
      */
     public function edit(string $id)
@@ -65,11 +70,13 @@ class RoleController extends Controller
         if ($role->hidden) {
             throw new PermissionsException(trans('errors.role_cannot_be_edited'));
         }
         if ($role->hidden) {
             throw new PermissionsException(trans('errors.role_cannot_be_edited'));
         }
+
         return view('settings.roles.edit', ['role' => $role]);
     }
 
     /**
      * Updates a user role.
         return view('settings.roles.edit', ['role' => $role]);
     }
 
     /**
      * Updates a user role.
+     *
      * @throws ValidationException
      */
     public function update(Request $request, string $id)
      * @throws ValidationException
      */
     public function update(Request $request, string $id)
@@ -77,11 +84,12 @@ class RoleController extends Controller
         $this->checkPermission('user-roles-manage');
         $this->validate($request, [
             'display_name' => 'required|min:3|max:180',
         $this->checkPermission('user-roles-manage');
         $this->validate($request, [
             'display_name' => 'required|min:3|max:180',
-            'description' => 'max:180'
+            'description'  => 'max:180',
         ]);
 
         $this->permissionsRepo->updateRole($id, $request->all());
         $this->showSuccessNotification(trans('settings.role_update_success'));
         ]);
 
         $this->permissionsRepo->updateRole($id, $request->all());
         $this->showSuccessNotification(trans('settings.role_update_success'));
+
         return redirect('/settings/roles');
     }
 
         return redirect('/settings/roles');
     }
 
@@ -96,12 +104,14 @@ class RoleController extends Controller
         $roles = $this->permissionsRepo->getAllRolesExcept($role);
         $blankRole = $role->newInstance(['display_name' => trans('settings.role_delete_no_migration')]);
         $roles->prepend($blankRole);
         $roles = $this->permissionsRepo->getAllRolesExcept($role);
         $blankRole = $role->newInstance(['display_name' => trans('settings.role_delete_no_migration')]);
         $roles->prepend($blankRole);
+
         return view('settings.roles.delete', ['role' => $role, 'roles' => $roles]);
     }
 
     /**
      * Delete a role from the system,
      * Migrate from a previous role if set.
         return view('settings.roles.delete', ['role' => $role, 'roles' => $roles]);
     }
 
     /**
      * Delete a role from the system,
      * Migrate from a previous role if set.
+     *
      * @throws Exception
      */
     public function delete(Request $request, string $id)
      * @throws Exception
      */
     public function delete(Request $request, string $id)
@@ -112,10 +122,12 @@ class RoleController extends Controller
             $this->permissionsRepo->deleteRole($id, $request->get('migrate_role_id'));
         } catch (PermissionsException $e) {
             $this->showErrorNotification($e->getMessage());
             $this->permissionsRepo->deleteRole($id, $request->get('migrate_role_id'));
         } catch (PermissionsException $e) {
             $this->showErrorNotification($e->getMessage());
+
             return redirect()->back();
         }
 
         $this->showSuccessNotification(trans('settings.role_delete_success'));
             return redirect()->back();
         }
 
         $this->showSuccessNotification(trans('settings.role_delete_success'));
+
         return redirect('/settings/roles');
     }
 }
         return redirect('/settings/roles');
     }
 }
index 8598575004f04a5e1c679288e6f5d7060b57a54a..d4431e1662ba423a485dc46077d7aefe3a85b846 100644 (file)
@@ -1,9 +1,11 @@
-<?php namespace BookStack\Http\Controllers;
+<?php
+
+namespace BookStack\Http\Controllers;
 
 use BookStack\Entities\Queries\Popular;
 
 use BookStack\Entities\Queries\Popular;
+use BookStack\Entities\Tools\SearchOptions;
 use BookStack\Entities\Tools\SearchRunner;
 use BookStack\Entities\Tools\ShelfContext;
 use BookStack\Entities\Tools\SearchRunner;
 use BookStack\Entities\Tools\ShelfContext;
-use BookStack\Entities\Tools\SearchOptions;
 use BookStack\Entities\Tools\SiblingFetcher;
 use Illuminate\Http\Request;
 
 use BookStack\Entities\Tools\SiblingFetcher;
 use Illuminate\Http\Request;
 
@@ -30,17 +32,17 @@ class SearchController extends Controller
         $this->setPageTitle(trans('entities.search_for_term', ['term' => $fullSearchString]));
 
         $page = intval($request->get('page', '0')) ?: 1;
         $this->setPageTitle(trans('entities.search_for_term', ['term' => $fullSearchString]));
 
         $page = intval($request->get('page', '0')) ?: 1;
-        $nextPageLink = url('/search?term=' . urlencode($fullSearchString) . '&page=' . ($page+1));
+        $nextPageLink = url('/search?term=' . urlencode($fullSearchString) . '&page=' . ($page + 1));
 
         $results = $this->searchRunner->searchEntities($searchOpts, 'all', $page, 20);
 
         return view('search.all', [
 
         $results = $this->searchRunner->searchEntities($searchOpts, 'all', $page, 20);
 
         return view('search.all', [
-            'entities'   => $results['results'],
+            'entities'     => $results['results'],
             'totalResults' => $results['total'],
             'totalResults' => $results['total'],
-            'searchTerm' => $fullSearchString,
-            'hasNextPage' => $results['has_more'],
+            'searchTerm'   => $fullSearchString,
+            'hasNextPage'  => $results['has_more'],
             'nextPageLink' => $nextPageLink,
             'nextPageLink' => $nextPageLink,
-            'options' => $searchOpts,
+            'options'      => $searchOpts,
         ]);
     }
 
         ]);
     }
 
@@ -51,6 +53,7 @@ class SearchController extends Controller
     {
         $term = $request->get('term', '');
         $results = $this->searchRunner->searchBook($bookId, $term);
     {
         $term = $request->get('term', '');
         $results = $this->searchRunner->searchBook($bookId, $term);
+
         return view('partials.entity-list', ['entities' => $results]);
     }
 
         return view('partials.entity-list', ['entities' => $results]);
     }
 
@@ -61,6 +64,7 @@ class SearchController extends Controller
     {
         $term = $request->get('term', '');
         $results = $this->searchRunner->searchChapter($chapterId, $term);
     {
         $term = $request->get('term', '');
         $results = $this->searchRunner->searchChapter($chapterId, $term);
+
         return view('partials.entity-list', ['entities' => $results]);
     }
 
         return view('partials.entity-list', ['entities' => $results]);
     }
 
@@ -71,15 +75,15 @@ class SearchController extends Controller
     public function searchEntitiesAjax(Request $request)
     {
         $entityTypes = $request->filled('types') ? explode(',', $request->get('types')) : ['page', 'chapter', 'book'];
     public function searchEntitiesAjax(Request $request)
     {
         $entityTypes = $request->filled('types') ? explode(',', $request->get('types')) : ['page', 'chapter', 'book'];
-        $searchTerm =  $request->get('term', false);
+        $searchTerm = $request->get('term', false);
         $permission = $request->get('permission', 'view');
 
         // Search for entities otherwise show most popular
         if ($searchTerm !== false) {
         $permission = $request->get('permission', 'view');
 
         // Search for entities otherwise show most popular
         if ($searchTerm !== false) {
-            $searchTerm .= ' {type:'. implode('|', $entityTypes) .'}';
+            $searchTerm .= ' {type:' . implode('|', $entityTypes) . '}';
             $entities = $this->searchRunner->searchEntities(SearchOptions::fromString($searchTerm), 'all', 1, 20, $permission)['results'];
         } else {
             $entities = $this->searchRunner->searchEntities(SearchOptions::fromString($searchTerm), 'all', 1, 20, $permission)['results'];
         } else {
-            $entities = (new Popular)->run(20, 0, $entityTypes, $permission);
+            $entities = (new Popular())->run(20, 0, $entityTypes, $permission);
         }
 
         return view('search.entity-ajax-list', ['entities' => $entities]);
         }
 
         return view('search.entity-ajax-list', ['entities' => $entities]);
@@ -93,7 +97,8 @@ class SearchController extends Controller
         $type = $request->get('entity_type', null);
         $id = $request->get('entity_id', null);
 
         $type = $request->get('entity_type', null);
         $id = $request->get('entity_id', null);
 
-        $entities = (new SiblingFetcher)->fetch($type, $id);
+        $entities = (new SiblingFetcher())->fetch($type, $id);
+
         return view('partials.entity-list-basic', ['entities' => $entities, 'style' => 'compact']);
     }
 }
         return view('partials.entity-list-basic', ['entities' => $entities, 'style' => 'compact']);
     }
 }
index f02f541bc9ba5b1a9ad14270d900ae053b23900d..d9f172081ef2efb2851c0dacbc5937e2cc8c7e71 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Http\Controllers;
+<?php
+
+namespace BookStack\Http\Controllers;
 
 use BookStack\Actions\ActivityType;
 use BookStack\Auth\User;
 
 use BookStack\Actions\ActivityType;
 use BookStack\Auth\User;
@@ -29,8 +31,8 @@ class SettingController extends Controller
         $version = trim(file_get_contents(base_path('version')));
 
         return view('settings.index', [
         $version = trim(file_get_contents(base_path('version')));
 
         return view('settings.index', [
-            'version' => $version,
-            'guestUser' => User::getDefault()
+            'version'   => $version,
+            'guestUser' => User::getDefault(),
         ]);
     }
 
         ]);
     }
 
@@ -72,6 +74,7 @@ class SettingController extends Controller
         $this->logActivity(ActivityType::SETTINGS_UPDATE, $section);
         $this->showSuccessNotification(trans('settings.settings_save_success'));
         $redirectLocation = '/settings#' . $section;
         $this->logActivity(ActivityType::SETTINGS_UPDATE, $section);
         $this->showSuccessNotification(trans('settings.settings_save_success'));
         $redirectLocation = '/settings#' . $section;
+
         return redirect(rtrim($redirectLocation, '#'));
     }
 }
         return redirect(rtrim($redirectLocation, '#'));
     }
 }
index 9f4ed4d893712affeeaaca24b9301b3523cbaa48..336e063ab402680f7f3a8de49d3e095de29b4004 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Http\Controllers;
+<?php
+
+namespace BookStack\Http\Controllers;
 
 use Illuminate\Support\Facades\Cache;
 use Illuminate\Support\Facades\DB;
 
 use Illuminate\Support\Facades\Cache;
 use Illuminate\Support\Facades\DB;
@@ -7,7 +9,6 @@ use Illuminate\Support\Str;
 
 class StatusController extends Controller
 {
 
 class StatusController extends Controller
 {
-
     /**
      * Show the system status as a simple json page.
      */
     /**
      * Show the system status as a simple json page.
      */
@@ -20,16 +21,19 @@ class StatusController extends Controller
             'cache' => $this->trueWithoutError(function () {
                 $rand = Str::random();
                 Cache::set('status_test', $rand);
             'cache' => $this->trueWithoutError(function () {
                 $rand = Str::random();
                 Cache::set('status_test', $rand);
+
                 return Cache::get('status_test') === $rand;
             }),
             'session' => $this->trueWithoutError(function () {
                 $rand = Str::random();
                 Session::put('status_test', $rand);
                 return Cache::get('status_test') === $rand;
             }),
             'session' => $this->trueWithoutError(function () {
                 $rand = Str::random();
                 Session::put('status_test', $rand);
+
                 return Session::get('status_test') === $rand;
             }),
         ];
 
         $hasError = in_array(false, $statuses);
                 return Session::get('status_test') === $rand;
             }),
         ];
 
         $hasError = in_array(false, $statuses);
+
         return response()->json($statuses, $hasError ? 500 : 200);
     }
 
         return response()->json($statuses, $hasError ? 500 : 200);
     }
 
index ce84bf4101e4c23f6437915a35c3d014a7c306a5..b0065af70f928e2f61cf8c8ec7d9050352503eb6 100644 (file)
@@ -1,11 +1,12 @@
-<?php namespace BookStack\Http\Controllers;
+<?php
+
+namespace BookStack\Http\Controllers;
 
 use BookStack\Actions\TagRepo;
 use Illuminate\Http\Request;
 
 class TagController extends Controller
 {
 
 use BookStack\Actions\TagRepo;
 use Illuminate\Http\Request;
 
 class TagController extends Controller
 {
-
     protected $tagRepo;
 
     /**
     protected $tagRepo;
 
     /**
@@ -23,6 +24,7 @@ class TagController extends Controller
     {
         $searchTerm = $request->get('search', null);
         $suggestions = $this->tagRepo->getNameSuggestions($searchTerm);
     {
         $searchTerm = $request->get('search', null);
         $suggestions = $this->tagRepo->getNameSuggestions($searchTerm);
+
         return response()->json($suggestions);
     }
 
         return response()->json($suggestions);
     }
 
@@ -34,6 +36,7 @@ class TagController extends Controller
         $searchTerm = $request->get('search', null);
         $tagName = $request->get('name', null);
         $suggestions = $this->tagRepo->getValueSuggestions($searchTerm, $tagName);
         $searchTerm = $request->get('search', null);
         $tagName = $request->get('name', null);
         $suggestions = $this->tagRepo->getValueSuggestions($searchTerm, $tagName);
+
         return response()->json($suggestions);
     }
 }
         return response()->json($suggestions);
     }
 }
index 3949722ead098b1d7c7e0b82dc8ca02a27a73eb3..bdc25f79dc7050d91cf93027481badc04eef0623 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Http\Controllers;
+<?php
+
+namespace BookStack\Http\Controllers;
 
 use BookStack\Actions\ActivityType;
 use BookStack\Api\ApiToken;
 
 use BookStack\Actions\ActivityType;
 use BookStack\Api\ApiToken;
@@ -9,7 +11,6 @@ use Illuminate\Support\Str;
 
 class UserApiTokenController extends Controller
 {
 
 class UserApiTokenController extends Controller
 {
-
     /**
      * Show the form to create a new API token.
      */
     /**
      * Show the form to create a new API token.
      */
@@ -20,6 +21,7 @@ class UserApiTokenController extends Controller
         $this->checkPermissionOrCurrentUser('users-manage', $userId);
 
         $user = User::query()->findOrFail($userId);
         $this->checkPermissionOrCurrentUser('users-manage', $userId);
 
         $user = User::query()->findOrFail($userId);
+
         return view('users.api-tokens.create', [
             'user' => $user,
         ]);
         return view('users.api-tokens.create', [
             'user' => $user,
         ]);
@@ -34,7 +36,7 @@ class UserApiTokenController extends Controller
         $this->checkPermissionOrCurrentUser('users-manage', $userId);
 
         $this->validate($request, [
         $this->checkPermissionOrCurrentUser('users-manage', $userId);
 
         $this->validate($request, [
-            'name' => 'required|max:250',
+            'name'       => 'required|max:250',
             'expires_at' => 'date_format:Y-m-d',
         ]);
 
             'expires_at' => 'date_format:Y-m-d',
         ]);
 
@@ -42,10 +44,10 @@ class UserApiTokenController extends Controller
         $secret = Str::random(32);
 
         $token = (new ApiToken())->forceFill([
         $secret = Str::random(32);
 
         $token = (new ApiToken())->forceFill([
-            'name' => $request->get('name'),
-            'token_id' => Str::random(32),
-            'secret' => Hash::make($secret),
-            'user_id' => $user->id,
+            'name'       => $request->get('name'),
+            'token_id'   => Str::random(32),
+            'secret'     => Hash::make($secret),
+            'user_id'    => $user->id,
             'expires_at' => $request->get('expires_at') ?: ApiToken::defaultExpiry(),
         ]);
 
             'expires_at' => $request->get('expires_at') ?: ApiToken::defaultExpiry(),
         ]);
 
@@ -71,9 +73,9 @@ class UserApiTokenController extends Controller
         $secret = session()->pull('api-token-secret:' . $token->id, null);
 
         return view('users.api-tokens.edit', [
         $secret = session()->pull('api-token-secret:' . $token->id, null);
 
         return view('users.api-tokens.edit', [
-            'user' => $user,
-            'token' => $token,
-            'model' => $token,
+            'user'   => $user,
+            'token'  => $token,
+            'model'  => $token,
             'secret' => $secret,
         ]);
     }
             'secret' => $secret,
         ]);
     }
@@ -84,18 +86,19 @@ class UserApiTokenController extends Controller
     public function update(Request $request, int $userId, int $tokenId)
     {
         $this->validate($request, [
     public function update(Request $request, int $userId, int $tokenId)
     {
         $this->validate($request, [
-            'name' => 'required|max:250',
+            'name'       => 'required|max:250',
             'expires_at' => 'date_format:Y-m-d',
         ]);
 
         [$user, $token] = $this->checkPermissionAndFetchUserToken($userId, $tokenId);
         $token->fill([
             'expires_at' => 'date_format:Y-m-d',
         ]);
 
         [$user, $token] = $this->checkPermissionAndFetchUserToken($userId, $tokenId);
         $token->fill([
-            'name' => $request->get('name'),
+            'name'       => $request->get('name'),
             'expires_at' => $request->get('expires_at') ?: ApiToken::defaultExpiry(),
         ])->save();
 
         $this->showSuccessNotification(trans('settings.user_api_token_update_success'));
         $this->logActivity(ActivityType::API_TOKEN_UPDATE, $token);
             'expires_at' => $request->get('expires_at') ?: ApiToken::defaultExpiry(),
         ])->save();
 
         $this->showSuccessNotification(trans('settings.user_api_token_update_success'));
         $this->logActivity(ActivityType::API_TOKEN_UPDATE, $token);
+
         return redirect($user->getEditUrl('/api-tokens/' . $token->id));
     }
 
         return redirect($user->getEditUrl('/api-tokens/' . $token->id));
     }
 
@@ -105,8 +108,9 @@ class UserApiTokenController extends Controller
     public function delete(int $userId, int $tokenId)
     {
         [$user, $token] = $this->checkPermissionAndFetchUserToken($userId, $tokenId);
     public function delete(int $userId, int $tokenId)
     {
         [$user, $token] = $this->checkPermissionAndFetchUserToken($userId, $tokenId);
+
         return view('users.api-tokens.delete', [
         return view('users.api-tokens.delete', [
-            'user' => $user,
+            'user'  => $user,
             'token' => $token,
         ]);
     }
             'token' => $token,
         ]);
     }
@@ -138,6 +142,7 @@ class UserApiTokenController extends Controller
 
         $user = User::query()->findOrFail($userId);
         $token = ApiToken::query()->where('user_id', '=', $user->id)->where('id', '=', $tokenId)->firstOrFail();
 
         $user = User::query()->findOrFail($userId);
         $token = ApiToken::query()->where('user_id', '=', $user->id)->where('id', '=', $tokenId)->firstOrFail();
+
         return [$user, $token];
     }
 }
         return [$user, $token];
     }
 }
index ba35904378a6f2ca04a76baf26f78cc94b56388a..f7b2afef8d2e97d37db5ab1a7bea33bd002a0887 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Http\Controllers;
+<?php
+
+namespace BookStack\Http\Controllers;
 
 use BookStack\Actions\ActivityType;
 use BookStack\Auth\Access\SocialAuthService;
 
 use BookStack\Actions\ActivityType;
 use BookStack\Auth\Access\SocialAuthService;
@@ -15,7 +17,6 @@ use Illuminate\Validation\ValidationException;
 
 class UserController extends Controller
 {
 
 class UserController extends Controller
 {
-
     protected $user;
     protected $userRepo;
     protected $inviteService;
     protected $user;
     protected $userRepo;
     protected $inviteService;
@@ -39,14 +40,15 @@ class UserController extends Controller
     {
         $this->checkPermission('users-manage');
         $listDetails = [
     {
         $this->checkPermission('users-manage');
         $listDetails = [
-            'order' => $request->get('order', 'asc'),
+            'order'  => $request->get('order', 'asc'),
             'search' => $request->get('search', ''),
             'search' => $request->get('search', ''),
-            'sort' => $request->get('sort', 'name'),
+            'sort'   => $request->get('sort', 'name'),
         ];
         $users = $this->userRepo->getAllUsersPaginatedAndSorted(20, $listDetails);
 
         $this->setPageTitle(trans('settings.users'));
         $users->appends($listDetails);
         ];
         $users = $this->userRepo->getAllUsersPaginatedAndSorted(20, $listDetails);
 
         $this->setPageTitle(trans('settings.users'));
         $users->appends($listDetails);
+
         return view('users.index', ['users' => $users, 'listDetails' => $listDetails]);
     }
 
         return view('users.index', ['users' => $users, 'listDetails' => $listDetails]);
     }
 
@@ -58,11 +60,13 @@ class UserController extends Controller
         $this->checkPermission('users-manage');
         $authMethod = config('auth.method');
         $roles = $this->userRepo->getAllRoles();
         $this->checkPermission('users-manage');
         $authMethod = config('auth.method');
         $roles = $this->userRepo->getAllRoles();
+
         return view('users.create', ['authMethod' => $authMethod, 'roles' => $roles]);
     }
 
     /**
      * Store a newly created user in storage.
         return view('users.create', ['authMethod' => $authMethod, 'roles' => $roles]);
     }
 
     /**
      * Store a newly created user in storage.
+     *
      * @throws UserUpdateException
      * @throws ValidationException
      */
      * @throws UserUpdateException
      * @throws ValidationException
      */
@@ -71,7 +75,7 @@ class UserController extends Controller
         $this->checkPermission('users-manage');
         $validationRules = [
             'name'  => 'required',
         $this->checkPermission('users-manage');
         $validationRules = [
             'name'  => 'required',
-            'email' => 'required|email|unique:users,email'
+            'email' => 'required|email|unique:users,email',
         ];
 
         $authMethod = config('auth.method');
         ];
 
         $authMethod = config('auth.method');
@@ -108,6 +112,7 @@ class UserController extends Controller
         $this->userRepo->downloadAndAssignUserAvatar($user);
 
         $this->logActivity(ActivityType::USER_CREATE, $user);
         $this->userRepo->downloadAndAssignUserAvatar($user);
 
         $this->logActivity(ActivityType::USER_CREATE, $user);
+
         return redirect('/settings/users');
     }
 
         return redirect('/settings/users');
     }
 
@@ -125,16 +130,18 @@ class UserController extends Controller
         $activeSocialDrivers = $socialAuthService->getActiveDrivers();
         $this->setPageTitle(trans('settings.user_profile'));
         $roles = $this->userRepo->getAllRoles();
         $activeSocialDrivers = $socialAuthService->getActiveDrivers();
         $this->setPageTitle(trans('settings.user_profile'));
         $roles = $this->userRepo->getAllRoles();
+
         return view('users.edit', [
         return view('users.edit', [
-            'user' => $user,
+            'user'                => $user,
             'activeSocialDrivers' => $activeSocialDrivers,
             'activeSocialDrivers' => $activeSocialDrivers,
-            'authMethod' => $authMethod,
-            'roles' => $roles
+            'authMethod'          => $authMethod,
+            'roles'               => $roles,
         ]);
     }
 
     /**
      * Update the specified user in storage.
         ]);
     }
 
     /**
      * Update the specified user in storage.
+     *
      * @throws UserUpdateException
      * @throws ImageUploadException
      * @throws ValidationException
      * @throws UserUpdateException
      * @throws ImageUploadException
      * @throws ValidationException
@@ -208,6 +215,7 @@ class UserController extends Controller
         $this->logActivity(ActivityType::USER_UPDATE, $user);
 
         $redirectUrl = userCan('users-manage') ? '/settings/users' : ('/settings/users/' . $user->id);
         $this->logActivity(ActivityType::USER_UPDATE, $user);
 
         $redirectUrl = userCan('users-manage') ? '/settings/users' : ('/settings/users/' . $user->id);
+
         return redirect($redirectUrl);
     }
 
         return redirect($redirectUrl);
     }
 
@@ -220,11 +228,13 @@ class UserController extends Controller
 
         $user = $this->userRepo->getById($id);
         $this->setPageTitle(trans('settings.users_delete_named', ['userName' => $user->name]));
 
         $user = $this->userRepo->getById($id);
         $this->setPageTitle(trans('settings.users_delete_named', ['userName' => $user->name]));
+
         return view('users.delete', ['user' => $user]);
     }
 
     /**
      * Remove the specified user from storage.
         return view('users.delete', ['user' => $user]);
     }
 
     /**
      * Remove the specified user from storage.
+     *
      * @throws Exception
      */
     public function destroy(Request $request, int $id)
      * @throws Exception
      */
     public function destroy(Request $request, int $id)
@@ -237,11 +247,13 @@ class UserController extends Controller
 
         if ($this->userRepo->isOnlyAdmin($user)) {
             $this->showErrorNotification(trans('errors.users_cannot_delete_only_admin'));
 
         if ($this->userRepo->isOnlyAdmin($user)) {
             $this->showErrorNotification(trans('errors.users_cannot_delete_only_admin'));
+
             return redirect($user->getEditUrl());
         }
 
         if ($user->system_name === 'public') {
             $this->showErrorNotification(trans('errors.users_cannot_delete_guest'));
             return redirect($user->getEditUrl());
         }
 
         if ($user->system_name === 'public') {
             $this->showErrorNotification(trans('errors.users_cannot_delete_guest'));
+
             return redirect($user->getEditUrl());
         }
 
             return redirect($user->getEditUrl());
         }
 
@@ -304,6 +316,7 @@ class UserController extends Controller
         if (!in_array($type, $validSortTypes)) {
             return redirect()->back(500);
         }
         if (!in_array($type, $validSortTypes)) {
             return redirect()->back(500);
         }
+
         return $this->changeListSort($id, $request, $type);
     }
 
         return $this->changeListSort($id, $request, $type);
     }
 
@@ -314,6 +327,7 @@ class UserController extends Controller
     {
         $enabled = setting()->getForCurrentUser('dark-mode-enabled', false);
         setting()->putUser(user(), 'dark-mode-enabled', $enabled ? 'false' : 'true');
     {
         $enabled = setting()->getForCurrentUser('dark-mode-enabled', false);
         setting()->putUser(user(), 'dark-mode-enabled', $enabled ? 'false' : 'true');
+
         return redirect()->back();
     }
 
         return redirect()->back();
     }
 
@@ -325,14 +339,15 @@ class UserController extends Controller
         $this->checkPermissionOrCurrentUser('users-manage', $id);
         $keyWhitelist = ['home-details'];
         if (!in_array($key, $keyWhitelist)) {
         $this->checkPermissionOrCurrentUser('users-manage', $id);
         $keyWhitelist = ['home-details'];
         if (!in_array($key, $keyWhitelist)) {
-            return response("Invalid key", 500);
+            return response('Invalid key', 500);
         }
 
         $newState = $request->get('expand', 'false');
 
         $user = $this->user->findOrFail($id);
         setting()->putUser($user, 'section_expansion#' . $key, $newState);
         }
 
         $newState = $request->get('expand', 'false');
 
         $user = $this->user->findOrFail($id);
         setting()->putUser($user, 'section_expansion#' . $key, $newState);
-        return response("", 204);
+
+        return response('', 204);
     }
 
     /**
     }
 
     /**
index 95e68cb07d95e97a583be7a37def344bcadc8819..09ae4c1bd3f6ad265763f39e76cfc3a49aee822c 100644 (file)
@@ -1,11 +1,13 @@
-<?php namespace BookStack\Http\Controllers;
+<?php
+
+namespace BookStack\Http\Controllers;
 
 use BookStack\Auth\UserRepo;
 
 class UserProfileController extends Controller
 {
     /**
 
 use BookStack\Auth\UserRepo;
 
 class UserProfileController extends Controller
 {
     /**
-     * Show the user profile page
+     * Show the user profile page.
      */
     public function show(UserRepo $repo, string $slug)
     {
      */
     public function show(UserRepo $repo, string $slug)
     {
@@ -16,10 +18,10 @@ class UserProfileController extends Controller
         $assetCounts = $repo->getAssetCounts($user);
 
         return view('users.profile', [
         $assetCounts = $repo->getAssetCounts($user);
 
         return view('users.profile', [
-            'user' => $user,
-            'activity' => $userActivity,
+            'user'            => $user,
+            'activity'        => $userActivity,
             'recentlyCreated' => $recentlyCreated,
             'recentlyCreated' => $recentlyCreated,
-            'assetCounts' => $assetCounts
+            'assetCounts'     => $assetCounts,
         ]);
     }
 }
         ]);
     }
 }
index a0dfbd8d06696ec8dc8be83ef4ac9747730af998..4150caf04cd4d90621e7fbbe0fd9aafa3eb87125 100644 (file)
@@ -26,6 +26,7 @@ class UserSearchController extends Controller
         }
 
         $users = $query->get();
         }
 
         $users = $query->get();
+
         return view('components.user-select-list', compact('users'));
     }
 }
         return view('components.user-select-list', compact('users'));
     }
 }
index 694036ab48c87ecb2cfe62417e95eef23b15d563..4f9bfc1e64050dcd7a244c12b453db9ccc04461d 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Http;
+<?php
+
+namespace BookStack\Http;
 
 use Illuminate\Foundation\Http\Kernel as HttpKernel;
 
 
 use Illuminate\Foundation\Http\Kernel as HttpKernel;
 
index 728057bed175b42a880014b0ecfbd6c3962d2701..21d69810faaf5e685a6303f59c2f02476dd006a8 100644 (file)
@@ -29,6 +29,7 @@ class ApiAuthenticate
     /**
      * Ensure the current user can access authenticated API routes, either via existing session
      * authentication or via API Token authentication.
     /**
      * Ensure the current user can access authenticated API routes, either via existing session
      * authentication or via API Token authentication.
+     *
      * @throws UnauthorizedException
      */
     protected function ensureAuthorizedBySessionOrToken(): void
      * @throws UnauthorizedException
      */
     protected function ensureAuthorizedBySessionOrToken(): void
@@ -40,6 +41,7 @@ class ApiAuthenticate
             if (!user()->can('access-api')) {
                 throw new ApiAuthException(trans('errors.api_user_no_api_permission'), 403);
             }
             if (!user()->can('access-api')) {
                 throw new ApiAuthException(trans('errors.api_user_no_api_permission'), 403);
             }
+
             return;
         }
 
             return;
         }
 
@@ -58,9 +60,9 @@ class ApiAuthenticate
     {
         return response()->json([
             'error' => [
     {
         return response()->json([
             'error' => [
-                'code' => $code,
+                'code'    => $code,
                 'message' => $message,
                 'message' => $message,
-            ]
+            ],
         ], $code);
     }
 }
         ], $code);
     }
 }
index df8c44d351cc92784bc8adaec1f642ea0c1719a0..3b018cde0f349f3b087507b7ea34864f48267f2a 100644 (file)
@@ -38,9 +38,9 @@ class Authenticate
         if ($request->wantsJson()) {
             return response()->json([
                 'error' => [
         if ($request->wantsJson()) {
             return response()->json([
                 'error' => [
-                    'code' => 401,
-                    'message' => trans('errors.email_confirmation_awaiting')
-                ]
+                    'code'    => 401,
+                    'message' => trans('errors.email_confirmation_awaiting'),
+                ],
             ], 401);
         }
 
             ], 401);
         }
 
index cc73ea68d36cdf438e184f0cfdbd2da489bebf52..adc1d1f3ec0ab4a9b7e3044b56e021a52f0e1453 100644 (file)
@@ -9,9 +9,10 @@ class CheckGuard
     /**
      * Handle an incoming request.
      *
     /**
      * Handle an incoming request.
      *
-     * @param  \Illuminate\Http\Request  $request
-     * @param  \Closure  $next
-     * @param string $allowedGuards
+     * @param \Illuminate\Http\Request $request
+     * @param \Closure                 $next
+     * @param string                   $allowedGuards
+     *
      * @return mixed
      */
     public function handle($request, Closure $next, ...$allowedGuards)
      * @return mixed
      */
     public function handle($request, Closure $next, ...$allowedGuards)
@@ -19,6 +20,7 @@ class CheckGuard
         $activeGuard = config('auth.method');
         if (!in_array($activeGuard, $allowedGuards)) {
             session()->flash('error', trans('errors.permission'));
         $activeGuard = config('auth.method');
         if (!in_array($activeGuard, $allowedGuards)) {
             session()->flash('error', trans('errors.permission'));
+
             return redirect('/');
         }
 
             return redirect('/');
         }
 
index cbf55040a5bbeba8cb0bf8b3c9dc6fef48fe2e12..2eabeca1663a82ac6a38eeb92d65cc347f173cc4 100644 (file)
@@ -3,13 +3,13 @@
 namespace BookStack\Http\Middleware;
 
 use BookStack\Exceptions\UnauthorizedException;
 namespace BookStack\Http\Middleware;
 
 use BookStack\Exceptions\UnauthorizedException;
-use Illuminate\Http\Request;
 
 trait ChecksForEmailConfirmation
 {
     /**
      * Check if the current user has a confirmed email if the instance deems it as required.
      * Throws if confirmation is required by the user.
 
 trait ChecksForEmailConfirmation
 {
     /**
      * Check if the current user has a confirmed email if the instance deems it as required.
      * Throws if confirmation is required by the user.
+     *
      * @throws UnauthorizedException
      */
     protected function ensureEmailConfirmedIfRequested()
      * @throws UnauthorizedException
      */
     protected function ensureEmailConfirmedIfRequested()
index cc8034413b8ed3651c66ab7df202521c8d62253d..11d9e6d4c5a2b84ce47786306c07c450c30f9c53 100644 (file)
@@ -3,7 +3,6 @@
 namespace BookStack\Http\Middleware;
 
 use Closure;
 namespace BookStack\Http\Middleware;
 
 use Closure;
-use Symfony\Component\HttpFoundation\Response;
 
 /**
  * Sets CSP headers to restrict the hosts that BookStack can be
 
 /**
  * Sets CSP headers to restrict the hosts that BookStack can be
@@ -15,8 +14,9 @@ class ControlIframeSecurity
     /**
      * Handle an incoming request.
      *
     /**
      * Handle an incoming request.
      *
-     * @param  \Illuminate\Http\Request  $request
-     * @param  \Closure  $next
+     * @param \Illuminate\Http\Request $request
+     * @param \Closure                 $next
+     *
      * @return mixed
      */
     public function handle($request, Closure $next)
      * @return mixed
      */
     public function handle($request, Closure $next)
@@ -31,6 +31,7 @@ class ControlIframeSecurity
         $response = $next($request);
         $cspValue = 'frame-ancestors ' . $iframeHosts->join(' ');
         $response->headers->set('Content-Security-Policy', $cspValue);
         $response = $next($request);
         $cspValue = 'frame-ancestors ' . $iframeHosts->join(' ');
         $response->headers->set('Content-Security-Policy', $cspValue);
+
         return $response;
     }
 }
         return $response;
     }
 }
index 0b286a713f8398f45811b78e82c0fac990991185..b29bbe4b3c60491acf2e2e7e1e1eb64c4fc56dec 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Http\Middleware;
+<?php
+
+namespace BookStack\Http\Middleware;
 
 use Carbon\Carbon;
 use Closure;
 
 use Carbon\Carbon;
 use Closure;
@@ -6,9 +8,8 @@ use Illuminate\Http\Request;
 
 class Localization
 {
 
 class Localization
 {
-
     /**
     /**
-     * Array of right-to-left locales
+     * Array of right-to-left locales.
      */
     protected $rtlLocales = ['ar', 'he'];
 
      */
     protected $rtlLocales = ['ar', 'he'];
 
@@ -16,45 +17,46 @@ class Localization
      * Map of BookStack locale names to best-estimate system locale names.
      */
     protected $localeMap = [
      * Map of BookStack locale names to best-estimate system locale names.
      */
     protected $localeMap = [
-        'ar' => 'ar',
-        'bg' => 'bg_BG',
-        'bs' => 'bs_BA',
-        'ca' => 'ca',
-        'da' => 'da_DK',
-        'de' => 'de_DE',
+        'ar'          => 'ar',
+        'bg'          => 'bg_BG',
+        'bs'          => 'bs_BA',
+        'ca'          => 'ca',
+        'da'          => 'da_DK',
+        'de'          => 'de_DE',
         'de_informal' => 'de_DE',
         'de_informal' => 'de_DE',
-        'en' => 'en_GB',
-        'es' => 'es_ES',
-        'es_AR' => 'es_AR',
-        'fr' => 'fr_FR',
-        'he' => 'he_IL',
-        'hr' => 'hr_HR',
-        'id' => 'id_ID',
-        'it' => 'it_IT',
-        'ja' => 'ja',
-        'ko' => 'ko_KR',
-        'lv' => 'lv_LV',
-        'nl' => 'nl_NL',
-        'nb' => 'nb_NO',
-        'pl' => 'pl_PL',
-        'pt' => 'pt_PT',
-        'pt_BR' => 'pt_BR',
-        'ru' => 'ru',
-        'sk' => 'sk_SK',
-        'sl' => 'sl_SI',
-        'sv' => 'sv_SE',
-        'uk' => 'uk_UA',
-        'vi' => 'vi_VN',
-        'zh_CN' => 'zh_CN',
-        'zh_TW' => 'zh_TW',
-        'tr' => 'tr_TR',
+        'en'          => 'en_GB',
+        'es'          => 'es_ES',
+        'es_AR'       => 'es_AR',
+        'fr'          => 'fr_FR',
+        'he'          => 'he_IL',
+        'hr'          => 'hr_HR',
+        'id'          => 'id_ID',
+        'it'          => 'it_IT',
+        'ja'          => 'ja',
+        'ko'          => 'ko_KR',
+        'lv'          => 'lv_LV',
+        'nl'          => 'nl_NL',
+        'nb'          => 'nb_NO',
+        'pl'          => 'pl_PL',
+        'pt'          => 'pt_PT',
+        'pt_BR'       => 'pt_BR',
+        'ru'          => 'ru',
+        'sk'          => 'sk_SK',
+        'sl'          => 'sl_SI',
+        'sv'          => 'sv_SE',
+        'uk'          => 'uk_UA',
+        'vi'          => 'vi_VN',
+        'zh_CN'       => 'zh_CN',
+        'zh_TW'       => 'zh_TW',
+        'tr'          => 'tr_TR',
     ];
 
     /**
      * Handle an incoming request.
      *
     ];
 
     /**
      * Handle an incoming request.
      *
-     * @param  \Illuminate\Http\Request  $request
-     * @param  \Closure  $next
+     * @param \Illuminate\Http\Request $request
+     * @param \Closure                 $next
+     *
      * @return mixed
      */
     public function handle($request, Closure $next)
      * @return mixed
      */
     public function handle($request, Closure $next)
@@ -73,6 +75,7 @@ class Localization
         app()->setLocale($locale);
         Carbon::setLocale($locale);
         $this->setSystemDateLocale($locale);
         app()->setLocale($locale);
         Carbon::setLocale($locale);
         $this->setSystemDateLocale($locale);
+
         return $next($request);
     }
 
         return $next($request);
     }
 
@@ -106,11 +109,12 @@ class Localization
                 return $lang;
             }
         }
                 return $lang;
             }
         }
+
         return $default;
     }
 
     /**
         return $default;
     }
 
     /**
-     * Get the ISO version of a BookStack language name
+     * Get the ISO version of a BookStack language name.
      */
     public function getLocaleIso(string $locale): string
     {
      */
     public function getLocaleIso(string $locale): string
     {
index d0bb4f79ef852e9e4b19fdcbd149159a6a05adb4..1d7e4aaa1b353e3f9e21cc7eee7540b7aa59f73a 100644 (file)
@@ -3,23 +3,23 @@
 namespace BookStack\Http\Middleware;
 
 use Closure;
 namespace BookStack\Http\Middleware;
 
 use Closure;
-use Illuminate\Support\Facades\Session;
 
 class PermissionMiddleware
 {
     /**
      * Handle an incoming request.
      *
 
 class PermissionMiddleware
 {
     /**
      * Handle an incoming request.
      *
-     * @param  \Illuminate\Http\Request $request
-     * @param  \Closure                 $next
-     * @param                           $permission
+     * @param \Illuminate\Http\Request $request
+     * @param \Closure                 $next
+     * @param                          $permission
+     *
      * @return mixed
      */
     public function handle($request, Closure $next, $permission)
     {
      * @return mixed
      */
     public function handle($request, Closure $next, $permission)
     {
-
         if (!$request->user() || !$request->user()->can($permission)) {
             session()->flash('error', trans('errors.permission'));
         if (!$request->user() || !$request->user()->can($permission)) {
             session()->flash('error', trans('errors.permission'));
+
             return redirect()->back();
         }
 
             return redirect()->back();
         }
 
index c27df7af4f5434bdbf7d208fbe98f82ddde78bfb..6853809ea9d03b5db7a74a817c6f256ef00d832a 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Http\Middleware;
+<?php
+
+namespace BookStack\Http\Middleware;
 
 use Closure;
 use Illuminate\Contracts\Auth\Guard;
 
 use Closure;
 use Illuminate\Contracts\Auth\Guard;
@@ -15,7 +17,8 @@ class RedirectIfAuthenticated
     /**
      * Create a new filter instance.
      *
     /**
      * Create a new filter instance.
      *
-     * @param  Guard $auth
+     * @param Guard $auth
+     *
      * @return void
      */
     public function __construct(Guard $auth)
      * @return void
      */
     public function __construct(Guard $auth)
@@ -26,8 +29,9 @@ class RedirectIfAuthenticated
     /**
      * Handle an incoming request.
      *
     /**
      * Handle an incoming request.
      *
-     * @param  \Illuminate\Http\Request $request
-     * @param  \Closure                 $next
+     * @param \Illuminate\Http\Request $request
+     * @param \Closure                 $next
+     *
      * @return mixed
      */
     public function handle($request, Closure $next)
      * @return mixed
      */
     public function handle($request, Closure $next)
index d995f144547219bf2eafcd1b5dff698cc9f1457b..5e727daae5e99f076c5b59e29ff7adb7bb03b068 100644 (file)
@@ -11,8 +11,9 @@ class RunThemeActions
     /**
      * Handle an incoming request.
      *
     /**
      * Handle an incoming request.
      *
-     * @param  \Illuminate\Http\Request  $request
-     * @param  \Closure  $next
+     * @param \Illuminate\Http\Request $request
+     * @param \Closure                 $next
+     *
      * @return mixed
      */
     public function handle($request, Closure $next)
      * @return mixed
      */
     public function handle($request, Closure $next)
@@ -24,6 +25,7 @@ class RunThemeActions
 
         $response = $next($request);
         $response = Theme::dispatch(ThemeEvents::WEB_MIDDLEWARE_AFTER, $request, $response) ?? $response;
 
         $response = $next($request);
         $response = Theme::dispatch(ThemeEvents::WEB_MIDDLEWARE_AFTER, $request, $response) ?? $response;
+
         return $response;
     }
 }
         return $response;
     }
 }
index 4e03aed58d50113236f5fef509a89c43101efa8b..c63d0c6033d4b6918a9970a9f495af2f1432430e 100644 (file)
@@ -6,7 +6,6 @@ use Illuminate\Routing\Middleware\ThrottleRequests as Middleware;
 
 class ThrottleApiRequests extends Middleware
 {
 
 class ThrottleApiRequests extends Middleware
 {
-
     /**
      * Resolve the number of attempts if the user is authenticated or not.
      */
     /**
      * Resolve the number of attempts if the user is authenticated or not.
      */
index 7b01d0aab0de906a01be4afe31a7f82b937b429e..3f8b32eb2cbe7105abde5c72487cbaaceccde723 100644 (file)
@@ -24,8 +24,10 @@ class TrustProxies extends Middleware
 
     /**
      * Handle the request, Set the correct user-configured proxy information.
 
     /**
      * Handle the request, Set the correct user-configured proxy information.
+     *
      * @param Request $request
      * @param Closure $next
      * @param Request $request
      * @param Closure $next
+     *
      * @return mixed
      */
     public function handle(Request $request, Closure $next)
      * @return mixed
      */
     public function handle(Request $request, Closure $next)
index bdeb265540a9bde5c6d53f6ffef8b5e8f1ca3711..804a22bc09a3e35acbe26833940eb215e45a81d7 100644 (file)
@@ -19,6 +19,6 @@ class VerifyCsrfToken extends Middleware
      * @var array
      */
     protected $except = [
      * @var array
      */
     protected $except = [
-        'saml2/*'
+        'saml2/*',
     ];
 }
     ];
 }
index 183686f67b4eef3a6299c2cb2e25893b4f4c4a61..c5b38f1c1bbfe1f391469d791d144ed400e1ce38 100644 (file)
@@ -1,13 +1,15 @@
-<?php namespace BookStack\Http;
+<?php
+
+namespace BookStack\Http;
 
 use Illuminate\Http\Request as LaravelRequest;
 
 class Request extends LaravelRequest
 {
 
 use Illuminate\Http\Request as LaravelRequest;
 
 class Request extends LaravelRequest
 {
-
     /**
      * Override the default request methods to get the scheme and host
      * to set the custom APP_URL, if set.
     /**
      * Override the default request methods to get the scheme and host
      * to set the custom APP_URL, if set.
+     *
      * @return \Illuminate\Config\Repository|mixed|string
      */
     public function getSchemeAndHttpHost()
      * @return \Illuminate\Config\Repository|mixed|string
      */
     public function getSchemeAndHttpHost()
@@ -17,7 +19,7 @@ class Request extends LaravelRequest
         if ($base) {
             $base = trim($base, '/');
         } else {
         if ($base) {
             $base = trim($base, '/');
         } else {
-            $base = $this->getScheme().'://'.$this->getHttpHost();
+            $base = $this->getScheme() . '://' . $this->getHttpHost();
         }
 
         return $base;
         }
 
         return $base;
index dd335feeda3acf7e26c707a3b05b04dde5e1fc2f..8a311d1f2d8b54523147bad167a48572deaccb02 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Interfaces;
+<?php
+
+namespace BookStack\Interfaces;
 
 use Illuminate\Database\Eloquent\Relations\MorphMany;
 
 
 use Illuminate\Database\Eloquent\Relations\MorphMany;
 
@@ -8,4 +10,4 @@ interface Favouritable
      * Get the related favourite instances.
      */
     public function favourites(): MorphMany;
      * Get the related favourite instances.
      */
     public function favourites(): MorphMany;
-}
\ No newline at end of file
+}
index 6aa94e69c9a66e39340df51fd91d7ee8c546974a..24ee1bab2f6faba7ce131ad96134f815377cc738 100644 (file)
@@ -1,23 +1,24 @@
-<?php namespace BookStack\Interfaces;
+<?php
+
+namespace BookStack\Interfaces;
 
 use Illuminate\Database\Eloquent\Builder;
 
 /**
 
 use Illuminate\Database\Eloquent\Builder;
 
 /**
- * Interface Sluggable
+ * Interface Sluggable.
  *
  * Assigned to models that can have slugs.
  * Must have the below properties.
  *
  *
  * Assigned to models that can have slugs.
  * Must have the below properties.
  *
- * @property int $id
+ * @property int    $id
  * @property string $name
  * @property string $name
+ *
  * @method Builder newQuery
  */
 interface Sluggable
 {
  * @method Builder newQuery
  */
 interface Sluggable
 {
-
     /**
      * Regenerate the slug for this model.
      */
     public function refreshSlug(): string;
     /**
      * Regenerate the slug for this model.
      */
     public function refreshSlug(): string;
-
-}
\ No newline at end of file
+}
index 4a7b6a013f0e273dc2bba46534d1a717244b7936..d79ebed997d8a6a91219511c50da4851c61d5e7d 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Interfaces;
+<?php
+
+namespace BookStack\Interfaces;
 
 use Illuminate\Database\Eloquent\Relations\MorphMany;
 
 
 use Illuminate\Database\Eloquent\Relations\MorphMany;
 
@@ -8,4 +10,4 @@ interface Viewable
      * Get all view instances for this viewable model.
      */
     public function views(): MorphMany;
      * Get all view instances for this viewable model.
      */
     public function views(): MorphMany;
-}
\ No newline at end of file
+}
index 498bacb2055fcb4296b69a44f1e75eb3c61b9e11..8520060f442efe78beed4a7a8159302e1f39f896 100644 (file)
@@ -1,14 +1,17 @@
-<?php namespace BookStack;
+<?php
+
+namespace BookStack;
 
 use Illuminate\Database\Eloquent\Model as EloquentModel;
 
 class Model extends EloquentModel
 {
 
 use Illuminate\Database\Eloquent\Model as EloquentModel;
 
 class Model extends EloquentModel
 {
-
     /**
      * Provides public access to get the raw attribute value from the model.
      * Used in areas where no mutations are required but performance is critical.
     /**
      * Provides public access to get the raw attribute value from the model.
      * Used in areas where no mutations are required but performance is critical.
+     *
      * @param $key
      * @param $key
+     *
      * @return mixed
      */
     public function getRawAttribute($key)
      * @return mixed
      */
     public function getRawAttribute($key)
index 229408f5cf9827533a8307727beac5e4768185c7..5399c25a8492eca5bdbfd52236c439630e02d45c 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Notifications;
+<?php
+
+namespace BookStack\Notifications;
 
 class ConfirmEmail extends MailNotification
 {
 
 class ConfirmEmail extends MailNotification
 {
@@ -6,6 +8,7 @@ class ConfirmEmail extends MailNotification
 
     /**
      * Create a new notification instance.
 
     /**
      * Create a new notification instance.
+     *
      * @param string $token
      */
     public function __construct($token)
      * @param string $token
      */
     public function __construct($token)
@@ -16,12 +19,14 @@ class ConfirmEmail extends MailNotification
     /**
      * Get the mail representation of the notification.
      *
     /**
      * Get the mail representation of the notification.
      *
-     * @param  mixed  $notifiable
+     * @param mixed $notifiable
+     *
      * @return \Illuminate\Notifications\Messages\MailMessage
      */
     public function toMail($notifiable)
     {
         $appName = ['appName' => setting('app-name')];
      * @return \Illuminate\Notifications\Messages\MailMessage
      */
     public function toMail($notifiable)
     {
         $appName = ['appName' => setting('app-name')];
+
         return $this->newMailMessage()
                 ->subject(trans('auth.email_confirm_subject', $appName))
                 ->greeting(trans('auth.email_confirm_greeting', $appName))
         return $this->newMailMessage()
                 ->subject(trans('auth.email_confirm_subject', $appName))
                 ->greeting(trans('auth.email_confirm_greeting', $appName))
index 5aa9b1e4a6296de1fe9557649a2d7401d877c52c..12159b27893db094541219862fdebebe1f3fdc94 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Notifications;
+<?php
+
+namespace BookStack\Notifications;
 
 use Illuminate\Bus\Queueable;
 use Illuminate\Contracts\Queue\ShouldQueue;
 
 use Illuminate\Bus\Queueable;
 use Illuminate\Contracts\Queue\ShouldQueue;
@@ -12,7 +14,8 @@ class MailNotification extends Notification implements ShouldQueue
     /**
      * Get the notification's channels.
      *
     /**
      * Get the notification's channels.
      *
-     * @param  mixed  $notifiable
+     * @param mixed $notifiable
+     *
      * @return array|string
      */
     public function via($notifiable)
      * @return array|string
      */
     public function via($notifiable)
@@ -22,13 +25,14 @@ class MailNotification extends Notification implements ShouldQueue
 
     /**
      * Create a new mail message.
 
     /**
      * Create a new mail message.
+     *
      * @return MailMessage
      */
     protected function newMailMessage()
     {
      * @return MailMessage
      */
     protected function newMailMessage()
     {
-        return (new MailMessage)->view([
+        return (new MailMessage())->view([
             'html' => 'vendor.notifications.email',
             'html' => 'vendor.notifications.email',
-            'text' => 'vendor.notifications.email-plain'
+            'text' => 'vendor.notifications.email-plain',
         ]);
     }
 }
         ]);
     }
 }
index 20875276400f0403d1a9a063459e37195a2cd475..7fa14659604f567ec04847ee761526c1dfdf2b0f 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Notifications;
+<?php
+
+namespace BookStack\Notifications;
 
 class ResetPassword extends MailNotification
 {
 
 class ResetPassword extends MailNotification
 {
@@ -12,7 +14,7 @@ class ResetPassword extends MailNotification
     /**
      * Create a notification instance.
      *
     /**
      * Create a notification instance.
      *
-     * @param  string  $token
+     * @param string $token
      */
     public function __construct($token)
     {
      */
     public function __construct($token)
     {
@@ -26,7 +28,7 @@ class ResetPassword extends MailNotification
      */
     public function toMail()
     {
      */
     public function toMail()
     {
-            return $this->newMailMessage()
+        return $this->newMailMessage()
             ->subject(trans('auth.email_reset_subject', ['appName' => setting('app-name')]))
             ->line(trans('auth.email_reset_text'))
             ->action(trans('auth.reset_password'), url('password/reset/' . $this->token))
             ->subject(trans('auth.email_reset_subject', ['appName' => setting('app-name')]))
             ->line(trans('auth.email_reset_text'))
             ->action(trans('auth.reset_password'), url('password/reset/' . $this->token))
index 7fce1c19c80a7d2d6d590a949679eda6059b08b1..7f59ff70ffab3f44b5199da30228018955151794 100644 (file)
@@ -1,11 +1,14 @@
-<?php namespace BookStack\Notifications;
+<?php
+
+namespace BookStack\Notifications;
 
 class TestEmail extends MailNotification
 {
     /**
      * Get the mail representation of the notification.
      *
 
 class TestEmail extends MailNotification
 {
     /**
      * Get the mail representation of the notification.
      *
-     * @param  mixed  $notifiable
+     * @param mixed $notifiable
+     *
      * @return \Illuminate\Notifications\Messages\MailMessage
      */
     public function toMail($notifiable)
      * @return \Illuminate\Notifications\Messages\MailMessage
      */
     public function toMail($notifiable)
index b01911bcdc06780f31664d15bc5881d9d65aac2e..b0dc9afac3f836d11e9159ed85ab393c0fa7e299 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Notifications;
+<?php
+
+namespace BookStack\Notifications;
 
 class UserInvite extends MailNotification
 {
 
 class UserInvite extends MailNotification
 {
@@ -6,6 +8,7 @@ class UserInvite extends MailNotification
 
     /**
      * Create a new notification instance.
 
     /**
      * Create a new notification instance.
+     *
      * @param string $token
      */
     public function __construct($token)
      * @param string $token
      */
     public function __construct($token)
@@ -16,12 +19,14 @@ class UserInvite extends MailNotification
     /**
      * Get the mail representation of the notification.
      *
     /**
      * Get the mail representation of the notification.
      *
-     * @param  mixed  $notifiable
+     * @param mixed $notifiable
+     *
      * @return \Illuminate\Notifications\Messages\MailMessage
      */
     public function toMail($notifiable)
     {
         $appName = ['appName' => setting('app-name')];
      * @return \Illuminate\Notifications\Messages\MailMessage
      */
     public function toMail($notifiable)
     {
         $appName = ['appName' => setting('app-name')];
+
         return $this->newMailMessage()
                 ->subject(trans('auth.user_invite_email_subject', $appName))
                 ->greeting(trans('auth.user_invite_email_greeting', $appName))
         return $this->newMailMessage()
                 ->subject(trans('auth.user_invite_email_subject', $appName))
                 ->greeting(trans('auth.user_invite_email_greeting', $appName))
index 333542c31e992771916faba7cca9da6f5760d3be..abee6bcda2edd772d0c8cd5e8c0753534fd47a4f 100644 (file)
@@ -1,10 +1,12 @@
-<?php namespace BookStack\Providers;
+<?php
+
+namespace BookStack\Providers;
 
 use Blade;
 use BookStack\Auth\Access\SocialAuthService;
 
 use Blade;
 use BookStack\Auth\Access\SocialAuthService;
+use BookStack\Entities\BreadcrumbsViewComposer;
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Bookshelf;
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Bookshelf;
-use BookStack\Entities\BreadcrumbsViewComposer;
 use BookStack\Entities\Models\Chapter;
 use BookStack\Entities\Models\Page;
 use BookStack\Settings\Setting;
 use BookStack\Entities\Models\Chapter;
 use BookStack\Entities\Models\Page;
 use BookStack\Settings\Setting;
@@ -45,9 +47,9 @@ class AppServiceProvider extends ServiceProvider
         // Set morph-map due to namespace changes
         Relation::morphMap([
             'BookStack\\Bookshelf' => Bookshelf::class,
         // Set morph-map due to namespace changes
         Relation::morphMap([
             'BookStack\\Bookshelf' => Bookshelf::class,
-            'BookStack\\Book' => Book::class,
-            'BookStack\\Chapter' => Chapter::class,
-            'BookStack\\Page' => Page::class,
+            'BookStack\\Book'      => Book::class,
+            'BookStack\\Chapter'   => Chapter::class,
+            'BookStack\\Page'      => Page::class,
         ]);
 
         // View Composers
         ]);
 
         // View Composers
@@ -65,7 +67,7 @@ class AppServiceProvider extends ServiceProvider
             return new SettingService($app->make(Setting::class), $app->make(Repository::class));
         });
 
             return new SettingService($app->make(Setting::class), $app->make(Repository::class));
         });
 
-        $this->app->singleton(SocialAuthService::class, function($app) {
+        $this->app->singleton(SocialAuthService::class, function ($app) {
             return new SocialAuthService($app->make(SocialiteFactory::class));
         });
     }
             return new SocialAuthService($app->make(SocialiteFactory::class));
         });
     }
index fe52df1686cec7ac00bcd82ba14a1c74b0b5f3dd..1a78214dc8937ff039d86d8e69bdcdb20c2dffd9 100644 (file)
@@ -9,7 +9,6 @@ use BookStack\Auth\Access\Guards\LdapSessionGuard;
 use BookStack\Auth\Access\Guards\Saml2SessionGuard;
 use BookStack\Auth\Access\LdapService;
 use BookStack\Auth\Access\RegistrationService;
 use BookStack\Auth\Access\Guards\Saml2SessionGuard;
 use BookStack\Auth\Access\LdapService;
 use BookStack\Auth\Access\RegistrationService;
-use BookStack\Auth\UserRepo;
 use Illuminate\Support\ServiceProvider;
 
 class AuthServiceProvider extends ServiceProvider
 use Illuminate\Support\ServiceProvider;
 
 class AuthServiceProvider extends ServiceProvider
@@ -27,6 +26,7 @@ class AuthServiceProvider extends ServiceProvider
 
         Auth::extend('ldap-session', function ($app, $name, array $config) {
             $provider = Auth::createUserProvider($config['provider']);
 
         Auth::extend('ldap-session', function ($app, $name, array $config) {
             $provider = Auth::createUserProvider($config['provider']);
+
             return new LdapSessionGuard(
                 $name,
                 $provider,
             return new LdapSessionGuard(
                 $name,
                 $provider,
@@ -38,6 +38,7 @@ class AuthServiceProvider extends ServiceProvider
 
         Auth::extend('saml2-session', function ($app, $name, array $config) {
             $provider = Auth::createUserProvider($config['provider']);
 
         Auth::extend('saml2-session', function ($app, $name, array $config) {
             $provider = Auth::createUserProvider($config['provider']);
+
             return new Saml2SessionGuard(
                 $name,
                 $provider,
             return new Saml2SessionGuard(
                 $name,
                 $provider,
index b668a4cd22b4312f6f7ce17649177de25a09ce1e..c54f48ca31378bbcf8f61f706029f9af118da7c7 100644 (file)
@@ -7,7 +7,6 @@ use Illuminate\Support\ServiceProvider;
 
 class CustomValidationServiceProvider extends ServiceProvider
 {
 
 class CustomValidationServiceProvider extends ServiceProvider
 {
-
     /**
      * Register our custom validation rules when the application boots.
      */
     /**
      * Register our custom validation rules when the application boots.
      */
@@ -15,6 +14,7 @@ class CustomValidationServiceProvider extends ServiceProvider
     {
         Validator::extend('image_extension', function ($attribute, $value, $parameters, $validator) {
             $validImageExtensions = ['png', 'jpg', 'jpeg', 'gif', 'webp'];
     {
         Validator::extend('image_extension', function ($attribute, $value, $parameters, $validator) {
             $validImageExtensions = ['png', 'jpg', 'jpeg', 'gif', 'webp'];
+
             return in_array(strtolower($value->getClientOriginalExtension()), $validImageExtensions);
         });
 
             return in_array(strtolower($value->getClientOriginalExtension()), $validImageExtensions);
         });
 
@@ -22,6 +22,7 @@ class CustomValidationServiceProvider extends ServiceProvider
             $cleanLinkName = strtolower(trim($value));
             $isJs = strpos($cleanLinkName, 'javascript:') === 0;
             $isData = strpos($cleanLinkName, 'data:') === 0;
             $cleanLinkName = strtolower(trim($value));
             $isJs = strpos($cleanLinkName, 'javascript:') === 0;
             $isData = strpos($cleanLinkName, 'data:') === 0;
+
             return !$isJs && !$isData;
         });
     }
             return !$isJs && !$isData;
         });
     }
index 1c982b82eacd26610861d49cfdcf71bc1e5a02c3..416aa5f347abdab63253cdc631d89f39e237c013 100644 (file)
@@ -1,11 +1,12 @@
-<?php namespace BookStack\Providers;
+<?php
+
+namespace BookStack\Providers;
 
 use Illuminate\Pagination\PaginationServiceProvider as IlluminatePaginationServiceProvider;
 use Illuminate\Pagination\Paginator;
 
 class PaginationServiceProvider extends IlluminatePaginationServiceProvider
 {
 
 use Illuminate\Pagination\PaginationServiceProvider as IlluminatePaginationServiceProvider;
 use Illuminate\Pagination\Paginator;
 
 class PaginationServiceProvider extends IlluminatePaginationServiceProvider
 {
-
     /**
      * Register the service provider.
      *
     /**
      * Register the service provider.
      *
index a37780e52eb1c25eaef4355afc3b497e786d9f6a..8f0dab400c7efd4ce00902d7ef94874a654e516e 100644 (file)
@@ -36,6 +36,7 @@ class RouteServiceProvider extends ServiceProvider
         $this->mapWebRoutes();
         $this->mapApiRoutes();
     }
         $this->mapWebRoutes();
         $this->mapApiRoutes();
     }
+
     /**
      * Define the "web" routes for the application.
      *
     /**
      * Define the "web" routes for the application.
      *
@@ -47,11 +48,12 @@ class RouteServiceProvider extends ServiceProvider
     {
         Route::group([
             'middleware' => 'web',
     {
         Route::group([
             'middleware' => 'web',
-            'namespace' => $this->namespace,
+            'namespace'  => $this->namespace,
         ], function ($router) {
             require base_path('routes/web.php');
         });
     }
         ], function ($router) {
             require base_path('routes/web.php');
         });
     }
+
     /**
      * Define the "api" routes for the application.
      *
     /**
      * Define the "api" routes for the application.
      *
@@ -63,8 +65,8 @@ class RouteServiceProvider extends ServiceProvider
     {
         Route::group([
             'middleware' => 'api',
     {
         Route::group([
             'middleware' => 'api',
-            'namespace' => $this->namespace . '\Api',
-            'prefix' => 'api',
+            'namespace'  => $this->namespace . '\Api',
+            'prefix'     => 'api',
         ], function ($router) {
             require base_path('routes/api.php');
         });
         ], function ($router) {
             require base_path('routes/api.php');
         });
index c41a15af06af98fbd8446c7b5e8face78941390f..54c83884a77d969270ee07eded2222f40451cc2c 100644 (file)
@@ -16,7 +16,7 @@ class ThemeServiceProvider extends ServiceProvider
     public function register()
     {
         $this->app->singleton(ThemeService::class, function ($app) {
     public function register()
     {
         $this->app->singleton(ThemeService::class, function ($app) {
-            return new ThemeService;
+            return new ThemeService();
         });
     }
 
         });
     }
 
index b7fb9b117ac18896cbd8cebcc54c08d21350a563..3610a1e22148a5601a566198dfdcdcde3d8af97f 100644 (file)
@@ -1,14 +1,16 @@
-<?php namespace BookStack\Providers;
+<?php
+
+namespace BookStack\Providers;
 
 use BookStack\Translation\FileLoader;
 use Illuminate\Translation\TranslationServiceProvider as BaseProvider;
 
 class TranslationServiceProvider extends BaseProvider
 {
 
 use BookStack\Translation\FileLoader;
 use Illuminate\Translation\TranslationServiceProvider as BaseProvider;
 
 class TranslationServiceProvider extends BaseProvider
 {
-
     /**
      * Register the translation line loader.
      * Overrides the default register action from Laravel so a custom loader can be used.
     /**
      * Register the translation line loader.
      * Overrides the default register action from Laravel so a custom loader can be used.
+     *
      * @return void
      */
     protected function registerLoader()
      * @return void
      */
     protected function registerLoader()
index 1a52920eeb73cc6c88e78ad7ec68961ddd30e8cf..c0492e6c1f7ca9133de70ba042b4d0b5823a6038 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Settings;
+<?php
+
+namespace BookStack\Settings;
 
 use BookStack\Model;
 
 
 use BookStack\Model;
 
index 310e0ccfff83d2898cb6b675d5924da233c4a0f0..f2c4c8305c47c2db227a79456e880422171dc500 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Settings;
+<?php
+
+namespace BookStack\Settings;
 
 use BookStack\Auth\User;
 use Illuminate\Contracts\Cache\Repository as Cache;
 
 use BookStack\Auth\User;
 use Illuminate\Contracts\Cache\Repository as Cache;
@@ -42,6 +44,7 @@ class SettingService
         $value = $this->getValueFromStore($key) ?? $default;
         $formatted = $this->formatValue($value, $default);
         $this->localCache[$key] = $formatted;
         $value = $this->getValueFromStore($key) ?? $default;
         $formatted = $this->formatValue($value, $default);
         $this->localCache[$key] = $formatted;
+
         return $formatted;
     }
 
         return $formatted;
     }
 
@@ -51,6 +54,7 @@ class SettingService
     protected function getFromSession(string $key, $default = false)
     {
         $value = session()->get($key, $default);
     protected function getFromSession(string $key, $default = false)
     {
         $value = session()->get($key, $default);
+
         return $this->formatValue($value, $default);
     }
 
         return $this->formatValue($value, $default);
     }
 
@@ -66,6 +70,7 @@ class SettingService
         if ($user->isDefault()) {
             return $this->getFromSession($key, $default);
         }
         if ($user->isDefault()) {
             return $this->getFromSession($key, $default);
         }
+
         return $this->get($this->userKey($user->id, $key), $default);
     }
 
         return $this->get($this->userKey($user->id, $key), $default);
     }
 
@@ -101,6 +106,7 @@ class SettingService
             }
 
             $this->cache->forever($cacheKey, $value);
             }
 
             $this->cache->forever($cacheKey, $value);
+
             return $value;
         }
 
             return $value;
         }
 
@@ -120,14 +126,14 @@ class SettingService
     }
 
     /**
     }
 
     /**
-     * Format a settings value
+     * Format a settings value.
      */
     protected function formatValue($value, $default)
     {
         // Change string booleans to actual booleans
         if ($value === 'true') {
             $value = true;
      */
     protected function formatValue($value, $default)
     {
         // Change string booleans to actual booleans
         if ($value === 'true') {
             $value = true;
-        } else if ($value === 'false') {
+        } elseif ($value === 'false') {
             $value = false;
         }
 
             $value = false;
         }
 
@@ -135,6 +141,7 @@ class SettingService
         if ($value === '') {
             $value = $default;
         }
         if ($value === '') {
             $value = $default;
         }
+
         return $value;
     }
 
         return $value;
     }
 
@@ -144,6 +151,7 @@ class SettingService
     public function has(string $key): bool
     {
         $setting = $this->getSettingObjectByKey($key);
     public function has(string $key): bool
     {
         $setting = $this->getSettingObjectByKey($key);
+
         return $setting !== null;
     }
 
         return $setting !== null;
     }
 
@@ -154,7 +162,7 @@ class SettingService
     public function put(string $key, $value): bool
     {
         $setting = $this->setting->newQuery()->firstOrNew([
     public function put(string $key, $value): bool
     {
         $setting = $this->setting->newQuery()->firstOrNew([
-            'setting_key' => $key
+            'setting_key' => $key,
         ]);
         $setting->type = 'string';
 
         ]);
         $setting->type = 'string';
 
@@ -166,6 +174,7 @@ class SettingService
         $setting->value = $value;
         $setting->save();
         $this->clearFromCache($key);
         $setting->value = $value;
         $setting->save();
         $this->clearFromCache($key);
+
         return true;
     }
 
         return true;
     }
 
@@ -179,6 +188,7 @@ class SettingService
         $values = collect($value)->values()->filter(function (array $item) {
             return count(array_filter($item)) > 0;
         });
         $values = collect($value)->values()->filter(function (array $item) {
             return count(array_filter($item)) > 0;
         });
+
         return json_encode($values);
     }
 
         return json_encode($values);
     }
 
@@ -189,6 +199,7 @@ class SettingService
     {
         if ($user->isDefault()) {
             session()->put($key, $value);
     {
         if ($user->isDefault()) {
             session()->put($key, $value);
+
             return true;
         }
 
             return true;
         }
 
index 56e1fba1ccd70f4a3342047f6d20ec13d6f4822b..e170cbf758722efead9e7c640c7d7e144042c20f 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Theming;
+<?php
+
+namespace BookStack\Theming;
 
 /**
  * The ThemeEvents used within BookStack.
 
 /**
  * The ThemeEvents used within BookStack.
@@ -16,6 +18,7 @@ class ThemeEvents
     /**
      * Application boot-up.
      * After main services are registered.
     /**
      * Application boot-up.
      * After main services are registered.
+     *
      * @param \BookStack\Application $app
      */
     const APP_BOOT = 'app_boot';
      * @param \BookStack\Application $app
      */
     const APP_BOOT = 'app_boot';
@@ -26,6 +29,7 @@ class ThemeEvents
      * that depend on the current session user (Localization for example).
      * Provides the original request to use.
      * Return values, if provided, will be used as a new response to use.
      * that depend on the current session user (Localization for example).
      * Provides the original request to use.
      * Return values, if provided, will be used as a new response to use.
+     *
      * @param \Illuminate\Http\Request $request
      * @returns \Illuminate\Http\Response|null
      */
      * @param \Illuminate\Http\Request $request
      * @returns \Illuminate\Http\Response|null
      */
@@ -36,6 +40,7 @@ class ThemeEvents
      * Runs after the request is handled but before the response is sent.
      * Provides both the original request and the currently resolved response.
      * Return values, if provided, will be used as a new response to use.
      * Runs after the request is handled but before the response is sent.
      * Provides both the original request and the currently resolved response.
      * Return values, if provided, will be used as a new response to use.
+     *
      * @param \Illuminate\Http\Request $request
      * @returns \Illuminate\Http\Response|null
      */
      * @param \Illuminate\Http\Request $request
      * @returns \Illuminate\Http\Response|null
      */
@@ -46,7 +51,8 @@ class ThemeEvents
      * Runs right after a user is logged-in to the application by any authentication
      * system as a standard app user. This includes a user becoming logged in
      * after registration. This is not emitted upon API usage.
      * Runs right after a user is logged-in to the application by any authentication
      * system as a standard app user. This includes a user becoming logged in
      * after registration. This is not emitted upon API usage.
-     * @param string $authSystem
+     *
+     * @param string               $authSystem
      * @param \BookStack\Auth\User $user
      */
     const AUTH_LOGIN = 'auth_login';
      * @param \BookStack\Auth\User $user
      */
     const AUTH_LOGIN = 'auth_login';
@@ -56,7 +62,8 @@ class ThemeEvents
      * Runs right after a user is newly registered to the application by any authentication
      * system as a standard app user. This includes auto-registration systems used
      * by LDAP, SAML and social systems. It only includes self-registrations.
      * Runs right after a user is newly registered to the application by any authentication
      * system as a standard app user. This includes auto-registration systems used
      * by LDAP, SAML and social systems. It only includes self-registrations.
-     * @param string $authSystem
+     *
+     * @param string               $authSystem
      * @param \BookStack\Auth\User $user
      */
     const AUTH_REGISTER = 'auth_register';
      * @param \BookStack\Auth\User $user
      */
     const AUTH_REGISTER = 'auth_register';
@@ -66,8 +73,9 @@ class ThemeEvents
      * Provides the commonmark library environment for customization
      * before its used to render markdown content.
      * If the listener returns a non-null value, that will be used as an environment instead.
      * Provides the commonmark library environment for customization
      * before its used to render markdown content.
      * If the listener returns a non-null value, that will be used as an environment instead.
+     *
      * @param \League\CommonMark\ConfigurableEnvironmentInterface $environment
      * @returns \League\CommonMark\ConfigurableEnvironmentInterface|null
      */
     const COMMONMARK_ENVIRONMENT_CONFIGURE = 'commonmark_environment_configure';
      * @param \League\CommonMark\ConfigurableEnvironmentInterface $environment
      * @returns \League\CommonMark\ConfigurableEnvironmentInterface|null
      */
     const COMMONMARK_ENVIRONMENT_CONFIGURE = 'commonmark_environment_configure';
-}
\ No newline at end of file
+}
index 895108e3e2aac8ee5791c266bd30c9ba6c1e951e..6fe80559eefbc204a6fd1b5ee538fcb337d638c9 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Theming;
+<?php
+
+namespace BookStack\Theming;
 
 use BookStack\Auth\Access\SocialAuthService;
 
 
 use BookStack\Auth\Access\SocialAuthService;
 
@@ -26,6 +28,7 @@ class ThemeService
      *
      * If a callback returns a non-null value, this method will
      * stop and return that value itself.
      *
      * If a callback returns a non-null value, this method will
      * stop and return that value itself.
+     *
      * @return mixed
      */
     public function dispatch(string $event, ...$args)
      * @return mixed
      */
     public function dispatch(string $event, ...$args)
@@ -36,6 +39,7 @@ class ThemeService
                 return $result;
             }
         }
                 return $result;
             }
         }
+
         return null;
     }
 
         return null;
     }
 
@@ -58,4 +62,4 @@ class ThemeService
         $socialAuthService = app()->make(SocialAuthService::class);
         $socialAuthService->addSocialDriver($driverName, $config, $socialiteHandler, $configureForRedirect);
     }
         $socialAuthService = app()->make(SocialAuthService::class);
         $socialAuthService->addSocialDriver($driverName, $config, $socialiteHandler, $configureForRedirect);
     }
-}
\ No newline at end of file
+}
index ace1fa12cb47781550afa38a682b1b4bf12fc2eb..a48936bc8e87414d1bee22fcfcb63cb56d54d8aa 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Traits;
+<?php
+
+namespace BookStack\Traits;
 
 use BookStack\Auth\User;
 use Illuminate\Database\Eloquent\Relations\BelongsTo;
 
 use BookStack\Auth\User;
 use Illuminate\Database\Eloquent\Relations\BelongsTo;
index ff4b8c18ec9d1b9e4bb43b24cdea1c09f29446f5..6700ff4df21184940095c77c6e4cab08391cb2bf 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Traits;
+<?php
+
+namespace BookStack\Traits;
 
 use BookStack\Auth\User;
 use Illuminate\Database\Eloquent\Relations\BelongsTo;
 
 use BookStack\Auth\User;
 use Illuminate\Database\Eloquent\Relations\BelongsTo;
index 0b4a93de6bc8dc84b9145378a2830f2645160c88..1ed7b06ccc593b35e6f24896c86063776c963190 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Translation;
+<?php
+
+namespace BookStack\Translation;
 
 use Illuminate\Translation\FileLoader as BaseLoader;
 
 
 use Illuminate\Translation\FileLoader as BaseLoader;
 
@@ -8,9 +10,11 @@ class FileLoader extends BaseLoader
      * Load the messages for the given locale.
      * Extends Laravel's translation FileLoader to look in multiple directories
      * so that we can load in translation overrides from the theme file if wanted.
      * Load the messages for the given locale.
      * Extends Laravel's translation FileLoader to look in multiple directories
      * so that we can load in translation overrides from the theme file if wanted.
-     * @param  string  $locale
-     * @param  string  $group
-     * @param  string|null  $namespace
+     *
+     * @param string      $locale
+     * @param string      $group
+     * @param string|null $namespace
+     *
      * @return array
      */
     public function load($locale, $group, $namespace = null)
      * @return array
      */
     public function load($locale, $group, $namespace = null)
@@ -21,7 +25,8 @@ class FileLoader extends BaseLoader
 
         if (is_null($namespace) || $namespace === '*') {
             $themeTranslations = $this->loadPath(theme_path('lang'), $locale, $group);
 
         if (is_null($namespace) || $namespace === '*') {
             $themeTranslations = $this->loadPath(theme_path('lang'), $locale, $group);
-            $originalTranslations =  $this->loadPath($this->path, $locale, $group);
+            $originalTranslations = $this->loadPath($this->path, $locale, $group);
+
             return array_merge($originalTranslations, $themeTranslations);
         }
 
             return array_merge($originalTranslations, $themeTranslations);
         }
 
index 383af9537d34a20590e1609bcaddeaa8a9b11a67..5acd4f141bb2dfcac8f118bde2bdcf11b97b2af8 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Uploads;
+<?php
+
+namespace BookStack\Uploads;
 
 use BookStack\Entities\Models\Page;
 use BookStack\Model;
 
 use BookStack\Entities\Models\Page;
 use BookStack\Model;
@@ -21,6 +23,7 @@ class Attachment extends Model
 
     /**
      * Get the downloadable file name for this upload.
 
     /**
      * Get the downloadable file name for this upload.
+     *
      * @return mixed|string
      */
     public function getFileName()
      * @return mixed|string
      */
     public function getFileName()
@@ -28,6 +31,7 @@ class Attachment extends Model
         if (strpos($this->name, '.') !== false) {
             return $this->name;
         }
         if (strpos($this->name, '.') !== false) {
             return $this->name;
         }
+
         return $this->name . '.' . $this->extension;
     }
 
         return $this->name . '.' . $this->extension;
     }
 
@@ -47,6 +51,7 @@ class Attachment extends Model
         if ($this->external && strpos($this->path, 'http') !== 0) {
             return $this->path;
         }
         if ($this->external && strpos($this->path, 'http') !== 0) {
             return $this->path;
         }
+
         return url('/attachments/' . $this->id . ($openInline ? '?open=true' : ''));
     }
 
         return url('/attachments/' . $this->id . ($openInline ? '?open=true' : ''));
     }
 
@@ -55,7 +60,7 @@ class Attachment extends Model
      */
     public function htmlLink(): string
     {
      */
     public function htmlLink(): string
     {
-        return '<a target="_blank" href="'.e($this->getUrl()).'">'.e($this->name).'</a>';
+        return '<a target="_blank" href="' . e($this->getUrl()) . '">' . e($this->name) . '</a>';
     }
 
     /**
     }
 
     /**
@@ -63,6 +68,6 @@ class Attachment extends Model
      */
     public function markdownLink(): string
     {
      */
     public function markdownLink(): string
     {
-        return '['. $this->name .']('. $this->getUrl() .')';
+        return '[' . $this->name . '](' . $this->getUrl() . ')';
     }
 }
     }
 }
index 37adb4f8368f0c355fcad8ae3bfd37037876c402..298d53a04c109ff42175318fd3ed69f9166ea375 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Uploads;
+<?php
+
+namespace BookStack\Uploads;
 
 use BookStack\Exceptions\FileUploadException;
 use Exception;
 
 use BookStack\Exceptions\FileUploadException;
 use Exception;
@@ -11,7 +13,6 @@ use Symfony\Component\HttpFoundation\File\UploadedFile;
 
 class AttachmentService
 {
 
 class AttachmentService
 {
-
     protected $fileSystem;
 
     /**
     protected $fileSystem;
 
     /**
@@ -22,7 +23,6 @@ class AttachmentService
         $this->fileSystem = $fileSystem;
     }
 
         $this->fileSystem = $fileSystem;
     }
 
-
     /**
      * Get the storage that will be used for storing files.
      */
     /**
      * Get the storage that will be used for storing files.
      */
@@ -40,6 +40,7 @@ class AttachmentService
 
     /**
      * Get an attachment from storage.
 
     /**
      * Get an attachment from storage.
+     *
      * @throws FileNotFoundException
      */
     public function getAttachmentFromStorage(Attachment $attachment): string
      * @throws FileNotFoundException
      */
     public function getAttachmentFromStorage(Attachment $attachment): string
@@ -49,10 +50,13 @@ class AttachmentService
 
     /**
      * Store a new attachment upon user upload.
 
     /**
      * Store a new attachment upon user upload.
+     *
      * @param UploadedFile $uploadedFile
      * @param UploadedFile $uploadedFile
-     * @param int $page_id
-     * @return Attachment
+     * @param int          $page_id
+     *
      * @throws FileUploadException
      * @throws FileUploadException
+     *
+     * @return Attachment
      */
     public function saveNewUpload(UploadedFile $uploadedFile, $page_id)
     {
      */
     public function saveNewUpload(UploadedFile $uploadedFile, $page_id)
     {
@@ -61,13 +65,13 @@ class AttachmentService
         $largestExistingOrder = Attachment::where('uploaded_to', '=', $page_id)->max('order');
 
         $attachment = Attachment::forceCreate([
         $largestExistingOrder = Attachment::where('uploaded_to', '=', $page_id)->max('order');
 
         $attachment = Attachment::forceCreate([
-            'name' => $attachmentName,
-            'path' => $attachmentPath,
-            'extension' => $uploadedFile->getClientOriginalExtension(),
+            'name'        => $attachmentName,
+            'path'        => $attachmentPath,
+            'extension'   => $uploadedFile->getClientOriginalExtension(),
             'uploaded_to' => $page_id,
             'uploaded_to' => $page_id,
-            'created_by' => user()->id,
-            'updated_by' => user()->id,
-            'order' => $largestExistingOrder + 1
+            'created_by'  => user()->id,
+            'updated_by'  => user()->id,
+            'order'       => $largestExistingOrder + 1,
         ]);
 
         return $attachment;
         ]);
 
         return $attachment;
@@ -76,10 +80,13 @@ class AttachmentService
     /**
      * Store a upload, saving to a file and deleting any existing uploads
      * attached to that file.
     /**
      * Store a upload, saving to a file and deleting any existing uploads
      * attached to that file.
+     *
      * @param UploadedFile $uploadedFile
      * @param UploadedFile $uploadedFile
-     * @param Attachment $attachment
-     * @return Attachment
+     * @param Attachment   $attachment
+     *
      * @throws FileUploadException
      * @throws FileUploadException
+     *
+     * @return Attachment
      */
     public function saveUpdatedUpload(UploadedFile $uploadedFile, Attachment $attachment)
     {
      */
     public function saveUpdatedUpload(UploadedFile $uploadedFile, Attachment $attachment)
     {
@@ -95,6 +102,7 @@ class AttachmentService
         $attachment->external = false;
         $attachment->extension = $uploadedFile->getClientOriginalExtension();
         $attachment->save();
         $attachment->external = false;
         $attachment->extension = $uploadedFile->getClientOriginalExtension();
         $attachment->save();
+
         return $attachment;
     }
 
         return $attachment;
     }
 
@@ -104,15 +112,16 @@ class AttachmentService
     public function saveNewFromLink(string $name, string $link, int $page_id): Attachment
     {
         $largestExistingOrder = Attachment::where('uploaded_to', '=', $page_id)->max('order');
     public function saveNewFromLink(string $name, string $link, int $page_id): Attachment
     {
         $largestExistingOrder = Attachment::where('uploaded_to', '=', $page_id)->max('order');
+
         return Attachment::forceCreate([
         return Attachment::forceCreate([
-            'name' => $name,
-            'path' => $link,
-            'external' => true,
-            'extension' => '',
+            'name'        => $name,
+            'path'        => $link,
+            'external'    => true,
+            'extension'   => '',
             'uploaded_to' => $page_id,
             'uploaded_to' => $page_id,
-            'created_by' => user()->id,
-            'updated_by' => user()->id,
-            'order' => $largestExistingOrder + 1
+            'created_by'  => user()->id,
+            'updated_by'  => user()->id,
+            'order'       => $largestExistingOrder + 1,
         ]);
     }
 
         ]);
     }
 
@@ -128,7 +137,6 @@ class AttachmentService
         }
     }
 
         }
     }
 
-
     /**
      * Update the details of a file.
      */
     /**
      * Update the details of a file.
      */
@@ -145,21 +153,25 @@ class AttachmentService
         }
 
         $attachment->save();
         }
 
         $attachment->save();
+
         return $attachment;
     }
 
     /**
      * Delete a File from the database and storage.
         return $attachment;
     }
 
     /**
      * Delete a File from the database and storage.
+     *
      * @param Attachment $attachment
      * @param Attachment $attachment
+     *
      * @throws Exception
      */
     public function deleteFile(Attachment $attachment)
     {
         if ($attachment->external) {
             $attachment->delete();
      * @throws Exception
      */
     public function deleteFile(Attachment $attachment)
     {
         if ($attachment->external) {
             $attachment->delete();
+
             return;
         }
             return;
         }
-        
+
         $this->deleteFileInStorage($attachment);
         $attachment->delete();
     }
         $this->deleteFileInStorage($attachment);
         $attachment->delete();
     }
@@ -167,6 +179,7 @@ class AttachmentService
     /**
      * Delete a file from the filesystem it sits on.
      * Cleans any empty leftover folders.
     /**
      * Delete a file from the filesystem it sits on.
      * Cleans any empty leftover folders.
+     *
      * @param Attachment $attachment
      */
     protected function deleteFileInStorage(Attachment $attachment)
      * @param Attachment $attachment
      */
     protected function deleteFileInStorage(Attachment $attachment)
@@ -181,17 +194,20 @@ class AttachmentService
     }
 
     /**
     }
 
     /**
-     * Store a file in storage with the given filename
+     * Store a file in storage with the given filename.
+     *
      * @param UploadedFile $uploadedFile
      * @param UploadedFile $uploadedFile
-     * @return string
+     *
      * @throws FileUploadException
      * @throws FileUploadException
+     *
+     * @return string
      */
     protected function putFileInStorage(UploadedFile $uploadedFile)
     {
         $attachmentData = file_get_contents($uploadedFile->getRealPath());
 
         $storage = $this->getStorage();
      */
     protected function putFileInStorage(UploadedFile $uploadedFile)
     {
         $attachmentData = file_get_contents($uploadedFile->getRealPath());
 
         $storage = $this->getStorage();
-        $basePath = 'uploads/files/' . Date('Y-m-M') . '/';
+        $basePath = 'uploads/files/' . date('Y-m-M') . '/';
 
         $uploadFileName = Str::random(16) . '.' . $uploadedFile->getClientOriginalExtension();
         while ($storage->exists($basePath . $uploadFileName)) {
 
         $uploadFileName = Str::random(16) . '.' . $uploadedFile->getClientOriginalExtension();
         while ($storage->exists($basePath . $uploadFileName)) {
@@ -199,10 +215,12 @@ class AttachmentService
         }
 
         $attachmentPath = $basePath . $uploadFileName;
         }
 
         $attachmentPath = $basePath . $uploadFileName;
+
         try {
             $storage->put($attachmentPath, $attachmentData);
         } catch (Exception $e) {
             Log::error('Error when attempting file upload:' . $e->getMessage());
         try {
             $storage->put($attachmentPath, $attachmentData);
         } catch (Exception $e) {
             Log::error('Error when attempting file upload:' . $e->getMessage());
+
             throw new FileUploadException(trans('errors.path_not_writable', ['filePath' => $attachmentPath]));
         }
 
             throw new FileUploadException(trans('errors.path_not_writable', ['filePath' => $attachmentPath]));
         }
 
index 5e8115637dbbe23abf78dd5a9eb52959d9e75fe8..4198bb2a326dce7b3e28d6083a6dc6422daf86ee 100644 (file)
@@ -1,23 +1,27 @@
-<?php namespace BookStack\Uploads;
+<?php
+
+namespace BookStack\Uploads;
 
 use BookStack\Exceptions\HttpFetchException;
 
 class HttpFetcher
 {
 
 use BookStack\Exceptions\HttpFetchException;
 
 class HttpFetcher
 {
-
     /**
      * Fetch content from an external URI.
     /**
      * Fetch content from an external URI.
+     *
      * @param string $uri
      * @param string $uri
-     * @return bool|string
+     *
      * @throws HttpFetchException
      * @throws HttpFetchException
+     *
+     * @return bool|string
      */
     public function fetch(string $uri)
     {
         $ch = curl_init();
         curl_setopt_array($ch, [
      */
     public function fetch(string $uri)
     {
         $ch = curl_init();
         curl_setopt_array($ch, [
-            CURLOPT_URL => $uri,
+            CURLOPT_URL            => $uri,
             CURLOPT_RETURNTRANSFER => 1,
             CURLOPT_RETURNTRANSFER => 1,
-            CURLOPT_CONNECTTIMEOUT => 5
+            CURLOPT_CONNECTTIMEOUT => 5,
         ]);
 
         $data = curl_exec($ch);
         ]);
 
         $data = curl_exec($ch);
index 3657aa9469d2bac249fe0b146608a4784ba96eef..4e0abc85b9a4d49128d4841cfc35548dff4dcb3b 100644 (file)
@@ -1,18 +1,20 @@
-<?php namespace BookStack\Uploads;
+<?php
+
+namespace BookStack\Uploads;
 
 use BookStack\Entities\Models\Page;
 use BookStack\Model;
 use BookStack\Traits\HasCreatorAndUpdater;
 
 /**
 
 use BookStack\Entities\Models\Page;
 use BookStack\Model;
 use BookStack\Traits\HasCreatorAndUpdater;
 
 /**
- * @property int $id
+ * @property int    $id
  * @property string $name
  * @property string $url
  * @property string $path
  * @property string $type
  * @property string $name
  * @property string $url
  * @property string $path
  * @property string $type
- * @property int $uploaded_to
- * @property int $created_by
- * @property int $updated_by
+ * @property int    $uploaded_to
+ * @property int    $created_by
+ * @property int    $updated_by
  */
 class Image extends Model
 {
  */
 class Image extends Model
 {
@@ -23,6 +25,7 @@ class Image extends Model
 
     /**
      * Get a thumbnail for this image.
 
     /**
      * Get a thumbnail for this image.
+     *
      * @throws \Exception
      */
     public function getThumb(int $width, int $height, bool $keepRatio = false): string
      * @throws \Exception
      */
     public function getThumb(int $width, int $height, bool $keepRatio = false): string
index ef249c58b02b59710133d25e71d871b4ff255b9c..11507856140a0a7c330991cb8c488a1167257170 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Uploads;
+<?php
+
+namespace BookStack\Uploads;
 
 use BookStack\Auth\Permissions\PermissionService;
 use BookStack\Entities\Models\Page;
 
 use BookStack\Auth\Permissions\PermissionService;
 use BookStack\Entities\Models\Page;
@@ -9,7 +11,6 @@ use Symfony\Component\HttpFoundation\File\UploadedFile;
 
 class ImageRepo
 {
 
 class ImageRepo
 {
-
     protected $image;
     protected $imageService;
     protected $restrictionService;
     protected $image;
     protected $imageService;
     protected $restrictionService;
@@ -30,7 +31,6 @@ class ImageRepo
         $this->page = $page;
     }
 
         $this->page = $page;
     }
 
-
     /**
      * Get an image with the given id.
      */
     /**
      * Get an image with the given id.
      */
@@ -54,8 +54,8 @@ class ImageRepo
         });
 
         return [
         });
 
         return [
-            'images'  => $returnImages,
-            'has_more' => $hasMore
+            'images'   => $returnImages,
+            'has_more' => $hasMore,
         ];
     }
 
         ];
     }
 
@@ -121,39 +121,45 @@ class ImageRepo
 
     /**
      * Save a new image into storage and return the new image.
 
     /**
      * Save a new image into storage and return the new image.
+     *
      * @throws ImageUploadException
      */
     public function saveNew(UploadedFile $uploadFile, string $type, int $uploadedTo = 0, int $resizeWidth = null, int $resizeHeight = null, bool $keepRatio = true): Image
     {
         $image = $this->imageService->saveNewFromUpload($uploadFile, $type, $uploadedTo, $resizeWidth, $resizeHeight, $keepRatio);
         $this->loadThumbs($image);
      * @throws ImageUploadException
      */
     public function saveNew(UploadedFile $uploadFile, string $type, int $uploadedTo = 0, int $resizeWidth = null, int $resizeHeight = null, bool $keepRatio = true): Image
     {
         $image = $this->imageService->saveNewFromUpload($uploadFile, $type, $uploadedTo, $resizeWidth, $resizeHeight, $keepRatio);
         $this->loadThumbs($image);
+
         return $image;
     }
 
     /**
      * Save a new image from an existing image data string.
         return $image;
     }
 
     /**
      * Save a new image from an existing image data string.
+     *
      * @throws ImageUploadException
      */
     public function saveNewFromData(string $imageName, string $imageData, string $type, int $uploadedTo = 0)
     {
         $image = $this->imageService->saveNew($imageName, $imageData, $type, $uploadedTo);
         $this->loadThumbs($image);
      * @throws ImageUploadException
      */
     public function saveNewFromData(string $imageName, string $imageData, string $type, int $uploadedTo = 0)
     {
         $image = $this->imageService->saveNew($imageName, $imageData, $type, $uploadedTo);
         $this->loadThumbs($image);
+
         return $image;
     }
 
     /**
      * Save a drawing the the database.
         return $image;
     }
 
     /**
      * Save a drawing the the database.
+     *
      * @throws ImageUploadException
      */
     public function saveDrawing(string $base64Uri, int $uploadedTo): Image
     {
         $name = 'Drawing-' . strval(user()->id) . '-' . strval(time()) . '.png';
      * @throws ImageUploadException
      */
     public function saveDrawing(string $base64Uri, int $uploadedTo): Image
     {
         $name = 'Drawing-' . strval(user()->id) . '-' . strval(time()) . '.png';
+
         return $this->imageService->saveNewFromBase64Uri($base64Uri, $name, 'drawio', $uploadedTo);
     }
 
         return $this->imageService->saveNewFromBase64Uri($base64Uri, $name, 'drawio', $uploadedTo);
     }
 
-
     /**
      * Update the details of an image via an array of properties.
     /**
      * Update the details of an image via an array of properties.
+     *
      * @throws ImageUploadException
      * @throws Exception
      */
      * @throws ImageUploadException
      * @throws Exception
      */
@@ -162,11 +168,13 @@ class ImageRepo
         $image->fill($updateDetails);
         $image->save();
         $this->loadThumbs($image);
         $image->fill($updateDetails);
         $image->save();
         $this->loadThumbs($image);
+
         return $image;
     }
 
     /**
      * Destroys an Image object along with its revisions, files and thumbnails.
         return $image;
     }
 
     /**
      * Destroys an Image object along with its revisions, files and thumbnails.
+     *
      * @throws Exception
      */
     public function destroyImage(Image $image = null): bool
      * @throws Exception
      */
     public function destroyImage(Image $image = null): bool
@@ -174,11 +182,13 @@ class ImageRepo
         if ($image) {
             $this->imageService->destroy($image);
         }
         if ($image) {
             $this->imageService->destroy($image);
         }
+
         return true;
     }
 
     /**
      * Destroy all images of a certain type.
         return true;
     }
 
     /**
      * Destroy all images of a certain type.
+     *
      * @throws Exception
      */
     public function destroyByType(string $imageType)
      * @throws Exception
      */
     public function destroyByType(string $imageType)
@@ -189,16 +199,16 @@ class ImageRepo
         }
     }
 
         }
     }
 
-
     /**
      * Load thumbnails onto an image object.
     /**
      * Load thumbnails onto an image object.
+     *
      * @throws Exception
      */
     public function loadThumbs(Image $image)
     {
         $image->thumbs = [
             'gallery' => $this->getThumbnail($image, 150, 150, false),
      * @throws Exception
      */
     public function loadThumbs(Image $image)
     {
         $image->thumbs = [
             'gallery' => $this->getThumbnail($image, 150, 150, false),
-            'display' => $this->getThumbnail($image, 1680, null, true)
+            'display' => $this->getThumbnail($image, 1680, null, true),
         ];
     }
 
         ];
     }
 
@@ -206,6 +216,7 @@ class ImageRepo
      * Get the thumbnail for an image.
      * If $keepRatio is true only the width will be used.
      * Checks the cache then storage to avoid creating / accessing the filesystem on every check.
      * Get the thumbnail for an image.
      * If $keepRatio is true only the width will be used.
      * Checks the cache then storage to avoid creating / accessing the filesystem on every check.
+     *
      * @throws Exception
      */
     protected function getThumbnail(Image $image, ?int $width = 220, ?int $height = 220, bool $keepRatio = false): ?string
      * @throws Exception
      */
     protected function getThumbnail(Image $image, ?int $width = 220, ?int $height = 220, bool $keepRatio = false): ?string
index 293049f4f8c35e0b55edd76c772d425386079703..51ddf9bdc55912c3884e9b126aa3b92634a66ab2 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Uploads;
+<?php
+
+namespace BookStack\Uploads;
 
 use BookStack\Exceptions\ImageUploadException;
 use DB;
 
 use BookStack\Exceptions\ImageUploadException;
 use DB;
@@ -6,8 +8,8 @@ use ErrorException;
 use Exception;
 use Illuminate\Contracts\Cache\Repository as Cache;
 use Illuminate\Contracts\Filesystem\Factory as FileSystem;
 use Exception;
 use Illuminate\Contracts\Cache\Repository as Cache;
 use Illuminate\Contracts\Filesystem\Factory as FileSystem;
-use Illuminate\Contracts\Filesystem\Filesystem as FileSystemInstance;
 use Illuminate\Contracts\Filesystem\FileNotFoundException;
 use Illuminate\Contracts\Filesystem\FileNotFoundException;
+use Illuminate\Contracts\Filesystem\Filesystem as FileSystemInstance;
 use Illuminate\Contracts\Filesystem\Filesystem as Storage;
 use Illuminate\Support\Str;
 use Intervention\Image\Exception\NotSupportedException;
 use Illuminate\Contracts\Filesystem\Filesystem as Storage;
 use Illuminate\Support\Str;
 use Intervention\Image\Exception\NotSupportedException;
@@ -50,8 +52,10 @@ class ImageService
 
     /**
      * Saves a new image from an upload.
 
     /**
      * Saves a new image from an upload.
-     * @return mixed
+     *
      * @throws ImageUploadException
      * @throws ImageUploadException
+     *
+     * @return mixed
      */
     public function saveNewFromUpload(
         UploadedFile $uploadedFile,
      */
     public function saveNewFromUpload(
         UploadedFile $uploadedFile,
@@ -73,20 +77,23 @@ class ImageService
 
     /**
      * Save a new image from a uri-encoded base64 string of data.
 
     /**
      * Save a new image from a uri-encoded base64 string of data.
+     *
      * @throws ImageUploadException
      */
     public function saveNewFromBase64Uri(string $base64Uri, string $name, string $type, int $uploadedTo = 0): Image
     {
         $splitData = explode(';base64,', $base64Uri);
         if (count($splitData) < 2) {
      * @throws ImageUploadException
      */
     public function saveNewFromBase64Uri(string $base64Uri, string $name, string $type, int $uploadedTo = 0): Image
     {
         $splitData = explode(';base64,', $base64Uri);
         if (count($splitData) < 2) {
-            throw new ImageUploadException("Invalid base64 image data provided");
+            throw new ImageUploadException('Invalid base64 image data provided');
         }
         $data = base64_decode($splitData[1]);
         }
         $data = base64_decode($splitData[1]);
+
         return $this->saveNew($name, $data, $type, $uploadedTo);
     }
 
     /**
      * Save a new image into storage.
         return $this->saveNew($name, $data, $type, $uploadedTo);
     }
 
     /**
      * Save a new image into storage.
+     *
      * @throws ImageUploadException
      */
     public function saveNew(string $imageName, string $imageData, string $type, int $uploadedTo = 0): Image
      * @throws ImageUploadException
      */
     public function saveNew(string $imageName, string $imageData, string $type, int $uploadedTo = 0): Image
@@ -95,7 +102,7 @@ class ImageService
         $secureUploads = setting('app-secure-images');
         $fileName = $this->cleanImageFileName($imageName);
 
         $secureUploads = setting('app-secure-images');
         $fileName = $this->cleanImageFileName($imageName);
 
-        $imagePath = '/uploads/images/' . $type . '/' . Date('Y-m') . '/';
+        $imagePath = '/uploads/images/' . $type . '/' . date('Y-m') . '/';
 
         while ($storage->exists($imagePath . $fileName)) {
             $fileName = Str::random(3) . $fileName;
 
         while ($storage->exists($imagePath . $fileName)) {
             $fileName = Str::random(3) . $fileName;
@@ -110,15 +117,16 @@ class ImageService
             $this->saveImageDataInPublicSpace($storage, $fullPath, $imageData);
         } catch (Exception $e) {
             \Log::error('Error when attempting image upload:' . $e->getMessage());
             $this->saveImageDataInPublicSpace($storage, $fullPath, $imageData);
         } catch (Exception $e) {
             \Log::error('Error when attempting image upload:' . $e->getMessage());
+
             throw new ImageUploadException(trans('errors.path_not_writable', ['filePath' => $fullPath]));
         }
 
         $imageDetails = [
             throw new ImageUploadException(trans('errors.path_not_writable', ['filePath' => $fullPath]));
         }
 
         $imageDetails = [
-            'name' => $imageName,
-            'path' => $fullPath,
-            'url' => $this->getPublicUrl($fullPath),
-            'type' => $type,
-            'uploaded_to' => $uploadedTo
+            'name'        => $imageName,
+            'path'        => $fullPath,
+            'url'         => $this->getPublicUrl($fullPath),
+            'type'        => $type,
+            'uploaded_to' => $uploadedTo,
         ];
 
         if (user()->id !== 0) {
         ];
 
         if (user()->id !== 0) {
@@ -129,6 +137,7 @@ class ImageService
 
         $image = $this->image->newInstance();
         $image->forceFill($imageDetails)->save();
 
         $image = $this->image->newInstance();
         $image->forceFill($imageDetails)->save();
+
         return $image;
     }
 
         return $image;
     }
 
@@ -181,13 +190,16 @@ class ImageService
      * Get the thumbnail for an image.
      * If $keepRatio is true only the width will be used.
      * Checks the cache then storage to avoid creating / accessing the filesystem on every check.
      * Get the thumbnail for an image.
      * If $keepRatio is true only the width will be used.
      * Checks the cache then storage to avoid creating / accessing the filesystem on every check.
+     *
      * @param Image $image
      * @param Image $image
-     * @param int $width
-     * @param int $height
-     * @param bool $keepRatio
-     * @return string
+     * @param int   $width
+     * @param int   $height
+     * @param bool  $keepRatio
+     *
      * @throws Exception
      * @throws ImageUploadException
      * @throws Exception
      * @throws ImageUploadException
+     *
+     * @return string
      */
     public function getThumbnail(Image $image, $width = 220, $height = 220, $keepRatio = false)
     {
      */
     public function getThumbnail(Image $image, $width = 220, $height = 220, $keepRatio = false)
     {
@@ -213,18 +225,20 @@ class ImageService
         $this->saveImageDataInPublicSpace($storage, $thumbFilePath, $thumbData);
         $this->cache->put('images-' . $image->id . '-' . $thumbFilePath, $thumbFilePath, 60 * 60 * 72);
 
         $this->saveImageDataInPublicSpace($storage, $thumbFilePath, $thumbData);
         $this->cache->put('images-' . $image->id . '-' . $thumbFilePath, $thumbFilePath, 60 * 60 * 72);
 
-
         return $this->getPublicUrl($thumbFilePath);
     }
 
     /**
      * Resize image data.
         return $this->getPublicUrl($thumbFilePath);
     }
 
     /**
      * Resize image data.
+     *
      * @param string $imageData
      * @param string $imageData
-     * @param int $width
-     * @param int $height
-     * @param bool $keepRatio
-     * @return string
+     * @param int    $width
+     * @param int    $height
+     * @param bool   $keepRatio
+     *
      * @throws ImageUploadException
      * @throws ImageUploadException
+     *
+     * @return string
      */
     protected function resizeImage(string $imageData, $width = 220, $height = null, bool $keepRatio = true)
     {
      */
     protected function resizeImage(string $imageData, $width = 220, $height = null, bool $keepRatio = true)
     {
@@ -234,6 +248,7 @@ class ImageService
             if ($e instanceof ErrorException || $e instanceof NotSupportedException) {
                 throw new ImageUploadException(trans('errors.cannot_create_thumbs'));
             }
             if ($e instanceof ErrorException || $e instanceof NotSupportedException) {
                 throw new ImageUploadException(trans('errors.cannot_create_thumbs'));
             }
+
             throw $e;
         }
 
             throw $e;
         }
 
@@ -246,7 +261,7 @@ class ImageService
             $thumb->fit($width, $height);
         }
 
             $thumb->fit($width, $height);
         }
 
-        $thumbData = (string)$thumb->encode();
+        $thumbData = (string) $thumb->encode();
 
         // Use original image data if we're keeping the ratio
         // and the resizing does not save any space.
 
         // Use original image data if we're keeping the ratio
         // and the resizing does not save any space.
@@ -259,17 +274,20 @@ class ImageService
 
     /**
      * Get the raw data content from an image.
 
     /**
      * Get the raw data content from an image.
+     *
      * @throws FileNotFoundException
      */
     public function getImageData(Image $image): string
     {
         $imagePath = $image->path;
         $storage = $this->getStorage();
      * @throws FileNotFoundException
      */
     public function getImageData(Image $image): string
     {
         $imagePath = $image->path;
         $storage = $this->getStorage();
+
         return $storage->get($imagePath);
     }
 
     /**
      * Destroy an image along with its revisions, thumbnails and remaining folders.
         return $storage->get($imagePath);
     }
 
     /**
      * Destroy an image along with its revisions, thumbnails and remaining folders.
+     *
      * @throws Exception
      */
     public function destroy(Image $image)
      * @throws Exception
      */
     public function destroy(Image $image)
@@ -314,7 +332,8 @@ class ImageService
     {
         $files = $storage->files($path);
         $folders = $storage->directories($path);
     {
         $files = $storage->files($path);
         $folders = $storage->directories($path);
-        return (count($files) === 0 && count($folders) === 0);
+
+        return count($files) === 0 && count($folders) === 0;
     }
 
     /**
     }
 
     /**
@@ -350,6 +369,7 @@ class ImageService
                     }
                 }
             });
                     }
                 }
             });
+
         return $deletedPaths;
     }
 
         return $deletedPaths;
     }
 
@@ -358,6 +378,7 @@ class ImageService
      * Attempts to convert the URL to a system storage url then
      * fetch the data from the disk or storage location.
      * Returns null if the image data cannot be fetched from storage.
      * Attempts to convert the URL to a system storage url then
      * fetch the data from the disk or storage location.
      * Returns null if the image data cannot be fetched from storage.
+     *
      * @throws FileNotFoundException
      */
     public function imageUriToBase64(string $uri): ?string
      * @throws FileNotFoundException
      */
     public function imageUriToBase64(string $uri): ?string
@@ -400,6 +421,7 @@ class ImageService
             if (strpos(strtolower($url), 'uploads/images') === 0) {
                 return trim($url, '/');
             }
             if (strpos(strtolower($url), 'uploads/images') === 0) {
                 return trim($url, '/');
             }
+
             return null;
         }
 
             return null;
         }
 
@@ -443,6 +465,7 @@ class ImageService
         }
 
         $basePath = ($this->storageUrl == false) ? url('/') : $this->storageUrl;
         }
 
         $basePath = ($this->storageUrl == false) ? url('/') : $this->storageUrl;
+
         return rtrim($basePath, '/') . $filePath;
     }
 }
         return rtrim($basePath, '/') . $filePath;
     }
 }
index e98c1cfcaf5fa19488415f9237b00d4b46d12afc..f5b085a35d5cf802a45de6710034421f4c653716 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Uploads;
+<?php
+
+namespace BookStack\Uploads;
 
 use BookStack\Auth\User;
 use BookStack\Exceptions\HttpFetchException;
 
 use BookStack\Auth\User;
 use BookStack\Exceptions\HttpFetchException;
@@ -66,6 +68,7 @@ class UserAvatars
 
     /**
      * Save an avatar image from an external service.
 
     /**
      * Save an avatar image from an external service.
+     *
      * @throws Exception
      */
     protected function saveAvatarImage(User $user, int $size = 500): Image
      * @throws Exception
      */
     protected function saveAvatarImage(User $user, int $size = 500): Image
@@ -74,13 +77,14 @@ class UserAvatars
         $email = strtolower(trim($user->email));
 
         $replacements = [
         $email = strtolower(trim($user->email));
 
         $replacements = [
-            '${hash}' => md5($email),
-            '${size}' => $size,
+            '${hash}'  => md5($email),
+            '${size}'  => $size,
             '${email}' => urlencode($email),
         ];
 
         $userAvatarUrl = strtr($avatarUrl, $replacements);
         $imageData = $this->getAvatarImageData($userAvatarUrl);
             '${email}' => urlencode($email),
         ];
 
         $userAvatarUrl = strtr($avatarUrl, $replacements);
         $imageData = $this->getAvatarImageData($userAvatarUrl);
+
         return $this->createAvatarImageFromData($user, $imageData, 'png');
     }
 
         return $this->createAvatarImageFromData($user, $imageData, 'png');
     }
 
@@ -101,6 +105,7 @@ class UserAvatars
 
     /**
      * Gets an image from url and returns it as a string of image data.
 
     /**
      * Gets an image from url and returns it as a string of image data.
+     *
      * @throws Exception
      */
     protected function getAvatarImageData(string $url): string
      * @throws Exception
      */
     protected function getAvatarImageData(string $url): string
@@ -110,6 +115,7 @@ class UserAvatars
         } catch (HttpFetchException $exception) {
             throw new Exception(trans('errors.cannot_get_image_from_url', ['url' => $url]));
         }
         } catch (HttpFetchException $exception) {
             throw new Exception(trans('errors.cannot_get_image_from_url', ['url' => $url]));
         }
+
         return $imageData;
     }
 
         return $imageData;
     }
 
@@ -119,6 +125,7 @@ class UserAvatars
     protected function avatarFetchEnabled(): bool
     {
         $fetchUrl = $this->getAvatarUrl();
     protected function avatarFetchEnabled(): bool
     {
         $fetchUrl = $this->getAvatarUrl();
+
         return is_string($fetchUrl) && strpos($fetchUrl, 'http') === 0;
     }
 
         return is_string($fetchUrl) && strpos($fetchUrl, 'http') === 0;
     }
 
index 11be5a0995c3dde7ec047c5a5c9290a1f8135a2e..f251a22fdc94730ea1fc049299641b3cd42a279a 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Util;
+<?php
+
+namespace BookStack\Util;
 
 use DOMDocument;
 use DOMNodeList;
 
 use DOMDocument;
 use DOMNodeList;
@@ -44,7 +46,7 @@ class HtmlContentFilter
         // Remove 'on*' attributes
         $onAttributes = $xPath->query('//@*[starts-with(name(), \'on\')]');
         foreach ($onAttributes as $attr) {
         // Remove 'on*' attributes
         $onAttributes = $xPath->query('//@*[starts-with(name(), \'on\')]');
         foreach ($onAttributes as $attr) {
-            /** @var \DOMAttr $attr*/
+            /** @var \DOMAttr $attr */
             $attrName = $attr->nodeName;
             $attr->parentNode->removeAttribute($attrName);
         }
             $attrName = $attr->nodeName;
             $attr->parentNode->removeAttribute($attrName);
         }
index c1d72b91da4fb7f5bb3efba3a2de46490ec3dce9..618c71bee1927a00563b44401e5114695a1549d9 100644 (file)
@@ -7,6 +7,7 @@ use BookStack\Settings\SettingService;
 
 /**
  * Get the path to a versioned file.
 
 /**
  * Get the path to a versioned file.
+ *
  * @throws Exception
  */
 function versioned_asset(string $file = ''): string
  * @throws Exception
  */
 function versioned_asset(string $file = ''): string
@@ -24,6 +25,7 @@ function versioned_asset(string $file = ''): string
     }
 
     $path = $file . '?version=' . urlencode($version) . $additional;
     }
 
     $path = $file . '?version=' . urlencode($version) . $additional;
+
     return url($path);
 }
 
     return url($path);
 }
 
@@ -64,6 +66,7 @@ function userCan(string $permission, Model $ownable = null): bool
 
     // Check permission on ownable item
     $permissionService = app(PermissionService::class);
 
     // Check permission on ownable item
     $permissionService = app(PermissionService::class);
+
     return $permissionService->checkOwnableUserAccess($ownable, $permission);
 }
 
     return $permissionService->checkOwnableUserAccess($ownable, $permission);
 }
 
@@ -74,11 +77,13 @@ function userCan(string $permission, Model $ownable = null): bool
 function userCanOnAny(string $permission, string $entityClass = null): bool
 {
     $permissionService = app(PermissionService::class);
 function userCanOnAny(string $permission, string $entityClass = null): bool
 {
     $permissionService = app(PermissionService::class);
+
     return $permissionService->checkUserHasPermissionOnAnything($permission, $entityClass);
 }
 
 /**
  * Helper to access system settings.
     return $permissionService->checkUserHasPermissionOnAnything($permission, $entityClass);
 }
 
 /**
  * Helper to access system settings.
+ *
  * @return mixed|SettingService
  */
 function setting(string $key = null, $default = null)
  * @return mixed|SettingService
  */
 function setting(string $key = null, $default = null)
@@ -103,7 +108,7 @@ function theme_path(string $path = ''): string
         return '';
     }
 
         return '';
     }
 
-    return base_path('themes/' . $theme .($path ? DIRECTORY_SEPARATOR.$path : $path));
+    return base_path('themes/' . $theme . ($path ? DIRECTORY_SEPARATOR . $path : $path));
 }
 
 /**
 }
 
 /**
@@ -122,7 +127,7 @@ function icon(string $name, array $attrs = []): string
     ], $attrs);
     $attrString = ' ';
     foreach ($attrs as $attrName => $attr) {
     ], $attrs);
     $attrString = ' ';
     foreach ($attrs as $attrName => $attr) {
-        $attrString .=  $attrName . '="' . $attr . '" ';
+        $attrString .= $attrName . '="' . $attr . '" ';
     }
 
     $iconPath = resource_path('icons/' . $name . '.svg');
     }
 
     $iconPath = resource_path('icons/' . $name . '.svg');
@@ -130,11 +135,12 @@ function icon(string $name, array $attrs = []): string
 
     if ($themeIconPath && file_exists($themeIconPath)) {
         $iconPath = $themeIconPath;
 
     if ($themeIconPath && file_exists($themeIconPath)) {
         $iconPath = $themeIconPath;
-    } else if (!file_exists($iconPath)) {
+    } elseif (!file_exists($iconPath)) {
         return '';
     }
 
     $fileContents = file_get_contents($iconPath);
         return '';
     }
 
     $fileContents = file_get_contents($iconPath);
+
     return  str_replace('<svg', '<svg' . $attrString, $fileContents);
 }
 
     return  str_replace('<svg', '<svg' . $attrString, $fileContents);
 }
 
index 722f68a7c9fdbe758aaf0ebb8101ce4431f16922..dc06455402aa1fcbf88774f6b881848abec5752a 100644 (file)
 
 $factory->define(\BookStack\Auth\User::class, function ($faker) {
     $name = $faker->name;
 
 $factory->define(\BookStack\Auth\User::class, function ($faker) {
     $name = $faker->name;
+
     return [
     return [
-        'name' => $name,
-        'email' => $faker->email,
-        'slug' => \Illuminate\Support\Str::slug($name . '-' . \Illuminate\Support\Str::random(5)),
-        'password' => Str::random(10),
-        'remember_token' => Str::random(10),
-        'email_confirmed' => 1
+        'name'            => $name,
+        'email'           => $faker->email,
+        'slug'            => \Illuminate\Support\Str::slug($name . '-' . \Illuminate\Support\Str::random(5)),
+        'password'        => Str::random(10),
+        'remember_token'  => Str::random(10),
+        'email_confirmed' => 1,
     ];
 });
 
 $factory->define(\BookStack\Entities\Models\Bookshelf::class, function ($faker) {
     return [
     ];
 });
 
 $factory->define(\BookStack\Entities\Models\Bookshelf::class, function ($faker) {
     return [
-        'name' => $faker->sentence,
-        'slug' => Str::random(10),
-        'description' => $faker->paragraph
+        'name'        => $faker->sentence,
+        'slug'        => Str::random(10),
+        'description' => $faker->paragraph,
     ];
 });
 
 $factory->define(\BookStack\Entities\Models\Book::class, function ($faker) {
     return [
     ];
 });
 
 $factory->define(\BookStack\Entities\Models\Book::class, function ($faker) {
     return [
-        'name' => $faker->sentence,
-        'slug' => Str::random(10),
-        'description' => $faker->paragraph
+        'name'        => $faker->sentence,
+        'slug'        => Str::random(10),
+        'description' => $faker->paragraph,
     ];
 });
 
 $factory->define(\BookStack\Entities\Models\Chapter::class, function ($faker) {
     return [
     ];
 });
 
 $factory->define(\BookStack\Entities\Models\Chapter::class, function ($faker) {
     return [
-        'name' => $faker->sentence,
-        'slug' => Str::random(10),
-        'description' => $faker->paragraph
+        'name'        => $faker->sentence,
+        'slug'        => Str::random(10),
+        'description' => $faker->paragraph,
     ];
 });
 
 $factory->define(\BookStack\Entities\Models\Page::class, function ($faker) {
     $html = '<p>' . implode('</p>', $faker->paragraphs(5)) . '</p>';
     ];
 });
 
 $factory->define(\BookStack\Entities\Models\Page::class, function ($faker) {
     $html = '<p>' . implode('</p>', $faker->paragraphs(5)) . '</p>';
+
     return [
     return [
-        'name' => $faker->sentence,
-        'slug' => Str::random(10),
-        'html' => $html,
-        'text' => strip_tags($html),
-        'revision_count' => 1
+        'name'           => $faker->sentence,
+        'slug'           => Str::random(10),
+        'html'           => $html,
+        'text'           => strip_tags($html),
+        'revision_count' => 1,
     ];
 });
 
 $factory->define(\BookStack\Auth\Role::class, function ($faker) {
     return [
         'display_name' => $faker->sentence(3),
     ];
 });
 
 $factory->define(\BookStack\Auth\Role::class, function ($faker) {
     return [
         'display_name' => $faker->sentence(3),
-        'description' => $faker->sentence(10)
+        'description'  => $faker->sentence(10),
     ];
 });
 
 $factory->define(\BookStack\Actions\Tag::class, function ($faker) {
     return [
     ];
 });
 
 $factory->define(\BookStack\Actions\Tag::class, function ($faker) {
     return [
-        'name' => $faker->city,
-        'value' => $faker->sentence(3)
+        'name'  => $faker->city,
+        'value' => $faker->sentence(3),
     ];
 });
 
 $factory->define(\BookStack\Uploads\Image::class, function ($faker) {
     return [
     ];
 });
 
 $factory->define(\BookStack\Uploads\Image::class, function ($faker) {
     return [
-        'name' => $faker->slug . '.jpg',
-        'url' => $faker->url,
-        'path' => $faker->url,
-        'type' => 'gallery',
-        'uploaded_to' => 0
+        'name'        => $faker->slug . '.jpg',
+        'url'         => $faker->url,
+        'path'        => $faker->url,
+        'type'        => 'gallery',
+        'uploaded_to' => 0,
     ];
 });
 
     ];
 });
 
-$factory->define(\BookStack\Actions\Comment::class, function($faker) {
+$factory->define(\BookStack\Actions\Comment::class, function ($faker) {
     $text = $faker->paragraph(1);
     $text = $faker->paragraph(1);
-    $html = '<p>' . $text. '</p>';
+    $html = '<p>' . $text . '</p>';
+
     return [
     return [
-        'html' => $html,
-        'text' => $text,
-        'parent_id' => null
+        'html'      => $html,
+        'text'      => $text,
+        'parent_id' => null,
     ];
     ];
-});
\ No newline at end of file
+});
index 17e71de5f99d933aaafb7d6996cb337203a468da..10ae5222b41065ba8992d02a6f88268f5c374ceb 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 <?php
 
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
 
 class CreateUsersTable extends Migration
 {
 
 class CreateUsersTable extends Migration
 {
@@ -23,11 +23,11 @@ class CreateUsersTable extends Migration
 
         // Create the initial admin user
         DB::table('users')->insert([
 
         // Create the initial admin user
         DB::table('users')->insert([
-            'name' => 'Admin',
-            'email' => '[email protected]',
-            'password' => bcrypt('password'),
+            'name'       => 'Admin',
+            'email'      => '[email protected]',
+            'password'   => bcrypt('password'),
             'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
             'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
-            'updated_at' => \Carbon\Carbon::now()->toDateTimeString()
+            'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
         ]);
     }
 
         ]);
     }
 
index 00057f9cffa277455d2b42a54a220e2186294cc3..c647b562d4a4c067b0ed9037cac12cb91675df2b 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 <?php
 
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
 
 class CreatePasswordResetsTable extends Migration
 {
 
 class CreatePasswordResetsTable extends Migration
 {
index 51fb55c48547f86be43d0929b8d44d414c7e40af..966dcd6d9d714c673ea06e4c35d22fe697dc5709 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 <?php
 
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
 
 class CreateBooksTable extends Migration
 {
 
 class CreateBooksTable extends Migration
 {
index 7a1dcec0e88d7e1f616ff010cff1e3d7a36e5636..afba2b3ebd700b04cdd430c997218d8ff235004d 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 <?php
 
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
 
 class CreatePagesTable extends Migration
 {
 
 class CreatePagesTable extends Migration
 {
@@ -12,8 +12,6 @@ class CreatePagesTable extends Migration
      */
     public function up()
     {
      */
     public function up()
     {
-
-
         Schema::create('pages', function (Blueprint $table) {
             $table->increments('id');
             $table->integer('book_id');
         Schema::create('pages', function (Blueprint $table) {
             $table->increments('id');
             $table->integer('book_id');
index 61beaa7c39ad227f2dc1f3a9dd7fff8fbd0bb662..f54ab9e2a1b60ff3f5eb813f5f3668400ffaaffc 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 <?php
 
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
 
 class CreateImagesTable extends Migration
 {
 
 class CreateImagesTable extends Migration
 {
index 7974759f26e343f2c75051917ecbfa85324930cd..f557cced4eae5bf258668073632d6b78dec4c97b 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 <?php
 
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
 
 class CreateChaptersTable extends Migration
 {
 
 class CreateChaptersTable extends Migration
 {
index 7e402bda34027b199a97b790f9c93f8df72f642d..4dc8784623304f7af21b91da2f8b1d0c992ba780 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 <?php
 
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
 
 class AddUsersToEntities extends Migration
 {
 
 class AddUsersToEntities extends Migration
 {
index 9c06933092122cd5e48051c9ff294de7dc6ce30a..3540678e65f0e120b8acb30c6d5a5829cfdc2002 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 <?php
 
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
 
 class CreatePageRevisionsTable extends Migration
 {
 
 class CreatePageRevisionsTable extends Migration
 {
index f8d9064f248ca85496e2c78019be796c407c36b6..e45e11b53dad01932b3448415b49c31dc145bcd6 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 <?php
 
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
 
 class CreateActivitiesTable extends Migration
 {
 
 class CreateActivitiesTable extends Migration
 {
index 47a77e29f95a20e59c830b70ba98b260637fda31..c17f72e2fed387a10d2ba5a5dd294a4d325c3109 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 <?php
 
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
 
 /**
  * Much of this code has been taken from entrust,
 
 /**
  * Much of this code has been taken from entrust,
@@ -10,7 +10,6 @@ use Illuminate\Database\Migrations\Migration;
  * Full attribution of the database Schema shown below goes to the entrust project.
  *
  * @license MIT
  * Full attribution of the database Schema shown below goes to the entrust project.
  *
  * @license MIT
- * @package Zizaco\Entrust
  * @url https://github.com/Zizaco/entrust
  */
 class AddRolesAndPermissions extends Migration
  * @url https://github.com/Zizaco/entrust
  */
 class AddRolesAndPermissions extends Migration
@@ -66,45 +65,43 @@ class AddRolesAndPermissions extends Migration
             $table->primary(['permission_id', 'role_id']);
         });
 
             $table->primary(['permission_id', 'role_id']);
         });
 
-
         // Create default roles
         $adminId = DB::table('roles')->insertGetId([
         // Create default roles
         $adminId = DB::table('roles')->insertGetId([
-            'name' => 'admin',
+            'name'         => 'admin',
             'display_name' => 'Admin',
             'display_name' => 'Admin',
-            'description' => 'Administrator of the whole application',
-            'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
-            'updated_at' => \Carbon\Carbon::now()->toDateTimeString()
+            'description'  => 'Administrator of the whole application',
+            'created_at'   => \Carbon\Carbon::now()->toDateTimeString(),
+            'updated_at'   => \Carbon\Carbon::now()->toDateTimeString(),
         ]);
         $editorId = DB::table('roles')->insertGetId([
         ]);
         $editorId = DB::table('roles')->insertGetId([
-            'name' => 'editor',
+            'name'         => 'editor',
             'display_name' => 'Editor',
             'display_name' => 'Editor',
-            'description' => 'User can edit Books, Chapters & Pages',
-            'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
-            'updated_at' => \Carbon\Carbon::now()->toDateTimeString()
+            'description'  => 'User can edit Books, Chapters & Pages',
+            'created_at'   => \Carbon\Carbon::now()->toDateTimeString(),
+            'updated_at'   => \Carbon\Carbon::now()->toDateTimeString(),
         ]);
         $viewerId = DB::table('roles')->insertGetId([
         ]);
         $viewerId = DB::table('roles')->insertGetId([
-            'name' => 'viewer',
+            'name'         => 'viewer',
             'display_name' => 'Viewer',
             'display_name' => 'Viewer',
-            'description' => 'User can view books & their content behind authentication',
-            'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
-            'updated_at' => \Carbon\Carbon::now()->toDateTimeString()
+            'description'  => 'User can view books & their content behind authentication',
+            'created_at'   => \Carbon\Carbon::now()->toDateTimeString(),
+            'updated_at'   => \Carbon\Carbon::now()->toDateTimeString(),
         ]);
 
         ]);
 
-
         // Create default CRUD permissions and allocate to admins and editors
         $entities = ['Book', 'Page', 'Chapter', 'Image'];
         $ops = ['Create', 'Update', 'Delete'];
         foreach ($entities as $entity) {
             foreach ($ops as $op) {
                 $newPermId = DB::table('permissions')->insertGetId([
         // Create default CRUD permissions and allocate to admins and editors
         $entities = ['Book', 'Page', 'Chapter', 'Image'];
         $ops = ['Create', 'Update', 'Delete'];
         foreach ($entities as $entity) {
             foreach ($ops as $op) {
                 $newPermId = DB::table('permissions')->insertGetId([
-                    'name' => strtolower($entity) . '-' . strtolower($op),
+                    'name'         => strtolower($entity) . '-' . strtolower($op),
                     'display_name' => $op . ' ' . $entity . 's',
                     'display_name' => $op . ' ' . $entity . 's',
-                    'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
-                    'updated_at' => \Carbon\Carbon::now()->toDateTimeString()
+                    'created_at'   => \Carbon\Carbon::now()->toDateTimeString(),
+                    'updated_at'   => \Carbon\Carbon::now()->toDateTimeString(),
                 ]);
                 DB::table('permission_role')->insert([
                     ['permission_id' => $newPermId, 'role_id' => $adminId],
                 ]);
                 DB::table('permission_role')->insert([
                     ['permission_id' => $newPermId, 'role_id' => $adminId],
-                    ['permission_id' => $newPermId, 'role_id' => $editorId]
+                    ['permission_id' => $newPermId, 'role_id' => $editorId],
                 ]);
             }
         }
                 ]);
             }
         }
@@ -115,14 +112,14 @@ class AddRolesAndPermissions extends Migration
         foreach ($entities as $entity) {
             foreach ($ops as $op) {
                 $newPermId = DB::table('permissions')->insertGetId([
         foreach ($entities as $entity) {
             foreach ($ops as $op) {
                 $newPermId = DB::table('permissions')->insertGetId([
-                    'name' => strtolower($entity) . '-' . strtolower($op),
+                    'name'         => strtolower($entity) . '-' . strtolower($op),
                     'display_name' => $op . ' ' . $entity,
                     'display_name' => $op . ' ' . $entity,
-                    'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
-                    'updated_at' => \Carbon\Carbon::now()->toDateTimeString()
+                    'created_at'   => \Carbon\Carbon::now()->toDateTimeString(),
+                    'updated_at'   => \Carbon\Carbon::now()->toDateTimeString(),
                 ]);
                 DB::table('permission_role')->insert([
                     'permission_id' => $newPermId,
                 ]);
                 DB::table('permission_role')->insert([
                     'permission_id' => $newPermId,
-                    'role_id' => $adminId
+                    'role_id'       => $adminId,
                 ]);
             }
         }
                 ]);
             }
         }
@@ -133,10 +130,9 @@ class AddRolesAndPermissions extends Migration
         foreach ($users as $user) {
             DB::table('role_user')->insert([
                 'role_id' => $adminId,
         foreach ($users as $user) {
             DB::table('role_user')->insert([
                 'role_id' => $adminId,
-                'user_id' => $user->id
+                'user_id' => $user->id,
             ]);
         }
             ]);
         }
-
     }
 
     /**
     }
 
     /**
index 2cef3e6e76da2dea9cae853d3b25bf8e30500443..1b0a8c1c68eafdad43bff0229dd631afd0dbdf13 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 <?php
 
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
 
 class CreateSettingsTable extends Migration
 {
 
 class CreateSettingsTable extends Migration
 {
index 497f88adde27ede97761cdb800fa5d6225b1deb6..c28902a4482f347ab01b253c52c2c485c8326e46 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 <?php
 
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
 
 class AddSearchIndexes extends Migration
 {
 
 class AddSearchIndexes extends Migration
 {
@@ -34,22 +34,21 @@ class AddSearchIndexes extends Migration
         $chapters = $sm->listTableDetails('chapters');
 
         if ($pages->hasIndex('search')) {
         $chapters = $sm->listTableDetails('chapters');
 
         if ($pages->hasIndex('search')) {
-            Schema::table('pages', function(Blueprint $table) {
+            Schema::table('pages', function (Blueprint $table) {
                 $table->dropIndex('search');
             });
         }
 
         if ($books->hasIndex('search')) {
                 $table->dropIndex('search');
             });
         }
 
         if ($books->hasIndex('search')) {
-            Schema::table('books', function(Blueprint $table) {
+            Schema::table('books', function (Blueprint $table) {
                 $table->dropIndex('search');
             });
         }
 
         if ($chapters->hasIndex('search')) {
                 $table->dropIndex('search');
             });
         }
 
         if ($chapters->hasIndex('search')) {
-            Schema::table('chapters', function(Blueprint $table) {
+            Schema::table('chapters', function (Blueprint $table) {
                 $table->dropIndex('search');
             });
         }
                 $table->dropIndex('search');
             });
         }
-
     }
 }
     }
 }
index 700d7f90f5fcdbaf55c70c9f9a7b4a33c84ba95a..3eec96163d5b59c20600d2524197e2199dec6a27 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 <?php
 
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
 
 class CreateSocialAccountsTable extends Migration
 {
 
 class CreateSocialAccountsTable extends Migration
 {
index 105bda49e0865c17642c003db21e8227aa6d4c88..927ef89bce37fa670411dbbcaacb96c7acdcb990 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 <?php
 
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
 
 class AddEmailConfirmationTable extends Migration
 {
 
 class AddEmailConfirmationTable extends Migration
 {
index 90c3508648c2525c21f9cb05bda3ec5bf504b63e..4c267b08ef1b28716dd02e43bdc4fd34e8acb39a 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 <?php
 
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
 
 class CreateViewsTable extends Migration
 {
 
 class CreateViewsTable extends Migration
 {
index 30f978cad5bc8fe93e7f2ffbdfef2aa1bb35bade..09773b1f3b0174eb2d154df4da3226c399a2d5fc 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 <?php
 
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
 
 class AddEntityIndexes extends Migration
 {
 
 class AddEntityIndexes extends Migration
 {
index 2e884b55c6af0d72e419ef1c41c6a6c52bf4839b..a45310b33f3a8f30a7eaf7da1cd71a38399eef18 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 <?php
 
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
 
 class FulltextWeighting extends Migration
 {
 
 class FulltextWeighting extends Migration
 {
@@ -34,19 +34,19 @@ class FulltextWeighting extends Migration
         $chapters = $sm->listTableDetails('chapters');
 
         if ($pages->hasIndex('name_search')) {
         $chapters = $sm->listTableDetails('chapters');
 
         if ($pages->hasIndex('name_search')) {
-            Schema::table('pages', function(Blueprint $table) {
+            Schema::table('pages', function (Blueprint $table) {
                 $table->dropIndex('name_search');
             });
         }
 
         if ($books->hasIndex('name_search')) {
                 $table->dropIndex('name_search');
             });
         }
 
         if ($books->hasIndex('name_search')) {
-            Schema::table('books', function(Blueprint $table) {
+            Schema::table('books', function (Blueprint $table) {
                 $table->dropIndex('name_search');
             });
         }
 
         if ($chapters->hasIndex('name_search')) {
                 $table->dropIndex('name_search');
             });
         }
 
         if ($chapters->hasIndex('name_search')) {
-            Schema::table('chapters', function(Blueprint $table) {
+            Schema::table('chapters', function (Blueprint $table) {
                 $table->dropIndex('name_search');
             });
         }
                 $table->dropIndex('name_search');
             });
         }
index 515bc9d8df7e86fcfd5e5640dbe2b6afbd77f5c3..3ebb10bb9796ce681cc0919ffac23d3615ff4afd 100644 (file)
@@ -1,8 +1,8 @@
 <?php
 
 use BookStack\Uploads\Image;
 <?php
 
 use BookStack\Uploads\Image;
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
 
 class AddImageUploadTypes extends Migration
 {
 
 class AddImageUploadTypes extends Migration
 {
@@ -18,7 +18,7 @@ class AddImageUploadTypes extends Migration
             $table->string('type')->index();
         });
 
             $table->string('type')->index();
         });
 
-        Image::all()->each(function($image) {
+        Image::all()->each(function ($image) {
             $image->path = $image->url;
             $image->type = 'gallery';
             $image->save();
             $image->path = $image->url;
             $image->type = 'gallery';
             $image->save();
@@ -36,6 +36,5 @@ class AddImageUploadTypes extends Migration
             $table->dropColumn('type');
             $table->dropColumn('path');
         });
             $table->dropColumn('type');
             $table->dropColumn('path');
         });
-
     }
 }
     }
 }
index 47cb027fad8aa33f54b57fd5976d1037a16ed83a..083f0a5bc72e85ed203e43610938ad8ddb7ecce7 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 <?php
 
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
 
 class AddUserAvatars extends Migration
 {
 
 class AddUserAvatars extends Migration
 {
index b7663054c2842bf20847846b46a9083f4776883f..002b45aeceedb14ae57caa1aed360bbb5695b847 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 <?php
 
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
 
 class AddExternalAuthToUsers extends Migration
 {
 
 class AddExternalAuthToUsers extends Migration
 {
@@ -28,4 +28,4 @@ class AddExternalAuthToUsers extends Migration
             $table->dropColumn('external_auth_id');
         });
     }
             $table->dropColumn('external_auth_id');
         });
     }
-}
\ No newline at end of file
+}
index 0be6c794017422ff77e964143bb85a78f5de1d47..7139178e8871026d14697bbbe447279a22b54fc8 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 <?php
 
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
 
 class AddSlugToRevisions extends Migration
 {
 
 class AddSlugToRevisions extends Migration
 {
index af6bb12320774d85467f2a910f69d786fdae1bc5..1bab5a873b1a0868cb48add0b47acffac969522d 100644 (file)
@@ -1,6 +1,5 @@
 <?php
 
 <?php
 
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 
 class UpdatePermissionsAndRoles extends Migration
 use Illuminate\Database\Migrations\Migration;
 
 class UpdatePermissionsAndRoles extends Migration
@@ -21,22 +20,22 @@ class UpdatePermissionsAndRoles extends Migration
 
         // Create & attach new admin permissions
         $permissionsToCreate = [
 
         // Create & attach new admin permissions
         $permissionsToCreate = [
-            'settings-manage' => 'Manage Settings',
-            'users-manage' => 'Manage Users',
-            'user-roles-manage' => 'Manage Roles & Permissions',
+            'settings-manage'         => 'Manage Settings',
+            'users-manage'            => 'Manage Users',
+            'user-roles-manage'       => 'Manage Roles & Permissions',
             'restrictions-manage-all' => 'Manage All Entity Permissions',
             'restrictions-manage-all' => 'Manage All Entity Permissions',
-            'restrictions-manage-own' => 'Manage Entity Permissions On Own Content'
+            'restrictions-manage-own' => 'Manage Entity Permissions On Own Content',
         ];
         foreach ($permissionsToCreate as $name => $displayName) {
             $permissionId = DB::table('permissions')->insertGetId([
         ];
         foreach ($permissionsToCreate as $name => $displayName) {
             $permissionId = DB::table('permissions')->insertGetId([
-                'name' => $name,
+                'name'         => $name,
                 'display_name' => $displayName,
                 'display_name' => $displayName,
-                'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
-                'updated_at' => \Carbon\Carbon::now()->toDateTimeString()
+                'created_at'   => \Carbon\Carbon::now()->toDateTimeString(),
+                'updated_at'   => \Carbon\Carbon::now()->toDateTimeString(),
             ]);
             DB::table('permission_role')->insert([
             ]);
             DB::table('permission_role')->insert([
-                'role_id' => $adminRoleId,
-                'permission_id' => $permissionId
+                'role_id'       => $adminRoleId,
+                'permission_id' => $permissionId,
             ]);
         }
 
             ]);
         }
 
@@ -46,24 +45,23 @@ class UpdatePermissionsAndRoles extends Migration
         foreach ($entities as $entity) {
             foreach ($ops as $op) {
                 $permissionId = DB::table('permissions')->insertGetId([
         foreach ($entities as $entity) {
             foreach ($ops as $op) {
                 $permissionId = DB::table('permissions')->insertGetId([
-                    'name' => strtolower($entity) . '-' . strtolower(str_replace(' ', '-', $op)),
+                    'name'         => strtolower($entity) . '-' . strtolower(str_replace(' ', '-', $op)),
                     'display_name' => $op . ' ' . $entity . 's',
                     'display_name' => $op . ' ' . $entity . 's',
-                    'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
-                    'updated_at' => \Carbon\Carbon::now()->toDateTimeString()
+                    'created_at'   => \Carbon\Carbon::now()->toDateTimeString(),
+                    'updated_at'   => \Carbon\Carbon::now()->toDateTimeString(),
                 ]);
                 DB::table('permission_role')->insert([
                 ]);
                 DB::table('permission_role')->insert([
-                    'role_id' => $adminRoleId,
-                    'permission_id' => $permissionId
+                    'role_id'       => $adminRoleId,
+                    'permission_id' => $permissionId,
                 ]);
                 if ($editorRole !== null) {
                     DB::table('permission_role')->insert([
                 ]);
                 if ($editorRole !== null) {
                     DB::table('permission_role')->insert([
-                        'role_id' => $editorRole->id,
-                        'permission_id' => $permissionId
+                        'role_id'       => $editorRole->id,
+                        'permission_id' => $permissionId,
                     ]);
                 }
             }
         }
                     ]);
                 }
             }
         }
-
     }
 
     /**
     }
 
     /**
@@ -85,14 +83,14 @@ class UpdatePermissionsAndRoles extends Migration
         foreach ($entities as $entity) {
             foreach ($ops as $op) {
                 $permissionId = DB::table('permissions')->insertGetId([
         foreach ($entities as $entity) {
             foreach ($ops as $op) {
                 $permissionId = DB::table('permissions')->insertGetId([
-                    'name' => strtolower($entity) . '-' . strtolower($op),
+                    'name'         => strtolower($entity) . '-' . strtolower($op),
                     'display_name' => $op . ' ' . $entity . 's',
                     'display_name' => $op . ' ' . $entity . 's',
-                    'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
-                    'updated_at' => \Carbon\Carbon::now()->toDateTimeString()
+                    'created_at'   => \Carbon\Carbon::now()->toDateTimeString(),
+                    'updated_at'   => \Carbon\Carbon::now()->toDateTimeString(),
                 ]);
                 DB::table('permission_role')->insert([
                 ]);
                 DB::table('permission_role')->insert([
-                    'role_id' => $adminRoleId,
-                    'permission_id' => $permissionId
+                    'role_id'       => $adminRoleId,
+                    'permission_id' => $permissionId,
                 ]);
             }
         }
                 ]);
             }
         }
@@ -103,14 +101,14 @@ class UpdatePermissionsAndRoles extends Migration
         foreach ($entities as $entity) {
             foreach ($ops as $op) {
                 $permissionId = DB::table('permissions')->insertGetId([
         foreach ($entities as $entity) {
             foreach ($ops as $op) {
                 $permissionId = DB::table('permissions')->insertGetId([
-                    'name' => strtolower($entity) . '-' . strtolower($op),
+                    'name'         => strtolower($entity) . '-' . strtolower($op),
                     'display_name' => $op . ' ' . $entity,
                     'display_name' => $op . ' ' . $entity,
-                    'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
-                    'updated_at' => \Carbon\Carbon::now()->toDateTimeString()
+                    'created_at'   => \Carbon\Carbon::now()->toDateTimeString(),
+                    'updated_at'   => \Carbon\Carbon::now()->toDateTimeString(),
                 ]);
                 DB::table('permission_role')->insert([
                 ]);
                 DB::table('permission_role')->insert([
-                    'role_id' => $adminRoleId,
-                    'permission_id' => $permissionId
+                    'role_id'       => $adminRoleId,
+                    'permission_id' => $permissionId,
                 ]);
             }
         }
                 ]);
             }
         }
index 5df2353a24e046175b743555c0074762413195d8..67464095260676e42cad648574fba5c10227acad 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 <?php
 
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
 
 class AddEntityAccessControls extends Migration
 {
 
 class AddEntityAccessControls extends Migration
 {
@@ -32,7 +32,7 @@ class AddEntityAccessControls extends Migration
             $table->index('restricted');
         });
 
             $table->index('restricted');
         });
 
-        Schema::create('restrictions', function(Blueprint $table) {
+        Schema::create('restrictions', function (Blueprint $table) {
             $table->increments('id');
             $table->integer('restrictable_id');
             $table->string('restrictable_type');
             $table->increments('id');
             $table->integer('restrictable_id');
             $table->string('restrictable_type');
@@ -63,7 +63,6 @@ class AddEntityAccessControls extends Migration
             $table->dropColumn('restricted');
         });
 
             $table->dropColumn('restricted');
         });
 
-
         Schema::table('pages', function (Blueprint $table) {
             $table->dropColumn('restricted');
         });
         Schema::table('pages', function (Blueprint $table) {
             $table->dropColumn('restricted');
         });
index e39c77d186a46659e53b155451c3ad7d2a4e6973..d633fb949e9f7949588979cde7b2b11fe63731f4 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 <?php
 
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
 
 class AddPageRevisionTypes extends Migration
 {
 
 class AddPageRevisionTypes extends Migration
 {
index 794ee6a5fa3bc0749cdcf534a01313cb2cfffe41..2cc296d056b3ae45facd782edb38fb9c8beb94df 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 <?php
 
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
 
 class AddPageDrafts extends Migration
 {
 
 class AddPageDrafts extends Migration
 {
@@ -12,7 +12,7 @@ class AddPageDrafts extends Migration
      */
     public function up()
     {
      */
     public function up()
     {
-        Schema::table('pages', function(Blueprint $table) {
+        Schema::table('pages', function (Blueprint $table) {
             $table->boolean('draft')->default(false);
             $table->index('draft');
         });
             $table->boolean('draft')->default(false);
             $table->index('draft');
         });
index 2daa32cfbaadcdd1e3338dd7c787ab7d65dd0fe4..27a198dc969bf0127239d2fe84d45643e590066a 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 <?php
 
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
 
 class AddMarkdownSupport extends Migration
 {
 
 class AddMarkdownSupport extends Migration
 {
index 9bdf4397fd1a4f337d76cd0a8661c22a8e5b63b1..48a913f8201c4b9a706935700daf3cdbabe2578e 100644 (file)
@@ -1,6 +1,5 @@
 <?php
 
 <?php
 
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 
 class AddViewPermissionsToRoles extends Migration
 use Illuminate\Database\Migrations\Migration;
 
 class AddViewPermissionsToRoles extends Migration
@@ -20,16 +19,16 @@ class AddViewPermissionsToRoles extends Migration
         foreach ($entities as $entity) {
             foreach ($ops as $op) {
                 $permId = DB::table('permissions')->insertGetId([
         foreach ($entities as $entity) {
             foreach ($ops as $op) {
                 $permId = DB::table('permissions')->insertGetId([
-                    'name' => strtolower($entity) . '-' . strtolower(str_replace(' ', '-', $op)),
+                    'name'         => strtolower($entity) . '-' . strtolower(str_replace(' ', '-', $op)),
                     'display_name' => $op . ' ' . $entity . 's',
                     'display_name' => $op . ' ' . $entity . 's',
-                    'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
-                    'updated_at' => \Carbon\Carbon::now()->toDateTimeString()
+                    'created_at'   => \Carbon\Carbon::now()->toDateTimeString(),
+                    'updated_at'   => \Carbon\Carbon::now()->toDateTimeString(),
                 ]);
                 // Assign view permission to all current roles
                 foreach ($currentRoles as $role) {
                     DB::table('permission_role')->insert([
                 ]);
                 // Assign view permission to all current roles
                 foreach ($currentRoles as $role) {
                     DB::table('permission_role')->insert([
-                        'role_id' => $role->id,
-                        'permission_id' => $permId
+                        'role_id'       => $role->id,
+                        'permission_id' => $permId,
                     ]);
                 }
             }
                     ]);
                 }
             }
index ce11f7b88efb19174f5cfa23783f62afc3a68244..5b43c7d549de1265fd5fee0eea91f4fd5b499ebd 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 <?php
 
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
 
 class CreateJointPermissionsTable extends Migration
 {
 
 class CreateJointPermissionsTable extends Migration
 {
@@ -42,13 +42,13 @@ class CreateJointPermissionsTable extends Migration
 
         // Create the new public role
         $publicRoleData = [
 
         // Create the new public role
         $publicRoleData = [
-            'name' => 'public',
+            'name'         => 'public',
             'display_name' => 'Public',
             'display_name' => 'Public',
-            'description' => 'The role given to public visitors if allowed',
-            'system_name' => 'public',
-            'hidden' => true,
-            'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
-            'updated_at' => \Carbon\Carbon::now()->toDateTimeString()
+            'description'  => 'The role given to public visitors if allowed',
+            'system_name'  => 'public',
+            'hidden'       => true,
+            'created_at'   => \Carbon\Carbon::now()->toDateTimeString(),
+            'updated_at'   => \Carbon\Carbon::now()->toDateTimeString(),
         ];
 
         // Ensure unique name
         ];
 
         // Ensure unique name
@@ -67,7 +67,7 @@ class CreateJointPermissionsTable extends Migration
                 // Assign view permission to public
                 DB::table('permission_role')->insert([
                     'permission_id' => $permission->id,
                 // Assign view permission to public
                 DB::table('permission_role')->insert([
                     'permission_id' => $permission->id,
-                    'role_id' => $publicRoleId
+                    'role_id'       => $publicRoleId,
                 ]);
             }
         }
                 ]);
             }
         }
index 55eed60606fef83bd9e89011bba4db2ac73e187e..1c691f56103efdcdb355973d1ab27609a495dd76 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 <?php
 
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
 
 class CreateTagsTable extends Migration
 {
 
 class CreateTagsTable extends Migration
 {
index c618877ef57cff8f14811807473e217feef424f2..904e8a48e4fd4e88b9a66f26d9101ef082a18d61 100644 (file)
@@ -1,6 +1,5 @@
 <?php
 
 <?php
 
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 
 class AddSummaryToPageRevisions extends Migration
 use Illuminate\Database\Migrations\Migration;
 
 class AddSummaryToPageRevisions extends Migration
index f666cad2c6efd0546ec151a961869f46ab8dc181..f5f1aa26b98a5d6570fa6b56ca6ff79a285ddf77 100644 (file)
@@ -1,8 +1,8 @@
 <?php
 
 <?php
 
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
 
 class RemoveHiddenRoles extends Migration
 {
 
 class RemoveHiddenRoles extends Migration
 {
@@ -14,32 +14,32 @@ class RemoveHiddenRoles extends Migration
     public function up()
     {
         // Remove the hidden property from roles
     public function up()
     {
         // Remove the hidden property from roles
-        Schema::table('roles', function(Blueprint $table) {
+        Schema::table('roles', function (Blueprint $table) {
             $table->dropColumn('hidden');
         });
 
         // Add column to mark system users
             $table->dropColumn('hidden');
         });
 
         // Add column to mark system users
-        Schema::table('users', function(Blueprint $table) {
+        Schema::table('users', function (Blueprint $table) {
             $table->string('system_name')->nullable()->index();
         });
 
         // Insert our new public system user.
         $publicUserId = DB::table('users')->insertGetId([
             $table->string('system_name')->nullable()->index();
         });
 
         // Insert our new public system user.
         $publicUserId = DB::table('users')->insertGetId([
-            'email' => '[email protected]',
-            'name' => 'Guest',
-            'system_name' => 'public',
+            'email'           => '[email protected]',
+            'name'            => 'Guest',
+            'system_name'     => 'public',
             'email_confirmed' => true,
             'email_confirmed' => true,
-            'created_at' => \Carbon\Carbon::now(),
-            'updated_at' => \Carbon\Carbon::now(),
+            'created_at'      => \Carbon\Carbon::now(),
+            'updated_at'      => \Carbon\Carbon::now(),
         ]);
         ]);
-        
+
         // Get the public role
         $publicRole = DB::table('roles')->where('system_name', '=', 'public')->first();
 
         // Connect the new public user to the public role
         DB::table('role_user')->insert([
             'user_id' => $publicUserId,
         // Get the public role
         $publicRole = DB::table('roles')->where('system_name', '=', 'public')->first();
 
         // Connect the new public user to the public role
         DB::table('role_user')->insert([
             'user_id' => $publicUserId,
-            'role_id' => $publicRole->id
+            'role_id' => $publicRole->id,
         ]);
     }
 
         ]);
     }
 
@@ -50,14 +50,14 @@ class RemoveHiddenRoles extends Migration
      */
     public function down()
     {
      */
     public function down()
     {
-        Schema::table('roles', function(Blueprint $table) {
+        Schema::table('roles', function (Blueprint $table) {
             $table->boolean('hidden')->default(false);
             $table->index('hidden');
         });
 
         DB::table('users')->where('system_name', '=', 'public')->delete();
 
             $table->boolean('hidden')->default(false);
             $table->index('hidden');
         });
 
         DB::table('users')->where('system_name', '=', 'public')->delete();
 
-        Schema::table('users', function(Blueprint $table) {
+        Schema::table('users', function (Blueprint $table) {
             $table->dropColumn('system_name');
         });
 
             $table->dropColumn('system_name');
         });
 
index 627c237c4f0dee81e97964965cca7e4603d6d65f..9c5422f08990c32863e3c34c7ecc05bb1ecdf30d 100644 (file)
@@ -1,8 +1,8 @@
 <?php
 
 <?php
 
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
 
 class CreateAttachmentsTable extends Migration
 {
 
 class CreateAttachmentsTable extends Migration
 {
@@ -38,17 +38,16 @@ class CreateAttachmentsTable extends Migration
         $entity = 'Attachment';
         foreach ($ops as $op) {
             $permissionId = DB::table('role_permissions')->insertGetId([
         $entity = 'Attachment';
         foreach ($ops as $op) {
             $permissionId = DB::table('role_permissions')->insertGetId([
-                'name' => strtolower($entity) . '-' . strtolower(str_replace(' ', '-', $op)),
+                'name'         => strtolower($entity) . '-' . strtolower(str_replace(' ', '-', $op)),
                 'display_name' => $op . ' ' . $entity . 's',
                 'display_name' => $op . ' ' . $entity . 's',
-                'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
-                'updated_at' => \Carbon\Carbon::now()->toDateTimeString()
+                'created_at'   => \Carbon\Carbon::now()->toDateTimeString(),
+                'updated_at'   => \Carbon\Carbon::now()->toDateTimeString(),
             ]);
             DB::table('permission_role')->insert([
             ]);
             DB::table('permission_role')->insert([
-                'role_id' => $adminRoleId,
-                'permission_id' => $permissionId
+                'role_id'       => $adminRoleId,
+                'permission_id' => $permissionId,
             ]);
         }
             ]);
         }
-
     }
 
     /**
     }
 
     /**
index 1f7761c2b626a72c353e8fab809f573bc087037e..f77d4a4eba0ccd2da423895f27a29a3dc3c29920 100644 (file)
@@ -1,8 +1,8 @@
 <?php
 
 <?php
 
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
 
 class CreateCacheTable extends Migration
 {
 
 class CreateCacheTable extends Migration
 {
index 56e76d6df6e94c4755f1584614d6db6459ef6800..b4d154fda42197624b49468abb934d2f39f47f14 100644 (file)
@@ -1,8 +1,8 @@
 <?php
 
 <?php
 
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
 
 class CreateSessionsTable extends Migration
 {
 
 class CreateSessionsTable extends Migration
 {
index a066fb1309445e378f7880457bfd57fceac28498..0f8a3dd34dced1c827a99227f04712ce4823e2f4 100644 (file)
@@ -1,8 +1,8 @@
 <?php
 
 <?php
 
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
 
 class CreateSearchIndexTable extends Migration
 {
 
 class CreateSearchIndexTable extends Migration
 {
@@ -32,21 +32,21 @@ class CreateSearchIndexTable extends Migration
         $chapters = $sm->listTableDetails('chapters');
 
         if ($pages->hasIndex('search')) {
         $chapters = $sm->listTableDetails('chapters');
 
         if ($pages->hasIndex('search')) {
-            Schema::table('pages', function(Blueprint $table) {
+            Schema::table('pages', function (Blueprint $table) {
                 $table->dropIndex('search');
                 $table->dropIndex('name_search');
             });
         }
 
         if ($books->hasIndex('search')) {
                 $table->dropIndex('search');
                 $table->dropIndex('name_search');
             });
         }
 
         if ($books->hasIndex('search')) {
-            Schema::table('books', function(Blueprint $table) {
+            Schema::table('books', function (Blueprint $table) {
                 $table->dropIndex('search');
                 $table->dropIndex('name_search');
             });
         }
 
         if ($chapters->hasIndex('search')) {
                 $table->dropIndex('search');
                 $table->dropIndex('name_search');
             });
         }
 
         if ($chapters->hasIndex('search')) {
-            Schema::table('chapters', function(Blueprint $table) {
+            Schema::table('chapters', function (Blueprint $table) {
                 $table->dropIndex('search');
                 $table->dropIndex('name_search');
             });
                 $table->dropIndex('search');
                 $table->dropIndex('name_search');
             });
@@ -70,7 +70,7 @@ class CreateSearchIndexTable extends Migration
 //        DB::statement("ALTER TABLE {$prefix}pages ADD FULLTEXT name_search(name)");
 //        DB::statement("ALTER TABLE {$prefix}books ADD FULLTEXT name_search(name)");
 //        DB::statement("ALTER TABLE {$prefix}chapters ADD FULLTEXT name_search(name)");
 //        DB::statement("ALTER TABLE {$prefix}pages ADD FULLTEXT name_search(name)");
 //        DB::statement("ALTER TABLE {$prefix}books ADD FULLTEXT name_search(name)");
 //        DB::statement("ALTER TABLE {$prefix}chapters ADD FULLTEXT name_search(name)");
-        
+
         Schema::dropIfExists('search_terms');
     }
 }
         Schema::dropIfExists('search_terms');
     }
 }
index 3583f36f3a9d73fe7c59ac6363c3757c7715edd9..8c6d75e778c9ad02fa0c2c78818d188eb89b1640 100644 (file)
@@ -1,8 +1,8 @@
 <?php
 
 <?php
 
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
 
 class AddRevisionCounts extends Migration
 {
 
 class AddRevisionCounts extends Migration
 {
index 1d69d1fa782ce47b80130cf35670418023755741..7e64d347b4cdb11151a74d1e9ce11a71d0359bd2 100644 (file)
@@ -1,8 +1,8 @@
 <?php
 
 <?php
 
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
 
 class CreateCommentsTable extends Migration
 {
 
 class CreateCommentsTable extends Migration
 {
@@ -35,17 +35,16 @@ class CreateCommentsTable extends Migration
             $entity = 'Comment';
             foreach ($ops as $op) {
                 $permissionId = DB::table('role_permissions')->insertGetId([
             $entity = 'Comment';
             foreach ($ops as $op) {
                 $permissionId = DB::table('role_permissions')->insertGetId([
-                    'name' => strtolower($entity) . '-' . strtolower(str_replace(' ', '-', $op)),
+                    'name'         => strtolower($entity) . '-' . strtolower(str_replace(' ', '-', $op)),
                     'display_name' => $op . ' ' . $entity . 's',
                     'display_name' => $op . ' ' . $entity . 's',
-                    'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
-                    'updated_at' => \Carbon\Carbon::now()->toDateTimeString()
+                    'created_at'   => \Carbon\Carbon::now()->toDateTimeString(),
+                    'updated_at'   => \Carbon\Carbon::now()->toDateTimeString(),
                 ]);
                 DB::table('permission_role')->insert([
                 ]);
                 DB::table('permission_role')->insert([
-                    'role_id' => $adminRoleId,
-                    'permission_id' => $permissionId
+                    'role_id'       => $adminRoleId,
+                    'permission_id' => $permissionId,
                 ]);
             }
                 ]);
             }
-
         });
     }
 
         });
     }
 
index 6f99329243a73a8c18cee8b48e667fce15f4b87f..7dd92433801b30cb30fcf88cf3139ee7325e5220 100644 (file)
@@ -1,8 +1,8 @@
 <?php
 
 <?php
 
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
 
 class AddCoverImageDisplay extends Migration
 {
 
 class AddCoverImageDisplay extends Migration
 {
index 0778e8762dd245e1855c675bf48e4de74bad1621..85e10a74b7e77ec5be3ee7bf439c3b76ead0d6bb 100644 (file)
@@ -1,8 +1,8 @@
 <?php
 
 <?php
 
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
 
 class AddRoleExternalAuthId extends Migration
 {
 
 class AddRoleExternalAuthId extends Migration
 {
index 488c6196830c4549b43b8a3d9fb4517eef7704fc..04f46ce509f4122ee2e2fa1ab2cef8d484663713 100644 (file)
@@ -1,8 +1,8 @@
 <?php
 
 <?php
 
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
 
 class CreateBookshelvesTable extends Migration
 {
 
 class CreateBookshelvesTable extends Migration
 {
@@ -23,7 +23,8 @@ class CreateBookshelvesTable extends Migration
             DB::statement("ALTER TABLE {$prefix}pages ENGINE = InnoDB;");
             DB::statement("ALTER TABLE {$prefix}chapters ENGINE = InnoDB;");
             DB::statement("ALTER TABLE {$prefix}books ENGINE = InnoDB;");
             DB::statement("ALTER TABLE {$prefix}pages ENGINE = InnoDB;");
             DB::statement("ALTER TABLE {$prefix}chapters ENGINE = InnoDB;");
             DB::statement("ALTER TABLE {$prefix}books ENGINE = InnoDB;");
-        } catch (Exception $exception) {}
+        } catch (Exception $exception) {
+        }
 
         // Here we have table drops before the creations due to upgrade issues
         // people were having due to the bookshelves_books table creation failing.
 
         // Here we have table drops before the creations due to upgrade issues
         // people were having due to the bookshelves_books table creation failing.
@@ -79,18 +80,18 @@ class CreateBookshelvesTable extends Migration
                 ->where('role_permissions.name', '=', 'book-' . $dbOpName)->get(['roles.id'])->pluck('id');
 
             $permId = DB::table('role_permissions')->insertGetId([
                 ->where('role_permissions.name', '=', 'book-' . $dbOpName)->get(['roles.id'])->pluck('id');
 
             $permId = DB::table('role_permissions')->insertGetId([
-                'name' => 'bookshelf-' . $dbOpName,
+                'name'         => 'bookshelf-' . $dbOpName,
                 'display_name' => $op . ' ' . 'BookShelves',
                 'display_name' => $op . ' ' . 'BookShelves',
-                'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
-                'updated_at' => \Carbon\Carbon::now()->toDateTimeString()
+                'created_at'   => \Carbon\Carbon::now()->toDateTimeString(),
+                'updated_at'   => \Carbon\Carbon::now()->toDateTimeString(),
             ]);
 
             ]);
 
-            $rowsToInsert = $roleIdsWithBookPermission->filter(function($roleId) {
+            $rowsToInsert = $roleIdsWithBookPermission->filter(function ($roleId) {
                 return !is_null($roleId);
                 return !is_null($roleId);
-            })->map(function($roleId) use ($permId) {
+            })->map(function ($roleId) use ($permId) {
                 return [
                 return [
-                    'role_id' => $roleId,
-                    'permission_id' => $permId
+                    'role_id'       => $roleId,
+                    'permission_id' => $permId,
                 ];
             })->toArray();
 
                 ];
             })->toArray();
 
@@ -107,7 +108,7 @@ class CreateBookshelvesTable extends Migration
     public function down()
     {
         // Drop created permissions
     public function down()
     {
         // Drop created permissions
-        $ops = ['bookshelf-create-all','bookshelf-create-own','bookshelf-delete-all','bookshelf-delete-own','bookshelf-update-all','bookshelf-update-own','bookshelf-view-all','bookshelf-view-own'];
+        $ops = ['bookshelf-create-all', 'bookshelf-create-own', 'bookshelf-delete-all', 'bookshelf-delete-own', 'bookshelf-update-all', 'bookshelf-update-own', 'bookshelf-view-all', 'bookshelf-view-own'];
 
         $permissionIds = DB::table('role_permissions')->whereIn('name', $ops)
             ->get(['id'])->pluck('id')->toArray();
 
         $permissionIds = DB::table('role_permissions')->whereIn('name', $ops)
             ->get(['id'])->pluck('id')->toArray();
index 3fcc6822751ea926985fbe9573a5a688ba71b7f0..ae26985ed8d5e111ca9e027c657f7e1f75fdc47a 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 
 use Carbon\Carbon;
 <?php
 
 use Carbon\Carbon;
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
 
 class AddTemplateSupport extends Migration
 {
 
 class AddTemplateSupport extends Migration
 {
@@ -22,14 +22,14 @@ class AddTemplateSupport extends Migration
         // Create new templates-manage permission and assign to admin role
         $adminRoleId = DB::table('roles')->where('system_name', '=', 'admin')->first()->id;
         $permissionId = DB::table('role_permissions')->insertGetId([
         // Create new templates-manage permission and assign to admin role
         $adminRoleId = DB::table('roles')->where('system_name', '=', 'admin')->first()->id;
         $permissionId = DB::table('role_permissions')->insertGetId([
-            'name' => 'templates-manage',
+            'name'         => 'templates-manage',
             'display_name' => 'Manage Page Templates',
             'display_name' => 'Manage Page Templates',
-            'created_at' => Carbon::now()->toDateTimeString(),
-            'updated_at' => Carbon::now()->toDateTimeString()
+            'created_at'   => Carbon::now()->toDateTimeString(),
+            'updated_at'   => Carbon::now()->toDateTimeString(),
         ]);
         DB::table('permission_role')->insert([
         ]);
         DB::table('permission_role')->insert([
-            'role_id' => $adminRoleId,
-            'permission_id' => $permissionId
+            'role_id'       => $adminRoleId,
+            'permission_id' => $permissionId,
         ]);
     }
 
         ]);
     }
 
index 23bd6988c879adad912da4bfb8a5c4781fcc16a8..6321b8187e4cb797ecfa04409c8d3db077e023f6 100644 (file)
@@ -1,8 +1,8 @@
 <?php
 
 <?php
 
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
 
 class AddUserInvitesTable extends Migration
 {
 
 class AddUserInvitesTable extends Migration
 {
index eff88247fab066fb9f43b118e2ba8ba752ed1231..4093833794ee30ddc98684e7565ddb5580c57fec 100644 (file)
@@ -16,7 +16,7 @@ class AddApiAuth extends Migration
     {
 
         // Add API tokens table
     {
 
         // Add API tokens table
-        Schema::create('api_tokens', function(Blueprint $table) {
+        Schema::create('api_tokens', function (Blueprint $table) {
             $table->increments('id');
             $table->string('name');
             $table->string('token_id')->unique();
             $table->increments('id');
             $table->string('name');
             $table->string('token_id')->unique();
@@ -29,14 +29,14 @@ class AddApiAuth extends Migration
         // Add access-api permission
         $adminRoleId = DB::table('roles')->where('system_name', '=', 'admin')->first()->id;
         $permissionId = DB::table('role_permissions')->insertGetId([
         // Add access-api permission
         $adminRoleId = DB::table('roles')->where('system_name', '=', 'admin')->first()->id;
         $permissionId = DB::table('role_permissions')->insertGetId([
-            'name' => 'access-api',
+            'name'         => 'access-api',
             'display_name' => 'Access system API',
             'display_name' => 'Access system API',
-            'created_at' => Carbon::now()->toDateTimeString(),
-            'updated_at' => Carbon::now()->toDateTimeString()
+            'created_at'   => Carbon::now()->toDateTimeString(),
+            'updated_at'   => Carbon::now()->toDateTimeString(),
         ]);
         DB::table('permission_role')->insert([
         ]);
         DB::table('permission_role')->insert([
-            'role_id' => $adminRoleId,
-            'permission_id' => $permissionId
+            'role_id'       => $adminRoleId,
+            'permission_id' => $permissionId,
         ]);
     }
 
         ]);
     }
 
index f3cafb7323280eb2aeb58d3dfd7f9bd3df1881c1..8f99817d267518f341f316e3bab3f9b7568dba18 100644 (file)
@@ -2,8 +2,8 @@
 
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Schema\Blueprint;
 
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Support\Facades\Schema;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Schema;
 
 class RemoveRoleNameField extends Migration
 {
 
 class RemoveRoleNameField extends Migration
 {
@@ -31,7 +31,7 @@ class RemoveRoleNameField extends Migration
         });
 
         DB::table('roles')->update([
         });
 
         DB::table('roles')->update([
-            "name" => DB::raw("lower(replace(`display_name`, ' ', '-'))"),
+            'name' => DB::raw("lower(replace(`display_name`, ' ', '-'))"),
         ]);
     }
 }
         ]);
     }
 }
index 7d6a270a919c911213d6e0292c016e8f7ee6bad5..28355265b6b5258ecbe2dbe28cde82aa7365d8dc 100644 (file)
@@ -13,7 +13,7 @@ class AddActivityIndexes extends Migration
      */
     public function up()
     {
      */
     public function up()
     {
-        Schema::table('activities', function(Blueprint $table) {
+        Schema::table('activities', function (Blueprint $table) {
             $table->index('key');
             $table->index('created_at');
         });
             $table->index('key');
             $table->index('created_at');
         });
@@ -26,7 +26,7 @@ class AddActivityIndexes extends Migration
      */
     public function down()
     {
      */
     public function down()
     {
-        Schema::table('activities', function(Blueprint $table) {
+        Schema::table('activities', function (Blueprint $table) {
             $table->dropIndex('activities_key_index');
             $table->dropIndex('activities_created_at_index');
         });
             $table->dropIndex('activities_key_index');
             $table->dropIndex('activities_created_at_index');
         });
index d2b63e8d0f9e4ef574d9f60d189594a947b3837b..09ee87f5ade99877b0e04706451eb3bece492e1e 100644 (file)
@@ -13,16 +13,16 @@ class AddEntitySoftDeletes extends Migration
      */
     public function up()
     {
      */
     public function up()
     {
-        Schema::table('bookshelves', function(Blueprint  $table) {
+        Schema::table('bookshelves', function (Blueprint $table) {
             $table->softDeletes();
         });
             $table->softDeletes();
         });
-        Schema::table('books', function(Blueprint  $table) {
+        Schema::table('books', function (Blueprint $table) {
             $table->softDeletes();
         });
             $table->softDeletes();
         });
-        Schema::table('chapters', function(Blueprint  $table) {
+        Schema::table('chapters', function (Blueprint $table) {
             $table->softDeletes();
         });
             $table->softDeletes();
         });
-        Schema::table('pages', function(Blueprint  $table) {
+        Schema::table('pages', function (Blueprint $table) {
             $table->softDeletes();
         });
     }
             $table->softDeletes();
         });
     }
@@ -34,16 +34,16 @@ class AddEntitySoftDeletes extends Migration
      */
     public function down()
     {
      */
     public function down()
     {
-        Schema::table('bookshelves', function(Blueprint  $table) {
+        Schema::table('bookshelves', function (Blueprint $table) {
             $table->dropSoftDeletes();
         });
             $table->dropSoftDeletes();
         });
-        Schema::table('books', function(Blueprint  $table) {
+        Schema::table('books', function (Blueprint $table) {
             $table->dropSoftDeletes();
         });
             $table->dropSoftDeletes();
         });
-        Schema::table('chapters', function(Blueprint  $table) {
+        Schema::table('chapters', function (Blueprint $table) {
             $table->dropSoftDeletes();
         });
             $table->dropSoftDeletes();
         });
-        Schema::table('pages', function(Blueprint  $table) {
+        Schema::table('pages', function (Blueprint $table) {
             $table->dropSoftDeletes();
         });
     }
             $table->dropSoftDeletes();
         });
     }
index 828dbc656baa5d96095ead0cdf57193d6968ed44..59f13f456ecb02da8ce8495067b9637bf26733d6 100644 (file)
@@ -2,8 +2,8 @@
 
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Schema\Blueprint;
 
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Support\Facades\Schema;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Schema;
 
 class SimplifyActivitiesTable extends Migration
 {
 
 class SimplifyActivitiesTable extends Migration
 {
@@ -25,7 +25,7 @@ class SimplifyActivitiesTable extends Migration
         DB::table('activities')
             ->where('entity_id', '=', 0)
             ->update([
         DB::table('activities')
             ->where('entity_id', '=', 0)
             ->update([
-                'entity_id' => null,
+                'entity_id'   => null,
                 'entity_type' => null,
             ]);
     }
                 'entity_type' => null,
             ]);
     }
@@ -40,7 +40,7 @@ class SimplifyActivitiesTable extends Migration
         DB::table('activities')
             ->whereNull('entity_id')
             ->update([
         DB::table('activities')
             ->whereNull('entity_id')
             ->update([
-                'entity_id' => 0,
+                'entity_id'   => 0,
                 'entity_type' => '',
             ]);
 
                 'entity_type' => '',
             ]);
 
index bf8bf281feabe0117db20c3b1ea76030af5cb7de..abff3906f55498951daeed8ba47b861380301dab 100644 (file)
@@ -2,8 +2,8 @@
 
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Schema\Blueprint;
 
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Support\Facades\Schema;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Schema;
 
 class AddOwnedByFieldToEntities extends Migration
 {
 
 class AddOwnedByFieldToEntities extends Migration
 {
index d86cb0dddd06947d478dde126f7ae8c685ec17a9..069765eb48cb36aed6610d4d73452a18b1abfb41 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 <?php
 
-use Illuminate\Database\Seeder;
 use Illuminate\Database\Eloquent\Model;
 use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Seeder;
 
 class DatabaseSeeder extends Seeder
 {
 
 class DatabaseSeeder extends Seeder
 {
index 611c05246244b426c3c8d711b29909bb8ed6256b..7463a3b3760ac006bb26c3e5845d3300e8f3cb67 100644 (file)
@@ -34,9 +34,9 @@ class DummyContentSeeder extends Seeder
         $byData = ['created_by' => $editorUser->id, 'updated_by' => $editorUser->id, 'owned_by' => $editorUser->id];
 
         factory(\BookStack\Entities\Models\Book::class, 5)->create($byData)
         $byData = ['created_by' => $editorUser->id, 'updated_by' => $editorUser->id, 'owned_by' => $editorUser->id];
 
         factory(\BookStack\Entities\Models\Book::class, 5)->create($byData)
-            ->each(function($book) use ($editorUser, $byData) {
+            ->each(function ($book) use ($byData) {
                 $chapters = factory(Chapter::class, 3)->create($byData)
                 $chapters = factory(Chapter::class, 3)->create($byData)
-                    ->each(function($chapter) use ($editorUser, $book, $byData){
+                    ->each(function ($chapter) use ($book, $byData) {
                         $pages = factory(Page::class, 3)->make(array_merge($byData, ['book_id' => $book->id]));
                         $chapter->pages()->saveMany($pages);
                     });
                         $pages = factory(Page::class, 3)->make(array_merge($byData, ['book_id' => $book->id]));
                         $chapter->pages()->saveMany($pages);
                     });
@@ -58,11 +58,11 @@ class DummyContentSeeder extends Seeder
         $apiPermission = RolePermission::getByName('access-api');
         $editorRole->attachPermission($apiPermission);
         $token = (new ApiToken())->forceFill([
         $apiPermission = RolePermission::getByName('access-api');
         $editorRole->attachPermission($apiPermission);
         $token = (new ApiToken())->forceFill([
-            'user_id' => $editorUser->id,
-            'name' => 'Testing API key',
+            'user_id'    => $editorUser->id,
+            'name'       => 'Testing API key',
             'expires_at' => ApiToken::defaultExpiry(),
             'expires_at' => ApiToken::defaultExpiry(),
-            'secret' => Hash::make('password'),
-            'token_id' => 'apitoken',
+            'secret'     => Hash::make('password'),
+            'token_id'   => 'apitoken',
         ]);
         $token->save();
 
         ]);
         $token->save();
 
index 9d890e90a4ef4cd9ade7b25b434248c63766d3d0..7e4ef97c7074672e42069c9595e217005224892a 100644 (file)
@@ -1,12 +1,10 @@
 <?php
 
 /**
 <?php
 
 /**
- * Laravel - A PHP Framework For Web Artisans
+ * Laravel - A PHP Framework For Web Artisans.
  *
  *
- * @package  Laravel
  * @author   Taylor Otwell <[email protected]>
  */
  * @author   Taylor Otwell <[email protected]>
  */
-
 define('LARAVEL_START', microtime(true));
 
 /*
 define('LARAVEL_START', microtime(true));
 
 /*
@@ -21,7 +19,7 @@ define('LARAVEL_START', microtime(true));
 |
 */
 
 |
 */
 
-require __DIR__.'/../vendor/autoload.php';
+require __DIR__ . '/../vendor/autoload.php';
 
 /*
 |--------------------------------------------------------------------------
 
 /*
 |--------------------------------------------------------------------------
@@ -35,7 +33,7 @@ require __DIR__.'/../vendor/autoload.php';
 |
 */
 
 |
 */
 
-$app = require_once __DIR__.'/../bootstrap/app.php';
+$app = require_once __DIR__ . '/../bootstrap/app.php';
 $app->alias('request', \BookStack\Http\Request::class);
 
 /*
 $app->alias('request', \BookStack\Http\Request::class);
 
 /*
@@ -58,4 +56,4 @@ $response = $kernel->handle(
 
 $response->send();
 
 
 $response->send();
 
-$kernel->terminate($request, $response);
\ No newline at end of file
+$kernel->terminate($request, $response);
index 5b724fab126dd57e6162886e6a868b0c5aeeacb6..a6ed0c8f110702c007db4feceb8075a5f1ab6971 100644 (file)
@@ -3,9 +3,8 @@
 /**
  * Routes for the BookStack API.
  * Routes have a uri prefix of /api/.
 /**
  * Routes for the BookStack API.
  * Routes have a uri prefix of /api/.
- * Controllers are all within app/Http/Controllers/Api
+ * Controllers are all within app/Http/Controllers/Api.
  */
  */
-
 Route::get('docs', 'ApiDocsController@display');
 Route::get('docs.json', 'ApiDocsController@json');
 
 Route::get('docs', 'ApiDocsController@display');
 Route::get('docs.json', 'ApiDocsController@json');
 
index 2bba3e2cfd074abace5d50f979ef31a77f590928..bc9705e10107b22080834ba302ebe67a6ce6fb43 100644 (file)
@@ -171,7 +171,7 @@ Route::group(['middleware' => 'auth'], function () {
     Route::get('/custom-head-content', 'HomeController@customHeadContent');
 
     // Settings
     Route::get('/custom-head-content', 'HomeController@customHeadContent');
 
     // Settings
-    Route::group(['prefix' => 'settings'], function() {
+    Route::group(['prefix' => 'settings'], function () {
         Route::get('/', 'SettingController@index')->name('settings');
         Route::post('/', 'SettingController@update');
 
         Route::get('/', 'SettingController@index')->name('settings');
         Route::post('/', 'SettingController@update');
 
@@ -223,7 +223,6 @@ Route::group(['middleware' => 'auth'], function () {
         Route::get('/roles/{id}', 'RoleController@edit');
         Route::put('/roles/{id}', 'RoleController@update');
     });
         Route::get('/roles/{id}', 'RoleController@edit');
         Route::put('/roles/{id}', 'RoleController@update');
     });
-
 });
 
 // Social auth routes
 });
 
 // Social auth routes
@@ -264,4 +263,4 @@ Route::post('/password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail
 Route::get('/password/reset/{token}', 'Auth\ResetPasswordController@showResetForm');
 Route::post('/password/reset', 'Auth\ResetPasswordController@reset');
 
 Route::get('/password/reset/{token}', 'Auth\ResetPasswordController@showResetForm');
 Route::post('/password/reset', 'Auth\ResetPasswordController@reset');
 
-Route::fallback('HomeController@getNotFound')->name('fallback');
\ No newline at end of file
+Route::fallback('HomeController@getNotFound')->name('fallback');
index f65c7c444f2bf9108a1df96408008ebd25e3c18f..de038652fe43b216e36f61173647792021f0d168 100644 (file)
@@ -1,12 +1,10 @@
 <?php
 
 /**
 <?php
 
 /**
- * Laravel - A PHP Framework For Web Artisans
+ * Laravel - A PHP Framework For Web Artisans.
  *
  *
- * @package  Laravel
  * @author   Taylor Otwell <[email protected]>
  */
  * @author   Taylor Otwell <[email protected]>
  */
-
 $uri = urldecode(
     parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
 );
 $uri = urldecode(
     parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
 );
@@ -14,8 +12,8 @@ $uri = urldecode(
 // This file allows us to emulate Apache's "mod_rewrite" functionality from the
 // built-in PHP web server. This provides a convenient way to test a Laravel
 // application without having installed a "real" web server software here.
 // This file allows us to emulate Apache's "mod_rewrite" functionality from the
 // built-in PHP web server. This provides a convenient way to test a Laravel
 // application without having installed a "real" web server software here.
-if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
+if ($uri !== '/' && file_exists(__DIR__ . '/public' . $uri)) {
     return false;
 }
 
     return false;
 }
 
-require_once __DIR__.'/public/index.php';
+require_once __DIR__ . '/public/index.php';
index 9c3fe273c1cbf034ab8a7246f943cbabbe0d1e2c..494a1f5060b6f8ee271a73f144de98fb5f27d962 100644 (file)
@@ -1,11 +1,11 @@
-<?php namespace Tests;
+<?php
 
 
+namespace Tests;
 
 use BookStack\Entities\Models\Book;
 
 class ActivityTrackingTest extends BrowserKitTest
 {
 
 use BookStack\Entities\Models\Book;
 
 class ActivityTrackingTest extends BrowserKitTest
 {
-
     public function test_recently_viewed_books()
     {
         $books = Book::all()->take(10);
     public function test_recently_viewed_books()
     {
         $books = Book::all()->take(10);
index 3020939479b355ab0d91fab30e6dc3acedb2288e..c45bd77eebcf4ccccb4af0ccd4badd224db2b5d9 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests\Api;
+<?php
+
+namespace Tests\Api;
 
 use BookStack\Auth\Permissions\RolePermission;
 use BookStack\Auth\User;
 
 use BookStack\Auth\Permissions\RolePermission;
 use BookStack\Auth\User;
@@ -29,28 +31,28 @@ class ApiAuthTest extends TestCase
     {
         $resp = $this->get($this->endpoint);
         $resp->assertStatus(401);
     {
         $resp = $this->get($this->endpoint);
         $resp->assertStatus(401);
-        $resp->assertJson($this->errorResponse("No authorization token found on the request", 401));
+        $resp->assertJson($this->errorResponse('No authorization token found on the request', 401));
     }
 
     public function test_bad_token_format_throws_error()
     {
     }
 
     public function test_bad_token_format_throws_error()
     {
-        $resp = $this->get($this->endpoint, ['Authorization' => "Token abc123"]);
+        $resp = $this->get($this->endpoint, ['Authorization' => 'Token abc123']);
         $resp->assertStatus(401);
         $resp->assertStatus(401);
-        $resp->assertJson($this->errorResponse("An authorization token was found on the request but the format appeared incorrect", 401));
+        $resp->assertJson($this->errorResponse('An authorization token was found on the request but the format appeared incorrect', 401));
     }
 
     public function test_token_with_non_existing_id_throws_error()
     {
     }
 
     public function test_token_with_non_existing_id_throws_error()
     {
-        $resp = $this->get($this->endpoint, ['Authorization' => "Token abc:123"]);
+        $resp = $this->get($this->endpoint, ['Authorization' => 'Token abc:123']);
         $resp->assertStatus(401);
         $resp->assertStatus(401);
-        $resp->assertJson($this->errorResponse("No matching API token was found for the provided authorization token", 401));
+        $resp->assertJson($this->errorResponse('No matching API token was found for the provided authorization token', 401));
     }
 
     public function test_token_with_bad_secret_value_throws_error()
     {
         $resp = $this->get($this->endpoint, ['Authorization' => "Token {$this->apiTokenId}:123"]);
         $resp->assertStatus(401);
     }
 
     public function test_token_with_bad_secret_value_throws_error()
     {
         $resp = $this->get($this->endpoint, ['Authorization' => "Token {$this->apiTokenId}:123"]);
         $resp->assertStatus(401);
-        $resp->assertJson($this->errorResponse("The secret provided for the given used API token is incorrect", 401));
+        $resp->assertJson($this->errorResponse('The secret provided for the given used API token is incorrect', 401));
     }
 
     public function test_api_access_permission_required_to_access_api()
     }
 
     public function test_api_access_permission_required_to_access_api()
@@ -65,7 +67,7 @@ class ApiAuthTest extends TestCase
 
         $resp = $this->get($this->endpoint, $this->apiAuthHeader());
         $resp->assertStatus(403);
 
         $resp = $this->get($this->endpoint, $this->apiAuthHeader());
         $resp->assertStatus(403);
-        $resp->assertJson($this->errorResponse("The owner of the used API token does not have permission to make API calls", 403));
+        $resp->assertJson($this->errorResponse('The owner of the used API token does not have permission to make API calls', 403));
     }
 
     public function test_api_access_permission_required_to_access_api_with_session_auth()
     }
 
     public function test_api_access_permission_required_to_access_api_with_session_auth()
@@ -86,7 +88,7 @@ class ApiAuthTest extends TestCase
         $this->actingAs($editor, 'standard');
         $resp = $this->get($this->endpoint);
         $resp->assertStatus(403);
         $this->actingAs($editor, 'standard');
         $resp = $this->get($this->endpoint);
         $resp->assertStatus(403);
-        $resp->assertJson($this->errorResponse("The owner of the used API token does not have permission to make API calls", 403));
+        $resp->assertJson($this->errorResponse('The owner of the used API token does not have permission to make API calls', 403));
     }
 
     public function test_token_expiry_checked()
     }
 
     public function test_token_expiry_checked()
@@ -102,7 +104,7 @@ class ApiAuthTest extends TestCase
         $token->save();
 
         $resp = $this->get($this->endpoint, $this->apiAuthHeader());
         $token->save();
 
         $resp = $this->get($this->endpoint, $this->apiAuthHeader());
-        $resp->assertJson($this->errorResponse("The authorization token used has expired", 403));
+        $resp->assertJson($this->errorResponse('The authorization token used has expired', 403));
     }
 
     public function test_email_confirmation_checked_using_api_auth()
     }
 
     public function test_email_confirmation_checked_using_api_auth()
@@ -116,7 +118,7 @@ class ApiAuthTest extends TestCase
 
         $resp = $this->get($this->endpoint, $this->apiAuthHeader());
         $resp->assertStatus(401);
 
         $resp = $this->get($this->endpoint, $this->apiAuthHeader());
         $resp->assertStatus(401);
-        $resp->assertJson($this->errorResponse("The email address for the account in use needs to be confirmed", 401));
+        $resp->assertJson($this->errorResponse('The email address for the account in use needs to be confirmed', 401));
     }
 
     public function test_rate_limit_headers_active_on_requests()
     }
 
     public function test_rate_limit_headers_active_on_requests()
@@ -141,7 +143,7 @@ class ApiAuthTest extends TestCase
         $resp->assertJson([
             'error' => [
                 'code' => 429,
         $resp->assertJson([
             'error' => [
                 'code' => 429,
-            ]
+            ],
         ]);
     }
         ]);
     }
-}
\ No newline at end of file
+}
index def62c94dd40465899f3e794e2c6b7897a963ff4..af808a76ca3f545535aa2ea9b3f494f0966fa48e 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests\Api;
+<?php
+
+namespace Tests\Api;
 
 use Tests\TestCase;
 
 
 use Tests\TestCase;
 
@@ -51,5 +53,4 @@ class ApiConfigTest extends TestCase
         $resp = $this->actingAsApiEditor()->get($this->endpoint);
         $resp->assertHeader('x-ratelimit-limit', 10);
     }
         $resp = $this->actingAsApiEditor()->get($this->endpoint);
         $resp->assertHeader('x-ratelimit-limit', 10);
     }
-
-}
\ No newline at end of file
+}
index 1687c64a17e10a7a5110166d251be7c2721afcf1..90d107eb34aa7b170d73fe2999014c7789248176 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests\Api;
+<?php
+
+namespace Tests\Api;
 
 use BookStack\Auth\User;
 use Tests\TestCase;
 
 use BookStack\Auth\User;
 use Tests\TestCase;
@@ -34,10 +36,10 @@ class ApiDocsTest extends TestCase
         $resp->assertStatus(200);
         $resp->assertHeader('Content-Type', 'application/json');
         $resp->assertJson([
         $resp->assertStatus(200);
         $resp->assertHeader('Content-Type', 'application/json');
         $resp->assertJson([
-            'docs' => [ [
+            'docs' => [[
                 'name' => 'docs-display',
                 'name' => 'docs-display',
-                'uri' => 'api/docs'
-            ] ]
+                'uri'  => 'api/docs',
+            ]],
         ]);
     }
 
         ]);
     }
 
@@ -55,4 +57,4 @@ class ApiDocsTest extends TestCase
         $resp = $this->get('/api/docs');
         $resp->assertStatus(200);
     }
         $resp = $this->get('/api/docs');
         $resp->assertStatus(200);
     }
-}
\ No newline at end of file
+}
index c3d9bc10888d51e91bc1a584cadabf6ff27b3642..f90ec5a3dd2a30fc806ca620e36919f6be11390e 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests\Api;
+<?php
+
+namespace Tests\Api;
 
 use BookStack\Entities\Models\Book;
 use Tests\TestCase;
 
 use BookStack\Entities\Models\Book;
 use Tests\TestCase;
@@ -27,7 +29,7 @@ class ApiListingTest extends TestCase
         $books = Book::visible()->orderBy('id')->take(3)->get();
 
         $resp = $this->get($this->endpoint . '?count=1');
         $books = Book::visible()->orderBy('id')->take(3)->get();
 
         $resp = $this->get($this->endpoint . '?count=1');
-        $resp->assertJsonMissing(['name' => $books[1]->name ]);
+        $resp->assertJsonMissing(['name' => $books[1]->name]);
 
         $resp = $this->get($this->endpoint . '?count=1&offset=1000');
         $resp->assertJsonCount(0, 'data');
 
         $resp = $this->get($this->endpoint . '?count=1&offset=1000');
         $resp->assertJsonCount(0, 'data');
@@ -38,19 +40,19 @@ class ApiListingTest extends TestCase
         $this->actingAsApiEditor();
 
         $sortChecks = [
         $this->actingAsApiEditor();
 
         $sortChecks = [
-            '-id' => Book::visible()->orderBy('id', 'desc')->first(),
+            '-id'   => Book::visible()->orderBy('id', 'desc')->first(),
             '+name' => Book::visible()->orderBy('name', 'asc')->first(),
             '+name' => Book::visible()->orderBy('name', 'asc')->first(),
-            'name' => Book::visible()->orderBy('name', 'asc')->first(),
-            '-name' => Book::visible()->orderBy('name', 'desc')->first()
+            'name'  => Book::visible()->orderBy('name', 'asc')->first(),
+            '-name' => Book::visible()->orderBy('name', 'desc')->first(),
         ];
 
         foreach ($sortChecks as $sortOption => $result) {
             $resp = $this->get($this->endpoint . '?count=1&sort=' . $sortOption);
             $resp->assertJson(['data' => [
                 [
         ];
 
         foreach ($sortChecks as $sortOption => $result) {
             $resp = $this->get($this->endpoint . '?count=1&sort=' . $sortOption);
             $resp->assertJson(['data' => [
                 [
-                    'id' => $result->id,
+                    'id'   => $result->id,
                     'name' => $result->name,
                     'name' => $result->name,
-                ]
+                ],
             ]]);
         }
     }
             ]]);
         }
     }
@@ -64,11 +66,11 @@ class ApiListingTest extends TestCase
 
         $filterChecks = [
             // Test different types of filter
 
         $filterChecks = [
             // Test different types of filter
-            "filter[id]={$book->id}" => 1,
-            "filter[id:ne]={$book->id}" => Book::visible()->where('id', '!=', $book->id)->count(),
-            "filter[id:gt]={$book->id}" => Book::visible()->where('id', '>', $book->id)->count(),
-            "filter[id:gte]={$book->id}" => Book::visible()->where('id', '>=', $book->id)->count(),
-            "filter[id:lt]={$book->id}" => Book::visible()->where('id', '<', $book->id)->count(),
+            "filter[id]={$book->id}"                  => 1,
+            "filter[id:ne]={$book->id}"               => Book::visible()->where('id', '!=', $book->id)->count(),
+            "filter[id:gt]={$book->id}"               => Book::visible()->where('id', '>', $book->id)->count(),
+            "filter[id:gte]={$book->id}"              => Book::visible()->where('id', '>=', $book->id)->count(),
+            "filter[id:lt]={$book->id}"               => Book::visible()->where('id', '<', $book->id)->count(),
             "filter[name:like]={$encodedNameSubstr}%" => Book::visible()->where('name', 'like', $nameSubstr . '%')->count(),
 
             // Test mulitple filters 'and' together
             "filter[name:like]={$encodedNameSubstr}%" => Book::visible()->where('name', 'like', $nameSubstr . '%')->count(),
 
             // Test mulitple filters 'and' together
@@ -86,7 +88,7 @@ class ApiListingTest extends TestCase
         $this->actingAsApiEditor();
         $bookCount = Book::query()->count();
         $resp = $this->get($this->endpoint . '?count=1');
         $this->actingAsApiEditor();
         $bookCount = Book::query()->count();
         $resp = $this->get($this->endpoint . '?count=1');
-        $resp->assertJson(['total' => $bookCount ]);
+        $resp->assertJson(['total' => $bookCount]);
     }
 
     public function test_total_on_results_shows_correctly_when_offset_provided()
     }
 
     public function test_total_on_results_shows_correctly_when_offset_provided()
@@ -94,7 +96,6 @@ class ApiListingTest extends TestCase
         $this->actingAsApiEditor();
         $bookCount = Book::query()->count();
         $resp = $this->get($this->endpoint . '?count=1&offset=1');
         $this->actingAsApiEditor();
         $bookCount = Book::query()->count();
         $resp = $this->get($this->endpoint . '?count=1&offset=1');
-        $resp->assertJson(['total' => $bookCount ]);
+        $resp->assertJson(['total' => $bookCount]);
     }
     }
-
-}
\ No newline at end of file
+}
index 446ba28117a765a7663b6c95def30782939d9329..279c7ad9a73b75b0617e3045b1315b1ee3ad837f 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests\Api;
+<?php
+
+namespace Tests\Api;
 
 use BookStack\Entities\Models\Book;
 use Tests\TestCase;
 
 use BookStack\Entities\Models\Book;
 use Tests\TestCase;
@@ -17,10 +19,10 @@ class BooksApiTest extends TestCase
         $resp = $this->getJson($this->baseEndpoint . '?count=1&sort=+id');
         $resp->assertJson(['data' => [
             [
         $resp = $this->getJson($this->baseEndpoint . '?count=1&sort=+id');
         $resp->assertJson(['data' => [
             [
-                'id' => $firstBook->id,
+                'id'   => $firstBook->id,
                 'name' => $firstBook->name,
                 'slug' => $firstBook->slug,
                 'name' => $firstBook->name,
                 'slug' => $firstBook->slug,
-            ]
+            ],
         ]]);
     }
 
         ]]);
     }
 
@@ -28,7 +30,7 @@ class BooksApiTest extends TestCase
     {
         $this->actingAsApiEditor();
         $details = [
     {
         $this->actingAsApiEditor();
         $details = [
-            'name' => 'My API book',
+            'name'        => 'My API book',
             'description' => 'A book created via the API',
         ];
 
             'description' => 'A book created via the API',
         ];
 
@@ -49,12 +51,12 @@ class BooksApiTest extends TestCase
         $resp = $this->postJson($this->baseEndpoint, $details);
         $resp->assertStatus(422);
         $resp->assertJson([
         $resp = $this->postJson($this->baseEndpoint, $details);
         $resp->assertStatus(422);
         $resp->assertJson([
-            "error" => [
-                "message" => "The given data was invalid.",
-                "validation" => [
-                    "name" => ["The name field is required."]
+            'error' => [
+                'message'    => 'The given data was invalid.',
+                'validation' => [
+                    'name' => ['The name field is required.'],
                 ],
                 ],
-                "code" => 422,
+                'code' => 422,
             ],
         ]);
     }
             ],
         ]);
     }
@@ -68,8 +70,8 @@ class BooksApiTest extends TestCase
 
         $resp->assertStatus(200);
         $resp->assertJson([
 
         $resp->assertStatus(200);
         $resp->assertJson([
-            'id' => $book->id,
-            'slug' => $book->slug,
+            'id'         => $book->id,
+            'slug'       => $book->slug,
             'created_by' => [
                 'name' => $book->createdBy->name,
             ],
             'created_by' => [
                 'name' => $book->createdBy->name,
             ],
@@ -77,7 +79,7 @@ class BooksApiTest extends TestCase
                 'name' => $book->createdBy->name,
             ],
             'owned_by' => [
                 'name' => $book->createdBy->name,
             ],
             'owned_by' => [
-                'name' => $book->ownedBy->name
+                'name' => $book->ownedBy->name,
             ],
         ]);
     }
             ],
         ]);
     }
@@ -87,7 +89,7 @@ class BooksApiTest extends TestCase
         $this->actingAsApiEditor();
         $book = Book::visible()->first();
         $details = [
         $this->actingAsApiEditor();
         $book = Book::visible()->first();
         $details = [
-            'name' => 'My updated API book',
+            'name'        => 'My updated API book',
             'description' => 'A book created via the API',
         ];
 
             'description' => 'A book created via the API',
         ];
 
@@ -153,4 +155,4 @@ class BooksApiTest extends TestCase
         $resp->assertSee('# ' . $book->pages()->first()->name);
         $resp->assertSee('# ' . $book->chapters()->first()->name);
     }
         $resp->assertSee('# ' . $book->pages()->first()->name);
         $resp->assertSee('# ' . $book->chapters()->first()->name);
     }
-}
\ No newline at end of file
+}
index e11bb0e1cf8d4f672d71791adabae4061604b378..b3dd0ae6b408ecb20badca3dcb552b193f8da3eb 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests\Api;
+<?php
+
+namespace Tests\Api;
 
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Chapter;
 
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Chapter;
@@ -18,12 +20,12 @@ class ChaptersApiTest extends TestCase
         $resp = $this->getJson($this->baseEndpoint . '?count=1&sort=+id');
         $resp->assertJson(['data' => [
             [
         $resp = $this->getJson($this->baseEndpoint . '?count=1&sort=+id');
         $resp->assertJson(['data' => [
             [
-                'id' => $firstChapter->id,
-                'name' => $firstChapter->name,
-                'slug' => $firstChapter->slug,
-                'book_id' => $firstChapter->book->id,
+                'id'       => $firstChapter->id,
+                'name'     => $firstChapter->name,
+                'slug'     => $firstChapter->slug,
+                'book_id'  => $firstChapter->book->id,
                 'priority' => $firstChapter->priority,
                 'priority' => $firstChapter->priority,
-            ]
+            ],
         ]]);
     }
 
         ]]);
     }
 
@@ -32,15 +34,15 @@ class ChaptersApiTest extends TestCase
         $this->actingAsApiEditor();
         $book = Book::query()->first();
         $details = [
         $this->actingAsApiEditor();
         $book = Book::query()->first();
         $details = [
-            'name' => 'My API chapter',
+            'name'        => 'My API chapter',
             'description' => 'A chapter created via the API',
             'description' => 'A chapter created via the API',
-            'book_id' => $book->id,
-            'tags' => [
+            'book_id'     => $book->id,
+            'tags'        => [
                 [
                 [
-                    'name' => 'tagname',
+                    'name'  => 'tagname',
                     'value' => 'tagvalue',
                     'value' => 'tagvalue',
-                ]
-            ]
+                ],
+            ],
         ];
 
         $resp = $this->postJson($this->baseEndpoint, $details);
         ];
 
         $resp = $this->postJson($this->baseEndpoint, $details);
@@ -48,10 +50,10 @@ class ChaptersApiTest extends TestCase
         $newItem = Chapter::query()->orderByDesc('id')->where('name', '=', $details['name'])->first();
         $resp->assertJson(array_merge($details, ['id' => $newItem->id, 'slug' => $newItem->slug]));
         $this->assertDatabaseHas('tags', [
         $newItem = Chapter::query()->orderByDesc('id')->where('name', '=', $details['name'])->first();
         $resp->assertJson(array_merge($details, ['id' => $newItem->id, 'slug' => $newItem->slug]));
         $this->assertDatabaseHas('tags', [
-            'entity_id' => $newItem->id,
+            'entity_id'   => $newItem->id,
             'entity_type' => $newItem->getMorphClass(),
             'entity_type' => $newItem->getMorphClass(),
-            'name' => 'tagname',
-            'value' => 'tagvalue',
+            'name'        => 'tagname',
+            'value'       => 'tagvalue',
         ]);
         $resp->assertJsonMissing(['pages' => []]);
         $this->assertActivityExists('chapter_create', $newItem);
         ]);
         $resp->assertJsonMissing(['pages' => []]);
         $this->assertActivityExists('chapter_create', $newItem);
@@ -62,14 +64,14 @@ class ChaptersApiTest extends TestCase
         $this->actingAsApiEditor();
         $book = Book::query()->first();
         $details = [
         $this->actingAsApiEditor();
         $book = Book::query()->first();
         $details = [
-            'book_id' => $book->id,
+            'book_id'     => $book->id,
             'description' => 'A chapter created via the API',
         ];
 
         $resp = $this->postJson($this->baseEndpoint, $details);
         $resp->assertStatus(422);
         $resp->assertJson($this->validationResponse([
             'description' => 'A chapter created via the API',
         ];
 
         $resp = $this->postJson($this->baseEndpoint, $details);
         $resp->assertStatus(422);
         $resp->assertJson($this->validationResponse([
-            "name" => ["The name field is required."]
+            'name' => ['The name field is required.'],
         ]));
     }
 
         ]));
     }
 
@@ -77,14 +79,14 @@ class ChaptersApiTest extends TestCase
     {
         $this->actingAsApiEditor();
         $details = [
     {
         $this->actingAsApiEditor();
         $details = [
-            'name' => 'My api chapter',
+            'name'        => 'My api chapter',
             'description' => 'A chapter created via the API',
         ];
 
         $resp = $this->postJson($this->baseEndpoint, $details);
         $resp->assertStatus(422);
         $resp->assertJson($this->validationResponse([
             'description' => 'A chapter created via the API',
         ];
 
         $resp = $this->postJson($this->baseEndpoint, $details);
         $resp->assertStatus(422);
         $resp->assertJson($this->validationResponse([
-            "book_id" => ["The book id field is required."]
+            'book_id' => ['The book id field is required.'],
         ]));
     }
 
         ]));
     }
 
@@ -97,24 +99,24 @@ class ChaptersApiTest extends TestCase
         $resp = $this->getJson($this->baseEndpoint . "/{$chapter->id}");
         $resp->assertStatus(200);
         $resp->assertJson([
         $resp = $this->getJson($this->baseEndpoint . "/{$chapter->id}");
         $resp->assertStatus(200);
         $resp->assertJson([
-            'id' => $chapter->id,
-            'slug' => $chapter->slug,
+            'id'         => $chapter->id,
+            'slug'       => $chapter->slug,
             'created_by' => [
                 'name' => $chapter->createdBy->name,
             ],
             'created_by' => [
                 'name' => $chapter->createdBy->name,
             ],
-            'book_id' => $chapter->book_id,
+            'book_id'    => $chapter->book_id,
             'updated_by' => [
                 'name' => $chapter->createdBy->name,
             ],
             'owned_by' => [
             'updated_by' => [
                 'name' => $chapter->createdBy->name,
             ],
             'owned_by' => [
-                'name' => $chapter->ownedBy->name
+                'name' => $chapter->ownedBy->name,
             ],
             'pages' => [
                 [
             ],
             'pages' => [
                 [
-                    'id' => $page->id,
+                    'id'   => $page->id,
                     'slug' => $page->slug,
                     'name' => $page->name,
                     'slug' => $page->slug,
                     'name' => $page->name,
-                ]
+                ],
             ],
         ]);
         $resp->assertJsonCount($chapter->pages()->count(), 'pages');
             ],
         ]);
         $resp->assertJsonCount($chapter->pages()->count(), 'pages');
@@ -125,13 +127,13 @@ class ChaptersApiTest extends TestCase
         $this->actingAsApiEditor();
         $chapter = Chapter::visible()->first();
         $details = [
         $this->actingAsApiEditor();
         $chapter = Chapter::visible()->first();
         $details = [
-            'name' => 'My updated API chapter',
+            'name'        => 'My updated API chapter',
             'description' => 'A chapter created via the API',
             'description' => 'A chapter created via the API',
-            'tags' => [
+            'tags'        => [
                 [
                 [
-                    'name' => 'freshtag',
+                    'name'  => 'freshtag',
                     'value' => 'freshtagval',
                     'value' => 'freshtagval',
-                ]
+                ],
             ],
         ];
 
             ],
         ];
 
@@ -140,7 +142,7 @@ class ChaptersApiTest extends TestCase
 
         $resp->assertStatus(200);
         $resp->assertJson(array_merge($details, [
 
         $resp->assertStatus(200);
         $resp->assertJson(array_merge($details, [
-            'id' => $chapter->id, 'slug' => $chapter->slug, 'book_id' => $chapter->book_id
+            'id' => $chapter->id, 'slug' => $chapter->slug, 'book_id' => $chapter->book_id,
         ]));
         $this->assertActivityExists('chapter_update', $chapter);
     }
         ]));
         $this->assertActivityExists('chapter_update', $chapter);
     }
@@ -198,4 +200,4 @@ class ChaptersApiTest extends TestCase
         $resp->assertSee('# ' . $chapter->name);
         $resp->assertSee('# ' . $chapter->pages()->first()->name);
     }
         $resp->assertSee('# ' . $chapter->name);
         $resp->assertSee('# ' . $chapter->pages()->first()->name);
     }
-}
\ No newline at end of file
+}
index 9fab675e739644b11df8284a0355c6456627e6fb..d52c6b513892374d955a5c758ad8ca5a46562837 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests\Api;
+<?php
+
+namespace Tests\Api;
 
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Chapter;
 
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Chapter;
@@ -19,12 +21,12 @@ class PagesApiTest extends TestCase
         $resp = $this->getJson($this->baseEndpoint . '?count=1&sort=+id');
         $resp->assertJson(['data' => [
             [
         $resp = $this->getJson($this->baseEndpoint . '?count=1&sort=+id');
         $resp->assertJson(['data' => [
             [
-                'id' => $firstPage->id,
-                'name' => $firstPage->name,
-                'slug' => $firstPage->slug,
-                'book_id' => $firstPage->book->id,
+                'id'       => $firstPage->id,
+                'name'     => $firstPage->name,
+                'slug'     => $firstPage->slug,
+                'book_id'  => $firstPage->book->id,
                 'priority' => $firstPage->priority,
                 'priority' => $firstPage->priority,
-            ]
+            ],
         ]]);
     }
 
         ]]);
     }
 
@@ -33,15 +35,15 @@ class PagesApiTest extends TestCase
         $this->actingAsApiEditor();
         $book = Book::query()->first();
         $details = [
         $this->actingAsApiEditor();
         $book = Book::query()->first();
         $details = [
-            'name' => 'My API page',
+            'name'    => 'My API page',
             'book_id' => $book->id,
             'book_id' => $book->id,
-            'html' => '<p>My new page content</p>',
-            'tags' => [
+            'html'    => '<p>My new page content</p>',
+            'tags'    => [
                 [
                 [
-                    'name' => 'tagname',
+                    'name'  => 'tagname',
                     'value' => 'tagvalue',
                     'value' => 'tagvalue',
-                ]
-            ]
+                ],
+            ],
         ];
 
         $resp = $this->postJson($this->baseEndpoint, $details);
         ];
 
         $resp = $this->postJson($this->baseEndpoint, $details);
@@ -50,10 +52,10 @@ class PagesApiTest extends TestCase
         $newItem = Page::query()->orderByDesc('id')->where('name', '=', $details['name'])->first();
         $resp->assertJson(array_merge($details, ['id' => $newItem->id, 'slug' => $newItem->slug]));
         $this->assertDatabaseHas('tags', [
         $newItem = Page::query()->orderByDesc('id')->where('name', '=', $details['name'])->first();
         $resp->assertJson(array_merge($details, ['id' => $newItem->id, 'slug' => $newItem->slug]));
         $this->assertDatabaseHas('tags', [
-            'entity_id' => $newItem->id,
+            'entity_id'   => $newItem->id,
             'entity_type' => $newItem->getMorphClass(),
             'entity_type' => $newItem->getMorphClass(),
-            'name' => 'tagname',
-            'value' => 'tagvalue',
+            'name'        => 'tagname',
+            'value'       => 'tagvalue',
         ]);
         $resp->assertSeeText('My new page content');
         $resp->assertJsonMissing(['book' => []]);
         ]);
         $resp->assertSeeText('My new page content');
         $resp->assertJsonMissing(['book' => []]);
@@ -66,13 +68,13 @@ class PagesApiTest extends TestCase
         $book = Book::query()->first();
         $details = [
             'book_id' => $book->id,
         $book = Book::query()->first();
         $details = [
             'book_id' => $book->id,
-            'html' => '<p>A page created via the API</p>',
+            'html'    => '<p>A page created via the API</p>',
         ];
 
         $resp = $this->postJson($this->baseEndpoint, $details);
         $resp->assertStatus(422);
         $resp->assertJson($this->validationResponse([
         ];
 
         $resp = $this->postJson($this->baseEndpoint, $details);
         $resp->assertStatus(422);
         $resp->assertJson($this->validationResponse([
-            "name" => ["The name field is required."]
+            'name' => ['The name field is required.'],
         ]));
     }
 
         ]));
     }
 
@@ -87,8 +89,8 @@ class PagesApiTest extends TestCase
         $resp = $this->postJson($this->baseEndpoint, $details);
         $resp->assertStatus(422);
         $resp->assertJson($this->validationResponse([
         $resp = $this->postJson($this->baseEndpoint, $details);
         $resp->assertStatus(422);
         $resp->assertJson($this->validationResponse([
-            "book_id" => ["The book id field is required when chapter id is not present."],
-            "chapter_id" => ["The chapter id field is required when book id is not present."]
+            'book_id'    => ['The book id field is required when chapter id is not present.'],
+            'chapter_id' => ['The chapter id field is required when book id is not present.'],
         ]));
 
         $chapter = Chapter::visible()->first();
         ]));
 
         $chapter = Chapter::visible()->first();
@@ -105,8 +107,8 @@ class PagesApiTest extends TestCase
         $this->actingAsApiEditor();
         $book = Book::visible()->first();
         $details = [
         $this->actingAsApiEditor();
         $book = Book::visible()->first();
         $details = [
-            'book_id' => $book->id,
-            'name' => 'My api page',
+            'book_id'  => $book->id,
+            'name'     => 'My api page',
             'markdown' => "# A new API page \n[link](https://example.com)",
         ];
 
             'markdown' => "# A new API page \n[link](https://example.com)",
         ];
 
@@ -127,17 +129,17 @@ class PagesApiTest extends TestCase
         $resp = $this->getJson($this->baseEndpoint . "/{$page->id}");
         $resp->assertStatus(200);
         $resp->assertJson([
         $resp = $this->getJson($this->baseEndpoint . "/{$page->id}");
         $resp->assertStatus(200);
         $resp->assertJson([
-            'id' => $page->id,
-            'slug' => $page->slug,
+            'id'         => $page->id,
+            'slug'       => $page->slug,
             'created_by' => [
                 'name' => $page->createdBy->name,
             ],
             'created_by' => [
                 'name' => $page->createdBy->name,
             ],
-            'book_id' => $page->book_id,
+            'book_id'    => $page->book_id,
             'updated_by' => [
                 'name' => $page->createdBy->name,
             ],
             'owned_by' => [
             'updated_by' => [
                 'name' => $page->createdBy->name,
             ],
             'owned_by' => [
-                'name' => $page->ownedBy->name
+                'name' => $page->ownedBy->name,
             ],
         ]);
     }
             ],
         ]);
     }
@@ -165,9 +167,9 @@ class PagesApiTest extends TestCase
             'html' => '<p>A page created via the API</p>',
             'tags' => [
                 [
             'html' => '<p>A page created via the API</p>',
             'tags' => [
                 [
-                    'name' => 'freshtag',
+                    'name'  => 'freshtag',
                     'value' => 'freshtagval',
                     'value' => 'freshtagval',
-                ]
+                ],
             ],
         ];
 
             ],
         ];
 
@@ -177,7 +179,7 @@ class PagesApiTest extends TestCase
         $resp->assertStatus(200);
         unset($details['html']);
         $resp->assertJson(array_merge($details, [
         $resp->assertStatus(200);
         unset($details['html']);
         $resp->assertJson(array_merge($details, [
-            'id' => $page->id, 'slug' => $page->slug, 'book_id' => $page->book_id
+            'id' => $page->id, 'slug' => $page->slug, 'book_id' => $page->book_id,
         ]));
         $this->assertActivityExists('page_update', $page);
     }
         ]));
         $this->assertActivityExists('page_update', $page);
     }
@@ -188,16 +190,16 @@ class PagesApiTest extends TestCase
         $page = Page::visible()->first();
         $chapter = Chapter::visible()->where('book_id', '!=', $page->book_id)->first();
         $details = [
         $page = Page::visible()->first();
         $chapter = Chapter::visible()->where('book_id', '!=', $page->book_id)->first();
         $details = [
-            'name' => 'My updated API page',
+            'name'       => 'My updated API page',
             'chapter_id' => $chapter->id,
             'chapter_id' => $chapter->id,
-            'html' => '<p>A page created via the API</p>',
+            'html'       => '<p>A page created via the API</p>',
         ];
 
         $resp = $this->putJson($this->baseEndpoint . "/{$page->id}", $details);
         $resp->assertStatus(200);
         $resp->assertJson([
             'chapter_id' => $chapter->id,
         ];
 
         $resp = $this->putJson($this->baseEndpoint . "/{$page->id}", $details);
         $resp->assertStatus(200);
         $resp->assertJson([
             'chapter_id' => $chapter->id,
-            'book_id' => $chapter->book_id,
+            'book_id'    => $chapter->book_id,
         ]);
     }
 
         ]);
     }
 
@@ -208,9 +210,9 @@ class PagesApiTest extends TestCase
         $chapter = Chapter::visible()->where('book_id', '!=', $page->book_id)->first();
         $this->setEntityRestrictions($chapter, ['view'], [$this->getEditor()->roles()->first()]);
         $details = [
         $chapter = Chapter::visible()->where('book_id', '!=', $page->book_id)->first();
         $this->setEntityRestrictions($chapter, ['view'], [$this->getEditor()->roles()->first()]);
         $details = [
-            'name' => 'My updated API page',
+            'name'       => 'My updated API page',
             'chapter_id' => $chapter->id,
             'chapter_id' => $chapter->id,
-            'html' => '<p>A page created via the API</p>',
+            'html'       => '<p>A page created via the API</p>',
         ];
 
         $resp = $this->putJson($this->baseEndpoint . "/{$page->id}", $details);
         ];
 
         $resp = $this->putJson($this->baseEndpoint . "/{$page->id}", $details);
@@ -269,4 +271,4 @@ class PagesApiTest extends TestCase
         $resp->assertSee('# ' . $page->name);
         $resp->assertHeader('Content-Disposition', 'attachment; filename="' . $page->slug . '.md"');
     }
         $resp->assertSee('# ' . $page->name);
         $resp->assertHeader('Content-Disposition', 'attachment; filename="' . $page->slug . '.md"');
     }
-}
\ No newline at end of file
+}
index 32715dd0a1630165af36f5f86254931bd8874ff8..8868c686e5086231fb26f5c7d2a7ce75e202c572 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests\Api;
+<?php
+
+namespace Tests\Api;
 
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Bookshelf;
 
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Bookshelf;
@@ -18,10 +20,10 @@ class ShelvesApiTest extends TestCase
         $resp = $this->getJson($this->baseEndpoint . '?count=1&sort=+id');
         $resp->assertJson(['data' => [
             [
         $resp = $this->getJson($this->baseEndpoint . '?count=1&sort=+id');
         $resp->assertJson(['data' => [
             [
-                'id' => $firstBookshelf->id,
+                'id'   => $firstBookshelf->id,
                 'name' => $firstBookshelf->name,
                 'slug' => $firstBookshelf->slug,
                 'name' => $firstBookshelf->name,
                 'slug' => $firstBookshelf->slug,
-            ]
+            ],
         ]]);
     }
 
         ]]);
     }
 
@@ -31,7 +33,7 @@ class ShelvesApiTest extends TestCase
         $books = Book::query()->take(2)->get();
 
         $details = [
         $books = Book::query()->take(2)->get();
 
         $details = [
-            'name' => 'My API shelf',
+            'name'        => 'My API shelf',
             'description' => 'A shelf created via the API',
         ];
 
             'description' => 'A shelf created via the API',
         ];
 
@@ -43,8 +45,8 @@ class ShelvesApiTest extends TestCase
         foreach ($books as $index => $book) {
             $this->assertDatabaseHas('bookshelves_books', [
                 'bookshelf_id' => $newItem->id,
         foreach ($books as $index => $book) {
             $this->assertDatabaseHas('bookshelves_books', [
                 'bookshelf_id' => $newItem->id,
-                'book_id' => $book->id,
-                'order' => $index,
+                'book_id'      => $book->id,
+                'order'        => $index,
             ]);
         }
     }
             ]);
         }
     }
@@ -59,12 +61,12 @@ class ShelvesApiTest extends TestCase
         $resp = $this->postJson($this->baseEndpoint, $details);
         $resp->assertStatus(422);
         $resp->assertJson([
         $resp = $this->postJson($this->baseEndpoint, $details);
         $resp->assertStatus(422);
         $resp->assertJson([
-            "error" => [
-                "message" => "The given data was invalid.",
-                "validation" => [
-                    "name" => ["The name field is required."]
+            'error' => [
+                'message'    => 'The given data was invalid.',
+                'validation' => [
+                    'name' => ['The name field is required.'],
                 ],
                 ],
-                "code" => 422,
+                'code' => 422,
             ],
         ]);
     }
             ],
         ]);
     }
@@ -78,8 +80,8 @@ class ShelvesApiTest extends TestCase
 
         $resp->assertStatus(200);
         $resp->assertJson([
 
         $resp->assertStatus(200);
         $resp->assertJson([
-            'id' => $shelf->id,
-            'slug' => $shelf->slug,
+            'id'         => $shelf->id,
+            'slug'       => $shelf->slug,
             'created_by' => [
                 'name' => $shelf->createdBy->name,
             ],
             'created_by' => [
                 'name' => $shelf->createdBy->name,
             ],
@@ -87,7 +89,7 @@ class ShelvesApiTest extends TestCase
                 'name' => $shelf->createdBy->name,
             ],
             'owned_by' => [
                 'name' => $shelf->createdBy->name,
             ],
             'owned_by' => [
-                'name' => $shelf->ownedBy->name
+                'name' => $shelf->ownedBy->name,
             ],
         ]);
     }
             ],
         ]);
     }
@@ -97,7 +99,7 @@ class ShelvesApiTest extends TestCase
         $this->actingAsApiEditor();
         $shelf = Bookshelf::visible()->first();
         $details = [
         $this->actingAsApiEditor();
         $shelf = Bookshelf::visible()->first();
         $details = [
-            'name' => 'My updated API shelf',
+            'name'        => 'My updated API shelf',
             'description' => 'A shelf created via the API',
         ];
 
             'description' => 'A shelf created via the API',
         ];
 
@@ -136,4 +138,4 @@ class ShelvesApiTest extends TestCase
         $resp->assertStatus(204);
         $this->assertActivityExists('bookshelf_delete');
     }
         $resp->assertStatus(204);
         $this->assertActivityExists('bookshelf_delete');
     }
-}
\ No newline at end of file
+}
index 1ad4d14b64e4c7137134552848b1f7c800dbed6f..683ca0c747a022a31c829f9ea2359feadf4e6e44 100644 (file)
@@ -1,8 +1,9 @@
-<?php namespace Tests\Api;
+<?php
+
+namespace Tests\Api;
 
 trait TestsApi
 {
 
 trait TestsApi
 {
-
     protected $apiTokenId = 'apitoken';
     protected $apiTokenSecret = 'password';
 
     protected $apiTokenId = 'apitoken';
     protected $apiTokenSecret = 'password';
 
@@ -12,6 +13,7 @@ trait TestsApi
     protected function actingAsApiEditor()
     {
         $this->actingAs($this->getEditor(), 'api');
     protected function actingAsApiEditor()
     {
         $this->actingAs($this->getEditor(), 'api');
+
         return $this;
     }
 
         return $this;
     }
 
@@ -20,7 +22,7 @@ trait TestsApi
      */
     protected function errorResponse(string $message, int $code): array
     {
      */
     protected function errorResponse(string $message, int $code): array
     {
-        return ["error" => ["code" => $code, "message" => $message]];
+        return ['error' => ['code' => $code, 'message' => $message]];
     }
 
     /**
     }
 
     /**
@@ -29,18 +31,19 @@ trait TestsApi
      */
     protected function validationResponse(array $messages): array
     {
      */
     protected function validationResponse(array $messages): array
     {
-        $err = $this->errorResponse("The given data was invalid.", 422);
+        $err = $this->errorResponse('The given data was invalid.', 422);
         $err['error']['validation'] = $messages;
         $err['error']['validation'] = $messages;
+
         return $err;
     }
         return $err;
     }
+
     /**
      * Get an approved API auth header.
      */
     protected function apiAuthHeader(): array
     {
         return [
     /**
      * Get an approved API auth header.
      */
     protected function apiAuthHeader(): array
     {
         return [
-            "Authorization" => "Token {$this->apiTokenId}:{$this->apiTokenSecret}"
+            'Authorization' => "Token {$this->apiTokenId}:{$this->apiTokenSecret}",
         ];
     }
         ];
     }
-
-}
\ No newline at end of file
+}
index 55a458786b2e2f4b4f7eacc56d8c089c65b80192..bc36a184d129f3465a9e9fc855dfcabd21b98d5d 100644 (file)
@@ -1,18 +1,20 @@
-<?php namespace Tests;
+<?php
+
+namespace Tests;
 
 use BookStack\Actions\Activity;
 use BookStack\Actions\ActivityService;
 use BookStack\Actions\ActivityType;
 use BookStack\Auth\UserRepo;
 use BookStack\Entities\Models\Chapter;
 
 use BookStack\Actions\Activity;
 use BookStack\Actions\ActivityService;
 use BookStack\Actions\ActivityType;
 use BookStack\Auth\UserRepo;
 use BookStack\Entities\Models\Chapter;
-use BookStack\Entities\Tools\TrashCan;
 use BookStack\Entities\Models\Page;
 use BookStack\Entities\Repos\PageRepo;
 use BookStack\Entities\Models\Page;
 use BookStack\Entities\Repos\PageRepo;
+use BookStack\Entities\Tools\TrashCan;
 use Carbon\Carbon;
 
 class AuditLogTest extends TestCase
 {
 use Carbon\Carbon;
 
 class AuditLogTest extends TestCase
 {
-    /** @var ActivityService  */
+    /** @var ActivityService */
     protected $activityService;
 
     public function setUp(): void
     protected $activityService;
 
     public function setUp(): void
@@ -56,7 +58,7 @@ class AuditLogTest extends TestCase
 
     public function test_shows_name_for_deleted_items()
     {
 
     public function test_shows_name_for_deleted_items()
     {
-        $this->actingAs( $this->getAdmin());
+        $this->actingAs($this->getAdmin());
         $page = Page::query()->first();
         $pageName = $page->name;
         $this->activityService->addForEntity($page, ActivityType::PAGE_CREATE);
         $page = Page::query()->first();
         $pageName = $page->name;
         $this->activityService->addForEntity($page, ActivityType::PAGE_CREATE);
@@ -137,7 +139,5 @@ class AuditLogTest extends TestCase
         $resp = $this->actingAs($admin)->get('settings/audit?user=' . $editor->id);
         $resp->assertSeeText($chapter->name);
         $resp->assertDontSeeText($page->name);
         $resp = $this->actingAs($admin)->get('settings/audit?user=' . $editor->id);
         $resp->assertSeeText($chapter->name);
         $resp->assertDontSeeText($page->name);
-
     }
     }
-
-}
\ No newline at end of file
+}
index f88fc19044286d5c3e4b937745cff0511437ce13..febf583998d460e10440aa0ec36a2852eaa01641 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests\Auth;
+<?php
+
+namespace Tests\Auth;
 
 use BookStack\Auth\Role;
 use BookStack\Auth\User;
 
 use BookStack\Auth\Role;
 use BookStack\Auth\User;
@@ -14,7 +16,6 @@ use Tests\BrowserKitTest;
 
 class AuthTest extends BrowserKitTest
 {
 
 class AuthTest extends BrowserKitTest
 {
-
     public function test_auth_working()
     {
         $this->visit('/')
     public function test_auth_working()
     {
         $this->visit('/')
@@ -135,10 +136,10 @@ class AuthTest extends BrowserKitTest
 
         // Get confirmation and confirm notification matches
         $emailConfirmation = DB::table('email_confirmations')->where('user_id', '=', $dbUser->id)->first();
 
         // Get confirmation and confirm notification matches
         $emailConfirmation = DB::table('email_confirmations')->where('user_id', '=', $dbUser->id)->first();
-        Notification::assertSentTo($dbUser, ConfirmEmail::class, function($notification, $channels) use ($emailConfirmation) {
+        Notification::assertSentTo($dbUser, ConfirmEmail::class, function ($notification, $channels) use ($emailConfirmation) {
             return $notification->token === $emailConfirmation->token;
         });
             return $notification->token === $emailConfirmation->token;
         });
-        
+
         // Check confirmation email confirmation activation.
         $this->visit('/register/confirm/' . $emailConfirmation->token)
             ->seePageIs('/')
         // Check confirmation email confirmation activation.
         $this->visit('/register/confirm/' . $emailConfirmation->token)
             ->seePageIs('/')
@@ -278,8 +279,8 @@ class AuthTest extends BrowserKitTest
             ->press('Save')
             ->seePageIs('/settings/users');
 
             ->press('Save')
             ->seePageIs('/settings/users');
 
-            $userPassword = User::find($user->id)->password;
-            $this->assertTrue(Hash::check('newpassword', $userPassword));
+        $userPassword = User::find($user->id)->password;
+        $this->assertTrue(Hash::check('newpassword', $userPassword));
     }
 
     public function test_user_deletion()
     }
 
     public function test_user_deletion()
@@ -340,7 +341,7 @@ class AuthTest extends BrowserKitTest
             ->see('A password reset link will be sent to [email protected] if that email address is found in the system.');
 
         $this->seeInDatabase('password_resets', [
             ->see('A password reset link will be sent to [email protected] if that email address is found in the system.');
 
         $this->seeInDatabase('password_resets', [
-            'email' => '[email protected]'
+            'email' => '[email protected]',
         ]);
 
         $user = User::where('email', '=', '[email protected]')->first();
         ]);
 
         $user = User::where('email', '=', '[email protected]')->first();
@@ -351,9 +352,9 @@ class AuthTest extends BrowserKitTest
         $this->visit('/password/reset/' . $n->first()->token)
             ->see('Reset Password')
             ->submitForm('Reset Password', [
         $this->visit('/password/reset/' . $n->first()->token)
             ->see('Reset Password')
             ->submitForm('Reset Password', [
-                'email' => '[email protected]',
-                'password' => 'randompass',
-                'password_confirmation' => 'randompass'
+                'email'                 => '[email protected]',
+                'password'              => 'randompass',
+                'password_confirmation' => 'randompass',
             ])->seePageIs('/')
             ->see('Your password has been successfully reset');
     }
             ])->seePageIs('/')
             ->see('Your password has been successfully reset');
     }
@@ -367,13 +368,12 @@ class AuthTest extends BrowserKitTest
             ->see('A password reset link will be sent to [email protected] if that email address is found in the system.')
             ->dontSee('We can\'t find a user');
 
             ->see('A password reset link will be sent to [email protected] if that email address is found in the system.')
             ->dontSee('We can\'t find a user');
 
-
         $this->visit('/password/reset/arandometokenvalue')
             ->see('Reset Password')
             ->submitForm('Reset Password', [
         $this->visit('/password/reset/arandometokenvalue')
             ->see('Reset Password')
             ->submitForm('Reset Password', [
-                'email' => '[email protected]',
-                'password' => 'randompass',
-                'password_confirmation' => 'randompass'
+                'email'                 => '[email protected]',
+                'password'              => 'randompass',
+                'password_confirmation' => 'randompass',
             ])->followRedirects()
             ->seePageIs('/password/reset/arandometokenvalue')
             ->dontSee('We can\'t find a user')
             ])->followRedirects()
             ->seePageIs('/password/reset/arandometokenvalue')
             ->dontSee('We can\'t find a user')
@@ -443,7 +443,7 @@ class AuthTest extends BrowserKitTest
     }
 
     /**
     }
 
     /**
-     * Perform a login
+     * Perform a login.
      */
     protected function login(string $email, string $password): AuthTest
     {
      */
     protected function login(string $email, string $password): AuthTest
     {
index 60859e324743c059a38ccd69235b85ac11533739..9d491fd0f75b641f5b6978eadb266a7881e38372 100644 (file)
@@ -1,8 +1,10 @@
-<?php namespace Tests\Auth;
+<?php
 
 
+namespace Tests\Auth;
+
+use BookStack\Auth\Access\Ldap;
 use BookStack\Auth\Access\LdapService;
 use BookStack\Auth\Role;
 use BookStack\Auth\Access\LdapService;
 use BookStack\Auth\Role;
-use BookStack\Auth\Access\Ldap;
 use BookStack\Auth\User;
 use Mockery\MockInterface;
 use Tests\TestCase;
 use BookStack\Auth\User;
 use Mockery\MockInterface;
 use Tests\TestCase;
@@ -21,20 +23,22 @@ class LdapTest extends TestCase
     public function setUp(): void
     {
         parent::setUp();
     public function setUp(): void
     {
         parent::setUp();
-        if (!defined('LDAP_OPT_REFERRALS')) define('LDAP_OPT_REFERRALS', 1);
+        if (!defined('LDAP_OPT_REFERRALS')) {
+            define('LDAP_OPT_REFERRALS', 1);
+        }
         config()->set([
         config()->set([
-            'auth.method' => 'ldap',
-            'auth.defaults.guard' => 'ldap',
-            'services.ldap.base_dn' => 'dc=ldap,dc=local',
-            'services.ldap.email_attribute' => 'mail',
+            'auth.method'                          => 'ldap',
+            'auth.defaults.guard'                  => 'ldap',
+            'services.ldap.base_dn'                => 'dc=ldap,dc=local',
+            'services.ldap.email_attribute'        => 'mail',
             'services.ldap.display_name_attribute' => 'cn',
             'services.ldap.display_name_attribute' => 'cn',
-            'services.ldap.id_attribute' => 'uid',
-            'services.ldap.user_to_groups' => false,
-            'services.ldap.version' => '3',
-            'services.ldap.user_filter' => '(&(uid=${user}))',
-            'services.ldap.follow_referrals' => false,
-            'services.ldap.tls_insecure' => false,
-            'services.ldap.thumbnail_attribute' => null,
+            'services.ldap.id_attribute'           => 'uid',
+            'services.ldap.user_to_groups'         => false,
+            'services.ldap.version'                => '3',
+            'services.ldap.user_filter'            => '(&(uid=${user}))',
+            'services.ldap.follow_referrals'       => false,
+            'services.ldap.tls_insecure'           => false,
+            'services.ldap.thumbnail_attribute'    => null,
         ]);
         $this->mockLdap = \Mockery::mock(Ldap::class);
         $this->app[Ldap::class] = $this->mockLdap;
         ]);
         $this->mockLdap = \Mockery::mock(Ldap::class);
         $this->app[Ldap::class] = $this->mockLdap;
@@ -91,8 +95,8 @@ class LdapTest extends TestCase
             ->with($this->resourceId, config('services.ldap.base_dn'), \Mockery::type('string'), \Mockery::type('array'))
             ->andReturn(['count' => 1, 0 => [
                 'uid' => [$this->mockUser->name],
             ->with($this->resourceId, config('services.ldap.base_dn'), \Mockery::type('string'), \Mockery::type('array'))
             ->andReturn(['count' => 1, 0 => [
                 'uid' => [$this->mockUser->name],
-                'cn' => [$this->mockUser->name],
-                'dn' => ['dc=test' . config('services.ldap.base_dn')]
+                'cn'  => [$this->mockUser->name],
+                'dn'  => ['dc=test' . config('services.ldap.base_dn')],
             ]]);
 
         $resp = $this->mockUserLogin();
             ]]);
 
         $resp = $this->mockUserLogin();
@@ -105,16 +109,16 @@ class LdapTest extends TestCase
         $resp->assertElementExists('#home-default');
         $resp->assertSee($this->mockUser->name);
         $this->assertDatabaseHas('users', [
         $resp->assertElementExists('#home-default');
         $resp->assertSee($this->mockUser->name);
         $this->assertDatabaseHas('users', [
-            'email' => $this->mockUser->email,
-            'email_confirmed' => false,
-            'external_auth_id' => $this->mockUser->name
+            'email'            => $this->mockUser->email,
+            'email_confirmed'  => false,
+            'external_auth_id' => $this->mockUser->name,
         ]);
     }
 
     public function test_email_domain_restriction_active_on_new_ldap_login()
     {
         $this->setSettings([
         ]);
     }
 
     public function test_email_domain_restriction_active_on_new_ldap_login()
     {
         $this->setSettings([
-            'registration-restrict' => 'testing.com'
+            'registration-restrict' => 'testing.com',
         ]);
 
         $this->commonLdapMocks(1, 1, 2, 4, 2);
         ]);
 
         $this->commonLdapMocks(1, 1, 2, 4, 2);
@@ -122,15 +126,14 @@ class LdapTest extends TestCase
             ->with($this->resourceId, config('services.ldap.base_dn'), \Mockery::type('string'), \Mockery::type('array'))
             ->andReturn(['count' => 1, 0 => [
                 'uid' => [$this->mockUser->name],
             ->with($this->resourceId, config('services.ldap.base_dn'), \Mockery::type('string'), \Mockery::type('array'))
             ->andReturn(['count' => 1, 0 => [
                 'uid' => [$this->mockUser->name],
-                'cn' => [$this->mockUser->name],
-                'dn' => ['dc=test' . config('services.ldap.base_dn')]
+                'cn'  => [$this->mockUser->name],
+                'dn'  => ['dc=test' . config('services.ldap.base_dn')],
             ]]);
 
         $resp = $this->mockUserLogin();
         $resp->assertRedirect('/login');
         $this->followRedirects($resp)->assertSee('Please enter an email to use for this account.');
 
             ]]);
 
         $resp = $this->mockUserLogin();
         $resp->assertRedirect('/login');
         $this->followRedirects($resp)->assertSee('Please enter an email to use for this account.');
 
-
         $email = '[email protected]';
         $resp = $this->mockUserLogin($email);
         $resp->assertRedirect('/login');
         $email = '[email protected]';
         $resp = $this->mockUserLogin($email);
         $resp->assertRedirect('/login');
@@ -147,9 +150,9 @@ class LdapTest extends TestCase
         $this->mockLdap->shouldReceive('searchAndGetEntries')->times(1)
             ->with($this->resourceId, config('services.ldap.base_dn'), \Mockery::type('string'), \Mockery::type('array'))
             ->andReturn(['count' => 1, 0 => [
         $this->mockLdap->shouldReceive('searchAndGetEntries')->times(1)
             ->with($this->resourceId, config('services.ldap.base_dn'), \Mockery::type('string'), \Mockery::type('array'))
             ->andReturn(['count' => 1, 0 => [
-                'cn' => [$this->mockUser->name],
-                'dn' => $ldapDn,
-                'mail' => [$this->mockUser->email]
+                'cn'   => [$this->mockUser->name],
+                'dn'   => $ldapDn,
+                'mail' => [$this->mockUser->email],
             ]]);
 
         $resp = $this->mockUserLogin();
             ]]);
 
         $resp = $this->mockUserLogin();
@@ -167,13 +170,12 @@ class LdapTest extends TestCase
         $this->mockLdap->shouldReceive('searchAndGetEntries')->times(1)
             ->with($this->resourceId, config('services.ldap.base_dn'), \Mockery::type('string'), \Mockery::type('array'))
             ->andReturn(['count' => 1, 0 => [
         $this->mockLdap->shouldReceive('searchAndGetEntries')->times(1)
             ->with($this->resourceId, config('services.ldap.base_dn'), \Mockery::type('string'), \Mockery::type('array'))
             ->andReturn(['count' => 1, 0 => [
-                'cn' => [$this->mockUser->name],
-                'dn' => $ldapDn,
+                'cn'           => [$this->mockUser->name],
+                'dn'           => $ldapDn,
                 'my_custom_id' => ['cooluser456'],
                 'my_custom_id' => ['cooluser456'],
-                'mail' => [$this->mockUser->email]
+                'mail'         => [$this->mockUser->email],
             ]]);
 
             ]]);
 
-
         $resp = $this->mockUserLogin();
         $resp->assertRedirect('/');
         $this->followRedirects($resp)->assertSee($this->mockUser->name);
         $resp = $this->mockUserLogin();
         $resp->assertRedirect('/');
         $this->followRedirects($resp)->assertSee($this->mockUser->name);
@@ -187,8 +189,8 @@ class LdapTest extends TestCase
             ->with($this->resourceId, config('services.ldap.base_dn'), \Mockery::type('string'), \Mockery::type('array'))
             ->andReturn(['count' => 1, 0 => [
                 'uid' => [$this->mockUser->name],
             ->with($this->resourceId, config('services.ldap.base_dn'), \Mockery::type('string'), \Mockery::type('array'))
             ->andReturn(['count' => 1, 0 => [
                 'uid' => [$this->mockUser->name],
-                'cn' => [$this->mockUser->name],
-                'dn' => ['dc=test' . config('services.ldap.base_dn')]
+                'cn'  => [$this->mockUser->name],
+                'dn'  => ['dc=test' . config('services.ldap.base_dn')],
             ]]);
         $this->mockLdap->shouldReceive('bind')->times(2)->andReturn(true, false);
 
             ]]);
         $this->mockLdap->shouldReceive('bind')->times(2)->andReturn(true, false);
 
@@ -217,14 +219,14 @@ class LdapTest extends TestCase
         $userForm->assertDontSee('Password');
 
         $save = $this->post('/settings/users/create', [
         $userForm->assertDontSee('Password');
 
         $save = $this->post('/settings/users/create', [
-            'name' => $this->mockUser->name,
+            'name'  => $this->mockUser->name,
             'email' => $this->mockUser->email,
         ]);
         $save->assertSessionHasErrors(['external_auth_id' => 'The external auth id field is required.']);
 
         $save = $this->post('/settings/users/create', [
             'email' => $this->mockUser->email,
         ]);
         $save->assertSessionHasErrors(['external_auth_id' => 'The external auth id field is required.']);
 
         $save = $this->post('/settings/users/create', [
-            'name' => $this->mockUser->name,
-            'email' => $this->mockUser->email,
+            'name'             => $this->mockUser->name,
+            'email'            => $this->mockUser->email,
             'external_auth_id' => $this->mockUser->name,
         ]);
         $save->assertRedirect('/settings/users');
             'external_auth_id' => $this->mockUser->name,
         ]);
         $save->assertRedirect('/settings/users');
@@ -239,8 +241,8 @@ class LdapTest extends TestCase
         $editPage->assertDontSee('Password');
 
         $update = $this->put("/settings/users/{$editUser->id}", [
         $editPage->assertDontSee('Password');
 
         $update = $this->put("/settings/users/{$editUser->id}", [
-            'name' => $editUser->name,
-            'email' => $editUser->email,
+            'name'             => $editUser->name,
+            'email'            => $editUser->email,
             'external_auth_id' => 'test_auth_id',
         ]);
         $update->assertRedirect('/settings/users');
             'external_auth_id' => 'test_auth_id',
         ]);
         $update->assertRedirect('/settings/users');
@@ -269,8 +271,8 @@ class LdapTest extends TestCase
         $this->mockUser->attachRole($existingRole);
 
         app('config')->set([
         $this->mockUser->attachRole($existingRole);
 
         app('config')->set([
-            'services.ldap.user_to_groups' => true,
-            'services.ldap.group_attribute' => 'memberOf',
+            'services.ldap.user_to_groups'     => true,
+            'services.ldap.group_attribute'    => 'memberOf',
             'services.ldap.remove_from_groups' => false,
         ]);
 
             'services.ldap.remove_from_groups' => false,
         ]);
 
@@ -278,15 +280,15 @@ class LdapTest extends TestCase
         $this->mockLdap->shouldReceive('searchAndGetEntries')->times(4)
             ->with($this->resourceId, config('services.ldap.base_dn'), \Mockery::type('string'), \Mockery::type('array'))
             ->andReturn(['count' => 1, 0 => [
         $this->mockLdap->shouldReceive('searchAndGetEntries')->times(4)
             ->with($this->resourceId, config('services.ldap.base_dn'), \Mockery::type('string'), \Mockery::type('array'))
             ->andReturn(['count' => 1, 0 => [
-                'uid' => [$this->mockUser->name],
-                'cn' => [$this->mockUser->name],
-                'dn' => ['dc=test' . config('services.ldap.base_dn')],
-                'mail' => [$this->mockUser->email],
+                'uid'      => [$this->mockUser->name],
+                'cn'       => [$this->mockUser->name],
+                'dn'       => ['dc=test' . config('services.ldap.base_dn')],
+                'mail'     => [$this->mockUser->email],
                 'memberof' => [
                     'count' => 2,
                 'memberof' => [
                     'count' => 2,
-                    0 => "cn=ldaptester,ou=groups,dc=example,dc=com",
-                    1 => "cn=ldaptester-second,ou=groups,dc=example,dc=com",
-                ]
+                    0       => 'cn=ldaptester,ou=groups,dc=example,dc=com',
+                    1       => 'cn=ldaptester-second,ou=groups,dc=example,dc=com',
+                ],
             ]]);
 
         $this->mockUserLogin()->assertRedirect('/');
             ]]);
 
         $this->mockUserLogin()->assertRedirect('/');
@@ -294,15 +296,15 @@ class LdapTest extends TestCase
         $user = User::where('email', $this->mockUser->email)->first();
         $this->assertDatabaseHas('role_user', [
             'user_id' => $user->id,
         $user = User::where('email', $this->mockUser->email)->first();
         $this->assertDatabaseHas('role_user', [
             'user_id' => $user->id,
-            'role_id' => $roleToReceive->id
+            'role_id' => $roleToReceive->id,
         ]);
         $this->assertDatabaseHas('role_user', [
             'user_id' => $user->id,
         ]);
         $this->assertDatabaseHas('role_user', [
             'user_id' => $user->id,
-            'role_id' => $roleToReceive2->id
+            'role_id' => $roleToReceive2->id,
         ]);
         $this->assertDatabaseHas('role_user', [
             'user_id' => $user->id,
         ]);
         $this->assertDatabaseHas('role_user', [
             'user_id' => $user->id,
-            'role_id' => $existingRole->id
+            'role_id' => $existingRole->id,
         ]);
     }
 
         ]);
     }
 
@@ -314,8 +316,8 @@ class LdapTest extends TestCase
         $this->mockUser->attachRole($existingRole);
 
         app('config')->set([
         $this->mockUser->attachRole($existingRole);
 
         app('config')->set([
-            'services.ldap.user_to_groups' => true,
-            'services.ldap.group_attribute' => 'memberOf',
+            'services.ldap.user_to_groups'     => true,
+            'services.ldap.group_attribute'    => 'memberOf',
             'services.ldap.remove_from_groups' => true,
         ]);
 
             'services.ldap.remove_from_groups' => true,
         ]);
 
@@ -323,14 +325,14 @@ class LdapTest extends TestCase
         $this->mockLdap->shouldReceive('searchAndGetEntries')->times(3)
             ->with($this->resourceId, config('services.ldap.base_dn'), \Mockery::type('string'), \Mockery::type('array'))
             ->andReturn(['count' => 1, 0 => [
         $this->mockLdap->shouldReceive('searchAndGetEntries')->times(3)
             ->with($this->resourceId, config('services.ldap.base_dn'), \Mockery::type('string'), \Mockery::type('array'))
             ->andReturn(['count' => 1, 0 => [
-                'uid' => [$this->mockUser->name],
-                'cn' => [$this->mockUser->name],
-                'dn' => ['dc=test' . config('services.ldap.base_dn')],
-                'mail' => [$this->mockUser->email],
+                'uid'      => [$this->mockUser->name],
+                'cn'       => [$this->mockUser->name],
+                'dn'       => ['dc=test' . config('services.ldap.base_dn')],
+                'mail'     => [$this->mockUser->email],
                 'memberof' => [
                     'count' => 1,
                 'memberof' => [
                     'count' => 1,
-                    0 => "cn=ldaptester,ou=groups,dc=example,dc=com",
-                ]
+                    0       => 'cn=ldaptester,ou=groups,dc=example,dc=com',
+                ],
             ]]);
 
         $this->mockUserLogin()->assertRedirect('/');
             ]]);
 
         $this->mockUserLogin()->assertRedirect('/');
@@ -338,11 +340,11 @@ class LdapTest extends TestCase
         $user = User::query()->where('email', $this->mockUser->email)->first();
         $this->assertDatabaseHas('role_user', [
             'user_id' => $user->id,
         $user = User::query()->where('email', $this->mockUser->email)->first();
         $this->assertDatabaseHas('role_user', [
             'user_id' => $user->id,
-            'role_id' => $roleToReceive->id
+            'role_id' => $roleToReceive->id,
         ]);
         $this->assertDatabaseMissing('role_user', [
             'user_id' => $user->id,
         ]);
         $this->assertDatabaseMissing('role_user', [
             'user_id' => $user->id,
-            'role_id' => $existingRole->id
+            'role_id' => $existingRole->id,
         ]);
     }
 
         ]);
     }
 
@@ -359,8 +361,8 @@ class LdapTest extends TestCase
         $roleToNotReceive = factory(Role::class)->create(['display_name' => 'ex-auth-a', 'external_auth_id' => 'test-second-param']);
 
         app('config')->set([
         $roleToNotReceive = factory(Role::class)->create(['display_name' => 'ex-auth-a', 'external_auth_id' => 'test-second-param']);
 
         app('config')->set([
-            'services.ldap.user_to_groups' => true,
-            'services.ldap.group_attribute' => 'memberOf',
+            'services.ldap.user_to_groups'     => true,
+            'services.ldap.group_attribute'    => 'memberOf',
             'services.ldap.remove_from_groups' => true,
         ]);
 
             'services.ldap.remove_from_groups' => true,
         ]);
 
@@ -368,14 +370,14 @@ class LdapTest extends TestCase
         $this->mockLdap->shouldReceive('searchAndGetEntries')->times(3)
             ->with($this->resourceId, config('services.ldap.base_dn'), \Mockery::type('string'), \Mockery::type('array'))
             ->andReturn(['count' => 1, 0 => [
         $this->mockLdap->shouldReceive('searchAndGetEntries')->times(3)
             ->with($this->resourceId, config('services.ldap.base_dn'), \Mockery::type('string'), \Mockery::type('array'))
             ->andReturn(['count' => 1, 0 => [
-                'uid' => [$this->mockUser->name],
-                'cn' => [$this->mockUser->name],
-                'dn' => ['dc=test' . config('services.ldap.base_dn')],
-                'mail' => [$this->mockUser->email],
+                'uid'      => [$this->mockUser->name],
+                'cn'       => [$this->mockUser->name],
+                'dn'       => ['dc=test' . config('services.ldap.base_dn')],
+                'mail'     => [$this->mockUser->email],
                 'memberof' => [
                     'count' => 1,
                 'memberof' => [
                     'count' => 1,
-                    0 => "cn=ex-auth-a,ou=groups,dc=example,dc=com",
-                ]
+                    0       => 'cn=ex-auth-a,ou=groups,dc=example,dc=com',
+                ],
             ]]);
 
         $this->mockUserLogin()->assertRedirect('/');
             ]]);
 
         $this->mockUserLogin()->assertRedirect('/');
@@ -383,11 +385,11 @@ class LdapTest extends TestCase
         $user = User::query()->where('email', $this->mockUser->email)->first();
         $this->assertDatabaseHas('role_user', [
             'user_id' => $user->id,
         $user = User::query()->where('email', $this->mockUser->email)->first();
         $this->assertDatabaseHas('role_user', [
             'user_id' => $user->id,
-            'role_id' => $roleToReceive->id
+            'role_id' => $roleToReceive->id,
         ]);
         $this->assertDatabaseMissing('role_user', [
             'user_id' => $user->id,
         ]);
         $this->assertDatabaseMissing('role_user', [
             'user_id' => $user->id,
-            'role_id' => $roleToNotReceive->id
+            'role_id' => $roleToNotReceive->id,
         ]);
     }
 
         ]);
     }
 
@@ -400,8 +402,8 @@ class LdapTest extends TestCase
         setting()->put('registration-role', $roleToReceive->id);
 
         app('config')->set([
         setting()->put('registration-role', $roleToReceive->id);
 
         app('config')->set([
-            'services.ldap.user_to_groups' => true,
-            'services.ldap.group_attribute' => 'memberOf',
+            'services.ldap.user_to_groups'     => true,
+            'services.ldap.group_attribute'    => 'memberOf',
             'services.ldap.remove_from_groups' => true,
         ]);
 
             'services.ldap.remove_from_groups' => true,
         ]);
 
@@ -409,15 +411,15 @@ class LdapTest extends TestCase
         $this->mockLdap->shouldReceive('searchAndGetEntries')->times(4)
             ->with($this->resourceId, config('services.ldap.base_dn'), \Mockery::type('string'), \Mockery::type('array'))
             ->andReturn(['count' => 1, 0 => [
         $this->mockLdap->shouldReceive('searchAndGetEntries')->times(4)
             ->with($this->resourceId, config('services.ldap.base_dn'), \Mockery::type('string'), \Mockery::type('array'))
             ->andReturn(['count' => 1, 0 => [
-                'uid' => [$this->mockUser->name],
-                'cn' => [$this->mockUser->name],
-                'dn' => ['dc=test' . config('services.ldap.base_dn')],
-                'mail' => [$this->mockUser->email],
+                'uid'      => [$this->mockUser->name],
+                'cn'       => [$this->mockUser->name],
+                'dn'       => ['dc=test' . config('services.ldap.base_dn')],
+                'mail'     => [$this->mockUser->email],
                 'memberof' => [
                     'count' => 2,
                 'memberof' => [
                     'count' => 2,
-                    0 => "cn=ldaptester,ou=groups,dc=example,dc=com",
-                    1 => "cn=ldaptester-second,ou=groups,dc=example,dc=com",
-                ]
+                    0       => 'cn=ldaptester,ou=groups,dc=example,dc=com',
+                    1       => 'cn=ldaptester-second,ou=groups,dc=example,dc=com',
+                ],
             ]]);
 
         $this->mockUserLogin()->assertRedirect('/');
             ]]);
 
         $this->mockUserLogin()->assertRedirect('/');
@@ -425,28 +427,28 @@ class LdapTest extends TestCase
         $user = User::query()->where('email', $this->mockUser->email)->first();
         $this->assertDatabaseHas('role_user', [
             'user_id' => $user->id,
         $user = User::query()->where('email', $this->mockUser->email)->first();
         $this->assertDatabaseHas('role_user', [
             'user_id' => $user->id,
-            'role_id' => $roleToReceive->id
+            'role_id' => $roleToReceive->id,
         ]);
         $this->assertDatabaseHas('role_user', [
             'user_id' => $user->id,
         ]);
         $this->assertDatabaseHas('role_user', [
             'user_id' => $user->id,
-            'role_id' => $roleToReceive2->id
+            'role_id' => $roleToReceive2->id,
         ]);
     }
 
     public function test_login_uses_specified_display_name_attribute()
     {
         app('config')->set([
         ]);
     }
 
     public function test_login_uses_specified_display_name_attribute()
     {
         app('config')->set([
-            'services.ldap.display_name_attribute' => 'displayName'
+            'services.ldap.display_name_attribute' => 'displayName',
         ]);
 
         $this->commonLdapMocks(1, 1, 2, 4, 2);
         $this->mockLdap->shouldReceive('searchAndGetEntries')->times(2)
             ->with($this->resourceId, config('services.ldap.base_dn'), \Mockery::type('string'), \Mockery::type('array'))
             ->andReturn(['count' => 1, 0 => [
         ]);
 
         $this->commonLdapMocks(1, 1, 2, 4, 2);
         $this->mockLdap->shouldReceive('searchAndGetEntries')->times(2)
             ->with($this->resourceId, config('services.ldap.base_dn'), \Mockery::type('string'), \Mockery::type('array'))
             ->andReturn(['count' => 1, 0 => [
-                'uid' => [$this->mockUser->name],
-                'cn' => [$this->mockUser->name],
-                'dn' => ['dc=test' . config('services.ldap.base_dn')],
-                'displayname' => 'displayNameAttribute'
+                'uid'         => [$this->mockUser->name],
+                'cn'          => [$this->mockUser->name],
+                'dn'          => ['dc=test' . config('services.ldap.base_dn')],
+                'displayname' => 'displayNameAttribute',
             ]]);
 
         $this->mockUserLogin()->assertRedirect('/login');
             ]]);
 
         $this->mockUserLogin()->assertRedirect('/login');
@@ -461,7 +463,7 @@ class LdapTest extends TestCase
     public function test_login_uses_default_display_name_attribute_if_specified_not_present()
     {
         app('config')->set([
     public function test_login_uses_default_display_name_attribute_if_specified_not_present()
     {
         app('config')->set([
-            'services.ldap.display_name_attribute' => 'displayName'
+            'services.ldap.display_name_attribute' => 'displayName',
         ]);
 
         $this->commonLdapMocks(1, 1, 2, 4, 2);
         ]);
 
         $this->commonLdapMocks(1, 1, 2, 4, 2);
@@ -469,8 +471,8 @@ class LdapTest extends TestCase
             ->with($this->resourceId, config('services.ldap.base_dn'), \Mockery::type('string'), \Mockery::type('array'))
             ->andReturn(['count' => 1, 0 => [
                 'uid' => [$this->mockUser->name],
             ->with($this->resourceId, config('services.ldap.base_dn'), \Mockery::type('string'), \Mockery::type('array'))
             ->andReturn(['count' => 1, 0 => [
                 'uid' => [$this->mockUser->name],
-                'cn' => [$this->mockUser->name],
-                'dn' => ['dc=test' . config('services.ldap.base_dn')]
+                'cn'  => [$this->mockUser->name],
+                'dn'  => ['dc=test' . config('services.ldap.base_dn')],
             ]]);
 
         $this->mockUserLogin()->assertRedirect('/login');
             ]]);
 
         $this->mockUserLogin()->assertRedirect('/login');
@@ -480,25 +482,25 @@ class LdapTest extends TestCase
         $resp->assertRedirect('/');
         $this->get('/')->assertSee($this->mockUser->name);
         $this->assertDatabaseHas('users', [
         $resp->assertRedirect('/');
         $this->get('/')->assertSee($this->mockUser->name);
         $this->assertDatabaseHas('users', [
-            'email' => $this->mockUser->email,
-            'email_confirmed' => false,
+            'email'            => $this->mockUser->email,
+            'email_confirmed'  => false,
             'external_auth_id' => $this->mockUser->name,
             'external_auth_id' => $this->mockUser->name,
-            'name' => $this->mockUser->name
+            'name'             => $this->mockUser->name,
         ]);
     }
 
     protected function checkLdapReceivesCorrectDetails($serverString, $expectedHost, $expectedPort)
     {
         app('config')->set([
         ]);
     }
 
     protected function checkLdapReceivesCorrectDetails($serverString, $expectedHost, $expectedPort)
     {
         app('config')->set([
-            'services.ldap.server' => $serverString
+            'services.ldap.server' => $serverString,
         ]);
 
         // Standard mocks
         $this->commonLdapMocks(0, 1, 1, 2, 1);
         $this->mockLdap->shouldReceive('searchAndGetEntries')->times(1)->andReturn(['count' => 1, 0 => [
             'uid' => [$this->mockUser->name],
         ]);
 
         // Standard mocks
         $this->commonLdapMocks(0, 1, 1, 2, 1);
         $this->mockLdap->shouldReceive('searchAndGetEntries')->times(1)->andReturn(['count' => 1, 0 => [
             'uid' => [$this->mockUser->name],
-            'cn' => [$this->mockUser->name],
-            'dn' => ['dc=test' . config('services.ldap.base_dn')]
+            'cn'  => [$this->mockUser->name],
+            'dn'  => ['dc=test' . config('services.ldap.base_dn')],
         ]]);
 
         $this->mockLdap->shouldReceive('connect')->once()
         ]]);
 
         $this->mockLdap->shouldReceive('connect')->once()
@@ -564,8 +566,8 @@ class LdapTest extends TestCase
             ->with($this->resourceId, config('services.ldap.base_dn'), \Mockery::type('string'), \Mockery::type('array'))
             ->andReturn(['count' => 1, 0 => [
                 'uid' => [$this->mockUser->name],
             ->with($this->resourceId, config('services.ldap.base_dn'), \Mockery::type('string'), \Mockery::type('array'))
             ->andReturn(['count' => 1, 0 => [
                 'uid' => [$this->mockUser->name],
-                'cn' => [$this->mockUser->name],
-                'dn' => ['dc=test' . config('services.ldap.base_dn')]
+                'cn'  => [$this->mockUser->name],
+                'dn'  => ['dc=test' . config('services.ldap.base_dn')],
             ]]);
 
         $resp = $this->post('/login', [
             ]]);
 
         $resp = $this->post('/login', [
@@ -573,7 +575,7 @@ class LdapTest extends TestCase
             'password' => $this->mockUser->password,
         ]);
         $resp->assertJsonStructure([
             'password' => $this->mockUser->password,
         ]);
         $resp->assertJsonStructure([
-            'details_from_ldap' => [],
+            'details_from_ldap'        => [],
             'details_bookstack_parsed' => [],
         ]);
     }
             'details_bookstack_parsed' => [],
         ]);
     }
@@ -603,8 +605,8 @@ class LdapTest extends TestCase
             ->with($this->resourceId, config('services.ldap.base_dn'), \Mockery::type('string'), ['cn', 'dn', 'uid', 'mail', 'cn'])
             ->andReturn(['count' => 1, 0 => [
                 'uid' => [hex2bin('FFF8F7')],
             ->with($this->resourceId, config('services.ldap.base_dn'), \Mockery::type('string'), ['cn', 'dn', 'uid', 'mail', 'cn'])
             ->andReturn(['count' => 1, 0 => [
                 'uid' => [hex2bin('FFF8F7')],
-                'cn' => [$this->mockUser->name],
-                'dn' => ['dc=test' . config('services.ldap.base_dn')]
+                'cn'  => [$this->mockUser->name],
+                'dn'  => ['dc=test' . config('services.ldap.base_dn')],
             ]]);
 
         $details = $ldapService->getUserDetails('test');
             ]]);
 
         $details = $ldapService->getUserDetails('test');
@@ -617,14 +619,14 @@ class LdapTest extends TestCase
         $this->mockLdap->shouldReceive('searchAndGetEntries')->times(2)
             ->with($this->resourceId, config('services.ldap.base_dn'), \Mockery::type('string'), \Mockery::type('array'))
             ->andReturn(['count' => 1, 0 => [
         $this->mockLdap->shouldReceive('searchAndGetEntries')->times(2)
             ->with($this->resourceId, config('services.ldap.base_dn'), \Mockery::type('string'), \Mockery::type('array'))
             ->andReturn(['count' => 1, 0 => [
-                'uid' => [$this->mockUser->name],
-                'cn' => [$this->mockUser->name],
-                'dn' => ['dc=test' . config('services.ldap.base_dn')],
+                'uid'  => [$this->mockUser->name],
+                'cn'   => [$this->mockUser->name],
+                'dn'   => ['dc=test' . config('services.ldap.base_dn')],
                 'mail' => '[email protected]',
             ]], ['count' => 1, 0 => [
                 'mail' => '[email protected]',
             ]], ['count' => 1, 0 => [
-                'uid' => ['Barry'],
-                'cn' => ['Scott'],
-                'dn' => ['dc=bscott' . config('services.ldap.base_dn')],
+                'uid'  => ['Barry'],
+                'cn'   => ['Scott'],
+                'dn'   => ['dc=bscott' . config('services.ldap.base_dn')],
                 'mail' => '[email protected]',
             ]]);
 
                 'mail' => '[email protected]',
             ]]);
 
@@ -644,8 +646,8 @@ class LdapTest extends TestCase
         setting()->put('registration-confirmation', 'true');
 
         app('config')->set([
         setting()->put('registration-confirmation', 'true');
 
         app('config')->set([
-            'services.ldap.user_to_groups' => true,
-            'services.ldap.group_attribute' => 'memberOf',
+            'services.ldap.user_to_groups'     => true,
+            'services.ldap.group_attribute'    => 'memberOf',
             'services.ldap.remove_from_groups' => true,
         ]);
 
             'services.ldap.remove_from_groups' => true,
         ]);
 
@@ -653,26 +655,26 @@ class LdapTest extends TestCase
         $this->mockLdap->shouldReceive('searchAndGetEntries')
             ->times(3)
             ->andReturn(['count' => 1, 0 => [
         $this->mockLdap->shouldReceive('searchAndGetEntries')
             ->times(3)
             ->andReturn(['count' => 1, 0 => [
-                'uid' => [$user->name],
-                'cn' => [$user->name],
-                'dn' => ['dc=test' . config('services.ldap.base_dn')],
-                'mail' => [$user->email],
+                'uid'      => [$user->name],
+                'cn'       => [$user->name],
+                'dn'       => ['dc=test' . config('services.ldap.base_dn')],
+                'mail'     => [$user->email],
                 'memberof' => [
                     'count' => 1,
                 'memberof' => [
                     'count' => 1,
-                    0 => "cn=ldaptester,ou=groups,dc=example,dc=com",
-                ]
+                    0       => 'cn=ldaptester,ou=groups,dc=example,dc=com',
+                ],
             ]]);
 
         $this->followingRedirects()->mockUserLogin()->assertSee('Thanks for registering!');
         $this->assertDatabaseHas('users', [
             ]]);
 
         $this->followingRedirects()->mockUserLogin()->assertSee('Thanks for registering!');
         $this->assertDatabaseHas('users', [
-            'email' => $user->email,
+            'email'           => $user->email,
             'email_confirmed' => false,
         ]);
 
         $user = User::query()->where('email', '=', $user->email)->first();
         $this->assertDatabaseHas('role_user', [
             'user_id' => $user->id,
             'email_confirmed' => false,
         ]);
 
         $user = User::query()->where('email', '=', $user->email)->first();
         $this->assertDatabaseHas('role_user', [
             'user_id' => $user->id,
-            'role_id' => $roleToReceive->id
+            'role_id' => $roleToReceive->id,
         ]);
 
         $homePage = $this->get('/');
         ]);
 
         $homePage = $this->get('/');
@@ -696,11 +698,11 @@ class LdapTest extends TestCase
         $this->mockLdap->shouldReceive('searchAndGetEntries')->times(1)
             ->with($this->resourceId, config('services.ldap.base_dn'), \Mockery::type('string'), \Mockery::type('array'))
             ->andReturn(['count' => 1, 0 => [
         $this->mockLdap->shouldReceive('searchAndGetEntries')->times(1)
             ->with($this->resourceId, config('services.ldap.base_dn'), \Mockery::type('string'), \Mockery::type('array'))
             ->andReturn(['count' => 1, 0 => [
-                'cn' => [$this->mockUser->name],
-                'dn' => $ldapDn,
+                'cn'        => [$this->mockUser->name],
+                'dn'        => $ldapDn,
                 'jpegphoto' => [base64_decode('/9j/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8Q
 EBEQCgwSExIQEw8QEBD/yQALCAABAAEBAREA/8wABgAQEAX/2gAIAQEAAD8A0s8g/9k=')],
                 'jpegphoto' => [base64_decode('/9j/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8Q
 EBEQCgwSExIQEw8QEBD/yQALCAABAAEBAREA/8wABgAQEAX/2gAIAQEAAD8A0s8g/9k=')],
-                'mail' => [$this->mockUser->email]
+                'mail' => [$this->mockUser->email],
             ]]);
 
         $this->mockUserLogin()
             ]]);
 
         $this->mockUserLogin()
index b6b02e2f76d8aef7a65493bfda7449b8ca5271dd..096f862e7c94c2244477322b23b37702a54389b7 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests\Auth;
+<?php
+
+namespace Tests\Auth;
 
 use BookStack\Auth\Role;
 use BookStack\Auth\User;
 
 use BookStack\Auth\Role;
 use BookStack\Auth\User;
@@ -6,28 +8,27 @@ use Tests\TestCase;
 
 class Saml2Test extends TestCase
 {
 
 class Saml2Test extends TestCase
 {
-
     public function setUp(): void
     {
         parent::setUp();
         // Set default config for SAML2
         config()->set([
     public function setUp(): void
     {
         parent::setUp();
         // Set default config for SAML2
         config()->set([
-            'auth.method' => 'saml2',
-            'auth.defaults.guard' => 'saml2',
-            'saml2.name' => 'SingleSignOn-Testing',
-            'saml2.email_attribute' => 'email',
-            'saml2.display_name_attributes' => ['first_name', 'last_name'],
-            'saml2.external_id_attribute' => 'uid',
-            'saml2.user_to_groups' => false,
-            'saml2.group_attribute' => 'user_groups',
-            'saml2.remove_from_groups' => false,
-            'saml2.onelogin_overrides' => null,
-            'saml2.onelogin.idp.entityId' => 'http://saml.local/saml2/idp/metadata.php',
-            'saml2.onelogin.idp.singleSignOnService.url' => 'http://saml.local/saml2/idp/SSOService.php',
-            'saml2.onelogin.idp.singleLogoutService.url' => 'http://saml.local/saml2/idp/SingleLogoutService.php',
-            'saml2.autoload_from_metadata' => false,
-            'saml2.onelogin.idp.x509cert' => $this->testCert,
-            'saml2.onelogin.debug' => false,
+            'auth.method'                                   => 'saml2',
+            'auth.defaults.guard'                           => 'saml2',
+            'saml2.name'                                    => 'SingleSignOn-Testing',
+            'saml2.email_attribute'                         => 'email',
+            'saml2.display_name_attributes'                 => ['first_name', 'last_name'],
+            'saml2.external_id_attribute'                   => 'uid',
+            'saml2.user_to_groups'                          => false,
+            'saml2.group_attribute'                         => 'user_groups',
+            'saml2.remove_from_groups'                      => false,
+            'saml2.onelogin_overrides'                      => null,
+            'saml2.onelogin.idp.entityId'                   => 'http://saml.local/saml2/idp/metadata.php',
+            'saml2.onelogin.idp.singleSignOnService.url'    => 'http://saml.local/saml2/idp/SSOService.php',
+            'saml2.onelogin.idp.singleLogoutService.url'    => 'http://saml.local/saml2/idp/SingleLogoutService.php',
+            'saml2.autoload_from_metadata'                  => false,
+            'saml2.onelogin.idp.x509cert'                   => $this->testCert,
+            'saml2.onelogin.debug'                          => false,
             'saml2.onelogin.security.requestedAuthnContext' => true,
         ]);
     }
             'saml2.onelogin.security.requestedAuthnContext' => true,
         ]);
     }
@@ -68,25 +69,23 @@ class Saml2Test extends TestCase
         $this->assertFalse($this->isAuthenticated());
 
         $this->withPost(['SAMLResponse' => $this->acsPostData], function () {
         $this->assertFalse($this->isAuthenticated());
 
         $this->withPost(['SAMLResponse' => $this->acsPostData], function () {
-
             $acsPost = $this->post('/saml2/acs');
             $acsPost->assertRedirect('/');
             $this->assertTrue($this->isAuthenticated());
             $this->assertDatabaseHas('users', [
             $acsPost = $this->post('/saml2/acs');
             $acsPost->assertRedirect('/');
             $this->assertTrue($this->isAuthenticated());
             $this->assertDatabaseHas('users', [
-                'email' => '[email protected]',
+                'email'            => '[email protected]',
                 'external_auth_id' => 'user',
                 'external_auth_id' => 'user',
-                'email_confirmed' => false,
-                'name' => 'Barry Scott'
+                'email_confirmed'  => false,
+                'name'             => 'Barry Scott',
             ]);
             ]);
-
         });
     }
 
     public function test_group_role_sync_on_login()
     {
         config()->set([
         });
     }
 
     public function test_group_role_sync_on_login()
     {
         config()->set([
-            'saml2.onelogin.strict' => false,
-            'saml2.user_to_groups' => true,
+            'saml2.onelogin.strict'    => false,
+            'saml2.user_to_groups'     => true,
             'saml2.remove_from_groups' => false,
         ]);
 
             'saml2.remove_from_groups' => false,
         ]);
 
@@ -106,8 +105,8 @@ class Saml2Test extends TestCase
     public function test_group_role_sync_removal_option_works_as_expected()
     {
         config()->set([
     public function test_group_role_sync_removal_option_works_as_expected()
     {
         config()->set([
-            'saml2.onelogin.strict' => false,
-            'saml2.user_to_groups' => true,
+            'saml2.onelogin.strict'    => false,
+            'saml2.user_to_groups'     => true,
             'saml2.remove_from_groups' => true,
         ]);
 
             'saml2.remove_from_groups' => true,
         ]);
 
@@ -165,7 +164,7 @@ class Saml2Test extends TestCase
     public function test_logout_sls_flow_when_sls_not_configured()
     {
         config()->set([
     public function test_logout_sls_flow_when_sls_not_configured()
     {
         config()->set([
-            'saml2.onelogin.strict' => false,
+            'saml2.onelogin.strict'                      => false,
             'saml2.onelogin.idp.singleLogoutService.url' => null,
         ]);
 
             'saml2.onelogin.idp.singleLogoutService.url' => null,
         ]);
 
@@ -183,7 +182,7 @@ class Saml2Test extends TestCase
     public function test_dump_user_details_option_works()
     {
         config()->set([
     public function test_dump_user_details_option_works()
     {
         config()->set([
-            'saml2.onelogin.strict' => false,
+            'saml2.onelogin.strict'   => false,
             'saml2.dump_user_details' => true,
         ]);
 
             'saml2.dump_user_details' => true,
         ]);
 
@@ -191,7 +190,7 @@ class Saml2Test extends TestCase
             $acsPost = $this->post('/saml2/acs');
             $acsPost->assertJsonStructure([
                 'id_from_idp',
             $acsPost = $this->post('/saml2/acs');
             $acsPost->assertJsonStructure([
                 'id_from_idp',
-                'attrs_from_idp' => [],
+                'attrs_from_idp'      => [],
                 'attrs_after_parsing' => [],
             ]);
         });
                 'attrs_after_parsing' => [],
             ]);
         });
@@ -258,7 +257,7 @@ class Saml2Test extends TestCase
     public function test_email_domain_restriction_active_on_new_saml_login()
     {
         $this->setSettings([
     public function test_email_domain_restriction_active_on_new_saml_login()
     {
         $this->setSettings([
-            'registration-restrict' => 'testing.com'
+            'registration-restrict' => 'testing.com',
         ]);
         config()->set([
             'saml2.onelogin.strict' => false,
         ]);
         config()->set([
             'saml2.onelogin.strict' => false,
@@ -277,8 +276,8 @@ class Saml2Test extends TestCase
     {
         setting()->put('registration-confirmation', 'true');
         config()->set([
     {
         setting()->put('registration-confirmation', 'true');
         config()->set([
-            'saml2.onelogin.strict' => false,
-            'saml2.user_to_groups' => true,
+            'saml2.onelogin.strict'    => false,
+            'saml2.user_to_groups'     => true,
             'saml2.remove_from_groups' => false,
         ]);
 
             'saml2.remove_from_groups' => false,
         ]);
 
@@ -309,10 +308,10 @@ class Saml2Test extends TestCase
 
         // Make the user pre-existing in DB with different auth_id
         User::query()->forceCreate([
 
         // Make the user pre-existing in DB with different auth_id
         User::query()->forceCreate([
-            'email' => '[email protected]',
+            'email'            => '[email protected]',
             'external_auth_id' => 'old_system_user_id',
             'external_auth_id' => 'old_system_user_id',
-            'email_confirmed' => false,
-            'name' => 'Barry Scott'
+            'email_confirmed'  => false,
+            'name'             => 'Barry Scott',
         ]);
 
         $this->withPost(['SAMLResponse' => $this->acsPostData], function () {
         ]);
 
         $this->withPost(['SAMLResponse' => $this->acsPostData], function () {
@@ -320,12 +319,12 @@ class Saml2Test extends TestCase
             $acsPost->assertRedirect('/login');
             $this->assertFalse($this->isAuthenticated());
             $this->assertDatabaseHas('users', [
             $acsPost->assertRedirect('/login');
             $this->assertFalse($this->isAuthenticated());
             $this->assertDatabaseHas('users', [
-                'email' => '[email protected]',
+                'email'            => '[email protected]',
                 'external_auth_id' => 'old_system_user_id',
             ]);
 
             $loginGet = $this->get('/login');
                 'external_auth_id' => 'old_system_user_id',
             ]);
 
             $loginGet = $this->get('/login');
-            $loginGet->assertSee("A user with the email [email protected] already exists but with different credentials");
+            $loginGet->assertSee('A user with the email [email protected] already exists but with different credentials');
         });
     }
 
         });
     }
 
@@ -360,6 +359,7 @@ class Saml2Test extends TestCase
         $query = explode('?', $location)[1];
         $params = [];
         parse_str($query, $params);
         $query = explode('?', $location)[1];
         $params = [];
         parse_str($query, $params);
+
         return gzinflate(base64_decode($params['SAMLRequest']));
     }
 
         return gzinflate(base64_decode($params['SAMLRequest']));
     }
 
@@ -397,23 +397,23 @@ class Saml2Test extends TestCase
      * The post data for a callback for single-sign-in.
      * Provides the following attributes:
      * array:5 [
      * The post data for a callback for single-sign-in.
      * Provides the following attributes:
      * array:5 [
-        "uid" => array:1 [
-            0 => "user"
-        ]
-        "first_name" => array:1 [
-            0 => "Barry"
-        ]
-        "last_name" => array:1 [
-            0 => "Scott"
-        ]
-        "email" => array:1 [
-            0 => "[email protected]"
-        ]
-        "user_groups" => array:2 [
-            0 => "member"
-            1 => "admin"
-        ]
-    ]
+     * "uid" => array:1 [
+     * 0 => "user"
+     * ]
+     * "first_name" => array:1 [
+     * 0 => "Barry"
+     * ]
+     * "last_name" => array:1 [
+     * 0 => "Scott"
+     * ]
+     * "email" => array:1 [
+     * 0 => "[email protected]"
+     * ]
+     * "user_groups" => array:2 [
+     * 0 => "member"
+     * 1 => "admin"
+     * ]
+     * ].
      */
     protected $acsPostData = 'PHNhbWxwOlJlc3BvbnNlIHhtbG5zOnNhbWxwPSJ1cm46b2FzaXM6bmFtZXM6dGM6U0FNTDoyLjA6cHJvdG9jb2wiIHhtbG5zOnNhbWw9InVybjpvYXNpczpuYW1lczp0YzpTQU1MOjIuMDphc3NlcnRpb24iIElEPSJfNGRkNDU2NGRjNzk0MDYxZWYxYmFhMDQ2N2Q3OTAyOGNlZDNjZTU0YmVlIiBWZXJzaW9uPSIyLjAiIElzc3VlSW5zdGFudD0iMjAxOS0xMS0xN1QxNzo1MzozOVoiIERlc3RpbmF0aW9uPSJodHRwOi8vYm9va3N0YWNrLmxvY2FsL3NhbWwyL2FjcyIgSW5SZXNwb25zZVRvPSJPTkVMT0dJTl82YTBmNGYzOTkzMDQwZjE5ODdmZDM3MDY4YjUyOTYyMjlhZDUzNjFjIj48c2FtbDpJc3N1ZXI+aHR0cDovL3NhbWwubG9jYWwvc2FtbDIvaWRwL21ldGFkYXRhLnBocDwvc2FtbDpJc3N1ZXI+PGRzOlNpZ25hdHVyZSB4bWxuczpkcz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC8wOS94bWxkc2lnIyI+CiAgPGRzOlNpZ25lZEluZm8+PGRzOkNhbm9uaWNhbGl6YXRpb25NZXRob2QgQWxnb3JpdGhtPSJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzEwL3htbC1leGMtYzE0biMiLz4KICAgIDxkczpTaWduYXR1cmVNZXRob2QgQWxnb3JpdGhtPSJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzA0L3htbGRzaWctbW9yZSNyc2Etc2hhMjU2Ii8+CiAgPGRzOlJlZmVyZW5jZSBVUkk9IiNfNGRkNDU2NGRjNzk0MDYxZWYxYmFhMDQ2N2Q3OTAyOGNlZDNjZTU0YmVlIj48ZHM6VHJhbnNmb3Jtcz48ZHM6VHJhbnNmb3JtIEFsZ29yaXRobT0iaHR0cDovL3d3dy53My5vcmcvMjAwMC8wOS94bWxkc2lnI2VudmVsb3BlZC1zaWduYXR1cmUiLz48ZHM6VHJhbnNmb3JtIEFsZ29yaXRobT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS8xMC94bWwtZXhjLWMxNG4jIi8+PC9kczpUcmFuc2Zvcm1zPjxkczpEaWdlc3RNZXRob2QgQWxnb3JpdGhtPSJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzA0L3htbGVuYyNzaGEyNTYiLz48ZHM6RGlnZXN0VmFsdWU+dm1oL1M3NU5mK2crZWNESkN6QWJaV0tKVmx1ZzdCZnNDKzlhV05lSXJlUT08L2RzOkRpZ2VzdFZhbHVlPjwvZHM6UmVmZXJlbmNlPjwvZHM6U2lnbmVkSW5mbz48ZHM6U2lnbmF0dXJlVmFsdWU+dnJhZ0tKWHNjVm5UNjJFaEk3bGk4MERUWHNOTGJOc3lwNWZ2QnU4WjFYSEtFUVA3QWpPNkcxcVBwaGpWQ2dRMzd6TldVVTZvUytQeFA3UDlHeG5xL3hKejRUT3lHcHJ5N1RoK2pIcHc0YWVzQTdrTmp6VU51UmU2c1ltWTlrRXh2VjMvTmJRZjROMlM2Y2RhRHIzWFRodllVVDcxYzQwNVVHOFJpQjJaY3liWHIxZU1yWCtXUDBnU2Qrc0F2RExqTjBJc3pVWlVUNThadFpEVE1ya1ZGL0pIbFBFQ04vVW1sYVBBeitTcUJ4c25xTndZK1oxYUt3MnlqeFRlNnUxM09Kb29OOVN1REowNE0rK2F3RlY3NkI4cXEyTzMxa3FBbDJibm1wTGxtTWdRNFEraUlnL3dCc09abTV1clphOWJObDNLVEhtTVBXbFpkbWhsLzgvMy9IT1RxN2thWGs3cnlWRHRLcFlsZ3FUajNhRUpuL0dwM2o4SFp5MUVialRiOTRRT1ZQMG5IQzB1V2hCaE13TjdzVjFrUSsxU2NjUlpUZXJKSGlSVUQvR0srTVg3M0YrbzJVTFRIL1Z6Tm9SM2o4N2hOLzZ1UC9JeG5aM1RudGR1MFZPZS9ucEdVWjBSMG9SWFhwa2JTL2poNWk1ZjU0RXN4eXZ1VEM5NHdKaEM8L2RzOlNpZ25hdHVyZVZhbHVlPgo8ZHM6S2V5SW5mbz48ZHM6WDUwOURhdGE+PGRzOlg1MDlDZXJ0aWZpY2F0ZT5NSUlFYXpDQ0F0T2dBd0lCQWdJVWU3YTA4OENucjRpem1ybkJFbng1cTNIVE12WXdEUVlKS29aSWh2Y05BUUVMQlFBd1JURUxNQWtHQTFVRUJoTUNSMEl4RXpBUkJnTlZCQWdNQ2xOdmJXVXRVM1JoZEdVeElUQWZCZ05WQkFvTUdFbHVkR1Z5Ym1WMElGZHBaR2RwZEhNZ1VIUjVJRXgwWkRBZUZ3MHhPVEV4TVRZeE1qRTNNVFZhRncweU9URXhNVFV4TWpFM01UVmFNRVV4Q3pBSkJnTlZCQVlUQWtkQ01STXdFUVlEVlFRSURBcFRiMjFsTFZOMFlYUmxNU0V3SHdZRFZRUUtEQmhKYm5SbGNtNWxkQ0JYYVdSbmFYUnpJRkIwZVNCTWRHUXdnZ0dpTUEwR0NTcUdTSWIzRFFFQkFRVUFBNElCandBd2dnR0tBb0lCZ1FEekxlOUZmZHlwbFR4SHA0U3VROWdRdFpUM3QrU0RmdkVMNzJwcENmRlp3NytCNXM1Qi9UNzNhWHBvUTNTNTNwR0kxUklXQ2dlMmlDVVEydHptMjdhU05IMGl1OWFKWWNVUVovUklUcWQwYXl5RGtzMU5BMlBUM1RXNnQzbTdLVjVyZTRQME5iK1lEZXV5SGRreitqY010cG44Q21Cb1QwSCtza2hhMGhpcUlOa2prUlBpSHZMSFZHcCt0SFVFQS9JNm1ONGFCL1VFeFNUTHM3OU5zTFVmdGVxcXhlOSt0dmRVYVRveURQcmhQRmpPTnMrOU5LQ2t6SUM2dmN2N0o2QXR1S0c2bkVUK3pCOXlPV2d0R1lRaWZYcVFBMnk1ZEw4MUJCMHE1dU1hQkxTMnBxM2FQUGp6VTJGMytFeXNqeVNXVG5Da2ZrN0M1U3NDWFJ1OFErVTk1dHVucE5md2Y1b2xFNldhczQ4Tk1NK1B3VjdpQ05NUGtOemxscTZQQ2lNK1A4RHJNU2N6elVaWlFVU3Y2ZFN3UENvK1lTVmltRU0wT2czWEpUaU5oUTVBTmxhSW42Nkt3NWdmb0JmdWlYbXlJS2lTRHlBaURZbUZhZjQzOTV3V3dMa1RSK2N3OFdmamFIc3dLWlRvbW4xTVIzT0pzWTJVSjBlUkJZTStZU3NDQXdFQUFhTlRNRkV3SFFZRFZSME9CQllFRkltcDJDWUNHZmNiN3c5MUgvY1NoVENrWHdSL01COEdBMVVkSXdRWU1CYUFGSW1wMkNZQ0dmY2I3dzkxSC9jU2hUQ2tYd1IvTUE4R0ExVWRFd0VCL3dRRk1BTUJBZjh3RFFZSktvWklodmNOQVFFTEJRQURnZ0dCQUErZy9DN3VMOWxuK1crcUJrbkxXODFrb2pZZmxnUEsxSTFNSEl3bk12bC9aVEhYNGRSWEtEcms3S2NVcTFLanFhak5WNjZmMWNha3AwM0lpakJpTzBYaTFnWFVaWUxvQ2lOR1V5eXA5WGxvaUl5OVh3MlBpV25ydzAreVp5dlZzc2JlaFhYWUpsNFJpaEJqQld1bDlSNHdNWUxPVVNKRGUyV3hjVUJoSm54eU5ScytQMHhMU1FYNkIybjZueG9Ea280cDA3czhaS1hRa2VpWjJpd0ZkVHh6UmtHanRoTVV2NzA0bnpzVkdCVDBEQ1B0ZlNhTzVLSlpXMXJDczN5aU10aG5CeHE0cUVET1FKRklsKy9MRDcxS2JCOXZaY1c1SnVhdnpCRm1rS0dOcm8vNkcxSTdlbDQ2SVI0d2lqVHlORkNZVXVEOWR0aWduTm1wV3ROOE9XK3B0aUwvanRUeVNXdWtqeXMwcyt2TG44M0NWdmpCMGRKdFZBSVlPZ1hGZEl1aWk2Nmdjend3TS9MR2lPRXhKbjBkVE56c0ovSVlocHhMNEZCRXVQMHBza1kwbzBhVWxKMkxTMmord1NRVFJLc0JnTWp5clVyZWtsZTJPRFN0U3RuM2VhYmpJeDAvRkhscEZyMGpOSW0vb01QN2t3anRVWDR6YU5lNDdRSTRHZz09PC9kczpYNTA5Q2VydGlmaWNhdGU+PC9kczpYNTA5RGF0YT48L2RzOktleUluZm8+PC9kczpTaWduYXR1cmU+PHNhbWxwOlN0YXR1cz48c2FtbHA6U3RhdHVzQ29kZSBWYWx1ZT0idXJuOm9hc2lzOm5hbWVzOnRjOlNBTUw6Mi4wOnN0YXR1czpTdWNjZXNzIi8+PC9zYW1scDpTdGF0dXM+PHNhbWw6QXNzZXJ0aW9uIHhtbG5zOnhzaT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEtaW5zdGFuY2UiIHhtbG5zOnhzPSJodHRwOi8vd3d3LnczLm9yZy8yMDAxL1hNTFNjaGVtYSIgSUQ9Il82ODQyZGY5YzY1OWYxM2ZlNTE5NmNkOWVmNmMyZjAyODM2NGFlOTQzYjEiIFZlcnNpb249IjIuMCIgSXNzdWVJbnN0YW50PSIyMDE5LTExLTE3VDE3OjUzOjM5WiI+PHNhbWw6SXNzdWVyPmh0dHA6Ly9zYW1sLmxvY2FsL3NhbWwyL2lkcC9tZXRhZGF0YS5waHA8L3NhbWw6SXNzdWVyPjxkczpTaWduYXR1cmUgeG1sbnM6ZHM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvMDkveG1sZHNpZyMiPgogIDxkczpTaWduZWRJbmZvPjxkczpDYW5vbmljYWxpemF0aW9uTWV0aG9kIEFsZ29yaXRobT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS8xMC94bWwtZXhjLWMxNG4jIi8+CiAgICA8ZHM6U2lnbmF0dXJlTWV0aG9kIEFsZ29yaXRobT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS8wNC94bWxkc2lnLW1vcmUjcnNhLXNoYTI1NiIvPgogIDxkczpSZWZlcmVuY2UgVVJJPSIjXzY4NDJkZjljNjU5ZjEzZmU1MTk2Y2Q5ZWY2YzJmMDI4MzY0YWU5NDNiMSI+PGRzOlRyYW5zZm9ybXM+PGRzOlRyYW5zZm9ybSBBbGdvcml0aG09Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvMDkveG1sZHNpZyNlbnZlbG9wZWQtc2lnbmF0dXJlIi8+PGRzOlRyYW5zZm9ybSBBbGdvcml0aG09Imh0dHA6Ly93d3cudzMub3JnLzIwMDEvMTAveG1sLWV4Yy1jMTRuIyIvPjwvZHM6VHJhbnNmb3Jtcz48ZHM6RGlnZXN0TWV0aG9kIEFsZ29yaXRobT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS8wNC94bWxlbmMjc2hhMjU2Ii8+PGRzOkRpZ2VzdFZhbHVlPmtyYjV3NlM4dG9YYy9lU3daUFVPQnZRem4zb3M0SkFDdXh4ckpreHBnRnc9PC9kczpEaWdlc3RWYWx1ZT48L2RzOlJlZmVyZW5jZT48L2RzOlNpZ25lZEluZm8+PGRzOlNpZ25hdHVyZVZhbHVlPjJxcW1Ba3hucXhOa3N5eXh5dnFTVDUxTDg5VS9ZdHpja2t1ekF4ci9hQ1JTK1NPRzg1YkFNWm8vU3puc3d0TVlBYlFRQ0VGb0R1amdNdlpzSFl3NlR2dmFHanlXWUpRNVZyYWhlemZaSWlCVUU0NHBtWGFrOCswV0l0WTVndnBGSXhxWFZaRmdFUkt2VExmZVFCMzhkMVZQc0ZVZ0RYdXQ4VS9Qdm43dXZwdXZjVXorMUUyOUVKR2FZL0dndnhUN0tyWU9SQTh3SitNdVRzUVZtanNlUnhveVJTejA4TmJ3ZTJIOGpXQnpFWWNxWWwyK0ZnK2hwNWd0S216VmhLRnBkNXZBNjdBSXo1NXN0QmNHNSswNHJVaWpFSzRzci9xa0x5QmtKQjdLdkwzanZKcG8zQjhxYkxYeXhLb1dSSmRnazhKNHMvTVp1QWk3QWUxUXNTTjl2Z3ZTdVRlc0VCUjVpSHJuS1lrbEpRWXNrbUQzbSsremE4U1NRbnBlM0UzYUZBY3p6cElUdUQ4YkFCWmRqcUk2TkhrSmFRQXBmb0hWNVQrZ244ejdUTWsrSStUU2JlQURubUxCS3lnMHRabW10L0ZKbDV6eWowVmxwc1dzTVM2OVE2bUZJVStqcEhSanpOb2FLMVM1dlQ3ZW1HbUhKSUp0cWlOdXJRN0tkQlBJPC9kczpTaWduYXR1cmVWYWx1ZT4KPGRzOktleUluZm8+PGRzOlg1MDlEYXRhPjxkczpYNTA5Q2VydGlmaWNhdGU+TUlJRWF6Q0NBdE9nQXdJQkFnSVVlN2EwODhDbnI0aXptcm5CRW54NXEzSFRNdll3RFFZSktvWklodmNOQVFFTEJRQXdSVEVMTUFrR0ExVUVCaE1DUjBJeEV6QVJCZ05WQkFnTUNsTnZiV1V0VTNSaGRHVXhJVEFmQmdOVkJBb01HRWx1ZEdWeWJtVjBJRmRwWkdkcGRITWdVSFI1SUV4MFpEQWVGdzB4T1RFeE1UWXhNakUzTVRWYUZ3MHlPVEV4TVRVeE1qRTNNVFZhTUVVeEN6QUpCZ05WQkFZVEFrZENNUk13RVFZRFZRUUlEQXBUYjIxbExWTjBZWFJsTVNFd0h3WURWUVFLREJoSmJuUmxjbTVsZENCWGFXUm5hWFJ6SUZCMGVTQk1kR1F3Z2dHaU1BMEdDU3FHU0liM0RRRUJBUVVBQTRJQmp3QXdnZ0dLQW9JQmdRRHpMZTlGZmR5cGxUeEhwNFN1UTlnUXRaVDN0K1NEZnZFTDcycHBDZkZadzcrQjVzNUIvVDczYVhwb1EzUzUzcEdJMVJJV0NnZTJpQ1VRMnR6bTI3YVNOSDBpdTlhSlljVVFaL1JJVHFkMGF5eURrczFOQTJQVDNUVzZ0M203S1Y1cmU0UDBOYitZRGV1eUhka3oramNNdHBuOENtQm9UMEgrc2toYTBoaXFJTmtqa1JQaUh2TEhWR3ArdEhVRUEvSTZtTjRhQi9VRXhTVExzNzlOc0xVZnRlcXF4ZTkrdHZkVWFUb3lEUHJoUEZqT05zKzlOS0NreklDNnZjdjdKNkF0dUtHNm5FVCt6Qjl5T1dndEdZUWlmWHFRQTJ5NWRMODFCQjBxNXVNYUJMUzJwcTNhUFBqelUyRjMrRXlzanlTV1RuQ2tmazdDNVNzQ1hSdThRK1U5NXR1bnBOZndmNW9sRTZXYXM0OE5NTStQd1Y3aUNOTVBrTnpsbHE2UENpTStQOERyTVNjenpVWlpRVVN2NmRTd1BDbytZU1ZpbUVNME9nM1hKVGlOaFE1QU5sYUluNjZLdzVnZm9CZnVpWG15SUtpU0R5QWlEWW1GYWY0Mzk1d1d3TGtUUitjdzhXZmphSHN3S1pUb21uMU1SM09Kc1kyVUowZVJCWU0rWVNzQ0F3RUFBYU5UTUZFd0hRWURWUjBPQkJZRUZJbXAyQ1lDR2ZjYjd3OTFIL2NTaFRDa1h3Ui9NQjhHQTFVZEl3UVlNQmFBRkltcDJDWUNHZmNiN3c5MUgvY1NoVENrWHdSL01BOEdBMVVkRXdFQi93UUZNQU1CQWY4d0RRWUpLb1pJaHZjTkFRRUxCUUFEZ2dHQkFBK2cvQzd1TDlsbitXK3FCa25MVzgxa29qWWZsZ1BLMUkxTUhJd25NdmwvWlRIWDRkUlhLRHJrN0tjVXExS2pxYWpOVjY2ZjFjYWtwMDNJaWpCaU8wWGkxZ1hVWllMb0NpTkdVeXlwOVhsb2lJeTlYdzJQaVducncwK3laeXZWc3NiZWhYWFlKbDRSaWhCakJXdWw5UjR3TVlMT1VTSkRlMld4Y1VCaEpueHlOUnMrUDB4TFNRWDZCMm42bnhvRGtvNHAwN3M4WktYUWtlaVoyaXdGZFR4elJrR2p0aE1VdjcwNG56c1ZHQlQwRENQdGZTYU81S0paVzFyQ3MzeWlNdGhuQnhxNHFFRE9RSkZJbCsvTEQ3MUtiQjl2WmNXNUp1YXZ6QkZta0tHTnJvLzZHMUk3ZWw0NklSNHdpalR5TkZDWVV1RDlkdGlnbk5tcFd0TjhPVytwdGlML2p0VHlTV3VranlzMHMrdkxuODNDVnZqQjBkSnRWQUlZT2dYRmRJdWlpNjZnY3p3d00vTEdpT0V4Sm4wZFROenNKL0lZaHB4TDRGQkV1UDBwc2tZMG8wYVVsSjJMUzJqK3dTUVRSS3NCZ01qeXJVcmVrbGUyT0RTdFN0bjNlYWJqSXgwL0ZIbHBGcjBqTkltL29NUDdrd2p0VVg0emFOZTQ3UUk0R2c9PTwvZHM6WDUwOUNlcnRpZmljYXRlPjwvZHM6WDUwOURhdGE+PC9kczpLZXlJbmZvPjwvZHM6U2lnbmF0dXJlPjxzYW1sOlN1YmplY3Q+PHNhbWw6TmFtZUlEIFNQTmFtZVF1YWxpZmllcj0iaHR0cDovL2Jvb2tzdGFjay5sb2NhbC9zYW1sMi9tZXRhZGF0YSIgRm9ybWF0PSJ1cm46b2FzaXM6bmFtZXM6dGM6U0FNTDoyLjA6bmFtZWlkLWZvcm1hdDp0cmFuc2llbnQiPl8yYzdhYjg2ZWI4ZjFkMTA2MzQ0M2YyMTljYzU4NjhmZjY2NzA4OTEyZTM8L3NhbWw6TmFtZUlEPjxzYW1sOlN1YmplY3RDb25maXJtYXRpb24gTWV0aG9kPSJ1cm46b2FzaXM6bmFtZXM6dGM6U0FNTDoyLjA6Y206YmVhcmVyIj48c2FtbDpTdWJqZWN0Q29uZmlybWF0aW9uRGF0YSBOb3RPbk9yQWZ0ZXI9IjIwMTktMTEtMTdUMTc6NTg6MzlaIiBSZWNpcGllbnQ9Imh0dHA6Ly9ib29rc3RhY2subG9jYWwvc2FtbDIvYWNzIiBJblJlc3BvbnNlVG89Ik9ORUxPR0lOXzZhMGY0ZjM5OTMwNDBmMTk4N2ZkMzcwNjhiNTI5NjIyOWFkNTM2MWMiLz48L3NhbWw6U3ViamVjdENvbmZpcm1hdGlvbj48L3NhbWw6U3ViamVjdD48c2FtbDpDb25kaXRpb25zIE5vdEJlZm9yZT0iMjAxOS0xMS0xN1QxNzo1MzowOVoiIE5vdE9uT3JBZnRlcj0iMjAxOS0xMS0xN1QxNzo1ODozOVoiPjxzYW1sOkF1ZGllbmNlUmVzdHJpY3Rpb24+PHNhbWw6QXVkaWVuY2U+aHR0cDovL2Jvb2tzdGFjay5sb2NhbC9zYW1sMi9tZXRhZGF0YTwvc2FtbDpBdWRpZW5jZT48L3NhbWw6QXVkaWVuY2VSZXN0cmljdGlvbj48L3NhbWw6Q29uZGl0aW9ucz48c2FtbDpBdXRoblN0YXRlbWVudCBBdXRobkluc3RhbnQ9IjIwMTktMTEtMTdUMTc6NTM6MzlaIiBTZXNzaW9uTm90T25PckFmdGVyPSIyMDE5LTExLTE4VDAxOjUzOjM5WiIgU2Vzc2lvbkluZGV4PSJfNGZlN2MwZDE1NzJkNjRiMjdmOTMwYWE2ZjIzNmE2ZjQyZTkzMDkwMWNjIj48c2FtbDpBdXRobkNvbnRleHQ+PHNhbWw6QXV0aG5Db250ZXh0Q2xhc3NSZWY+dXJuOm9hc2lzOm5hbWVzOnRjOlNBTUw6Mi4wOmFjOmNsYXNzZXM6UGFzc3dvcmQ8L3NhbWw6QXV0aG5Db250ZXh0Q2xhc3NSZWY+PC9zYW1sOkF1dGhuQ29udGV4dD48L3NhbWw6QXV0aG5TdGF0ZW1lbnQ+PHNhbWw6QXR0cmlidXRlU3RhdGVtZW50PjxzYW1sOkF0dHJpYnV0ZSBOYW1lPSJ1aWQiIE5hbWVGb3JtYXQ9InVybjpvYXNpczpuYW1lczp0YzpTQU1MOjIuMDphdHRybmFtZS1mb3JtYXQ6YmFzaWMiPjxzYW1sOkF0dHJpYnV0ZVZhbHVlIHhzaTp0eXBlPSJ4czpzdHJpbmciPnVzZXI8L3NhbWw6QXR0cmlidXRlVmFsdWU+PC9zYW1sOkF0dHJpYnV0ZT48c2FtbDpBdHRyaWJ1dGUgTmFtZT0iZmlyc3RfbmFtZSIgTmFtZUZvcm1hdD0idXJuOm9hc2lzOm5hbWVzOnRjOlNBTUw6Mi4wOmF0dHJuYW1lLWZvcm1hdDpiYXNpYyI+PHNhbWw6QXR0cmlidXRlVmFsdWUgeHNpOnR5cGU9InhzOnN0cmluZyI+QmFycnk8L3NhbWw6QXR0cmlidXRlVmFsdWU+PC9zYW1sOkF0dHJpYnV0ZT48c2FtbDpBdHRyaWJ1dGUgTmFtZT0ibGFzdF9uYW1lIiBOYW1lRm9ybWF0PSJ1cm46b2FzaXM6bmFtZXM6dGM6U0FNTDoyLjA6YXR0cm5hbWUtZm9ybWF0OmJhc2ljIj48c2FtbDpBdHRyaWJ1dGVWYWx1ZSB4c2k6dHlwZT0ieHM6c3RyaW5nIj5TY290dDwvc2FtbDpBdHRyaWJ1dGVWYWx1ZT48L3NhbWw6QXR0cmlidXRlPjxzYW1sOkF0dHJpYnV0ZSBOYW1lPSJlbWFpbCIgTmFtZUZvcm1hdD0idXJuOm9hc2lzOm5hbWVzOnRjOlNBTUw6Mi4wOmF0dHJuYW1lLWZvcm1hdDpiYXNpYyI+PHNhbWw6QXR0cmlidXRlVmFsdWUgeHNpOnR5cGU9InhzOnN0cmluZyI+dXNlckBleGFtcGxlLmNvbTwvc2FtbDpBdHRyaWJ1dGVWYWx1ZT48L3NhbWw6QXR0cmlidXRlPjxzYW1sOkF0dHJpYnV0ZSBOYW1lPSJ1c2VyX2dyb3VwcyIgTmFtZUZvcm1hdD0idXJuOm9hc2lzOm5hbWVzOnRjOlNBTUw6Mi4wOmF0dHJuYW1lLWZvcm1hdDpiYXNpYyI+PHNhbWw6QXR0cmlidXRlVmFsdWUgeHNpOnR5cGU9InhzOnN0cmluZyI+bWVtYmVyPC9zYW1sOkF0dHJpYnV0ZVZhbHVlPjxzYW1sOkF0dHJpYnV0ZVZhbHVlIHhzaTp0eXBlPSJ4czpzdHJpbmciPmFkbWluPC9zYW1sOkF0dHJpYnV0ZVZhbHVlPjwvc2FtbDpBdHRyaWJ1dGU+PC9zYW1sOkF0dHJpYnV0ZVN0YXRlbWVudD48L3NhbWw6QXNzZXJ0aW9uPjwvc2FtbHA6UmVzcG9uc2U+';
 
      */
     protected $acsPostData = 'PHNhbWxwOlJlc3BvbnNlIHhtbG5zOnNhbWxwPSJ1cm46b2FzaXM6bmFtZXM6dGM6U0FNTDoyLjA6cHJvdG9jb2wiIHhtbG5zOnNhbWw9InVybjpvYXNpczpuYW1lczp0YzpTQU1MOjIuMDphc3NlcnRpb24iIElEPSJfNGRkNDU2NGRjNzk0MDYxZWYxYmFhMDQ2N2Q3OTAyOGNlZDNjZTU0YmVlIiBWZXJzaW9uPSIyLjAiIElzc3VlSW5zdGFudD0iMjAxOS0xMS0xN1QxNzo1MzozOVoiIERlc3RpbmF0aW9uPSJodHRwOi8vYm9va3N0YWNrLmxvY2FsL3NhbWwyL2FjcyIgSW5SZXNwb25zZVRvPSJPTkVMT0dJTl82YTBmNGYzOTkzMDQwZjE5ODdmZDM3MDY4YjUyOTYyMjlhZDUzNjFjIj48c2FtbDpJc3N1ZXI+aHR0cDovL3NhbWwubG9jYWwvc2FtbDIvaWRwL21ldGFkYXRhLnBocDwvc2FtbDpJc3N1ZXI+PGRzOlNpZ25hdHVyZSB4bWxuczpkcz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC8wOS94bWxkc2lnIyI+CiAgPGRzOlNpZ25lZEluZm8+PGRzOkNhbm9uaWNhbGl6YXRpb25NZXRob2QgQWxnb3JpdGhtPSJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzEwL3htbC1leGMtYzE0biMiLz4KICAgIDxkczpTaWduYXR1cmVNZXRob2QgQWxnb3JpdGhtPSJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzA0L3htbGRzaWctbW9yZSNyc2Etc2hhMjU2Ii8+CiAgPGRzOlJlZmVyZW5jZSBVUkk9IiNfNGRkNDU2NGRjNzk0MDYxZWYxYmFhMDQ2N2Q3OTAyOGNlZDNjZTU0YmVlIj48ZHM6VHJhbnNmb3Jtcz48ZHM6VHJhbnNmb3JtIEFsZ29yaXRobT0iaHR0cDovL3d3dy53My5vcmcvMjAwMC8wOS94bWxkc2lnI2VudmVsb3BlZC1zaWduYXR1cmUiLz48ZHM6VHJhbnNmb3JtIEFsZ29yaXRobT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS8xMC94bWwtZXhjLWMxNG4jIi8+PC9kczpUcmFuc2Zvcm1zPjxkczpEaWdlc3RNZXRob2QgQWxnb3JpdGhtPSJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzA0L3htbGVuYyNzaGEyNTYiLz48ZHM6RGlnZXN0VmFsdWU+dm1oL1M3NU5mK2crZWNESkN6QWJaV0tKVmx1ZzdCZnNDKzlhV05lSXJlUT08L2RzOkRpZ2VzdFZhbHVlPjwvZHM6UmVmZXJlbmNlPjwvZHM6U2lnbmVkSW5mbz48ZHM6U2lnbmF0dXJlVmFsdWU+dnJhZ0tKWHNjVm5UNjJFaEk3bGk4MERUWHNOTGJOc3lwNWZ2QnU4WjFYSEtFUVA3QWpPNkcxcVBwaGpWQ2dRMzd6TldVVTZvUytQeFA3UDlHeG5xL3hKejRUT3lHcHJ5N1RoK2pIcHc0YWVzQTdrTmp6VU51UmU2c1ltWTlrRXh2VjMvTmJRZjROMlM2Y2RhRHIzWFRodllVVDcxYzQwNVVHOFJpQjJaY3liWHIxZU1yWCtXUDBnU2Qrc0F2RExqTjBJc3pVWlVUNThadFpEVE1ya1ZGL0pIbFBFQ04vVW1sYVBBeitTcUJ4c25xTndZK1oxYUt3MnlqeFRlNnUxM09Kb29OOVN1REowNE0rK2F3RlY3NkI4cXEyTzMxa3FBbDJibm1wTGxtTWdRNFEraUlnL3dCc09abTV1clphOWJObDNLVEhtTVBXbFpkbWhsLzgvMy9IT1RxN2thWGs3cnlWRHRLcFlsZ3FUajNhRUpuL0dwM2o4SFp5MUVialRiOTRRT1ZQMG5IQzB1V2hCaE13TjdzVjFrUSsxU2NjUlpUZXJKSGlSVUQvR0srTVg3M0YrbzJVTFRIL1Z6Tm9SM2o4N2hOLzZ1UC9JeG5aM1RudGR1MFZPZS9ucEdVWjBSMG9SWFhwa2JTL2poNWk1ZjU0RXN4eXZ1VEM5NHdKaEM8L2RzOlNpZ25hdHVyZVZhbHVlPgo8ZHM6S2V5SW5mbz48ZHM6WDUwOURhdGE+PGRzOlg1MDlDZXJ0aWZpY2F0ZT5NSUlFYXpDQ0F0T2dBd0lCQWdJVWU3YTA4OENucjRpem1ybkJFbng1cTNIVE12WXdEUVlKS29aSWh2Y05BUUVMQlFBd1JURUxNQWtHQTFVRUJoTUNSMEl4RXpBUkJnTlZCQWdNQ2xOdmJXVXRVM1JoZEdVeElUQWZCZ05WQkFvTUdFbHVkR1Z5Ym1WMElGZHBaR2RwZEhNZ1VIUjVJRXgwWkRBZUZ3MHhPVEV4TVRZeE1qRTNNVFZhRncweU9URXhNVFV4TWpFM01UVmFNRVV4Q3pBSkJnTlZCQVlUQWtkQ01STXdFUVlEVlFRSURBcFRiMjFsTFZOMFlYUmxNU0V3SHdZRFZRUUtEQmhKYm5SbGNtNWxkQ0JYYVdSbmFYUnpJRkIwZVNCTWRHUXdnZ0dpTUEwR0NTcUdTSWIzRFFFQkFRVUFBNElCandBd2dnR0tBb0lCZ1FEekxlOUZmZHlwbFR4SHA0U3VROWdRdFpUM3QrU0RmdkVMNzJwcENmRlp3NytCNXM1Qi9UNzNhWHBvUTNTNTNwR0kxUklXQ2dlMmlDVVEydHptMjdhU05IMGl1OWFKWWNVUVovUklUcWQwYXl5RGtzMU5BMlBUM1RXNnQzbTdLVjVyZTRQME5iK1lEZXV5SGRreitqY010cG44Q21Cb1QwSCtza2hhMGhpcUlOa2prUlBpSHZMSFZHcCt0SFVFQS9JNm1ONGFCL1VFeFNUTHM3OU5zTFVmdGVxcXhlOSt0dmRVYVRveURQcmhQRmpPTnMrOU5LQ2t6SUM2dmN2N0o2QXR1S0c2bkVUK3pCOXlPV2d0R1lRaWZYcVFBMnk1ZEw4MUJCMHE1dU1hQkxTMnBxM2FQUGp6VTJGMytFeXNqeVNXVG5Da2ZrN0M1U3NDWFJ1OFErVTk1dHVucE5md2Y1b2xFNldhczQ4Tk1NK1B3VjdpQ05NUGtOemxscTZQQ2lNK1A4RHJNU2N6elVaWlFVU3Y2ZFN3UENvK1lTVmltRU0wT2czWEpUaU5oUTVBTmxhSW42Nkt3NWdmb0JmdWlYbXlJS2lTRHlBaURZbUZhZjQzOTV3V3dMa1RSK2N3OFdmamFIc3dLWlRvbW4xTVIzT0pzWTJVSjBlUkJZTStZU3NDQXdFQUFhTlRNRkV3SFFZRFZSME9CQllFRkltcDJDWUNHZmNiN3c5MUgvY1NoVENrWHdSL01COEdBMVVkSXdRWU1CYUFGSW1wMkNZQ0dmY2I3dzkxSC9jU2hUQ2tYd1IvTUE4R0ExVWRFd0VCL3dRRk1BTUJBZjh3RFFZSktvWklodmNOQVFFTEJRQURnZ0dCQUErZy9DN3VMOWxuK1crcUJrbkxXODFrb2pZZmxnUEsxSTFNSEl3bk12bC9aVEhYNGRSWEtEcms3S2NVcTFLanFhak5WNjZmMWNha3AwM0lpakJpTzBYaTFnWFVaWUxvQ2lOR1V5eXA5WGxvaUl5OVh3MlBpV25ydzAreVp5dlZzc2JlaFhYWUpsNFJpaEJqQld1bDlSNHdNWUxPVVNKRGUyV3hjVUJoSm54eU5ScytQMHhMU1FYNkIybjZueG9Ea280cDA3czhaS1hRa2VpWjJpd0ZkVHh6UmtHanRoTVV2NzA0bnpzVkdCVDBEQ1B0ZlNhTzVLSlpXMXJDczN5aU10aG5CeHE0cUVET1FKRklsKy9MRDcxS2JCOXZaY1c1SnVhdnpCRm1rS0dOcm8vNkcxSTdlbDQ2SVI0d2lqVHlORkNZVXVEOWR0aWduTm1wV3ROOE9XK3B0aUwvanRUeVNXdWtqeXMwcyt2TG44M0NWdmpCMGRKdFZBSVlPZ1hGZEl1aWk2Nmdjend3TS9MR2lPRXhKbjBkVE56c0ovSVlocHhMNEZCRXVQMHBza1kwbzBhVWxKMkxTMmord1NRVFJLc0JnTWp5clVyZWtsZTJPRFN0U3RuM2VhYmpJeDAvRkhscEZyMGpOSW0vb01QN2t3anRVWDR6YU5lNDdRSTRHZz09PC9kczpYNTA5Q2VydGlmaWNhdGU+PC9kczpYNTA5RGF0YT48L2RzOktleUluZm8+PC9kczpTaWduYXR1cmU+PHNhbWxwOlN0YXR1cz48c2FtbHA6U3RhdHVzQ29kZSBWYWx1ZT0idXJuOm9hc2lzOm5hbWVzOnRjOlNBTUw6Mi4wOnN0YXR1czpTdWNjZXNzIi8+PC9zYW1scDpTdGF0dXM+PHNhbWw6QXNzZXJ0aW9uIHhtbG5zOnhzaT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEtaW5zdGFuY2UiIHhtbG5zOnhzPSJodHRwOi8vd3d3LnczLm9yZy8yMDAxL1hNTFNjaGVtYSIgSUQ9Il82ODQyZGY5YzY1OWYxM2ZlNTE5NmNkOWVmNmMyZjAyODM2NGFlOTQzYjEiIFZlcnNpb249IjIuMCIgSXNzdWVJbnN0YW50PSIyMDE5LTExLTE3VDE3OjUzOjM5WiI+PHNhbWw6SXNzdWVyPmh0dHA6Ly9zYW1sLmxvY2FsL3NhbWwyL2lkcC9tZXRhZGF0YS5waHA8L3NhbWw6SXNzdWVyPjxkczpTaWduYXR1cmUgeG1sbnM6ZHM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvMDkveG1sZHNpZyMiPgogIDxkczpTaWduZWRJbmZvPjxkczpDYW5vbmljYWxpemF0aW9uTWV0aG9kIEFsZ29yaXRobT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS8xMC94bWwtZXhjLWMxNG4jIi8+CiAgICA8ZHM6U2lnbmF0dXJlTWV0aG9kIEFsZ29yaXRobT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS8wNC94bWxkc2lnLW1vcmUjcnNhLXNoYTI1NiIvPgogIDxkczpSZWZlcmVuY2UgVVJJPSIjXzY4NDJkZjljNjU5ZjEzZmU1MTk2Y2Q5ZWY2YzJmMDI4MzY0YWU5NDNiMSI+PGRzOlRyYW5zZm9ybXM+PGRzOlRyYW5zZm9ybSBBbGdvcml0aG09Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvMDkveG1sZHNpZyNlbnZlbG9wZWQtc2lnbmF0dXJlIi8+PGRzOlRyYW5zZm9ybSBBbGdvcml0aG09Imh0dHA6Ly93d3cudzMub3JnLzIwMDEvMTAveG1sLWV4Yy1jMTRuIyIvPjwvZHM6VHJhbnNmb3Jtcz48ZHM6RGlnZXN0TWV0aG9kIEFsZ29yaXRobT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS8wNC94bWxlbmMjc2hhMjU2Ii8+PGRzOkRpZ2VzdFZhbHVlPmtyYjV3NlM4dG9YYy9lU3daUFVPQnZRem4zb3M0SkFDdXh4ckpreHBnRnc9PC9kczpEaWdlc3RWYWx1ZT48L2RzOlJlZmVyZW5jZT48L2RzOlNpZ25lZEluZm8+PGRzOlNpZ25hdHVyZVZhbHVlPjJxcW1Ba3hucXhOa3N5eXh5dnFTVDUxTDg5VS9ZdHpja2t1ekF4ci9hQ1JTK1NPRzg1YkFNWm8vU3puc3d0TVlBYlFRQ0VGb0R1amdNdlpzSFl3NlR2dmFHanlXWUpRNVZyYWhlemZaSWlCVUU0NHBtWGFrOCswV0l0WTVndnBGSXhxWFZaRmdFUkt2VExmZVFCMzhkMVZQc0ZVZ0RYdXQ4VS9Qdm43dXZwdXZjVXorMUUyOUVKR2FZL0dndnhUN0tyWU9SQTh3SitNdVRzUVZtanNlUnhveVJTejA4TmJ3ZTJIOGpXQnpFWWNxWWwyK0ZnK2hwNWd0S216VmhLRnBkNXZBNjdBSXo1NXN0QmNHNSswNHJVaWpFSzRzci9xa0x5QmtKQjdLdkwzanZKcG8zQjhxYkxYeXhLb1dSSmRnazhKNHMvTVp1QWk3QWUxUXNTTjl2Z3ZTdVRlc0VCUjVpSHJuS1lrbEpRWXNrbUQzbSsremE4U1NRbnBlM0UzYUZBY3p6cElUdUQ4YkFCWmRqcUk2TkhrSmFRQXBmb0hWNVQrZ244ejdUTWsrSStUU2JlQURubUxCS3lnMHRabW10L0ZKbDV6eWowVmxwc1dzTVM2OVE2bUZJVStqcEhSanpOb2FLMVM1dlQ3ZW1HbUhKSUp0cWlOdXJRN0tkQlBJPC9kczpTaWduYXR1cmVWYWx1ZT4KPGRzOktleUluZm8+PGRzOlg1MDlEYXRhPjxkczpYNTA5Q2VydGlmaWNhdGU+TUlJRWF6Q0NBdE9nQXdJQkFnSVVlN2EwODhDbnI0aXptcm5CRW54NXEzSFRNdll3RFFZSktvWklodmNOQVFFTEJRQXdSVEVMTUFrR0ExVUVCaE1DUjBJeEV6QVJCZ05WQkFnTUNsTnZiV1V0VTNSaGRHVXhJVEFmQmdOVkJBb01HRWx1ZEdWeWJtVjBJRmRwWkdkcGRITWdVSFI1SUV4MFpEQWVGdzB4T1RFeE1UWXhNakUzTVRWYUZ3MHlPVEV4TVRVeE1qRTNNVFZhTUVVeEN6QUpCZ05WQkFZVEFrZENNUk13RVFZRFZRUUlEQXBUYjIxbExWTjBZWFJsTVNFd0h3WURWUVFLREJoSmJuUmxjbTVsZENCWGFXUm5hWFJ6SUZCMGVTQk1kR1F3Z2dHaU1BMEdDU3FHU0liM0RRRUJBUVVBQTRJQmp3QXdnZ0dLQW9JQmdRRHpMZTlGZmR5cGxUeEhwNFN1UTlnUXRaVDN0K1NEZnZFTDcycHBDZkZadzcrQjVzNUIvVDczYVhwb1EzUzUzcEdJMVJJV0NnZTJpQ1VRMnR6bTI3YVNOSDBpdTlhSlljVVFaL1JJVHFkMGF5eURrczFOQTJQVDNUVzZ0M203S1Y1cmU0UDBOYitZRGV1eUhka3oramNNdHBuOENtQm9UMEgrc2toYTBoaXFJTmtqa1JQaUh2TEhWR3ArdEhVRUEvSTZtTjRhQi9VRXhTVExzNzlOc0xVZnRlcXF4ZTkrdHZkVWFUb3lEUHJoUEZqT05zKzlOS0NreklDNnZjdjdKNkF0dUtHNm5FVCt6Qjl5T1dndEdZUWlmWHFRQTJ5NWRMODFCQjBxNXVNYUJMUzJwcTNhUFBqelUyRjMrRXlzanlTV1RuQ2tmazdDNVNzQ1hSdThRK1U5NXR1bnBOZndmNW9sRTZXYXM0OE5NTStQd1Y3aUNOTVBrTnpsbHE2UENpTStQOERyTVNjenpVWlpRVVN2NmRTd1BDbytZU1ZpbUVNME9nM1hKVGlOaFE1QU5sYUluNjZLdzVnZm9CZnVpWG15SUtpU0R5QWlEWW1GYWY0Mzk1d1d3TGtUUitjdzhXZmphSHN3S1pUb21uMU1SM09Kc1kyVUowZVJCWU0rWVNzQ0F3RUFBYU5UTUZFd0hRWURWUjBPQkJZRUZJbXAyQ1lDR2ZjYjd3OTFIL2NTaFRDa1h3Ui9NQjhHQTFVZEl3UVlNQmFBRkltcDJDWUNHZmNiN3c5MUgvY1NoVENrWHdSL01BOEdBMVVkRXdFQi93UUZNQU1CQWY4d0RRWUpLb1pJaHZjTkFRRUxCUUFEZ2dHQkFBK2cvQzd1TDlsbitXK3FCa25MVzgxa29qWWZsZ1BLMUkxTUhJd25NdmwvWlRIWDRkUlhLRHJrN0tjVXExS2pxYWpOVjY2ZjFjYWtwMDNJaWpCaU8wWGkxZ1hVWllMb0NpTkdVeXlwOVhsb2lJeTlYdzJQaVducncwK3laeXZWc3NiZWhYWFlKbDRSaWhCakJXdWw5UjR3TVlMT1VTSkRlMld4Y1VCaEpueHlOUnMrUDB4TFNRWDZCMm42bnhvRGtvNHAwN3M4WktYUWtlaVoyaXdGZFR4elJrR2p0aE1VdjcwNG56c1ZHQlQwRENQdGZTYU81S0paVzFyQ3MzeWlNdGhuQnhxNHFFRE9RSkZJbCsvTEQ3MUtiQjl2WmNXNUp1YXZ6QkZta0tHTnJvLzZHMUk3ZWw0NklSNHdpalR5TkZDWVV1RDlkdGlnbk5tcFd0TjhPVytwdGlML2p0VHlTV3VranlzMHMrdkxuODNDVnZqQjBkSnRWQUlZT2dYRmRJdWlpNjZnY3p3d00vTEdpT0V4Sm4wZFROenNKL0lZaHB4TDRGQkV1UDBwc2tZMG8wYVVsSjJMUzJqK3dTUVRSS3NCZ01qeXJVcmVrbGUyT0RTdFN0bjNlYWJqSXgwL0ZIbHBGcjBqTkltL29NUDdrd2p0VVg0emFOZTQ3UUk0R2c9PTwvZHM6WDUwOUNlcnRpZmljYXRlPjwvZHM6WDUwOURhdGE+PC9kczpLZXlJbmZvPjwvZHM6U2lnbmF0dXJlPjxzYW1sOlN1YmplY3Q+PHNhbWw6TmFtZUlEIFNQTmFtZVF1YWxpZmllcj0iaHR0cDovL2Jvb2tzdGFjay5sb2NhbC9zYW1sMi9tZXRhZGF0YSIgRm9ybWF0PSJ1cm46b2FzaXM6bmFtZXM6dGM6U0FNTDoyLjA6bmFtZWlkLWZvcm1hdDp0cmFuc2llbnQiPl8yYzdhYjg2ZWI4ZjFkMTA2MzQ0M2YyMTljYzU4NjhmZjY2NzA4OTEyZTM8L3NhbWw6TmFtZUlEPjxzYW1sOlN1YmplY3RDb25maXJtYXRpb24gTWV0aG9kPSJ1cm46b2FzaXM6bmFtZXM6dGM6U0FNTDoyLjA6Y206YmVhcmVyIj48c2FtbDpTdWJqZWN0Q29uZmlybWF0aW9uRGF0YSBOb3RPbk9yQWZ0ZXI9IjIwMTktMTEtMTdUMTc6NTg6MzlaIiBSZWNpcGllbnQ9Imh0dHA6Ly9ib29rc3RhY2subG9jYWwvc2FtbDIvYWNzIiBJblJlc3BvbnNlVG89Ik9ORUxPR0lOXzZhMGY0ZjM5OTMwNDBmMTk4N2ZkMzcwNjhiNTI5NjIyOWFkNTM2MWMiLz48L3NhbWw6U3ViamVjdENvbmZpcm1hdGlvbj48L3NhbWw6U3ViamVjdD48c2FtbDpDb25kaXRpb25zIE5vdEJlZm9yZT0iMjAxOS0xMS0xN1QxNzo1MzowOVoiIE5vdE9uT3JBZnRlcj0iMjAxOS0xMS0xN1QxNzo1ODozOVoiPjxzYW1sOkF1ZGllbmNlUmVzdHJpY3Rpb24+PHNhbWw6QXVkaWVuY2U+aHR0cDovL2Jvb2tzdGFjay5sb2NhbC9zYW1sMi9tZXRhZGF0YTwvc2FtbDpBdWRpZW5jZT48L3NhbWw6QXVkaWVuY2VSZXN0cmljdGlvbj48L3NhbWw6Q29uZGl0aW9ucz48c2FtbDpBdXRoblN0YXRlbWVudCBBdXRobkluc3RhbnQ9IjIwMTktMTEtMTdUMTc6NTM6MzlaIiBTZXNzaW9uTm90T25PckFmdGVyPSIyMDE5LTExLTE4VDAxOjUzOjM5WiIgU2Vzc2lvbkluZGV4PSJfNGZlN2MwZDE1NzJkNjRiMjdmOTMwYWE2ZjIzNmE2ZjQyZTkzMDkwMWNjIj48c2FtbDpBdXRobkNvbnRleHQ+PHNhbWw6QXV0aG5Db250ZXh0Q2xhc3NSZWY+dXJuOm9hc2lzOm5hbWVzOnRjOlNBTUw6Mi4wOmFjOmNsYXNzZXM6UGFzc3dvcmQ8L3NhbWw6QXV0aG5Db250ZXh0Q2xhc3NSZWY+PC9zYW1sOkF1dGhuQ29udGV4dD48L3NhbWw6QXV0aG5TdGF0ZW1lbnQ+PHNhbWw6QXR0cmlidXRlU3RhdGVtZW50PjxzYW1sOkF0dHJpYnV0ZSBOYW1lPSJ1aWQiIE5hbWVGb3JtYXQ9InVybjpvYXNpczpuYW1lczp0YzpTQU1MOjIuMDphdHRybmFtZS1mb3JtYXQ6YmFzaWMiPjxzYW1sOkF0dHJpYnV0ZVZhbHVlIHhzaTp0eXBlPSJ4czpzdHJpbmciPnVzZXI8L3NhbWw6QXR0cmlidXRlVmFsdWU+PC9zYW1sOkF0dHJpYnV0ZT48c2FtbDpBdHRyaWJ1dGUgTmFtZT0iZmlyc3RfbmFtZSIgTmFtZUZvcm1hdD0idXJuOm9hc2lzOm5hbWVzOnRjOlNBTUw6Mi4wOmF0dHJuYW1lLWZvcm1hdDpiYXNpYyI+PHNhbWw6QXR0cmlidXRlVmFsdWUgeHNpOnR5cGU9InhzOnN0cmluZyI+QmFycnk8L3NhbWw6QXR0cmlidXRlVmFsdWU+PC9zYW1sOkF0dHJpYnV0ZT48c2FtbDpBdHRyaWJ1dGUgTmFtZT0ibGFzdF9uYW1lIiBOYW1lRm9ybWF0PSJ1cm46b2FzaXM6bmFtZXM6dGM6U0FNTDoyLjA6YXR0cm5hbWUtZm9ybWF0OmJhc2ljIj48c2FtbDpBdHRyaWJ1dGVWYWx1ZSB4c2k6dHlwZT0ieHM6c3RyaW5nIj5TY290dDwvc2FtbDpBdHRyaWJ1dGVWYWx1ZT48L3NhbWw6QXR0cmlidXRlPjxzYW1sOkF0dHJpYnV0ZSBOYW1lPSJlbWFpbCIgTmFtZUZvcm1hdD0idXJuOm9hc2lzOm5hbWVzOnRjOlNBTUw6Mi4wOmF0dHJuYW1lLWZvcm1hdDpiYXNpYyI+PHNhbWw6QXR0cmlidXRlVmFsdWUgeHNpOnR5cGU9InhzOnN0cmluZyI+dXNlckBleGFtcGxlLmNvbTwvc2FtbDpBdHRyaWJ1dGVWYWx1ZT48L3NhbWw6QXR0cmlidXRlPjxzYW1sOkF0dHJpYnV0ZSBOYW1lPSJ1c2VyX2dyb3VwcyIgTmFtZUZvcm1hdD0idXJuOm9hc2lzOm5hbWVzOnRjOlNBTUw6Mi4wOmF0dHJuYW1lLWZvcm1hdDpiYXNpYyI+PHNhbWw6QXR0cmlidXRlVmFsdWUgeHNpOnR5cGU9InhzOnN0cmluZyI+bWVtYmVyPC9zYW1sOkF0dHJpYnV0ZVZhbHVlPjxzYW1sOkF0dHJpYnV0ZVZhbHVlIHhzaTp0eXBlPSJ4czpzdHJpbmciPmFkbWluPC9zYW1sOkF0dHJpYnV0ZVZhbHVlPjwvc2FtbDpBdHRyaWJ1dGU+PC9zYW1sOkF0dHJpYnV0ZVN0YXRlbWVudD48L3NhbWw6QXNzZXJ0aW9uPjwvc2FtbHA6UmVzcG9uc2U+';
 
index 60de8fbcbbcc07165081dbbfe7e6f8bd98e26740..5818cbb742bbe57c68292fef25ed59f0deacc473 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests\Auth;
+<?php
+
+namespace Tests\Auth;
 
 use BookStack\Auth\SocialAccount;
 use BookStack\Auth\User;
 
 use BookStack\Auth\SocialAccount;
 use BookStack\Auth\User;
@@ -10,7 +12,6 @@ use Tests\TestCase;
 
 class SocialAuthTest extends TestCase
 {
 
 class SocialAuthTest extends TestCase
 {
-
     public function test_social_registration()
     {
         $user = factory(User::class)->make();
     public function test_social_registration()
     {
         $user = factory(User::class)->make();
@@ -43,7 +44,7 @@ class SocialAuthTest extends TestCase
         config([
             'GOOGLE_APP_ID' => 'abc123', 'GOOGLE_APP_SECRET' => '123abc',
             'GITHUB_APP_ID' => 'abc123', 'GITHUB_APP_SECRET' => '123abc',
         config([
             'GOOGLE_APP_ID' => 'abc123', 'GOOGLE_APP_SECRET' => '123abc',
             'GITHUB_APP_ID' => 'abc123', 'GITHUB_APP_SECRET' => '123abc',
-            'APP_URL' => 'http://localhost'
+            'APP_URL'       => 'http://localhost',
         ]);
 
         $mockSocialite = $this->mock(Factory::class);
         ]);
 
         $mockSocialite = $this->mock(Factory::class);
@@ -60,7 +61,7 @@ class SocialAuthTest extends TestCase
         // Test login routes
         $resp = $this->get('/login');
         $resp->assertElementExists('a#social-login-google[href$="/login/service/google"]');
         // Test login routes
         $resp = $this->get('/login');
         $resp->assertElementExists('a#social-login-google[href$="/login/service/google"]');
-        $resp = $this->followingRedirects()->get("/login/service/google");
+        $resp = $this->followingRedirects()->get('/login/service/google');
         $resp->assertSee('login-form');
 
         // Test social callback
         $resp->assertSee('login-form');
 
         // Test social callback
@@ -70,18 +71,17 @@ class SocialAuthTest extends TestCase
 
         $resp = $this->get('/login');
         $resp->assertElementExists('a#social-login-github[href$="/login/service/github"]');
 
         $resp = $this->get('/login');
         $resp->assertElementExists('a#social-login-github[href$="/login/service/github"]');
-        $resp = $this->followingRedirects()->get("/login/service/github");
+        $resp = $this->followingRedirects()->get('/login/service/github');
         $resp->assertSee('login-form');
 
         $resp->assertSee('login-form');
 
-
         // Test social callback with matching social account
         DB::table('social_accounts')->insert([
         // Test social callback with matching social account
         DB::table('social_accounts')->insert([
-            'user_id' => $this->getAdmin()->id,
-            'driver' => 'github',
-            'driver_id' => 'logintest123'
+            'user_id'   => $this->getAdmin()->id,
+            'driver'    => 'github',
+            'driver_id' => 'logintest123',
         ]);
         $resp = $this->followingRedirects()->get('/login/service/github/callback');
         ]);
         $resp = $this->followingRedirects()->get('/login/service/github/callback');
-        $resp->assertDontSee("login-form");
+        $resp->assertDontSee('login-form');
     }
 
     public function test_social_account_detach()
     }
 
     public function test_social_account_detach()
@@ -89,12 +89,12 @@ class SocialAuthTest extends TestCase
         $editor = $this->getEditor();
         config([
             'GITHUB_APP_ID' => 'abc123', 'GITHUB_APP_SECRET' => '123abc',
         $editor = $this->getEditor();
         config([
             'GITHUB_APP_ID' => 'abc123', 'GITHUB_APP_SECRET' => '123abc',
-            'APP_URL' => 'http://localhost'
+            'APP_URL'       => 'http://localhost',
         ]);
 
         $socialAccount = SocialAccount::query()->forceCreate([
         ]);
 
         $socialAccount = SocialAccount::query()->forceCreate([
-            'user_id' => $editor->id,
-            'driver' => 'github',
+            'user_id'   => $editor->id,
+            'driver'    => 'github',
             'driver_id' => 'logintest123',
         ]);
 
             'driver_id' => 'logintest123',
         ]);
 
@@ -113,7 +113,7 @@ class SocialAuthTest extends TestCase
     {
         config([
             'services.google.client_id' => 'abc123', 'services.google.client_secret' => '123abc',
     {
         config([
             'services.google.client_id' => 'abc123', 'services.google.client_secret' => '123abc',
-            'APP_URL' => 'http://localhost'
+            'APP_URL'                   => 'http://localhost',
         ]);
 
         $user = factory(User::class)->make();
         ]);
 
         $user = factory(User::class)->make();
@@ -151,7 +151,7 @@ class SocialAuthTest extends TestCase
     {
         config([
             'services.google.client_id' => 'abc123', 'services.google.client_secret' => '123abc',
     {
         config([
             'services.google.client_id' => 'abc123', 'services.google.client_secret' => '123abc',
-            'APP_URL' => 'http://localhost', 'services.google.auto_register' => true, 'services.google.auto_confirm' => true
+            'APP_URL'                   => 'http://localhost', 'services.google.auto_register' => true, 'services.google.auto_confirm' => true,
         ]);
 
         $user = factory(User::class)->make();
         ]);
 
         $user = factory(User::class)->make();
@@ -210,5 +210,4 @@ class SocialAuthTest extends TestCase
         $user = $user->whereEmail($user->email)->first();
         $this->assertDatabaseHas('social_accounts', ['user_id' => $user->id]);
     }
         $user = $user->whereEmail($user->email)->first();
         $this->assertDatabaseHas('social_accounts', ['user_id' => $user->id]);
     }
-
 }
 }
index b6f521eaa23196466114b27a04d5cca41b885115..c5c4b01af065ea607471c64562e554f8c51feed3 100644 (file)
@@ -1,5 +1,6 @@
-<?php namespace Tests\Auth;
+<?php
 
 
+namespace Tests\Auth;
 
 use BookStack\Auth\Access\UserInviteService;
 use BookStack\Auth\User;
 
 use BookStack\Auth\Access\UserInviteService;
 use BookStack\Auth\User;
@@ -12,7 +13,6 @@ use Tests\TestCase;
 
 class UserInviteTest extends TestCase
 {
 
 class UserInviteTest extends TestCase
 {
-
     public function test_user_creation_creates_invite()
     {
         Notification::fake();
     public function test_user_creation_creates_invite()
     {
         Notification::fake();
@@ -20,8 +20,8 @@ class UserInviteTest extends TestCase
 
         $email = Str::random(16) . '@example.com';
         $resp = $this->actingAs($admin)->post('/settings/users/create', [
 
         $email = Str::random(16) . '@example.com';
         $resp = $this->actingAs($admin)->post('/settings/users/create', [
-            'name' => 'Barry',
-            'email' => $email,
+            'name'        => 'Barry',
+            'email'       => $email,
             'send_invite' => 'true',
         ]);
         $resp->assertRedirect('/settings/users');
             'send_invite' => 'true',
         ]);
         $resp->assertRedirect('/settings/users');
@@ -30,7 +30,7 @@ class UserInviteTest extends TestCase
 
         Notification::assertSentTo($newUser, UserInvite::class);
         $this->assertDatabaseHas('user_invites', [
 
         Notification::assertSentTo($newUser, UserInvite::class);
         $this->assertDatabaseHas('user_invites', [
-            'user_id' => $newUser->id
+            'user_id' => $newUser->id,
         ]);
     }
 
         ]);
     }
 
@@ -54,12 +54,12 @@ class UserInviteTest extends TestCase
         ]);
         $setPasswordResp->assertSee('Password set, you now have access to BookStack!');
         $newPasswordValid = auth()->validate([
         ]);
         $setPasswordResp->assertSee('Password set, you now have access to BookStack!');
         $newPasswordValid = auth()->validate([
-            'email' => $user->email,
-            'password' => 'my test password'
+            'email'    => $user->email,
+            'password' => 'my test password',
         ]);
         $this->assertTrue($newPasswordValid);
         $this->assertDatabaseMissing('user_invites', [
         ]);
         $this->assertTrue($newPasswordValid);
         $this->assertDatabaseMissing('user_invites', [
-            'user_id' => $user->id
+            'user_id' => $user->id,
         ]);
     }
 
         ]);
     }
 
@@ -85,7 +85,7 @@ class UserInviteTest extends TestCase
         $noPassword->assertSee('The password field is required.');
 
         $this->assertDatabaseHas('user_invites', [
         $noPassword->assertSee('The password field is required.');
 
         $this->assertDatabaseHas('user_invites', [
-            'user_id' => $user->id
+            'user_id' => $user->id,
         ]);
     }
 
         ]);
     }
 
@@ -112,6 +112,4 @@ class UserInviteTest extends TestCase
         $setPasswordPageResp->assertRedirect('/password/email');
         $setPasswordPageResp->assertSessionHas('error', 'This invitation link has expired. You can instead try to reset your account password.');
     }
         $setPasswordPageResp->assertRedirect('/password/email');
         $setPasswordPageResp->assertSessionHas('error', 'This invitation link has expired. You can instead try to reset your account password.');
     }
-
-
-}
\ No newline at end of file
+}
index 7917a0c409e881a7b8790c9a7c19584c5f1b0327..23eb1088773cf8499286eba5c3b858f10edad6a9 100644 (file)
@@ -1,10 +1,12 @@
-<?php namespace Tests;
+<?php
 
 
+namespace Tests;
+
+use BookStack\Auth\Permissions\PermissionService;
 use BookStack\Auth\User;
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Chapter;
 use BookStack\Entities\Models\Entity;
 use BookStack\Auth\User;
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Chapter;
 use BookStack\Entities\Models\Entity;
-use BookStack\Auth\Permissions\PermissionService;
 use BookStack\Entities\Models\Page;
 use BookStack\Settings\SettingService;
 use DB;
 use BookStack\Entities\Models\Page;
 use BookStack\Settings\SettingService;
 use DB;
@@ -16,17 +18,17 @@ use Symfony\Component\DomCrawler\Crawler;
 
 abstract class BrowserKitTest extends TestCase
 {
 
 abstract class BrowserKitTest extends TestCase
 {
-
     use DatabaseTransactions;
     use SharedTestHelpers;
 
     /**
      * The base URL to use while testing the application.
     use DatabaseTransactions;
     use SharedTestHelpers;
 
     /**
      * The base URL to use while testing the application.
+     *
      * @var string
      */
     protected $baseUrl = 'http://localhost';
 
      * @var string
      */
     protected $baseUrl = 'http://localhost';
 
-    public function tearDown() : void
+    public function tearDown(): void
     {
         DB::disconnect();
         parent::tearDown();
     {
         DB::disconnect();
         parent::tearDown();
@@ -39,16 +41,16 @@ abstract class BrowserKitTest extends TestCase
      */
     public function createApplication()
     {
      */
     public function createApplication()
     {
-        $app = require __DIR__.'/../bootstrap/app.php';
+        $app = require __DIR__ . '/../bootstrap/app.php';
 
         $app->make(Kernel::class)->bootstrap();
 
         return $app;
     }
 
 
         $app->make(Kernel::class)->bootstrap();
 
         return $app;
     }
 
-
     /**
      * Quickly sets an array of settings.
     /**
      * Quickly sets an array of settings.
+     *
      * @param $settingsArray
      */
     protected function setSettings($settingsArray)
      * @param $settingsArray
      */
     protected function setSettings($settingsArray)
@@ -80,6 +82,7 @@ abstract class BrowserKitTest extends TestCase
 
     /**
      * Helper for updating entity permissions.
 
     /**
      * Helper for updating entity permissions.
+     *
      * @param Entity $entity
      */
     protected function updateEntityPermissions(Entity $entity)
      * @param Entity $entity
      */
     protected function updateEntityPermissions(Entity $entity)
@@ -88,25 +91,28 @@ abstract class BrowserKitTest extends TestCase
         $restrictionService->buildJointPermissionsForEntity($entity);
     }
 
         $restrictionService->buildJointPermissionsForEntity($entity);
     }
 
-
     /**
     /**
-     * Quick way to create a new user without any permissions
+     * Quick way to create a new user without any permissions.
+     *
      * @param array $attributes
      * @param array $attributes
+     *
      * @return mixed
      */
     protected function getNewBlankUser($attributes = [])
     {
         $user = factory(User::class)->create($attributes);
      * @return mixed
      */
     protected function getNewBlankUser($attributes = [])
     {
         $user = factory(User::class)->create($attributes);
+
         return $user;
     }
 
     /**
      * Assert that a given string is seen inside an element.
      *
         return $user;
     }
 
     /**
      * Assert that a given string is seen inside an element.
      *
-     * @param  bool|string|null $element
-     * @param  integer          $position
-     * @param  string           $text
-     * @param  bool             $negate
+     * @param bool|string|null $element
+     * @param int              $position
+     * @param string           $text
+     * @param bool             $negate
+     *
      * @return $this
      */
     protected function seeInNthElement($element, $position, $text, $negate = false)
      * @return $this
      */
     protected function seeInNthElement($element, $position, $text, $negate = false)
@@ -130,13 +136,16 @@ abstract class BrowserKitTest extends TestCase
     /**
      * Assert that the current page matches a given URI.
      *
     /**
      * Assert that the current page matches a given URI.
      *
-     * @param  string  $uri
+     * @param string $uri
+     *
      * @return $this
      */
     protected function seePageUrlIs($uri)
     {
         $this->assertEquals(
      * @return $this
      */
     protected function seePageUrlIs($uri)
     {
         $this->assertEquals(
-            $uri, $this->currentUri, "Did not land on expected page [{$uri}].\n"
+            $uri,
+            $this->currentUri,
+            "Did not land on expected page [{$uri}].\n"
         );
 
         return $this;
         );
 
         return $this;
@@ -144,10 +153,12 @@ abstract class BrowserKitTest extends TestCase
 
     /**
      * Do a forced visit that does not error out on exception.
 
     /**
      * Do a forced visit that does not error out on exception.
+     *
      * @param string $uri
      * @param string $uri
-     * @param array $parameters
-     * @param array $cookies
-     * @param array $files
+     * @param array  $parameters
+     * @param array  $cookies
+     * @param array  $files
+     *
      * @return $this
      */
     protected function forceVisit($uri, $parameters = [], $cookies = [], $files = [])
      * @return $this
      */
     protected function forceVisit($uri, $parameters = [], $cookies = [], $files = [])
@@ -158,13 +169,16 @@ abstract class BrowserKitTest extends TestCase
         $this->clearInputs()->followRedirects();
         $this->currentUri = $this->app->make('request')->fullUrl();
         $this->crawler = new Crawler($this->response->getContent(), $uri);
         $this->clearInputs()->followRedirects();
         $this->currentUri = $this->app->make('request')->fullUrl();
         $this->crawler = new Crawler($this->response->getContent(), $uri);
+
         return $this;
     }
 
     /**
      * Click the text within the selected element.
         return $this;
     }
 
     /**
      * Click the text within the selected element.
+     *
      * @param $parentElement
      * @param $linkText
      * @param $parentElement
      * @param $linkText
+     *
      * @return $this
      */
     protected function clickInElement($parentElement, $linkText)
      * @return $this
      */
     protected function clickInElement($parentElement, $linkText)
@@ -172,28 +186,33 @@ abstract class BrowserKitTest extends TestCase
         $elem = $this->crawler->filter($parentElement);
         $link = $elem->selectLink($linkText);
         $this->visit($link->link()->getUri());
         $elem = $this->crawler->filter($parentElement);
         $link = $elem->selectLink($linkText);
         $this->visit($link->link()->getUri());
+
         return $this;
     }
 
     /**
      * Check if the page contains the given element.
         return $this;
     }
 
     /**
      * Check if the page contains the given element.
-     * @param  string  $selector
+     *
+     * @param string $selector
      */
     protected function pageHasElement($selector)
     {
         $elements = $this->crawler->filter($selector);
      */
     protected function pageHasElement($selector)
     {
         $elements = $this->crawler->filter($selector);
-        $this->assertTrue(count($elements) > 0, "The page does not contain an element matching " . $selector);
+        $this->assertTrue(count($elements) > 0, 'The page does not contain an element matching ' . $selector);
+
         return $this;
     }
 
     /**
      * Check if the page contains the given element.
         return $this;
     }
 
     /**
      * Check if the page contains the given element.
-     * @param  string  $selector
+     *
+     * @param string $selector
      */
     protected function pageNotHasElement($selector)
     {
         $elements = $this->crawler->filter($selector);
      */
     protected function pageNotHasElement($selector)
     {
         $elements = $this->crawler->filter($selector);
-        $this->assertFalse(count($elements) > 0, "The page contains " . count($elements) . " elements matching " . $selector);
+        $this->assertFalse(count($elements) > 0, 'The page contains ' . count($elements) . ' elements matching ' . $selector);
+
         return $this;
     }
 }
         return $this;
     }
 }
index 6b03c86f92e46a68f4eac2b107bf0c7793ceaa3b..0f144246c80fa1e21899bdd51964cf5ec99540c7 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests\Commands;
+<?php
+
+namespace Tests\Commands;
 
 use BookStack\Auth\User;
 use Tests\TestCase;
 
 use BookStack\Auth\User;
 use Tests\TestCase;
@@ -8,18 +10,18 @@ class AddAdminCommandTest extends TestCase
     public function test_add_admin_command()
     {
         $exitCode = \Artisan::call('bookstack:create-admin', [
     public function test_add_admin_command()
     {
         $exitCode = \Artisan::call('bookstack:create-admin', [
-            '--email' => '[email protected]',
-            '--name' => 'Admin Test',
+            '--email'    => '[email protected]',
+            '--name'     => 'Admin Test',
             '--password' => 'testing-4',
         ]);
         $this->assertTrue($exitCode === 0, 'Command executed successfully');
 
         $this->assertDatabaseHas('users', [
             'email' => '[email protected]',
             '--password' => 'testing-4',
         ]);
         $this->assertTrue($exitCode === 0, 'Command executed successfully');
 
         $this->assertDatabaseHas('users', [
             'email' => '[email protected]',
-            'name' => 'Admin Test'
+            'name'  => 'Admin Test',
         ]);
 
         $this->assertTrue(User::query()->where('email', '=', '[email protected]')->first()->hasSystemRole('admin'), 'User has admin role as expected');
         $this->assertTrue(\Auth::attempt(['email' => '[email protected]', 'password' => 'testing-4']), 'Password stored as expected');
     }
         ]);
 
         $this->assertTrue(User::query()->where('email', '=', '[email protected]')->first()->hasSystemRole('admin'), 'User has admin role as expected');
         $this->assertTrue(\Auth::attempt(['email' => '[email protected]', 'password' => 'testing-4']), 'Password stored as expected');
     }
-}
\ No newline at end of file
+}
index 751a165c65c70e2085d9c598a1d816b3d4e2771b..172e6c6aeab2726540c8f7c53221c1d0401dcef1 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests\Commands;
+<?php
+
+namespace Tests\Commands;
 
 use BookStack\Actions\ActivityType;
 use BookStack\Entities\Models\Page;
 
 use BookStack\Actions\ActivityType;
 use BookStack\Entities\Models\Page;
@@ -14,20 +16,18 @@ class ClearActivityCommandTest extends TestCase
         \Activity::addForEntity($page, ActivityType::PAGE_UPDATE);
 
         $this->assertDatabaseHas('activities', [
         \Activity::addForEntity($page, ActivityType::PAGE_UPDATE);
 
         $this->assertDatabaseHas('activities', [
-            'type' => 'page_update',
+            'type'      => 'page_update',
             'entity_id' => $page->id,
             'entity_id' => $page->id,
-            'user_id' => $this->getEditor()->id
+            'user_id'   => $this->getEditor()->id,
         ]);
 
         ]);
 
-
         DB::rollBack();
         $exitCode = \Artisan::call('bookstack:clear-activity');
         DB::beginTransaction();
         $this->assertTrue($exitCode === 0, 'Command executed successfully');
 
         DB::rollBack();
         $exitCode = \Artisan::call('bookstack:clear-activity');
         DB::beginTransaction();
         $this->assertTrue($exitCode === 0, 'Command executed successfully');
 
-
         $this->assertDatabaseMissing('activities', [
         $this->assertDatabaseMissing('activities', [
-            'type' => 'page_update'
+            'type' => 'page_update',
         ]);
     }
         ]);
     }
-}
\ No newline at end of file
+}
index e0293faf165433e3ebcc7b70e934411283894ea6..a7aef958fc98725f79ad9b1107bc2f32813c8774 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests\Commands;
+<?php
+
+namespace Tests\Commands;
 
 use BookStack\Entities\Models\Page;
 use BookStack\Entities\Repos\PageRepo;
 
 use BookStack\Entities\Models\Page;
 use BookStack\Entities\Repos\PageRepo;
@@ -17,11 +19,11 @@ class ClearRevisionsCommandTest extends TestCase
 
         $this->assertDatabaseHas('page_revisions', [
             'page_id' => $page->id,
 
         $this->assertDatabaseHas('page_revisions', [
             'page_id' => $page->id,
-            'type' => 'version'
+            'type'    => 'version',
         ]);
         $this->assertDatabaseHas('page_revisions', [
             'page_id' => $page->id,
         ]);
         $this->assertDatabaseHas('page_revisions', [
             'page_id' => $page->id,
-            'type' => 'update_draft'
+            'type'    => 'update_draft',
         ]);
 
         $exitCode = Artisan::call('bookstack:clear-revisions');
         ]);
 
         $exitCode = Artisan::call('bookstack:clear-revisions');
@@ -29,11 +31,11 @@ class ClearRevisionsCommandTest extends TestCase
 
         $this->assertDatabaseMissing('page_revisions', [
             'page_id' => $page->id,
 
         $this->assertDatabaseMissing('page_revisions', [
             'page_id' => $page->id,
-            'type' => 'version'
+            'type'    => 'version',
         ]);
         $this->assertDatabaseHas('page_revisions', [
             'page_id' => $page->id,
         ]);
         $this->assertDatabaseHas('page_revisions', [
             'page_id' => $page->id,
-            'type' => 'update_draft'
+            'type'    => 'update_draft',
         ]);
 
         $exitCode = Artisan::call('bookstack:clear-revisions', ['--all' => true]);
         ]);
 
         $exitCode = Artisan::call('bookstack:clear-revisions', ['--all' => true]);
@@ -41,7 +43,7 @@ class ClearRevisionsCommandTest extends TestCase
 
         $this->assertDatabaseMissing('page_revisions', [
             'page_id' => $page->id,
 
         $this->assertDatabaseMissing('page_revisions', [
             'page_id' => $page->id,
-            'type' => 'update_draft'
+            'type'    => 'update_draft',
         ]);
     }
         ]);
     }
-}
\ No newline at end of file
+}
index 04665adcf2b384b200b2b728555b47e91a56168a..bbd06fa01086aeeb9fa3134669975ff9af83e2c7 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests\Commands;
+<?php
+
+namespace Tests\Commands;
 
 use BookStack\Entities\Models\Page;
 use Illuminate\Support\Facades\DB;
 
 use BookStack\Entities\Models\Page;
 use Illuminate\Support\Facades\DB;
@@ -6,7 +8,6 @@ use Tests\TestCase;
 
 class ClearViewsCommandTest extends TestCase
 {
 
 class ClearViewsCommandTest extends TestCase
 {
-
     public function test_clear_views_command()
     {
         $this->asEditor();
     public function test_clear_views_command()
     {
         $this->asEditor();
@@ -15,9 +16,9 @@ class ClearViewsCommandTest extends TestCase
         $this->get($page->getUrl());
 
         $this->assertDatabaseHas('views', [
         $this->get($page->getUrl());
 
         $this->assertDatabaseHas('views', [
-            'user_id' => $this->getEditor()->id,
+            'user_id'     => $this->getEditor()->id,
             'viewable_id' => $page->id,
             'viewable_id' => $page->id,
-            'views' => 1
+            'views'       => 1,
         ]);
 
         DB::rollBack();
         ]);
 
         DB::rollBack();
@@ -26,7 +27,7 @@ class ClearViewsCommandTest extends TestCase
         $this->assertTrue($exitCode === 0, 'Command executed successfully');
 
         $this->assertDatabaseMissing('views', [
         $this->assertTrue($exitCode === 0, 'Command executed successfully');
 
         $this->assertDatabaseMissing('views', [
-            'user_id' => $this->getEditor()->id
+            'user_id' => $this->getEditor()->id,
         ]);
     }
         ]);
     }
-}
\ No newline at end of file
+}
index 87199bdc3ead7893671d1050cebd0c93cc9299c8..5a60b8d55c550ea4b01164f40e1f150199117488 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests\Commands;
+<?php
+
+namespace Tests\Commands;
 
 use BookStack\Entities\Models\Bookshelf;
 use Tests\TestCase;
 
 use BookStack\Entities\Models\Bookshelf;
 use Tests\TestCase;
@@ -17,8 +19,8 @@ class CopyShelfPermissionsCommandTest extends TestCase
         $shelf = Bookshelf::first();
         $child = $shelf->books()->first();
         $editorRole = $this->getEditor()->roles()->first();
         $shelf = Bookshelf::first();
         $child = $shelf->books()->first();
         $editorRole = $this->getEditor()->roles()->first();
-        $this->assertFalse(boolval($child->restricted), "Child book should not be restricted by default");
-        $this->assertTrue($child->permissions()->count() === 0, "Child book should have no permissions by default");
+        $this->assertFalse(boolval($child->restricted), 'Child book should not be restricted by default');
+        $this->assertTrue($child->permissions()->count() === 0, 'Child book should have no permissions by default');
 
         $this->setEntityRestrictions($shelf, ['view', 'update'], [$editorRole]);
         $this->artisan('bookstack:copy-shelf-permissions', [
 
         $this->setEntityRestrictions($shelf, ['view', 'update'], [$editorRole]);
         $this->artisan('bookstack:copy-shelf-permissions', [
@@ -26,8 +28,8 @@ class CopyShelfPermissionsCommandTest extends TestCase
         ]);
         $child = $shelf->books()->first();
 
         ]);
         $child = $shelf->books()->first();
 
-        $this->assertTrue(boolval($child->restricted), "Child book should now be restricted");
-        $this->assertTrue($child->permissions()->count() === 2, "Child book should have copied permissions");
+        $this->assertTrue(boolval($child->restricted), 'Child book should now be restricted');
+        $this->assertTrue($child->permissions()->count() === 2, 'Child book should have copied permissions');
         $this->assertDatabaseHas('entity_permissions', ['restrictable_id' => $child->id, 'action' => 'view', 'role_id' => $editorRole->id]);
         $this->assertDatabaseHas('entity_permissions', ['restrictable_id' => $child->id, 'action' => 'update', 'role_id' => $editorRole->id]);
     }
         $this->assertDatabaseHas('entity_permissions', ['restrictable_id' => $child->id, 'action' => 'view', 'role_id' => $editorRole->id]);
         $this->assertDatabaseHas('entity_permissions', ['restrictable_id' => $child->id, 'action' => 'update', 'role_id' => $editorRole->id]);
     }
@@ -38,17 +40,17 @@ class CopyShelfPermissionsCommandTest extends TestCase
         Bookshelf::query()->where('id', '!=', $shelf->id)->delete();
         $child = $shelf->books()->first();
         $editorRole = $this->getEditor()->roles()->first();
         Bookshelf::query()->where('id', '!=', $shelf->id)->delete();
         $child = $shelf->books()->first();
         $editorRole = $this->getEditor()->roles()->first();
-        $this->assertFalse(boolval($child->restricted), "Child book should not be restricted by default");
-        $this->assertTrue($child->permissions()->count() === 0, "Child book should have no permissions by default");
+        $this->assertFalse(boolval($child->restricted), 'Child book should not be restricted by default');
+        $this->assertTrue($child->permissions()->count() === 0, 'Child book should have no permissions by default');
 
         $this->setEntityRestrictions($shelf, ['view', 'update'], [$editorRole]);
         $this->artisan('bookstack:copy-shelf-permissions --all')
             ->expectsQuestion('Permission settings for all shelves will be cascaded. Books assigned to multiple shelves will receive only the permissions of it\'s last processed shelf. Are you sure you want to proceed?', 'y');
         $child = $shelf->books()->first();
 
 
         $this->setEntityRestrictions($shelf, ['view', 'update'], [$editorRole]);
         $this->artisan('bookstack:copy-shelf-permissions --all')
             ->expectsQuestion('Permission settings for all shelves will be cascaded. Books assigned to multiple shelves will receive only the permissions of it\'s last processed shelf. Are you sure you want to proceed?', 'y');
         $child = $shelf->books()->first();
 
-        $this->assertTrue(boolval($child->restricted), "Child book should now be restricted");
-        $this->assertTrue($child->permissions()->count() === 2, "Child book should have copied permissions");
+        $this->assertTrue(boolval($child->restricted), 'Child book should now be restricted');
+        $this->assertTrue($child->permissions()->count() === 2, 'Child book should have copied permissions');
         $this->assertDatabaseHas('entity_permissions', ['restrictable_id' => $child->id, 'action' => 'view', 'role_id' => $editorRole->id]);
         $this->assertDatabaseHas('entity_permissions', ['restrictable_id' => $child->id, 'action' => 'update', 'role_id' => $editorRole->id]);
     }
         $this->assertDatabaseHas('entity_permissions', ['restrictable_id' => $child->id, 'action' => 'view', 'role_id' => $editorRole->id]);
         $this->assertDatabaseHas('entity_permissions', ['restrictable_id' => $child->id, 'action' => 'update', 'role_id' => $editorRole->id]);
     }
-}
\ No newline at end of file
+}
index 1deeaa703a114fc39c471a181e173afd2e7d0b5b..08f137777d191af0601e83cbd5e0a011eb06be1e 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests\Commands;
+<?php
+
+namespace Tests\Commands;
 
 use BookStack\Actions\Comment;
 use Tests\TestCase;
 
 use BookStack\Actions\Comment;
 use Tests\TestCase;
@@ -26,4 +28,4 @@ class RegenerateCommentContentCommandTest extends TestCase
             'html' => "<p>some_fresh_content</p>\n",
         ]);
     }
             'html' => "<p>some_fresh_content</p>\n",
         ]);
     }
-}
\ No newline at end of file
+}
index d5b34ba170c4e8c41aaf826061f7df6646d93445..2090c991bebbf4bcd4b363f4a31ff0363f5f38cc 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests\Commands;
+<?php
+
+namespace Tests\Commands;
 
 use BookStack\Auth\Permissions\JointPermission;
 use BookStack\Entities\Models\Page;
 
 use BookStack\Auth\Permissions\JointPermission;
 use BookStack\Entities\Models\Page;
@@ -21,4 +23,4 @@ class RegeneratePermissionsCommandTest extends TestCase
 
         $this->assertDatabaseHas('joint_permissions', ['entity_id' => $page->id]);
     }
 
         $this->assertDatabaseHas('joint_permissions', ['entity_id' => $page->id]);
     }
-}
\ No newline at end of file
+}
index 7043ce047f17bc09d829f852e1f267403228cf11..0acccd80cc2adc14a4e2254247002974fc02a583 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests\Commands;
+<?php
+
+namespace Tests\Commands;
 
 use BookStack\Entities\Models\Page;
 use Symfony\Component\Console\Exception\RuntimeException;
 
 use BookStack\Entities\Models\Page;
 use Symfony\Component\Console\Exception\RuntimeException;
@@ -14,17 +16,17 @@ class UpdateUrlCommandTest extends TestCase
 
         $this->artisan('bookstack:update-url https://example.com https://cats.example.com')
             ->expectsQuestion("This will search for \"https://example.com\" in your database and replace it with  \"https://cats.example.com\".\nAre you sure you want to proceed?", 'y')
 
         $this->artisan('bookstack:update-url https://example.com https://cats.example.com')
             ->expectsQuestion("This will search for \"https://example.com\" in your database and replace it with  \"https://cats.example.com\".\nAre you sure you want to proceed?", 'y')
-            ->expectsQuestion("This operation could cause issues if used incorrectly. Have you made a backup of your existing database?", 'y');
+            ->expectsQuestion('This operation could cause issues if used incorrectly. Have you made a backup of your existing database?', 'y');
 
         $this->assertDatabaseHas('pages', [
 
         $this->assertDatabaseHas('pages', [
-            'id' => $page->id,
-            'html' => '<a href="https://cats.example.com/donkeys"></a>'
+            'id'   => $page->id,
+            'html' => '<a href="https://cats.example.com/donkeys"></a>',
         ]);
     }
 
     public function test_command_requires_valid_url()
     {
         ]);
     }
 
     public function test_command_requires_valid_url()
     {
-        $badUrlMessage = "The given urls are expected to be full urls starting with http:// or https://";
+        $badUrlMessage = 'The given urls are expected to be full urls starting with http:// or https://';
         $this->artisan('bookstack:update-url //example.com https://cats.example.com')->expectsOutput($badUrlMessage);
         $this->artisan('bookstack:update-url https://example.com htts://cats.example.com')->expectsOutput($badUrlMessage);
         $this->artisan('bookstack:update-url example.com https://cats.example.com')->expectsOutput($badUrlMessage);
         $this->artisan('bookstack:update-url //example.com https://cats.example.com')->expectsOutput($badUrlMessage);
         $this->artisan('bookstack:update-url https://example.com htts://cats.example.com')->expectsOutput($badUrlMessage);
         $this->artisan('bookstack:update-url example.com https://cats.example.com')->expectsOutput($badUrlMessage);
@@ -54,6 +56,6 @@ class UpdateUrlCommandTest extends TestCase
     {
         $this->artisan("bookstack:update-url {$oldUrl} {$newUrl}")
             ->expectsQuestion("This will search for \"{$oldUrl}\" in your database and replace it with  \"{$newUrl}\".\nAre you sure you want to proceed?", 'y')
     {
         $this->artisan("bookstack:update-url {$oldUrl} {$newUrl}")
             ->expectsQuestion("This will search for \"{$oldUrl}\" in your database and replace it with  \"{$newUrl}\".\nAre you sure you want to proceed?", 'y')
-            ->expectsQuestion("This operation could cause issues if used incorrectly. Have you made a backup of your existing database?", 'y');
+            ->expectsQuestion('This operation could cause issues if used incorrectly. Have you made a backup of your existing database?', 'y');
     }
     }
-}
\ No newline at end of file
+}
index 42a5da2d16ab402a976d43deab9fe03877518c72..b1cefbb6584375b519bcc230f434464f1ca87b4a 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests;
+<?php
+
+namespace Tests;
 
 use Illuminate\Contracts\Console\Kernel;
 
 
 use Illuminate\Contracts\Console\Kernel;
 
@@ -11,8 +13,9 @@ trait CreatesApplication
      */
     public function createApplication()
     {
      */
     public function createApplication()
     {
-        $app = require __DIR__.'/../bootstrap/app.php';
+        $app = require __DIR__ . '/../bootstrap/app.php';
         $app->make(Kernel::class)->bootstrap();
         $app->make(Kernel::class)->bootstrap();
+
         return $app;
     }
         return $app;
     }
-}
\ No newline at end of file
+}
index 60658f6b2b8a87ecf36609a32f79bda7b46434e6..cc9a7e44ea2a3c247022bfb49fd9789376cc08d8 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests\Entity;
+<?php
+
+namespace Tests\Entity;
 
 use BookStack\Auth\User;
 use BookStack\Entities\Models\Book;
 
 use BookStack\Auth\User;
 use BookStack\Entities\Models\Book;
@@ -10,7 +12,6 @@ use Tests\Uploads\UsesImages;
 
 class BookShelfTest extends TestCase
 {
 
 class BookShelfTest extends TestCase
 {
-
     use UsesImages;
 
     public function test_shelves_shows_in_header_if_have_view_permissions()
     use UsesImages;
 
     public function test_shelves_shows_in_header_if_have_view_permissions()
@@ -79,16 +80,16 @@ class BookShelfTest extends TestCase
     {
         $booksToInclude = Book::take(2)->get();
         $shelfInfo = [
     {
         $booksToInclude = Book::take(2)->get();
         $shelfInfo = [
-            'name' => 'My test book' . Str::random(4),
-            'description' => 'Test book description ' . Str::random(10)
+            'name'        => 'My test book' . Str::random(4),
+            'description' => 'Test book description ' . Str::random(10),
         ];
         $resp = $this->asEditor()->post('/shelves', array_merge($shelfInfo, [
             'books' => $booksToInclude->implode('id', ','),
         ];
         $resp = $this->asEditor()->post('/shelves', array_merge($shelfInfo, [
             'books' => $booksToInclude->implode('id', ','),
-            'tags' => [
+            'tags'  => [
                 [
                 [
-                    'name' => 'Test Category',
+                    'name'  => 'Test Category',
                     'value' => 'Test Tag Value',
                     'value' => 'Test Tag Value',
-                ]
+                ],
             ],
         ]));
         $resp->assertRedirect();
             ],
         ]));
         $resp->assertRedirect();
@@ -109,8 +110,8 @@ class BookShelfTest extends TestCase
     public function test_shelves_create_sets_cover_image()
     {
         $shelfInfo = [
     public function test_shelves_create_sets_cover_image()
     {
         $shelfInfo = [
-            'name' => 'My test book' . Str::random(4),
-            'description' => 'Test book description ' . Str::random(10)
+            'name'        => 'My test book' . Str::random(4),
+            'description' => 'Test book description ' . Str::random(10),
         ];
 
         $imageFile = $this->getTestImage('shelf-test.png');
         ];
 
         $imageFile = $this->getTestImage('shelf-test.png');
@@ -120,7 +121,7 @@ class BookShelfTest extends TestCase
         $lastImage = Image::query()->orderByDesc('id')->firstOrFail();
         $shelf = Bookshelf::query()->where('name', '=', $shelfInfo['name'])->first();
         $this->assertDatabaseHas('bookshelves', [
         $lastImage = Image::query()->orderByDesc('id')->firstOrFail();
         $shelf = Bookshelf::query()->where('name', '=', $shelfInfo['name'])->first();
         $this->assertDatabaseHas('bookshelves', [
-            'id' => $shelf->id,
+            'id'       => $shelf->id,
             'image_id' => $lastImage->id,
         ]);
         $this->assertEquals($lastImage->id, $shelf->cover->id);
             'image_id' => $lastImage->id,
         ]);
         $this->assertEquals($lastImage->id, $shelf->cover->id);
@@ -175,7 +176,7 @@ class BookShelfTest extends TestCase
         // Set book ordering
         $this->asAdmin()->put($shelf->getUrl(), [
             'books' => $books->implode('id', ','),
         // Set book ordering
         $this->asAdmin()->put($shelf->getUrl(), [
             'books' => $books->implode('id', ','),
-            'tags' => [], 'description' => 'abc', 'name' => 'abc'
+            'tags'  => [], 'description' => 'abc', 'name' => 'abc',
         ]);
         $this->assertEquals(3, $shelf->books()->count());
         $shelf->refresh();
         ]);
         $this->assertEquals(3, $shelf->books()->count());
         $shelf->refresh();
@@ -205,17 +206,17 @@ class BookShelfTest extends TestCase
 
         $booksToInclude = Book::take(2)->get();
         $shelfInfo = [
 
         $booksToInclude = Book::take(2)->get();
         $shelfInfo = [
-            'name' => 'My test book' . Str::random(4),
-            'description' => 'Test book description ' . Str::random(10)
+            'name'        => 'My test book' . Str::random(4),
+            'description' => 'Test book description ' . Str::random(10),
         ];
 
         $resp = $this->asEditor()->put($shelf->getUrl(), array_merge($shelfInfo, [
             'books' => $booksToInclude->implode('id', ','),
         ];
 
         $resp = $this->asEditor()->put($shelf->getUrl(), array_merge($shelfInfo, [
             'books' => $booksToInclude->implode('id', ','),
-            'tags' => [
+            'tags'  => [
                 [
                 [
-                    'name' => 'Test Category',
+                    'name'  => 'Test Category',
                     'value' => 'Test Tag Value',
                     'value' => 'Test Tag Value',
-                ]
+                ],
             ],
         ]));
         $shelf = Bookshelf::find($shelf->id);
             ],
         ]));
         $shelf = Bookshelf::find($shelf->id);
@@ -246,15 +247,15 @@ class BookShelfTest extends TestCase
         $testName = 'Test Book in Shelf Name';
 
         $createBookResp = $this->asEditor()->post($shelf->getUrl('/create-book'), [
         $testName = 'Test Book in Shelf Name';
 
         $createBookResp = $this->asEditor()->post($shelf->getUrl('/create-book'), [
-            'name' => $testName,
-            'description' => 'Book in shelf description'
+            'name'        => $testName,
+            'description' => 'Book in shelf description',
         ]);
         $createBookResp->assertRedirect();
 
         $newBook = Book::query()->orderBy('id', 'desc')->first();
         $this->assertDatabaseHas('bookshelves_books', [
             'bookshelf_id' => $shelf->id,
         ]);
         $createBookResp->assertRedirect();
 
         $newBook = Book::query()->orderBy('id', 'desc')->first();
         $this->assertDatabaseHas('bookshelves_books', [
             'bookshelf_id' => $shelf->id,
-            'book_id' => $newBook->id,
+            'book_id'      => $newBook->id,
         ]);
 
         $resp = $this->asEditor()->get($shelf->getUrl());
         ]);
 
         $resp = $this->asEditor()->get($shelf->getUrl());
@@ -293,16 +294,16 @@ class BookShelfTest extends TestCase
 
         $child = $shelf->books()->first();
         $editorRole = $this->getEditor()->roles()->first();
 
         $child = $shelf->books()->first();
         $editorRole = $this->getEditor()->roles()->first();
-        $this->assertFalse(boolval($child->restricted), "Child book should not be restricted by default");
-        $this->assertTrue($child->permissions()->count() === 0, "Child book should have no permissions by default");
+        $this->assertFalse(boolval($child->restricted), 'Child book should not be restricted by default');
+        $this->assertTrue($child->permissions()->count() === 0, 'Child book should have no permissions by default');
 
         $this->setEntityRestrictions($shelf, ['view', 'update'], [$editorRole]);
         $resp = $this->post($shelf->getUrl('/copy-permissions'));
         $child = $shelf->books()->first();
 
         $resp->assertRedirect($shelf->getUrl());
 
         $this->setEntityRestrictions($shelf, ['view', 'update'], [$editorRole]);
         $resp = $this->post($shelf->getUrl('/copy-permissions'));
         $child = $shelf->books()->first();
 
         $resp->assertRedirect($shelf->getUrl());
-        $this->assertTrue(boolval($child->restricted), "Child book should now be restricted");
-        $this->assertTrue($child->permissions()->count() === 2, "Child book should have copied permissions");
+        $this->assertTrue(boolval($child->restricted), 'Child book should now be restricted');
+        $this->assertTrue($child->permissions()->count() === 2, 'Child book should have copied permissions');
         $this->assertDatabaseHas('entity_permissions', ['restrictable_id' => $child->id, 'action' => 'view', 'role_id' => $editorRole->id]);
         $this->assertDatabaseHas('entity_permissions', ['restrictable_id' => $child->id, 'action' => 'update', 'role_id' => $editorRole->id]);
     }
         $this->assertDatabaseHas('entity_permissions', ['restrictable_id' => $child->id, 'action' => 'view', 'role_id' => $editorRole->id]);
         $this->assertDatabaseHas('entity_permissions', ['restrictable_id' => $child->id, 'action' => 'update', 'role_id' => $editorRole->id]);
     }
@@ -337,8 +338,8 @@ class BookShelfTest extends TestCase
     {
         // Create shelf
         $shelfInfo = [
     {
         // Create shelf
         $shelfInfo = [
-            'name' => 'My test shelf' . Str::random(4),
-            'description' => 'Test shelf description ' . Str::random(10)
+            'name'        => 'My test shelf' . Str::random(4),
+            'description' => 'Test shelf description ' . Str::random(10),
         ];
 
         $this->asEditor()->post('/shelves', $shelfInfo);
         ];
 
         $this->asEditor()->post('/shelves', $shelfInfo);
@@ -346,8 +347,8 @@ class BookShelfTest extends TestCase
 
         // Create book and add to shelf
         $this->asEditor()->post($shelf->getUrl('/create-book'), [
 
         // Create book and add to shelf
         $this->asEditor()->post($shelf->getUrl('/create-book'), [
-            'name' => 'Test book name',
-            'description' => 'Book in shelf description'
+            'name'        => 'Test book name',
+            'description' => 'Book in shelf description',
         ]);
 
         $newBook = Book::query()->orderBy('id', 'desc')->first();
         ]);
 
         $newBook = Book::query()->orderBy('id', 'desc')->first();
index e1b06431b43a2edda49d828ede935fd9392da66f..b4ba2fa8229a82ea7c9c709204dce46dda4781bb 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests\Entity;
+<?php
+
+namespace Tests\Entity;
 
 use BookStack\Entities\Models\Book;
 use Tests\TestCase;
 
 use BookStack\Entities\Models\Book;
 use Tests\TestCase;
@@ -46,4 +48,4 @@ class BookTest extends TestCase
         $resp->assertElementContains('#sibling-navigation', 'Previous');
         $resp->assertElementContains('#sibling-navigation', substr($chapter->name, 0, 20));
     }
         $resp->assertElementContains('#sibling-navigation', 'Previous');
         $resp->assertElementContains('#sibling-navigation', substr($chapter->name, 0, 20));
     }
-}
\ No newline at end of file
+}
index e9350a32be1636a39ddeb7c5d374badd8a4f1724..45c132e8917428d90b8333243513e77c3a38936c 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests\Entity;
+<?php
+
+namespace Tests\Entity;
 
 use BookStack\Entities\Models\Chapter;
 use Tests\TestCase;
 
 use BookStack\Entities\Models\Chapter;
 use Tests\TestCase;
@@ -28,4 +30,4 @@ class ChapterTest extends TestCase
         $redirectReq = $this->get($deleteReq->baseResponse->headers->get('location'));
         $redirectReq->assertNotificationContains('Chapter Successfully Deleted');
     }
         $redirectReq = $this->get($deleteReq->baseResponse->headers->get('location'));
         $redirectReq->assertNotificationContains('Chapter Successfully Deleted');
     }
-}
\ No newline at end of file
+}
index 5ab6ad9a81beb34f1620e019f4bfe8dbb6c56ea9..d8caa73585aebcd54dd085b87428878a3cd71d80 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests\Entity;
+<?php
+
+namespace Tests\Entity;
 
 use BookStack\Entities\Models\Page;
 use Tests\TestCase;
 
 use BookStack\Entities\Models\Page;
 use Tests\TestCase;
@@ -30,4 +32,4 @@ class CommentSettingTest extends TestCase
         $this->asAdmin()->get($this->page->getUrl())
             ->assertElementExists('.comments-list');
     }
         $this->asAdmin()->get($this->page->getUrl())
             ->assertElementExists('.comments-list');
     }
-}
\ No newline at end of file
+}
index 63d1a29a29ac656bf5d53ec38a00fad8102af35c..3bf51556e3cea5f87ee94b1d05c0560fc7abe69c 100644 (file)
@@ -1,12 +1,13 @@
-<?php namespace Tests\Entity;
+<?php
+
+namespace Tests\Entity;
 
 
-use BookStack\Entities\Models\Page;
 use BookStack\Actions\Comment;
 use BookStack\Actions\Comment;
+use BookStack\Entities\Models\Page;
 use Tests\TestCase;
 
 class CommentTest extends TestCase
 {
 use Tests\TestCase;
 
 class CommentTest extends TestCase
 {
-
     public function test_add_comment()
     {
         $this->asAdmin();
     public function test_add_comment()
     {
         $this->asAdmin();
@@ -22,11 +23,11 @@ class CommentTest extends TestCase
         $pageResp->assertSee($comment->text);
 
         $this->assertDatabaseHas('comments', [
         $pageResp->assertSee($comment->text);
 
         $this->assertDatabaseHas('comments', [
-            'local_id' => 1,
-            'entity_id' => $page->id,
+            'local_id'    => 1,
+            'entity_id'   => $page->id,
             'entity_type' => Page::newModelInstance()->getMorphClass(),
             'entity_type' => Page::newModelInstance()->getMorphClass(),
-            'text' => $comment->text,
-            'parent_id' => 2
+            'text'        => $comment->text,
+            'parent_id'   => 2,
         ]);
     }
 
         ]);
     }
 
@@ -49,8 +50,8 @@ class CommentTest extends TestCase
         $resp->assertDontSee($comment->text);
 
         $this->assertDatabaseHas('comments', [
         $resp->assertDontSee($comment->text);
 
         $this->assertDatabaseHas('comments', [
-            'text' => $newText,
-            'entity_id' => $page->id
+            'text'      => $newText,
+            'entity_id' => $page->id,
         ]);
     }
 
         ]);
     }
 
@@ -68,7 +69,7 @@ class CommentTest extends TestCase
         $resp->assertStatus(200);
 
         $this->assertDatabaseMissing('comments', [
         $resp->assertStatus(200);
 
         $this->assertDatabaseMissing('comments', [
-            'id' => $comment->id
+            'id' => $comment->id,
         ]);
     }
 
         ]);
     }
 
@@ -80,10 +81,10 @@ class CommentTest extends TestCase
         ]);
 
         $this->assertDatabaseHas('comments', [
         ]);
 
         $this->assertDatabaseHas('comments', [
-            'entity_id' => $page->id,
+            'entity_id'   => $page->id,
             'entity_type' => $page->getMorphClass(),
             'entity_type' => $page->getMorphClass(),
-            'text' => '# My Title',
-            'html' => "<h1>My Title</h1>\n",
+            'text'        => '# My Title',
+            'html'        => "<h1>My Title</h1>\n",
         ]);
 
         $pageView = $this->get($page->getUrl());
         ]);
 
         $pageView = $this->get($page->getUrl());
index 6b53b2cb61705cec2391217737ee83ee6a475a10..8d2ef0fded27bf40f86760b1c9f45b6e4c5c25a8 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests\Entity;
+<?php
+
+namespace Tests\Entity;
 
 use BookStack\Actions\Tag;
 use BookStack\Entities\Models\Book;
 
 use BookStack\Actions\Tag;
 use BookStack\Entities\Models\Book;
@@ -9,7 +11,6 @@ use Tests\TestCase;
 
 class EntitySearchTest extends TestCase
 {
 
 class EntitySearchTest extends TestCase
 {
-
     public function test_page_search()
     {
         $book = Book::all()->first();
     public function test_page_search()
     {
         $book = Book::all()->first();
@@ -80,13 +81,13 @@ class EntitySearchTest extends TestCase
     {
         $newTags = [
             new Tag([
     {
         $newTags = [
             new Tag([
-                'name' => 'animal',
-                'value' => 'cat'
+                'name'  => 'animal',
+                'value' => 'cat',
             ]),
             new Tag([
             ]),
             new Tag([
-                'name' => 'color',
-                'value' => 'red'
-            ])
+                'name'  => 'color',
+                'value' => 'red',
+            ]),
         ];
 
         $pageA = Page::first();
         ];
 
         $pageA = Page::first();
@@ -135,22 +136,22 @@ class EntitySearchTest extends TestCase
         $this->get('/search?term=' . urlencode('danzorbhsing {created_by:me}'))->assertDontSee($page->name);
         $this->get('/search?term=' . urlencode('danzorbhsing {updated_by:me}'))->assertDontSee($page->name);
         $this->get('/search?term=' . urlencode('danzorbhsing {owned_by:me}'))->assertDontSee($page->name);
         $this->get('/search?term=' . urlencode('danzorbhsing {created_by:me}'))->assertDontSee($page->name);
         $this->get('/search?term=' . urlencode('danzorbhsing {updated_by:me}'))->assertDontSee($page->name);
         $this->get('/search?term=' . urlencode('danzorbhsing {owned_by:me}'))->assertDontSee($page->name);
-        $this->get('/search?term=' . urlencode('danzorbhsing {updated_by:'.$editorSlug.'}'))->assertDontSee($page->name);
+        $this->get('/search?term=' . urlencode('danzorbhsing {updated_by:' . $editorSlug . '}'))->assertDontSee($page->name);
         $page->created_by = $editorId;
         $page->save();
         $this->get('/search?term=' . urlencode('danzorbhsing {created_by:me}'))->assertSee($page->name);
         $page->created_by = $editorId;
         $page->save();
         $this->get('/search?term=' . urlencode('danzorbhsing {created_by:me}'))->assertSee($page->name);
-        $this->get('/search?term=' . urlencode('danzorbhsing {created_by: '.$editorSlug.'}'))->assertSee($page->name);
+        $this->get('/search?term=' . urlencode('danzorbhsing {created_by: ' . $editorSlug . '}'))->assertSee($page->name);
         $this->get('/search?term=' . urlencode('danzorbhsing {updated_by:me}'))->assertDontSee($page->name);
         $this->get('/search?term=' . urlencode('danzorbhsing {owned_by:me}'))->assertDontSee($page->name);
         $page->updated_by = $editorId;
         $page->save();
         $this->get('/search?term=' . urlencode('danzorbhsing {updated_by:me}'))->assertSee($page->name);
         $this->get('/search?term=' . urlencode('danzorbhsing {updated_by:me}'))->assertDontSee($page->name);
         $this->get('/search?term=' . urlencode('danzorbhsing {owned_by:me}'))->assertDontSee($page->name);
         $page->updated_by = $editorId;
         $page->save();
         $this->get('/search?term=' . urlencode('danzorbhsing {updated_by:me}'))->assertSee($page->name);
-        $this->get('/search?term=' . urlencode('danzorbhsing {updated_by:'.$editorSlug.'}'))->assertSee($page->name);
+        $this->get('/search?term=' . urlencode('danzorbhsing {updated_by:' . $editorSlug . '}'))->assertSee($page->name);
         $this->get('/search?term=' . urlencode('danzorbhsing {owned_by:me}'))->assertDontSee($page->name);
         $page->owned_by = $editorId;
         $page->save();
         $this->get('/search?term=' . urlencode('danzorbhsing {owned_by:me}'))->assertSee($page->name);
         $this->get('/search?term=' . urlencode('danzorbhsing {owned_by:me}'))->assertDontSee($page->name);
         $page->owned_by = $editorId;
         $page->save();
         $this->get('/search?term=' . urlencode('danzorbhsing {owned_by:me}'))->assertSee($page->name);
-        $this->get('/search?term=' . urlencode('danzorbhsing {owned_by:'.$editorSlug.'}'))->assertSee($page->name);
+        $this->get('/search?term=' . urlencode('danzorbhsing {owned_by:' . $editorSlug . '}'))->assertSee($page->name);
 
         // Content filters
         $this->get('/search?term=' . urlencode('{in_name:danzorbhsing}'))->assertDontSee($page->name);
 
         // Content filters
         $this->get('/search?term=' . urlencode('{in_name:danzorbhsing}'))->assertDontSee($page->name);
index 52f9a3ae29cdba5e26ef6c13b85abf3bc359620a..f8c88b1fee11b733dfb75c9f2de7cd070ea63eb5 100644 (file)
@@ -1,17 +1,18 @@
-<?php namespace Tests\Entity;
+<?php
 
 
-use BookStack\Entities\Models\Bookshelf;
+namespace Tests\Entity;
+
+use BookStack\Auth\UserRepo;
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Book;
+use BookStack\Entities\Models\Bookshelf;
 use BookStack\Entities\Models\Chapter;
 use BookStack\Entities\Models\Page;
 use BookStack\Entities\Models\Chapter;
 use BookStack\Entities\Models\Page;
-use BookStack\Auth\UserRepo;
 use BookStack\Entities\Repos\PageRepo;
 use Carbon\Carbon;
 use Tests\BrowserKitTest;
 
 class EntityTest extends BrowserKitTest
 {
 use BookStack\Entities\Repos\PageRepo;
 use Carbon\Carbon;
 use Tests\BrowserKitTest;
 
 class EntityTest extends BrowserKitTest
 {
-
     public function test_entity_creation()
     {
         // Test Creation
     public function test_entity_creation()
     {
         // Test Creation
@@ -42,7 +43,7 @@ class EntityTest extends BrowserKitTest
 
     public function test_book_sort_page_shows()
     {
 
     public function test_book_sort_page_shows()
     {
-        $books =  Book::all();
+        $books = Book::all();
         $bookToSort = $books[0];
         $this->asAdmin()
             ->visit($bookToSort->getUrl())
         $bookToSort = $books[0];
         $this->asAdmin()
             ->visit($bookToSort->getUrl())
@@ -54,7 +55,7 @@ class EntityTest extends BrowserKitTest
 
     public function test_book_sort_item_returns_book_content()
     {
 
     public function test_book_sort_item_returns_book_content()
     {
-        $books =  Book::all();
+        $books = Book::all();
         $bookToSort = $books[0];
         $firstPage = $bookToSort->pages[0];
         $firstChapter = $bookToSort->chapters[0];
         $bookToSort = $books[0];
         $firstPage = $bookToSort->pages[0];
         $firstChapter = $bookToSort->chapters[0];
@@ -84,13 +85,12 @@ class EntityTest extends BrowserKitTest
             ->submitForm('Grid View')
             ->seePageIs('/books')
             ->pageHasElement('.featured-image-container');
             ->submitForm('Grid View')
             ->seePageIs('/books')
             ->pageHasElement('.featured-image-container');
-
     }
 
     public function pageCreation($chapter)
     {
         $page = factory(Page::class)->make([
     }
 
     public function pageCreation($chapter)
     {
         $page = factory(Page::class)->make([
-            'name' => 'My First Page'
+            'name' => 'My First Page',
         ]);
 
         $this->asAdmin()
         ]);
 
         $this->asAdmin()
@@ -110,13 +110,14 @@ class EntityTest extends BrowserKitTest
             ->see($page->name);
 
         $page = Page::where('slug', '=', 'my-first-page')->where('chapter_id', '=', $chapter->id)->first();
             ->see($page->name);
 
         $page = Page::where('slug', '=', 'my-first-page')->where('chapter_id', '=', $chapter->id)->first();
+
         return $page;
     }
 
     public function chapterCreation(Book $book)
     {
         $chapter = factory(Chapter::class)->make([
         return $page;
     }
 
     public function chapterCreation(Book $book)
     {
         $chapter = factory(Chapter::class)->make([
-            'name' => 'My First Chapter'
+            'name' => 'My First Chapter',
         ]);
 
         $this->asAdmin()
         ]);
 
         $this->asAdmin()
@@ -133,13 +134,14 @@ class EntityTest extends BrowserKitTest
             ->see($chapter->name)->see($chapter->description);
 
         $chapter = Chapter::where('slug', '=', 'my-first-chapter')->where('book_id', '=', $book->id)->first();
             ->see($chapter->name)->see($chapter->description);
 
         $chapter = Chapter::where('slug', '=', 'my-first-chapter')->where('book_id', '=', $book->id)->first();
+
         return $chapter;
     }
 
     public function bookCreation()
     {
         $book = factory(Book::class)->make([
         return $chapter;
     }
 
     public function bookCreation()
     {
         $book = factory(Book::class)->make([
-            'name' => 'My First Book'
+            'name' => 'My First Book',
         ]);
         $this->asAdmin()
             ->visit('/books')
         ]);
         $this->asAdmin()
             ->visit('/books')
@@ -165,6 +167,7 @@ class EntityTest extends BrowserKitTest
         $this->assertMatchesRegularExpression($expectedPattern, $this->currentUri, "Did not land on expected page [$expectedPattern].\n");
 
         $book = Book::where('slug', '=', 'my-first-book')->first();
         $this->assertMatchesRegularExpression($expectedPattern, $this->currentUri, "Did not land on expected page [$expectedPattern].\n");
 
         $book = Book::where('slug', '=', 'my-first-book')->first();
+
         return $book;
     }
 
         return $book;
     }
 
@@ -245,7 +248,7 @@ class EntityTest extends BrowserKitTest
     {
         $page = Page::orderBy('updated_at', 'asc')->first();
         Page::where('id', '!=', $page->id)->update([
     {
         $page = Page::orderBy('updated_at', 'asc')->first();
         Page::where('id', '!=', $page->id)->update([
-            'updated_at' => Carbon::now()->subSecond(1)
+            'updated_at' => Carbon::now()->subSecond(1),
         ]);
         $this->asAdmin()->visit('/')
             ->dontSeeInElement('#recently-updated-pages', $page->name);
         ]);
         $this->asAdmin()->visit('/')
             ->dontSeeInElement('#recently-updated-pages', $page->name);
@@ -258,13 +261,13 @@ class EntityTest extends BrowserKitTest
     public function test_slug_multi_byte_url_safe()
     {
         $book = $this->newBook([
     public function test_slug_multi_byte_url_safe()
     {
         $book = $this->newBook([
-            'name' => 'информация'
+            'name' => 'информация',
         ]);
 
         $this->assertEquals('informatsiya', $book->slug);
 
         $book = $this->newBook([
         ]);
 
         $this->assertEquals('informatsiya', $book->slug);
 
         $book = $this->newBook([
-            'name' => '¿Qué?'
+            'name' => '¿Qué?',
         ]);
 
         $this->assertEquals('que', $book->slug);
         ]);
 
         $this->assertEquals('que', $book->slug);
@@ -273,7 +276,7 @@ class EntityTest extends BrowserKitTest
     public function test_slug_format()
     {
         $book = $this->newBook([
     public function test_slug_format()
     {
         $book = $this->newBook([
-            'name' => 'PartA / PartB / PartC'
+            'name' => 'PartA / PartB / PartC',
         ]);
 
         $this->assertEquals('parta-partb-partc', $book->slug);
         ]);
 
         $this->assertEquals('parta-partb-partc', $book->slug);
@@ -313,5 +316,4 @@ class EntityTest extends BrowserKitTest
             ->submitForm('Confirm')
             ->seePageIs($chapter->getUrl());
     }
             ->submitForm('Confirm')
             ->seePageIs($chapter->getUrl());
     }
-
 }
 }
index f437904e842517375b20599142a538f07ebfe0ab..4c6fb1a74f43da2c09011c42f9dabb1267bca328 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests\Entity;
+<?php
+
+namespace Tests\Entity;
 
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Chapter;
 
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Chapter;
@@ -9,7 +11,6 @@ use Tests\TestCase;
 
 class ExportTest extends TestCase
 {
 
 class ExportTest extends TestCase
 {
-
     public function test_page_text_export()
     {
         $page = Page::query()->first();
     public function test_page_text_export()
     {
         $page = Page::query()->first();
@@ -133,7 +134,7 @@ class ExportTest extends TestCase
     {
         $page = Page::query()->first();
 
     {
         $page = Page::query()->first();
 
-        $customHeadContent = "<style>p{color: red;}</style>";
+        $customHeadContent = '<style>p{color: red;}</style>';
         $this->setSettings(['app-custom-head' => $customHeadContent]);
 
         $resp = $this->asEditor()->get($page->getUrl('/export/html'));
         $this->setSettings(['app-custom-head' => $customHeadContent]);
 
         $resp = $this->asEditor()->get($page->getUrl('/export/html'));
@@ -144,7 +145,7 @@ class ExportTest extends TestCase
     {
         $page = Page::query()->first();
 
     {
         $page = Page::query()->first();
 
-        $customHeadContent = "<!-- A comment -->";
+        $customHeadContent = '<!-- A comment -->';
         $this->setSettings(['app-custom-head' => $customHeadContent]);
 
         $resp = $this->asEditor()->get($page->getUrl('/export/html'));
         $this->setSettings(['app-custom-head' => $customHeadContent]);
 
         $resp = $this->asEditor()->get($page->getUrl('/export/html'));
@@ -209,8 +210,8 @@ class ExportTest extends TestCase
     {
         $page = Page::query()->first();
         $page->html = '<img src="http://localhost/uploads/images/gallery/svg_test.svg"/>'
     {
         $page = Page::query()->first();
         $page->html = '<img src="http://localhost/uploads/images/gallery/svg_test.svg"/>'
-            .'<img src="http://localhost/uploads/svg_test.svg"/>'
-            .'<img src="/uploads/svg_test.svg"/>';
+            . '<img src="http://localhost/uploads/svg_test.svg"/>'
+            . '<img src="/uploads/svg_test.svg"/>';
         $storageDisk = Storage::disk('local');
         $storageDisk->makeDirectory('uploads/images/gallery');
         $storageDisk->put('uploads/images/gallery/svg_test.svg', '<svg>good</svg>');
         $storageDisk = Storage::disk('local');
         $storageDisk->makeDirectory('uploads/images/gallery');
         $storageDisk->put('uploads/images/gallery/svg_test.svg', '<svg>good</svg>');
@@ -273,7 +274,7 @@ class ExportTest extends TestCase
     {
         $page = Page::query()->first()->forceFill([
             'markdown' => '# A header',
     {
         $page = Page::query()->first()->forceFill([
             'markdown' => '# A header',
-            'html' => '<h1>Dogcat</h1>',
+            'html'     => '<h1>Dogcat</h1>',
         ]);
         $page->save();
 
         ]);
         $page->save();
 
@@ -286,7 +287,7 @@ class ExportTest extends TestCase
     {
         $page = Page::query()->first()->forceFill([
             'markdown' => '',
     {
         $page = Page::query()->first()->forceFill([
             'markdown' => '',
-            'html' => "<h1>Dogcat</h1><p>Some <strong>bold</strong> text</p>",
+            'html'     => '<h1>Dogcat</h1><p>Some <strong>bold</strong> text</p>',
         ]);
         $page->save();
 
         ]);
         $page->save();
 
@@ -298,7 +299,7 @@ class ExportTest extends TestCase
     {
         $page = Page::query()->first()->forceFill([
             'markdown' => '',
     {
         $page = Page::query()->first()->forceFill([
             'markdown' => '',
-            'html' => "<h1>Dogcat</h1><p class=\"callout info\">Some callout text</p><p>Another line</p>",
+            'html'     => '<h1>Dogcat</h1><p class="callout info">Some callout text</p><p>Another line</p>',
         ]);
         $page->save();
 
         ]);
         $page->save();
 
@@ -310,7 +311,7 @@ class ExportTest extends TestCase
     {
         $page = Page::query()->first()->forceFill([
             'markdown' => '',
     {
         $page = Page::query()->first()->forceFill([
             'markdown' => '',
-            'html' => '<h1>Dogcat</h1>'."\r\n".'<pre id="bkmrk-var-a-%3D-%27cat%27%3B"><code class="language-JavaScript">var a = \'cat\';</code></pre><p>Another line</p>',
+            'html'     => '<h1>Dogcat</h1>' . "\r\n" . '<pre id="bkmrk-var-a-%3D-%27cat%27%3B"><code class="language-JavaScript">var a = \'cat\';</code></pre><p>Another line</p>',
         ]);
         $page->save();
 
         ]);
         $page->save();
 
@@ -339,5 +340,4 @@ class ExportTest extends TestCase
         $resp->assertSee('# ' . $chapter->name);
         $resp->assertSee('# ' . $page->name);
     }
         $resp->assertSee('# ' . $chapter->name);
         $resp->assertSee('# ' . $page->name);
     }
-
 }
 }
index 5e5fa8a0c2f7b52427784e295bef3b935e250294..7de7ea11bc6dcd5871939acb6d58c89d9d68fdd2 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests\Entity;
+<?php
+
+namespace Tests\Entity;
 
 use Tests\BrowserKitTest;
 
 
 use Tests\BrowserKitTest;
 
@@ -23,7 +25,7 @@ class MarkdownTest extends BrowserKitTest
         $this->asAdmin()->visit($this->page->getUrl() . '/edit')
             ->pageHasElement('#html-editor');
     }
         $this->asAdmin()->visit($this->page->getUrl() . '/edit')
             ->pageHasElement('#html-editor');
     }
-    
+
     public function test_markdown_setting_shows_markdown_editor()
     {
         $this->setMarkdownEditor();
     public function test_markdown_setting_shows_markdown_editor()
     {
         $this->setMarkdownEditor();
@@ -48,5 +50,4 @@ class MarkdownTest extends BrowserKitTest
         $this->asAdmin()->visit($this->page->getUrl() . '/edit')
             ->seeInField('markdown', $this->page->html);
     }
         $this->asAdmin()->visit($this->page->getUrl() . '/edit')
             ->seeInField('markdown', $this->page->html);
     }
-
-}
\ No newline at end of file
+}
index f1462dbd08a61ecd07770a47d612e546368b3ddf..6021987259db69290053cc344c4f3f75957c9788 100644 (file)
@@ -1,7 +1,9 @@
-<?php namespace Tests\Entity;
+<?php
+
+namespace Tests\Entity;
 
 
-use BookStack\Entities\Tools\PageContent;
 use BookStack\Entities\Models\Page;
 use BookStack\Entities\Models\Page;
+use BookStack\Entities\Tools\PageContent;
 use Tests\TestCase;
 use Tests\Uploads\UsesImages;
 
 use Tests\TestCase;
 use Tests\Uploads\UsesImages;
 
@@ -131,7 +133,6 @@ class PageContentTest extends TestCase
             $pageView->assertElementNotContains('.page-content', '<script>');
             $pageView->assertElementNotContains('.page-content', '</script>');
         }
             $pageView->assertElementNotContains('.page-content', '<script>');
             $pageView->assertElementNotContains('.page-content', '</script>');
         }
-
     }
 
     public function test_iframe_js_and_base64_urls_are_removed()
     }
 
     public function test_iframe_js_and_base64_urls_are_removed()
@@ -141,7 +142,7 @@ class PageContentTest extends TestCase
             '<iframe SRC=" javascript: alert(document.cookie)"></iframe>',
             '<iframe src="data:text/html;base64,PHNjcmlwdD5hbGVydCgnaGVsbG8nKTwvc2NyaXB0Pg==" frameborder="0"></iframe>',
             '<iframe src=" data:text/html;base64,PHNjcmlwdD5hbGVydCgnaGVsbG8nKTwvc2NyaXB0Pg==" frameborder="0"></iframe>',
             '<iframe SRC=" javascript: alert(document.cookie)"></iframe>',
             '<iframe src="data:text/html;base64,PHNjcmlwdD5hbGVydCgnaGVsbG8nKTwvc2NyaXB0Pg==" frameborder="0"></iframe>',
             '<iframe src=" data:text/html;base64,PHNjcmlwdD5hbGVydCgnaGVsbG8nKTwvc2NyaXB0Pg==" frameborder="0"></iframe>',
-            '<iframe srcdoc="<script>window.alert(document.cookie)</script>"></iframe>'
+            '<iframe srcdoc="<script>window.alert(document.cookie)</script>"></iframe>',
         ];
 
         $this->asEditor();
         ];
 
         $this->asEditor();
@@ -160,14 +161,13 @@ class PageContentTest extends TestCase
             $pageView->assertElementNotContains('.page-content', 'data:');
             $pageView->assertElementNotContains('.page-content', 'base64');
         }
             $pageView->assertElementNotContains('.page-content', 'data:');
             $pageView->assertElementNotContains('.page-content', 'base64');
         }
-
     }
 
     public function test_javascript_uri_links_are_removed()
     {
         $checks = [
             '<a id="xss" href="javascript:alert(document.cookie)>Click me</a>',
     }
 
     public function test_javascript_uri_links_are_removed()
     {
         $checks = [
             '<a id="xss" href="javascript:alert(document.cookie)>Click me</a>',
-            '<a id="xss" href="javascript: alert(document.cookie)>Click me</a>'
+            '<a id="xss" href="javascript: alert(document.cookie)>Click me</a>',
         ];
 
         $this->asEditor();
         ];
 
         $this->asEditor();
@@ -183,12 +183,13 @@ class PageContentTest extends TestCase
             $pageView->assertElementNotContains('.page-content', 'href=javascript:');
         }
     }
             $pageView->assertElementNotContains('.page-content', 'href=javascript:');
         }
     }
+
     public function test_form_actions_with_javascript_are_removed()
     {
         $checks = [
             '<form><input id="xss" type=submit formaction=javascript:alert(document.domain) value=Submit><input></form>',
             '<form ><button id="xss" formaction=javascript:alert(document.domain)>Click me</button></form>',
     public function test_form_actions_with_javascript_are_removed()
     {
         $checks = [
             '<form><input id="xss" type=submit formaction=javascript:alert(document.domain) value=Submit><input></form>',
             '<form ><button id="xss" formaction=javascript:alert(document.domain)>Click me</button></form>',
-            '<form id="xss" action=javascript:alert(document.domain)><input type=submit value=Submit></form>'
+            '<form id="xss" action=javascript:alert(document.domain)><input type=submit value=Submit></form>',
         ];
 
         $this->asEditor();
         ];
 
         $this->asEditor();
@@ -207,7 +208,7 @@ class PageContentTest extends TestCase
             $pageView->assertElementNotContains('.page-content', 'formaction=javascript:');
         }
     }
             $pageView->assertElementNotContains('.page-content', 'formaction=javascript:');
         }
     }
-    
+
     public function test_metadata_redirects_are_removed()
     {
         $checks = [
     public function test_metadata_redirects_are_removed()
     {
         $checks = [
@@ -229,6 +230,7 @@ class PageContentTest extends TestCase
             $pageView->assertElementNotContains('.page-content', 'external_url');
         }
     }
             $pageView->assertElementNotContains('.page-content', 'external_url');
         }
     }
+
     public function test_page_inline_on_attributes_removed_by_default()
     {
         $this->asEditor();
     public function test_page_inline_on_attributes_removed_by_default()
     {
         $this->asEditor();
@@ -265,7 +267,6 @@ class PageContentTest extends TestCase
             $pageView->assertStatus(200);
             $pageView->assertElementNotContains('.page-content', 'onclick');
         }
             $pageView->assertStatus(200);
             $pageView->assertElementNotContains('.page-content', 'onclick');
         }
-
     }
 
     public function test_page_content_scripts_show_when_configured()
     }
 
     public function test_page_content_scripts_show_when_configured()
@@ -308,7 +309,7 @@ class PageContentTest extends TestCase
         $pageA->html = $content;
         $pageA->save();
 
         $pageA->html = $content;
         $pageA->save();
 
-        $pageB->html = '<ul id="bkmrk-xxx-%28"></ul> <p>{{@'. $pageA->id .'#test}}</p>';
+        $pageB->html = '<ul id="bkmrk-xxx-%28"></ul> <p>{{@' . $pageA->id . '#test}}</p>';
         $pageB->save();
 
         $pageView = $this->get($pageB->getUrl());
         $pageB->save();
 
         $pageView = $this->get($pageB->getUrl());
@@ -322,14 +323,14 @@ class PageContentTest extends TestCase
 
         $content = '<ul id="bkmrk-test"><li>test a</li><li><ul id="bkmrk-test"><li>test b</li></ul></li></ul>';
         $pageSave = $this->put($page->getUrl(), [
 
         $content = '<ul id="bkmrk-test"><li>test a</li><li><ul id="bkmrk-test"><li>test b</li></ul></li></ul>';
         $pageSave = $this->put($page->getUrl(), [
-            'name' => $page->name,
-            'html' => $content,
-            'summary' => ''
+            'name'    => $page->name,
+            'html'    => $content,
+            'summary' => '',
         ]);
         $pageSave->assertRedirect();
 
         $updatedPage = Page::query()->where('id', '=', $page->id)->first();
         ]);
         $pageSave->assertRedirect();
 
         $updatedPage = Page::query()->where('id', '=', $page->id)->first();
-        $this->assertEquals(substr_count($updatedPage->html, "bkmrk-test\""), 1);
+        $this->assertEquals(substr_count($updatedPage->html, 'bkmrk-test"'), 1);
     }
 
     public function test_anchors_referencing_non_bkmrk_ids_rewritten_after_save()
     }
 
     public function test_anchors_referencing_non_bkmrk_ids_rewritten_after_save()
@@ -339,9 +340,9 @@ class PageContentTest extends TestCase
 
         $content = '<h1 id="non-standard-id">test</h1><p><a href="#non-standard-id">link</a></p>';
         $this->put($page->getUrl(), [
 
         $content = '<h1 id="non-standard-id">test</h1><p><a href="#non-standard-id">link</a></p>';
         $this->put($page->getUrl(), [
-            'name' => $page->name,
-            'html' => $content,
-            'summary' => ''
+            'name'    => $page->name,
+            'html'    => $content,
+            'summary' => '',
         ]);
 
         $updatedPage = Page::query()->where('id', '=', $page->id)->first();
         ]);
 
         $updatedPage = Page::query()->where('id', '=', $page->id)->first();
@@ -358,21 +359,21 @@ class PageContentTest extends TestCase
         $this->assertCount(3, $navMap);
         $this->assertArrayMapIncludes([
             'nodeName' => 'h1',
         $this->assertCount(3, $navMap);
         $this->assertArrayMapIncludes([
             'nodeName' => 'h1',
-            'link' => '#testa',
-            'text' => 'Hello',
-            'level' => 1,
+            'link'     => '#testa',
+            'text'     => 'Hello',
+            'level'    => 1,
         ], $navMap[0]);
         $this->assertArrayMapIncludes([
             'nodeName' => 'h2',
         ], $navMap[0]);
         $this->assertArrayMapIncludes([
             'nodeName' => 'h2',
-            'link' => '#testb',
-            'text' => 'There',
-            'level' => 2,
+            'link'     => '#testb',
+            'text'     => 'There',
+            'level'    => 2,
         ], $navMap[1]);
         $this->assertArrayMapIncludes([
             'nodeName' => 'h3',
         ], $navMap[1]);
         $this->assertArrayMapIncludes([
             'nodeName' => 'h3',
-            'link' => '#testc',
-            'text' => 'Donkey',
-            'level' => 3,
+            'link'     => '#testc',
+            'text'     => 'Donkey',
+            'level'    => 3,
         ], $navMap[2]);
     }
 
         ], $navMap[2]);
     }
 
@@ -385,8 +386,8 @@ class PageContentTest extends TestCase
         $this->assertCount(1, $navMap);
         $this->assertArrayMapIncludes([
             'nodeName' => 'h1',
         $this->assertCount(1, $navMap);
         $this->assertArrayMapIncludes([
             'nodeName' => 'h1',
-            'link' => '#testa',
-            'text' => 'Hello'
+            'link'     => '#testa',
+            'text'     => 'Hello',
         ], $navMap[0]);
     }
 
         ], $navMap[0]);
     }
 
@@ -399,15 +400,15 @@ class PageContentTest extends TestCase
         $this->assertCount(3, $navMap);
         $this->assertArrayMapIncludes([
             'nodeName' => 'h4',
         $this->assertCount(3, $navMap);
         $this->assertArrayMapIncludes([
             'nodeName' => 'h4',
-            'level' => 1,
+            'level'    => 1,
         ], $navMap[0]);
         $this->assertArrayMapIncludes([
             'nodeName' => 'h5',
         ], $navMap[0]);
         $this->assertArrayMapIncludes([
             'nodeName' => 'h5',
-            'level' => 2,
+            'level'    => 2,
         ], $navMap[1]);
         $this->assertArrayMapIncludes([
             'nodeName' => 'h6',
         ], $navMap[1]);
         $this->assertArrayMapIncludes([
             'nodeName' => 'h6',
-            'level' => 3,
+            'level'    => 3,
         ], $navMap[2]);
     }
 
         ], $navMap[2]);
     }
 
@@ -436,7 +437,7 @@ class PageContentTest extends TestCase
 | Paragraph   | Text        |';
         $this->put($page->getUrl(), [
             'name' => $page->name,  'markdown' => $content,
 | Paragraph   | Text        |';
         $this->put($page->getUrl(), [
             'name' => $page->name,  'markdown' => $content,
-            'html' => '', 'summary' => ''
+            'html' => '', 'summary' => '',
         ]);
 
         $page->refresh();
         ]);
 
         $page->refresh();
@@ -455,7 +456,7 @@ class PageContentTest extends TestCase
 - [x] Item b';
         $this->put($page->getUrl(), [
             'name' => $page->name,  'markdown' => $content,
 - [x] Item b';
         $this->put($page->getUrl(), [
             'name' => $page->name,  'markdown' => $content,
-            'html' => '', 'summary' => ''
+            'html' => '', 'summary' => '',
         ]);
 
         $page->refresh();
         ]);
 
         $page->refresh();
@@ -474,7 +475,7 @@ class PageContentTest extends TestCase
         $content = '~~some crossed out text~~';
         $this->put($page->getUrl(), [
             'name' => $page->name,  'markdown' => $content,
         $content = '~~some crossed out text~~';
         $this->put($page->getUrl(), [
             'name' => $page->name,  'markdown' => $content,
-            'html' => '', 'summary' => ''
+            'html' => '', 'summary' => '',
         ]);
 
         $page->refresh();
         ]);
 
         $page->refresh();
@@ -492,7 +493,7 @@ class PageContentTest extends TestCase
         $content = '<!-- Test Comment -->';
         $this->put($page->getUrl(), [
             'name' => $page->name,  'markdown' => $content,
         $content = '<!-- Test Comment -->';
         $this->put($page->getUrl(), [
             'name' => $page->name,  'markdown' => $content,
-            'html' => '', 'summary' => ''
+            'html' => '', 'summary' => '',
         ]);
 
         $page->refresh();
         ]);
 
         $page->refresh();
@@ -510,7 +511,7 @@ class PageContentTest extends TestCase
 
         $this->put($page->getUrl(), [
             'name' => $page->name, 'summary' => '',
 
         $this->put($page->getUrl(), [
             'name' => $page->name, 'summary' => '',
-            'html' => '<p>test<img src="data:image/jpeg;base64,'.$this->base64Jpeg.'"/></p>',
+            'html' => '<p>test<img src="data:image/jpeg;base64,' . $this->base64Jpeg . '"/></p>',
         ]);
 
         $page->refresh();
         ]);
 
         $page->refresh();
@@ -534,7 +535,7 @@ class PageContentTest extends TestCase
         $base64PngWithoutWhitespace = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQAB';
         $this->put($page->getUrl(), [
             'name' => $page->name, 'summary' => '',
         $base64PngWithoutWhitespace = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQAB';
         $this->put($page->getUrl(), [
             'name' => $page->name, 'summary' => '',
-            'html' => '<p>test<img src="data:image/png;base64,'.$base64PngWithWhitespace.'"/></p>',
+            'html' => '<p>test<img src="data:image/png;base64,' . $base64PngWithWhitespace . '"/></p>',
         ]);
 
         $page->refresh();
         ]);
 
         $page->refresh();
@@ -556,7 +557,7 @@ class PageContentTest extends TestCase
 
         $this->put($page->getUrl(), [
             'name' => $page->name, 'summary' => '',
 
         $this->put($page->getUrl(), [
             'name' => $page->name, 'summary' => '',
-            'html' => '<p>test<img src="data:image/jiff;base64,'.$this->base64Jpeg.'"/></p>',
+            'html' => '<p>test<img src="data:image/jiff;base64,' . $this->base64Jpeg . '"/></p>',
         ]);
 
         $page->refresh();
         ]);
 
         $page->refresh();
index 0e3980c6702217cd10043748a9d8ad89dbb18bcc..68059af6e7126d1c2b75487d425b6c684a8aca3e 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests\Entity;
+<?php
+
+namespace Tests\Entity;
 
 use BookStack\Entities\Models\Page;
 use BookStack\Entities\Repos\PageRepo;
 
 use BookStack\Entities\Models\Page;
 use BookStack\Entities\Repos\PageRepo;
@@ -68,7 +70,7 @@ class PageDraftTest extends BrowserKitTest
         $this->actingAs($newUser)
             ->visit($this->page->getUrl('/edit'))
             ->see('Admin has started editing this page');
         $this->actingAs($newUser)
             ->visit($this->page->getUrl('/edit'))
             ->see('Admin has started editing this page');
-            $this->flushSession();
+        $this->flushSession();
         $this->visit($nonEditedPage->getUrl() . '/edit')
             ->dontSeeInElement('.notification', 'Admin has started editing this page');
     }
         $this->visit($nonEditedPage->getUrl() . '/edit')
             ->dontSeeInElement('.notification', 'Admin has started editing this page');
     }
@@ -112,5 +114,4 @@ class PageDraftTest extends BrowserKitTest
             'html' => $page->html,
         ]);
     }
             'html' => $page->html,
         ]);
     }
-
 }
 }
index 62fbfbf3140d46b1544b9af26fdb60e38a4c8f9b..2ed7d3b411e86b8990cc0b000740ec2a79a26bbd 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests\Entity;
+<?php
+
+namespace Tests\Entity;
 
 use BookStack\Entities\Models\Page;
 use BookStack\Entities\Repos\PageRepo;
 
 use BookStack\Entities\Models\Page;
 use BookStack\Entities\Repos\PageRepo;
@@ -47,8 +49,7 @@ class PageRevisionTest extends TestCase
         $page = Page::first();
         $pageRepo->update($page, ['name' => 'updated page abc123', 'html' => '<p>new contente def456</p>', 'summary' => 'initial page revision testing']);
         $pageRepo->update($page, ['name' => 'updated page again', 'html' => '<p>new content</p>', 'summary' => 'page revision testing']);
         $page = Page::first();
         $pageRepo->update($page, ['name' => 'updated page abc123', 'html' => '<p>new contente def456</p>', 'summary' => 'initial page revision testing']);
         $pageRepo->update($page, ['name' => 'updated page again', 'html' => '<p>new content</p>', 'summary' => 'page revision testing']);
-        $page =  Page::find($page->id);
-
+        $page = Page::find($page->id);
 
         $pageView = $this->get($page->getUrl());
         $pageView->assertDontSee('abc123');
 
         $pageView = $this->get($page->getUrl());
         $pageView->assertDontSee('abc123');
@@ -56,7 +57,7 @@ class PageRevisionTest extends TestCase
 
         $revToRestore = $page->revisions()->where('name', 'like', '%abc123')->first();
         $restoreReq = $this->put($page->getUrl() . '/revisions/' . $revToRestore->id . '/restore');
 
         $revToRestore = $page->revisions()->where('name', 'like', '%abc123')->first();
         $restoreReq = $this->put($page->getUrl() . '/revisions/' . $revToRestore->id . '/restore');
-        $page =  Page::find($page->id);
+        $page = Page::find($page->id);
 
         $restoreReq->assertStatus(302);
         $restoreReq->assertRedirect($page->getUrl());
 
         $restoreReq->assertStatus(302);
         $restoreReq->assertRedirect($page->getUrl());
@@ -89,7 +90,7 @@ class PageRevisionTest extends TestCase
 
         $pageView = $this->get($page->getUrl());
         $this->assertDatabaseHas('pages', [
 
         $pageView = $this->get($page->getUrl());
         $this->assertDatabaseHas('pages', [
-            'id' => $page->id,
+            'id'       => $page->id,
             'markdown' => '## New Content def456',
         ]);
         $pageView->assertSee('abc123');
             'markdown' => '## New Content def456',
         ]);
         $pageView->assertSee('abc123');
@@ -112,8 +113,8 @@ class PageRevisionTest extends TestCase
 
         $this->assertDatabaseHas('page_revisions', [
             'page_id' => $page->id,
 
         $this->assertDatabaseHas('page_revisions', [
             'page_id' => $page->id,
-            'text' => 'new contente def456',
-            'type' => 'version',
+            'text'    => 'new contente def456',
+            'type'    => 'version',
             'summary' => "Restored from #{$revToRestore->id}; My first update",
         ]);
     }
             'summary' => "Restored from #{$revToRestore->id}; My first update",
         ]);
     }
@@ -125,7 +126,7 @@ class PageRevisionTest extends TestCase
         $resp = $this->asEditor()->put($page->getUrl(), ['name' => 'Updated page', 'html' => 'new page html', 'summary' => 'Update a']);
         $resp->assertStatus(302);
 
         $resp = $this->asEditor()->put($page->getUrl(), ['name' => 'Updated page', 'html' => 'new page html', 'summary' => 'Update a']);
         $resp->assertStatus(302);
 
-        $this->assertTrue(Page::find($page->id)->revision_count === $startCount+1);
+        $this->assertTrue(Page::find($page->id)->revision_count === $startCount + 1);
     }
 
     public function test_revision_count_shown_in_page_meta()
     }
 
     public function test_revision_count_shown_in_page_meta()
@@ -141,7 +142,8 @@ class PageRevisionTest extends TestCase
         $pageView->assertSee('Revision #' . $page->revision_count);
     }
 
         $pageView->assertSee('Revision #' . $page->revision_count);
     }
 
-    public function test_revision_deletion() {
+    public function test_revision_deletion()
+    {
         $page = Page::first();
         $this->asEditor()->put($page->getUrl(), ['name' => 'Updated page', 'html' => 'new page html', 'summary' => 'Update a']);
 
         $page = Page::first();
         $this->asEditor()->put($page->getUrl(), ['name' => 'Updated page', 'html' => 'new page html', 'summary' => 'Update a']);
 
@@ -201,4 +203,4 @@ class PageRevisionTest extends TestCase
         $revisionCount = $page->revisions()->count();
         $this->assertEquals(12, $revisionCount);
     }
         $revisionCount = $page->revisions()->count();
         $this->assertEquals(12, $revisionCount);
     }
-}
\ No newline at end of file
+}
index a5594e8b8df06ececf95ae1df6d8256590738e91..3d16895102f5a5f6af570119f2e5234a365e7aaf 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests\Entity;
+<?php
+
+namespace Tests\Entity;
 
 use BookStack\Entities\Models\Page;
 use Tests\TestCase;
 
 use BookStack\Entities\Models\Page;
 use Tests\TestCase;
@@ -27,14 +29,14 @@ class PageTemplateTest extends TestCase
         $this->actingAs($editor);
 
         $pageUpdateData = [
         $this->actingAs($editor);
 
         $pageUpdateData = [
-            'name' => $page->name,
-            'html' => $page->html,
+            'name'     => $page->name,
+            'html'     => $page->html,
             'template' => 'true',
         ];
 
         $this->put($page->getUrl(), $pageUpdateData);
         $this->assertDatabaseHas('pages', [
             'template' => 'true',
         ];
 
         $this->put($page->getUrl(), $pageUpdateData);
         $this->assertDatabaseHas('pages', [
-            'id' => $page->id,
+            'id'       => $page->id,
             'template' => false,
         ]);
 
             'template' => false,
         ]);
 
@@ -42,7 +44,7 @@ class PageTemplateTest extends TestCase
 
         $this->put($page->getUrl(), $pageUpdateData);
         $this->assertDatabaseHas('pages', [
 
         $this->put($page->getUrl(), $pageUpdateData);
         $this->assertDatabaseHas('pages', [
-            'id' => $page->id,
+            'id'       => $page->id,
             'template' => true,
         ]);
     }
             'template' => true,
         ]);
     }
@@ -64,7 +66,7 @@ class PageTemplateTest extends TestCase
         $templateFetch = $this->get('/templates/' . $page->id);
         $templateFetch->assertStatus(200);
         $templateFetch->assertJson([
         $templateFetch = $this->get('/templates/' . $page->id);
         $templateFetch->assertStatus(200);
         $templateFetch->assertJson([
-            'html' => $content,
+            'html'     => $content,
             'markdown' => '',
         ]);
     }
             'markdown' => '',
         ]);
     }
@@ -86,5 +88,4 @@ class PageTemplateTest extends TestCase
         $templatesFetch->assertSee($page->name);
         $templatesFetch->assertSee('pagination');
     }
         $templatesFetch->assertSee($page->name);
         $templatesFetch->assertSee('pagination');
     }
-
-}
\ No newline at end of file
+}
index a6f6f9d508e070b0c5a41b007a6ad72a72a1ee58..2721c225cd66c487f823d6e075e552f406ce6549 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests\Entity;
+<?php
+
+namespace Tests\Entity;
 
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Page;
 
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Page;
@@ -6,7 +8,6 @@ use Tests\TestCase;
 
 class PageTest extends TestCase
 {
 
 class PageTest extends TestCase
 {
-
     public function test_page_view_when_creator_is_deleted_but_owner_exists()
     {
         $page = Page::query()->first();
     public function test_page_view_when_creator_is_deleted_but_owner_exists()
     {
         $page = Page::query()->first();
@@ -33,22 +34,22 @@ class PageTest extends TestCase
 
         $details = [
             'markdown' => '# a title',
 
         $details = [
             'markdown' => '# a title',
-            'html' => '<h1>a title</h1>',
-            'name' => 'my page',
+            'html'     => '<h1>a title</h1>',
+            'name'     => 'my page',
         ];
         $resp = $this->post($book->getUrl("/draft/{$draft->id}"), $details);
         $resp->assertRedirect();
 
         $this->assertDatabaseHas('pages', [
             'markdown' => $details['markdown'],
         ];
         $resp = $this->post($book->getUrl("/draft/{$draft->id}"), $details);
         $resp->assertRedirect();
 
         $this->assertDatabaseHas('pages', [
             'markdown' => $details['markdown'],
-            'name' => $details['name'],
-            'id' => $draft->id,
-            'draft' => false
+            'name'     => $details['name'],
+            'id'       => $draft->id,
+            'draft'    => false,
         ]);
 
         $draft->refresh();
         ]);
 
         $draft->refresh();
-        $resp = $this->get($draft->getUrl("/edit"));
-        $resp->assertSee("# a title");
+        $resp = $this->get($draft->getUrl('/edit'));
+        $resp->assertSee('# a title');
     }
 
     public function test_page_delete()
     }
 
     public function test_page_delete()
@@ -112,7 +113,7 @@ class PageTest extends TestCase
 
         $movePageResp = $this->post($page->getUrl('/copy'), [
             'entity_selection' => 'book:' . $newBook->id,
 
         $movePageResp = $this->post($page->getUrl('/copy'), [
             'entity_selection' => 'book:' . $newBook->id,
-            'name' => 'My copied test page'
+            'name'             => 'My copied test page',
         ]);
         $pageCopy = Page::where('name', '=', 'My copied test page')->first();
 
         ]);
         $pageCopy = Page::where('name', '=', 'My copied test page')->first();
 
@@ -131,7 +132,7 @@ class PageTest extends TestCase
 
         $this->asEditor()->post($page->getUrl('/copy'), [
             'entity_selection' => 'book:' . $newBook->id,
 
         $this->asEditor()->post($page->getUrl('/copy'), [
             'entity_selection' => 'book:' . $newBook->id,
-            'name' => 'My copied test page'
+            'name'             => 'My copied test page',
         ]);
         $pageCopy = Page::where('name', '=', 'My copied test page')->first();
 
         ]);
         $pageCopy = Page::where('name', '=', 'My copied test page')->first();
 
@@ -148,7 +149,7 @@ class PageTest extends TestCase
         $resp->assertSee('Copy Page');
 
         $movePageResp = $this->post($page->getUrl('/copy'), [
         $resp->assertSee('Copy Page');
 
         $movePageResp = $this->post($page->getUrl('/copy'), [
-            'name' => 'My copied test page'
+            'name' => 'My copied test page',
         ]);
 
         $pageCopy = Page::where('name', '=', 'My copied test page')->first();
         ]);
 
         $pageCopy = Page::where('name', '=', 'My copied test page')->first();
@@ -178,14 +179,14 @@ class PageTest extends TestCase
 
         $movePageResp = $this->post($page->getUrl('/copy'), [
             'entity_selection' => 'book:' . $newBook->id,
 
         $movePageResp = $this->post($page->getUrl('/copy'), [
             'entity_selection' => 'book:' . $newBook->id,
-            'name' => 'My copied test page'
+            'name'             => 'My copied test page',
         ]);
         $movePageResp->assertRedirect();
 
         $this->assertDatabaseHas('pages', [
         ]);
         $movePageResp->assertRedirect();
 
         $this->assertDatabaseHas('pages', [
-            'name' => 'My copied test page',
+            'name'       => 'My copied test page',
             'created_by' => $viewer->id,
             'created_by' => $viewer->id,
-            'book_id' => $newBook->id,
+            'book_id'    => $newBook->id,
         ]);
     }
 
         ]);
     }
 
@@ -199,7 +200,7 @@ class PageTest extends TestCase
             ->where('draft', '=', true)->first();
 
         $details = [
             ->where('draft', '=', true)->first();
 
         $details = [
-            'name' => 'my page',
+            'name'     => 'my page',
             'markdown' => '',
         ];
         $resp = $this->post($book->getUrl("/draft/{$draft->id}"), $details);
             'markdown' => '',
         ];
         $resp = $this->post($book->getUrl("/draft/{$draft->id}"), $details);
@@ -207,8 +208,8 @@ class PageTest extends TestCase
 
         $this->assertDatabaseHas('pages', [
             'markdown' => $details['markdown'],
 
         $this->assertDatabaseHas('pages', [
             'markdown' => $details['markdown'],
-            'id' => $draft->id,
-            'draft' => false
+            'id'       => $draft->id,
+            'draft'    => false,
         ]);
     }
         ]);
     }
-}
\ No newline at end of file
+}
index c9e116523ed0fdf943622fc4c6a77a7d07ceb689..25a0ae7209572b18145e1cf9411c8fff4b2edd93 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests\Entity;
+<?php
+
+namespace Tests\Entity;
 
 use BookStack\Entities\Tools\SearchOptions;
 use Tests\TestCase;
 
 use BookStack\Entities\Tools\SearchOptions;
 use Tests\TestCase;
@@ -18,7 +20,7 @@ class SearchOptionsTest extends TestCase
     public function test_to_string_includes_all_items_in_the_correct_format()
     {
         $expected = 'cat "dog" [tag=good] {is_tree}';
     public function test_to_string_includes_all_items_in_the_correct_format()
     {
         $expected = 'cat "dog" [tag=good] {is_tree}';
-        $options = new SearchOptions;
+        $options = new SearchOptions();
         $options->searches = ['cat'];
         $options->exacts = ['dog'];
         $options->tags = ['tag=good'];
         $options->searches = ['cat'];
         $options->exacts = ['dog'];
         $options->tags = ['tag=good'];
@@ -36,8 +38,8 @@ class SearchOptionsTest extends TestCase
 
         $this->assertEquals([
             'is_tree' => '',
 
         $this->assertEquals([
             'is_tree' => '',
-            'name' => 'dan',
-            'cat' => 'happy',
+            'name'    => 'dan',
+            'cat'     => 'happy',
         ], $opts->filters);
     }
 }
         ], $opts->filters);
     }
 }
index c27c41f29120e83bb7e635568a4c5b98e6b9e261..f3d50b67d96940dec49edc73b02de062edac2e4d 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests\Entity;
+<?php
+
+namespace Tests\Entity;
 
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Chapter;
 
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Chapter;
@@ -39,7 +41,7 @@ class SortTest extends TestCase
         $resp->assertSee('Move Page');
 
         $movePageResp = $this->put($page->getUrl('/move'), [
         $resp->assertSee('Move Page');
 
         $movePageResp = $this->put($page->getUrl('/move'), [
-            'entity_selection' => 'book:' . $newBook->id
+            'entity_selection' => 'book:' . $newBook->id,
         ]);
         $page = Page::find($page->id);
 
         ]);
         $page = Page::find($page->id);
 
@@ -59,7 +61,7 @@ class SortTest extends TestCase
         $newChapter = $newBook->chapters()->first();
 
         $movePageResp = $this->actingAs($this->getEditor())->put($page->getUrl('/move'), [
         $newChapter = $newBook->chapters()->first();
 
         $movePageResp = $this->actingAs($this->getEditor())->put($page->getUrl('/move'), [
-            'entity_selection' => 'chapter:' . $newChapter->id
+            'entity_selection' => 'chapter:' . $newChapter->id,
         ]);
         $page = Page::find($page->id);
 
         ]);
         $page = Page::find($page->id);
 
@@ -77,7 +79,7 @@ class SortTest extends TestCase
         $newBook = Book::where('id', '!=', $oldChapter->book_id)->first();
 
         $movePageResp = $this->actingAs($this->getEditor())->put($page->getUrl('/move'), [
         $newBook = Book::where('id', '!=', $oldChapter->book_id)->first();
 
         $movePageResp = $this->actingAs($this->getEditor())->put($page->getUrl('/move'), [
-            'entity_selection' => 'book:' . $newBook->id
+            'entity_selection' => 'book:' . $newBook->id,
         ]);
         $page->refresh();
 
         ]);
         $page->refresh();
 
@@ -99,13 +101,13 @@ class SortTest extends TestCase
         $this->setEntityRestrictions($newBook, ['view', 'update', 'delete'], $editor->roles->all());
 
         $movePageResp = $this->actingAs($editor)->put($page->getUrl('/move'), [
         $this->setEntityRestrictions($newBook, ['view', 'update', 'delete'], $editor->roles->all());
 
         $movePageResp = $this->actingAs($editor)->put($page->getUrl('/move'), [
-            'entity_selection' => 'book:' . $newBook->id
+            'entity_selection' => 'book:' . $newBook->id,
         ]);
         $this->assertPermissionError($movePageResp);
 
         $this->setEntityRestrictions($newBook, ['view', 'update', 'delete', 'create'], $editor->roles->all());
         $movePageResp = $this->put($page->getUrl('/move'), [
         ]);
         $this->assertPermissionError($movePageResp);
 
         $this->setEntityRestrictions($newBook, ['view', 'update', 'delete', 'create'], $editor->roles->all());
         $movePageResp = $this->put($page->getUrl('/move'), [
-            'entity_selection' => 'book:' . $newBook->id
+            'entity_selection' => 'book:' . $newBook->id,
         ]);
 
         $page = Page::find($page->id);
         ]);
 
         $page = Page::find($page->id);
@@ -125,7 +127,7 @@ class SortTest extends TestCase
         $this->setEntityRestrictions($page, ['view', 'update', 'create'], $editor->roles->all());
 
         $movePageResp = $this->actingAs($editor)->put($page->getUrl('/move'), [
         $this->setEntityRestrictions($page, ['view', 'update', 'create'], $editor->roles->all());
 
         $movePageResp = $this->actingAs($editor)->put($page->getUrl('/move'), [
-            'entity_selection' => 'book:' . $newBook->id
+            'entity_selection' => 'book:' . $newBook->id,
         ]);
         $this->assertPermissionError($movePageResp);
         $pageView = $this->get($page->getUrl());
         ]);
         $this->assertPermissionError($movePageResp);
         $pageView = $this->get($page->getUrl());
@@ -133,7 +135,7 @@ class SortTest extends TestCase
 
         $this->setEntityRestrictions($page, ['view', 'update', 'create', 'delete'], $editor->roles->all());
         $movePageResp = $this->put($page->getUrl('/move'), [
 
         $this->setEntityRestrictions($page, ['view', 'update', 'create', 'delete'], $editor->roles->all());
         $movePageResp = $this->put($page->getUrl('/move'), [
-            'entity_selection' => 'book:' . $newBook->id
+            'entity_selection' => 'book:' . $newBook->id,
         ]);
 
         $page = Page::find($page->id);
         ]);
 
         $page = Page::find($page->id);
@@ -152,7 +154,7 @@ class SortTest extends TestCase
         $chapterMoveResp->assertSee('Move Chapter');
 
         $moveChapterResp = $this->put($chapter->getUrl('/move'), [
         $chapterMoveResp->assertSee('Move Chapter');
 
         $moveChapterResp = $this->put($chapter->getUrl('/move'), [
-            'entity_selection' => 'book:' . $newBook->id
+            'entity_selection' => 'book:' . $newBook->id,
         ]);
 
         $chapter = Chapter::find($chapter->id);
         ]);
 
         $chapter = Chapter::find($chapter->id);
@@ -180,7 +182,7 @@ class SortTest extends TestCase
         $this->setEntityRestrictions($chapter, ['view', 'update', 'create'], $editor->roles->all());
 
         $moveChapterResp = $this->actingAs($editor)->put($chapter->getUrl('/move'), [
         $this->setEntityRestrictions($chapter, ['view', 'update', 'create'], $editor->roles->all());
 
         $moveChapterResp = $this->actingAs($editor)->put($chapter->getUrl('/move'), [
-            'entity_selection' => 'book:' . $newBook->id
+            'entity_selection' => 'book:' . $newBook->id,
         ]);
         $this->assertPermissionError($moveChapterResp);
         $pageView = $this->get($chapter->getUrl());
         ]);
         $this->assertPermissionError($moveChapterResp);
         $pageView = $this->get($chapter->getUrl());
@@ -188,7 +190,7 @@ class SortTest extends TestCase
 
         $this->setEntityRestrictions($chapter, ['view', 'update', 'create', 'delete'], $editor->roles->all());
         $moveChapterResp = $this->put($chapter->getUrl('/move'), [
 
         $this->setEntityRestrictions($chapter, ['view', 'update', 'create', 'delete'], $editor->roles->all());
         $moveChapterResp = $this->put($chapter->getUrl('/move'), [
-            'entity_selection' => 'book:' . $newBook->id
+            'entity_selection' => 'book:' . $newBook->id,
         ]);
 
         $chapter = Chapter::find($chapter->id);
         ]);
 
         $chapter = Chapter::find($chapter->id);
@@ -207,7 +209,7 @@ class SortTest extends TestCase
         $pageToCheck->delete();
 
         $this->asEditor()->put($chapter->getUrl('/move'), [
         $pageToCheck->delete();
 
         $this->asEditor()->put($chapter->getUrl('/move'), [
-            'entity_selection' => 'book:' . $newBook->id
+            'entity_selection' => 'book:' . $newBook->id,
         ]);
 
         $pageToCheck->refresh();
         ]);
 
         $pageToCheck->refresh();
@@ -224,20 +226,20 @@ class SortTest extends TestCase
         // Create request data
         $reqData = [
             [
         // Create request data
         $reqData = [
             [
-                'id' => $chapterToMove->id,
-                'sort' => 0,
+                'id'            => $chapterToMove->id,
+                'sort'          => 0,
                 'parentChapter' => false,
                 'parentChapter' => false,
-                'type' => 'chapter',
-                'book' => $newBook->id
-            ]
+                'type'          => 'chapter',
+                'book'          => $newBook->id,
+            ],
         ];
         foreach ($pagesToMove as $index => $page) {
             $reqData[] = [
         ];
         foreach ($pagesToMove as $index => $page) {
             $reqData[] = [
-                'id' => $page->id,
-                'sort' => $index,
+                'id'            => $page->id,
+                'sort'          => $index,
                 'parentChapter' => $index === count($pagesToMove) - 1 ? $chapterToMove->id : false,
                 'parentChapter' => $index === count($pagesToMove) - 1 ? $chapterToMove->id : false,
-                'type' => 'page',
-                'book' => $newBook->id
+                'type'          => 'page',
+                'book'          => $newBook->id,
             ];
         }
 
             ];
         }
 
@@ -245,9 +247,9 @@ class SortTest extends TestCase
         $sortResp->assertRedirect($newBook->getUrl());
         $sortResp->assertStatus(302);
         $this->assertDatabaseHas('chapters', [
         $sortResp->assertRedirect($newBook->getUrl());
         $sortResp->assertStatus(302);
         $this->assertDatabaseHas('chapters', [
-            'id' => $chapterToMove->id,
-            'book_id' => $newBook->id,
-            'priority' => 0
+            'id'       => $chapterToMove->id,
+            'book_id'  => $newBook->id,
+            'priority' => 0,
         ]);
         $this->assertTrue($newBook->chapters()->count() === 1);
         $this->assertTrue($newBook->chapters()->first()->pages()->count() === 1);
         ]);
         $this->assertTrue($newBook->chapters()->count() === 1);
         $this->assertTrue($newBook->chapters()->first()->pages()->count() === 1);
@@ -256,5 +258,4 @@ class SortTest extends TestCase
         $checkResp = $this->get(Page::find($checkPage->id)->getUrl());
         $checkResp->assertSee($newBook->name);
     }
         $checkResp = $this->get(Page::find($checkPage->id)->getUrl());
         $checkResp->assertSee($newBook->name);
     }
-
-}
\ No newline at end of file
+}
index 62ebf5f1ba4e68840fddad353a0f10020a5c982b..74da37f4a867cbea8f6ced182a33f06ad4f12a0b 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests\Entity;
+<?php
+
+namespace Tests\Entity;
 
 use BookStack\Actions\Tag;
 use BookStack\Entities\Models\Entity;
 
 use BookStack\Actions\Tag;
 use BookStack\Entities\Models\Entity;
@@ -7,7 +9,6 @@ use Tests\TestCase;
 
 class TagTest extends TestCase
 {
 
 class TagTest extends TestCase
 {
-
     protected $defaultTagCount = 20;
 
     /**
     protected $defaultTagCount = 20;
 
     /**
@@ -22,6 +23,7 @@ class TagTest extends TestCase
         }
 
         $entity->tags()->saveMany($tags);
         }
 
         $entity->tags()->saveMany($tags);
+
         return $entity;
     }
 
         return $entity;
     }
 
@@ -89,12 +91,11 @@ class TagTest extends TestCase
         ];
 
         $page = $this->getEntityWithTags(Page::class, $tags);
         ];
 
         $page = $this->getEntityWithTags(Page::class, $tags);
-        $resp = $this->asEditor()->get("/search?term=[category]");
+        $resp = $this->asEditor()->get('/search?term=[category]');
         $resp->assertSee($page->name);
         $resp->assertElementContains('[href="' . $page->getUrl() . '"]', 'category');
         $resp->assertElementContains('[href="' . $page->getUrl() . '"]', 'buckets');
         $resp->assertElementContains('[href="' . $page->getUrl() . '"]', 'color');
         $resp->assertElementContains('[href="' . $page->getUrl() . '"]', 'red');
     }
         $resp->assertSee($page->name);
         $resp->assertElementContains('[href="' . $page->getUrl() . '"]', 'category');
         $resp->assertElementContains('[href="' . $page->getUrl() . '"]', 'buckets');
         $resp->assertElementContains('[href="' . $page->getUrl() . '"]', 'color');
         $resp->assertElementContains('[href="' . $page->getUrl() . '"]', 'red');
     }
-
 }
 }
index 6b69355fcd3a8cc218469557e0b45b48258e190c..2eeb6537e0e0b9afaf5823ad99a66e2eab7a1322 100644 (file)
@@ -1,11 +1,12 @@
-<?php namespace Tests;
+<?php
+
+namespace Tests;
 
 use BookStack\Entities\Models\Book;
 use Illuminate\Support\Facades\Log;
 
 class ErrorTest extends TestCase
 {
 
 use BookStack\Entities\Models\Book;
 use Illuminate\Support\Facades\Log;
 
 class ErrorTest extends TestCase
 {
-
     public function test_404_page_does_not_show_login()
     {
         // Due to middleware being handled differently this will not fail
     public function test_404_page_does_not_show_login()
     {
         // Due to middleware being handled differently this will not fail
@@ -45,4 +46,4 @@ class ErrorTest extends TestCase
         $resp->assertStatus(404);
         $resp->assertSeeText('Image Not Found');
     }
         $resp->assertStatus(404);
         $resp->assertSeeText('Image Not Found');
     }
-}
\ No newline at end of file
+}
index 7209063c92ba3a5181ac9c905342e922776147ef..a0f11886e5a23760c1e9122f2a76071c7df43df9 100644 (file)
@@ -9,7 +9,6 @@ use Tests\TestCase;
 
 class FavouriteTest extends TestCase
 {
 
 class FavouriteTest extends TestCase
 {
-
     public function test_page_add_favourite_flow()
     {
         $page = Page::query()->first();
     public function test_page_add_favourite_flow()
     {
         $page = Page::query()->first();
@@ -21,15 +20,15 @@ class FavouriteTest extends TestCase
 
         $resp = $this->post('/favourites/add', [
             'type' => get_class($page),
 
         $resp = $this->post('/favourites/add', [
             'type' => get_class($page),
-            'id' => $page->id,
+            'id'   => $page->id,
         ]);
         $resp->assertRedirect($page->getUrl());
         $resp->assertSessionHas('success', "\"{$page->name}\" has been added to your favourites");
 
         $this->assertDatabaseHas('favourites', [
         ]);
         $resp->assertRedirect($page->getUrl());
         $resp->assertSessionHas('success', "\"{$page->name}\" has been added to your favourites");
 
         $this->assertDatabaseHas('favourites', [
-            'user_id' => $editor->id,
+            'user_id'           => $editor->id,
             'favouritable_type' => $page->getMorphClass(),
             'favouritable_type' => $page->getMorphClass(),
-            'favouritable_id' => $page->id,
+            'favouritable_id'   => $page->id,
         ]);
     }
 
         ]);
     }
 
@@ -38,8 +37,8 @@ class FavouriteTest extends TestCase
         $page = Page::query()->first();
         $editor = $this->getEditor();
         Favourite::query()->forceCreate([
         $page = Page::query()->first();
         $editor = $this->getEditor();
         Favourite::query()->forceCreate([
-            'user_id' => $editor->id,
-            'favouritable_id' => $page->id,
+            'user_id'           => $editor->id,
+            'favouritable_id'   => $page->id,
             'favouritable_type' => $page->getMorphClass(),
         ]);
 
             'favouritable_type' => $page->getMorphClass(),
         ]);
 
@@ -49,7 +48,7 @@ class FavouriteTest extends TestCase
 
         $resp = $this->post('/favourites/remove', [
             'type' => get_class($page),
 
         $resp = $this->post('/favourites/remove', [
             'type' => get_class($page),
-            'id' => $page->id,
+            'id'   => $page->id,
         ]);
         $resp->assertRedirect($page->getUrl());
         $resp->assertSessionHas('success', "\"{$page->name}\" has been removed from your favourites");
         ]);
         $resp->assertRedirect($page->getUrl());
         $resp->assertSessionHas('success', "\"{$page->name}\" has been removed from your favourites");
@@ -90,7 +89,7 @@ class FavouriteTest extends TestCase
 
         /** @var Page $page */
         $page = Page::query()->first();
 
         /** @var Page $page */
         $page = Page::query()->first();
-        $page->favourites()->save((new Favourite)->forceFill(['user_id' => $editor->id]));
+        $page->favourites()->save((new Favourite())->forceFill(['user_id' => $editor->id]));
 
         $resp = $this->get('/');
         $resp->assertElementExists('#top-favourites');
 
         $resp = $this->get('/');
         $resp->assertElementExists('#top-favourites');
@@ -106,7 +105,7 @@ class FavouriteTest extends TestCase
         $resp = $this->actingAs($editor)->get('/favourites');
         $resp->assertDontSee($page->name);
 
         $resp = $this->actingAs($editor)->get('/favourites');
         $resp->assertDontSee($page->name);
 
-        $page->favourites()->save((new Favourite)->forceFill(['user_id' => $editor->id]));
+        $page->favourites()->save((new Favourite())->forceFill(['user_id' => $editor->id]));
 
         $resp = $this->get('/favourites');
         $resp->assertSee($page->name);
 
         $resp = $this->get('/favourites');
         $resp->assertSee($page->name);
@@ -114,5 +113,4 @@ class FavouriteTest extends TestCase
         $resp = $this->get('/favourites?page=2');
         $resp->assertDontSee($page->name);
     }
         $resp = $this->get('/favourites?page=2');
         $resp->assertDontSee($page->name);
     }
-
-}
\ No newline at end of file
+}
index f0ff0c40da5b946e617c174c5740559962228db7..cb2959411cf49be89ef99a104bf781799e6a3cb7 100644 (file)
@@ -4,10 +4,9 @@ use Tests\TestCase;
 
 class FooterLinksTest extends TestCase
 {
 
 class FooterLinksTest extends TestCase
 {
-
     public function test_saving_setting()
     {
     public function test_saving_setting()
     {
-        $resp = $this->asAdmin()->post("/settings", [
+        $resp = $this->asAdmin()->post('/settings', [
             'setting-app-footer-links' => [
                 ['label' => 'My custom link 1', 'url' => 'https://example.com/1'],
                 ['label' => 'My custom link 2', 'url' => 'https://example.com/2'],
             'setting-app-footer-links' => [
                 ['label' => 'My custom link 1', 'url' => 'https://example.com/1'],
                 ['label' => 'My custom link 2', 'url' => 'https://example.com/2'],
@@ -58,4 +57,4 @@ class FooterLinksTest extends TestCase
         $resp->assertElementContains('footer a[href="https://example.com/privacy"]', 'Privacy Policy');
         $resp->assertElementContains('footer a[href="https://example.com/terms"]', 'Terms of Service');
     }
         $resp->assertElementContains('footer a[href="https://example.com/privacy"]', 'Privacy Policy');
         $resp->assertElementContains('footer a[href="https://example.com/terms"]', 'Terms of Service');
     }
-}
\ No newline at end of file
+}
index a8e33465d108b1b9ad5000ef796ce761789b3db4..db4e94c6d11b1a03fe6a0a12e40e61f36dddbfdc 100644 (file)
@@ -1,13 +1,13 @@
-<?php namespace Tests;
+<?php
+
+namespace Tests;
 
 use BookStack\Auth\Role;
 use BookStack\Auth\User;
 use BookStack\Entities\Models\Bookshelf;
 
 use BookStack\Auth\Role;
 use BookStack\Auth\User;
 use BookStack\Entities\Models\Bookshelf;
-use BookStack\Entities\Models\Page;
 
 class HomepageTest extends TestCase
 {
 
 class HomepageTest extends TestCase
 {
-
     public function test_default_homepage_visible()
     {
         $this->asEditor();
     public function test_default_homepage_visible()
     {
         $this->asEditor();
@@ -42,8 +42,8 @@ class HomepageTest extends TestCase
         $content = str_repeat('This is the body content of my custom homepage.', 20);
         $customPage = $this->newPage(['name' => $name, 'html' => $content]);
         $this->setSettings([
         $content = str_repeat('This is the body content of my custom homepage.', 20);
         $customPage = $this->newPage(['name' => $name, 'html' => $content]);
         $this->setSettings([
-            'app-homepage' => $customPage->id,
-            'app-homepage-type' => 'page'
+            'app-homepage'      => $customPage->id,
+            'app-homepage-type' => 'page',
         ]);
 
         $homeVisit = $this->get('/');
         ]);
 
         $homeVisit = $this->get('/');
@@ -68,8 +68,8 @@ class HomepageTest extends TestCase
         $content = str_repeat('This is the body content of my custom homepage.', 20);
         $customPage = $this->newPage(['name' => $name, 'html' => $content]);
         $this->setSettings([
         $content = str_repeat('This is the body content of my custom homepage.', 20);
         $customPage = $this->newPage(['name' => $name, 'html' => $content]);
         $this->setSettings([
-            'app-homepage' => $customPage->id,
-            'app-homepage-type' => 'default'
+            'app-homepage'      => $customPage->id,
+            'app-homepage-type' => 'default',
         ]);
 
         $pageDeleteReq = $this->delete($customPage->getUrl());
         ]);
 
         $pageDeleteReq = $this->delete($customPage->getUrl());
index d5c6e453238ead0b3d82f0d805d23f7983fdf676..a9070248e5f86ab4fc333d0110e72d6a42ecf2a4 100644 (file)
@@ -1,8 +1,9 @@
-<?php namespace Tests;
+<?php
+
+namespace Tests;
 
 class LanguageTest extends TestCase
 {
 
 class LanguageTest extends TestCase
 {
-
     protected $langs;
 
     /**
     protected $langs;
 
     /**
@@ -61,6 +62,7 @@ class LanguageTest extends TestCase
         foreach ($this->langs as $lang) {
             foreach ($files as $file) {
                 $loadError = false;
         foreach ($this->langs as $lang) {
             foreach ($files as $file) {
                 $loadError = false;
+
                 try {
                     $translations = trans(str_replace('.php', '', $file), [], $lang);
                 } catch (\Exception $e) {
                 try {
                     $translations = trans(str_replace('.php', '', $file), [], $lang);
                 } catch (\Exception $e) {
@@ -74,10 +76,9 @@ class LanguageTest extends TestCase
     public function test_rtl_config_set_if_lang_is_rtl()
     {
         $this->asEditor();
     public function test_rtl_config_set_if_lang_is_rtl()
     {
         $this->asEditor();
-        $this->assertFalse(config('app.rtl'), "App RTL config should be false by default");
+        $this->assertFalse(config('app.rtl'), 'App RTL config should be false by default');
         setting()->putUser($this->getEditor(), 'language', 'ar');
         $this->get('/');
         setting()->putUser($this->getEditor(), 'language', 'ar');
         $this->get('/');
-        $this->assertTrue(config('app.rtl'), "App RTL config should have been set to true by middleware");
+        $this->assertTrue(config('app.rtl'), 'App RTL config should have been set to true by middleware');
     }
     }
-
-}
\ No newline at end of file
+}
index 653f2e57e27e21d6b34af73de86f38d07d215c30..17a5aa2c56faaf50cb4e9fbd6ad5ca828cba76a1 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests;
+<?php
+
+namespace Tests;
 
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Bookshelf;
 
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Bookshelf;
@@ -97,6 +99,4 @@ class OpenGraphTest extends TestCase
 
         return $tags;
     }
 
         return $tags;
     }
-
-
-}
\ No newline at end of file
+}
index 2f06bff2e8e766cb360826ec436b2321a55715f9..fe508668eae6fb660504dd3684d882a289753b8a 100644 (file)
@@ -1,16 +1,16 @@
-<?php namespace Tests\Permissions;
+<?php
+
+namespace Tests\Permissions;
 
 use BookStack\Auth\User;
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Bookshelf;
 use BookStack\Entities\Models\Chapter;
 use BookStack\Entities\Models\Page;
 
 use BookStack\Auth\User;
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Bookshelf;
 use BookStack\Entities\Models\Chapter;
 use BookStack\Entities\Models\Page;
-use Illuminate\Support\Str;
 use Tests\TestCase;
 
 class EntityOwnerChangeTest extends TestCase
 {
 use Tests\TestCase;
 
 class EntityOwnerChangeTest extends TestCase
 {
-
     public function test_changing_page_owner()
     {
         $page = Page::query()->first();
     public function test_changing_page_owner()
     {
         $page = Page::query()->first();
@@ -46,5 +46,4 @@ class EntityOwnerChangeTest extends TestCase
         $this->asAdmin()->put($shelf->getUrl('permissions'), ['owned_by' => $user->id]);
         $this->assertDatabaseHas('bookshelves', ['owned_by' => $user->id, 'id' => $shelf->id]);
     }
         $this->asAdmin()->put($shelf->getUrl('permissions'), ['owned_by' => $user->id]);
         $this->assertDatabaseHas('bookshelves', ['owned_by' => $user->id, 'id' => $shelf->id]);
     }
-
-}
\ No newline at end of file
+}
index 8dc112e57d8f8182775c4bcc8d60ff3a65e43b12..77c62fdb500b88352aa5354305d0a1612ae57047 100644 (file)
@@ -1,17 +1,18 @@
-<?php namespace Tests\Permissions;
+<?php
 
 
+namespace Tests\Permissions;
+
+use BookStack\Auth\User;
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Bookshelf;
 use BookStack\Entities\Models\Chapter;
 use BookStack\Entities\Models\Entity;
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Bookshelf;
 use BookStack\Entities\Models\Chapter;
 use BookStack\Entities\Models\Entity;
-use BookStack\Auth\User;
 use BookStack\Entities\Models\Page;
 use Illuminate\Support\Str;
 use Tests\BrowserKitTest;
 
 class EntityPermissionsTest extends BrowserKitTest
 {
 use BookStack\Entities\Models\Page;
 use Illuminate\Support\Str;
 use Tests\BrowserKitTest;
 
 class EntityPermissionsTest extends BrowserKitTest
 {
-
     /**
      * @var User
      */
     /**
      * @var User
      */
@@ -266,7 +267,6 @@ class EntityPermissionsTest extends BrowserKitTest
 
         $this->setRestrictionsForTestRoles($chapter, ['view', 'create']);
 
 
         $this->setRestrictionsForTestRoles($chapter, ['view', 'create']);
 
-
         $this->visit($chapterUrl . '/create-page')
             ->type('test page', 'name')
             ->type('test content', 'html')
         $this->visit($chapterUrl . '/create-page')
             ->type('test page', 'name')
             ->type('test content', 'html')
@@ -396,10 +396,10 @@ class EntityPermissionsTest extends BrowserKitTest
             ->press('Save Permissions')
             ->seeInDatabase('bookshelves', ['id' => $shelf->id, 'restricted' => true])
             ->seeInDatabase('entity_permissions', [
             ->press('Save Permissions')
             ->seeInDatabase('bookshelves', ['id' => $shelf->id, 'restricted' => true])
             ->seeInDatabase('entity_permissions', [
-                'restrictable_id' => $shelf->id,
+                'restrictable_id'   => $shelf->id,
                 'restrictable_type' => Bookshelf::newModelInstance()->getMorphClass(),
                 'restrictable_type' => Bookshelf::newModelInstance()->getMorphClass(),
-                'role_id' => '2',
-                'action' => 'view'
+                'role_id'           => '2',
+                'action'            => 'view',
             ]);
     }
 
             ]);
     }
 
@@ -413,10 +413,10 @@ class EntityPermissionsTest extends BrowserKitTest
             ->press('Save Permissions')
             ->seeInDatabase('books', ['id' => $book->id, 'restricted' => true])
             ->seeInDatabase('entity_permissions', [
             ->press('Save Permissions')
             ->seeInDatabase('books', ['id' => $book->id, 'restricted' => true])
             ->seeInDatabase('entity_permissions', [
-                'restrictable_id' => $book->id,
+                'restrictable_id'   => $book->id,
                 'restrictable_type' => Book::newModelInstance()->getMorphClass(),
                 'restrictable_type' => Book::newModelInstance()->getMorphClass(),
-                'role_id' => '2',
-                'action' => 'view'
+                'role_id'           => '2',
+                'action'            => 'view',
             ]);
     }
 
             ]);
     }
 
@@ -430,10 +430,10 @@ class EntityPermissionsTest extends BrowserKitTest
             ->press('Save Permissions')
             ->seeInDatabase('chapters', ['id' => $chapter->id, 'restricted' => true])
             ->seeInDatabase('entity_permissions', [
             ->press('Save Permissions')
             ->seeInDatabase('chapters', ['id' => $chapter->id, 'restricted' => true])
             ->seeInDatabase('entity_permissions', [
-                'restrictable_id' => $chapter->id,
+                'restrictable_id'   => $chapter->id,
                 'restrictable_type' => Chapter::newModelInstance()->getMorphClass(),
                 'restrictable_type' => Chapter::newModelInstance()->getMorphClass(),
-                'role_id' => '2',
-                'action' => 'update'
+                'role_id'           => '2',
+                'action'            => 'update',
             ]);
     }
 
             ]);
     }
 
@@ -447,10 +447,10 @@ class EntityPermissionsTest extends BrowserKitTest
             ->press('Save Permissions')
             ->seeInDatabase('pages', ['id' => $page->id, 'restricted' => true])
             ->seeInDatabase('entity_permissions', [
             ->press('Save Permissions')
             ->seeInDatabase('pages', ['id' => $page->id, 'restricted' => true])
             ->seeInDatabase('entity_permissions', [
-                'restrictable_id' => $page->id,
+                'restrictable_id'   => $page->id,
                 'restrictable_type' => Page::newModelInstance()->getMorphClass(),
                 'restrictable_type' => Page::newModelInstance()->getMorphClass(),
-                'role_id' => '2',
-                'action' => 'delete'
+                'role_id'           => '2',
+                'action'            => 'delete',
             ]);
     }
 
             ]);
     }
 
@@ -679,7 +679,8 @@ class EntityPermissionsTest extends BrowserKitTest
         $this->actingAs($this->user)->visit($firstBook->getUrl() . '/sort');
     }
 
         $this->actingAs($this->user)->visit($firstBook->getUrl() . '/sort');
     }
 
-    public function test_book_sort_permission() {
+    public function test_book_sort_permission()
+    {
         $firstBook = Book::first();
         $secondBook = Book::find(2);
 
         $firstBook = Book::first();
         $secondBook = Book::find(2);
 
@@ -692,12 +693,12 @@ class EntityPermissionsTest extends BrowserKitTest
         // Create request data
         $reqData = [
             [
         // Create request data
         $reqData = [
             [
-                'id' => $firstBookChapter->id,
-                'sort' => 0,
+                'id'            => $firstBookChapter->id,
+                'sort'          => 0,
                 'parentChapter' => false,
                 'parentChapter' => false,
-                'type' => 'chapter',
-                'book' => $secondBook->id
-            ]
+                'type'          => 'chapter',
+                'book'          => $secondBook->id,
+            ],
         ];
 
         // Move chapter from first book to a second book
         ];
 
         // Move chapter from first book to a second book
@@ -708,12 +709,12 @@ class EntityPermissionsTest extends BrowserKitTest
 
         $reqData = [
             [
 
         $reqData = [
             [
-                'id' => $secondBookChapter->id,
-                'sort' => 0,
+                'id'            => $secondBookChapter->id,
+                'sort'          => 0,
                 'parentChapter' => false,
                 'parentChapter' => false,
-                'type' => 'chapter',
-                'book' => $firstBook->id
-            ]
+                'type'          => 'chapter',
+                'book'          => $firstBook->id,
+            ],
         ];
 
         // Move chapter from second book to first book
         ];
 
         // Move chapter from second book to first book
index e5a1146a59b8803fdb0073cd566863b617505a89..2e3d84fa13e23a263870252f7201f2ed9818a827 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests\Permissions;
+<?php
+
+namespace Tests\Permissions;
 
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Chapter;
 
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Chapter;
@@ -7,7 +9,6 @@ use Tests\TestCase;
 
 class ExportPermissionsTest extends TestCase
 {
 
 class ExportPermissionsTest extends TestCase
 {
-
     public function test_page_content_without_view_access_hidden_on_chapter_export()
     {
         $chapter = Chapter::query()->first();
     public function test_page_content_without_view_access_hidden_on_chapter_export()
     {
         $chapter = Chapter::query()->first();
@@ -63,5 +64,4 @@ class ExportPermissionsTest extends TestCase
             $resp->assertDontSee($pageContent);
         }
     }
             $resp->assertDontSee($pageContent);
         }
     }
-
-}
\ No newline at end of file
+}
index 8398d08281a12d4e0239ae1531f4817d86b0c1a5..09c3233e38c3dd77a6d758be55d068b637e15b2c 100644 (file)
@@ -1,12 +1,14 @@
-<?php namespace Tests\Permissions;
+<?php
+
+namespace Tests\Permissions;
 
 use BookStack\Actions\Comment;
 
 use BookStack\Actions\Comment;
+use BookStack\Auth\Role;
 use BookStack\Auth\User;
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Bookshelf;
 use BookStack\Entities\Models\Chapter;
 use BookStack\Entities\Models\Page;
 use BookStack\Auth\User;
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Bookshelf;
 use BookStack\Entities\Models\Chapter;
 use BookStack\Entities\Models\Page;
-use BookStack\Auth\Role;
 use BookStack\Uploads\Image;
 use Laravel\BrowserKitTesting\HttpException;
 use Tests\BrowserKitTest;
 use BookStack\Uploads\Image;
 use Laravel\BrowserKitTesting\HttpException;
 use Tests\BrowserKitTest;
@@ -93,11 +95,11 @@ class RolesTest extends BrowserKitTest
 
         $editUrl = '/settings/users/' . $adminUser->id;
         $this->actingAs($adminUser)->put($editUrl, [
 
         $editUrl = '/settings/users/' . $adminUser->id;
         $this->actingAs($adminUser)->put($editUrl, [
-            'name' => $adminUser->name,
+            'name'  => $adminUser->name,
             'email' => $adminUser->email,
             'roles' => [
                 'viewer' => strval($viewerRole->id),
             'email' => $adminUser->email,
             'roles' => [
                 'viewer' => strval($viewerRole->id),
-            ]
+            ],
         ])->followRedirects();
 
         $this->seePageIs($editUrl);
         ])->followRedirects();
 
         $this->seePageIs($editUrl);
@@ -134,7 +136,7 @@ class RolesTest extends BrowserKitTest
 
     public function test_manage_users_permission_shows_link_in_header_if_does_not_have_settings_manage_permision()
     {
 
     public function test_manage_users_permission_shows_link_in_header_if_does_not_have_settings_manage_permision()
     {
-        $usersLink = 'href="'.url('/settings/users') . '"';
+        $usersLink = 'href="' . url('/settings/users') . '"';
         $this->actingAs($this->user)->visit('/')->dontSee($usersLink);
         $this->giveUserPermissions($this->user, ['users-manage']);
         $this->actingAs($this->user)->visit('/')->see($usersLink);
         $this->actingAs($this->user)->visit('/')->dontSee($usersLink);
         $this->giveUserPermissions($this->user, ['users-manage']);
         $this->actingAs($this->user)->visit('/')->see($usersLink);
@@ -152,13 +154,13 @@ class RolesTest extends BrowserKitTest
             ->assertResponseOk()
             ->seeElement('input[name=email][disabled]');
         $this->put($userProfileUrl, [
             ->assertResponseOk()
             ->seeElement('input[name=email][disabled]');
         $this->put($userProfileUrl, [
-            'name' => 'my_new_name',
+            'name'  => 'my_new_name',
             'email' => '[email protected]',
         ]);
         $this->seeInDatabase('users', [
             'email' => '[email protected]',
         ]);
         $this->seeInDatabase('users', [
-            'id' => $this->user->id,
+            'id'    => $this->user->id,
             'email' => $originalEmail,
             'email' => $originalEmail,
-            'name' => 'my_new_name',
+            'name'  => 'my_new_name',
         ]);
 
         $this->giveUserPermissions($this->user, ['users-manage']);
         ]);
 
         $this->giveUserPermissions($this->user, ['users-manage']);
@@ -168,14 +170,14 @@ class RolesTest extends BrowserKitTest
             ->dontSeeElement('input[name=email][disabled]')
             ->seeElement('input[name=email]');
         $this->put($userProfileUrl, [
             ->dontSeeElement('input[name=email][disabled]')
             ->seeElement('input[name=email]');
         $this->put($userProfileUrl, [
-            'name' => 'my_new_name_2',
+            'name'  => 'my_new_name_2',
             'email' => '[email protected]',
         ]);
 
         $this->seeInDatabase('users', [
             'email' => '[email protected]',
         ]);
 
         $this->seeInDatabase('users', [
-            'id' => $this->user->id,
+            'id'    => $this->user->id,
             'email' => '[email protected]',
             'email' => '[email protected]',
-            'name' => 'my_new_name_2',
+            'name'  => 'my_new_name_2',
         ]);
     }
 
         ]);
     }
 
@@ -250,10 +252,11 @@ class RolesTest extends BrowserKitTest
     }
 
     /**
     }
 
     /**
-     * Check a standard entity access permission
+     * Check a standard entity access permission.
+     *
      * @param string $permission
      * @param string $permission
-     * @param array $accessUrls Urls that are only accessible after having the permission
-     * @param array $visibles Check this text, In the buttons toolbar, is only visible with the permission
+     * @param array  $accessUrls Urls that are only accessible after having the permission
+     * @param array  $visibles   Check this text, In the buttons toolbar, is only visible with the permission
      */
     private function checkAccessPermission($permission, $accessUrls = [], $visibles = [])
     {
      */
     private function checkAccessPermission($permission, $accessUrls = [], $visibles = [])
     {
@@ -263,7 +266,7 @@ class RolesTest extends BrowserKitTest
         }
         foreach ($visibles as $url => $text) {
             $this->actingAs($this->user)->visit($url)
         }
         foreach ($visibles as $url => $text) {
             $this->actingAs($this->user)->visit($url)
-                ->dontSeeInElement('.action-buttons',$text);
+                ->dontSeeInElement('.action-buttons', $text);
         }
 
         $this->giveUserPermissions($this->user, [$permission]);
         }
 
         $this->giveUserPermissions($this->user, [$permission]);
@@ -281,9 +284,9 @@ class RolesTest extends BrowserKitTest
     public function test_bookshelves_create_all_permissions()
     {
         $this->checkAccessPermission('bookshelf-create-all', [
     public function test_bookshelves_create_all_permissions()
     {
         $this->checkAccessPermission('bookshelf-create-all', [
-            '/create-shelf'
+            '/create-shelf',
         ], [
         ], [
-            '/shelves' => 'New Shelf'
+            '/shelves' => 'New Shelf',
         ]);
 
         $this->visit('/create-shelf')
         ]);
 
         $this->visit('/create-shelf')
@@ -301,9 +304,9 @@ class RolesTest extends BrowserKitTest
         $this->regenEntityPermissions($ownShelf);
 
         $this->checkAccessPermission('bookshelf-update-own', [
         $this->regenEntityPermissions($ownShelf);
 
         $this->checkAccessPermission('bookshelf-update-own', [
-            $ownShelf->getUrl('/edit')
+            $ownShelf->getUrl('/edit'),
         ], [
         ], [
-            $ownShelf->getUrl() => 'Edit'
+            $ownShelf->getUrl() => 'Edit',
         ]);
 
         $this->visit($otherShelf->getUrl())
         ]);
 
         $this->visit($otherShelf->getUrl())
@@ -316,9 +319,9 @@ class RolesTest extends BrowserKitTest
     {
         $otherShelf = Bookshelf::first();
         $this->checkAccessPermission('bookshelf-update-all', [
     {
         $otherShelf = Bookshelf::first();
         $this->checkAccessPermission('bookshelf-update-all', [
-            $otherShelf->getUrl('/edit')
+            $otherShelf->getUrl('/edit'),
         ], [
         ], [
-            $otherShelf->getUrl() => 'Edit'
+            $otherShelf->getUrl() => 'Edit',
         ]);
     }
 
         ]);
     }
 
@@ -331,9 +334,9 @@ class RolesTest extends BrowserKitTest
         $this->regenEntityPermissions($ownShelf);
 
         $this->checkAccessPermission('bookshelf-delete-own', [
         $this->regenEntityPermissions($ownShelf);
 
         $this->checkAccessPermission('bookshelf-delete-own', [
-            $ownShelf->getUrl('/delete')
+            $ownShelf->getUrl('/delete'),
         ], [
         ], [
-            $ownShelf->getUrl() => 'Delete'
+            $ownShelf->getUrl() => 'Delete',
         ]);
 
         $this->visit($otherShelf->getUrl())
         ]);
 
         $this->visit($otherShelf->getUrl())
@@ -351,9 +354,9 @@ class RolesTest extends BrowserKitTest
         $this->giveUserPermissions($this->user, ['bookshelf-update-all']);
         $otherShelf = Bookshelf::first();
         $this->checkAccessPermission('bookshelf-delete-all', [
         $this->giveUserPermissions($this->user, ['bookshelf-update-all']);
         $otherShelf = Bookshelf::first();
         $this->checkAccessPermission('bookshelf-delete-all', [
-            $otherShelf->getUrl('/delete')
+            $otherShelf->getUrl('/delete'),
         ], [
         ], [
-            $otherShelf->getUrl() => 'Delete'
+            $otherShelf->getUrl() => 'Delete',
         ]);
 
         $this->visit($otherShelf->getUrl())->visit($otherShelf->getUrl('/delete'))
         ]);
 
         $this->visit($otherShelf->getUrl())->visit($otherShelf->getUrl('/delete'))
@@ -365,9 +368,9 @@ class RolesTest extends BrowserKitTest
     public function test_books_create_all_permissions()
     {
         $this->checkAccessPermission('book-create-all', [
     public function test_books_create_all_permissions()
     {
         $this->checkAccessPermission('book-create-all', [
-            '/create-book'
+            '/create-book',
         ], [
         ], [
-            '/books' => 'Create New Book'
+            '/books' => 'Create New Book',
         ]);
 
         $this->visit('/create-book')
         ]);
 
         $this->visit('/create-book')
@@ -382,9 +385,9 @@ class RolesTest extends BrowserKitTest
         $otherBook = Book::take(1)->get()->first();
         $ownBook = $this->createEntityChainBelongingToUser($this->user)['book'];
         $this->checkAccessPermission('book-update-own', [
         $otherBook = Book::take(1)->get()->first();
         $ownBook = $this->createEntityChainBelongingToUser($this->user)['book'];
         $this->checkAccessPermission('book-update-own', [
-            $ownBook->getUrl() . '/edit'
+            $ownBook->getUrl() . '/edit',
         ], [
         ], [
-            $ownBook->getUrl() => 'Edit'
+            $ownBook->getUrl() => 'Edit',
         ]);
 
         $this->visit($otherBook->getUrl())
         ]);
 
         $this->visit($otherBook->getUrl())
@@ -397,9 +400,9 @@ class RolesTest extends BrowserKitTest
     {
         $otherBook = Book::take(1)->get()->first();
         $this->checkAccessPermission('book-update-all', [
     {
         $otherBook = Book::take(1)->get()->first();
         $this->checkAccessPermission('book-update-all', [
-            $otherBook->getUrl() . '/edit'
+            $otherBook->getUrl() . '/edit',
         ], [
         ], [
-            $otherBook->getUrl() => 'Edit'
+            $otherBook->getUrl() => 'Edit',
         ]);
     }
 
         ]);
     }
 
@@ -409,9 +412,9 @@ class RolesTest extends BrowserKitTest
         $otherBook = Book::take(1)->get()->first();
         $ownBook = $this->createEntityChainBelongingToUser($this->user)['book'];
         $this->checkAccessPermission('book-delete-own', [
         $otherBook = Book::take(1)->get()->first();
         $ownBook = $this->createEntityChainBelongingToUser($this->user)['book'];
         $this->checkAccessPermission('book-delete-own', [
-            $ownBook->getUrl() . '/delete'
+            $ownBook->getUrl() . '/delete',
         ], [
         ], [
-            $ownBook->getUrl() => 'Delete'
+            $ownBook->getUrl() => 'Delete',
         ]);
 
         $this->visit($otherBook->getUrl())
         ]);
 
         $this->visit($otherBook->getUrl())
@@ -429,9 +432,9 @@ class RolesTest extends BrowserKitTest
         $this->giveUserPermissions($this->user, ['book-update-all']);
         $otherBook = Book::take(1)->get()->first();
         $this->checkAccessPermission('book-delete-all', [
         $this->giveUserPermissions($this->user, ['book-update-all']);
         $otherBook = Book::take(1)->get()->first();
         $this->checkAccessPermission('book-delete-all', [
-            $otherBook->getUrl() . '/delete'
+            $otherBook->getUrl() . '/delete',
         ], [
         ], [
-            $otherBook->getUrl() => 'Delete'
+            $otherBook->getUrl() => 'Delete',
         ]);
 
         $this->visit($otherBook->getUrl())->visit($otherBook->getUrl() . '/delete')
         ]);
 
         $this->visit($otherBook->getUrl())->visit($otherBook->getUrl() . '/delete')
@@ -445,9 +448,9 @@ class RolesTest extends BrowserKitTest
         $book = Book::take(1)->get()->first();
         $ownBook = $this->createEntityChainBelongingToUser($this->user)['book'];
         $this->checkAccessPermission('chapter-create-own', [
         $book = Book::take(1)->get()->first();
         $ownBook = $this->createEntityChainBelongingToUser($this->user)['book'];
         $this->checkAccessPermission('chapter-create-own', [
-            $ownBook->getUrl('/create-chapter')
+            $ownBook->getUrl('/create-chapter'),
         ], [
         ], [
-            $ownBook->getUrl() => 'New Chapter'
+            $ownBook->getUrl() => 'New Chapter',
         ]);
 
         $this->visit($ownBook->getUrl('/create-chapter'))
         ]);
 
         $this->visit($ownBook->getUrl('/create-chapter'))
@@ -466,9 +469,9 @@ class RolesTest extends BrowserKitTest
     {
         $book = Book::take(1)->get()->first();
         $this->checkAccessPermission('chapter-create-all', [
     {
         $book = Book::take(1)->get()->first();
         $this->checkAccessPermission('chapter-create-all', [
-            $book->getUrl('/create-chapter')
+            $book->getUrl('/create-chapter'),
         ], [
         ], [
-            $book->getUrl() => 'New Chapter'
+            $book->getUrl() => 'New Chapter',
         ]);
 
         $this->visit($book->getUrl('/create-chapter'))
         ]);
 
         $this->visit($book->getUrl('/create-chapter'))
@@ -483,9 +486,9 @@ class RolesTest extends BrowserKitTest
         $otherChapter = Chapter::take(1)->get()->first();
         $ownChapter = $this->createEntityChainBelongingToUser($this->user)['chapter'];
         $this->checkAccessPermission('chapter-update-own', [
         $otherChapter = Chapter::take(1)->get()->first();
         $ownChapter = $this->createEntityChainBelongingToUser($this->user)['chapter'];
         $this->checkAccessPermission('chapter-update-own', [
-            $ownChapter->getUrl() . '/edit'
+            $ownChapter->getUrl() . '/edit',
         ], [
         ], [
-            $ownChapter->getUrl() => 'Edit'
+            $ownChapter->getUrl() => 'Edit',
         ]);
 
         $this->visit($otherChapter->getUrl())
         ]);
 
         $this->visit($otherChapter->getUrl())
@@ -498,9 +501,9 @@ class RolesTest extends BrowserKitTest
     {
         $otherChapter = Chapter::take(1)->get()->first();
         $this->checkAccessPermission('chapter-update-all', [
     {
         $otherChapter = Chapter::take(1)->get()->first();
         $this->checkAccessPermission('chapter-update-all', [
-            $otherChapter->getUrl() . '/edit'
+            $otherChapter->getUrl() . '/edit',
         ], [
         ], [
-            $otherChapter->getUrl() => 'Edit'
+            $otherChapter->getUrl() => 'Edit',
         ]);
     }
 
         ]);
     }
 
@@ -510,9 +513,9 @@ class RolesTest extends BrowserKitTest
         $otherChapter = Chapter::take(1)->get()->first();
         $ownChapter = $this->createEntityChainBelongingToUser($this->user)['chapter'];
         $this->checkAccessPermission('chapter-delete-own', [
         $otherChapter = Chapter::take(1)->get()->first();
         $ownChapter = $this->createEntityChainBelongingToUser($this->user)['chapter'];
         $this->checkAccessPermission('chapter-delete-own', [
-            $ownChapter->getUrl() . '/delete'
+            $ownChapter->getUrl() . '/delete',
         ], [
         ], [
-            $ownChapter->getUrl() => 'Delete'
+            $ownChapter->getUrl() => 'Delete',
         ]);
 
         $bookUrl = $ownChapter->book->getUrl();
         ]);
 
         $bookUrl = $ownChapter->book->getUrl();
@@ -531,9 +534,9 @@ class RolesTest extends BrowserKitTest
         $this->giveUserPermissions($this->user, ['chapter-update-all']);
         $otherChapter = Chapter::take(1)->get()->first();
         $this->checkAccessPermission('chapter-delete-all', [
         $this->giveUserPermissions($this->user, ['chapter-update-all']);
         $otherChapter = Chapter::take(1)->get()->first();
         $this->checkAccessPermission('chapter-delete-all', [
-            $otherChapter->getUrl() . '/delete'
+            $otherChapter->getUrl() . '/delete',
         ], [
         ], [
-            $otherChapter->getUrl() => 'Delete'
+            $otherChapter->getUrl() => 'Delete',
         ]);
 
         $bookUrl = $otherChapter->book->getUrl();
         ]);
 
         $bookUrl = $otherChapter->book->getUrl();
@@ -562,8 +565,8 @@ class RolesTest extends BrowserKitTest
         }
 
         $this->checkAccessPermission('page-create-own', [], [
         }
 
         $this->checkAccessPermission('page-create-own', [], [
-            $ownBook->getUrl() => 'New Page',
-            $ownChapter->getUrl() => 'New Page'
+            $ownBook->getUrl()    => 'New Page',
+            $ownChapter->getUrl() => 'New Page',
         ]);
 
         $this->giveUserPermissions($this->user, ['page-create-own']);
         ]);
 
         $this->giveUserPermissions($this->user, ['page-create-own']);
@@ -606,8 +609,8 @@ class RolesTest extends BrowserKitTest
         }
 
         $this->checkAccessPermission('page-create-all', [], [
         }
 
         $this->checkAccessPermission('page-create-all', [], [
-            $book->getUrl() => 'New Page',
-            $chapter->getUrl() => 'New Page'
+            $book->getUrl()    => 'New Page',
+            $chapter->getUrl() => 'New Page',
         ]);
 
         $this->giveUserPermissions($this->user, ['page-create-all']);
         ]);
 
         $this->giveUserPermissions($this->user, ['page-create-all']);
@@ -636,9 +639,9 @@ class RolesTest extends BrowserKitTest
         $otherPage = Page::take(1)->get()->first();
         $ownPage = $this->createEntityChainBelongingToUser($this->user)['page'];
         $this->checkAccessPermission('page-update-own', [
         $otherPage = Page::take(1)->get()->first();
         $ownPage = $this->createEntityChainBelongingToUser($this->user)['page'];
         $this->checkAccessPermission('page-update-own', [
-            $ownPage->getUrl() . '/edit'
+            $ownPage->getUrl() . '/edit',
         ], [
         ], [
-            $ownPage->getUrl() => 'Edit'
+            $ownPage->getUrl() => 'Edit',
         ]);
 
         $this->visit($otherPage->getUrl())
         ]);
 
         $this->visit($otherPage->getUrl())
@@ -651,9 +654,9 @@ class RolesTest extends BrowserKitTest
     {
         $otherPage = Page::take(1)->get()->first();
         $this->checkAccessPermission('page-update-all', [
     {
         $otherPage = Page::take(1)->get()->first();
         $this->checkAccessPermission('page-update-all', [
-            $otherPage->getUrl() . '/edit'
+            $otherPage->getUrl() . '/edit',
         ], [
         ], [
-            $otherPage->getUrl() => 'Edit'
+            $otherPage->getUrl() => 'Edit',
         ]);
     }
 
         ]);
     }
 
@@ -663,9 +666,9 @@ class RolesTest extends BrowserKitTest
         $otherPage = Page::take(1)->get()->first();
         $ownPage = $this->createEntityChainBelongingToUser($this->user)['page'];
         $this->checkAccessPermission('page-delete-own', [
         $otherPage = Page::take(1)->get()->first();
         $ownPage = $this->createEntityChainBelongingToUser($this->user)['page'];
         $this->checkAccessPermission('page-delete-own', [
-            $ownPage->getUrl() . '/delete'
+            $ownPage->getUrl() . '/delete',
         ], [
         ], [
-            $ownPage->getUrl() => 'Delete'
+            $ownPage->getUrl() => 'Delete',
         ]);
 
         $parent = $ownPage->chapter ?? $ownPage->book;
         ]);
 
         $parent = $ownPage->chapter ?? $ownPage->book;
@@ -684,9 +687,9 @@ class RolesTest extends BrowserKitTest
         $this->giveUserPermissions($this->user, ['page-update-all']);
         $otherPage = Page::take(1)->get()->first();
         $this->checkAccessPermission('page-delete-all', [
         $this->giveUserPermissions($this->user, ['page-update-all']);
         $otherPage = Page::take(1)->get()->first();
         $this->checkAccessPermission('page-delete-all', [
-            $otherPage->getUrl() . '/delete'
+            $otherPage->getUrl() . '/delete',
         ], [
         ], [
-            $otherPage->getUrl() => 'Delete'
+            $otherPage->getUrl() => 'Delete',
         ]);
 
         $parent = $otherPage->chapter ?? $otherPage->book;
         ]);
 
         $parent = $otherPage->chapter ?? $otherPage->book;
@@ -702,8 +705,8 @@ class RolesTest extends BrowserKitTest
         $adminRole = Role::getSystemRole('admin');
         $publicRole = Role::getSystemRole('public');
         $this->asAdmin()->visit('/settings/users/' . $user->id)
         $adminRole = Role::getSystemRole('admin');
         $publicRole = Role::getSystemRole('public');
         $this->asAdmin()->visit('/settings/users/' . $user->id)
-            ->seeElement('[name="roles['.$adminRole->id.']"]')
-            ->seeElement('[name="roles['.$publicRole->id.']"]');
+            ->seeElement('[name="roles[' . $adminRole->id . ']"]')
+            ->seeElement('[name="roles[' . $publicRole->id . ']"]');
     }
 
     public function test_public_role_visible_in_role_listing()
     }
 
     public function test_public_role_visible_in_role_listing()
@@ -779,8 +782,8 @@ class RolesTest extends BrowserKitTest
 
         $this->asAdmin()->put('/settings/roles/' . $viewerRole->id, [
             'display_name' => $viewerRole->display_name,
 
         $this->asAdmin()->put('/settings/roles/' . $viewerRole->id, [
             'display_name' => $viewerRole->display_name,
-            'description' => $viewerRole->description,
-            'permission' => []
+            'description'  => $viewerRole->description,
+            'permission'   => [],
         ])->assertResponseStatus(302);
 
         $this->expectException(HttpException::class);
         ])->assertResponseStatus(302);
 
         $this->expectException(HttpException::class);
@@ -805,7 +808,8 @@ class RolesTest extends BrowserKitTest
             ->dontSee('Sort the current book');
     }
 
             ->dontSee('Sort the current book');
     }
 
-    public function test_comment_create_permission () {
+    public function test_comment_create_permission()
+    {
         $ownPage = $this->createEntityChainBelongingToUser($this->user)['page'];
 
         $this->actingAs($this->user)->addComment($ownPage);
         $ownPage = $this->createEntityChainBelongingToUser($this->user)['page'];
 
         $this->actingAs($this->user)->addComment($ownPage);
@@ -818,8 +822,8 @@ class RolesTest extends BrowserKitTest
         $this->assertResponseStatus(200);
     }
 
         $this->assertResponseStatus(200);
     }
 
-
-    public function test_comment_update_own_permission () {
+    public function test_comment_update_own_permission()
+    {
         $ownPage = $this->createEntityChainBelongingToUser($this->user)['page'];
         $this->giveUserPermissions($this->user, ['comment-create-all']);
         $commentId = $this->actingAs($this->user)->addComment($ownPage);
         $ownPage = $this->createEntityChainBelongingToUser($this->user)['page'];
         $this->giveUserPermissions($this->user, ['comment-create-all']);
         $commentId = $this->actingAs($this->user)->addComment($ownPage);
@@ -835,7 +839,8 @@ class RolesTest extends BrowserKitTest
         $this->assertResponseStatus(200);
     }
 
         $this->assertResponseStatus(200);
     }
 
-    public function test_comment_update_all_permission () {
+    public function test_comment_update_all_permission()
+    {
         $ownPage = $this->createEntityChainBelongingToUser($this->user)['page'];
         $commentId = $this->asAdmin()->addComment($ownPage);
 
         $ownPage = $this->createEntityChainBelongingToUser($this->user)['page'];
         $commentId = $this->asAdmin()->addComment($ownPage);
 
@@ -850,7 +855,8 @@ class RolesTest extends BrowserKitTest
         $this->assertResponseStatus(200);
     }
 
         $this->assertResponseStatus(200);
     }
 
-    public function test_comment_delete_own_permission () {
+    public function test_comment_delete_own_permission()
+    {
         $ownPage = $this->createEntityChainBelongingToUser($this->user)['page'];
         $this->giveUserPermissions($this->user, ['comment-create-all']);
         $commentId = $this->actingAs($this->user)->addComment($ownPage);
         $ownPage = $this->createEntityChainBelongingToUser($this->user)['page'];
         $this->giveUserPermissions($this->user, ['comment-create-all']);
         $commentId = $this->actingAs($this->user)->addComment($ownPage);
@@ -866,7 +872,8 @@ class RolesTest extends BrowserKitTest
         $this->assertResponseStatus(200);
     }
 
         $this->assertResponseStatus(200);
     }
 
-    public function test_comment_delete_all_permission () {
+    public function test_comment_delete_all_permission()
+    {
         $ownPage = $this->createEntityChainBelongingToUser($this->user)['page'];
         $commentId = $this->asAdmin()->addComment($ownPage);
 
         $ownPage = $this->createEntityChainBelongingToUser($this->user)['page'];
         $commentId = $this->asAdmin()->addComment($ownPage);
 
@@ -881,33 +888,37 @@ class RolesTest extends BrowserKitTest
         $this->assertResponseStatus(200);
     }
 
         $this->assertResponseStatus(200);
     }
 
-    private function addComment($page) {
+    private function addComment($page)
+    {
         $comment = factory(Comment::class)->make();
         $url = "/comment/$page->id";
         $request = [
             'text' => $comment->text,
         $comment = factory(Comment::class)->make();
         $url = "/comment/$page->id";
         $request = [
             'text' => $comment->text,
-            'html' => $comment->html
+            'html' => $comment->html,
         ];
 
         $this->postJson($url, $request);
         $comment = $page->comments()->first();
         ];
 
         $this->postJson($url, $request);
         $comment = $page->comments()->first();
+
         return $comment === null ? null : $comment->id;
     }
 
         return $comment === null ? null : $comment->id;
     }
 
-    private function updateComment($commentId) {
+    private function updateComment($commentId)
+    {
         $comment = factory(Comment::class)->make();
         $url = "/comment/$commentId";
         $request = [
             'text' => $comment->text,
         $comment = factory(Comment::class)->make();
         $url = "/comment/$commentId";
         $request = [
             'text' => $comment->text,
-            'html' => $comment->html
+            'html' => $comment->html,
         ];
 
         return $this->putJson($url, $request);
     }
 
         ];
 
         return $this->putJson($url, $request);
     }
 
-    private function deleteComment($commentId) {
-         $url = '/comment/' . $commentId;
-         return $this->json('DELETE', $url);
-    }
+    private function deleteComment($commentId)
+    {
+        $url = '/comment/' . $commentId;
 
 
+        return $this->json('DELETE', $url);
+    }
 }
 }
index 7dbf467bd838d8d82ece92e72b6b298ec0b88146..ae0c0ff95c6d454f649f0fe535b374a775a4d459 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests;
+<?php
+
+namespace Tests;
 
 use Auth;
 use BookStack\Auth\Permissions\PermissionService;
 
 use Auth;
 use BookStack\Auth\Permissions\PermissionService;
@@ -12,7 +14,6 @@ use Illuminate\Support\Facades\View;
 
 class PublicActionTest extends TestCase
 {
 
 class PublicActionTest extends TestCase
 {
-
     public function test_app_not_public()
     {
         $this->setSettings(['app-public' => 'false']);
     public function test_app_not_public()
     {
         $this->setSettings(['app-public' => 'false']);
@@ -27,7 +28,7 @@ class PublicActionTest extends TestCase
     public function test_login_link_visible()
     {
         $this->setSettings(['app-public' => 'true']);
     public function test_login_link_visible()
     {
         $this->setSettings(['app-public' => 'true']);
-        $this->get('/')->assertElementExists('a[href="'.url('/login').'"]');
+        $this->get('/')->assertElementExists('a[href="' . url('/login') . '"]');
     }
 
     public function test_register_link_visible_when_enabled()
     }
 
     public function test_register_link_visible_when_enabled()
@@ -94,22 +95,22 @@ class PublicActionTest extends TestCase
         $chapter = Chapter::query()->first();
         $resp = $this->get($chapter->getUrl());
         $resp->assertSee('New Page');
         $chapter = Chapter::query()->first();
         $resp = $this->get($chapter->getUrl());
         $resp->assertSee('New Page');
-        $resp->assertElementExists('a[href="'.$chapter->getUrl('/create-page').'"]');
+        $resp->assertElementExists('a[href="' . $chapter->getUrl('/create-page') . '"]');
 
         $resp = $this->get($chapter->getUrl('/create-page'));
         $resp->assertSee('Continue');
         $resp->assertSee('Page Name');
 
         $resp = $this->get($chapter->getUrl('/create-page'));
         $resp->assertSee('Continue');
         $resp->assertSee('Page Name');
-        $resp->assertElementExists('form[action="'.$chapter->getUrl('/create-guest-page').'"]');
+        $resp->assertElementExists('form[action="' . $chapter->getUrl('/create-guest-page') . '"]');
 
         $resp = $this->post($chapter->getUrl('/create-guest-page'), ['name' => 'My guest page']);
         $resp->assertRedirect($chapter->book->getUrl('/page/my-guest-page/edit'));
 
         $user = User::getDefault();
         $this->assertDatabaseHas('pages', [
 
         $resp = $this->post($chapter->getUrl('/create-guest-page'), ['name' => 'My guest page']);
         $resp->assertRedirect($chapter->book->getUrl('/page/my-guest-page/edit'));
 
         $user = User::getDefault();
         $this->assertDatabaseHas('pages', [
-            'name' => 'My guest page',
+            'name'       => 'My guest page',
             'chapter_id' => $chapter->id,
             'created_by' => $user->id,
             'chapter_id' => $chapter->id,
             'created_by' => $user->id,
-            'updated_by' => $user->id
+            'updated_by' => $user->id,
         ]);
     }
 
         ]);
     }
 
@@ -137,7 +138,7 @@ class PublicActionTest extends TestCase
 
         $resp = $this->get('/robots.txt');
         $resp->assertSee("User-agent: *\nDisallow:");
 
         $resp = $this->get('/robots.txt');
         $resp->assertSee("User-agent: *\nDisallow:");
-        $resp->assertDontSee("Disallow: /");
+        $resp->assertDontSee('Disallow: /');
     }
 
     public function test_robots_effected_by_setting()
     }
 
     public function test_robots_effected_by_setting()
@@ -148,7 +149,7 @@ class PublicActionTest extends TestCase
 
         $resp = $this->get('/robots.txt');
         $resp->assertSee("User-agent: *\nDisallow:");
 
         $resp = $this->get('/robots.txt');
         $resp->assertSee("User-agent: *\nDisallow:");
-        $resp->assertDontSee("Disallow: /");
+        $resp->assertDontSee('Disallow: /');
 
         // Check config overrides app-public setting
         config()->set('app.allow_robots', false);
 
         // Check config overrides app-public setting
         config()->set('app.allow_robots', false);
@@ -184,4 +185,4 @@ class PublicActionTest extends TestCase
         $resp->assertRedirect($book->getUrl());
         $this->followRedirects($resp)->assertSee($book->name);
     }
         $resp->assertRedirect($book->getUrl());
         $this->followRedirects($resp)->assertSee($book->name);
     }
-}
\ No newline at end of file
+}
index 1cfcc0bceb49d0e9a7509f29c5cb10f07fb53ff3..1c54452124fbb088631edb961931739377244270 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests;
+<?php
+
+namespace Tests;
 
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Bookshelf;
 
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Bookshelf;
@@ -27,7 +29,7 @@ class RecycleBinTest extends TestCase
             "DELETE:/settings/recycle-bin/{$deletion->id}",
         ];
 
             "DELETE:/settings/recycle-bin/{$deletion->id}",
         ];
 
-        foreach($routes as $route) {
+        foreach ($routes as $route) {
             [$method, $url] = explode(':', $route);
             $resp = $this->call($method, $url);
             $this->assertPermissionError($resp);
             [$method, $url] = explode(':', $route);
             $resp = $this->call($method, $url);
             $this->assertPermissionError($resp);
@@ -35,7 +37,7 @@ class RecycleBinTest extends TestCase
 
         $this->giveUserPermissions($editor, ['restrictions-manage-all']);
 
 
         $this->giveUserPermissions($editor, ['restrictions-manage-all']);
 
-        foreach($routes as $route) {
+        foreach ($routes as $route) {
             [$method, $url] = explode(':', $route);
             $resp = $this->call($method, $url);
             $this->assertPermissionError($resp);
             [$method, $url] = explode(':', $route);
             $resp = $this->call($method, $url);
             $this->assertPermissionError($resp);
@@ -43,14 +45,13 @@ class RecycleBinTest extends TestCase
 
         $this->giveUserPermissions($editor, ['settings-manage']);
 
 
         $this->giveUserPermissions($editor, ['settings-manage']);
 
-        foreach($routes as $route) {
+        foreach ($routes as $route) {
             DB::beginTransaction();
             [$method, $url] = explode(':', $route);
             $resp = $this->call($method, $url);
             $this->assertNotPermissionError($resp);
             DB::rollBack();
         }
             DB::beginTransaction();
             [$method, $url] = explode(':', $route);
             $resp = $this->call($method, $url);
             $this->assertNotPermissionError($resp);
             DB::rollBack();
         }
-
     }
 
     public function test_recycle_bin_view()
     }
 
     public function test_recycle_bin_view()
@@ -72,7 +73,7 @@ class RecycleBinTest extends TestCase
     public function test_recycle_bin_empty()
     {
         $page = Page::query()->first();
     public function test_recycle_bin_empty()
     {
         $page = Page::query()->first();
-        $book = Book::query()->where('id' , '!=', $page->book_id)->whereHas('pages')->whereHas('chapters')->with(['pages', 'chapters'])->firstOrFail();
+        $book = Book::query()->where('id', '!=', $page->book_id)->whereHas('pages')->whereHas('chapters')->with(['pages', 'chapters'])->firstOrFail();
         $editor = $this->getEditor();
         $this->actingAs($editor)->delete($page->getUrl());
         $this->actingAs($editor)->delete($book->getUrl());
         $editor = $this->getEditor();
         $this->actingAs($editor)->delete($page->getUrl());
         $this->actingAs($editor)->delete($book->getUrl());
@@ -89,7 +90,7 @@ class RecycleBinTest extends TestCase
 
         $itemCount = 2 + $book->pages->count() + $book->chapters->count();
         $redirectReq = $this->get('/settings/recycle-bin');
 
         $itemCount = 2 + $book->pages->count() + $book->chapters->count();
         $redirectReq = $this->get('/settings/recycle-bin');
-        $redirectReq->assertNotificationContains('Deleted '.$itemCount.' total items from the recycle bin');
+        $redirectReq->assertNotificationContains('Deleted ' . $itemCount . ' total items from the recycle bin');
     }
 
     public function test_entity_restore()
     }
 
     public function test_entity_restore()
@@ -110,7 +111,7 @@ class RecycleBinTest extends TestCase
 
         $itemCount = 1 + $book->pages->count() + $book->chapters->count();
         $redirectReq = $this->get('/settings/recycle-bin');
 
         $itemCount = 1 + $book->pages->count() + $book->chapters->count();
         $redirectReq = $this->get('/settings/recycle-bin');
-        $redirectReq->assertNotificationContains('Restored '.$itemCount.' total items from the recycle bin');
+        $redirectReq->assertNotificationContains('Restored ' . $itemCount . ' total items from the recycle bin');
     }
 
     public function test_permanent_delete()
     }
 
     public function test_permanent_delete()
@@ -129,13 +130,13 @@ class RecycleBinTest extends TestCase
 
         $itemCount = 1 + $book->pages->count() + $book->chapters->count();
         $redirectReq = $this->get('/settings/recycle-bin');
 
         $itemCount = 1 + $book->pages->count() + $book->chapters->count();
         $redirectReq = $this->get('/settings/recycle-bin');
-        $redirectReq->assertNotificationContains('Deleted '.$itemCount.' total items from the recycle bin');
+        $redirectReq->assertNotificationContains('Deleted ' . $itemCount . ' total items from the recycle bin');
     }
 
     public function test_permanent_delete_for_each_type()
     {
         /** @var Entity $entity */
     }
 
     public function test_permanent_delete_for_each_type()
     {
         /** @var Entity $entity */
-        foreach ([new Bookshelf, new Book, new Chapter, new Page] as $entity) {
+        foreach ([new Bookshelf(), new Book(), new Chapter(), new Page()] as $entity) {
             $entity = $entity->newQuery()->first();
             $this->asEditor()->delete($entity->getUrl());
             $deletion = Deletion::query()->orderBy('id', 'desc')->firstOrFail();
             $entity = $entity->newQuery()->first();
             $this->asEditor()->delete($entity->getUrl());
             $deletion = Deletion::query()->orderBy('id', 'desc')->firstOrFail();
@@ -154,24 +155,24 @@ class RecycleBinTest extends TestCase
         $deletion = $page->deletions()->firstOrFail();
 
         $this->assertDatabaseHas('activities', [
         $deletion = $page->deletions()->firstOrFail();
 
         $this->assertDatabaseHas('activities', [
-            'type' => 'page_delete',
-            'entity_id' => $page->id,
+            'type'        => 'page_delete',
+            'entity_id'   => $page->id,
             'entity_type' => $page->getMorphClass(),
         ]);
 
         $this->asAdmin()->delete("/settings/recycle-bin/{$deletion->id}");
 
         $this->assertDatabaseMissing('activities', [
             'entity_type' => $page->getMorphClass(),
         ]);
 
         $this->asAdmin()->delete("/settings/recycle-bin/{$deletion->id}");
 
         $this->assertDatabaseMissing('activities', [
-            'type' => 'page_delete',
-            'entity_id' => $page->id,
+            'type'        => 'page_delete',
+            'entity_id'   => $page->id,
             'entity_type' => $page->getMorphClass(),
         ]);
 
         $this->assertDatabaseHas('activities', [
             'entity_type' => $page->getMorphClass(),
         ]);
 
         $this->assertDatabaseHas('activities', [
-            'type' => 'page_delete',
-            'entity_id' => null,
+            'type'        => 'page_delete',
+            'entity_id'   => null,
             'entity_type' => null,
             'entity_type' => null,
-            'detail' => $page->name,
+            'detail'      => $page->name,
         ]);
     }
 
         ]);
     }
 
@@ -233,8 +234,8 @@ class RecycleBinTest extends TestCase
         $chapterRestoreView->assertSeeText($chapter->name);
 
         $chapterRestore = $this->post("/settings/recycle-bin/{$chapterDeletion->id}/restore");
         $chapterRestoreView->assertSeeText($chapter->name);
 
         $chapterRestore = $this->post("/settings/recycle-bin/{$chapterDeletion->id}/restore");
-        $chapterRestore->assertRedirect("/settings/recycle-bin");
-        $this->assertDatabaseMissing("deletions", ["id" => $chapterDeletion->id]);
+        $chapterRestore->assertRedirect('/settings/recycle-bin');
+        $this->assertDatabaseMissing('deletions', ['id' => $chapterDeletion->id]);
 
         $chapter->refresh();
         $this->assertNotNull($chapter->deleted_at);
 
         $chapter->refresh();
         $this->assertNotNull($chapter->deleted_at);
@@ -263,6 +264,6 @@ class RecycleBinTest extends TestCase
 
         $pageRestoreView = $this->asAdmin()->get("/settings/recycle-bin/{$pageDeletion->id}/restore");
         $pageRestoreView->assertSee('The parent of this item has also been deleted.');
 
         $pageRestoreView = $this->asAdmin()->get("/settings/recycle-bin/{$pageDeletion->id}/restore");
         $pageRestoreView->assertSee('The parent of this item has also been deleted.');
-        $pageRestoreView->assertElementContains('a[href$="/settings/recycle-bin/' . $bookDeletion->id. '/restore"]', 'Restore Parent');
+        $pageRestoreView->assertElementContains('a[href$="/settings/recycle-bin/' . $bookDeletion->id . '/restore"]', 'Restore Parent');
     }
     }
-}
\ No newline at end of file
+}
index db095ff70d8d0f6f8214beb365bdd86f33c73999..888dac8106af4b8088ecf2f28fb8d82bd96d12f6 100644 (file)
@@ -1,40 +1,40 @@
-<?php namespace Tests;
+<?php
 
 
+namespace Tests;
 
 use Illuminate\Support\Str;
 
 class SecurityHeaderTest extends TestCase
 {
 
 use Illuminate\Support\Str;
 
 class SecurityHeaderTest extends TestCase
 {
-
     public function test_cookies_samesite_lax_by_default()
     {
     public function test_cookies_samesite_lax_by_default()
     {
-        $resp = $this->get("/");
+        $resp = $this->get('/');
         foreach ($resp->headers->getCookies() as $cookie) {
         foreach ($resp->headers->getCookies() as $cookie) {
-            $this->assertEquals("lax", $cookie->getSameSite());
+            $this->assertEquals('lax', $cookie->getSameSite());
         }
     }
 
     public function test_cookies_samesite_none_when_iframe_hosts_set()
     {
         }
     }
 
     public function test_cookies_samesite_none_when_iframe_hosts_set()
     {
-        $this->runWithEnv("ALLOWED_IFRAME_HOSTS", "http://example.com", function() {
-            $resp = $this->get("/");
+        $this->runWithEnv('ALLOWED_IFRAME_HOSTS', 'http://example.com', function () {
+            $resp = $this->get('/');
             foreach ($resp->headers->getCookies() as $cookie) {
             foreach ($resp->headers->getCookies() as $cookie) {
-                $this->assertEquals("none", $cookie->getSameSite());
+                $this->assertEquals('none', $cookie->getSameSite());
             }
         });
     }
 
     public function test_secure_cookies_controlled_by_app_url()
     {
             }
         });
     }
 
     public function test_secure_cookies_controlled_by_app_url()
     {
-        $this->runWithEnv("APP_URL", "http://example.com", function() {
-            $resp = $this->get("/");
+        $this->runWithEnv('APP_URL', 'http://example.com', function () {
+            $resp = $this->get('/');
             foreach ($resp->headers->getCookies() as $cookie) {
                 $this->assertFalse($cookie->isSecure());
             }
         });
 
             foreach ($resp->headers->getCookies() as $cookie) {
                 $this->assertFalse($cookie->isSecure());
             }
         });
 
-        $this->runWithEnv("APP_URL", "https://example.com", function() {
-            $resp = $this->get("/");
+        $this->runWithEnv('APP_URL', 'https://example.com', function () {
+            $resp = $this->get('/');
             foreach ($resp->headers->getCookies() as $cookie) {
                 $this->assertTrue($cookie->isSecure());
             }
             foreach ($resp->headers->getCookies() as $cookie) {
                 $this->assertTrue($cookie->isSecure());
             }
@@ -43,7 +43,7 @@ class SecurityHeaderTest extends TestCase
 
     public function test_iframe_csp_self_only_by_default()
     {
 
     public function test_iframe_csp_self_only_by_default()
     {
-        $resp = $this->get("/");
+        $resp = $this->get('/');
         $cspHeaders = collect($resp->headers->get('Content-Security-Policy'));
         $frameHeaders = $cspHeaders->filter(function ($val) {
             return Str::startsWith($val, 'frame-ancestors');
         $cspHeaders = collect($resp->headers->get('Content-Security-Policy'));
         $frameHeaders = $cspHeaders->filter(function ($val) {
             return Str::startsWith($val, 'frame-ancestors');
@@ -55,17 +55,15 @@ class SecurityHeaderTest extends TestCase
 
     public function test_iframe_csp_includes_extra_hosts_if_configured()
     {
 
     public function test_iframe_csp_includes_extra_hosts_if_configured()
     {
-        $this->runWithEnv("ALLOWED_IFRAME_HOSTS", "https://a.example.com https://b.example.com", function() {
-            $resp = $this->get("/");
+        $this->runWithEnv('ALLOWED_IFRAME_HOSTS', 'https://a.example.com https://b.example.com', function () {
+            $resp = $this->get('/');
             $cspHeaders = collect($resp->headers->get('Content-Security-Policy'));
             $cspHeaders = collect($resp->headers->get('Content-Security-Policy'));
-            $frameHeaders = $cspHeaders->filter(function($val) {
+            $frameHeaders = $cspHeaders->filter(function ($val) {
                 return Str::startsWith($val, 'frame-ancestors');
             });
 
             $this->assertTrue($frameHeaders->count() === 1);
             $this->assertEquals('frame-ancestors \'self\' https://a.example.com https://b.example.com', $frameHeaders->first());
         });
                 return Str::startsWith($val, 'frame-ancestors');
             });
 
             $this->assertTrue($frameHeaders->count() === 1);
             $this->assertEquals('frame-ancestors \'self\' https://a.example.com https://b.example.com', $frameHeaders->first());
         });
-
     }
     }
-
-}
\ No newline at end of file
+}
index a98f01e94e553f2f7bec643e1c736cd79e749b03..0bc80924e499024a7435aeacc353b48891f115dc 100644 (file)
@@ -1,5 +1,10 @@
-<?php namespace Tests;
+<?php
 
 
+namespace Tests;
+
+use BookStack\Auth\Permissions\PermissionService;
+use BookStack\Auth\Permissions\PermissionsRepo;
+use BookStack\Auth\Role;
 use BookStack\Auth\User;
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Bookshelf;
 use BookStack\Auth\User;
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Bookshelf;
@@ -9,22 +14,18 @@ use BookStack\Entities\Models\Page;
 use BookStack\Entities\Repos\BookRepo;
 use BookStack\Entities\Repos\BookshelfRepo;
 use BookStack\Entities\Repos\ChapterRepo;
 use BookStack\Entities\Repos\BookRepo;
 use BookStack\Entities\Repos\BookshelfRepo;
 use BookStack\Entities\Repos\ChapterRepo;
-use BookStack\Auth\Permissions\PermissionsRepo;
-use BookStack\Auth\Role;
-use BookStack\Auth\Permissions\PermissionService;
 use BookStack\Entities\Repos\PageRepo;
 use BookStack\Settings\SettingService;
 use BookStack\Uploads\HttpFetcher;
 use BookStack\Entities\Repos\PageRepo;
 use BookStack\Settings\SettingService;
 use BookStack\Uploads\HttpFetcher;
+use Illuminate\Foundation\Testing\Assert as PHPUnit;
 use Illuminate\Support\Env;
 use Illuminate\Support\Facades\Log;
 use Mockery;
 use Monolog\Handler\TestHandler;
 use Monolog\Logger;
 use Illuminate\Support\Env;
 use Illuminate\Support\Facades\Log;
 use Mockery;
 use Monolog\Handler\TestHandler;
 use Monolog\Logger;
-use Illuminate\Foundation\Testing\Assert as PHPUnit;
 
 trait SharedTestHelpers
 {
 
 trait SharedTestHelpers
 {
-
     protected $admin;
     protected $editor;
 
     protected $admin;
     protected $editor;
 
@@ -57,7 +58,6 @@ trait SharedTestHelpers
         return $this->actingAs($this->getEditor());
     }
 
         return $this->actingAs($this->getEditor());
     }
 
-
     /**
      * Get a editor user.
      */
     /**
      * Get a editor user.
      */
@@ -67,6 +67,7 @@ trait SharedTestHelpers
             $editorRole = Role::getRole('editor');
             $this->editor = $editorRole->users->first();
         }
             $editorRole = Role::getRole('editor');
             $this->editor = $editorRole->users->first();
         }
+
         return $this->editor;
     }
 
         return $this->editor;
     }
 
@@ -79,6 +80,7 @@ trait SharedTestHelpers
         if (!empty($attributes)) {
             $user->forceFill($attributes)->save();
         }
         if (!empty($attributes)) {
             $user->forceFill($attributes)->save();
         }
+
         return $user;
     }
 
         return $user;
     }
 
@@ -116,7 +118,7 @@ trait SharedTestHelpers
     }
 
     /**
     }
 
     /**
-     * Create and return a new test chapter
+     * Create and return a new test chapter.
      */
     public function newChapter(array $input = ['name' => 'test chapter', 'description' => 'My new test chapter'], Book $book): Chapter
     {
      */
     public function newChapter(array $input = ['name' => 'test chapter', 'description' => 'My new test chapter'], Book $book): Chapter
     {
@@ -124,13 +126,14 @@ trait SharedTestHelpers
     }
 
     /**
     }
 
     /**
-     * Create and return a new test page
+     * Create and return a new test page.
      */
     public function newPage(array $input = ['name' => 'test page', 'html' => 'My new test page']): Page
     {
         $book = Book::query()->first();
         $pageRepo = app(PageRepo::class);
         $draftPage = $pageRepo->getNewDraftPage($book);
      */
     public function newPage(array $input = ['name' => 'test page', 'html' => 'My new test page']): Page
     {
         $book = Book::query()->first();
         $pageRepo = app(PageRepo::class);
         $draftPage = $pageRepo->getNewDraftPage($book);
+
         return $pageRepo->publishDraft($draftPage, $input);
     }
 
         return $pageRepo->publishDraft($draftPage, $input);
     }
 
@@ -158,7 +161,7 @@ trait SharedTestHelpers
             foreach ($roles as $role) {
                 $permissions[] = [
                     'role_id' => $role->id,
             foreach ($roles as $role) {
                 $permissions[] = [
                     'role_id' => $role->id,
-                    'action' => strtolower($action)
+                    'action'  => strtolower($action),
                 ];
             }
         }
                 ];
             }
         }
@@ -189,6 +192,7 @@ trait SharedTestHelpers
         $permissionRepo = app(PermissionsRepo::class);
         $roleData = factory(Role::class)->make()->toArray();
         $roleData['permissions'] = array_flip($permissions);
         $permissionRepo = app(PermissionsRepo::class);
         $roleData = factory(Role::class)->make()->toArray();
         $roleData['permissions'] = array_flip($permissions);
+
         return $permissionRepo->saveNewRole($roleData);
     }
 
         return $permissionRepo->saveNewRole($roleData);
     }
 
@@ -253,7 +257,7 @@ trait SharedTestHelpers
      */
     protected function assertPermissionError($response)
     {
      */
     protected function assertPermissionError($response)
     {
-        PHPUnit::assertTrue($this->isPermissionError($response->baseResponse ?? $response->response), "Failed asserting the response contains a permission error.");
+        PHPUnit::assertTrue($this->isPermissionError($response->baseResponse ?? $response->response), 'Failed asserting the response contains a permission error.');
     }
 
     /**
     }
 
     /**
@@ -261,7 +265,7 @@ trait SharedTestHelpers
      */
     protected function assertNotPermissionError($response)
     {
      */
     protected function assertNotPermissionError($response)
     {
-        PHPUnit::assertFalse($this->isPermissionError($response->baseResponse ?? $response->response), "Failed asserting the response does not contain a permission error.");
+        PHPUnit::assertFalse($this->isPermissionError($response->baseResponse ?? $response->response), 'Failed asserting the response does not contain a permission error.');
     }
 
     /**
     }
 
     /**
@@ -291,5 +295,4 @@ trait SharedTestHelpers
 
         return $testHandler;
     }
 
         return $testHandler;
     }
-
-}
\ No newline at end of file
+}
index b4c35cf91759774060a48a715d7ea594d54419da..09882759c387ee37680f1a0741ad8e18344dc854 100644 (file)
@@ -1,8 +1,8 @@
 <?php
 
 use Illuminate\Cache\ArrayStore;
 <?php
 
 use Illuminate\Cache\ArrayStore;
-use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Cache;
 use Illuminate\Support\Facades\Cache;
+use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Session;
 use Tests\TestCase;
 
 use Illuminate\Support\Facades\Session;
 use Tests\TestCase;
 
@@ -10,12 +10,12 @@ class StatusTest extends TestCase
 {
     public function test_returns_json_with_expected_results()
     {
 {
     public function test_returns_json_with_expected_results()
     {
-        $resp = $this->get("/status");
+        $resp = $this->get('/status');
         $resp->assertStatus(200);
         $resp->assertJson([
             'database' => true,
         $resp->assertStatus(200);
         $resp->assertJson([
             'database' => true,
-            'cache' => true,
-            'session' => true,
+            'cache'    => true,
+            'session'  => true,
         ]);
     }
 
         ]);
     }
 
@@ -23,7 +23,7 @@ class StatusTest extends TestCase
     {
         DB::shouldReceive('table')->andThrow(new Exception());
 
     {
         DB::shouldReceive('table')->andThrow(new Exception());
 
-        $resp = $this->get("/status");
+        $resp = $this->get('/status');
         $resp->assertStatus(500);
         $resp->assertJson([
             'database' => false,
         $resp->assertStatus(500);
         $resp->assertJson([
             'database' => false,
@@ -36,7 +36,7 @@ class StatusTest extends TestCase
         Cache::swap($mockStore);
         $mockStore->shouldReceive('get')->andReturn('cat');
 
         Cache::swap($mockStore);
         $mockStore->shouldReceive('get')->andReturn('cat');
 
-        $resp = $this->get("/status");
+        $resp = $this->get('/status');
         $resp->assertStatus(500);
         $resp->assertJson([
             'cache' => false,
         $resp->assertStatus(500);
         $resp->assertJson([
             'cache' => false,
@@ -50,10 +50,10 @@ class StatusTest extends TestCase
         Session::swap($mockSession);
         $mockSession->shouldReceive('get')->andReturn('cat');
 
         Session::swap($mockSession);
         $mockSession->shouldReceive('get')->andReturn('cat');
 
-        $resp = $this->get("/status");
+        $resp = $this->get('/status');
         $resp->assertStatus(500);
         $resp->assertJson([
             'session' => false,
         ]);
     }
         $resp->assertStatus(500);
         $resp->assertJson([
             'session' => false,
         ]);
     }
-}
\ No newline at end of file
+}
index 2c901981af53cb9e22909fdcc89673cb3cf5fece..080515173d67cdd6cdf3605dc9e66c7ad1de42a4 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests;
+<?php
+
+namespace Tests;
 
 use BookStack\Entities\Models\Entity;
 use Illuminate\Foundation\Testing\DatabaseTransactions;
 
 use BookStack\Entities\Models\Entity;
 use Illuminate\Foundation\Testing\DatabaseTransactions;
@@ -12,25 +14,31 @@ abstract class TestCase extends BaseTestCase
 
     /**
      * The base URL to use while testing the application.
 
     /**
      * The base URL to use while testing the application.
+     *
      * @var string
      */
     protected $baseUrl = 'http://localhost';
 
     /**
      * Assert the session contains a specific entry.
      * @var string
      */
     protected $baseUrl = 'http://localhost';
 
     /**
      * Assert the session contains a specific entry.
+     *
      * @param string $key
      * @param string $key
+     *
      * @return $this
      */
     protected function assertSessionHas(string $key)
     {
         $this->assertTrue(session()->has($key), "Session does not contain a [{$key}] entry");
      * @return $this
      */
     protected function assertSessionHas(string $key)
     {
         $this->assertTrue(session()->has($key), "Session does not contain a [{$key}] entry");
+
         return $this;
     }
 
     /**
      * Override of the get method so we can get visibility of custom TestResponse methods.
         return $this;
     }
 
     /**
      * Override of the get method so we can get visibility of custom TestResponse methods.
-     * @param  string  $uri
-     * @param  array  $headers
+     *
+     * @param string $uri
+     * @param array  $headers
+     *
      * @return TestResponse
      */
     public function get($uri, array $headers = [])
      * @return TestResponse
      */
     public function get($uri, array $headers = [])
@@ -41,7 +49,8 @@ abstract class TestCase extends BaseTestCase
     /**
      * Create the test response instance from the given response.
      *
     /**
      * Create the test response instance from the given response.
      *
-     * @param  \Illuminate\Http\Response $response
+     * @param \Illuminate\Http\Response $response
+     *
      * @return TestResponse
      */
     protected function createTestResponse($response)
      * @return TestResponse
      */
     protected function createTestResponse($response)
@@ -64,4 +73,4 @@ abstract class TestCase extends BaseTestCase
 
         $this->assertDatabaseHas('activities', $detailsToCheck);
     }
 
         $this->assertDatabaseHas('activities', $detailsToCheck);
     }
-}
\ No newline at end of file
+}
index 76ff322fff6e0dae8ede4d175ef3e4b46ffa3c6b..0a2091fe3e92bc0dd018acc216087b107e37e7a1 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests;
+<?php
+
+namespace Tests;
 
 use BookStack\Notifications\TestEmail;
 use Illuminate\Contracts\Notifications\Dispatcher;
 
 use BookStack\Notifications\TestEmail;
 use Illuminate\Contracts\Notifications\Dispatcher;
@@ -6,7 +8,6 @@ use Illuminate\Support\Facades\Notification;
 
 class TestEmailTest extends TestCase
 {
 
 class TestEmailTest extends TestCase
 {
-
     public function test_a_send_test_button_shows()
     {
         $pageView = $this->asAdmin()->get('/settings/maintenance');
     public function test_a_send_test_button_shows()
     {
         $pageView = $this->asAdmin()->get('/settings/maintenance');
@@ -57,6 +58,4 @@ class TestEmailTest extends TestCase
         $sendReq = $this->actingAs($user)->post('/settings/maintenance/send-test-email');
         Notification::assertSentTo($user, TestEmail::class);
     }
         $sendReq = $this->actingAs($user)->post('/settings/maintenance/send-test-email');
         Notification::assertSentTo($user, TestEmail::class);
     }
-
-
-}
\ No newline at end of file
+}
index bf7ee0f69add042497b6862569354b1f1629427f..39a9d796b12a218085e092235ffe21f553d91bd6 100644 (file)
@@ -1,16 +1,17 @@
-<?php namespace Tests;
+<?php
 
 
-use \Illuminate\Foundation\Testing\TestResponse as BaseTestResponse;
-use Symfony\Component\DomCrawler\Crawler;
+namespace Tests;
+
+use Illuminate\Foundation\Testing\TestResponse as BaseTestResponse;
 use PHPUnit\Framework\Assert as PHPUnit;
 use PHPUnit\Framework\Assert as PHPUnit;
+use Symfony\Component\DomCrawler\Crawler;
 
 /**
  * Class TestResponse
  * Custom extension of the default Laravel TestResponse class.
 
 /**
  * Class TestResponse
  * Custom extension of the default Laravel TestResponse class.
- * @package Tests
  */
  */
-class TestResponse extends BaseTestResponse {
-
+class TestResponse extends BaseTestResponse
+{
     protected $crawlerInstance;
 
     /**
     protected $crawlerInstance;
 
     /**
@@ -21,11 +22,13 @@ class TestResponse extends BaseTestResponse {
         if (!is_object($this->crawlerInstance)) {
             $this->crawlerInstance = new Crawler($this->getContent());
         }
         if (!is_object($this->crawlerInstance)) {
             $this->crawlerInstance = new Crawler($this->getContent());
         }
+
         return $this->crawlerInstance;
     }
 
     /**
      * Assert the response contains the specified element.
         return $this->crawlerInstance;
     }
 
     /**
      * Assert the response contains the specified element.
+     *
      * @return $this
      */
     public function assertElementExists(string $selector)
      * @return $this
      */
     public function assertElementExists(string $selector)
@@ -33,16 +36,18 @@ class TestResponse extends BaseTestResponse {
         $elements = $this->crawler()->filter($selector);
         PHPUnit::assertTrue(
             $elements->count() > 0,
         $elements = $this->crawler()->filter($selector);
         PHPUnit::assertTrue(
             $elements->count() > 0,
-            'Unable to find element matching the selector: '.PHP_EOL.PHP_EOL.
-            "[{$selector}]".PHP_EOL.PHP_EOL.
-            'within'.PHP_EOL.PHP_EOL.
+            'Unable to find element matching the selector: ' . PHP_EOL . PHP_EOL .
+            "[{$selector}]" . PHP_EOL . PHP_EOL .
+            'within' . PHP_EOL . PHP_EOL .
             "[{$this->getContent()}]."
         );
             "[{$this->getContent()}]."
         );
+
         return $this;
     }
 
     /**
      * Assert the response does not contain the specified element.
         return $this;
     }
 
     /**
      * Assert the response does not contain the specified element.
+     *
      * @return $this
      */
     public function assertElementNotExists(string $selector)
      * @return $this
      */
     public function assertElementNotExists(string $selector)
@@ -50,11 +55,12 @@ class TestResponse extends BaseTestResponse {
         $elements = $this->crawler()->filter($selector);
         PHPUnit::assertTrue(
             $elements->count() === 0,
         $elements = $this->crawler()->filter($selector);
         PHPUnit::assertTrue(
             $elements->count() === 0,
-            'Found elements matching the selector: '.PHP_EOL.PHP_EOL.
-            "[{$selector}]".PHP_EOL.PHP_EOL.
-            'within'.PHP_EOL.PHP_EOL.
+            'Found elements matching the selector: ' . PHP_EOL . PHP_EOL .
+            "[{$selector}]" . PHP_EOL . PHP_EOL .
+            'within' . PHP_EOL . PHP_EOL .
             "[{$this->getContent()}]."
         );
             "[{$this->getContent()}]."
         );
+
         return $this;
     }
 
         return $this;
     }
 
@@ -62,6 +68,7 @@ class TestResponse extends BaseTestResponse {
      * Assert the response includes a specific element containing the given text.
      * If an nth match is provided, only that will be checked otherwise all matching
      * elements will be checked for the given text.
      * Assert the response includes a specific element containing the given text.
      * If an nth match is provided, only that will be checked otherwise all matching
      * elements will be checked for the given text.
+     *
      * @return $this
      */
     public function assertElementContains(string $selector, string $text, ?int $nthMatch = null)
      * @return $this
      */
     public function assertElementContains(string $selector, string $text, ?int $nthMatch = null)
@@ -84,12 +91,12 @@ class TestResponse extends BaseTestResponse {
 
         PHPUnit::assertTrue(
             $matched,
 
         PHPUnit::assertTrue(
             $matched,
-            'Unable to find element of selector: '.PHP_EOL.PHP_EOL.
-            ($nthMatch ? ("at position {$nthMatch}".PHP_EOL.PHP_EOL) : '') .
-            "[{$selector}]".PHP_EOL.PHP_EOL.
-            'containing text'.PHP_EOL.PHP_EOL.
-            "[{$text}]".PHP_EOL.PHP_EOL.
-            'within'.PHP_EOL.PHP_EOL.
+            'Unable to find element of selector: ' . PHP_EOL . PHP_EOL .
+            ($nthMatch ? ("at position {$nthMatch}" . PHP_EOL . PHP_EOL) : '') .
+            "[{$selector}]" . PHP_EOL . PHP_EOL .
+            'containing text' . PHP_EOL . PHP_EOL .
+            "[{$text}]" . PHP_EOL . PHP_EOL .
+            'within' . PHP_EOL . PHP_EOL .
             "[{$this->getContent()}]."
         );
 
             "[{$this->getContent()}]."
         );
 
@@ -100,6 +107,7 @@ class TestResponse extends BaseTestResponse {
      * Assert the response does not include a specific element containing the given text.
      * If an nth match is provided, only that will be checked otherwise all matching
      * elements will be checked for the given text.
      * Assert the response does not include a specific element containing the given text.
      * If an nth match is provided, only that will be checked otherwise all matching
      * elements will be checked for the given text.
+     *
      * @return $this
      */
     public function assertElementNotContains(string $selector, string $text, ?int $nthMatch = null)
      * @return $this
      */
     public function assertElementNotContains(string $selector, string $text, ?int $nthMatch = null)
@@ -122,12 +130,12 @@ class TestResponse extends BaseTestResponse {
 
         PHPUnit::assertTrue(
             !$matched,
 
         PHPUnit::assertTrue(
             !$matched,
-            'Found element of selector: '.PHP_EOL.PHP_EOL.
-            ($nthMatch ? ("at position {$nthMatch}".PHP_EOL.PHP_EOL) : '') .
-            "[{$selector}]".PHP_EOL.PHP_EOL.
-            'containing text'.PHP_EOL.PHP_EOL.
-            "[{$text}]".PHP_EOL.PHP_EOL.
-            'within'.PHP_EOL.PHP_EOL.
+            'Found element of selector: ' . PHP_EOL . PHP_EOL .
+            ($nthMatch ? ("at position {$nthMatch}" . PHP_EOL . PHP_EOL) : '') .
+            "[{$selector}]" . PHP_EOL . PHP_EOL .
+            'containing text' . PHP_EOL . PHP_EOL .
+            "[{$text}]" . PHP_EOL . PHP_EOL .
+            'within' . PHP_EOL . PHP_EOL .
             "[{$this->getContent()}]."
         );
 
             "[{$this->getContent()}]."
         );
 
@@ -136,6 +144,7 @@ class TestResponse extends BaseTestResponse {
 
     /**
      * Assert there's a notification within the view containing the given text.
 
     /**
      * Assert there's a notification within the view containing the given text.
+     *
      * @return $this
      */
     public function assertNotificationContains(string $text)
      * @return $this
      */
     public function assertNotificationContains(string $text)
@@ -145,14 +154,15 @@ class TestResponse extends BaseTestResponse {
 
     /**
      * Get the escaped text pattern for the constraint.
 
     /**
      * Get the escaped text pattern for the constraint.
+     *
      * @return string
      */
     protected function getEscapedPattern(string $text)
     {
         $rawPattern = preg_quote($text, '/');
         $escapedPattern = preg_quote(e($text), '/');
      * @return string
      */
     protected function getEscapedPattern(string $text)
     {
         $rawPattern = preg_quote($text, '/');
         $escapedPattern = preg_quote(e($text), '/');
+
         return $rawPattern == $escapedPattern
             ? $rawPattern : "({$rawPattern}|{$escapedPattern})";
     }
         return $rawPattern == $escapedPattern
             ? $rawPattern : "({$rawPattern}|{$escapedPattern})";
     }
-
 }
 }
index be3fc4ebdd1d4c5bdfb8eb3c78ce2afb297832be..bab85be7a5e4ff9f8c0dd8bff3abbc785cb54cbc 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests;
+<?php
+
+namespace Tests;
 
 use BookStack\Auth\User;
 use BookStack\Entities\Models\Page;
 
 use BookStack\Auth\User;
 use BookStack\Entities\Models\Page;
@@ -49,6 +51,7 @@ class ThemeTest extends TestCase
         $callback = function ($environment) use (&$callbackCalled) {
             $this->assertInstanceOf(ConfigurableEnvironmentInterface::class, $environment);
             $callbackCalled = true;
         $callback = function ($environment) use (&$callbackCalled) {
             $this->assertInstanceOf(ConfigurableEnvironmentInterface::class, $environment);
             $callbackCalled = true;
+
             return $environment;
         };
         Theme::listen(ThemeEvents::COMMONMARK_ENVIRONMENT_CONFIGURE, $callback);
             return $environment;
         };
         Theme::listen(ThemeEvents::COMMONMARK_ENVIRONMENT_CONFIGURE, $callback);
@@ -158,8 +161,8 @@ class ThemeTest extends TestCase
     public function test_add_social_driver()
     {
         Theme::addSocialDriver('catnet', [
     public function test_add_social_driver()
     {
         Theme::addSocialDriver('catnet', [
-            'client_id' => 'abc123',
-            'client_secret' => 'def456'
+            'client_id'     => 'abc123',
+            'client_secret' => 'def456',
         ], 'SocialiteProviders\Discord\DiscordExtendSocialite@handleTesting');
 
         $this->assertEquals('catnet', config('services.catnet.name'));
         ], 'SocialiteProviders\Discord\DiscordExtendSocialite@handleTesting');
 
         $this->assertEquals('catnet', config('services.catnet.name'));
@@ -173,9 +176,9 @@ class ThemeTest extends TestCase
     public function test_add_social_driver_uses_name_in_config_if_given()
     {
         Theme::addSocialDriver('catnet', [
     public function test_add_social_driver_uses_name_in_config_if_given()
     {
         Theme::addSocialDriver('catnet', [
-            'client_id' => 'abc123',
+            'client_id'     => 'abc123',
             'client_secret' => 'def456',
             'client_secret' => 'def456',
-            'name' => 'Super Cat Name',
+            'name'          => 'Super Cat Name',
         ], 'SocialiteProviders\Discord\DiscordExtendSocialite@handleTesting');
 
         $this->assertEquals('Super Cat Name', config('services.catnet.name'));
         ], 'SocialiteProviders\Discord\DiscordExtendSocialite@handleTesting');
 
         $this->assertEquals('Super Cat Name', config('services.catnet.name'));
@@ -183,15 +186,14 @@ class ThemeTest extends TestCase
         $loginResp->assertSee('Super Cat Name');
     }
 
         $loginResp->assertSee('Super Cat Name');
     }
 
-
     public function test_add_social_driver_allows_a_configure_for_redirect_callback_to_be_passed()
     {
         Theme::addSocialDriver(
             'discord',
             [
     public function test_add_social_driver_allows_a_configure_for_redirect_callback_to_be_passed()
     {
         Theme::addSocialDriver(
             'discord',
             [
-                'client_id' => 'abc123',
+                'client_id'     => 'abc123',
                 'client_secret' => 'def456',
                 'client_secret' => 'def456',
-                'name' => 'Super Cat Name',
+                'name'          => 'Super Cat Name',
             ],
             'SocialiteProviders\Discord\DiscordExtendSocialite@handle',
             function ($driver) {
             ],
             'SocialiteProviders\Discord\DiscordExtendSocialite@handle',
             function ($driver) {
@@ -204,11 +206,10 @@ class ThemeTest extends TestCase
         $this->assertStringContainsString('donkey=donut', $redirect);
     }
 
         $this->assertStringContainsString('donkey=donut', $redirect);
     }
 
-
     protected function usingThemeFolder(callable $callback)
     {
         // Create a folder and configure a theme
     protected function usingThemeFolder(callable $callback)
     {
         // Create a folder and configure a theme
-        $themeFolderName = 'testing_theme_' . rtrim(base64_encode(time()), "=");
+        $themeFolderName = 'testing_theme_' . rtrim(base64_encode(time()), '=');
         config()->set('view.theme', $themeFolderName);
         $themeFolderPath = theme_path('');
         File::makeDirectory($themeFolderPath);
         config()->set('view.theme', $themeFolderName);
         $themeFolderPath = theme_path('');
         File::makeDirectory($themeFolderPath);
@@ -218,5 +219,4 @@ class ThemeTest extends TestCase
         // Cleanup the custom theme folder we created
         File::deleteDirectory($themeFolderPath);
     }
         // Cleanup the custom theme folder we created
         File::deleteDirectory($themeFolderPath);
     }
-
-}
\ No newline at end of file
+}
index 0833ffbd8858c4a049ecd7354a58800d37d8b947..f45d201363294274588d2e2ad318b8f970714a61 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests\Unit;
+<?php
+
+namespace Tests\Unit;
 
 use Illuminate\Support\Facades\Log;
 use Tests\TestCase;
 
 use Illuminate\Support\Facades\Log;
 use Tests\TestCase;
@@ -7,15 +9,12 @@ use Tests\TestCase;
  * Class ConfigTest
  * Many of the tests here are to check on tweaks made
  * to maintain backwards compatibility.
  * Class ConfigTest
  * Many of the tests here are to check on tweaks made
  * to maintain backwards compatibility.
- *
- * @package Tests
  */
 class ConfigTest extends TestCase
 {
  */
 class ConfigTest extends TestCase
 {
-
     public function test_filesystem_images_falls_back_to_storage_type_var()
     {
     public function test_filesystem_images_falls_back_to_storage_type_var()
     {
-        $this->runWithEnv('STORAGE_TYPE', 'local_secure', function() {
+        $this->runWithEnv('STORAGE_TYPE', 'local_secure', function () {
             $this->checkEnvConfigResult('STORAGE_IMAGE_TYPE', 's3', 'filesystems.images', 's3');
             $this->checkEnvConfigResult('STORAGE_IMAGE_TYPE', null, 'filesystems.images', 'local_secure');
         });
             $this->checkEnvConfigResult('STORAGE_IMAGE_TYPE', 's3', 'filesystems.images', 's3');
             $this->checkEnvConfigResult('STORAGE_IMAGE_TYPE', null, 'filesystems.images', 'local_secure');
         });
@@ -23,7 +22,7 @@ class ConfigTest extends TestCase
 
     public function test_filesystem_attachments_falls_back_to_storage_type_var()
     {
 
     public function test_filesystem_attachments_falls_back_to_storage_type_var()
     {
-        $this->runWithEnv('STORAGE_TYPE', 'local_secure', function() {
+        $this->runWithEnv('STORAGE_TYPE', 'local_secure', function () {
             $this->checkEnvConfigResult('STORAGE_ATTACHMENT_TYPE', 's3', 'filesystems.attachments', 's3');
             $this->checkEnvConfigResult('STORAGE_ATTACHMENT_TYPE', null, 'filesystems.attachments', 'local_secure');
         });
             $this->checkEnvConfigResult('STORAGE_ATTACHMENT_TYPE', 's3', 'filesystems.attachments', 's3');
             $this->checkEnvConfigResult('STORAGE_ATTACHMENT_TYPE', null, 'filesystems.attachments', 'local_secure');
         });
@@ -46,11 +45,11 @@ class ConfigTest extends TestCase
         ]);
 
         $temp = tempnam(sys_get_temp_dir(), 'bs-test');
         ]);
 
         $temp = tempnam(sys_get_temp_dir(), 'bs-test');
-        $original = ini_set( 'error_log', $temp);
+        $original = ini_set('error_log', $temp);
 
         Log::channel('errorlog_plain_webserver')->info('Aww, look, a cute puppy');
 
 
         Log::channel('errorlog_plain_webserver')->info('Aww, look, a cute puppy');
 
-        ini_set( 'error_log', $original);
+        ini_set('error_log', $original);
 
         $output = file_get_contents($temp);
         $this->assertStringContainsString('Aww, look, a cute puppy', $output);
 
         $output = file_get_contents($temp);
         $this->assertStringContainsString('Aww, look, a cute puppy', $output);
@@ -81,13 +80,13 @@ class ConfigTest extends TestCase
      * Set an environment variable of the given name and value
      * then check the given config key to see if it matches the given result.
      * Providing a null $envVal clears the variable.
      * Set an environment variable of the given name and value
      * then check the given config key to see if it matches the given result.
      * Providing a null $envVal clears the variable.
+     *
      * @param mixed $expectedResult
      */
     protected function checkEnvConfigResult(string $envName, ?string $envVal, string $configKey, $expectedResult)
     {
      * @param mixed $expectedResult
      */
     protected function checkEnvConfigResult(string $envName, ?string $envVal, string $configKey, $expectedResult)
     {
-        $this->runWithEnv($envName, $envVal, function() use ($configKey, $expectedResult) {
+        $this->runWithEnv($envName, $envVal, function () use ($configKey, $expectedResult) {
             $this->assertEquals($expectedResult, config($configKey));
         });
     }
             $this->assertEquals($expectedResult, config($configKey));
         });
     }
-
-}
\ No newline at end of file
+}
index b9f485da13f0743178049d2e314db04fccd18536..fff5414f2bd45df1aec13c8be529ae462b3a3001 100644 (file)
@@ -1,22 +1,22 @@
-<?php namespace Tests\Unit;
+<?php
+
+namespace Tests\Unit;
 
 use Tests\TestCase;
 
 class UrlTest extends TestCase
 {
 
 use Tests\TestCase;
 
 class UrlTest extends TestCase
 {
-
     public function test_url_helper_takes_custom_url_into_account()
     {
     public function test_url_helper_takes_custom_url_into_account()
     {
-        $this->runWithEnv('APP_URL', 'http://example.com/bookstack', function() {
+        $this->runWithEnv('APP_URL', 'http://example.com/bookstack', function () {
             $this->assertEquals('http://example.com/bookstack/books', url('/books'));
         });
     }
 
     public function test_url_helper_sets_correct_scheme_even_when_request_scheme_is_different()
     {
             $this->assertEquals('http://example.com/bookstack/books', url('/books'));
         });
     }
 
     public function test_url_helper_sets_correct_scheme_even_when_request_scheme_is_different()
     {
-        $this->runWithEnv('APP_URL', 'https://example.com/', function() {
+        $this->runWithEnv('APP_URL', 'https://example.com/', function () {
             $this->get('http://example.com/login')->assertSee('https://example.com/dist/styles.css');
         });
     }
             $this->get('http://example.com/login')->assertSee('https://example.com/dist/styles.css');
         });
     }
-
-}
\ No newline at end of file
+}
index 55a5aa84fed023e82f2c384d8b13327231dae8c2..2248bc2c5d15a3833ac129fb9bb6ae007e30b191 100644 (file)
@@ -1,9 +1,11 @@
-<?php namespace Tests\Uploads;
+<?php
 
 
-use BookStack\Entities\Tools\TrashCan;
+namespace Tests\Uploads;
+
+use BookStack\Entities\Models\Page;
 use BookStack\Entities\Repos\PageRepo;
 use BookStack\Entities\Repos\PageRepo;
+use BookStack\Entities\Tools\TrashCan;
 use BookStack\Uploads\Attachment;
 use BookStack\Uploads\Attachment;
-use BookStack\Entities\Models\Page;
 use BookStack\Uploads\AttachmentService;
 use Illuminate\Http\UploadedFile;
 use Tests\TestCase;
 use BookStack\Uploads\AttachmentService;
 use Illuminate\Http\UploadedFile;
 use Tests\TestCase;
@@ -11,7 +13,7 @@ use Tests\TestCase;
 class AttachmentTest extends TestCase
 {
     /**
 class AttachmentTest extends TestCase
 {
     /**
-     * Get a test file that can be uploaded
+     * Get a test file that can be uploaded.
      */
     protected function getTestFile(string $fileName): UploadedFile
     {
      */
     protected function getTestFile(string $fileName): UploadedFile
     {
@@ -24,17 +26,18 @@ class AttachmentTest extends TestCase
     protected function uploadFile(string $name, int $uploadedTo = 0): \Illuminate\Foundation\Testing\TestResponse
     {
         $file = $this->getTestFile($name);
     protected function uploadFile(string $name, int $uploadedTo = 0): \Illuminate\Foundation\Testing\TestResponse
     {
         $file = $this->getTestFile($name);
+
         return $this->call('POST', '/attachments/upload', ['uploaded_to' => $uploadedTo], [], ['file' => $file], []);
     }
 
     /**
         return $this->call('POST', '/attachments/upload', ['uploaded_to' => $uploadedTo], [], ['file' => $file], []);
     }
 
     /**
-     * Create a new attachment
+     * Create a new attachment.
      */
     protected function createAttachment(Page $page): Attachment
     {
         $this->post('attachments/link', [
      */
     protected function createAttachment(Page $page): Attachment
     {
         $this->post('attachments/link', [
-            'attachment_link_url' => 'https://example.com',
-            'attachment_link_name' => 'Example Attachment Link',
+            'attachment_link_url'         => 'https://example.com',
+            'attachment_link_name'        => 'Example Attachment Link',
             'attachment_link_uploaded_to' => $page->id,
         ]);
 
             'attachment_link_uploaded_to' => $page->id,
         ]);
 
@@ -61,10 +64,10 @@ class AttachmentTest extends TestCase
         $fileName = 'upload_test_file.txt';
 
         $expectedResp = [
         $fileName = 'upload_test_file.txt';
 
         $expectedResp = [
-            'name' => $fileName,
+            'name'       => $fileName,
             'uploaded_to'=> $page->id,
             'uploaded_to'=> $page->id,
-            'extension' => 'txt',
-            'order' => 1,
+            'extension'  => 'txt',
+            'order'      => 1,
             'created_by' => $admin->id,
             'updated_by' => $admin->id,
         ];
             'created_by' => $admin->id,
             'updated_by' => $admin->id,
         ];
@@ -86,7 +89,6 @@ class AttachmentTest extends TestCase
         $page = Page::query()->first();
         $fileName = 'upload_test_file.txt';
 
         $page = Page::query()->first();
         $fileName = 'upload_test_file.txt';
 
-
         $upload = $this->asAdmin()->uploadFile($fileName, $page->id);
         $upload->assertStatus(200);
 
         $upload = $this->asAdmin()->uploadFile($fileName, $page->id);
         $upload->assertStatus(200);
 
@@ -122,20 +124,20 @@ class AttachmentTest extends TestCase
         $this->asAdmin();
 
         $linkReq = $this->call('POST', 'attachments/link', [
         $this->asAdmin();
 
         $linkReq = $this->call('POST', 'attachments/link', [
-            'attachment_link_url' => 'https://example.com',
-            'attachment_link_name' => 'Example Attachment Link',
+            'attachment_link_url'         => 'https://example.com',
+            'attachment_link_name'        => 'Example Attachment Link',
             'attachment_link_uploaded_to' => $page->id,
         ]);
 
         $expectedData = [
             'attachment_link_uploaded_to' => $page->id,
         ]);
 
         $expectedData = [
-            'path' => 'https://example.com',
-            'name' => 'Example Attachment Link',
+            'path'        => 'https://example.com',
+            'name'        => 'Example Attachment Link',
             'uploaded_to' => $page->id,
             'uploaded_to' => $page->id,
-            'created_by' => $admin->id,
-            'updated_by' => $admin->id,
-            'external' => true,
-            'order' => 1,
-            'extension' => ''
+            'created_by'  => $admin->id,
+            'updated_by'  => $admin->id,
+            'external'    => true,
+            'order'       => 1,
+            'extension'   => '',
         ];
 
         $linkReq->assertStatus(200);
         ];
 
         $linkReq->assertStatus(200);
@@ -160,14 +162,14 @@ class AttachmentTest extends TestCase
         $attachment = $this->createAttachment($page);
         $update = $this->call('PUT', 'attachments/' . $attachment->id, [
             'attachment_edit_name' => 'My new attachment name',
         $attachment = $this->createAttachment($page);
         $update = $this->call('PUT', 'attachments/' . $attachment->id, [
             'attachment_edit_name' => 'My new attachment name',
-            'attachment_edit_url' => 'https://test.example.com'
+            'attachment_edit_url'  => 'https://test.example.com',
         ]);
 
         $expectedData = [
         ]);
 
         $expectedData = [
-            'id' => $attachment->id,
-            'path' => 'https://test.example.com',
-            'name' => 'My new attachment name',
-            'uploaded_to' => $page->id
+            'id'          => $attachment->id,
+            'path'        => 'https://test.example.com',
+            'name'        => 'My new attachment name',
+            'uploaded_to' => $page->id,
         ];
 
         $update->assertStatus(200);
         ];
 
         $update->assertStatus(200);
@@ -191,7 +193,7 @@ class AttachmentTest extends TestCase
         $this->delete($attachment->getUrl());
 
         $this->assertDatabaseMissing('attachments', [
         $this->delete($attachment->getUrl());
 
         $this->assertDatabaseMissing('attachments', [
-            'name' => $fileName
+            'name' => $fileName,
         ]);
         $this->assertFalse(file_exists($filePath), 'File at path ' . $filePath . ' was not deleted as expected');
 
         ]);
         $this->assertFalse(file_exists($filePath), 'File at path ' . $filePath . ' was not deleted as expected');
 
@@ -210,14 +212,14 @@ class AttachmentTest extends TestCase
 
         $this->assertTrue(file_exists($filePath), 'File at path ' . $filePath . ' does not exist');
         $this->assertDatabaseHas('attachments', [
 
         $this->assertTrue(file_exists($filePath), 'File at path ' . $filePath . ' does not exist');
         $this->assertDatabaseHas('attachments', [
-            'name' => $fileName
+            'name' => $fileName,
         ]);
 
         app(PageRepo::class)->destroy($page);
         app(TrashCan::class)->empty();
 
         $this->assertDatabaseMissing('attachments', [
         ]);
 
         app(PageRepo::class)->destroy($page);
         app(TrashCan::class)->empty();
 
         $this->assertDatabaseMissing('attachments', [
-            'name' => $fileName
+            'name' => $fileName,
         ]);
         $this->assertFalse(file_exists($filePath), 'File at path ' . $filePath . ' was not deleted as expected');
 
         ]);
         $this->assertFalse(file_exists($filePath), 'File at path ' . $filePath . ' was not deleted as expected');
 
@@ -229,7 +231,6 @@ class AttachmentTest extends TestCase
         $admin = $this->getAdmin();
         $viewer = $this->getViewer();
         $page = Page::query()->first(); /** @var Page $page */
         $admin = $this->getAdmin();
         $viewer = $this->getViewer();
         $page = Page::query()->first(); /** @var Page $page */
-
         $this->actingAs($admin);
         $fileName = 'permission_test.txt';
         $this->uploadFile($fileName, $page->id);
         $this->actingAs($admin);
         $fileName = 'permission_test.txt';
         $this->uploadFile($fileName, $page->id);
@@ -244,7 +245,7 @@ class AttachmentTest extends TestCase
         $this->actingAs($viewer);
         $attachmentGet = $this->get($attachment->getUrl());
         $attachmentGet->assertStatus(404);
         $this->actingAs($viewer);
         $attachmentGet = $this->get($attachment->getUrl());
         $attachmentGet->assertStatus(404);
-        $attachmentGet->assertSee("Attachment not found");
+        $attachmentGet->assertSee('Attachment not found');
 
         $this->deleteUploads();
     }
 
         $this->deleteUploads();
     }
@@ -259,15 +260,15 @@ class AttachmentTest extends TestCase
             ' javascript:alert("bunny")',
             'JavaScript:alert("bunny")',
             "\t\n\t\nJavaScript:alert(\"bunny\")",
             ' javascript:alert("bunny")',
             'JavaScript:alert("bunny")',
             "\t\n\t\nJavaScript:alert(\"bunny\")",
-            "data:text/html;<a></a>",
-            "Data:text/html;<a></a>",
-            "Data:text/html;<a></a>",
+            'data:text/html;<a></a>',
+            'Data:text/html;<a></a>',
+            'Data:text/html;<a></a>',
         ];
 
         foreach ($badLinks as $badLink) {
             $linkReq = $this->post('attachments/link', [
         ];
 
         foreach ($badLinks as $badLink) {
             $linkReq = $this->post('attachments/link', [
-                'attachment_link_url' => $badLink,
-                'attachment_link_name' => 'Example Attachment Link',
+                'attachment_link_url'         => $badLink,
+                'attachment_link_name'        => 'Example Attachment Link',
                 'attachment_link_uploaded_to' => $page->id,
             ]);
             $linkReq->assertStatus(422);
                 'attachment_link_uploaded_to' => $page->id,
             ]);
             $linkReq->assertStatus(422);
@@ -280,7 +281,7 @@ class AttachmentTest extends TestCase
 
         foreach ($badLinks as $badLink) {
             $linkReq = $this->put('attachments/' . $attachment->id, [
 
         foreach ($badLinks as $badLink) {
             $linkReq = $this->put('attachments/' . $attachment->id, [
-                'attachment_edit_url' => $badLink,
+                'attachment_edit_url'  => $badLink,
                 'attachment_edit_name' => 'Example Attachment Link',
             ]);
             $linkReq->assertStatus(422);
                 'attachment_edit_name' => 'Example Attachment Link',
             ]);
             $linkReq->assertStatus(422);
@@ -303,7 +304,7 @@ class AttachmentTest extends TestCase
         $attachmentGet = $this->get($attachment->getUrl(true));
         // http-foundation/Response does some 'fixing' of responses to add charsets to text responses.
         $attachmentGet->assertHeader('Content-Type', 'text/plain; charset=UTF-8');
         $attachmentGet = $this->get($attachment->getUrl(true));
         // http-foundation/Response does some 'fixing' of responses to add charsets to text responses.
         $attachmentGet->assertHeader('Content-Type', 'text/plain; charset=UTF-8');
-        $attachmentGet->assertHeader('Content-Disposition', "inline; filename=\"upload_test_file.txt\"");
+        $attachmentGet->assertHeader('Content-Disposition', 'inline; filename="upload_test_file.txt"');
 
         $this->deleteUploads();
     }
 
         $this->deleteUploads();
     }
index efaa016ddc6660ead3ea67d9a300ccd54cd75e4f..cf568d07cf6c909b7c46597b5a22d91bb25f94e2 100644 (file)
@@ -1,24 +1,25 @@
-<?php namespace Tests\Uploads;
+<?php
+
+namespace Tests\Uploads;
 
 use BookStack\Auth\User;
 use BookStack\Exceptions\HttpFetchException;
 use BookStack\Uploads\HttpFetcher;
 
 use BookStack\Auth\User;
 use BookStack\Exceptions\HttpFetchException;
 use BookStack\Uploads\HttpFetcher;
-use Illuminate\Support\Facades\Log;
 use Tests\TestCase;
 
 class AvatarTest extends TestCase
 {
     use UsesImages;
 
 use Tests\TestCase;
 
 class AvatarTest extends TestCase
 {
     use UsesImages;
 
-
     protected function createUserRequest($user)
     {
         $this->asAdmin()->post('/settings/users/create', [
     protected function createUserRequest($user)
     {
         $this->asAdmin()->post('/settings/users/create', [
-            'name' => $user->name,
-            'email' => $user->email,
-            'password' => 'testing',
+            'name'             => $user->name,
+            'email'            => $user->email,
+            'password'         => 'testing',
             'password-confirm' => 'testing',
         ]);
             'password-confirm' => 'testing',
         ]);
+
         return User::where('email', '=', $user->email)->first();
     }
 
         return User::where('email', '=', $user->email)->first();
     }
 
@@ -42,26 +43,25 @@ class AvatarTest extends TestCase
             'services.disable_services' => false,
         ]);
         $user = factory(User::class)->make();
             'services.disable_services' => false,
         ]);
         $user = factory(User::class)->make();
-        $this->assertImageFetchFrom('https://www.gravatar.com/avatar/'.md5(strtolower($user->email)).'?s=500&d=identicon');
+        $this->assertImageFetchFrom('https://www.gravatar.com/avatar/' . md5(strtolower($user->email)) . '?s=500&d=identicon');
 
         $user = $this->createUserRequest($user);
         $this->assertDatabaseHas('images', [
 
         $user = $this->createUserRequest($user);
         $this->assertDatabaseHas('images', [
-            'type' => 'user',
-            'created_by' => $user->id
+            'type'       => 'user',
+            'created_by' => $user->id,
         ]);
         $this->deleteUserImage($user);
     }
 
         ]);
         $this->deleteUserImage($user);
     }
 
-
     public function test_custom_url_used_if_set()
     {
         config()->set([
             'services.disable_services' => false,
     public function test_custom_url_used_if_set()
     {
         config()->set([
             'services.disable_services' => false,
-            'services.avatar_url' => 'https://example.com/${email}/${hash}/${size}',
+            'services.avatar_url'       => 'https://example.com/${email}/${hash}/${size}',
         ]);
 
         $user = factory(User::class)->make();
         ]);
 
         $user = factory(User::class)->make();
-        $url = 'https://example.com/'. urlencode(strtolower($user->email)) .'/'. md5(strtolower($user->email)).'/500';
+        $url = 'https://example.com/' . urlencode(strtolower($user->email)) . '/' . md5(strtolower($user->email)) . '/500';
         $this->assertImageFetchFrom($url);
 
         $user = $this->createUserRequest($user);
         $this->assertImageFetchFrom($url);
 
         $user = $this->createUserRequest($user);
@@ -97,5 +97,4 @@ class AvatarTest extends TestCase
         $this->createUserRequest($user);
         $this->assertTrue($logger->hasError('Failed to save user avatar image'));
     }
         $this->createUserRequest($user);
         $this->assertTrue($logger->hasError('Failed to save user avatar image'));
     }
-
 }
 }
index d134135aa6e9aed7a6f3fceb0a07d37702252ec0..422de472ae00d610dfb4d67e28b47cb157e59ac7 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests\Uploads;
+<?php
+
+namespace Tests\Uploads;
 
 use BookStack\Entities\Models\Page;
 use BookStack\Uploads\Image;
 
 use BookStack\Entities\Models\Page;
 use BookStack\Uploads\Image;
@@ -21,7 +23,7 @@ class DrawioTest extends TestCase
 
         $imageGet = $this->getJson("/images/drawio/base64/{$image->id}");
         $imageGet->assertJson([
 
         $imageGet = $this->getJson("/images/drawio/base64/{$image->id}");
         $imageGet->assertJson([
-            'content' => 'iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAIAAAACDbGyAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4gEcDCo5iYNs+gAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAAAFElEQVQI12O0jN/KgASYGFABqXwAZtoBV6Sl3hIAAAAASUVORK5CYII='
+            'content' => 'iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAIAAAACDbGyAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4gEcDCo5iYNs+gAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAAAFElEQVQI12O0jN/KgASYGFABqXwAZtoBV6Sl3hIAAAAASUVORK5CYII=',
         ]);
     }
 
         ]);
     }
 
@@ -33,23 +35,23 @@ class DrawioTest extends TestCase
 
         $upload = $this->postJson('images/drawio', [
             'uploaded_to' => $page->id,
 
         $upload = $this->postJson('images/drawio', [
             'uploaded_to' => $page->id,
-            'image' => 'image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAIAAAACDbGyAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4gEcDCo5iYNs+gAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAAAFElEQVQI12O0jN/KgASYGFABqXwAZtoBV6Sl3hIAAAAASUVORK5CYII='
+            'image'       => 'image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAIAAAACDbGyAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4gEcDCo5iYNs+gAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAAAFElEQVQI12O0jN/KgASYGFABqXwAZtoBV6Sl3hIAAAAASUVORK5CYII=',
         ]);
 
         $upload->assertStatus(200);
         $upload->assertJson([
         ]);
 
         $upload->assertStatus(200);
         $upload->assertJson([
-            'type' => 'drawio',
+            'type'        => 'drawio',
             'uploaded_to' => $page->id,
             'uploaded_to' => $page->id,
-            'created_by' => $editor->id,
-            'updated_by' => $editor->id,
+            'created_by'  => $editor->id,
+            'updated_by'  => $editor->id,
         ]);
 
         $image = Image::where('type', '=', 'drawio')->first();
         ]);
 
         $image = Image::where('type', '=', 'drawio')->first();
-        $this->assertTrue(file_exists(public_path($image->path)), 'Uploaded image not found at path: '. public_path($image->path));
+        $this->assertTrue(file_exists(public_path($image->path)), 'Uploaded image not found at path: ' . public_path($image->path));
 
         $testImageData = file_get_contents($this->getTestImageFilePath());
         $uploadedImageData = file_get_contents(public_path($image->path));
 
         $testImageData = file_get_contents($this->getTestImageFilePath());
         $uploadedImageData = file_get_contents(public_path($image->path));
-        $this->assertTrue($testImageData === $uploadedImageData, "Uploaded image file data does not match our test image as expected");
+        $this->assertTrue($testImageData === $uploadedImageData, 'Uploaded image file data does not match our test image as expected');
     }
 
     public function test_drawio_url_can_be_configured()
     }
 
     public function test_drawio_url_can_be_configured()
@@ -75,5 +77,4 @@ class DrawioTest extends TestCase
         $resp = $this->actingAs($editor)->get($page->getUrl('/edit'));
         $resp->assertDontSee('drawio-url');
     }
         $resp = $this->actingAs($editor)->get($page->getUrl('/edit'));
         $resp->assertDontSee('drawio-url');
     }
-
-}
\ No newline at end of file
+}
index 95332565e5761673cdafa5489aecced690a7faaf..69b6dc90e96218296e84d51db5d788a7af5a7aa5 100644 (file)
@@ -1,15 +1,16 @@
-<?php namespace Tests\Uploads;
+<?php
 
 
+namespace Tests\Uploads;
+
+use BookStack\Entities\Models\Page;
 use BookStack\Entities\Repos\PageRepo;
 use BookStack\Uploads\Image;
 use BookStack\Entities\Repos\PageRepo;
 use BookStack\Uploads\Image;
-use BookStack\Entities\Models\Page;
 use BookStack\Uploads\ImageService;
 use Illuminate\Support\Str;
 use Tests\TestCase;
 
 class ImageTest extends TestCase
 {
 use BookStack\Uploads\ImageService;
 use Illuminate\Support\Str;
 use Tests\TestCase;
 
 class ImageTest extends TestCase
 {
-
     use UsesImages;
 
     public function test_image_upload()
     use UsesImages;
 
     public function test_image_upload()
@@ -21,18 +22,18 @@ class ImageTest extends TestCase
         $imgDetails = $this->uploadGalleryImage($page);
         $relPath = $imgDetails['path'];
 
         $imgDetails = $this->uploadGalleryImage($page);
         $relPath = $imgDetails['path'];
 
-        $this->assertTrue(file_exists(public_path($relPath)), 'Uploaded image found at path: '. public_path($relPath));
+        $this->assertTrue(file_exists(public_path($relPath)), 'Uploaded image found at path: ' . public_path($relPath));
 
         $this->deleteImage($relPath);
 
         $this->assertDatabaseHas('images', [
 
         $this->deleteImage($relPath);
 
         $this->assertDatabaseHas('images', [
-            'url' => $this->baseUrl . $relPath,
-            'type' => 'gallery',
+            'url'         => $this->baseUrl . $relPath,
+            'type'        => 'gallery',
             'uploaded_to' => $page->id,
             'uploaded_to' => $page->id,
-            'path' => $relPath,
-            'created_by' => $admin->id,
-            'updated_by' => $admin->id,
-            'name' => $imgDetails['name'],
+            'path'        => $relPath,
+            'created_by'  => $admin->id,
+            'updated_by'  => $admin->id,
+            'name'        => $imgDetails['name'],
         ]);
     }
 
         ]);
     }
 
@@ -47,7 +48,7 @@ class ImageTest extends TestCase
         $imgDetails = $this->uploadGalleryImage($page, 'compressed.png');
         $relPath = $imgDetails['path'];
 
         $imgDetails = $this->uploadGalleryImage($page, 'compressed.png');
         $relPath = $imgDetails['path'];
 
-        $this->assertTrue(file_exists(public_path($relPath)), 'Uploaded image found at path: '. public_path($relPath));
+        $this->assertTrue(file_exists(public_path($relPath)), 'Uploaded image found at path: ' . public_path($relPath));
         $displayImage = $imgDetails['response']->thumbs->display;
 
         $displayImageRelPath = implode('/', array_slice(explode('/', $displayImage), 3));
         $displayImage = $imgDetails['response']->thumbs->display;
 
         $displayImageRelPath = implode('/', array_slice(explode('/', $displayImage), 3));
@@ -77,7 +78,7 @@ class ImageTest extends TestCase
 
         $this->assertDatabaseHas('images', [
             'type' => 'gallery',
 
         $this->assertDatabaseHas('images', [
             'type' => 'gallery',
-            'name' => $newName
+            'name' => $newName,
         ]);
     }
 
         ]);
     }
 
@@ -115,7 +116,7 @@ class ImageTest extends TestCase
         $imgDetails = $this->uploadGalleryImage($page);
 
         $image = Image::query()->first();
         $imgDetails = $this->uploadGalleryImage($page);
 
         $image = Image::query()->first();
-        $page->html = '<img src="'.$image->url.'">';
+        $page->html = '<img src="' . $image->url . '">';
         $page->save();
 
         $usage = $this->get('/images/edit/' . $image->id . '?delete=true');
         $page->save();
 
         $usage = $this->get('/images/edit/' . $image->id . '?delete=true');
@@ -144,7 +145,7 @@ class ImageTest extends TestCase
 
         $this->assertDatabaseMissing('images', [
             'type' => 'gallery',
 
         $this->assertDatabaseMissing('images', [
             'type' => 'gallery',
-            'name' => $fileName
+            'name' => $fileName,
         ]);
     }
 
         ]);
     }
 
@@ -194,11 +195,11 @@ class ImageTest extends TestCase
     {
         $this->asEditor();
         $badNames = [
     {
         $this->asEditor();
         $badNames = [
-            "bad-char-#-image.png",
-            "bad-char-?-image.png",
-            "?#.png",
-            "?.png",
-            "#.png",
+            'bad-char-#-image.png',
+            'bad-char-?-image.png',
+            '?#.png',
+            '?.png',
+            '#.png',
         ];
         foreach ($badNames as $name) {
             $galleryFile = $this->getTestImage($name);
         ];
         foreach ($badNames as $name) {
             $galleryFile = $this->getTestImage($name);
@@ -228,12 +229,12 @@ class ImageTest extends TestCase
         $this->asEditor();
         $galleryFile = $this->getTestImage('my-secure-test-upload.png');
         $page = Page::query()->first();
         $this->asEditor();
         $galleryFile = $this->getTestImage('my-secure-test-upload.png');
         $page = Page::query()->first();
-        $expectedPath = storage_path('uploads/images/gallery/' . Date('Y-m') . '/my-secure-test-upload.png');
+        $expectedPath = storage_path('uploads/images/gallery/' . date('Y-m') . '/my-secure-test-upload.png');
 
         $upload = $this->call('POST', '/images/gallery', ['uploaded_to' => $page->id], [], ['file' => $galleryFile], []);
         $upload->assertStatus(200);
 
 
         $upload = $this->call('POST', '/images/gallery', ['uploaded_to' => $page->id], [], ['file' => $galleryFile], []);
         $upload->assertStatus(200);
 
-        $this->assertTrue(file_exists($expectedPath), 'Uploaded image not found at path: '. $expectedPath);
+        $this->assertTrue(file_exists($expectedPath), 'Uploaded image not found at path: ' . $expectedPath);
 
         if (file_exists($expectedPath)) {
             unlink($expectedPath);
 
         if (file_exists($expectedPath)) {
             unlink($expectedPath);
@@ -246,7 +247,7 @@ class ImageTest extends TestCase
         $this->asEditor();
         $galleryFile = $this->getTestImage('my-secure-test-upload.png');
         $page = Page::query()->first();
         $this->asEditor();
         $galleryFile = $this->getTestImage('my-secure-test-upload.png');
         $page = Page::query()->first();
-        $expectedPath = storage_path('uploads/images/gallery/' . Date('Y-m') . '/my-secure-test-upload.png');
+        $expectedPath = storage_path('uploads/images/gallery/' . date('Y-m') . '/my-secure-test-upload.png');
 
         $upload = $this->call('POST', '/images/gallery', ['uploaded_to' => $page->id], [], ['file' => $galleryFile], []);
         $imageUrl = json_decode($upload->getContent(), true)['url'];
 
         $upload = $this->call('POST', '/images/gallery', ['uploaded_to' => $page->id], [], ['file' => $galleryFile], []);
         $imageUrl = json_decode($upload->getContent(), true)['url'];
@@ -268,12 +269,12 @@ class ImageTest extends TestCase
         config()->set('filesystems.images', 'local_secure');
         $this->asAdmin();
         $galleryFile = $this->getTestImage('my-system-test-upload.png');
         config()->set('filesystems.images', 'local_secure');
         $this->asAdmin();
         $galleryFile = $this->getTestImage('my-system-test-upload.png');
-        $expectedPath = public_path('uploads/images/system/' . Date('Y-m') . '/my-system-test-upload.png');
+        $expectedPath = public_path('uploads/images/system/' . date('Y-m') . '/my-system-test-upload.png');
 
         $upload = $this->call('POST', '/settings', [], [], ['app_logo' => $galleryFile], []);
         $upload->assertRedirect('/settings');
 
 
         $upload = $this->call('POST', '/settings', [], [], ['app_logo' => $galleryFile], []);
         $upload->assertRedirect('/settings');
 
-        $this->assertTrue(file_exists($expectedPath), 'Uploaded image not found at path: '. $expectedPath);
+        $this->assertTrue(file_exists($expectedPath), 'Uploaded image not found at path: ' . $expectedPath);
 
         if (file_exists($expectedPath)) {
             unlink($expectedPath);
 
         if (file_exists($expectedPath)) {
             unlink($expectedPath);
@@ -291,12 +292,12 @@ class ImageTest extends TestCase
         $this->uploadImage($imageName, $page->id);
         $image = Image::first();
 
         $this->uploadImage($imageName, $page->id);
         $image = Image::first();
 
-        $delete = $this->delete( '/images/' . $image->id);
+        $delete = $this->delete('/images/' . $image->id);
         $delete->assertStatus(200);
 
         $this->assertDatabaseMissing('images', [
         $delete->assertStatus(200);
 
         $this->assertDatabaseMissing('images', [
-            'url' => $this->baseUrl . $relPath,
-            'type' => 'gallery'
+            'url'  => $this->baseUrl . $relPath,
+            'type' => 'gallery',
         ]);
 
         $this->assertFalse(file_exists(public_path($relPath)), 'Uploaded image has not been deleted as expected');
         ]);
 
         $this->assertFalse(file_exists(public_path($relPath)), 'Uploaded image has not been deleted as expected');
@@ -319,7 +320,7 @@ class ImageTest extends TestCase
         $folder = public_path(dirname($relPath));
         $imageCount = count(glob($folder . '/*'));
 
         $folder = public_path(dirname($relPath));
         $imageCount = count(glob($folder . '/*'));
 
-        $delete = $this->delete( '/images/' . $image->id);
+        $delete = $this->delete('/images/' . $image->id);
         $delete->assertStatus(200);
 
         $newCount = count(glob($folder . '/*'));
         $delete->assertStatus(200);
 
         $newCount = count(glob($folder . '/*'));
@@ -346,9 +347,9 @@ class ImageTest extends TestCase
         $this->call('PUT', '/settings/users/' . $editor->id, [], [], ['profile_image' => $file], []);
 
         $this->assertDatabaseHas('images', [
         $this->call('PUT', '/settings/users/' . $editor->id, [], [], ['profile_image' => $file], []);
 
         $this->assertDatabaseHas('images', [
-            'type' => 'user',
+            'type'        => 'user',
             'uploaded_to' => $editor->id,
             'uploaded_to' => $editor->id,
-            'created_by' => $admin->id,
+            'created_by'  => $admin->id,
         ]);
     }
 
         ]);
     }
 
@@ -361,7 +362,7 @@ class ImageTest extends TestCase
         $this->call('PUT', '/settings/users/' . $editor->id, [], [], ['profile_image' => $file], []);
 
         $profileImages = Image::where('type', '=', 'user')->where('created_by', '=', $editor->id)->get();
         $this->call('PUT', '/settings/users/' . $editor->id, [], [], ['profile_image' => $file], []);
 
         $profileImages = Image::where('type', '=', 'user')->where('created_by', '=', $editor->id)->get();
-        $this->assertTrue($profileImages->count() === 1, "Found profile images does not match upload count");
+        $this->assertTrue($profileImages->count() === 1, 'Found profile images does not match upload count');
 
         $imagePath = public_path($profileImages->first()->path);
         $this->assertTrue(file_exists($imagePath));
 
         $imagePath = public_path($profileImages->first()->path);
         $this->assertTrue(file_exists($imagePath));
@@ -370,12 +371,12 @@ class ImageTest extends TestCase
         $userDelete->assertStatus(302);
 
         $this->assertDatabaseMissing('images', [
         $userDelete->assertStatus(302);
 
         $this->assertDatabaseMissing('images', [
-            'type' => 'user',
-            'created_by' => $editor->id
+            'type'       => 'user',
+            'created_by' => $editor->id,
         ]);
         $this->assertDatabaseMissing('images', [
         ]);
         $this->assertDatabaseMissing('images', [
-            'type' => 'user',
-            'uploaded_to' => $editor->id
+            'type'        => 'user',
+            'uploaded_to' => $editor->id,
         ]);
 
         $this->assertFalse(file_exists($imagePath));
         ]);
 
         $this->assertFalse(file_exists($imagePath));
@@ -397,9 +398,9 @@ class ImageTest extends TestCase
 
         $pageRepo = app(PageRepo::class);
         $pageRepo->update($page, [
 
         $pageRepo = app(PageRepo::class);
         $pageRepo->update($page, [
-            'name' => $page->name,
-            'html' => $page->html . "<img src=\"{$image->url}\">",
-            'summary' => ''
+            'name'    => $page->name,
+            'html'    => $page->html . "<img src=\"{$image->url}\">",
+            'summary' => '',
         ]);
 
         // Ensure no images are reported as deletable
         ]);
 
         // Ensure no images are reported as deletable
@@ -409,9 +410,9 @@ class ImageTest extends TestCase
 
         // Save a revision of our page without the image;
         $pageRepo->update($page, [
 
         // Save a revision of our page without the image;
         $pageRepo->update($page, [
-            'name' => $page->name,
-            'html' => "<p>Hello</p>",
-            'summary' => ''
+            'name'    => $page->name,
+            'html'    => '<p>Hello</p>',
+            'summary' => '',
         ]);
 
         // Ensure revision images are picked up okay
         ]);
 
         // Ensure revision images are picked up okay
@@ -435,5 +436,4 @@ class ImageTest extends TestCase
 
         $this->deleteImage($relPath);
     }
 
         $this->deleteImage($relPath);
     }
-
 }
 }
index 24c253802f23dd72ccc2d4252ba79334b2a105c2..789c967c6771c6938bf0f51491c9b6ee5677b243 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests\Uploads;
+<?php
+
+namespace Tests\Uploads;
 
 use BookStack\Entities\Models\Page;
 use Illuminate\Http\UploadedFile;
 
 use BookStack\Entities\Models\Page;
 use Illuminate\Http\UploadedFile;
@@ -29,11 +31,12 @@ trait UsesImages
         $data = file_get_contents($base64FilePath);
         $decoded = base64_decode($data);
         file_put_contents($imagePath, $decoded);
         $data = file_get_contents($base64FilePath);
         $decoded = base64_decode($data);
         file_put_contents($imagePath, $decoded);
+
         return new UploadedFile($imagePath, $imageFileName, 'image/png', null, true);
     }
 
     /**
         return new UploadedFile($imagePath, $imageFileName, 'image/png', null, true);
     }
 
     /**
-     * Get a test image that can be uploaded
+     * Get a test image that can be uploaded.
      */
     protected function getTestImage(string $fileName, ?string $testDataFileName = null): UploadedFile
     {
      */
     protected function getTestImage(string $fileName, ?string $testDataFileName = null): UploadedFile
     {
@@ -42,6 +45,7 @@ trait UsesImages
 
     /**
      * Get the raw file data for the test image.
 
     /**
      * Get the raw file data for the test image.
+     *
      * @return false|string
      */
     protected function getTestImageContent()
      * @return false|string
      */
     protected function getTestImageContent()
@@ -54,19 +58,22 @@ trait UsesImages
      */
     protected function getTestImagePath(string $type, string $fileName): string
     {
      */
     protected function getTestImagePath(string $type, string $fileName): string
     {
-        return '/uploads/images/' . $type . '/' . Date('Y-m') . '/' . $fileName;
+        return '/uploads/images/' . $type . '/' . date('Y-m') . '/' . $fileName;
     }
 
     /**
      * Uploads an image with the given name.
     }
 
     /**
      * Uploads an image with the given name.
+     *
      * @param $name
      * @param $name
-     * @param int $uploadedTo
+     * @param int    $uploadedTo
      * @param string $contentType
      * @param string $contentType
+     *
      * @return \Illuminate\Foundation\Testing\TestResponse
      */
     protected function uploadImage($name, $uploadedTo = 0, $contentType = 'image/png', ?string $testDataFileName = null)
     {
         $file = $this->getTestImage($name, $testDataFileName);
      * @return \Illuminate\Foundation\Testing\TestResponse
      */
     protected function uploadImage($name, $uploadedTo = 0, $contentType = 'image/png', ?string $testDataFileName = null)
     {
         $file = $this->getTestImage($name, $testDataFileName);
+
         return $this->withHeader('Content-Type', $contentType)
             ->call('POST', '/images/gallery', ['uploaded_to' => $uploadedTo], [], ['file' => $file], []);
     }
         return $this->withHeader('Content-Type', $contentType)
             ->call('POST', '/images/gallery', ['uploaded_to' => $uploadedTo], [], ['file' => $file], []);
     }
@@ -75,7 +82,9 @@ trait UsesImages
      * Upload a new gallery image.
      * Returns the image name.
      * Can provide a page to relate the image to.
      * Upload a new gallery image.
      * Returns the image name.
      * Can provide a page to relate the image to.
+     *
      * @param Page|null $page
      * @param Page|null $page
+     *
      * @return array
      */
     protected function uploadGalleryImage(Page $page = null, ?string $testDataFileName = null)
      * @return array
      */
     protected function uploadGalleryImage(Page $page = null, ?string $testDataFileName = null)
@@ -90,10 +99,11 @@ trait UsesImages
 
         $upload = $this->uploadImage($imageName, $page->id, 'image/png', $testDataFileName);
         $upload->assertStatus(200);
 
         $upload = $this->uploadImage($imageName, $page->id, 'image/png', $testDataFileName);
         $upload->assertStatus(200);
+
         return [
         return [
-            'name' => $imageName,
-            'path' => $relPath,
-            'page' => $page,
+            'name'     => $imageName,
+            'path'     => $relPath,
+            'page'     => $page,
             'response' => json_decode($upload->getContent()),
         ];
     }
             'response' => json_decode($upload->getContent()),
         ];
     }
@@ -108,5 +118,4 @@ trait UsesImages
             unlink($path);
         }
     }
             unlink($path);
         }
     }
-
-}
\ No newline at end of file
+}
index df686dd77df953423a103d8caa57313539dd832e..d3404b72ef14a11e21af96408d190b2d88f544f3 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests\User;
+<?php
+
+namespace Tests\User;
 
 use BookStack\Actions\ActivityType;
 use BookStack\Api\ApiToken;
 
 use BookStack\Actions\ActivityType;
 use BookStack\Api\ApiToken;
@@ -7,9 +9,8 @@ use Tests\TestCase;
 
 class UserApiTokenTest extends TestCase
 {
 
 class UserApiTokenTest extends TestCase
 {
-
     protected $testTokenData = [
     protected $testTokenData = [
-        'name' => 'My test API token',
+        'name'       => 'My test API token',
         'expires_at' => '2050-04-01',
     ];
 
         'expires_at' => '2050-04-01',
     ];
 
@@ -51,8 +52,8 @@ class UserApiTokenTest extends TestCase
         $token = ApiToken::query()->latest()->first();
         $resp->assertRedirect($editor->getEditUrl('/api-tokens/' . $token->id));
         $this->assertDatabaseHas('api_tokens', [
         $token = ApiToken::query()->latest()->first();
         $resp->assertRedirect($editor->getEditUrl('/api-tokens/' . $token->id));
         $this->assertDatabaseHas('api_tokens', [
-            'user_id' => $editor->id,
-            'name' => $this->testTokenData['name'],
+            'user_id'    => $editor->id,
+            'name'       => $this->testTokenData['name'],
             'expires_at' => $this->testTokenData['expires_at'],
         ]);
 
             'expires_at' => $this->testTokenData['expires_at'],
         ]);
 
@@ -81,7 +82,7 @@ class UserApiTokenTest extends TestCase
         $under = Carbon::now()->addYears(99);
         $this->assertTrue(
             ($token->expires_at < $over && $token->expires_at > $under),
         $under = Carbon::now()->addYears(99);
         $this->assertTrue(
             ($token->expires_at < $over && $token->expires_at > $under),
-            "Token expiry set at 100 years in future"
+            'Token expiry set at 100 years in future'
         );
     }
 
         );
     }
 
@@ -117,7 +118,7 @@ class UserApiTokenTest extends TestCase
         $this->asAdmin()->post($editor->getEditUrl('/create-api-token'), $this->testTokenData);
         $token = ApiToken::query()->latest()->first();
         $updateData = [
         $this->asAdmin()->post($editor->getEditUrl('/create-api-token'), $this->testTokenData);
         $token = ApiToken::query()->latest()->first();
         $updateData = [
-            'name' => 'My updated token',
+            'name'       => 'My updated token',
             'expires_at' => '2011-01-01',
         ];
 
             'expires_at' => '2011-01-01',
         ];
 
@@ -136,7 +137,7 @@ class UserApiTokenTest extends TestCase
         $token = ApiToken::query()->latest()->first();
 
         $resp = $this->put($editor->getEditUrl('/api-tokens/' . $token->id), [
         $token = ApiToken::query()->latest()->first();
 
         $resp = $this->put($editor->getEditUrl('/api-tokens/' . $token->id), [
-            'name' => 'My updated token',
+            'name'       => 'My updated token',
             'expires_at' => '',
         ]);
         $token->refresh();
             'expires_at' => '',
         ]);
         $token->refresh();
@@ -145,7 +146,7 @@ class UserApiTokenTest extends TestCase
         $under = Carbon::now()->addYears(99);
         $this->assertTrue(
             ($token->expires_at < $over && $token->expires_at > $under),
         $under = Carbon::now()->addYears(99);
         $this->assertTrue(
             ($token->expires_at < $over && $token->expires_at > $under),
-            "Token expiry set at 100 years in future"
+            'Token expiry set at 100 years in future'
         );
     }
 
         );
     }
 
@@ -160,7 +161,7 @@ class UserApiTokenTest extends TestCase
         $resp = $this->get($tokenUrl . '/delete');
         $resp->assertSeeText('Delete Token');
         $resp->assertSeeText($token->name);
         $resp = $this->get($tokenUrl . '/delete');
         $resp->assertSeeText('Delete Token');
         $resp->assertSeeText($token->name);
-        $resp->assertElementExists('form[action="'.$tokenUrl.'"]');
+        $resp->assertElementExists('form[action="' . $tokenUrl . '"]');
 
         $resp = $this->delete($tokenUrl);
         $resp->assertRedirect($editor->getEditUrl('#api_tokens'));
 
         $resp = $this->delete($tokenUrl);
         $resp->assertRedirect($editor->getEditUrl('#api_tokens'));
@@ -185,5 +186,4 @@ class UserApiTokenTest extends TestCase
         $resp->assertRedirect($viewer->getEditUrl('#api_tokens'));
         $this->assertDatabaseMissing('api_tokens', ['id' => $token->id]);
     }
         $resp->assertRedirect($viewer->getEditUrl('#api_tokens'));
         $this->assertDatabaseMissing('api_tokens', ['id' => $token->id]);
     }
-
-}
\ No newline at end of file
+}
index d99d61401e19e0385a07a6ec16e90d8e25a87bc7..4fd7bacc7dc465fd648e6c25d64efd8284547d7b 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests\User;
+<?php
+
+namespace Tests\User;
 
 use BookStack\Actions\ActivityType;
 use BookStack\Auth\User;
 
 use BookStack\Actions\ActivityType;
 use BookStack\Auth\User;
@@ -7,15 +9,14 @@ use Tests\TestCase;
 
 class UserManagementTest extends TestCase
 {
 
 class UserManagementTest extends TestCase
 {
-
     public function test_delete()
     {
         $editor = $this->getEditor();
         $resp = $this->asAdmin()->delete("settings/users/{$editor->id}");
     public function test_delete()
     {
         $editor = $this->getEditor();
         $resp = $this->asAdmin()->delete("settings/users/{$editor->id}");
-        $resp->assertRedirect("/settings/users");
+        $resp->assertRedirect('/settings/users');
         $resp = $this->followRedirects($resp);
 
         $resp = $this->followRedirects($resp);
 
-        $resp->assertSee("User successfully removed");
+        $resp->assertSee('User successfully removed');
         $this->assertActivityExists(ActivityType::USER_DELETE);
 
         $this->assertDatabaseMissing('users', ['id' => $editor->id]);
         $this->assertActivityExists(ActivityType::USER_DELETE);
 
         $this->assertDatabaseMissing('users', ['id' => $editor->id]);
@@ -25,20 +26,20 @@ class UserManagementTest extends TestCase
     {
         $editor = $this->getEditor();
         $resp = $this->asAdmin()->get("settings/users/{$editor->id}/delete");
     {
         $editor = $this->getEditor();
         $resp = $this->asAdmin()->get("settings/users/{$editor->id}/delete");
-        $resp->assertSee("Migrate Ownership");
-        $resp->assertSee("new_owner_id");
+        $resp->assertSee('Migrate Ownership');
+        $resp->assertSee('new_owner_id');
     }
 
     public function test_delete_with_new_owner_id_changes_ownership()
     {
         $page = Page::query()->first();
         $owner = $page->ownedBy;
     }
 
     public function test_delete_with_new_owner_id_changes_ownership()
     {
         $page = Page::query()->first();
         $owner = $page->ownedBy;
-        $newOwner = User::query()->where('id', '!=' , $owner->id)->first();
+        $newOwner = User::query()->where('id', '!=', $owner->id)->first();
 
         $this->asAdmin()->delete("settings/users/{$owner->id}", ['new_owner_id' => $newOwner->id]);
         $this->assertDatabaseHas('pages', [
 
         $this->asAdmin()->delete("settings/users/{$owner->id}", ['new_owner_id' => $newOwner->id]);
         $this->assertDatabaseHas('pages', [
-            'id' => $page->id,
+            'id'       => $page->id,
             'owned_by' => $newOwner->id,
         ]);
     }
             'owned_by' => $newOwner->id,
         ]);
     }
-}
\ No newline at end of file
+}
index 49c49188b2451f0b74cf017210f0b5baafd23f80..1d5d3e7297ef29b2c58a6d117a4a461324fc45db 100644 (file)
@@ -1,28 +1,29 @@
-<?php namespace Tests\User;
+<?php
+
+namespace Tests\User;
 
 use Tests\TestCase;
 
 class UserPreferencesTest extends TestCase
 {
 
 use Tests\TestCase;
 
 class UserPreferencesTest extends TestCase
 {
-
     public function test_update_sort_preference()
     {
         $editor = $this->getEditor();
         $this->actingAs($editor);
 
     public function test_update_sort_preference()
     {
         $editor = $this->getEditor();
         $this->actingAs($editor);
 
-        $updateRequest = $this->patch('/settings/users/' . $editor->id.'/change-sort/books', [
-            'sort' => 'created_at',
-            'order' => 'desc'
+        $updateRequest = $this->patch('/settings/users/' . $editor->id . '/change-sort/books', [
+            'sort'  => 'created_at',
+            'order' => 'desc',
         ]);
         $updateRequest->assertStatus(302);
 
         $this->assertDatabaseHas('settings', [
             'setting_key' => 'user:' . $editor->id . ':books_sort',
         ]);
         $updateRequest->assertStatus(302);
 
         $this->assertDatabaseHas('settings', [
             'setting_key' => 'user:' . $editor->id . ':books_sort',
-            'value' => 'created_at'
+            'value'       => 'created_at',
         ]);
         $this->assertDatabaseHas('settings', [
             'setting_key' => 'user:' . $editor->id . ':books_sort_order',
         ]);
         $this->assertDatabaseHas('settings', [
             'setting_key' => 'user:' . $editor->id . ':books_sort_order',
-            'value' => 'desc'
+            'value'       => 'desc',
         ]);
         $this->assertEquals('created_at', setting()->getForCurrentUser('books_sort'));
         $this->assertEquals('desc', setting()->getForCurrentUser('books_sort_order'));
         ]);
         $this->assertEquals('created_at', setting()->getForCurrentUser('books_sort'));
         $this->assertEquals('desc', setting()->getForCurrentUser('books_sort_order'));
@@ -33,9 +34,9 @@ class UserPreferencesTest extends TestCase
         $editor = $this->getEditor();
         $this->actingAs($editor);
 
         $editor = $this->getEditor();
         $this->actingAs($editor);
 
-        $updateRequest = $this->patch('/settings/users/' . $editor->id.'/change-sort/bookshelves', [
-            'sort' => 'cat',
-            'order' => 'dog'
+        $updateRequest = $this->patch('/settings/users/' . $editor->id . '/change-sort/bookshelves', [
+            'sort'  => 'cat',
+            'order' => 'dog',
         ]);
         $updateRequest->assertStatus(302);
 
         ]);
         $updateRequest->assertStatus(302);
 
@@ -48,9 +49,9 @@ class UserPreferencesTest extends TestCase
         $editor = $this->getEditor();
         $this->actingAs($editor);
 
         $editor = $this->getEditor();
         $this->actingAs($editor);
 
-        $updateRequest = $this->patch('/settings/users/' . $editor->id.'/change-sort/dogs', [
-            'sort' => 'name',
-            'order' => 'asc'
+        $updateRequest = $this->patch('/settings/users/' . $editor->id . '/change-sort/dogs', [
+            'sort'  => 'name',
+            'order' => 'asc',
         ]);
         $updateRequest->assertStatus(500);
 
         ]);
         $updateRequest->assertStatus(500);
 
@@ -63,16 +64,16 @@ class UserPreferencesTest extends TestCase
         $editor = $this->getEditor();
         $this->actingAs($editor);
 
         $editor = $this->getEditor();
         $this->actingAs($editor);
 
-        $updateRequest = $this->patch('/settings/users/' . $editor->id.'/update-expansion-preference/home-details', ['expand' => 'true']);
+        $updateRequest = $this->patch('/settings/users/' . $editor->id . '/update-expansion-preference/home-details', ['expand' => 'true']);
         $updateRequest->assertStatus(204);
 
         $this->assertDatabaseHas('settings', [
             'setting_key' => 'user:' . $editor->id . ':section_expansion#home-details',
         $updateRequest->assertStatus(204);
 
         $this->assertDatabaseHas('settings', [
             'setting_key' => 'user:' . $editor->id . ':section_expansion#home-details',
-            'value' => 'true'
+            'value'       => 'true',
         ]);
         $this->assertEquals(true, setting()->getForCurrentUser('section_expansion#home-details'));
 
         ]);
         $this->assertEquals(true, setting()->getForCurrentUser('section_expansion#home-details'));
 
-        $invalidKeyRequest = $this->patch('/settings/users/' . $editor->id.'/update-expansion-preference/my-home-details', ['expand' => 'true']);
+        $invalidKeyRequest = $this->patch('/settings/users/' . $editor->id . '/update-expansion-preference/my-home-details', ['expand' => 'true']);
         $invalidKeyRequest->assertStatus(500);
     }
 
         $invalidKeyRequest->assertStatus(500);
     }
 
@@ -105,4 +106,4 @@ class UserPreferencesTest extends TestCase
         $home = $this->get('/login');
         $home->assertElementExists('.dark-mode');
     }
         $home = $this->get('/login');
         $home->assertElementExists('.dark-mode');
     }
-}
\ No newline at end of file
+}
index a5db83c48e78816ed4af15402f8c5185209272b5..e2bd59a47375248a6c21d7844b561524ce426352 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests\User;
+<?php
+
+namespace Tests\User;
 
 use Activity;
 use BookStack\Actions\ActivityType;
 
 use Activity;
 use BookStack\Actions\ActivityType;
@@ -141,5 +143,4 @@ class UserProfileTest extends BrowserKitTest
             ->pageNotHasElement('.content-wrap .entity-list-item')
             ->see('List View');
     }
             ->pageNotHasElement('.content-wrap .entity-list-item')
             ->see('List View');
     }
-
 }
 }