repo
stringlengths
7
63
file_url
stringlengths
81
284
file_path
stringlengths
5
200
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:02:33
2026-01-05 05:24:06
truncated
bool
2 classes
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/lang/et/preferences.php
lang/et/preferences.php
<?php /** * Text used for user-preference specific views within bookstack. */ return [ 'my_account' => 'Minu konto', 'shortcuts' => 'Kiirklahvid', 'shortcuts_interface' => 'Kasutajaliidese eelistused', 'shortcuts_toggle_desc' => 'Siit saad sisse ja välja lülitada navigeerimiseks ja tegevusteks kasutatavad kiirklahvid.', 'shortcuts_customize_desc' => 'Allpool saad iga kiirklahvi kohandada. Pärast kiirklahvile vastava tekstivälja valimist vajuta lihtsalt soovitud klahvikombinatsiooni.', 'shortcuts_toggle_label' => 'Kiirklahvid sisse lülitatud', 'shortcuts_section_navigation' => 'Navigatsioon', 'shortcuts_section_actions' => 'Sagedased tegevused', 'shortcuts_save' => 'Salvesta kiirklahvid', 'shortcuts_overlay_desc' => 'Märkus: Kui kiirklahvid on sisse lülitatud, saab "?" vajutades kuvada abiinfo, mis märgib ära kõigi hetkel ekraanil nähtavate tegevuste kiirklahvid.', 'shortcuts_update_success' => 'Kiirklahvide eelistused on salvestatud!', 'shortcuts_overview_desc' => 'Halda klaviatuuri kiirklahve süsteemi kasutajaliideses navigeerimiseks.', 'notifications' => 'Teavituste eelistused', 'notifications_desc' => 'Halda e-posti teavitusi, mis saadetakse teatud tegevuste puhul.', 'notifications_opt_own_page_changes' => 'Teavita muudatustest minu lehtedel', 'notifications_opt_own_page_comments' => 'Teavita kommentaaridest minu lehtedel', 'notifications_opt_comment_mentions' => 'Teavita mind, kui mind kommentaaris mainitakse', 'notifications_opt_comment_replies' => 'Teavita vastustest minu kommentaaridele', 'notifications_save' => 'Salvesta eelistused', 'notifications_update_success' => 'Teavituste eelistused on salvestatud!', 'notifications_watched' => 'Jälgitud ja ignoreeritud objektid', 'notifications_watched_desc' => 'Allpool on objektid, millele on määratud kohaldatud jälgimise eelistused. Eelistuste muutmiseks ava vastav objekt ning leia jälgimise valikud külgmenüüs.', 'auth' => 'Ligipääs ja turvalisus', 'auth_change_password' => 'Muuda parool', 'auth_change_password_desc' => 'Muuda parooli, millega rakendusse sisse logid. See peab olema vähemalt 8 tähemärki.', 'auth_change_password_success' => 'Parool on muudetud!', 'profile' => 'Profiili detailid', 'profile_desc' => 'Halda oma konto andmeid, mis sind teistele kasutajatele esindab, lisaks andmetele, mida kasutatakse suhtluseks ja süsteemi kohaldamiseks.', 'profile_view_public' => 'Vaata avalikku profiili', 'profile_name_desc' => 'Seadista oma avalik nimi, mis on nähtav teistele kasutajatele sinu tehtud tegevuste ja sulle kuuluva sisu kaudu.', 'profile_email_desc' => 'Seda e-posti aadressi kasutatakse teavituste saatmiseks ning, sõltuvalt aktiivsest autentimismeetodist, süsteemile ligipääsemiseks.', 'profile_email_no_permission' => 'Kahjuks ei ole sul luba oma e-posti aadressi muuta. Kui soovid seda muuta, pead administraatoriga ühendust võtma.', 'profile_avatar_desc' => 'Vali pilt, mis sind süsteemis teistele kasutajatele esindab. Ideaalis peaks see pilt olema ruudukujuline ning 256px kõrge ja lai.', 'profile_admin_options' => 'Administraatori valikud', 'profile_admin_options_desc' => 'Täiendavad administraatori-taseme valikud, näiteks rollide haldamiseks, on rakenduse "Seaded > Kasutajad" all sinu kasutajakonto vaates.', 'delete_account' => 'Kustuta konto', 'delete_my_account' => 'Kustuta minu konto', 'delete_my_account_desc' => 'See kustutab su kasutajakonto süsteemist. Sa ei saa kontot taastada ega seda tegevust tagasi võtta. Sinu loodud sisu, näiteks lisatud lehed ja üleslaaditud pildid, jäävad alles.', 'delete_my_account_warning' => 'Kas oled kindel, et soovid oma konto kustutada?', ];
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/lang/et/errors.php
lang/et/errors.php
<?php /** * Text shown in error messaging. */ return [ // Permissions 'permission' => 'Sul puudub õigus selle lehe vaatamiseks.', 'permissionJson' => 'Sul puudub õigus selle tegevuse teostamiseks.', // Auth 'error_user_exists_different_creds' => 'See e-posti aadress on juba seotud teise kasutajaga.', 'auth_pre_register_theme_prevention' => 'Etteantud detailidega kasutajakontot ei õnnestunud registreerida', 'email_already_confirmed' => 'E-posti aadress on juba kinnitatud. Proovi sisse logida.', 'email_confirmation_invalid' => 'Kinnituslink ei ole kehtiv või on seda juba kasutatud. Proovi uuesti registreeruda.', 'email_confirmation_expired' => 'Kinnituslink on aegunud. Sulle saadeti aadressi kinnitamiseks uus e-kiri.', 'email_confirmation_awaiting' => 'Selle kasutajakonto e-posti aadress vajab kinnitamist', 'ldap_fail_anonymous' => 'LDAP anonüümne ligipääs ebaõnnestus', 'ldap_fail_authed' => 'LDAP ligipääs antud nime ja parooliga ebaõnnestus', 'ldap_extension_not_installed' => 'PHP LDAP laiendus ei ole paigaldatud', 'ldap_cannot_connect' => 'Ühendus LDAP serveriga ebaõnnestus', 'saml_already_logged_in' => 'Juba sisse logitud', 'saml_no_email_address' => 'Selle kasutaja e-posti aadressi ei õnnestunud välisest autentimissüsteemist leida', 'saml_invalid_response_id' => 'Välisest autentimissüsteemist tulnud päringut ei algatatud sellest rakendusest. Seda viga võib põhjustada pärast sisselogimist tagasi liikumine.', 'saml_fail_authed' => 'Sisenemine :system kaudu ebaõnnestus, süsteem ei andnud volitust', 'oidc_already_logged_in' => 'Juba sisse logitud', 'oidc_no_email_address' => 'Selle kasutaja e-posti aadressi ei õnnestunud välisest autentimissüsteemist leida', 'oidc_fail_authed' => 'Sisenemine :system kaudu ebaõnnestus, süsteem ei andnud volitust', 'social_no_action_defined' => 'Tegevus on defineerimata', 'social_login_bad_response' => ":socialAccount kaudu sisselogimisel tekkis viga: \n:error", 'social_account_in_use' => 'See :socialAccount konto on juba kasutusel, proovi :socialAccount kaudu sisse logida.', 'social_account_email_in_use' => 'E-posti aadress :email on juba kasutusel. Kui sul on juba kasutajakonto, saad oma :socialAccount konto siduda profiili seadetes.', 'social_account_existing' => 'See :socialAccount konto on juba seotud su profiiliga.', 'social_account_already_used_existing' => 'See :socialAccount konto on juba seotud teise kasutajaga.', 'social_account_not_used' => 'See :socialAccount konto ei ole seotud ühegi kasutajaga. Seosta see oma profiili seadetes. ', 'social_account_register_instructions' => 'Kui sul pole veel kasutajakontot, saad selle registreerida :socialAccount kaudu.', 'social_driver_not_found' => 'Sotsiaalmeedia kontode draiverit ei leitud', 'social_driver_not_configured' => 'Sinu :socialAccount konto seaded ei ole korrektsed.', 'invite_token_expired' => 'Link on aegunud. Võid selle asemel proovida oma konto parooli lähtestada.', 'login_user_not_found' => 'Selle tegevuse jaoks ei leitud kasutajat.', // System 'path_not_writable' => 'Faili asukohaga :filePath ei õnnestunud üles laadida. Veendu, et serveril on kirjutusõigused.', 'cannot_get_image_from_url' => 'Ei suutnud laadida pilti aadressilt :url', 'cannot_create_thumbs' => 'Server ei saa piltide eelvaateid tekitada. Veendu, et PHP GD laiendus on paigaldatud.', 'server_upload_limit' => 'Server ei luba nii suurte failide üleslaadimist. Proovi väiksema failiga.', 'server_post_limit' => 'Server ei saa etteantud andmemahtu vastu võtta. Proovi uuesti väiksema failiga.', 'uploaded' => 'Server ei luba nii suurte failide üleslaadimist. Proovi väiksema failiga.', // Drawing & Images 'image_upload_error' => 'Pildi üleslaadimisel tekkis viga', 'image_upload_type_error' => 'Pildifaili tüüp ei ole korrektne', 'image_upload_replace_type' => 'Pildifaili asendused peavad olema sama tüüpi', 'image_upload_memory_limit' => 'Pildi üleslaadimine ja/või eelvaadete tekitamine ebaõnnestus süsteemsete ressursipiirangute tõttu.', 'image_thumbnail_memory_limit' => 'Pildi eelvaadete tekitamine ebaõnnestus süsteemsete ressursipiirangute tõttu.', 'image_gallery_thumbnail_memory_limit' => 'Galerii eelvaadete tekitamine ebaõnnestus süsteemsete ressursipiirangute tõttu.', 'drawing_data_not_found' => 'Joonise andmeid ei õnnestunud laadida. Joonist ei pruugi enam eksisteerida, või sul puuduvad õigused selle vaatamiseks.', // Attachments 'attachment_not_found' => 'Manust ei leitud', 'attachment_upload_error' => 'Manuse faili üleslaadimisel tekkis viga', // Pages 'page_draft_autosave_fail' => 'Mustandi salvestamine ebaõnnestus. Kontrolli oma internetiühendust', 'page_draft_delete_fail' => 'Mustandi kustutamine ja lehe salvestatud seisu laadimine ebaõnnestus', 'page_custom_home_deletion' => 'Ei saa kustutada lehte, mis on määratud avaleheks', // Entities 'entity_not_found' => 'Objekti ei leitud', 'bookshelf_not_found' => 'Riiulit ei leitud', 'book_not_found' => 'Raamatut ei leitud', 'page_not_found' => 'Lehte ei leitud', 'chapter_not_found' => 'Peatükki ei leitud', 'selected_book_not_found' => 'Valitud raamatut ei leitud', 'selected_book_chapter_not_found' => 'Valitud raamatut või peatükki ei leitud', 'guests_cannot_save_drafts' => 'Külalised ei saa mustandeid salvestada', // Users 'users_cannot_delete_only_admin' => 'Ainsat administraatorit ei saa kustutada', 'users_cannot_delete_guest' => 'Külaliskasutajat ei saa kustutada', 'users_could_not_send_invite' => 'Kasutajat ei õnnestunud luua, kuna kutse e-kirja saatmine ebaõnnestus', // Roles 'role_cannot_be_edited' => 'Seda rolli ei saa muuta', 'role_system_cannot_be_deleted' => 'See roll on süsteemne ja seda ei saa kustutada', 'role_registration_default_cannot_delete' => 'Seda rolli ei saa kustutada, kuna see on seatud uute kasutajate vaikimisi rolliks', 'role_cannot_remove_only_admin' => 'See kasutaja on ainus, kellel on administraatori roll. Enne kustutamist lisa administraatori roll mõnele teisele kasutajale.', // Comments 'comment_list' => 'Kommentaaride pärimisel tekkis viga.', 'cannot_add_comment_to_draft' => 'Mustandile ei saa kommentaare lisada.', 'comment_add' => 'Kommentaari lisamisel / muutmisel tekkis viga.', 'comment_delete' => 'Kommentaari kustutamisel tekkis viga.', 'empty_comment' => 'Tühja kommentaari ei saa lisada.', // Error pages '404_page_not_found' => 'Lehekülge ei leitud', 'sorry_page_not_found' => 'Vabandust, soovitud lehekülge ei leitud.', 'sorry_page_not_found_permission_warning' => 'Kui see lehekülg peaks kindlalt olemas olema, ei pruugi sul olla õigust selle vaatamiseks.', 'image_not_found' => 'Pildifaili ei leitud', 'image_not_found_subtitle' => 'Vabandust, soovitud pildifaili ei leitud.', 'image_not_found_details' => 'Kui sa eeldasid, et see pildifail on olemas, võib see olla kustutatud.', 'return_home' => 'Tagasi avalehele', 'error_occurred' => 'Tekkis viga', 'app_down' => ':appName on hetkel maas', 'back_soon' => 'See on varsti tagasi.', // Import 'import_zip_cant_read' => 'ZIP-faili lugemine ebaõnnestus.', 'import_zip_cant_decode_data' => 'ZIP-failist ei leitud data.json sisu.', 'import_zip_no_data' => 'ZIP-failist ei leitud raamatute, peatükkide või lehtede sisu.', 'import_zip_data_too_large' => 'ZIP data.json content exceeds the configured application maximum upload size.', 'import_validation_failed' => 'Imporditud ZIP-faili valideerimine ebaõnnestus vigadega:', 'import_zip_failed_notification' => 'ZIP-faili importimine ebaõnnestus.', 'import_perms_books' => 'Sul puuduvad õigused raamatute lisamiseks.', 'import_perms_chapters' => 'Sul puuduvad õigused peatükkide lisamiseks.', 'import_perms_pages' => 'Sul puuduvad õigused lehtede lisamiseks.', 'import_perms_images' => 'Sul puuduvad õigused piltide lisamiseks.', 'import_perms_attachments' => 'Sul puuduvad õigused manuste lisamiseks.', // API errors 'api_no_authorization_found' => 'Päringust ei leitud volitustunnust', 'api_bad_authorization_format' => 'Päringust leiti volitustunnus, aga see ei olnud korrektses formaadis', 'api_user_token_not_found' => 'Volitustunnusele vastavat API tunnust ei leitud', 'api_incorrect_token_secret' => 'API tunnusele lisatud salajane võti ei ole korrektne', 'api_user_no_api_permission' => 'Selle API tunnuse omanikul ei ole õigust API päringuid teha', 'api_user_token_expired' => 'Volitustunnus on aegunud', // Settings & Maintenance 'maintenance_test_email_failure' => 'Test e-kirja saatmisel tekkis viga:', // HTTP errors 'http_ssr_url_no_match' => 'URL ei klapi ühegi lubatud SSR hostiga', ];
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/lang/et/activities.php
lang/et/activities.php
<?php /** * Activity text strings. * Is used for all the text within activity logs & notifications. */ return [ // Pages 'page_create' => 'lisas lehe', 'page_create_notification' => 'Leht on lisatud', 'page_update' => 'muutis lehte', 'page_update_notification' => 'Leht on muudetud', 'page_delete' => 'kustutas lehe', 'page_delete_notification' => 'Leht on kustutatud', 'page_restore' => 'taastas lehe', 'page_restore_notification' => 'Leht on taastatud', 'page_move' => 'liigutas lehte', 'page_move_notification' => 'Leht on liigutatud', // Chapters 'chapter_create' => 'lisas peatüki', 'chapter_create_notification' => 'Peatükk on lisatud', 'chapter_update' => 'muutis peatükki', 'chapter_update_notification' => 'Peatükk on muudetud', 'chapter_delete' => 'kustutas peatüki', 'chapter_delete_notification' => 'Peatükk on kustutatud', 'chapter_move' => 'liigutas peatükki', 'chapter_move_notification' => 'Peatükk on liigutatud', // Books 'book_create' => 'lisas raamatu', 'book_create_notification' => 'Raamat on lisatud', 'book_create_from_chapter' => 'muutis peatüki raamatuks', 'book_create_from_chapter_notification' => 'Peatükk on muudetud raamatuks', 'book_update' => 'muutis raamatut', 'book_update_notification' => 'Raamat on muudetud', 'book_delete' => 'kustutas raamatu', 'book_delete_notification' => 'Raamat on kustutatud', 'book_sort' => 'sorteeris raamatut', 'book_sort_notification' => 'Raamat on sorteeritud', // Bookshelves 'bookshelf_create' => 'lisas riiuli', 'bookshelf_create_notification' => 'Riiul on lisatud', 'bookshelf_create_from_book' => 'muutis raamatu riiuliks', 'bookshelf_create_from_book_notification' => 'Raamat on muudetud riiuliks', 'bookshelf_update' => 'muutis riiulit', 'bookshelf_update_notification' => 'Riiul on muudetud', 'bookshelf_delete' => 'kustutas riiuli', 'bookshelf_delete_notification' => 'Riiul on kustutatud', // Revisions 'revision_restore' => 'taastas redaktsiooni', 'revision_delete' => 'kustutas redaktsiooni', 'revision_delete_notification' => 'Redaktsioon on kustutatud', // Favourites 'favourite_add_notification' => '":name" lisati su lemmikute hulka', 'favourite_remove_notification' => '":name" eemaldati su lemmikute hulgast', // Watching 'watch_update_level_notification' => 'Jälgimise eelistused edukalt salvestatud', // Auth 'auth_login' => 'logis sisse', 'auth_register' => 'registreerus uue kasutajana', 'auth_password_reset_request' => 'soovis parooli lähtestamist', 'auth_password_reset_update' => 'lähtestas kasutaja parooli', 'mfa_setup_method' => 'seadistas mitmeastmelise autentimise meetodi', 'mfa_setup_method_notification' => 'Mitmeastmeline autentimine seadistatud', 'mfa_remove_method' => 'eemaldas mitmeastmelise autentimise meetodi', 'mfa_remove_method_notification' => 'Mitmeastmeline autentimine eemaldatud', // Settings 'settings_update' => 'uuendas seadeid', 'settings_update_notification' => 'Seaded uuendatud', 'maintenance_action_run' => 'käivitas hooldustegevuse', // Webhooks 'webhook_create' => 'lisas veebihaagi', 'webhook_create_notification' => 'Veebihaak on lisatud', 'webhook_update' => 'muutis veebihaaki', 'webhook_update_notification' => 'Veebihaak on muudetud', 'webhook_delete' => 'kustutas veebihaagi', 'webhook_delete_notification' => 'Veebihaak on kustutatud', // Imports 'import_create' => 'lisas impordi', 'import_create_notification' => 'Import on üles laaditud', 'import_run' => 'muutis importi', 'import_run_notification' => 'Sisu on imporditud', 'import_delete' => 'kustutas impordi', 'import_delete_notification' => 'Import on kustutatud', // Users 'user_create' => 'lisas kasutaja', 'user_create_notification' => 'Kasutaja on lisatud', 'user_update' => 'muutis kasutajat', 'user_update_notification' => 'Kasutaja on muudetud', 'user_delete' => 'kustutas kasutaja', 'user_delete_notification' => 'Kasutaja on kustutatud', // API Tokens 'api_token_create' => 'lisas API tunnuse', 'api_token_create_notification' => 'API tunnus on lisatud', 'api_token_update' => 'muutis API tunnust', 'api_token_update_notification' => 'API tunnus on muudetud', 'api_token_delete' => 'kustutas API tunnuse', 'api_token_delete_notification' => 'API tunnus on kustutatud', // Roles 'role_create' => 'lisas rolli', 'role_create_notification' => 'Roll on lisatud', 'role_update' => 'muutis rolli', 'role_update_notification' => 'Roll on muudetud', 'role_delete' => 'kustutas rolli', 'role_delete_notification' => 'Roll on kustutatud', // Recycle Bin 'recycle_bin_empty' => 'tühjendas prügikasti', 'recycle_bin_restore' => 'taastas prügikastist', 'recycle_bin_destroy' => 'eemaldas prügikastist', // Comments 'commented_on' => 'kommenteeris lehte', 'comment_create' => 'lisas kommentaari', 'comment_update' => 'muutis kommentaari', 'comment_delete' => 'kustutas kommentaari', // Sort Rules 'sort_rule_create' => 'lisas sorteerimisreegli', 'sort_rule_create_notification' => 'Sorteerimisreegel on lisatud', 'sort_rule_update' => 'muutis sorteerimisreeglit', 'sort_rule_update_notification' => 'Sorteerimisreegel on muudetud', 'sort_rule_delete' => 'kustutas sorteerimisreegli', 'sort_rule_delete_notification' => 'Sorteerimisreegel on kustutatud', // Other 'permissions_update' => 'muutis õiguseid', ];
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/lang/et/common.php
lang/et/common.php
<?php /** * Common elements found throughout many areas of BookStack. */ return [ // Buttons 'cancel' => 'Tühista', 'close' => 'Sulge', 'confirm' => 'Kinnita', 'back' => 'Tagasi', 'save' => 'Salvesta', 'continue' => 'Jätka', 'select' => 'Vali', 'toggle_all' => 'Vaheta kõik', 'more' => 'Rohkem', // Form Labels 'name' => 'Pealkiri', 'description' => 'Kirjeldus', 'role' => 'Roll', 'cover_image' => 'Kaanepilt', 'cover_image_description' => 'See pildifail peaks olema umbes 440x250px, ehkki seda skaleeritakse ja lõigatakse vastavalt vajadusele, et see mahuks erinevatesse kasutajaliidestesse, seega tegelikud kuvamõõdud võivad erineda.', // Actions 'actions' => 'Tegevused', 'view' => 'Vaata', 'view_all' => 'Vaata kõiki', 'new' => 'Uus', 'create' => 'Lisa', 'update' => 'Uuenda', 'edit' => 'Muuda', 'archive' => 'Arhiveeri', 'unarchive' => 'Taasta arhiivist', 'sort' => 'Sorteeri', 'move' => 'Liiguta', 'copy' => 'Kopeeri', 'reply' => 'Vasta', 'delete' => 'Kustuta', 'delete_confirm' => 'Kinnita kustutamine', 'search' => 'Otsi', 'search_clear' => 'Tühjenda otsing', 'reset' => 'Taasta', 'remove' => 'Eemalda', 'add' => 'Lisa', 'configure' => 'Seadista', 'manage' => 'Halda', 'fullscreen' => 'Täisekraan', 'favourite' => 'Lemmik', 'unfavourite' => 'Eemalda lemmik', 'next' => 'Järgmine', 'previous' => 'Eelmine', 'filter_active' => 'Aktiivne filter:', 'filter_clear' => 'Tühjenda filter', 'download' => 'Laadi alla', 'open_in_tab' => 'Ava vahelehel', 'open' => 'Ava', // Sort Options 'sort_options' => 'Sorteerimise valikud', 'sort_direction_toggle' => 'Sorteerimise suund', 'sort_ascending' => 'Sorteeri kasvavalt', 'sort_descending' => 'Sorteeri kahanevalt', 'sort_name' => 'Pealkiri', 'sort_default' => 'Vaikimisi', 'sort_created_at' => 'Loomise aeg', 'sort_updated_at' => 'Muutmise aeg', // Misc 'deleted_user' => 'Kustutatud kasutaja', 'no_activity' => 'Pole tegevusi, mida näidata', 'no_items' => 'Ühtegi elementi pole', 'back_to_top' => 'Tagasi üles', 'skip_to_main_content' => 'Otse põhisisu juurde', 'toggle_details' => 'Näita detaile', 'toggle_thumbnails' => 'Näita eelvaateid', 'details' => 'Detailid', 'grid_view' => 'Tabelivaade', 'list_view' => 'Loendivaade', 'default' => 'Vaikimisi', 'breadcrumb' => 'Jäljerida', 'status' => 'Staatus', 'status_active' => 'Aktiivne', 'status_inactive' => 'Mitteaktiivne', 'never' => 'Mitte kunagi', 'none' => 'Puudub', // Header 'homepage' => 'Avaleht', 'header_menu_expand' => 'Laienda päisemenüü', 'profile_menu' => 'Profiilimenüü', 'view_profile' => 'Vaata profiili', 'edit_profile' => 'Muuda profiili', 'dark_mode' => 'Tume režiim', 'light_mode' => 'Hele režiim', 'global_search' => 'Globaalne otsing', // Layout tabs 'tab_info' => 'Info', 'tab_info_label' => 'Sakk: Näita sekundaarset infot', 'tab_content' => 'Sisu', 'tab_content_label' => 'Sakk: Näita primaarset sisu', // Email Content 'email_action_help' => 'Kui sul on probleeme ":actionText" nupu vajutamisega, kopeeri allolev URL oma veebilehitsejasse:', 'email_rights' => 'Kõik õigused kaitstud', // Footer Link Options // Not directly used but available for convenience to users. 'privacy_policy' => 'Privaatsus', 'terms_of_service' => 'Kasutustingimused', // OpenSearch 'opensearch_description' => 'Otsi :appName', ];
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/lang/et/pagination.php
lang/et/pagination.php
<?php /** * Pagination Language Lines * The following language lines are used by the paginator library to build * the simple pagination links. */ return [ 'previous' => '&laquo; Eelmine', 'next' => 'Järgmine &raquo;', ];
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/lang/et/settings.php
lang/et/settings.php
<?php /** * Settings text strings * Contains all text strings used in the general settings sections of BookStack * including users and roles. */ return [ // Common Messages 'settings' => 'Seaded', 'settings_save' => 'Salvesta seaded', 'system_version' => 'Süsteemi versioon', 'categories' => 'Kategooriad', // App Settings 'app_customization' => 'Kohandamine', 'app_features_security' => 'Funktsioonid ja turvalisus', 'app_name' => 'Rakenduse nimi', 'app_name_desc' => 'Seda nime näidatakse päises ja kõigis süsteemsetes e-kirjades.', 'app_name_header' => 'Näita nime päises', 'app_public_access' => 'Avalik ligipääs', 'app_public_access_desc' => 'Selle sisselülitamine võimaldab külalistel ilma sisselogimata ligipääsu su BookStack\'i sisule.', 'app_public_access_desc_guest' => 'Sisselogimata kasutajate ligipääsu saab seadistada "Külaline" kasutaja kaudu.', 'app_public_access_toggle' => 'Luba avalik ligipääs', 'app_public_viewing' => 'Luba avalik ligipääs?', 'app_secure_images' => 'Turvalisem piltide üleslaadimine', 'app_secure_images_toggle' => 'Lülita sisse turvalisem piltide üleslaadimine', 'app_secure_images_desc' => 'Jõudluse kaalutlustel on kõik pildifailid avalikult kättesaadavad. See valik lisab pildifailide URL-ide ette juhugenereeritud, raskesti arvatava stringi. Ligipääsu piiramiseks veendu, et kataloogide indekseerimine ei oleks lubatud.', 'app_default_editor' => 'Vaikimisi lehe redaktor', 'app_default_editor_desc' => 'Vali, millist redaktorit vaikimisi uute lehtede jaoks kasutada. Seda valikut saab õiguste olemasolul iga lehe jaoks eraldi muuta.', 'app_custom_html' => 'Kohandatud HTML päise sisu', 'app_custom_html_desc' => 'Siia lisatud sisu lisatakse iga lehe <head> sektsiooni lõppu. See võimaldab stiile üle laadida või lisada analüütika koodi.', 'app_custom_html_disabled_notice' => 'Kohandatud HTML päise sisu on sellel lehel välja lülitatud, et probleemseid muudatusi saaks tagasi võtta.', 'app_logo' => 'Rakenduse logo', 'app_logo_desc' => 'Seda kasutatakse muuhulgas rakenduse päises. Pildifail peaks olema 86px kõrge. Suuremad pildid tehakse väiksemaks.', 'app_icon' => 'Rakenduse ikoon', 'app_icon_desc' => 'Seda ikooni kasutatakse brauseri sakkidel ja järjehoidjate ikoonidena. See peaks olema 256px ruudukujuline PNG.', 'app_homepage' => 'Rakenduse avaleht', 'app_homepage_desc' => 'Vali leht, mida näidata avalehel vaikimisi vaate asemel. Valitud lehele ei rakendata ligipääsuõiguseid.', 'app_homepage_select' => 'Vali leht', 'app_footer_links' => 'Lingid jaluses', 'app_footer_links_desc' => 'Lisa rakenduse jalusesse linke. Neid näidatakse enamike lehtede jaluses, kaasa arvatud need, mis ei vaja sisselogimist. Võid kasutada märgendit "trans::<key>", et kasutada süsteemseid tõlkeid. Näiteks "trans::common.privacy_policy" tekitab tõlgitud teksti "Privaatsus" ning "trans::common.terms_of_service" tekitab tõlgitud teksti "Kasutustingimused".', 'app_footer_links_label' => 'Lingi tekst', 'app_footer_links_url' => 'Lingi URL', 'app_footer_links_add' => 'Lisa link', 'app_disable_comments' => 'Keela kommentaarid', 'app_disable_comments_toggle' => 'Keela kommentaarid', 'app_disable_comments_desc' => 'Keelab kommentaarid kogu rakenduses. <br>Olemasolevaid kommentaare ei näidata.', // Color settings 'color_scheme' => 'Rakenduse värvid', 'color_scheme_desc' => 'Määra rakenduse kasutajaliidese värvid. Tumeda ja heleda režiimi värve saab sobivuse ja loetavuse huvides eraldi seadistada.', 'ui_colors_desc' => 'Määra rakenduse põhivärv ja vaikimisi linkide värv. Põhivärvi kasutatakse peamiselt päise, nuppude ning kasutajaliidese dekoratsioonide jaoks. Vaikimisi linkide värvi kasutatakse tekstipõhiste linkide ja tegevuste jaoks, nii kirjalikus sisus kui rakenduse kasutajaliideses.', 'app_color' => 'Põhivärv', 'link_color' => 'Vaikimisi linkide värv', 'content_colors_desc' => 'Määra värvid erinevatele sisuelementidele. Loetavuse huvides on soovituslik valida värvid, mille heledus on sarnane vaikimisi värvidele.', 'bookshelf_color' => 'Riiuli värv', 'book_color' => 'Raamatu värv', 'chapter_color' => 'Peatüki värv', 'page_color' => 'Lehe värv', 'page_draft_color' => 'Mustandi värv', // Registration Settings 'reg_settings' => 'Registreerumine', 'reg_enable' => 'Luba registreerumine', 'reg_enable_toggle' => 'Luba registreerumine', 'reg_enable_desc' => 'Kui registreerumine on lubatud, saavad kasutajad ise endale rakenduse konto tekitada, ning neile antakse vaikimisi roll.', 'reg_default_role' => 'Vaikimisi roll uutele kasutajatele', 'reg_enable_external_warning' => 'Ülalolevat valikut ignoreeritakse, kui väline LDAP või SAML autentimine on aktiivne. Kui autentimine välise süsteemi vastu on edukas, genereeritakse puuduvad kasutajadkontod automaatselt.', 'reg_email_confirmation' => 'E-posti aadressi kinnitus', 'reg_email_confirmation_toggle' => 'Nõua e-posti aadressi kinnitamist', 'reg_confirm_email_desc' => 'Kui domeeni piirang on kasutusel, siis on e-posti aadressi kinnitamine nõutud ja seda seadet ignoreeritakse.', 'reg_confirm_restrict_domain' => 'Domeeni piirang', 'reg_confirm_restrict_domain_desc' => 'Sisesta komaga eraldatud nimekiri e-posti domeenidest, millega soovid registreerumist piirata. Kasutajale saadetakse aadressi kinnitamiseks e-kiri, enne kui neil lubatakse rakendust kasutada.<br>Pane tähele, et kasutajad saavad pärast edukat registreerumist oma e-posti aadressi muuta.', 'reg_confirm_restrict_domain_placeholder' => 'Piirangut ei ole', // Sorting Settings 'sorting' => 'Loendid ja järjestamine', 'sorting_book_default' => 'Vaikimisi raamatute sorteerimise reegel', 'sorting_book_default_desc' => 'Vali vaikimisi uutele raamatutele rakenduv sorteerimisreegel. See ei mõjuta olemasolevaid raamatuid ning seda saab raamatupõhiselt muuta.', 'sorting_rules' => 'Sorteerimisreeglid', 'sorting_rules_desc' => 'Need on eeldefineeritud sorteerimistoimingud, mida saab süsteemis olevale sisule rakendada.', 'sort_rule_assigned_to_x_books' => 'Määratud :count raamatule|Määratud :count raamatule', 'sort_rule_create' => 'Lisa sorteerimisreegel', 'sort_rule_edit' => 'Muuda sorteerimisreeglit', 'sort_rule_delete' => 'Kustuta sorteerimisreegel', 'sort_rule_delete_desc' => 'Eemalda sorteerimisreegel süsteemist. Seda reeglit kasutavad raamatud jäävad käsitsi sorteerituks.', 'sort_rule_delete_warn_books' => 'Seda reeglit kasutab hetkel :count raamat(ut). Kas oled kindel, et soovid selle kustutada?', 'sort_rule_delete_warn_default' => 'See reegel on hetkel raamatute vaikimisi sorteerimisreegel. Kas oled kindel, et soovid selle kustutada?', 'sort_rule_details' => 'Sorteerimisreegli andmed', 'sort_rule_details_desc' => 'Määra sorteerimisreegli nimi, mida kasutatakse reegli valimise loendites.', 'sort_rule_operations' => 'Sorteerimistoimingud', 'sort_rule_operations_desc' => 'Seadista sorteerimistoimingud, liigutades neid saadaval toimingute loendist. Toimingud rakendatakse järjest, ülevalt alla. Siin tehtud muudatused rakenduvad salvestamisel kõigile määratud raamatutele.', 'sort_rule_available_operations' => 'Saadaval toimingud', 'sort_rule_available_operations_empty' => 'Rohkem toiminguid pole', 'sort_rule_configured_operations' => 'Seadistatud toimingud', 'sort_rule_configured_operations_empty' => 'Lisa toiminguid "Saadaval toimingud" loendist', 'sort_rule_op_asc' => '(kasvavalt)', 'sort_rule_op_desc' => '(kahanevalt)', 'sort_rule_op_name' => 'Nimi - tähestikuline', 'sort_rule_op_name_numeric' => 'Nimi - numbriline', 'sort_rule_op_created_date' => 'Loomise aeg', 'sort_rule_op_updated_date' => 'Muutmise aeg', 'sort_rule_op_chapters_first' => 'Peatükid eespool', 'sort_rule_op_chapters_last' => 'Peatükid tagapool', 'sorting_page_limits' => 'Leheküljepõhised kuvalimiidid', 'sorting_page_limits_desc' => 'Seadista, mitut objekti erinevates loendites ühel leheküljel kuvada. Väiksem väärtus tähendab reeglina paremat jõudlust, samas kui suurem väärtus vähendab vajadust mitut lehekülge läbi klikkida. Soovituslik on kasutada 3-ga jaguvat väärtust (18, 24, 30 jne).', // Maintenance settings 'maint' => 'Hooldus', 'maint_image_cleanup' => 'Pildifailide koristus', 'maint_image_cleanup_desc' => 'Kontrollib lehtede ja redaktsioonide sisu, et leida pilte ja jooniseid, mis enam kasutusel ei ole. Enne selle käivitamist tee andmebaasist ja pildifailidest täielik varukoopia.', 'maint_delete_images_only_in_revisions' => 'Kustuta ka pildifailid, mis on kasutusel ainult vanades redaktsioonides', 'maint_image_cleanup_run' => 'Käivita koristus', 'maint_image_cleanup_warning' => 'Leiti :count potentsiaalselt kasutamata pildifaili. Kas oled kindel, et soovid need kustutada?', 'maint_image_cleanup_success' => 'Leiti ja kustutati :count potentsiaalselt kasutamata pildifaili!', 'maint_image_cleanup_nothing_found' => 'Kasutamata pildifaile ei leitud, pole midagi kustutada!', 'maint_send_test_email' => 'Saada testimiseks e-kiri', 'maint_send_test_email_desc' => 'See saadab testimiseks e-kirja su profiilis märgitud aadressile.', 'maint_send_test_email_run' => 'Saada test e-kiri', 'maint_send_test_email_success' => 'E-kiri saadetud aadressile :address', 'maint_send_test_email_mail_subject' => 'Test e-kiri', 'maint_send_test_email_mail_greeting' => 'E-kirjade saatmine tundub toimivat!', 'maint_send_test_email_mail_text' => 'Hea töö! Kui sa selle e-kirja kätte said, on su e-posti seaded õigesti määratud.', 'maint_recycle_bin_desc' => 'Kustutatud riiulid, raamatud, peatükid ja lehed saadetakse prügikasti, et neid saaks taastada või lõplikult kustutada. Vanemad objektid võidakse teatud aja järel automaatselt prügikastist kustutada.', 'maint_recycle_bin_open' => 'Ava prügikast', 'maint_regen_references' => 'Genereeri viited uuesti', 'maint_regen_references_desc' => 'See tegevus taastekitab andmebaasis objektidevahelised viited. Enamasti tehakse seda automaatselt, aga antud tegevus võimaldab indekseerida vanemat sisu või sisu, mis lisati mitteametlike meetodite abil.', 'maint_regen_references_success' => 'Viiteindeks genereeritud!', 'maint_timeout_command_note' => 'Märkus: See tegevus võib aega võtta, mis võib teatud veebikeskkondades põhjustada aegumise vigu. Alternatiivina võib seda tegevust käivitada käsurealt.', // Recycle Bin 'recycle_bin' => 'Prügikast', 'recycle_bin_desc' => 'Siin saad taastada kustutatud objekte, või neid süsteemist lõplikult eemaldada. Nimekiri on filtreerimata, mitte nagu mujal tegevusloendites, kus rakenduvad õigused.', 'recycle_bin_deleted_item' => 'Kustutatud objekt', 'recycle_bin_deleted_parent' => 'Ülemobjekt', 'recycle_bin_deleted_by' => 'Kustutaja', 'recycle_bin_deleted_at' => 'Kustutamise aeg', 'recycle_bin_permanently_delete' => 'Kustuta lõplikult', 'recycle_bin_restore' => 'Taasta', 'recycle_bin_contents_empty' => 'Prügikast on hetkel tühi', 'recycle_bin_empty' => 'Tühjenda prügikast', 'recycle_bin_empty_confirm' => 'See kustutab lõplikult kõik objektid prügikastis, kaasa arvatud nende sisu. Kas oled kindel, et soovid prügikasti tühjendada?', 'recycle_bin_destroy_confirm' => 'See kustutab lõplikult süsteemist valitud objekti koos loetletud alamobjektidega, ja seda sisu ei ole enam võimalik taastada. Kas oled kindel, et soovid selle objekti kustutada?', 'recycle_bin_destroy_list' => 'Kustutatavad objektid', 'recycle_bin_restore_list' => 'Taastatavad objektid', 'recycle_bin_restore_confirm' => 'See taastab valitud objekti koos kõigi alamobjektidega nende algsesse asukohta. Kui see asukoht on ka vahepeal kustutatud ja on nüüd prügikastis, tuleb ka see taastada.', 'recycle_bin_restore_deleted_parent' => 'Selle objekti ülemobjekt on ka kustutatud. Taastada ei saa enne, kui ülemobjekt on taastatud.', 'recycle_bin_restore_parent' => 'Taasta ülemobjekt', 'recycle_bin_destroy_notification' => 'Prügikastist kustutati :count objekti.', 'recycle_bin_restore_notification' => 'Prügikastist taastati :count objekti.', // Audit Log 'audit' => 'Auditilogi', 'audit_desc' => 'Auditilogi kuvab nimekirja tegevustest, mida süsteem jälgib. See nimekiri on filtreerimata, erinevalt muudest loenditest süsteemis, kus rakenduvad õigused.', 'audit_event_filter' => 'Sündmuse filter', 'audit_event_filter_no_filter' => 'Ilma filtrita', 'audit_deleted_item' => 'Kustutatud objekt', 'audit_deleted_item_name' => 'Nimi: :name', 'audit_table_user' => 'Kasutaja', 'audit_table_event' => 'Sündmus', 'audit_table_related' => 'Seotud objekt või detail', 'audit_table_ip' => 'IP-aadress', 'audit_table_date' => 'Tegevuse aeg', 'audit_date_from' => 'Kuupäev alates', 'audit_date_to' => 'Kuupäev kuni', // Role Settings 'roles' => 'Rollid', 'role_user_roles' => 'Kasutaja rollid', 'roles_index_desc' => 'Rolle saab kasutada kasutajate grupeerimiseks ja liikmetele süsteemsete õiguste andmiseks. Kui kasutaja on mitme rolli liige, siis õigused kombineeritakse ning kasutaja saab kõik õigused.', 'roles_x_users_assigned' => ':count kasutaja|:count kasutajat', 'roles_x_permissions_provided' => ':count õigus|:count õigust', 'roles_assigned_users' => 'Määratud kasutajad', 'roles_permissions_provided' => 'Antud õigused', 'role_create' => 'Lisa uus roll', 'role_delete' => 'Kustuta roll', 'role_delete_confirm' => 'See kustutab rolli nimega \':roleName\'.', 'role_delete_users_assigned' => 'Selle rolliga on seotud :userCount kasutajat. Kui soovid neile selle asemel uue rolli määrata, siis vali see allpool.', 'role_delete_no_migration' => "Ära määra uut rolli", 'role_delete_sure' => 'Kas oled kindel, et soovid selle rolli kustutada?', 'role_edit' => 'Muuda rolli', 'role_details' => 'Rolli detailid', 'role_name' => 'Rolli nimi', 'role_desc' => 'Rolli lühike kirjeldus', 'role_mfa_enforced' => 'Vajab mitmeastmelist autentimist', 'role_external_auth_id' => 'Välise autentimise ID-d', 'role_system' => 'Süsteemsed õigused', 'role_manage_users' => 'Kasutajate haldamine', 'role_manage_roles' => 'Rollide ja õiguste haldamine', 'role_manage_entity_permissions' => 'Kõigi raamatute, peatükkide ja lehtede õiguste haldamine', 'role_manage_own_entity_permissions' => 'Oma raamatute, peatükkide ja lehtede õiguste haldamine', 'role_manage_page_templates' => 'Mallide haldamine', 'role_access_api' => 'Süsteemi API ligipääs', 'role_manage_settings' => 'Rakenduse seadete haldamine', 'role_export_content' => 'Sisu eksport', 'role_import_content' => 'Imporditud sisu', 'role_editor_change' => 'Lehe redaktori muutmine', 'role_notifications' => 'Võta vastu ja halda teavitusi', 'role_permission_note_users_and_roles' => 'Need õigused lubavad ka süsteemis olevaid kasutajaid ja rolle vaadata ja otsida.', 'role_asset' => 'Sisu õigused', 'roles_system_warning' => 'Pane tähele, et ülalolevad kolm õigust võimaldavad kasutajal enda või teiste kasutajate õiguseid muuta. Määra nende õigustega roll ainult usaldusväärsetele kasutajatele.', 'role_asset_desc' => 'Need load kontrollivad vaikimisi ligipääsu süsteemis olevale sisule. Raamatute, peatükkide ja lehtede õigused rakenduvad esmajärjekorras.', 'role_asset_admins' => 'Administraatoritel on automaatselt ligipääs kogu sisule, aga need valikud võivad peida või näidata kasutajaliidese elemente.', 'role_asset_image_view_note' => 'See käib nähtavuse kohta pildifailide halduris. Tegelik ligipääs üleslaaditud pildifailidele sõltub süsteemsest piltide salvestamise valikust.', 'role_asset_users_note' => 'Need õigused lubavad ka süsteemis olevaid kasutajaid vaadata ja otsida.', 'role_all' => 'Kõik', 'role_own' => 'Enda omad', 'role_controlled_by_asset' => 'Õigused määratud seotud objekti kaudu', 'role_save' => 'Salvesta roll', 'role_users' => 'Selle rolliga kasutajad', 'role_users_none' => 'Seda rolli ei ole hetkel ühelgi kasutajal', // Users 'users' => 'Kasutajad', 'users_index_desc' => 'Loo ja halda süsteemi kasutajakontosid. Kontosid kasutatakse sisselogimiseks ning sisu ja tegevuse omistamiseks. Ligipääsuload on enamasti rollipõhised, aga sisu omandus ja muud faktorid võivad samuti mõjutada õiguseid ja ligipääsu.', 'user_profile' => 'Kasutajaprofiil', 'users_add_new' => 'Lisa uus kasutaja', 'users_search' => 'Otsi kasutajaid', 'users_latest_activity' => 'Viimane tegevus', 'users_details' => 'Kasutaja andmed', 'users_details_desc' => 'Määra kasutajale nimi ja e-posti aadress. E-posti aadressi kasutatakse rakendusse sisse logimiseks.', 'users_details_desc_no_email' => 'Määra kasutajale nimi, mille järgi teised ta ära tunnevad.', 'users_role' => 'Kasutaja rollid', 'users_role_desc' => 'Vali, millised rollid sellel kasutajal on. Kui talle on valitud mitu rolli, siis nende õigused kombineeritakse ja kasutaja saab kõigi rollide õigused.', 'users_password' => 'Kasutaja parool', 'users_password_desc' => 'Määra parool, millega rakendusse sisse logida. See peab olema vähemalt 8 tähemärki.', 'users_send_invite_text' => 'Sa võid kasutajale saata e-postiga kutse, mis võimaldab neil ise parooli seada. Vastasel juhul määra parool ise.', 'users_send_invite_option' => 'Saada e-postiga kutse', 'users_external_auth_id' => 'Välise autentimise ID', 'users_external_auth_id_desc' => 'Kui kasutusel on väline autentimissüsteem (nagu SAML2, OIDC või LDAP), siis see ID ühendab selle BookStack kasutaja autentimissüsteemi kasutajakontoga. Kui kasutad vaikimisi e-posti põhist autentimist, võid seda välja ignoreerida.', 'users_password_warning' => 'Täida allolevad väljad ainult siis, kui soovid selle kasutaja parooli muuta.', 'users_system_public' => 'See kasutaja tähistab kõiki külalisi, kes su rakendust vaatavad. Selle kontoga ei saa sisse logida, see määratakse automaatselt.', 'users_delete' => 'Kustuta kasutaja', 'users_delete_named' => 'Kustuta kasutaja :userName', 'users_delete_warning' => 'See kustutab kasutaja nimega \':userName\' süsteemist täielikult.', 'users_delete_confirm' => 'Kas oled kindel, et soovid selle kasutaja kustutada?', 'users_migrate_ownership' => 'Teisalda omandus', 'users_migrate_ownership_desc' => 'Vali siin kasutaja, kui soovid talle üle viia kõik selle kasutaja objektid.', 'users_none_selected' => 'Kasutaja valimata', 'users_edit' => 'Muuda kasutajat', 'users_edit_profile' => 'Muuda profiili', 'users_avatar' => 'Kasutaja profiilipilt', 'users_avatar_desc' => 'Vali sellele kasutajale profiilipilt. See peaks olema umbes 256x256 pikslit.', 'users_preferred_language' => 'Eelistatud keel', 'users_preferred_language_desc' => 'See valik muudab rakenduse kasutajaliidese keelt. Kasutajate loodud sisu see ei mõjuta.', 'users_social_accounts' => 'Sotsiaalmeedia kontod', 'users_social_accounts_desc' => 'Vaata selle kasutaja ühendatud sotsiaalmeedia kontode seisundit. Sotsiaalmeedia kontosid saab kasutada süsteemile ligipääsemiseks, lisaks primaarsele autentimissüsteemile.', 'users_social_accounts_info' => 'Siin saad seostada teised kontod, millega kiiremini ja lihtsamini sisse logida. Siit konto eemaldamine ei tühista varem lubatud ligipääsu. Ligipääsu saad tühistada ühendatud konto profiili seadetest.', 'users_social_connect' => 'Lisa konto', 'users_social_disconnect' => 'Eemalda konto', 'users_social_status_connected' => 'Ühendatud', 'users_social_status_disconnected' => 'Ühendus katkestatud', 'users_social_connected' => ':socialAccount konto lisati su profiilile.', 'users_social_disconnected' => ':socialAccount konto eemaldati su profiililt.', 'users_api_tokens' => 'API tunnused', 'users_api_tokens_desc' => 'Lisa ja halda BookStack REST API-ga autentimiseks mõeldud ligipääsutunnuseid. API kasutamise õigused on määratud ksautaja kaudu, kellele ligipääsutunnus kuulub.', 'users_api_tokens_none' => 'Sellel kasutajal pole API tunnuseid', 'users_api_tokens_create' => 'Lisa tunnus', 'users_api_tokens_expires' => 'Aegub', 'users_api_tokens_docs' => 'API dokumentatsioon', 'users_mfa' => 'Mitmeastmeline autentimine', 'users_mfa_desc' => 'Seadista mitmeastmeline autentimine, et oma kasutajakonto turvalisust tõsta.', 'users_mfa_x_methods' => ':count meetod seadistatud|:count meetodit seadistatud', 'users_mfa_configure' => 'Seadista meetodid', // API Tokens 'user_api_token_create' => 'Lisa API tunnus', 'user_api_token_name' => 'Nimi', 'user_api_token_name_desc' => 'Anna oma tunnusele inimloetav nimi, et selle eesmärk paremini meeles püsiks.', 'user_api_token_expiry' => 'Kehtiv kuni', 'user_api_token_expiry_desc' => 'Määra kuupäev, millal see tunnus aegub. Pärast seda kuupäeva ei saa selle tunnusega enam päringuid teha. Välja tühjaks jätmine määrab aegumiskuupäeva 100 aastat tulevikku.', 'user_api_token_create_secret_message' => 'Kohe pärast selle tunnuse loomist genereeritakse ja kuvatakse tunnuse ID ja salajane võti. Võtit kuvatakse ainult ühe korra, seega kopeeri selle väärtus enne jätkamist turvalisse kohta.', 'user_api_token' => 'API tunnus', 'user_api_token_id' => 'Tunnuse ID', 'user_api_token_id_desc' => 'See on API tunnuse süsteemne mittemuudetav identifikaator, mis tuleb API päringutele kaasa panna.', 'user_api_token_secret' => 'Tunnuse võti', 'user_api_token_secret_desc' => 'See on API tunnuse salajane võti, mis tuleb API päringutele kaasa panna. Seda kuvatakse ainult ühe korra, seega kopeeri see turvalisse kohta.', 'user_api_token_created' => 'Tunnus lisatud :timeAgo', 'user_api_token_updated' => 'Tunnus muudetud :timeAgo', 'user_api_token_delete' => 'Kustuta tunnus', 'user_api_token_delete_warning' => 'See kustutab API tunnuse nimega \':tokenName\' süsteemist.', 'user_api_token_delete_confirm' => 'Kas oled kindel, et soovid selle API tunnuse kustutada?', // Webhooks 'webhooks' => 'Veebihaagid', 'webhooks_index_desc' => 'Veebihaakide abil saab teatud süsteemis toimunud tegevuste ja sündmuste puhul saata andmeid välistele URL-idele, mis võimaldab integreerida väliseid platvorme, nagu sõnumi- või teavitussüsteemid.', 'webhooks_x_trigger_events' => ':count sündmus|:count sündmust', 'webhooks_create' => 'Lisa uus veebihaak', 'webhooks_none_created' => 'Ühtegi veebihaaki pole lisatud.', 'webhooks_edit' => 'Muuda veebihaaki', 'webhooks_save' => 'Salvesta veebihaak', 'webhooks_details' => 'Veebihaagi seaded', 'webhooks_details_desc' => 'Sisesta kasutajasõbralik nimi ja POST lõpp-punkt, kuhu veebihaagi andmeid saadetakse.', 'webhooks_events' => 'Veebihaagi sündmused', 'webhooks_events_desc' => 'Vali kõik sündmused, mille peale seda veebihaaki peaks käivitama.', 'webhooks_events_warning' => 'Pea meeles, et veebihaak käivitatakse kõigi valitud sündmuste peale, isegi kui on seatud kohandatud õigused. Hoolitse selle eest, et veebihaak ei teeks avalikuks konfidentsiaalset sisu.', 'webhooks_events_all' => 'Kõik süsteemsed sündmused', 'webhooks_name' => 'Veebihaagi nimi', 'webhooks_timeout' => 'Veebihaagi päringu aegumine (sekundit)', 'webhooks_endpoint' => 'Veebihaagi lõpp-punkt', 'webhooks_active' => 'Veebihaak aktiivne', 'webhook_events_table_header' => 'Sündmused', 'webhooks_delete' => 'Kustuta veebihaak', 'webhooks_delete_warning' => 'See kustutab veebihaagi nimega \':webhookName\' süsteemist.', 'webhooks_delete_confirm' => 'Kas oled kindel, et soovid selle veebihaagi kustutada?', 'webhooks_format_example' => 'Veebihaagi formaadi näidis', 'webhooks_format_example_desc' => 'Veebihaagi andmed saadetakse POST-päringuga seadistatud lõpp-punktile allpool toodud JSON-formaadis. Omadused "related_item" ja "url" on valikulised ja sõltuvad sündmusest, mis veebihaagi käivitas.', 'webhooks_status' => 'Veebihaagi staatus', 'webhooks_last_called' => 'Viimati käivitatud:', 'webhooks_last_errored' => 'Viimati ebaõnnestunud:', 'webhooks_last_error_message' => 'Viimane veateade:', // Licensing 'licenses' => 'Litsentsid', 'licenses_desc' => 'See leht koondab litsentsiinfot BookStack\'i ja selles kasutatud projektide ja teekide kohta. Paljusid loetletud teekidest võidakse kasutada ainult arenduse kontekstis.', 'licenses_bookstack' => 'BookStack\'i litsents', 'licenses_php' => 'PHP teekide litsentsid', 'licenses_js' => 'JavaScript teekide litsentsid', 'licenses_other' => 'Muud litsentsid', 'license_details' => 'Litsentsi detailid', //! If editing translations files directly please ignore this in all //! languages apart from en. Content will be auto-copied from en. //!//////////////////////////////// 'language_select' => [ 'en' => 'English (inglise keel)', 'ar' => 'العربية (araabia keel)', 'bg' => 'Bǎlgarski (bulgaaria keel)', 'bs' => 'Bosanski (bosnia keel)', 'ca' => 'Català (katalaani keel)', 'cs' => 'Česky (tšehhi keel)', 'cy' => 'Cymraeg', 'da' => 'Dansk (taani keel)', 'de' => 'Deutsch (saksa keel)', 'de_informal' => 'Deutsch (Du) (mitteformaalne saksa keel)', 'el' => 'ελληνικά', 'es' => 'Español (hispaania keel)', 'es_AR' => 'Español Argentina (Argentiina hispaania keel)', 'et' => 'Eesti keel', 'eu' => 'Euskara', 'fa' => 'فارسی', 'fi' => 'Suomi', 'fr' => 'Français (prantsuse keel)', 'he' => 'עברית (heebrea keel)', 'hr' => 'Hrvatski (horvaadi keel)', 'hu' => 'Magyar (ungari keel)', 'id' => 'Bahasa Indonesia (indoneesia keel)', 'it' => 'Italiano (itaalia keel)', 'ja' => '日本語 (jaapani keel)', 'ko' => '한국어 (korea keel)', 'lt' => 'Lietuvių Kalba (leedu keel)', 'lv' => 'Latviešu Valoda (läti keel)', 'nb' => 'Norsk (Bokmål) (norra keel)', 'ne' => 'नेपाली', 'nn' => 'Nynorsk', 'nl' => 'Nederlands (hollandi keel)', 'pl' => 'Polski (poola keel)', 'pt' => 'Português (portugali keel)', 'pt_BR' => 'Português do Brasil (Brasiilia portugali keel)', 'ro' => 'Română', 'ru' => 'Русский (vene keel)', 'sk' => 'Slovensky', 'sl' => 'Sloveenia', 'sv' => 'Rootsi', 'tr' => 'Türgi', 'uk' => 'Ukraina', 'uz' => 'O‘zbekcha', 'vi' => 'Vietnami', 'zh_CN' => 'Hiina (lihtsustatud)', 'zh_TW' => 'Hiina (traditsiooniline)', ], //!//////////////////////////////// ];
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/lang/et/validation.php
lang/et/validation.php
<?php /** * Validation Lines * The following language lines contain the default error messages used by * the validator class. Some of these rules have multiple versions such * as the size rules. Feel free to tweak each of these messages here. */ return [ // Standard laravel validation lines 'accepted' => ':attribute peab olema aktsepteeritud.', 'active_url' => ':attribute ei ole kehtiv URL.', 'after' => ':attribute peab olema kuupäev pärast :date.', 'alpha' => ':attribute võib sisaldada ainult tähti.', 'alpha_dash' => ':attribute võib sisaldada ainult tähti, numbreid, sidekriipse ja alakriipse.', 'alpha_num' => ':attribute võib sisaldada ainult tähti ja numbreid.', 'array' => ':attribute peab olema massiiv.', 'backup_codes' => 'Kood ei ole korrektne või on seda juba kasutatud.', 'before' => ':attribute peab olema kuupäev enne :date.', 'between' => [ 'numeric' => ':attribute peab jääma vahemikku :min ja :max.', 'file' => ':attribute peab olema :min ja :max kilobaidi vahel.', 'string' => ':attribute peab olema :min ja :max tähemärgi vahel.', 'array' => ':attribute peab olema :min ja :max elemendi vahel.', ], 'boolean' => ':attribute peab olema tõene või väär.', 'confirmed' => ':attribute kinnitus ei kattu.', 'date' => ':attribute ei ole kehtiv kuupäev.', 'date_format' => ':attribute ei ühti formaadiga :format.', 'different' => ':attribute ja :other peavad olema erinevad.', 'digits' => ':attribute peab olema :digits-kohaline arv.', 'digits_between' => ':attribute peab olema :min ja :max numbri vahel.', 'email' => ':attribute peab olema kehtiv e-posti aadress.', 'ends_with' => ':attribute lõpus peab olema üks järgmistest väärtustest: :values', 'file' => ':attribute peab olema sobiv fail.', 'filled' => ':attribute väli on kohustuslik.', 'gt' => [ 'numeric' => ':attribute peab olema suurem kui :value.', 'file' => ':attribute peab olema suurem kui :value kilobaiti.', 'string' => ':attribute peab sisaldama rohkem kui :value tähemärki.', 'array' => ':attribute peab sisaldama rohkem kui :value elementi.', ], 'gte' => [ 'numeric' => ':attribute peab olema suurem kui või võrdne :value.', 'file' => ':attribute peab olema :value kilobaiti või rohkem.', 'string' => ':attribute peab sisaldama :value või rohkem tähemärki.', 'array' => ':attribute peab sisaldama :value või rohkem elementi.', ], 'exists' => 'Valitud :attribute on vigane.', 'image' => ':attribute peab olema pildifail.', 'image_extension' => ':attribute peab olema lubatud ja toetatud pildiformaadis.', 'in' => 'Valitud :attribute on vigane.', 'integer' => ':attribute peab olema täisarv.', 'ip' => ':attribute peab olema kehtiv IP-aadress.', 'ipv4' => ':attribute peab olema kehtiv IPv4 aadress.', 'ipv6' => ':attribute peab olema kehtiv IPv6 aadress.', 'json' => ':attribute peab olema kehtiv JSON-vormingus tekst.', 'lt' => [ 'numeric' => ':attribute peab olema väiksem kui :value.', 'file' => ':attribute peab olema väiksem kui :value kilobaiti.', 'string' => ':attribute peab sisaldama vähem kui :value tähemärki.', 'array' => ':attribute peab sisaldama vähem kui :value elementi.', ], 'lte' => [ 'numeric' => ':attribute peab olema :value või vähem.', 'file' => ':attribute peab olema :value kilobaiti või vähem.', 'string' => ':attribute peab sisaldama :value või vähem tähemärki.', 'array' => ':attribute ei tohi sisaldada rohkem kui :value elementi.', ], 'max' => [ 'numeric' => ':attribute ei tohi olla suurem kui :max.', 'file' => ':attribute ei tohi olla suurem kui :max kilobaiti.', 'string' => ':attribute ei tohi sisaldada rohkem kui :max tähemärki.', 'array' => ':attribute ei tohi sisaldada rohkem kui :max elementi.', ], 'mimes' => ':attribute peab olema seda tüüpi fail: :values.', 'min' => [ 'numeric' => ':attribute peab olema vähemalt :min.', 'file' => ':attribute peab olema vähemalt :min kilobaiti.', 'string' => ':attribute peab sisaldama vähemalt :min tähemärki.', 'array' => ':attribute peab sisaldama vähemalt :min elementi.', ], 'not_in' => 'Valitud :attribute on vigane.', 'not_regex' => ':attribute on vigases formaadis.', 'numeric' => ':attribute peab olema arv.', 'regex' => ':attribute on vigases formaadis.', 'required' => ':attribute on kohustuslik.', 'required_if' => ':attribute on kohustuslik, kui :other on :value.', 'required_with' => ':attribute on kohustuslik, kui :values on olemas.', 'required_with_all' => ':attribute on kohustuslik, kui :values on olemas.', 'required_without' => ':attribute on kohustuslik, kui :values ei ole olemas.', 'required_without_all' => ':attribute on kohustuslik, kui :values on valimata.', 'same' => ':attribute ja :other peavad klappima.', 'safe_url' => 'Link ei pruugi olla turvaline.', 'size' => [ 'numeric' => ':attribute peab olema :size.', 'file' => ':attribute peab olema :size kilobaiti.', 'string' => ':attribute peab sisaldama :size tähemärki.', 'array' => ':attribute peab sisaldama :size elemente.', ], 'string' => ':attribute peab olema string.', 'timezone' => ':attribute peab olema kehtiv ajavöönd.', 'totp' => 'Kood ei ole korrektne või on aegunud.', 'unique' => ':attribute on juba võetud.', 'url' => ':attribute on vigases formaadis.', 'uploaded' => 'Faili üleslaadimine ebaõnnestus. Server ei pruugi sellise suurusega faile vastu võtta.', 'zip_file' => ':attribute peab viitama failile ZIP-arhiivi sees.', 'zip_file_size' => 'The file :attribute must not exceed :size MB.', 'zip_file_mime' => ':attribute peab viitama :validTypes tüüpi failile, leiti :foundType.', 'zip_model_expected' => 'Oodatud andmete asemel leiti ":type".', 'zip_unique' => ':attribute peab olema ZIP-arhiivi piires objekti tüübile unikaalne.', // Custom validation lines 'custom' => [ 'password-confirm' => [ 'required_with' => 'Parooli kinnitus on nõutud', ], ], // Custom validation attributes 'attributes' => [], ];
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/lang/et/auth.php
lang/et/auth.php
<?php /** * Authentication Language Lines * The following language lines are used during authentication for various * messages that we need to display to the user. */ return [ 'failed' => 'Kasutajanimi ja parool ei klapi.', 'throttle' => 'Liiga palju sisselogimiskatseid. Proovi uuesti :seconds sekundi pärast.', // Login & Register 'sign_up' => 'Registreeru', 'log_in' => 'Logi sisse', 'log_in_with' => 'Logi sisse :socialDriver abil', 'sign_up_with' => 'Registreeru :socialDriver abil', 'logout' => 'Logi välja', 'name' => 'Nimi', 'username' => 'Kasutajanimi', 'email' => 'E-post', 'password' => 'Parool', 'password_confirm' => 'Kinnita parool', 'password_hint' => 'Peab olema vähemalt 8 tähemärki pikk', 'forgot_password' => 'Unustasid parooli?', 'remember_me' => 'Jäta mind meelde', 'ldap_email_hint' => 'Sisesta kasutajakonto e-posti aadress.', 'create_account' => 'Loo konto', 'already_have_account' => 'Kasutajakonto juba olemas?', 'dont_have_account' => 'Sul ei ole veel kontot?', 'social_login' => 'Sisene läbi sotsiaalmeedia', 'social_registration' => 'Registreeru läbi sotsiaalmeedia', 'social_registration_text' => 'Registreeru ja logi sisse välise teenuse kaudu.', 'register_thanks' => 'Aitäh, et registreerusid!', 'register_confirm' => 'Vaata oma postkasti ja klõpsa kinnitusnupul, et rakendusele :appName ligi pääseda.', 'registrations_disabled' => 'Registreerumine on hetkel keelatud', 'registration_email_domain_invalid' => 'Sellel e-posti domeenil ei ole rakendusele ligipääsu', 'register_success' => 'Aitäh, et registreerusid! Oled nüüd sisse logitud.', // Login auto-initiation 'auto_init_starting' => 'Sisselogimiskatse', 'auto_init_starting_desc' => 'Sisselogimise protsessi alustamiseks autentimissüsteemiga ühendumine. Kui 5 sekundi jooksul edasiminekut ei ole, proovi alloleval lingil klikkida.', 'auto_init_start_link' => 'Jätka autentimisega', // Password Reset 'reset_password' => 'Lähtesta parool', 'reset_password_send_instructions' => 'Siseta oma e-posti aadress ning sulle saadetakse link parooli lähtestamiseks.', 'reset_password_send_button' => 'Saada lähtestamise link', 'reset_password_sent' => 'Kui süsteemis leidub e-posti aadress :email, saadetakse sinna link parooli lähtestamiseks.', 'reset_password_success' => 'Sinu parool on edukalt lähtestatud.', 'email_reset_subject' => 'Lähtesta oma :appName parool', 'email_reset_text' => 'Said selle e-kirja, sest meile laekus soov sinu konto parooli lähtestamiseks.', 'email_reset_not_requested' => 'Kui sa ei soovinud parooli lähtestada, ei pea sa rohkem midagi tegema.', // Email Confirmation 'email_confirm_subject' => 'Kinnita oma :appName konto e-posti aadress', 'email_confirm_greeting' => 'Aitäh, et liitusid rakendusega :appName!', 'email_confirm_text' => 'Palun kinnita oma e-posti aadress, klõpsates alloleval nupul:', 'email_confirm_action' => 'Kinnita e-posti aadress', 'email_confirm_send_error' => 'E-posti aadressi kinnitamine on vajalik, aga e-kirja saatmine ebaõnnestus. Võta ühendust administraatoriga.', 'email_confirm_success' => 'E-posti aadress on kinnitatud! Nüüd saad selle aadressiga sisse logida.', 'email_confirm_resent' => 'Kinnituskiri on saadetud, vaata oma postkasti.', 'email_confirm_thanks' => 'Aitäh, et kinnitasid!', 'email_confirm_thanks_desc' => 'Palun oota hetke, kuni kinnitust töödeldakse. Kui sind 3 sekundi jooksul ümber ei suunata, klõpsa jätkamiseks allpool "Jätka" linki.', 'email_not_confirmed' => 'E-posti aadress ei ole kinnitatud', 'email_not_confirmed_text' => 'Sinu e-posti aadress ei ole veel kinnitatud.', 'email_not_confirmed_click_link' => 'Klõpsa lingil e-kirjas, mis saadeti sulle pärast registreerumist.', 'email_not_confirmed_resend' => 'Kui sa ei leia e-kirja, siis saad alloleva vormi abil selle uuesti saata.', 'email_not_confirmed_resend_button' => 'Saada kinnituskiri uuesti', // User Invite 'user_invite_email_subject' => 'Sind on kutsutud liituma rakendusega :appName!', 'user_invite_email_greeting' => 'Sulle on loodud kasutajakonto rakenduses :appName.', 'user_invite_email_text' => 'Vajuta allolevale nupule, et seada parool ja ligipääs saada:', 'user_invite_email_action' => 'Sea konto parool', 'user_invite_page_welcome' => 'Tere tulemast rakendusse :appName!', 'user_invite_page_text' => 'Registreerumise lõpetamiseks ja ligipääsu saamiseks pead seadma parooli, millega edaspidi rakendusse sisse logid.', 'user_invite_page_confirm_button' => 'Kinnita parool', 'user_invite_success_login' => 'Parool seatud, nüüd on sul selle parooli abil ligipääs rakendusele :appName!', // Multi-factor Authentication 'mfa_setup' => 'Seadista mitmeastmeline autentimine', 'mfa_setup_desc' => 'Seadista mitmeastmeline autentimine, et oma kasutajakonto turvalisust tõsta.', 'mfa_setup_configured' => 'Juba seadistatud', 'mfa_setup_reconfigure' => 'Seadista ümber', 'mfa_setup_remove_confirmation' => 'Kas oled kindel, et soovid selle mitmeastmelise autentimise meetodi eemaldada?', 'mfa_setup_action' => 'Seadista', 'mfa_backup_codes_usage_limit_warning' => 'Sul on vähem kui 5 varukoodi järel. Genereeri ja hoiusta uus komplekt enne, kui nad otsa saavad, et vältida oma kasutajakontole ligipääsu kaotamist.', 'mfa_option_totp_title' => 'Mobiilirakendus', 'mfa_option_totp_desc' => 'Mitmeastmelise autentimise kasutamiseks on sul vaja TOTP-toega mobiilirakendust, nagu Google Authenticator, Authy või Microsoft Authenticator.', 'mfa_option_backup_codes_title' => 'Varukoodid', 'mfa_option_backup_codes_desc' => 'Genereerib komplekti ühekordseid tagavarakoode, mille abil saad sisselogimisel oma isikut tuvastada. Hoia neid kindlas ja turvalises kohas.', 'mfa_gen_confirm_and_enable' => 'Kinnita ja lülita sisse', 'mfa_gen_backup_codes_title' => 'Varukoodide seadistamine', 'mfa_gen_backup_codes_desc' => 'Hoiusta allolevad koodid turvalises kohas. Saad neid kasutada sisselogimisel sekundaarse autentimismeetodina.', 'mfa_gen_backup_codes_download' => 'Laadi koodid alla', 'mfa_gen_backup_codes_usage_warning' => 'Igat koodi saab ainult ühe korra kasutada', 'mfa_gen_totp_title' => 'Mobiilirakenduse seadistamine', 'mfa_gen_totp_desc' => 'Mitmeastmelise autentimise kasutamiseks on sul vaja TOTP-toega mobiilirakendust, nagu Google Authenticator, Authy või Microsoft Authenticator.', 'mfa_gen_totp_scan' => 'Alustamiseks skaneeri allolevat QR-koodi oma eelistatud rakendusega.', 'mfa_gen_totp_verify_setup' => 'Kontrolli seadistust', 'mfa_gen_totp_verify_setup_desc' => 'Veendu, et kõik toimib korrektselt, sisestades oma rakenduse genereeritud koodi allolevasse tekstikasti:', 'mfa_gen_totp_provide_code_here' => 'Sisesta rakenduse genereeritud kood siia', 'mfa_verify_access' => 'Kinnita ligipääs', 'mfa_verify_access_desc' => 'Sinu konto nõuab ligipääsuks täiendava kinnitusmeetodi abil oma isiku tuvastamist. Jätkamiseks vali üks järgnevatest meetoditest.', 'mfa_verify_no_methods' => 'Ühtegi meetodit pole seadistatud', 'mfa_verify_no_methods_desc' => 'Sinu kontole pole lisatud ühtegi mitmeastmelise autentimise meetodit. Ligipääsu saamiseks pead seadistama vähemalt ühe meetodi.', 'mfa_verify_use_totp' => 'Tuvasta mobiilirakendusega', 'mfa_verify_use_backup_codes' => 'Tuvasta varukoodiga', 'mfa_verify_backup_code' => 'Varukood', 'mfa_verify_backup_code_desc' => 'Sisesta allpool üks oma järelejäänud varukoodidest:', 'mfa_verify_backup_code_enter_here' => 'Sisesta varukood siia', 'mfa_verify_totp_desc' => 'Sisesta oma mobiilirakenduse poolt genereeritud kood allpool:', 'mfa_setup_login_notification' => 'Mitmeastmeline autentimine seadistatud. Logi nüüd uuesti sisse, kasutades seadistatud meetodit.', ];
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Users/UserRepo.php
app/Users/UserRepo.php
<?php namespace BookStack\Users; use BookStack\Access\UserInviteException; use BookStack\Access\UserInviteService; use BookStack\Activity\ActivityType; use BookStack\Entities\Tools\SlugGenerator; use BookStack\Exceptions\NotifyException; use BookStack\Exceptions\UserUpdateException; use BookStack\Facades\Activity; use BookStack\Uploads\UserAvatars; use BookStack\Users\Models\Role; use BookStack\Users\Models\User; use DB; use Exception; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Log; use Illuminate\Support\Str; class UserRepo { public function __construct( protected UserAvatars $userAvatar, protected UserInviteService $inviteService, protected SlugGenerator $slugGenerator, ) { } /** * Get a user by their email address. */ public function getByEmail(string $email): ?User { return User::query()->where('email', '=', $email)->first(); } /** * Get a user by their ID. */ public function getById(int $id): User { return User::query()->findOrFail($id); } /** * Get a user by their slug. */ public function getBySlug(string $slug): User { return User::query()->where('slug', '=', $slug)->firstOrFail(); } /** * Create a new basic instance of user with the given pre-validated data. * * @param array{name: string, email: string, password: ?string, external_auth_id: ?string, language: ?string, roles: ?array} $data */ public function createWithoutActivity(array $data, bool $emailConfirmed = false): User { $user = new User(); $user->name = $data['name']; $user->email = $data['email']; $user->password = Hash::make(empty($data['password']) ? Str::random(32) : $data['password']); $user->email_confirmed = $emailConfirmed; $user->external_auth_id = $data['external_auth_id'] ?? ''; $this->slugGenerator->regenerateForUser($user); $user->save(); if (!empty($data['language'])) { setting()->putUser($user, 'language', $data['language']); } if (isset($data['roles'])) { $this->setUserRoles($user, $data['roles']); } $this->downloadAndAssignUserAvatar($user); return $user; } /** * As per "createWithoutActivity" but records a "create" activity. * * @param array{name: string, email: string, password: ?string, external_auth_id: ?string, language: ?string, roles: ?array} $data * @throws UserInviteException */ public function create(array $data, bool $sendInvite = false): User { $user = $this->createWithoutActivity($data, true); if ($sendInvite) { $this->inviteService->sendInvitation($user); } Activity::add(ActivityType::USER_CREATE, $user); return $user; } /** * Update the given user with the given data, but do not create an activity. * * @param array{name: ?string, email: ?string, external_auth_id: ?string, password: ?string, roles: ?array<int>, language: ?string} $data * * @throws UserUpdateException */ public function updateWithoutActivity(User $user, array $data, bool $manageUsersAllowed): User { if (!empty($data['name'])) { $user->name = $data['name']; $this->slugGenerator->regenerateForUser($user); } if (!empty($data['email']) && $manageUsersAllowed) { $user->email = $data['email']; } if (!empty($data['external_auth_id']) && $manageUsersAllowed) { $user->external_auth_id = $data['external_auth_id']; } if (isset($data['roles']) && $manageUsersAllowed) { $this->setUserRoles($user, $data['roles']); } if (!empty($data['password'])) { $user->password = Hash::make($data['password']); } if (!empty($data['language'])) { setting()->putUser($user, 'language', $data['language']); } $user->save(); return $user; } /** * Update the given user with the given data. * * @param array{name: ?string, email: ?string, external_auth_id: ?string, password: ?string, roles: ?array<int>, language: ?string} $data * * @throws UserUpdateException */ public function update(User $user, array $data, bool $manageUsersAllowed): User { $user = $this->updateWithoutActivity($user, $data, $manageUsersAllowed); Activity::add(ActivityType::USER_UPDATE, $user); return $user; } /** * Remove the given user from storage, Delete all related content. * * @throws Exception */ public function destroy(User $user, ?int $newOwnerId = null): void { $this->ensureDeletable($user); $this->removeUserDependantRelations($user); $this->nullifyUserNonDependantRelations($user); $user->delete(); // Delete user profile images $this->userAvatar->destroyAllForUser($user); // Delete related activities setting()->deleteUserSettings($user->id); // Migrate or nullify ownership $newOwner = null; if (!empty($newOwnerId)) { $newOwner = User::query()->find($newOwnerId); } $this->migrateOwnership($user, $newOwner); Activity::add(ActivityType::USER_DELETE, $user); } protected function removeUserDependantRelations(User $user): void { $user->apiTokens()->delete(); $user->socialAccounts()->delete(); $user->favourites()->delete(); $user->mfaValues()->delete(); $user->watches()->delete(); $tables = ['email_confirmations', 'user_invites', 'views']; foreach ($tables as $table) { DB::table($table)->where('user_id', '=', $user->id)->delete(); } } protected function nullifyUserNonDependantRelations(User $user): void { $toNullify = [ 'attachments' => ['created_by', 'updated_by'], 'comments' => ['created_by', 'updated_by'], 'deletions' => ['deleted_by'], 'entities' => ['created_by', 'updated_by'], 'images' => ['created_by', 'updated_by'], 'imports' => ['created_by'], 'joint_permissions' => ['owner_id'], 'page_revisions' => ['created_by'], 'sessions' => ['user_id'], ]; foreach ($toNullify as $table => $columns) { foreach ($columns as $column) { DB::table($table) ->where($column, '=', $user->id) ->update([$column => null]); } } } /** * @throws NotifyException */ protected function ensureDeletable(User $user): void { if ($this->isOnlyAdmin($user)) { throw new NotifyException(trans('errors.users_cannot_delete_only_admin'), $user->getEditUrl()); } if ($user->system_name === 'public') { throw new NotifyException(trans('errors.users_cannot_delete_guest'), $user->getEditUrl()); } } /** * Migrate ownership of items in the system from one user to another. */ protected function migrateOwnership(User $fromUser, User|null $toUser): void { $newOwnerValue = $toUser ? $toUser->id : null; DB::table('entities') ->where('owned_by', '=', $fromUser->id) ->update(['owned_by' => $newOwnerValue]); } /** * Get an avatar image for a user and set it as their avatar. * Returns early if avatars disabled or not set in config. */ protected function downloadAndAssignUserAvatar(User $user): void { try { $this->userAvatar->fetchAndAssignToUser($user); } catch (Exception $e) { Log::error('Failed to save user avatar image'); } } /** * Checks if the give user is the only admin. */ protected function isOnlyAdmin(User $user): bool { if (!$user->hasSystemRole('admin')) { return false; } $adminRole = Role::getSystemRole('admin'); if ($adminRole->users()->count() > 1) { return false; } return true; } /** * Set the assigned user roles via an array of role IDs. * * @throws UserUpdateException */ protected function setUserRoles(User $user, array $roles): void { $roles = array_filter(array_values($roles)); if ($this->demotingLastAdmin($user, $roles)) { throw new UserUpdateException(trans('errors.role_cannot_remove_only_admin'), $user->getEditUrl()); } $user->roles()->sync($roles); } /** * Check if the given user is the last admin and their new roles no longer * contain the admin role. */ protected function demotingLastAdmin(User $user, array $newRoles): bool { if ($this->isOnlyAdmin($user)) { $adminRole = Role::getSystemRole('admin'); if (!in_array(strval($adminRole->id), $newRoles)) { return true; } } return false; } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Users/Controllers/UserPreferencesController.php
app/Users/Controllers/UserPreferencesController.php
<?php namespace BookStack\Users\Controllers; use BookStack\Http\Controller; use BookStack\Users\UserRepo; use Illuminate\Http\Request; class UserPreferencesController extends Controller { public function __construct( protected UserRepo $userRepo ) { } /** * Update the preferred view format for a list view of the given type. */ public function changeView(Request $request, string $type) { $valueViewTypes = ['books', 'bookshelves', 'bookshelf']; if (!in_array($type, $valueViewTypes)) { return $this->redirectToRequest($request); } $view = $request->get('view'); if (!in_array($view, ['grid', 'list'])) { $view = 'list'; } $key = $type . '_view_type'; setting()->putForCurrentUser($key, $view); return $this->redirectToRequest($request); } /** * Change the stored sort type for a particular view. */ public function changeSort(Request $request, string $type) { $validSortTypes = ['books', 'bookshelves', 'shelf_books', 'users', 'roles', 'webhooks', 'tags', 'page_revisions']; if (!in_array($type, $validSortTypes)) { return $this->redirectToRequest($request); } $sort = substr($request->get('sort') ?: 'name', 0, 50); $order = $request->get('order') === 'desc' ? 'desc' : 'asc'; $sortKey = $type . '_sort'; $orderKey = $type . '_sort_order'; setting()->putForCurrentUser($sortKey, $sort); setting()->putForCurrentUser($orderKey, $order); return $this->redirectToRequest($request); } /** * Toggle dark mode for the current user. */ public function toggleDarkMode(Request $request) { $enabled = setting()->getForCurrentUser('dark-mode-enabled'); setting()->putForCurrentUser('dark-mode-enabled', $enabled ? 'false' : 'true'); return $this->redirectToRequest($request); } /** * Update the stored section expansion preference for the given user. */ public function changeExpansion(Request $request, string $type) { $typeWhitelist = ['home-details']; if (!in_array($type, $typeWhitelist)) { return response('Invalid key', 500); } $newState = $request->get('expand', 'false'); setting()->putForCurrentUser('section_expansion#' . $type, $newState); return response('', 204); } /** * Update the favorite status for a code language. */ public function updateCodeLanguageFavourite(Request $request) { $validated = $this->validate($request, [ 'language' => ['required', 'string', 'max:20'], 'active' => ['required', 'bool'], ]); $currentFavoritesStr = setting()->getForCurrentUser('code-language-favourites', ''); $currentFavorites = array_filter(explode(',', $currentFavoritesStr)); $isFav = in_array($validated['language'], $currentFavorites); if (!$isFav && $validated['active']) { $currentFavorites[] = $validated['language']; } elseif ($isFav && !$validated['active']) { $index = array_search($validated['language'], $currentFavorites); array_splice($currentFavorites, $index, 1); } setting()->putForCurrentUser('code-language-favourites', implode(',', $currentFavorites)); return response('', 204); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Users/Controllers/UserController.php
app/Users/Controllers/UserController.php
<?php namespace BookStack\Users\Controllers; use BookStack\Access\SocialDriverManager; use BookStack\Access\UserInviteException; use BookStack\Exceptions\ImageUploadException; use BookStack\Exceptions\UserUpdateException; use BookStack\Http\Controller; use BookStack\Permissions\Permission; use BookStack\Uploads\ImageRepo; use BookStack\Users\Models\Role; use BookStack\Users\Queries\UsersAllPaginatedAndSorted; use BookStack\Users\UserRepo; use BookStack\Util\SimpleListOptions; use Exception; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Log; use Illuminate\Validation\Rules\Password; use Illuminate\Validation\ValidationException; class UserController extends Controller { public function __construct( protected UserRepo $userRepo, protected ImageRepo $imageRepo ) { } /** * Display a listing of the users. */ public function index(Request $request) { $this->checkPermission(Permission::UsersManage); $listOptions = SimpleListOptions::fromRequest($request, 'users')->withSortOptions([ 'name' => trans('common.sort_name'), 'email' => trans('auth.email'), 'created_at' => trans('common.sort_created_at'), 'updated_at' => trans('common.sort_updated_at'), 'last_activity_at' => trans('settings.users_latest_activity'), ]); $users = (new UsersAllPaginatedAndSorted())->run(20, $listOptions); $this->setPageTitle(trans('settings.users')); $users->appends($listOptions->getPaginationAppends()); return view('users.index', [ 'users' => $users, 'listOptions' => $listOptions, ]); } /** * Show the form for creating a new user. */ public function create() { $this->checkPermission(Permission::UsersManage); $authMethod = config('auth.method'); $roles = Role::query()->orderBy('display_name', 'asc')->get(); $this->setPageTitle(trans('settings.users_add_new')); return view('users.create', ['authMethod' => $authMethod, 'roles' => $roles]); } /** * Store a new user in storage. * * @throws ValidationException */ public function store(Request $request) { $this->checkPermission(Permission::UsersManage); $authMethod = config('auth.method'); $sendInvite = ($request->get('send_invite', 'false') === 'true'); $externalAuth = $authMethod === 'ldap' || $authMethod === 'saml2' || $authMethod === 'oidc'; $passwordRequired = ($authMethod === 'standard' && !$sendInvite); $validationRules = [ 'name' => ['required', 'max:100'], 'email' => ['required', 'email', 'unique:users,email'], 'language' => ['string', 'max:15', 'alpha_dash'], 'roles' => ['array'], 'roles.*' => ['integer'], 'password' => $passwordRequired ? ['required', Password::default()] : null, 'password-confirm' => $passwordRequired ? ['required', 'same:password'] : null, 'external_auth_id' => $externalAuth ? ['required'] : null, ]; $validated = $this->validate($request, array_filter($validationRules)); try { DB::transaction(function () use ($validated, $sendInvite) { $this->userRepo->create($validated, $sendInvite); }); } catch (UserInviteException $e) { Log::error("Failed to send user invite with error: {$e->getMessage()}"); $this->showErrorNotification(trans('errors.users_could_not_send_invite')); return redirect('/settings/users/create')->withInput(); } return redirect('/settings/users'); } /** * Show the form for editing the specified user. */ public function edit(int $id, SocialDriverManager $socialDriverManager) { $this->checkPermission(Permission::UsersManage); $user = $this->userRepo->getById($id); $user->load(['apiTokens', 'mfaValues']); $authMethod = ($user->system_name) ? 'system' : config('auth.method'); $activeSocialDrivers = $socialDriverManager->getActive(); $mfaMethods = $user->mfaValues->groupBy('method'); $this->setPageTitle(trans('settings.user_profile')); $roles = Role::query()->orderBy('display_name', 'asc')->get(); return view('users.edit', [ 'user' => $user, 'activeSocialDrivers' => $activeSocialDrivers, 'mfaMethods' => $mfaMethods, 'authMethod' => $authMethod, 'roles' => $roles, ]); } /** * Update the specified user in storage. * * @throws UserUpdateException * @throws ImageUploadException * @throws ValidationException */ public function update(Request $request, int $id) { $this->preventAccessInDemoMode(); $this->checkPermission(Permission::UsersManage); $validated = $this->validate($request, [ 'name' => ['min:1', 'max:100'], 'email' => ['min:2', 'email', 'unique:users,email,' . $id], 'password' => ['required_with:password_confirm', Password::default()], 'password-confirm' => ['same:password', 'required_with:password'], 'language' => ['string', 'max:15', 'alpha_dash'], 'roles' => ['array'], 'roles.*' => ['integer'], 'external_auth_id' => ['string'], 'profile_image' => array_merge(['nullable'], $this->getImageValidationRules()), ]); $user = $this->userRepo->getById($id); $this->userRepo->update($user, $validated, true); // Save profile image if in request if ($request->hasFile('profile_image')) { $imageUpload = $request->file('profile_image'); $this->imageRepo->destroyImage($user->avatar); $image = $this->imageRepo->saveNew($imageUpload, 'user', $user->id); $user->image_id = $image->id; $user->save(); } // Delete the profile image if reset option is in request if ($request->has('profile_image_reset')) { $this->imageRepo->destroyImage($user->avatar); $user->image_id = 0; $user->save(); } return redirect('/settings/users'); } /** * Show the user delete page. */ public function delete(int $id) { $this->checkPermission(Permission::UsersManage); $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. * * @throws Exception */ public function destroy(Request $request, int $id) { $this->preventAccessInDemoMode(); $this->checkPermission(Permission::UsersManage); $user = $this->userRepo->getById($id); $newOwnerId = intval($request->get('new_owner_id')) ?: null; $this->userRepo->destroy($user, $newOwnerId); return redirect('/settings/users'); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Users/Controllers/UserAccountController.php
app/Users/Controllers/UserAccountController.php
<?php namespace BookStack\Users\Controllers; use BookStack\Access\SocialDriverManager; use BookStack\Http\Controller; use BookStack\Permissions\Permission; use BookStack\Permissions\PermissionApplicator; use BookStack\Settings\UserNotificationPreferences; use BookStack\Settings\UserShortcutMap; use BookStack\Uploads\ImageRepo; use BookStack\Users\UserRepo; use Closure; use Illuminate\Http\Request; use Illuminate\Validation\Rules\Password; class UserAccountController extends Controller { public function __construct( protected UserRepo $userRepo, ) { $this->middleware(function (Request $request, Closure $next) { $this->preventGuestAccess(); return $next($request); }); } /** * Redirect the root my-account path to the main/first category. * Required as a controller method, instead of the Route::redirect helper, * to ensure the URL is generated correctly. */ public function redirect() { return redirect('/my-account/profile'); } /** * Show the profile form interface. */ public function showProfile() { $this->setPageTitle(trans('preferences.profile')); return view('users.account.profile', [ 'model' => user(), 'category' => 'profile', ]); } /** * Handle the submission of the user profile form. */ public function updateProfile(Request $request, ImageRepo $imageRepo) { $this->preventAccessInDemoMode(); $user = user(); $validated = $this->validate($request, [ 'name' => ['min:2', 'max:100'], 'email' => ['min:2', 'email', 'unique:users,email,' . $user->id], 'language' => ['string', 'max:15', 'alpha_dash'], 'profile_image' => array_merge(['nullable'], $this->getImageValidationRules()), ]); $this->userRepo->update($user, $validated, userCan(Permission::UsersManage)); // Save the profile image if in request if ($request->hasFile('profile_image')) { $imageUpload = $request->file('profile_image'); $imageRepo->destroyImage($user->avatar); $image = $imageRepo->saveNew($imageUpload, 'user', $user->id); $user->image_id = $image->id; $user->save(); } // Delete the profile image if the reset option is in request if ($request->has('profile_image_reset')) { $imageRepo->destroyImage($user->avatar); $user->image_id = 0; $user->save(); } return redirect('/my-account/profile'); } /** * Show the user-specific interface shortcuts. */ public function showShortcuts() { $shortcuts = UserShortcutMap::fromUserPreferences(); $enabled = setting()->getForCurrentUser('ui-shortcuts-enabled', false); $this->setPageTitle(trans('preferences.shortcuts_interface')); return view('users.account.shortcuts', [ 'category' => 'shortcuts', 'shortcuts' => $shortcuts, 'enabled' => $enabled, ]); } /** * Update the user-specific interface shortcuts. */ public function updateShortcuts(Request $request) { $enabled = $request->get('enabled') === 'true'; $providedShortcuts = $request->get('shortcut', []); $shortcuts = new UserShortcutMap($providedShortcuts); setting()->putForCurrentUser('ui-shortcuts', $shortcuts->toJson()); setting()->putForCurrentUser('ui-shortcuts-enabled', $enabled); $this->showSuccessNotification(trans('preferences.shortcuts_update_success')); return redirect('/my-account/shortcuts'); } /** * Show the notification preferences for the current user. */ public function showNotifications(PermissionApplicator $permissions) { $this->checkPermission(Permission::ReceiveNotifications); $preferences = (new UserNotificationPreferences(user())); $query = user()->watches()->getQuery(); $query = $permissions->restrictEntityRelationQuery($query, 'watches', 'watchable_id', 'watchable_type'); $query = $permissions->filterDeletedFromEntityRelationQuery($query, 'watches', 'watchable_id', 'watchable_type'); $watches = $query->with('watchable')->paginate(20); $this->setPageTitle(trans('preferences.notifications')); return view('users.account.notifications', [ 'category' => 'notifications', 'preferences' => $preferences, 'watches' => $watches, ]); } /** * Update the notification preferences for the current user. */ public function updateNotifications(Request $request) { $this->preventAccessInDemoMode(); $this->checkPermission(Permission::ReceiveNotifications); $data = $this->validate($request, [ 'preferences' => ['required', 'array'], 'preferences.*' => ['required', 'string'], ]); $preferences = (new UserNotificationPreferences(user())); $preferences->updateFromSettingsArray($data['preferences']); $this->showSuccessNotification(trans('preferences.notifications_update_success')); return redirect('/my-account/notifications'); } /** * Show the view for the "Access & Security" account options. */ public function showAuth(SocialDriverManager $socialDriverManager) { $mfaMethods = user()->mfaValues()->get()->groupBy('method'); $this->setPageTitle(trans('preferences.auth')); return view('users.account.auth', [ 'category' => 'auth', 'mfaMethods' => $mfaMethods, 'authMethod' => config('auth.method'), 'activeSocialDrivers' => $socialDriverManager->getActive(), ]); } /** * Handle the submission for the auth change password form. */ public function updatePassword(Request $request) { $this->preventAccessInDemoMode(); if (config('auth.method') !== 'standard') { $this->showPermissionError(); } $validated = $this->validate($request, [ 'password' => ['required_with:password_confirm', Password::default()], 'password-confirm' => ['same:password', 'required_with:password'], ]); $this->userRepo->update(user(), $validated, false); $this->showSuccessNotification(trans('preferences.auth_change_password_success')); return redirect('/my-account/auth'); } /** * Show the user self-delete page. */ public function delete() { $this->setPageTitle(trans('preferences.delete_my_account')); return view('users.account.delete', [ 'category' => 'profile', ]); } /** * Remove the current user from the system. */ public function destroy(Request $request) { $this->preventAccessInDemoMode(); $requestNewOwnerId = intval($request->get('new_owner_id')) ?: null; $newOwnerId = userCan(Permission::UsersManage) ? $requestNewOwnerId : null; $this->userRepo->destroy(user(), $newOwnerId); return redirect('/'); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Users/Controllers/UserProfileController.php
app/Users/Controllers/UserProfileController.php
<?php namespace BookStack\Users\Controllers; use BookStack\Activity\ActivityQueries; use BookStack\Http\Controller; use BookStack\Users\Queries\UserContentCounts; use BookStack\Users\Queries\UserRecentlyCreatedContent; use BookStack\Users\UserRepo; class UserProfileController extends Controller { public function __construct( protected UserRepo $userRepo, protected ActivityQueries $activityQueries, protected UserContentCounts $contentCounts, protected UserRecentlyCreatedContent $recentlyCreatedContent ) { } /** * Show the user profile page. */ public function show(string $slug) { $user = $this->userRepo->getBySlug($slug); $userActivity = $this->activityQueries->userActivity($user); $recentlyCreated = $this->recentlyCreatedContent->run($user, 5); $assetCounts = $this->contentCounts->run($user); $this->setPageTitle($user->name); return view('users.profile', [ 'user' => $user, 'activity' => $userActivity, 'recentlyCreated' => $recentlyCreated, 'assetCounts' => $assetCounts, ]); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Users/Controllers/RoleApiController.php
app/Users/Controllers/RoleApiController.php
<?php namespace BookStack\Users\Controllers; use BookStack\Http\ApiController; use BookStack\Permissions\Permission; use BookStack\Permissions\PermissionsRepo; use BookStack\Users\Models\Role; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; class RoleApiController extends ApiController { protected array $fieldsToExpose = [ 'display_name', 'description', 'mfa_enforced', 'external_auth_id', 'created_at', 'updated_at', ]; protected array $rules = [ 'create' => [ 'display_name' => ['required', 'string', 'min:3', 'max:180'], 'description' => ['string', 'max:180'], 'mfa_enforced' => ['boolean'], 'external_auth_id' => ['string', 'max:180'], 'permissions' => ['array'], 'permissions.*' => ['string'], ], 'update' => [ 'display_name' => ['string', 'min:3', 'max:180'], 'description' => ['string', 'max:180'], 'mfa_enforced' => ['boolean'], 'external_auth_id' => ['string', 'max:180'], 'permissions' => ['array'], 'permissions.*' => ['string'], ] ]; public function __construct( protected PermissionsRepo $permissionsRepo ) { // Checks for all endpoints in this controller $this->middleware(function ($request, $next) { $this->checkPermission(Permission::UserRolesManage); return $next($request); }); } /** * Get a listing of roles in the system. * Requires permission to manage roles. */ public function list() { $roles = Role::query()->select(['*']) ->withCount(['users', 'permissions']); return $this->apiListingResponse($roles, [ ...$this->fieldsToExpose, 'permissions_count', 'users_count', ]); } /** * Create a new role in the system. * Permissions should be provided as an array of permission name strings. * Requires permission to manage roles. */ public function create(Request $request) { $data = $this->validate($request, $this->rules()['create']); $role = null; DB::transaction(function () use ($data, &$role) { $role = $this->permissionsRepo->saveNewRole($data); }); $this->singleFormatter($role); return response()->json($role); } /** * View the details of a single role. * Provides the permissions and a high-level list of the users assigned. * Requires permission to manage roles. */ public function read(string $id) { $role = $this->permissionsRepo->getRoleById($id); $this->singleFormatter($role); return response()->json($role); } /** * Update an existing role in the system. * Permissions should be provided as an array of permission name strings. * An empty "permissions" array would clear granted permissions. * In many cases, where permissions are changed, you'll want to fetch the existing * permissions and then modify before providing in your update request. * Requires permission to manage roles. */ public function update(Request $request, string $id) { $data = $this->validate($request, $this->rules()['update']); $role = $this->permissionsRepo->updateRole($id, $data); $this->singleFormatter($role); return response()->json($role); } /** * Delete a role from the system. * Requires permission to manage roles. */ public function delete(string $id) { $this->permissionsRepo->deleteRole(intval($id)); return response('', 204); } /** * Format the given role model for a single-result display. */ protected function singleFormatter(Role $role): void { $role->load('users:id,name,slug'); $role->unsetRelation('permissions'); $role->setAttribute('permissions', $role->permissions()->orderBy('name', 'asc')->pluck('name')); $role->makeVisible(['users', 'permissions']); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Users/Controllers/UserSearchController.php
app/Users/Controllers/UserSearchController.php
<?php namespace BookStack\Users\Controllers; use BookStack\Http\Controller; use BookStack\Permissions\Permission; use BookStack\Users\Models\User; use Illuminate\Database\Eloquent\Collection; use Illuminate\Http\Request; class UserSearchController extends Controller { /** * Search users in the system, with the response formatted * for use in a select-style list. */ public function forSelect(Request $request) { $hasPermission = !user()->isGuest() && ( userCan(Permission::UsersManage) || userCan(Permission::RestrictionsManageOwn) || userCan(Permission::RestrictionsManageAll) ); if (!$hasPermission) { $this->showPermissionError(); } $search = $request->get('search', ''); $query = User::query() ->orderBy('name', 'asc') ->take(20); if (!empty($search)) { $query->where('name', 'like', '%' . $search . '%'); } /** @var Collection<User> $users */ $users = $query->get(); return view('form.user-select-list', [ 'users' => $users, ]); } /** * Search users in the system, with the response formatted * for use in a list of mentions. */ public function forMentions(Request $request) { $hasPermission = !user()->isGuest() && ( userCan(Permission::CommentCreateAll) || userCan(Permission::CommentUpdate) ); if (!$hasPermission) { $this->showPermissionError(); } $search = $request->get('search', ''); $query = User::query() ->orderBy('name', 'asc') ->take(20); if (!empty($search)) { $query->where('name', 'like', '%' . $search . '%'); } /** @var Collection<User> $users */ $users = $query->get(); return view('form.user-mention-list', [ 'users' => $users, ]); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Users/Controllers/UserApiController.php
app/Users/Controllers/UserApiController.php
<?php namespace BookStack\Users\Controllers; use BookStack\Entities\EntityExistsRule; use BookStack\Exceptions\UserUpdateException; use BookStack\Http\ApiController; use BookStack\Permissions\Permission; use BookStack\Users\Models\User; use BookStack\Users\UserRepo; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; use Illuminate\Validation\Rules\Password; use Illuminate\Validation\Rules\Unique; class UserApiController extends ApiController { protected UserRepo $userRepo; protected array $fieldsToExpose = [ 'email', 'created_at', 'updated_at', 'last_activity_at', 'external_auth_id', ]; public function __construct(UserRepo $userRepo) { $this->userRepo = $userRepo; // Checks for all endpoints in this controller $this->middleware(function ($request, $next) { $this->checkPermission(Permission::UsersManage); $this->preventAccessInDemoMode(); return $next($request); }); } protected function rules(?int $userId = null): array { return [ 'create' => [ 'name' => ['required', 'string', 'min:1', 'max:100'], 'email' => [ 'required', 'string', 'email', 'min:2', new Unique('users', 'email'), ], 'external_auth_id' => ['string'], 'language' => ['string', 'max:15', 'alpha_dash'], 'password' => ['string', Password::default()], 'roles' => ['array'], 'roles.*' => ['integer'], 'send_invite' => ['boolean'], ], 'update' => [ 'name' => ['string', 'min:1', 'max:100'], 'email' => [ 'string', 'email', 'min:2', (new Unique('users', 'email'))->ignore($userId), ], 'external_auth_id' => ['string'], 'language' => ['string', 'max:15', 'alpha_dash'], 'password' => ['string', Password::default()], 'roles' => ['array'], 'roles.*' => ['integer'], ], 'delete' => [ 'migrate_ownership_id' => ['integer', 'exists:users,id'], ], ]; } /** * Get a listing of users in the system. * Requires permission to manage users. */ public function list() { $users = User::query()->select(['users.*']) ->scopes('withLastActivityAt') ->with(['avatar']); return $this->apiListingResponse($users, [ 'id', 'name', 'slug', 'email', 'external_auth_id', 'created_at', 'updated_at', 'last_activity_at', ], [$this->listFormatter(...)]); } /** * Create a new user in the system. * Requires permission to manage users. */ public function create(Request $request) { $data = $this->validate($request, $this->rules()['create']); $sendInvite = boolval($data['send_invite'] ?? false) === true; $user = null; DB::transaction(function () use ($data, $sendInvite, &$user) { $user = $this->userRepo->create($data, $sendInvite); }); $this->singleFormatter($user); return response()->json($user); } /** * View the details of a single user. * Requires permission to manage users. */ public function read(string $id) { $user = $this->userRepo->getById($id); $this->singleFormatter($user); return response()->json($user); } /** * Update an existing user in the system. * Requires permission to manage users. * * @throws UserUpdateException */ public function update(Request $request, string $id) { $data = $this->validate($request, $this->rules($id)['update']); $user = $this->userRepo->getById($id); $this->userRepo->update($user, $data, userCan(Permission::UsersManage)); $this->singleFormatter($user); return response()->json($user); } /** * Delete a user from the system. * Can optionally accept a user id via `migrate_ownership_id` to indicate * who should be the new owner of their related content. * Requires permission to manage users. */ public function delete(Request $request, string $id) { $user = $this->userRepo->getById($id); $newOwnerId = $request->get('migrate_ownership_id', null); $this->userRepo->destroy($user, $newOwnerId); return response('', 204); } /** * Format the given user model for single-result display. */ protected function singleFormatter(User $user) { $this->listFormatter($user); $user->load('roles:id,display_name'); $user->makeVisible(['roles']); } /** * Format the given user model for a listing multi-result display. */ protected function listFormatter(User $user) { $user->makeVisible($this->fieldsToExpose); $user->setAttribute('profile_url', $user->getProfileUrl()); $user->setAttribute('edit_url', $user->getEditUrl()); $user->setAttribute('avatar_url', $user->getAvatar()); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Users/Controllers/RoleController.php
app/Users/Controllers/RoleController.php
<?php namespace BookStack\Users\Controllers; use BookStack\Exceptions\PermissionsException; use BookStack\Http\Controller; use BookStack\Permissions\Permission; use BookStack\Permissions\PermissionsRepo; use BookStack\Users\Models\Role; use BookStack\Users\Queries\RolesAllPaginatedAndSorted; use BookStack\Util\SimpleListOptions; use Exception; use Illuminate\Http\Request; class RoleController extends Controller { public function __construct( protected PermissionsRepo $permissionsRepo ) { } /** * Show a listing of the roles in the system. */ public function index(Request $request) { $this->checkPermission(Permission::UserRolesManage); $listOptions = SimpleListOptions::fromRequest($request, 'roles')->withSortOptions([ 'display_name' => trans('common.sort_name'), 'users_count' => trans('settings.roles_assigned_users'), 'permissions_count' => trans('settings.roles_permissions_provided'), 'created_at' => trans('common.sort_created_at'), 'updated_at' => trans('common.sort_updated_at'), ]); $roles = (new RolesAllPaginatedAndSorted())->run(20, $listOptions); $roles->appends($listOptions->getPaginationAppends()); $this->setPageTitle(trans('settings.roles')); return view('settings.roles.index', [ 'roles' => $roles, 'listOptions' => $listOptions, ]); } /** * Show the form to create a new role. */ public function create(Request $request) { $this->checkPermission(Permission::UserRolesManage); /** @var ?Role $role */ $role = null; if ($request->has('copy_from')) { $role = Role::query()->find($request->get('copy_from')); } if ($role) { $role->display_name .= ' (' . trans('common.copy') . ')'; } $this->setPageTitle(trans('settings.role_create')); return view('settings.roles.create', ['role' => $role]); } /** * Store a new role in the system. */ public function store(Request $request) { $this->checkPermission(Permission::UserRolesManage); $data = $this->validate($request, [ 'display_name' => ['required', 'min:3', 'max:180'], 'description' => ['max:180'], 'external_auth_id' => ['string', 'max:180'], 'permissions' => ['array'], 'mfa_enforced' => ['string'], ]); $data['permissions'] = array_keys($data['permissions'] ?? []); $data['mfa_enforced'] = ($data['mfa_enforced'] ?? 'false') === 'true'; $this->permissionsRepo->saveNewRole($data); return redirect('/settings/roles'); } /** * Show the form for editing a user role. */ public function edit(string $id) { $this->checkPermission(Permission::UserRolesManage); $role = $this->permissionsRepo->getRoleById($id); $this->setPageTitle(trans('settings.role_edit')); return view('settings.roles.edit', ['role' => $role]); } /** * Updates a user role. */ public function update(Request $request, string $id) { $this->checkPermission(Permission::UserRolesManage); $data = $this->validate($request, [ 'display_name' => ['required', 'min:3', 'max:180'], 'description' => ['max:180'], 'external_auth_id' => ['string', 'max:180'], 'permissions' => ['array'], 'mfa_enforced' => ['string'], ]); $data['permissions'] = array_keys($data['permissions'] ?? []); $data['mfa_enforced'] = ($data['mfa_enforced'] ?? 'false') === 'true'; $this->permissionsRepo->updateRole($id, $data); return redirect('/settings/roles'); } /** * Show the view to delete a role. * Offers the chance to migrate users. */ public function showDelete(string $id) { $this->checkPermission(Permission::UserRolesManage); $role = $this->permissionsRepo->getRoleById($id); $roles = $this->permissionsRepo->getAllRolesExcept($role); $blankRole = $role->newInstance(['display_name' => trans('settings.role_delete_no_migration')]); $roles->prepend($blankRole); $this->setPageTitle(trans('settings.role_delete')); 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) { $this->checkPermission(Permission::UserRolesManage); try { $migrateRoleId = intval($request->get('migrate_role_id') ?: "0"); $this->permissionsRepo->deleteRole($id, $migrateRoleId); } catch (PermissionsException $e) { $this->showErrorNotification($e->getMessage()); return redirect("/settings/roles/delete/{$id}"); } return redirect('/settings/roles'); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Users/Models/User.php
app/Users/Models/User.php
<?php namespace BookStack\Users\Models; use BookStack\Access\Mfa\MfaValue; use BookStack\Access\Notifications\ResetPasswordNotification; use BookStack\Access\SocialAccount; use BookStack\Activity\Models\Favourite; use BookStack\Activity\Models\Loggable; use BookStack\Activity\Models\Watch; use BookStack\Api\ApiToken; use BookStack\App\Model; use BookStack\App\SluggableInterface; use BookStack\Permissions\Permission; use BookStack\Translation\LocaleDefinition; use BookStack\Translation\LocaleManager; use BookStack\Uploads\Image; use Carbon\Carbon; use Exception; use Illuminate\Auth\Authenticatable; use Illuminate\Auth\Passwords\CanResetPassword; use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Notifications\Notifiable; use Illuminate\Support\Collection; /** * @property int $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 * @property Collection $mfaValues * @property ?Image $avatar */ class User extends Model implements AuthenticatableContract, CanResetPasswordContract, Loggable, SluggableInterface { use HasFactory; use Authenticatable; use CanResetPassword; use Notifiable; /** * The database table used by the model. * * @var string */ protected $table = 'users'; /** * The attributes that are mass assignable. * * @var list<string> */ protected $fillable = ['name', 'email']; protected $casts = ['last_activity_at' => 'datetime']; /** * The attributes excluded from the model's JSON form. * * @var list<string> */ protected $hidden = [ 'password', 'remember_token', 'system_name', 'email_confirmed', 'external_auth_id', 'email', 'created_at', 'updated_at', 'image_id', 'roles', 'avatar', 'user_id', 'pivot', ]; /** * This holds the user's permissions when loaded. */ protected ?Collection $permissions; /** * This holds the user's avatar URL when loaded to prevent re-calculating within the same request. */ protected string $avatarUrl = ''; /** * Returns the default public user. * Fetches from the container as a singleton to effectively cache at an app level. */ public static function getGuest(): self { return app()->make('users.default'); } /** * Check if the user is the default public user. */ public function isGuest(): bool { return $this->system_name === 'public'; } /** * Check if the user has general access to the application. */ public function hasAppAccess(): bool { return !$this->isGuest() || setting('app-public'); } /** * The roles that belong to the user. * * @return BelongsToMany<Role, $this> */ public function roles(): BelongsToMany { return $this->belongsToMany(Role::class); } /** * Check if the user has a role. */ public function hasRole($roleId): bool { return $this->roles->pluck('id')->contains($roleId); } /** * Check if the user has a role. */ public function hasSystemRole(string $roleSystemName): bool { return $this->roles->pluck('system_name')->contains($roleSystemName); } /** * Attach the default system role to this user. */ public function attachDefaultRole(): void { $roleId = intval(setting('registration-role')); if ($roleId && $this->roles()->where('id', '=', $roleId)->count() === 0) { $this->roles()->attach($roleId); } } /** * Check if the user has a particular permission. */ public function can(string|Permission $permission): bool { $permissionName = is_string($permission) ? $permission : $permission->value; return $this->permissions()->contains($permissionName); } /** * Get all permissions belonging to the current user. */ protected function permissions(): Collection { if (isset($this->permissions)) { return $this->permissions; } $this->permissions = $this->newQuery()->getConnection()->table('role_user', 'ru') ->select('role_permissions.name as name')->distinct() ->leftJoin('permission_role', 'ru.role_id', '=', 'permission_role.role_id') ->leftJoin('role_permissions', 'permission_role.permission_id', '=', 'role_permissions.id') ->where('ru.user_id', '=', $this->id) ->pluck('name'); return $this->permissions; } /** * Clear any cached permissions in this instance. */ public function clearPermissionCache(): void { $this->permissions = null; } /** * Attach a role to this user. */ public function attachRole(Role $role): void { $this->roles()->attach($role->id); $this->unsetRelation('roles'); } /** * Get the social account associated with this user. */ public function socialAccounts(): HasMany { return $this->hasMany(SocialAccount::class); } /** * Check if the user has a social account, * If a driver is passed, it checks for that single account type. */ public function hasSocialAccount(string $socialDriver = ''): bool { if (empty($socialDriver)) { return $this->socialAccounts()->count() > 0; } return $this->socialAccounts()->where('driver', '=', $socialDriver)->exists(); } /** * Returns a URL to the user's avatar. */ public function getAvatar(int $size = 50): string { $default = url('/user_avatar.png'); $imageId = $this->image_id; if ($imageId === 0 || $imageId === '0' || $imageId === null) { return $default; } if (!empty($this->avatarUrl)) { return $this->avatarUrl; } try { $avatar = $this->avatar?->getThumb($size, $size, false) ?? $default; } catch (Exception $err) { $avatar = $default; } $this->avatarUrl = $avatar; return $avatar; } /** * Get the avatar for the user. */ public function avatar(): BelongsTo { return $this->belongsTo(Image::class, 'image_id'); } /** * Get the API tokens assigned to this user. */ public function apiTokens(): HasMany { return $this->hasMany(ApiToken::class); } /** * Get the favourite instances for this user. */ public function favourites(): HasMany { return $this->hasMany(Favourite::class); } /** * Get the MFA values belonging to this use. */ public function mfaValues(): HasMany { return $this->hasMany(MfaValue::class); } /** * Get the tracked entity watches for this user. */ public function watches(): HasMany { return $this->hasMany(Watch::class); } /** * Get the last activity time for this user. */ public function scopeWithLastActivityAt(Builder $query) { $query->addSelect(['activities.created_at as last_activity_at']) ->leftJoinSub(function (\Illuminate\Database\Query\Builder $query) { $query->from('activities')->select('user_id') ->selectRaw('max(created_at) as created_at') ->groupBy('user_id'); }, 'activities', 'users.id', '=', 'activities.user_id'); } /** * Get the url for editing this user. */ public function getEditUrl(string $path = ''): string { $uri = '/settings/users/' . $this->id . '/' . trim($path, '/'); return url(rtrim($uri, '/')); } /** * Get the url that links to this user's profile. */ public function getProfileUrl(): string { return url('/user/' . $this->slug); } /** * Get a shortened version of the user's name. */ public function getShortName(int $chars = 8): string { if (mb_strlen($this->name) <= $chars) { return $this->name; } $splitName = explode(' ', $this->name); if (mb_strlen($splitName[0]) <= $chars) { return $splitName[0]; } return mb_substr($this->name, 0, max($chars - 2, 0)) . '…'; } /** * Get the locale for this user. */ public function getLocale(): LocaleDefinition { return app()->make(LocaleManager::class)->getForUser($this); } /** * Send the password reset notification. * * @param string $token * * @return void */ public function sendPasswordResetNotification($token) { $this->notify(new ResetPasswordNotification($token)); } /** * {@inheritdoc} */ public function logDescriptor(): string { return "({$this->id}) {$this->name}"; } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Users/Models/Role.php
app/Users/Models/Role.php
<?php namespace BookStack\Users\Models; use BookStack\Activity\Models\Loggable; use BookStack\App\Model; use BookStack\Permissions\Models\EntityPermission; use BookStack\Permissions\Models\JointPermission; use BookStack\Permissions\Models\RolePermission; use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\HasMany; /** * Class Role. * * @property int $id * @property string $display_name * @property string $description * @property string $external_auth_id * @property string $system_name * @property bool $mfa_enforced * @property Collection $users */ class Role extends Model implements Loggable { use HasFactory; protected $fillable = ['display_name', 'description', 'external_auth_id', 'mfa_enforced']; protected $hidden = ['pivot']; protected $casts = [ 'mfa_enforced' => 'boolean', ]; /** * The roles that belong to the role. */ public function users(): BelongsToMany { return $this->belongsToMany(User::class)->orderBy('name', 'asc'); } /** * Get all related JointPermissions. */ public function jointPermissions(): HasMany { return $this->hasMany(JointPermission::class); } /** * The RolePermissions that belong to the role. * @return BelongsToMany<RolePermission, $this> */ public function permissions(): BelongsToMany { return $this->belongsToMany(RolePermission::class, 'permission_role', 'role_id', 'permission_id') ->select(['id', 'name']); } /** * Get the entity permissions assigned to this role. */ public function entityPermissions(): HasMany { return $this->hasMany(EntityPermission::class); } /** * Check if this role has a permission. */ public function hasPermission(string $permissionName): bool { $permissions = $this->getRelationValue('permissions'); foreach ($permissions as $permission) { if ($permission->getRawAttribute('name') === $permissionName) { return true; } } return false; } /** * Add a permission to this role. */ public function attachPermission(RolePermission $permission) { $this->permissions()->attach($permission->id); } /** * Detach a single permission from this role. */ public function detachPermission(RolePermission $permission) { $this->permissions()->detach([$permission->id]); } /** * Get the role of the specified display name. */ public static function getRole(string $displayName): ?self { return static::query()->where('display_name', '=', $displayName)->first(); } /** * Get the role object for the specified system role. */ public static function getSystemRole(string $systemName): ?self { static $cache = []; if (!isset($cache[$systemName])) { $cache[$systemName] = static::query()->where('system_name', '=', $systemName)->first(); } return $cache[$systemName]; } /** * {@inheritdoc} */ public function logDescriptor(): string { return "({$this->id}) {$this->display_name}"; } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Users/Models/OwnableInterface.php
app/Users/Models/OwnableInterface.php
<?php namespace BookStack\Users\Models; interface OwnableInterface { public function getOwnerFieldName(): string; }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Users/Models/HasCreatorAndUpdater.php
app/Users/Models/HasCreatorAndUpdater.php
<?php namespace BookStack\Users\Models; use Illuminate\Database\Eloquent\Relations\BelongsTo; /** * @property int $created_by * @property int $updated_by * @property ?User $createdBy * @property ?User $updatedBy */ trait HasCreatorAndUpdater { /** * Relation for the user that created this entity. */ public function createdBy(): BelongsTo { return $this->belongsTo(User::class, 'created_by'); } /** * Relation for the user that updated this entity. */ public function updatedBy(): BelongsTo { return $this->belongsTo(User::class, 'updated_by'); } public function getOwnerFieldName(): string { return 'created_by'; } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Users/Queries/UserContentCounts.php
app/Users/Queries/UserContentCounts.php
<?php namespace BookStack\Users\Queries; use BookStack\Entities\Queries\EntityQueries; use BookStack\Users\Models\User; /** * Get asset created counts for the given user. */ class UserContentCounts { public function __construct( protected EntityQueries $queries, ) { } /** * @return array{pages: int, chapters: int, books: int, shelves: int} */ public function run(User $user): array { $createdBy = ['created_by' => $user->id]; return [ 'pages' => $this->queries->pages->visibleForList()->where($createdBy)->count(), 'chapters' => $this->queries->chapters->visibleForList()->where($createdBy)->count(), 'books' => $this->queries->books->visibleForList()->where($createdBy)->count(), 'shelves' => $this->queries->shelves->visibleForList()->where($createdBy)->count(), ]; } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Users/Queries/UsersAllPaginatedAndSorted.php
app/Users/Queries/UsersAllPaginatedAndSorted.php
<?php namespace BookStack\Users\Queries; use BookStack\Users\Models\User; use BookStack\Util\SimpleListOptions; use Illuminate\Pagination\LengthAwarePaginator; /** * Get all the users with their permissions in a paginated format. * Note: Due to the use of email search this should only be used when * user is assumed to be trusted. (Admin users). * Email search can be abused to extract email addresses. */ class UsersAllPaginatedAndSorted { public function run(int $count, SimpleListOptions $listOptions): LengthAwarePaginator { $sort = $listOptions->getSort(); if ($sort === 'created_at') { $sort = 'users.created_at'; } $query = User::query()->select(['*']) ->scopes(['withLastActivityAt']) ->with(['roles', 'avatar']) ->withCount('mfaValues') ->orderBy($sort, $listOptions->getOrder()); if ($listOptions->getSearch()) { $term = '%' . $listOptions->getSearch() . '%'; $query->where(function ($query) use ($term) { $query->where('name', 'like', $term) ->orWhere('email', 'like', $term); }); } return $query->paginate($count); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Users/Queries/RolesAllPaginatedAndSorted.php
app/Users/Queries/RolesAllPaginatedAndSorted.php
<?php namespace BookStack\Users\Queries; use BookStack\Users\Models\Role; use BookStack\Util\SimpleListOptions; use Illuminate\Pagination\LengthAwarePaginator; /** * Get all the roles in the system in a paginated format. */ class RolesAllPaginatedAndSorted { public function run(int $count, SimpleListOptions $listOptions): LengthAwarePaginator { $sort = $listOptions->getSort(); if ($sort === 'created_at') { $sort = 'roles.created_at'; } $query = Role::query()->select(['*']) ->withCount(['users', 'permissions']) ->orderBy($sort, $listOptions->getOrder()); if ($listOptions->getSearch()) { $term = '%' . $listOptions->getSearch() . '%'; $query->where(function ($query) use ($term) { $query->where('display_name', 'like', $term) ->orWhere('description', 'like', $term); }); } return $query->paginate($count); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Users/Queries/UserRecentlyCreatedContent.php
app/Users/Queries/UserRecentlyCreatedContent.php
<?php namespace BookStack\Users\Queries; use BookStack\Entities\Queries\EntityQueries; use BookStack\Users\Models\User; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Collection; /** * Get the recently created content for the provided user. */ class UserRecentlyCreatedContent { public function __construct( protected EntityQueries $queries, ) { } /** * @return array{pages: Collection, chapters: Collection, books: Collection, shelves: Collection} */ public function run(User $user, int $count): array { $query = function (Builder $query) use ($user, $count) { return $query->orderBy('created_at', 'desc') ->where('created_by', '=', $user->id) ->take($count) ->get(); }; return [ 'pages' => $query($this->queries->pages->visibleForList()->where('draft', '=', false)), 'chapters' => $query($this->queries->chapters->visibleForList()), 'books' => $query($this->queries->books->visibleForList()), 'shelves' => $query($this->queries->shelves->visibleForList()), ]; } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Exceptions/BookStackExceptionHandlerPage.php
app/Exceptions/BookStackExceptionHandlerPage.php
<?php namespace BookStack\Exceptions; use BookStack\App\AppVersion; use Illuminate\Contracts\Foundation\ExceptionRenderer; class BookStackExceptionHandlerPage implements ExceptionRenderer { public function render($throwable) { return view('errors.debug', [ 'error' => $throwable->getMessage(), 'errorClass' => get_class($throwable), 'trace' => $throwable->getTraceAsString(), 'environment' => $this->getEnvironment(), ])->render(); } protected function safeReturn(callable $callback, $default = null) { try { return $callback(); } catch (\Exception $e) { return $default; } } protected function getEnvironment(): array { return [ 'PHP Version' => phpversion(), 'BookStack Version' => $this->safeReturn(function () { return AppVersion::get(); }, 'unknown'), 'Theme Configured' => $this->safeReturn(function () { return config('view.theme'); }) ?? 'None', ]; } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Exceptions/UserRegistrationException.php
app/Exceptions/UserRegistrationException.php
<?php namespace BookStack\Exceptions; class UserRegistrationException extends NotifyException { }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Exceptions/LoginAttemptInvalidUserException.php
app/Exceptions/LoginAttemptInvalidUserException.php
<?php namespace BookStack\Exceptions; class LoginAttemptInvalidUserException extends LoginAttemptException { }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Exceptions/FileUploadException.php
app/Exceptions/FileUploadException.php
<?php namespace BookStack\Exceptions; class FileUploadException extends PrettyException { }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Exceptions/SocialDriverNotConfigured.php
app/Exceptions/SocialDriverNotConfigured.php
<?php namespace BookStack\Exceptions; class SocialDriverNotConfigured extends PrettyException { }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Exceptions/NotFoundException.php
app/Exceptions/NotFoundException.php
<?php namespace BookStack\Exceptions; class NotFoundException extends PrettyException { /** * NotFoundException constructor. */ public function __construct($message = 'Item not found') { parent::__construct($message, 404); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Exceptions/UserTokenExpiredException.php
app/Exceptions/UserTokenExpiredException.php
<?php namespace BookStack\Exceptions; class UserTokenExpiredException extends \Exception { public $userId; /** * UserTokenExpiredException constructor. * * @param string $message * @param int $userId */ public function __construct(string $message, int $userId) { $this->userId = $userId; parent::__construct($message); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Exceptions/NotifyException.php
app/Exceptions/NotifyException.php
<?php namespace BookStack\Exceptions; use Exception; use Illuminate\Contracts\Support\Responsable; use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; class NotifyException extends Exception implements Responsable, HttpExceptionInterface { public $message; public string $redirectLocation; protected int $status; public function __construct(string $message, string $redirectLocation = '/', int $status = 500) { $this->message = $message; $this->redirectLocation = $redirectLocation; $this->status = $status; parent::__construct(); } /** * Get the desired HTTP status code for this exception. */ public function getStatusCode(): int { return $this->status; } /** * Get the desired HTTP headers for this exception. */ public function getHeaders(): array { return []; } /** * Send the response for this type of exception. * * {@inheritdoc} */ public function toResponse($request) { $message = $this->getMessage(); // Front-end JSON handling. API-side handling managed via handler. if ($request->wantsJson()) { return response()->json(['error' => $message], $this->getStatusCode()); } if (!empty($message)) { session()->flash('error', $message); } return redirect($this->redirectLocation); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Exceptions/ZipValidationException.php
app/Exceptions/ZipValidationException.php
<?php namespace BookStack\Exceptions; class ZipValidationException extends \Exception { public function __construct( public array $errors ) { parent::__construct(); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Exceptions/HttpFetchException.php
app/Exceptions/HttpFetchException.php
<?php namespace BookStack\Exceptions; use Exception; class HttpFetchException extends Exception { }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Exceptions/PrettyException.php
app/Exceptions/PrettyException.php
<?php namespace BookStack\Exceptions; use Exception; use Illuminate\Contracts\Support\Responsable; use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; class PrettyException extends Exception implements Responsable, HttpExceptionInterface { protected ?string $subtitle = null; protected ?string $details = null; /** * Render a response for when this exception occurs. * * {@inheritdoc} */ public function toResponse($request) { $code = $this->getStatusCode(); return response()->view('errors.' . $code, [ 'message' => $this->getMessage(), 'subtitle' => $this->subtitle, 'details' => $this->details, ], $code); } public function setSubtitle(string $subtitle): self { $this->subtitle = $subtitle; return $this; } public function setDetails(string $details): self { $this->details = $details; return $this; } /** * Get the desired HTTP status code for this exception. */ public function getStatusCode(): int { return ($this->getCode() === 0) ? 500 : $this->getCode(); } /** * Get the desired HTTP headers for this exception. */ public function getHeaders(): array { return []; } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Exceptions/PermissionsException.php
app/Exceptions/PermissionsException.php
<?php namespace BookStack\Exceptions; use Exception; class PermissionsException extends Exception { }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Exceptions/Handler.php
app/Exceptions/Handler.php
<?php namespace BookStack\Exceptions; use Illuminate\Auth\AuthenticationException; use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Illuminate\Http\Exceptions\PostTooLargeException; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Http\Response; use Illuminate\Validation\ValidationException; use Symfony\Component\ErrorHandler\Error\FatalError; use Symfony\Component\HttpFoundation\Response as SymfonyResponse; use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; use Throwable; class Handler extends ExceptionHandler { /** * A list of the exception types that are not reported. * * @var array<int, class-string<Throwable>> */ protected $dontReport = [ NotFoundException::class, StoppedAuthenticationException::class, ]; /** * A list of the inputs that are never flashed to the session on validation exceptions. * * @var array<int, string> */ protected $dontFlash = [ 'current_password', 'password', 'password_confirmation', ]; /** * A function to run upon out of memory. * If it returns a response, that will be provided back to the request * upon an out of memory event. * * @var ?callable(): ?Response */ protected $onOutOfMemory = null; /** * Report or log an exception. * * @param Throwable $exception * * @return void *@throws Throwable * */ public function report(Throwable $exception) { parent::report($exception); } /** * Render an exception into an HTTP response. * * @param Request $request */ public function render($request, Throwable $e): SymfonyResponse { if ($e instanceof FatalError && str_contains($e->getMessage(), 'bytes exhausted (tried to allocate') && $this->onOutOfMemory) { $response = call_user_func($this->onOutOfMemory); if ($response) { return $response; } } if ($e instanceof PostTooLargeException) { $e = new NotifyException(trans('errors.server_post_limit'), '/', 413); } if ($this->isApiRequest($request)) { return $this->renderApiException($e); } return parent::render($request, $e); } /** * Provide a function to be called when an out of memory event occurs. * If the callable returns a response, this response will be returned * to the request upon error. */ public function prepareForOutOfMemory(callable $onOutOfMemory): void { $this->onOutOfMemory = $onOutOfMemory; } /** * Forget the current out of memory handler, if existing. */ public function forgetOutOfMemoryHandler(): void { $this->onOutOfMemory = null; } /** * Check if the given request is an API request. */ protected function isApiRequest(Request $request): bool { return str_starts_with($request->path(), 'api/'); } /** * Render an exception when the API is in use. */ protected function renderApiException(Throwable $e): JsonResponse { $code = 500; $headers = []; if ($e instanceof HttpExceptionInterface) { $code = $e->getStatusCode(); $headers = $e->getHeaders(); } if ($e instanceof ModelNotFoundException) { $code = 404; } $responseData = [ 'error' => [ 'message' => $e->getMessage(), ], ]; if ($e instanceof ValidationException) { $responseData['error']['message'] = 'The given data was invalid.'; $responseData['error']['validation'] = $e->errors(); $code = $e->status; } $responseData['error']['code'] = $code; return new JsonResponse($responseData, $code, $headers); } /** * Convert an authentication exception into an unauthenticated response. * * @param Request $request */ protected function unauthenticated($request, AuthenticationException $exception): SymfonyResponse { if ($request->expectsJson()) { return response()->json(['error' => 'Unauthenticated.'], 401); } return redirect()->guest('login'); } /** * Convert a validation exception into a JSON response. * * @param Request $request */ protected function invalidJson($request, ValidationException $exception): JsonResponse { return response()->json($exception->errors(), $exception->status); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Exceptions/UserTokenNotFoundException.php
app/Exceptions/UserTokenNotFoundException.php
<?php namespace BookStack\Exceptions; class UserTokenNotFoundException extends \Exception { }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Exceptions/SocialSignInException.php
app/Exceptions/SocialSignInException.php
<?php namespace BookStack\Exceptions; class SocialSignInException extends NotifyException { }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Exceptions/UserUpdateException.php
app/Exceptions/UserUpdateException.php
<?php namespace BookStack\Exceptions; class UserUpdateException extends NotifyException { }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Exceptions/ImageUploadException.php
app/Exceptions/ImageUploadException.php
<?php namespace BookStack\Exceptions; class ImageUploadException extends PrettyException { }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Exceptions/LoginAttemptException.php
app/Exceptions/LoginAttemptException.php
<?php namespace BookStack\Exceptions; class LoginAttemptException extends \Exception { }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Exceptions/ZipImportException.php
app/Exceptions/ZipImportException.php
<?php namespace BookStack\Exceptions; class ZipImportException extends \Exception { public function __construct( public array $errors ) { $message = "Import failed with errors:" . implode("\n", $this->errors); parent::__construct($message); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Exceptions/StoppedAuthenticationException.php
app/Exceptions/StoppedAuthenticationException.php
<?php namespace BookStack\Exceptions; use BookStack\Access\LoginService; use BookStack\Users\Models\User; use Illuminate\Contracts\Support\Responsable; use Illuminate\Http\Request; class StoppedAuthenticationException extends \Exception implements Responsable { public function __construct( protected User $user, protected LoginService $loginService ) { parent::__construct(); } /** * {@inheritdoc} */ public function toResponse($request) { $redirect = '/login'; if ($this->loginService->awaitingEmailConfirmation($this->user)) { return $this->awaitingEmailConfirmationResponse($request); } if ($this->loginService->needsMfaVerification($this->user)) { $redirect = '/mfa/verify'; } return redirect($redirect); } /** * Provide an error response for when the current user's email is not confirmed * in a system which requires it. */ protected function awaitingEmailConfirmationResponse(Request $request) { if ($request->wantsJson()) { return response()->json([ 'error' => [ 'code' => 401, 'message' => trans('errors.email_confirmation_awaiting'), ], ], 401); } if (session()->pull('sent-email-confirmation') === true) { return redirect('/register/confirm'); } return redirect('/register/confirm/awaiting'); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Exceptions/MoveOperationException.php
app/Exceptions/MoveOperationException.php
<?php namespace BookStack\Exceptions; use Exception; class MoveOperationException extends Exception { }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Exceptions/SocialSignInAccountNotUsed.php
app/Exceptions/SocialSignInAccountNotUsed.php
<?php namespace BookStack\Exceptions; class SocialSignInAccountNotUsed extends SocialSignInException { }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Exceptions/LdapException.php
app/Exceptions/LdapException.php
<?php namespace BookStack\Exceptions; class LdapException extends PrettyException { }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Exceptions/ZipExportException.php
app/Exceptions/ZipExportException.php
<?php namespace BookStack\Exceptions; class ZipExportException extends \Exception { }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Exceptions/PdfExportException.php
app/Exceptions/PdfExportException.php
<?php namespace BookStack\Exceptions; class PdfExportException extends \Exception { }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Exceptions/SamlException.php
app/Exceptions/SamlException.php
<?php namespace BookStack\Exceptions; class SamlException extends NotifyException { }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Exceptions/JsonDebugException.php
app/Exceptions/JsonDebugException.php
<?php namespace BookStack\Exceptions; use Exception; use Illuminate\Http\JsonResponse; use Illuminate\Contracts\Support\Responsable; class JsonDebugException extends Exception implements Responsable { protected array $data; /** * JsonDebugException constructor. */ public function __construct(array $data) { $this->data = $data; parent::__construct(); } /** * Convert this exception into a response. * We add a manual data conversion to UTF8 to ensure any binary data is presentable as a JSON string. */ public function toResponse($request): JsonResponse { $cleaned = mb_convert_encoding($this->data, 'UTF-8'); return response()->json($cleaned); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Exceptions/ConfirmationEmailException.php
app/Exceptions/ConfirmationEmailException.php
<?php namespace BookStack\Exceptions; class ConfirmationEmailException extends NotifyException { }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Exceptions/LoginAttemptEmailNeededException.php
app/Exceptions/LoginAttemptEmailNeededException.php
<?php namespace BookStack\Exceptions; class LoginAttemptEmailNeededException extends LoginAttemptException { }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Exceptions/ThemeException.php
app/Exceptions/ThemeException.php
<?php namespace BookStack\Exceptions; class ThemeException extends \Exception { }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Exceptions/ApiAuthException.php
app/Exceptions/ApiAuthException.php
<?php namespace BookStack\Exceptions; use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; class ApiAuthException extends \Exception implements HttpExceptionInterface { protected int $status; public function __construct(string $message, int $statusCode = 401) { $this->status = $statusCode; parent::__construct($message, $statusCode); } public function getStatusCode(): int { return $this->status; } public function getHeaders(): array { return []; } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Http/HttpRequestService.php
app/Http/HttpRequestService.php
<?php namespace BookStack\Http; use GuzzleHttp\Client; use GuzzleHttp\Handler\MockHandler; use GuzzleHttp\HandlerStack; use GuzzleHttp\Middleware; use GuzzleHttp\Psr7\Request as GuzzleRequest; use GuzzleHttp\Psr7\Response; use Psr\Http\Client\ClientInterface; class HttpRequestService { protected ?HandlerStack $handler = null; /** * Build a new http client for sending requests on. */ public function buildClient(int $timeout, array $options = []): ClientInterface { $defaultOptions = [ 'timeout' => $timeout, 'handler' => $this->handler, ]; return new Client(array_merge($options, $defaultOptions)); } /** * Create a new JSON http request for use with a client. */ public function jsonRequest(string $method, string $uri, array $data): GuzzleRequest { $headers = ['Content-Type' => 'application/json']; return new GuzzleRequest($method, $uri, $headers, json_encode($data)); } /** * Mock any http clients built from this service, and response with the given responses. * Returns history which can then be queried. * @link https://docs.guzzlephp.org/en/stable/testing.html#history-middleware */ public function mockClient(array $responses = [], bool $pad = true): HttpClientHistory { // By default, we pad out the responses with 10 successful values so that requests will be // properly recorded for inspection. Otherwise, we can't later check if we're received // too many requests. if ($pad) { $response = new Response(200, [], 'success'); $responses = array_merge($responses, array_fill(0, 10, $response)); } $container = []; $history = Middleware::history($container); $mock = new MockHandler($responses); $this->handler = HandlerStack::create($mock); $this->handler->push($history, 'history'); return new HttpClientHistory($container); } /** * Clear mocking that has been set up for clients. */ public function clearMocking(): void { $this->handler = null; } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Http/Controller.php
app/Http/Controller.php
<?php namespace BookStack\Http; use BookStack\Activity\Models\Loggable; use BookStack\App\Model; use BookStack\Exceptions\NotifyException; use BookStack\Facades\Activity; use BookStack\Permissions\Permission; use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Http\JsonResponse; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; use Illuminate\Routing\Controller as BaseController; abstract class Controller extends BaseController { use DispatchesJobs; use ValidatesRequests; /** * Check if the current user is signed in. */ protected function isSignedIn(): bool { return auth()->check(); } /** * Stops the application and shows a permission error if the application is in demo mode. */ protected function preventAccessInDemoMode(): void { if (config('app.env') === 'demo') { $this->showPermissionError(); } } /** * Adds the page title into the view. */ public function setPageTitle(string $title): void { view()->share('pageTitle', $title); } /** * On a permission error redirect to home and display the error as a notification. * * @throws NotifyException */ protected function showPermissionError(string $redirectLocation = '/'): never { $message = request()->wantsJson() ? trans('errors.permissionJson') : trans('errors.permission'); throw new NotifyException($message, $redirectLocation, 403); } /** * Checks that the current user has the given permission otherwise throw an exception. */ protected function checkPermission(string|Permission $permission): void { if (!user() || !user()->can($permission)) { $this->showPermissionError(); } } /** * Prevent access for guest users beyond this point. */ protected function preventGuestAccess(): void { if (user()->isGuest()) { $this->showPermissionError(); } } /** * Check the current user's permissions against an ownable item otherwise throw an exception. */ protected function checkOwnablePermission(string|Permission $permission, Model $ownable, string $redirectLocation = '/'): void { if (!userCan($permission, $ownable)) { $this->showPermissionError($redirectLocation); } } /** * Check if a user has a permission or bypass the permission * check if the given callback resolves true. */ protected function checkPermissionOr(string|Permission $permission, callable $callback): void { if ($callback() !== true) { $this->checkPermission($permission); } } /** * Check if the current user has a permission or bypass if the provided user * id matches the current user. */ protected function checkPermissionOrCurrentUser(string|Permission $permission, int $userId): void { $this->checkPermissionOr($permission, function () use ($userId) { return $userId === user()->id; }); } /** * Send back a JSON error message. */ protected function jsonError(string $messageText = '', int $statusCode = 500): JsonResponse { return response()->json(['message' => $messageText, 'status' => 'error'], $statusCode); } /** * Create and return a new download response factory using the current request. */ protected function download(): DownloadResponseFactory { return new DownloadResponseFactory(request()); } /** * Show a positive, successful notification to the user on the next view load. */ protected function showSuccessNotification(string $message): void { session()->flash('success', $message); } /** * Show a warning notification to the user on the next view load. */ protected function showWarningNotification(string $message): void { session()->flash('warning', $message); } /** * Show an error notification to the user on the next view load. */ protected function showErrorNotification(string $message): void { session()->flash('error', $message); } /** * Log an activity in the system. */ protected function logActivity(string $type, string|Loggable $detail = ''): void { Activity::add($type, $detail); } /** * Get the validation rules for image files. */ protected function getImageValidationRules(): array { return ['image_extension', 'mimes:jpeg,png,gif,webp,avif', 'max:' . (config('app.upload_limit') * 1000)]; } /** * Redirect to the URL provided in the request as a '_return' parameter. * Will check that the parameter leads to a URL under the root path of the system. */ protected function redirectToRequest(Request $request): RedirectResponse { $basePath = url('/'); $returnUrl = $request->input('_return') ?? $basePath; if (!str_starts_with($returnUrl, $basePath)) { return redirect($basePath); } return redirect($returnUrl); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Http/Request.php
app/Http/Request.php
<?php namespace BookStack\Http; use Illuminate\Http\Request as LaravelRequest; class Request extends LaravelRequest { /** * Override the default request methods to get the scheme and host * to directly use the custom APP_URL, if set. */ public function getSchemeAndHttpHost(): string { $appUrl = config('app.url', null); if ($appUrl) { return implode('/', array_slice(explode('/', $appUrl), 0, 3)); } return parent::getSchemeAndHttpHost(); } /** * Override the default request methods to get the base URL * to directly use the custom APP_URL, if set. * The base URL never ends with a / but should start with one if not empty. */ public function getBaseUrl(): string { $appUrl = config('app.url', null); if ($appUrl) { $parsedBaseUrl = rtrim(implode('/', array_slice(explode('/', $appUrl), 3)), '/'); return empty($parsedBaseUrl) ? '' : ('/' . $parsedBaseUrl); } return parent::getBaseUrl(); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Http/RangeSupportedStream.php
app/Http/RangeSupportedStream.php
<?php namespace BookStack\Http; use BookStack\Util\WebSafeMimeSniffer; use Illuminate\Http\Request; /** * Helper wrapper for range-based stream response handling. * Much of this used symfony/http-foundation as a reference during build. * URL: https://github.com/symfony/http-foundation/blob/v6.0.20/BinaryFileResponse.php * License: MIT license, Copyright (c) Fabien Potencier. */ class RangeSupportedStream { protected string $sniffContent = ''; protected array $responseHeaders = []; protected int $responseStatus = 200; protected int $responseLength = 0; protected int $responseOffset = 0; public function __construct( protected $stream, protected int $fileSize, Request $request, ) { $this->responseLength = $this->fileSize; $this->parseRequest($request); } /** * Sniff a mime type from the stream. */ public function sniffMime(string $extension = ''): string { $offset = min(2000, $this->fileSize); $this->sniffContent = fread($this->stream, $offset); return (new WebSafeMimeSniffer())->sniff($this->sniffContent, $extension); } /** * Output the current stream to stdout before closing out the stream. */ public function outputAndClose(): void { // End & flush the output buffer, if we're in one, otherwise we still use memory. // Output buffer may or may not exist depending on PHP `output_buffering` setting. // Ignore in testing since output buffers are used to gather a response. if (!empty(ob_get_status()) && !app()->runningUnitTests()) { ob_end_clean(); } $outStream = fopen('php://output', 'w'); $sniffLength = strlen($this->sniffContent); $bytesToWrite = $this->responseLength; if ($sniffLength > 0 && $this->responseOffset < $sniffLength) { $sniffEnd = min($sniffLength, $bytesToWrite + $this->responseOffset); $sniffOutLength = $sniffEnd - $this->responseOffset; $sniffOutput = substr($this->sniffContent, $this->responseOffset, $sniffOutLength); fwrite($outStream, $sniffOutput); $bytesToWrite -= $sniffOutLength; } else if ($this->responseOffset !== 0) { fseek($this->stream, $this->responseOffset); } stream_copy_to_stream($this->stream, $outStream, $bytesToWrite); fclose($this->stream); fclose($outStream); } public function getResponseHeaders(): array { return $this->responseHeaders; } public function getResponseStatus(): int { return $this->responseStatus; } protected function parseRequest(Request $request): void { $this->responseHeaders['Accept-Ranges'] = $request->isMethodSafe() ? 'bytes' : 'none'; $range = $this->getRangeFromRequest($request); if ($range) { [$start, $end] = $range; if ($start < 0 || $start > $end) { $this->responseStatus = 416; $this->responseHeaders['Content-Range'] = sprintf('bytes */%s', $this->fileSize); } else { $this->responseLength = $end < $this->fileSize ? $end - $start + 1 : -1; $this->responseOffset = $start; $this->responseStatus = 206; $this->responseHeaders['Content-Range'] = sprintf('bytes %s-%s/%s', $start, $end, $this->fileSize); $this->responseHeaders['Content-Length'] = $end - $start + 1; } } if ($request->isMethod('HEAD')) { $this->responseLength = 0; } } protected function getRangeFromRequest(Request $request): ?array { $range = $request->headers->get('Range'); if (!$range || !$request->isMethod('GET') || !str_starts_with($range, 'bytes=')) { return null; } if ($request->headers->has('If-Range')) { return null; } [$start, $end] = explode('-', substr($range, 6), 2) + [0]; $end = ('' === $end) ? $this->fileSize - 1 : (int) $end; if ('' === $start) { $start = $this->fileSize - $end; $end = $this->fileSize - 1; } else { $start = (int) $start; } $end = min($end, $this->fileSize - 1); return [$start, $end]; } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Http/HttpClientHistory.php
app/Http/HttpClientHistory.php
<?php namespace BookStack\Http; use GuzzleHttp\Psr7\Request as GuzzleRequest; class HttpClientHistory { public function __construct( protected &$container ) { } public function requestCount(): int { return count($this->container); } public function requestAt(int $index): ?GuzzleRequest { return $this->container[$index]['request'] ?? null; } public function latestRequest(): ?GuzzleRequest { return $this->requestAt($this->requestCount() - 1); } public function all(): array { return $this->container; } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Http/DownloadResponseFactory.php
app/Http/DownloadResponseFactory.php
<?php namespace BookStack\Http; use Illuminate\Http\Request; use Illuminate\Http\Response; use Symfony\Component\HttpFoundation\StreamedResponse; class DownloadResponseFactory { public function __construct( protected Request $request, ) { } /** * Create a response that directly forces a download in the browser. */ public function directly(string $content, string $fileName): Response { return response()->make($content, 200, $this->getHeaders($fileName, strlen($content))); } /** * Create a response that forces a download, from a given stream of content. */ public function streamedDirectly($stream, string $fileName, int $fileSize): StreamedResponse { $rangeStream = new RangeSupportedStream($stream, $fileSize, $this->request); $headers = array_merge($this->getHeaders($fileName, $fileSize), $rangeStream->getResponseHeaders()); return response()->stream( fn() => $rangeStream->outputAndClose(), $rangeStream->getResponseStatus(), $headers, ); } /** * Create a response that downloads the given file via a stream. * Has the option to delete the provided file once the stream is closed. */ public function streamedFileDirectly(string $filePath, string $fileName, bool $deleteAfter = false): StreamedResponse { $fileSize = filesize($filePath); $stream = fopen($filePath, 'r'); if ($deleteAfter) { // Delete the given file if it still exists after the app terminates $callback = function () use ($filePath) { if (file_exists($filePath)) { unlink($filePath); } }; // We watch both app terminate and php shutdown to cover both normal app termination // as well as other potential scenarios (connection termination). app()->terminating($callback); register_shutdown_function($callback); } return $this->streamedDirectly($stream, $fileName, $fileSize); } /** * Create a file download response that provides the file with a content-type * correct for the file, in a way so the browser can show the content in browser, * for a given content stream. */ public function streamedInline($stream, string $fileName, int $fileSize): StreamedResponse { $rangeStream = new RangeSupportedStream($stream, $fileSize, $this->request); $mime = $rangeStream->sniffMime(pathinfo($fileName, PATHINFO_EXTENSION)); $headers = array_merge($this->getHeaders($fileName, $fileSize, $mime), $rangeStream->getResponseHeaders()); return response()->stream( fn() => $rangeStream->outputAndClose(), $rangeStream->getResponseStatus(), $headers, ); } /** * Create a response that provides the given file via a stream with detected content-type. * Has the option to delete the provided file once the stream is closed. */ public function streamedFileInline(string $filePath, ?string $fileName = null): StreamedResponse { $fileSize = filesize($filePath); $stream = fopen($filePath, 'r'); if ($fileName === null) { $fileName = basename($filePath); } return $this->streamedInline($stream, $fileName, $fileSize); } /** * Get the common headers to provide for a download response. */ protected function getHeaders(string $fileName, int $fileSize, string $mime = 'application/octet-stream'): array { $disposition = ($mime === 'application/octet-stream') ? 'attachment' : 'inline'; $downloadName = str_replace('"', '', $fileName); return [ 'Content-Type' => $mime, 'Content-Length' => $fileSize, 'Content-Disposition' => "{$disposition}; filename=\"{$downloadName}\"", 'X-Content-Type-Options' => 'nosniff', ]; } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Http/Kernel.php
app/Http/Kernel.php
<?php namespace BookStack\Http; use Illuminate\Foundation\Http\Kernel as HttpKernel; class Kernel extends HttpKernel { /** * The application's global HTTP middleware stack. * These middleware are run during every request to your application. * * @var list<class-string> */ protected $middleware = [ \BookStack\Http\Middleware\PreventRequestsDuringMaintenance::class, \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, \BookStack\Http\Middleware\TrimStrings::class, \BookStack\Http\Middleware\TrustProxies::class, \BookStack\Http\Middleware\PreventResponseCaching::class, ]; /** * The application's route middleware groups. * * @var array<string, array<int, class-string>> */ protected $middlewareGroups = [ 'web' => [ \BookStack\Http\Middleware\ApplyCspRules::class, \BookStack\Http\Middleware\EncryptCookies::class, \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, \BookStack\Http\Middleware\StartSessionExtended::class, \Illuminate\View\Middleware\ShareErrorsFromSession::class, \BookStack\Http\Middleware\VerifyCsrfToken::class, \BookStack\Http\Middleware\CheckEmailConfirmed::class, \BookStack\Http\Middleware\RunThemeActions::class, \BookStack\Http\Middleware\Localization::class, ], 'api' => [ \BookStack\Http\Middleware\ThrottleApiRequests::class, \BookStack\Http\Middleware\EncryptCookies::class, \BookStack\Http\Middleware\StartSessionIfCookieExists::class, \BookStack\Http\Middleware\ApiAuthenticate::class, \BookStack\Http\Middleware\CheckEmailConfirmed::class, ], ]; /** * The application's middleware aliases. * * @var array<string, class-string> */ protected $middlewareAliases = [ 'auth' => \BookStack\Http\Middleware\Authenticate::class, 'can' => \BookStack\Http\Middleware\CheckUserHasPermission::class, 'guest' => \BookStack\Http\Middleware\RedirectIfAuthenticated::class, 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 'guard' => \BookStack\Http\Middleware\CheckGuard::class, 'mfa-setup' => \BookStack\Http\Middleware\AuthenticatedOrPendingMfa::class, ]; }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Http/ApiController.php
app/Http/ApiController.php
<?php namespace BookStack\Http; use BookStack\Api\ListingResponseBuilder; use Illuminate\Database\Eloquent\Builder; use Illuminate\Http\JsonResponse; abstract class ApiController extends Controller { /** * The validation rules for this controller. * Can alternative be defined in a rules() method is they need to be dynamic. * * @var array<string, array<string, string[]>> */ protected array $rules = []; /** * Provide a paginated listing JSON response in a standard format * taking into account any pagination parameters passed by the user. */ protected function apiListingResponse(Builder $query, array $fields, array $modifiers = []): JsonResponse { $listing = new ListingResponseBuilder($query, request(), $fields); foreach ($modifiers as $modifier) { $listing->modifyResults($modifier); } return $listing->toResponse(); } /** * Get the validation rules for this controller. * Defaults to a $rules property but can be a rules() method. */ public function getValidationRules(): array { return $this->rules(); } /** * Get the validation rules for the actions in this controller. * Defaults to a $rules property but can be a rules() method. */ protected function rules(): array { return $this->rules; } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Http/Middleware/ApiAuthenticate.php
app/Http/Middleware/ApiAuthenticate.php
<?php namespace BookStack\Http\Middleware; use BookStack\Exceptions\ApiAuthException; use BookStack\Permissions\Permission; use Closure; use Illuminate\Http\Request; class ApiAuthenticate { /** * Handle an incoming request. * * @throws ApiAuthException */ public function handle(Request $request, Closure $next) { // Validate the token and it's users API access $this->ensureAuthorizedBySessionOrToken(); return $next($request); } /** * Ensure the current user can access authenticated API routes, either via existing session * authentication or via API Token authentication. * * @throws ApiAuthException */ protected function ensureAuthorizedBySessionOrToken(): void { // Return if the user is already found to be signed in via session-based auth. // This is to make it easy to browser the API via browser after just logging into the system. if (!user()->isGuest() || session()->isStarted()) { if (!$this->sessionUserHasApiAccess()) { throw new ApiAuthException(trans('errors.api_user_no_api_permission'), 403); } return; } // Set our api guard to be the default for this request lifecycle. auth()->shouldUse('api'); // Validate the token and it's users API access auth()->authenticate(); } /** * Check if the active session user has API access. */ protected function sessionUserHasApiAccess(): bool { $hasApiPermission = user()->can(Permission::AccessApi); return $hasApiPermission && user()->hasAppAccess(); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Http/Middleware/Localization.php
app/Http/Middleware/Localization.php
<?php namespace BookStack\Http\Middleware; use BookStack\Translation\LocaleManager; use Closure; class Localization { public function __construct( protected LocaleManager $localeManager ) { } /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * * @return mixed */ public function handle($request, Closure $next) { // Share details of the user's locale for use in views $userLocale = $this->localeManager->getForUser(user()); view()->share('locale', $userLocale); // Set locale for system components app()->setLocale($userLocale->appLocale()); return $next($request); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Http/Middleware/CheckEmailConfirmed.php
app/Http/Middleware/CheckEmailConfirmed.php
<?php namespace BookStack\Http\Middleware; use BookStack\Access\EmailConfirmationService; use BookStack\Users\Models\User; use Closure; /** * Check that the user's email address is confirmed. * * As of v21.08 this is technically not required but kept as a prevention * to log out any users that may be logged in but in an "awaiting confirmation" state. * We'll keep this for a while until it'd be very unlikely for a user to be upgrading from * a pre-v21.08 version. * * Ideally we'd simply invalidate all existing sessions upon update but that has * proven to be a lot more difficult than expected. */ class CheckEmailConfirmed { protected $confirmationService; public function __construct(EmailConfirmationService $confirmationService) { $this->confirmationService = $confirmationService; } /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * * @return mixed */ public function handle($request, Closure $next) { /** @var User $user */ $user = auth()->user(); if (auth()->check() && !$user->email_confirmed && $this->confirmationService->confirmationRequired()) { auth()->logout(); return redirect()->to('/'); } return $next($request); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Http/Middleware/RunThemeActions.php
app/Http/Middleware/RunThemeActions.php
<?php namespace BookStack\Http\Middleware; use BookStack\Facades\Theme; use BookStack\Theming\ThemeEvents; use Closure; class RunThemeActions { /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * * @return mixed */ public function handle($request, Closure $next) { $earlyResponse = Theme::dispatch(ThemeEvents::WEB_MIDDLEWARE_BEFORE, $request); if (!is_null($earlyResponse)) { return $earlyResponse; } $response = $next($request); $response = Theme::dispatch(ThemeEvents::WEB_MIDDLEWARE_AFTER, $request, $response) ?? $response; return $response; } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Http/Middleware/Authenticate.php
app/Http/Middleware/Authenticate.php
<?php namespace BookStack\Http\Middleware; use Closure; use Illuminate\Http\Request; class Authenticate { /** * Handle an incoming request. */ public function handle(Request $request, Closure $next) { if (!user()->hasAppAccess()) { if ($request->ajax()) { return response('Unauthorized.', 401); } return redirect()->guest(url('/login')); } return $next($request); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Http/Middleware/RedirectIfAuthenticated.php
app/Http/Middleware/RedirectIfAuthenticated.php
<?php namespace BookStack\Http\Middleware; use BookStack\App\Providers\RouteServiceProvider; use Closure; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Symfony\Component\HttpFoundation\Response; class RedirectIfAuthenticated { /** * Handle an incoming request. * * @param Closure(Request): (Response) $next */ public function handle(Request $request, Closure $next, string ...$guards): Response { $guards = empty($guards) ? [null] : $guards; foreach ($guards as $guard) { if (Auth::guard($guard)->check()) { return redirect(RouteServiceProvider::HOME); } } return $next($request); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Http/Middleware/ThrottleApiRequests.php
app/Http/Middleware/ThrottleApiRequests.php
<?php namespace BookStack\Http\Middleware; use Illuminate\Routing\Middleware\ThrottleRequests as Middleware; class ThrottleApiRequests extends Middleware { /** * Resolve the number of attempts if the user is authenticated or not. */ protected function resolveMaxAttempts($request, $maxAttempts): int { return (int) config('api.requests_per_minute'); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Http/Middleware/TrustProxies.php
app/Http/Middleware/TrustProxies.php
<?php namespace BookStack\Http\Middleware; use Closure; use Illuminate\Http\Middleware\TrustProxies as Middleware; use Illuminate\Http\Request; class TrustProxies extends Middleware { /** * The trusted proxies for this application. * * @var array<int,string>|string|null */ protected $proxies; /** * The headers that should be used to detect proxies. * * @var int */ protected $headers = Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_HOST | Request::HEADER_X_FORWARDED_PORT | Request::HEADER_X_FORWARDED_PROTO | Request::HEADER_X_FORWARDED_AWS_ELB; /** * Handle the request, Set the correct user-configured proxy information. * * @param Request $request * @param Closure $next * * @return mixed */ public function handle(Request $request, Closure $next) { $setProxies = config('app.proxies'); if ($setProxies !== '**' && $setProxies !== '*' && $setProxies !== '') { $setProxies = explode(',', $setProxies); } $this->proxies = $setProxies; return parent::handle($request, $next); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Http/Middleware/PreventResponseCaching.php
app/Http/Middleware/PreventResponseCaching.php
<?php namespace BookStack\Http\Middleware; use Closure; use Symfony\Component\HttpFoundation\Response; class PreventResponseCaching { /** * Paths to ignore when preventing response caching. */ protected array $ignoredPathPrefixes = [ 'theme/', ]; /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * * @return mixed */ public function handle($request, Closure $next) { /** @var Response $response */ $response = $next($request); $path = $request->path(); foreach ($this->ignoredPathPrefixes as $ignoredPath) { if (str_starts_with($path, $ignoredPath)) { return $response; } } $response->headers->set('Cache-Control', 'no-cache, no-store, private'); $response->headers->set('Expires', 'Sun, 12 Jul 2015 19:01:00 GMT'); return $response; } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Http/Middleware/AuthenticatedOrPendingMfa.php
app/Http/Middleware/AuthenticatedOrPendingMfa.php
<?php namespace BookStack\Http\Middleware; use BookStack\Access\LoginService; use BookStack\Access\Mfa\MfaSession; use Closure; class AuthenticatedOrPendingMfa { protected $loginService; protected $mfaSession; public function __construct(LoginService $loginService, MfaSession $mfaSession) { $this->loginService = $loginService; $this->mfaSession = $mfaSession; } /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * * @return mixed */ public function handle($request, Closure $next) { $user = auth()->user(); $loggedIn = $user !== null; $lastAttemptUser = $this->loginService->getLastLoginAttemptUser(); if ($loggedIn || ($lastAttemptUser && $this->mfaSession->isPendingMfaSetup($lastAttemptUser))) { return $next($request); } return redirect()->to(url('/login')); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Http/Middleware/CheckUserHasPermission.php
app/Http/Middleware/CheckUserHasPermission.php
<?php namespace BookStack\Http\Middleware; use BookStack\Permissions\Permission; use Closure; use Illuminate\Http\Request; class CheckUserHasPermission { /** * Handle an incoming request. * * @return mixed */ public function handle(Request $request, Closure $next, string|Permission $permission) { if (!user()->can($permission)) { return $this->errorResponse($request); } return $next($request); } protected function errorResponse(Request $request) { if ($request->wantsJson()) { return response()->json(['error' => trans('errors.permissionJson')], 403); } session()->flash('error', trans('errors.permission')); return redirect('/'); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Http/Middleware/ApplyCspRules.php
app/Http/Middleware/ApplyCspRules.php
<?php namespace BookStack\Http\Middleware; use BookStack\Util\CspService; use Closure; use Illuminate\Http\Request; class ApplyCspRules { protected CspService $cspService; public function __construct(CspService $cspService) { $this->cspService = $cspService; } /** * Handle an incoming request. * * @param Request $request * @param Closure $next * * @return mixed */ public function handle($request, Closure $next) { view()->share('cspNonce', $this->cspService->getNonce()); if ($this->cspService->allowedIFrameHostsConfigured()) { config()->set('session.same_site', 'none'); } $response = $next($request); $cspHeader = $this->cspService->getCspHeader(); $response->headers->set('Content-Security-Policy', $cspHeader, false); return $response; } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Http/Middleware/CheckGuard.php
app/Http/Middleware/CheckGuard.php
<?php namespace BookStack\Http\Middleware; use Closure; class CheckGuard { /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @param string $allowedGuards * * @return mixed */ public function handle($request, Closure $next, ...$allowedGuards) { $activeGuard = config('auth.method'); if (!in_array($activeGuard, $allowedGuards)) { session()->flash('error', trans('errors.permission')); return redirect('/'); } return $next($request); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Http/Middleware/PreventRequestsDuringMaintenance.php
app/Http/Middleware/PreventRequestsDuringMaintenance.php
<?php namespace BookStack\Http\Middleware; use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware; class PreventRequestsDuringMaintenance extends Middleware { /** * The URIs that should be reachable while maintenance mode is enabled. * * @var array<int, string> */ protected $except = [ // ]; }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Http/Middleware/TrimStrings.php
app/Http/Middleware/TrimStrings.php
<?php namespace BookStack\Http\Middleware; use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware; class TrimStrings extends Middleware { /** * The names of the attributes that should not be trimmed. * * @var array<int, string> */ protected $except = [ 'password', 'password_confirmation', 'password-confirm', ]; }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Http/Middleware/StartSessionExtended.php
app/Http/Middleware/StartSessionExtended.php
<?php namespace BookStack\Http\Middleware; use Illuminate\Http\Request; use Illuminate\Session\Middleware\StartSession as Middleware; /** * An extended version of the default Laravel "StartSession" middleware * with customizations applied as required: * * - Adds filtering for the request URLs stored in session history. */ class StartSessionExtended extends Middleware { protected static array $pathPrefixesExcludedFromHistory = [ 'uploads/images/', 'dist/', 'manifest.json', 'opensearch.xml', ]; /** * @inheritdoc */ protected function storeCurrentUrl(Request $request, $session): void { $requestPath = strtolower($request->path()); foreach (static::$pathPrefixesExcludedFromHistory as $excludedPath) { if (str_starts_with($requestPath, $excludedPath)) { return; } } parent::storeCurrentUrl($request, $session); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Http/Middleware/TrustHosts.php
app/Http/Middleware/TrustHosts.php
<?php namespace BookStack\Http\Middleware; use Illuminate\Http\Middleware\TrustHosts as Middleware; class TrustHosts extends Middleware { /** * Get the host patterns that should be trusted. * * @return array<int, string|null> */ public function hosts(): array { return [ $this->allSubdomainsOfApplicationUrl(), ]; } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Http/Middleware/StartSessionIfCookieExists.php
app/Http/Middleware/StartSessionIfCookieExists.php
<?php namespace BookStack\Http\Middleware; use Closure; use Illuminate\Session\Middleware\StartSession as Middleware; class StartSessionIfCookieExists extends Middleware { /** * Handle an incoming request. */ public function handle($request, Closure $next) { $sessionCookieName = config('session.cookie'); if ($request->cookies->has($sessionCookieName)) { return parent::handle($request, $next); } return $next($request); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Http/Middleware/EncryptCookies.php
app/Http/Middleware/EncryptCookies.php
<?php namespace BookStack\Http\Middleware; use Illuminate\Cookie\Middleware\EncryptCookies as Middleware; class EncryptCookies extends Middleware { /** * The names of the cookies that should not be encrypted. * * @var array<int, string> */ protected $except = [ // ]; }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Http/Middleware/VerifyCsrfToken.php
app/Http/Middleware/VerifyCsrfToken.php
<?php namespace BookStack\Http\Middleware; use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware; class VerifyCsrfToken extends Middleware { /** * Indicates whether the XSRF-TOKEN cookie should be set on the response. * * @var bool */ protected $addHttpCookie = true; /** * The URIs that should be excluded from CSRF verification. * * @var array<int, string> */ protected $except = [ 'saml2/*', ]; }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Translation/LocaleManager.php
app/Translation/LocaleManager.php
<?php namespace BookStack\Translation; use BookStack\Users\Models\User; use Illuminate\Http\Request; class LocaleManager { /** * Array of right-to-left locale options. */ protected array $rtlLocales = ['ar', 'fa', 'he']; /** * Map of BookStack locale names to best-estimate ISO locale names. * Locales can often be found by running `locale -a` on a linux system. * * @var array<string, string> */ protected array $localeMap = [ 'ar' => 'ar', 'bg' => 'bg_BG', 'bn' => 'bn_BD', 'bs' => 'bs_BA', 'ca' => 'ca', 'cs' => 'cs_CZ', 'cy' => 'cy_GB', 'da' => 'da_DK', 'de' => 'de_DE', 'de_informal' => 'de_DE', 'el' => 'el_GR', 'en' => 'en_GB', 'es' => 'es_ES', 'es_AR' => 'es_AR', 'et' => 'et_EE', 'eu' => 'eu_ES', 'fa' => 'fa_IR', 'fi' => 'fi_FI', 'fr' => 'fr_FR', 'he' => 'he_IL', 'hr' => 'hr_HR', 'hu' => 'hu_HU', 'id' => 'id_ID', 'is' => 'is_IS', 'it' => 'it_IT', 'ja' => 'ja', 'ka' => 'ka_GE', 'ko' => 'ko_KR', 'ku' => 'ku_TR', 'lt' => 'lt_LT', 'lv' => 'lv_LV', 'ne' => 'ne_NP', 'nb' => 'nb_NO', 'nl' => 'nl_NL', 'nn' => 'nn_NO', 'pl' => 'pl_PL', 'pt' => 'pt_PT', 'pt_BR' => 'pt_BR', 'ro' => 'ro_RO', 'ru' => 'ru', 'sk' => 'sk_SK', 'sl' => 'sl_SI', 'sq' => 'sq_AL', 'sr' => 'sr_RS', 'sv' => 'sv_SE', 'tk' => 'tk_TM', 'tr' => 'tr_TR', 'uk' => 'uk_UA', 'uz' => 'uz_UZ', 'vi' => 'vi_VN', 'zh_CN' => 'zh_CN', 'zh_TW' => 'zh_TW', ]; /** * Get the BookStack locale string for the given user. */ protected function getLocaleForUser(User $user): string { $default = config('app.default_locale'); if ($user->isGuest() && config('app.auto_detect_locale')) { return $this->autoDetectLocale(request(), $default); } return setting()->getUser($user, 'language', $default); } /** * Get a locale definition for the current user. */ public function getForUser(User $user): LocaleDefinition { $localeString = $this->getLocaleForUser($user); return new LocaleDefinition( $localeString, $this->localeMap[$localeString] ?? $localeString, in_array($localeString, $this->rtlLocales), ); } /** * Autodetect the visitors locale by matching locales in their headers * against the locales supported by BookStack. */ protected function autoDetectLocale(Request $request, string $default): string { $availableLocales = $this->getAllAppLocales(); foreach ($request->getLanguages() as $lang) { if (in_array($lang, $availableLocales)) { return $lang; } } return $default; } /** * Get all the available app-specific level locale strings. */ public function getAllAppLocales(): array { return array_keys($this->localeMap); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Translation/FileLoader.php
app/Translation/FileLoader.php
<?php namespace BookStack\Translation; use Illuminate\Translation\FileLoader as BaseLoader; 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. * * Note: As of using Laravel 10, this may now be redundant since Laravel's * file loader supports multiple paths. This needs further testing though * to confirm if Laravel works how we expect, since we specifically need * the theme folder to be able to partially override core lang files. * * @param string $locale * @param string $group * @param string|null $namespace * * @return array */ public function load($locale, $group, $namespace = null): array { if ($group === '*' && $namespace === '*') { return $this->loadJsonPaths($locale); } if (is_null($namespace) || $namespace === '*') { $themePath = theme_path('lang'); $themeTranslations = $themePath ? $this->loadPaths([$themePath], $locale, $group) : []; $originalTranslations = $this->loadPaths($this->paths, $locale, $group); return array_merge($originalTranslations, $themeTranslations); } return $this->loadNamespaced($locale, $group, $namespace); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Translation/MessageSelector.php
app/Translation/MessageSelector.php
<?php namespace BookStack\Translation; use Illuminate\Translation\MessageSelector as BaseClass; /** * This is a customization of the default Laravel MessageSelector class to tweak pluralization, * so that is uses just the first part of the locale string to provide support with * non-standard locales such as "de_informal". */ class MessageSelector extends BaseClass { public function getPluralIndex($locale, $number) { $locale = explode('_', $locale)[0]; return parent::getPluralIndex($locale, $number); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Translation/LocaleDefinition.php
app/Translation/LocaleDefinition.php
<?php namespace BookStack\Translation; class LocaleDefinition { public function __construct( protected string $appName, protected string $isoName, protected bool $isRtl ) { } /** * Provide the BookStack-specific locale name. */ public function appLocale(): string { return $this->appName; } /** * Provide the ISO-aligned locale name. */ public function isoLocale(): string { return $this->isoName; } /** * Returns a string suitable for the HTML "lang" attribute. */ public function htmlLang(): string { return str_replace('_', '-', $this->isoName); } /** * Returns a string suitable for the HTML "dir" attribute. */ public function htmlDirection(): string { return $this->isRtl ? 'rtl' : 'ltr'; } /** * Translate using this locate. */ public function trans(string $key, array $replace = []): string { return trans($key, $replace, $this->appLocale()); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Activity/ActivityType.php
app/Activity/ActivityType.php
<?php namespace BookStack\Activity; class ActivityType { const PAGE_CREATE = 'page_create'; const PAGE_UPDATE = 'page_update'; const PAGE_DELETE = 'page_delete'; const PAGE_RESTORE = 'page_restore'; const PAGE_MOVE = 'page_move'; const CHAPTER_CREATE = 'chapter_create'; const CHAPTER_UPDATE = 'chapter_update'; const CHAPTER_DELETE = 'chapter_delete'; const CHAPTER_MOVE = 'chapter_move'; const BOOK_CREATE = 'book_create'; const BOOK_CREATE_FROM_CHAPTER = 'book_create_from_chapter'; const BOOK_UPDATE = 'book_update'; const BOOK_DELETE = 'book_delete'; const BOOK_SORT = 'book_sort'; const BOOKSHELF_CREATE = 'bookshelf_create'; const BOOKSHELF_CREATE_FROM_BOOK = 'bookshelf_create_from_book'; const BOOKSHELF_UPDATE = 'bookshelf_update'; const BOOKSHELF_DELETE = 'bookshelf_delete'; const COMMENTED_ON = 'commented_on'; const COMMENT_CREATE = 'comment_create'; const COMMENT_UPDATE = 'comment_update'; const COMMENT_DELETE = 'comment_delete'; const PERMISSIONS_UPDATE = 'permissions_update'; const REVISION_RESTORE = 'revision_restore'; const REVISION_DELETE = 'revision_delete'; const SETTINGS_UPDATE = 'settings_update'; const MAINTENANCE_ACTION_RUN = 'maintenance_action_run'; const RECYCLE_BIN_EMPTY = 'recycle_bin_empty'; const RECYCLE_BIN_RESTORE = 'recycle_bin_restore'; const RECYCLE_BIN_DESTROY = 'recycle_bin_destroy'; const USER_CREATE = 'user_create'; const USER_UPDATE = 'user_update'; const USER_DELETE = 'user_delete'; const API_TOKEN_CREATE = 'api_token_create'; const API_TOKEN_UPDATE = 'api_token_update'; const API_TOKEN_DELETE = 'api_token_delete'; const ROLE_CREATE = 'role_create'; const ROLE_UPDATE = 'role_update'; const ROLE_DELETE = 'role_delete'; const AUTH_PASSWORD_RESET = 'auth_password_reset_request'; const AUTH_PASSWORD_RESET_UPDATE = 'auth_password_reset_update'; const AUTH_LOGIN = 'auth_login'; const AUTH_REGISTER = 'auth_register'; const MFA_SETUP_METHOD = 'mfa_setup_method'; const MFA_REMOVE_METHOD = 'mfa_remove_method'; const WEBHOOK_CREATE = 'webhook_create'; const WEBHOOK_UPDATE = 'webhook_update'; const WEBHOOK_DELETE = 'webhook_delete'; const IMPORT_CREATE = 'import_create'; const IMPORT_RUN = 'import_run'; const IMPORT_DELETE = 'import_delete'; const SORT_RULE_CREATE = 'sort_rule_create'; const SORT_RULE_UPDATE = 'sort_rule_update'; const SORT_RULE_DELETE = 'sort_rule_delete'; /** * Get all the possible values. */ public static function all(): array { return (new \ReflectionClass(static::class))->getConstants(); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Activity/DispatchWebhookJob.php
app/Activity/DispatchWebhookJob.php
<?php namespace BookStack\Activity; use BookStack\Activity\Models\Loggable; use BookStack\Activity\Models\Webhook; use BookStack\Activity\Tools\WebhookFormatter; use BookStack\Facades\Theme; use BookStack\Http\HttpRequestService; use BookStack\Theming\ThemeEvents; use BookStack\Users\Models\User; use BookStack\Util\SsrUrlValidator; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; use Illuminate\Support\Facades\Log; class DispatchWebhookJob implements ShouldQueue { use Dispatchable; use InteractsWithQueue; use Queueable; use SerializesModels; protected Webhook $webhook; protected User $initiator; protected int $initiatedTime; protected array $webhookData; /** * Create a new job instance. * * @return void */ public function __construct(Webhook $webhook, string $event, Loggable|string $detail) { $this->webhook = $webhook; $this->initiator = user(); $this->initiatedTime = time(); $themeResponse = Theme::dispatch(ThemeEvents::WEBHOOK_CALL_BEFORE, $event, $this->webhook, $detail, $this->initiator, $this->initiatedTime); $this->webhookData = $themeResponse ?? WebhookFormatter::getDefault($event, $this->webhook, $detail, $this->initiator, $this->initiatedTime)->format(); } /** * Execute the job. * * @return void */ public function handle(HttpRequestService $http) { $lastError = null; try { (new SsrUrlValidator())->ensureAllowed($this->webhook->endpoint); $client = $http->buildClient($this->webhook->timeout, [ 'connect_timeout' => 10, 'allow_redirects' => ['strict' => true], ]); $response = $client->sendRequest($http->jsonRequest('POST', $this->webhook->endpoint, $this->webhookData)); $statusCode = $response->getStatusCode(); if ($statusCode >= 400) { $lastError = "Response status from endpoint was {$statusCode}"; Log::error("Webhook call to endpoint {$this->webhook->endpoint} failed with status {$statusCode}"); } } catch (\Exception $error) { $lastError = $error->getMessage(); Log::error("Webhook call to endpoint {$this->webhook->endpoint} failed with error \"{$lastError}\""); } $this->webhook->last_called_at = now(); if ($lastError) { $this->webhook->last_errored_at = now(); $this->webhook->last_error = $lastError; } $this->webhook->save(); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Activity/CommentRepo.php
app/Activity/CommentRepo.php
<?php namespace BookStack\Activity; use BookStack\Activity\Models\Comment; use BookStack\Entities\Models\Entity; use BookStack\Entities\Models\Page; use BookStack\Exceptions\NotifyException; use BookStack\Facades\Activity as ActivityService; use BookStack\Util\HtmlDescriptionFilter; use Illuminate\Database\Eloquent\Builder; class CommentRepo { /** * Get a comment by ID. */ public function getById(int $id): Comment { return Comment::query()->findOrFail($id); } /** * Get a comment by ID, ensuring it is visible to the user based upon access to the page * which the comment is attached to. */ public function getVisibleById(int $id): Comment { return $this->getQueryForVisible()->findOrFail($id); } /** * Start a query for comments visible to the user. * @return Builder<Comment> */ public function getQueryForVisible(): Builder { return Comment::query()->scopes('visible'); } /** * Create a new comment on an entity. */ public function create(Entity $entity, string $html, ?int $parentId, string $contentRef): Comment { // Prevent comments being added to draft pages if ($entity instanceof Page && $entity->draft) { throw new \Exception(trans('errors.cannot_add_comment_to_draft')); } // Validate parent ID if ($parentId !== null) { $parentCommentExists = Comment::query() ->where('commentable_id', '=', $entity->id) ->where('commentable_type', '=', $entity->getMorphClass()) ->where('local_id', '=', $parentId) ->exists(); if (!$parentCommentExists) { $parentId = null; } } $userId = user()->id; $comment = new Comment(); $comment->html = HtmlDescriptionFilter::filterFromString($html); $comment->created_by = $userId; $comment->updated_by = $userId; $comment->local_id = $this->getNextLocalId($entity); $comment->parent_id = $parentId; $comment->content_ref = preg_match('/^bkmrk-(.*?):\d+:(\d*-\d*)?$/', $contentRef) === 1 ? $contentRef : ''; $entity->comments()->save($comment); ActivityService::add(ActivityType::COMMENT_CREATE, $comment); ActivityService::add(ActivityType::COMMENTED_ON, $entity); $comment->refresh()->unsetRelations(); return $comment; } /** * Update an existing comment. */ public function update(Comment $comment, string $html): Comment { $comment->updated_by = user()->id; $comment->html = HtmlDescriptionFilter::filterFromString($html); $comment->save(); ActivityService::add(ActivityType::COMMENT_UPDATE, $comment); return $comment; } /** * Archive an existing comment. */ public function archive(Comment $comment, bool $log = true): Comment { if ($comment->parent_id) { throw new NotifyException('Only top-level comments can be archived.', '/', 400); } $comment->archived = true; $comment->save(); if ($log) { ActivityService::add(ActivityType::COMMENT_UPDATE, $comment); } return $comment; } /** * Un-archive an existing comment. */ public function unarchive(Comment $comment, bool $log = true): Comment { if ($comment->parent_id) { throw new NotifyException('Only top-level comments can be un-archived.', '/', 400); } $comment->archived = false; $comment->save(); if ($log) { ActivityService::add(ActivityType::COMMENT_UPDATE, $comment); } return $comment; } /** * Delete a comment from the system. */ public function delete(Comment $comment): void { $comment->delete(); ActivityService::add(ActivityType::COMMENT_DELETE, $comment); } /** * Get the next local ID relative to the linked entity. */ protected function getNextLocalId(Entity $entity): int { $currentMaxId = $entity->comments()->max('local_id'); return $currentMaxId + 1; } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Activity/TagRepo.php
app/Activity/TagRepo.php
<?php namespace BookStack\Activity; use BookStack\Activity\Models\Tag; use BookStack\Entities\Models\Entity; use BookStack\Permissions\PermissionApplicator; use BookStack\Util\SimpleListOptions; use Illuminate\Database\Eloquent\Builder; use Illuminate\Support\Collection; use Illuminate\Support\Facades\DB; class TagRepo { public function __construct( protected PermissionApplicator $permissions ) { } /** * Start a query against all tags in the system. */ public function queryWithTotals(SimpleListOptions $listOptions, string $nameFilter): Builder { $searchTerm = $listOptions->getSearch(); $sort = $listOptions->getSort(); if ($sort === 'name' && $nameFilter) { $sort = 'value'; } $query = Tag::query() ->select([ 'name', ($searchTerm || $nameFilter) ? 'value' : DB::raw('COUNT(distinct value) as `values`'), DB::raw('COUNT(id) as usages'), DB::raw('SUM(IF(entity_type = \'page\', 1, 0)) as page_count'), DB::raw('SUM(IF(entity_type = \'chapter\', 1, 0)) as chapter_count'), DB::raw('SUM(IF(entity_type = \'book\', 1, 0)) as book_count'), DB::raw('SUM(IF(entity_type = \'bookshelf\', 1, 0)) as shelf_count'), ]) ->orderBy($sort, $listOptions->getOrder()) ->whereHas('entity'); if ($nameFilter) { $query->where('name', '=', $nameFilter); $query->groupBy('value'); } elseif ($searchTerm) { $query->groupBy('name', 'value'); } else { $query->groupBy('name'); } if ($searchTerm) { $query->where(function (Builder $query) use ($searchTerm) { $query->where('name', 'like', '%' . $searchTerm . '%') ->orWhere('value', 'like', '%' . $searchTerm . '%'); }); } return $this->permissions->restrictEntityRelationQuery($query, 'tags', 'entity_id', 'entity_type'); } /** * Get tag name suggestions from scanning existing tag names. * If no search term is given the 50 most popular tag names are provided. */ public function getNameSuggestions(string $searchTerm): Collection { $query = Tag::query() ->select('*', DB::raw('count(*) as count')) ->groupBy('name'); if ($searchTerm) { $query = $query->where('name', 'LIKE', $searchTerm . '%')->orderBy('name', 'asc'); } else { $query = $query->orderBy('count', 'desc')->take(50); } $query = $this->permissions->restrictEntityRelationQuery($query, 'tags', 'entity_id', 'entity_type'); return $query->pluck('name'); } /** * Get tag value suggestions from scanning existing tag values. * If no search is given the 50 most popular values are provided. * Passing a tagName will only find values for a tags with a particular name. */ public function getValueSuggestions(string $searchTerm, string $tagName): Collection { $query = Tag::query() ->select('*', DB::raw('count(*) as count')) ->where('value', '!=', '') ->groupBy('value'); if ($searchTerm) { $query = $query->where('value', 'LIKE', $searchTerm . '%')->orderBy('value', 'desc'); } else { $query = $query->orderBy('count', 'desc')->take(50); } if ($tagName) { $query = $query->where('name', '=', $tagName); } $query = $this->permissions->restrictEntityRelationQuery($query, 'tags', 'entity_id', 'entity_type'); return $query->pluck('value'); } /** * Save an array of tags to an entity. */ public function saveTagsToEntity(Entity $entity, array $tags = []): iterable { $entity->tags()->delete(); $newTags = collect($tags)->filter(function ($tag) { return boolval(trim($tag['name'])); })->map(function ($tag) { return $this->newInstanceFromInput($tag); })->all(); return $entity->tags()->saveMany($newTags); } /** * Create a new Tag instance from user input. * Input must be an array with a 'name' and an optional 'value' key. */ protected function newInstanceFromInput(array $input): Tag { return new Tag([ 'name' => trim($input['name']), 'value' => trim($input['value'] ?? ''), ]); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Activity/WatchLevels.php
app/Activity/WatchLevels.php
<?php namespace BookStack\Activity; use BookStack\Entities\Models\Bookshelf; use BookStack\Entities\Models\Entity; use BookStack\Entities\Models\Page; class WatchLevels { /** * Default level, No specific option set * Typically not a stored status */ const DEFAULT = -1; /** * Ignore all notifications. */ const IGNORE = 0; /** * Watch for new content. */ const NEW = 1; /** * Watch for updates and new content */ const UPDATES = 2; /** * Watch for comments, updates and new content. */ const COMMENTS = 3; /** * Get all the possible values as an option_name => value array. * @return array<string, int> */ public static function all(): array { $options = []; foreach ((new \ReflectionClass(static::class))->getConstants() as $name => $value) { $options[strtolower($name)] = $value; } return $options; } /** * Get the watch options suited for the given entity. * @return array<string, int> */ public static function allSuitedFor(Entity $entity): array { $options = static::all(); if ($entity instanceof Page) { unset($options['new']); } elseif ($entity instanceof Bookshelf) { return []; } return $options; } /** * Convert the given name to a level value. * Defaults to default value if the level does not exist. */ public static function levelNameToValue(string $level): int { return static::all()[$level] ?? static::DEFAULT; } /** * Convert the given int level value to a level name. * Defaults to 'default' level name if not existing. */ public static function levelValueToName(int $level): string { foreach (static::all() as $name => $value) { if ($level === $value) { return $name; } } return 'default'; } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Activity/ActivityQueries.php
app/Activity/ActivityQueries.php
<?php namespace BookStack\Activity; use BookStack\Activity\Models\Activity; use BookStack\Entities\Models\Book; use BookStack\Entities\Models\Chapter; use BookStack\Entities\Models\Entity; use BookStack\Entities\Models\Page; use BookStack\Entities\Tools\MixedEntityListLoader; use BookStack\Permissions\PermissionApplicator; use BookStack\Users\Models\User; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Relations\MorphTo; use Illuminate\Database\Eloquent\Relations\Relation; class ActivityQueries { public function __construct( protected PermissionApplicator $permissions, protected MixedEntityListLoader $listLoader, ) { } /** * Gets the latest activity. */ public function latest(int $count = 20, int $page = 0): array { $activityList = $this->permissions ->restrictEntityRelationQuery(Activity::query(), 'activities', 'loggable_id', 'loggable_type') ->orderBy('created_at', 'desc') ->with(['user']) ->skip($count * $page) ->take($count) ->get(); $this->listLoader->loadIntoRelations($activityList->all(), 'loggable', false); return $this->filterSimilar($activityList); } /** * Gets the latest activity for an entity, Filtering out similar * items to prevent a message activity list. */ public function entityActivity(Entity $entity, int $count = 20, int $page = 1): array { /** @var array<string, int[]> $queryIds */ $queryIds = [$entity->getMorphClass() => [$entity->id]]; if ($entity instanceof Book) { $queryIds[(new Chapter())->getMorphClass()] = $entity->chapters()->scopes('visible')->pluck('id'); } if ($entity instanceof Book || $entity instanceof Chapter) { $queryIds[(new Page())->getMorphClass()] = $entity->pages()->scopes('visible')->pluck('id'); } $query = Activity::query(); $query->where(function (Builder $query) use ($queryIds) { foreach ($queryIds as $morphClass => $idArr) { $query->orWhere(function (Builder $innerQuery) use ($morphClass, $idArr) { $innerQuery->where('loggable_type', '=', $morphClass) ->whereIn('loggable_id', $idArr); }); } }); $activity = $query->orderBy('created_at', 'desc') ->with(['loggable' => function (Relation $query) { /** @var MorphTo<Entity, Activity> $query */ $query->withTrashed(); }, 'user.avatar']) ->skip($count * ($page - 1)) ->take($count) ->get(); return $this->filterSimilar($activity); } /** * Get the latest activity for a user, Filtering out similar items. */ public function userActivity(User $user, int $count = 20, int $page = 0): array { $activityList = $this->permissions ->restrictEntityRelationQuery(Activity::query(), 'activities', 'loggable_id', 'loggable_type') ->orderBy('created_at', 'desc') ->where('user_id', '=', $user->id) ->skip($count * $page) ->take($count) ->get(); return $this->filterSimilar($activityList); } /** * Filters out similar activity. * * @param Activity[] $activities */ protected function filterSimilar(iterable $activities): array { $newActivity = []; $previousItem = null; foreach ($activities as $activityItem) { if (!$previousItem || !$activityItem->isSimilarTo($previousItem)) { $newActivity[] = $activityItem; } $previousItem = $activityItem; } return $newActivity; } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Activity/Controllers/AuditLogController.php
app/Activity/Controllers/AuditLogController.php
<?php namespace BookStack\Activity\Controllers; use BookStack\Activity\ActivityType; use BookStack\Activity\Models\Activity; use BookStack\Http\Controller; use BookStack\Permissions\Permission; use BookStack\Sorting\SortUrl; use BookStack\Util\SimpleListOptions; use Illuminate\Http\Request; class AuditLogController extends Controller { public function index(Request $request) { $this->checkPermission(Permission::SettingsManage); $this->checkPermission(Permission::UsersManage); $sort = $request->get('sort', 'activity_date'); $order = $request->get('order', 'desc'); $listOptions = (new SimpleListOptions('', $sort, $order))->withSortOptions([ 'created_at' => trans('settings.audit_table_date'), 'type' => trans('settings.audit_table_event'), ]); $filters = [ 'event' => $request->get('event', ''), 'date_from' => $request->get('date_from', ''), 'date_to' => $request->get('date_to', ''), 'user' => $request->get('user', ''), 'ip' => $request->get('ip', ''), ]; $query = Activity::query() ->with([ 'loggable' => fn ($query) => $query->withTrashed(), 'user', ]) ->orderBy($listOptions->getSort(), $listOptions->getOrder()); if ($filters['event']) { $query->where('type', '=', $filters['event']); } if ($filters['user']) { $query->where('user_id', '=', $filters['user']); } if ($filters['date_from']) { $query->where('created_at', '>=', $filters['date_from']); } if ($filters['date_to']) { $query->where('created_at', '<=', $filters['date_to']); } if ($filters['ip']) { $query->where('ip', 'like', $filters['ip'] . '%'); } $activities = $query->paginate(100); $activities->appends($request->all()); $types = ActivityType::all(); $this->setPageTitle(trans('settings.audit')); return view('settings.audit', [ 'activities' => $activities, 'filters' => $filters, 'listOptions' => $listOptions, 'activityTypes' => $types, 'filterSortUrl' => new SortUrl('settings/audit', array_filter($request->except('page'))) ]); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Activity/Controllers/AuditLogApiController.php
app/Activity/Controllers/AuditLogApiController.php
<?php namespace BookStack\Activity\Controllers; use BookStack\Activity\Models\Activity; use BookStack\Http\ApiController; use BookStack\Permissions\Permission; class AuditLogApiController extends ApiController { /** * Get a listing of audit log events in the system. * The loggable relation fields currently only relates to core * content types (page, book, bookshelf, chapter) but this may be * used more in the future across other types. * Requires permission to manage both users and system settings. */ public function list() { $this->checkPermission(Permission::SettingsManage); $this->checkPermission(Permission::UsersManage); $query = Activity::query()->with(['user']); return $this->apiListingResponse($query, [ 'id', 'type', 'detail', 'user_id', 'loggable_id', 'loggable_type', 'ip', 'created_at', ]); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Activity/Controllers/CommentController.php
app/Activity/Controllers/CommentController.php
<?php namespace BookStack\Activity\Controllers; use BookStack\Activity\CommentRepo; use BookStack\Activity\Tools\CommentTree; use BookStack\Activity\Tools\CommentTreeNode; use BookStack\Entities\Queries\PageQueries; use BookStack\Http\Controller; use BookStack\Permissions\Permission; use Illuminate\Http\Request; use Illuminate\Validation\ValidationException; class CommentController extends Controller { public function __construct( protected CommentRepo $commentRepo, protected PageQueries $pageQueries, ) { } /** * Save a new comment for a Page. * * @throws ValidationException|\Exception */ public function savePageComment(Request $request, int $pageId) { $input = $this->validate($request, [ 'html' => ['required', 'string'], 'parent_id' => ['nullable', 'integer'], 'content_ref' => ['string'], ]); $page = $this->pageQueries->findVisibleById($pageId); if ($page === null) { return response('Not found', 404); } // Create a new comment. $this->checkPermission(Permission::CommentCreateAll); $contentRef = $input['content_ref'] ?? ''; $comment = $this->commentRepo->create($page, $input['html'], $input['parent_id'] ?? null, $contentRef); return view('comments.comment-branch', [ 'readOnly' => false, 'branch' => new CommentTreeNode($comment, 0, []), ]); } /** * Update an existing comment. * * @throws ValidationException */ public function update(Request $request, int $commentId) { $input = $this->validate($request, [ 'html' => ['required', 'string'], ]); $comment = $this->commentRepo->getById($commentId); $this->checkOwnablePermission(Permission::PageView, $comment->entity); $this->checkOwnablePermission(Permission::CommentUpdate, $comment); $comment = $this->commentRepo->update($comment, $input['html']); return view('comments.comment', [ 'comment' => $comment, 'readOnly' => false, ]); } /** * Mark a comment as archived. */ public function archive(int $id) { $comment = $this->commentRepo->getById($id); $this->checkOwnablePermission(Permission::PageView, $comment->entity); if (!userCan(Permission::CommentUpdate, $comment) && !userCan(Permission::CommentDelete, $comment)) { $this->showPermissionError(); } $this->commentRepo->archive($comment); $tree = new CommentTree($comment->entity); return view('comments.comment-branch', [ 'readOnly' => false, 'branch' => $tree->getCommentNodeForId($id), ]); } /** * Unmark a comment as archived. */ public function unarchive(int $id) { $comment = $this->commentRepo->getById($id); $this->checkOwnablePermission(Permission::PageView, $comment->entity); if (!userCan(Permission::CommentUpdate, $comment) && !userCan(Permission::CommentDelete, $comment)) { $this->showPermissionError(); } $this->commentRepo->unarchive($comment); $tree = new CommentTree($comment->entity); return view('comments.comment-branch', [ 'readOnly' => false, 'branch' => $tree->getCommentNodeForId($id), ]); } /** * Delete a comment from the system. */ public function destroy(int $id) { $comment = $this->commentRepo->getById($id); $this->checkOwnablePermission(Permission::CommentDelete, $comment); $this->commentRepo->delete($comment); return response()->json(['message' => trans('entities.comment_deleted')]); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Activity/Controllers/WatchController.php
app/Activity/Controllers/WatchController.php
<?php namespace BookStack\Activity\Controllers; use BookStack\Activity\Tools\UserEntityWatchOptions; use BookStack\Entities\Tools\MixedEntityRequestHelper; use BookStack\Http\Controller; use BookStack\Permissions\Permission; use Illuminate\Http\Request; class WatchController extends Controller { public function update(Request $request, MixedEntityRequestHelper $entityHelper) { $this->checkPermission(Permission::ReceiveNotifications); $this->preventGuestAccess(); $requestData = $this->validate($request, array_merge([ 'level' => ['required', 'string'], ], $entityHelper->validationRules())); $watchable = $entityHelper->getVisibleEntityFromRequestData($requestData); $watchOptions = new UserEntityWatchOptions(user(), $watchable); $watchOptions->updateLevelByName($requestData['level']); $this->showSuccessNotification(trans('activities.watch_update_level_notification')); return redirect($watchable->getUrl()); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Activity/Controllers/CommentApiController.php
app/Activity/Controllers/CommentApiController.php
<?php declare(strict_types=1); namespace BookStack\Activity\Controllers; use BookStack\Activity\CommentRepo; use BookStack\Activity\Models\Comment; use BookStack\Entities\Queries\PageQueries; use BookStack\Http\ApiController; use BookStack\Permissions\Permission; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Http\Response; /** * The comment data model has a 'local_id' property, which is a unique integer ID * scoped to the page which the comment is on. The 'parent_id' is used for replies * and refers to the 'local_id' of the parent comment on the same page, not the main * globally unique 'id'. * * If you want to get all comments for a page in a tree-like structure, as reflected in * the UI, then that is provided on pages-read API responses. */ class CommentApiController extends ApiController { protected array $rules = [ 'create' => [ 'page_id' => ['required', 'integer'], 'reply_to' => ['nullable', 'integer'], 'html' => ['required', 'string'], 'content_ref' => ['string'], ], 'update' => [ 'html' => ['string'], 'archived' => ['boolean'], ] ]; public function __construct( protected CommentRepo $commentRepo, protected PageQueries $pageQueries, ) { } /** * Get a listing of comments visible to the user. */ public function list(): JsonResponse { $query = $this->commentRepo->getQueryForVisible(); return $this->apiListingResponse($query, [ 'id', 'commentable_id', 'commentable_type', 'parent_id', 'local_id', 'content_ref', 'created_by', 'updated_by', 'created_at', 'updated_at' ]); } /** * Create a new comment on a page. * If commenting as a reply to an existing comment, the 'reply_to' parameter * should be provided, set to the 'local_id' of the comment being replied to. */ public function create(Request $request): JsonResponse { $this->checkPermission(Permission::CommentCreateAll); $input = $this->validate($request, $this->rules()['create']); $page = $this->pageQueries->findVisibleByIdOrFail($input['page_id']); $comment = $this->commentRepo->create( $page, $input['html'], $input['reply_to'] ?? null, $input['content_ref'] ?? '', ); return response()->json($comment); } /** * Read the details of a single comment, along with its direct replies. */ public function read(string $id): JsonResponse { $comment = $this->commentRepo->getVisibleById(intval($id)); $comment->load('createdBy', 'updatedBy'); $replies = $this->commentRepo->getQueryForVisible() ->where('parent_id', '=', $comment->local_id) ->where('commentable_id', '=', $comment->commentable_id) ->where('commentable_type', '=', $comment->commentable_type) ->get(); /** @var Comment[] $toProcess */ $toProcess = [$comment, ...$replies]; foreach ($toProcess as $commentToProcess) { $commentToProcess->setAttribute('html', $commentToProcess->safeHtml()); $commentToProcess->makeVisible('html'); } $comment->setRelation('replies', $replies); return response()->json($comment); } /** * Update the content or archived status of an existing comment. * * Only provide a new archived status if needing to actively change the archive state. * Only top-level comments (non-replies) can be archived or unarchived. */ public function update(Request $request, string $id): JsonResponse { $comment = $this->commentRepo->getVisibleById(intval($id)); $this->checkOwnablePermission(Permission::CommentUpdate, $comment); $input = $this->validate($request, $this->rules()['update']); $hasHtml = isset($input['html']); if (isset($input['archived'])) { if ($input['archived']) { $this->commentRepo->archive($comment, !$hasHtml); } else { $this->commentRepo->unarchive($comment, !$hasHtml); } } if ($hasHtml) { $comment = $this->commentRepo->update($comment, $input['html']); } return response()->json($comment); } /** * Delete a single comment from the system. */ public function delete(string $id): Response { $comment = $this->commentRepo->getVisibleById(intval($id)); $this->checkOwnablePermission(Permission::CommentDelete, $comment); $this->commentRepo->delete($comment); return response('', 204); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false
BookStackApp/BookStack
https://github.com/BookStackApp/BookStack/blob/e6b754fad029d6c35e139b907d04e6510775997b/app/Activity/Controllers/WebhookController.php
app/Activity/Controllers/WebhookController.php
<?php namespace BookStack\Activity\Controllers; use BookStack\Activity\ActivityType; use BookStack\Activity\Models\Webhook; use BookStack\Activity\Queries\WebhooksAllPaginatedAndSorted; use BookStack\Http\Controller; use BookStack\Permissions\Permission; use BookStack\Util\SimpleListOptions; use Illuminate\Http\Request; class WebhookController extends Controller { public function __construct() { $this->middleware([ Permission::SettingsManage->middleware() ]); } /** * Show all webhooks configured in the system. */ public function index(Request $request) { $listOptions = SimpleListOptions::fromRequest($request, 'webhooks')->withSortOptions([ 'name' => trans('common.sort_name'), 'endpoint' => trans('settings.webhooks_endpoint'), 'created_at' => trans('common.sort_created_at'), 'updated_at' => trans('common.sort_updated_at'), 'active' => trans('common.status'), ]); $webhooks = (new WebhooksAllPaginatedAndSorted())->run(20, $listOptions); $webhooks->appends($listOptions->getPaginationAppends()); $this->setPageTitle(trans('settings.webhooks')); return view('settings.webhooks.index', [ 'webhooks' => $webhooks, 'listOptions' => $listOptions, ]); } /** * Show the view for creating a new webhook in the system. */ public function create() { $this->setPageTitle(trans('settings.webhooks_create')); return view('settings.webhooks.create'); } /** * Store a new webhook in the system. */ public function store(Request $request) { $validated = $this->validate($request, [ 'name' => ['required', 'max:150'], 'endpoint' => ['required', 'url', 'max:500'], 'events' => ['required', 'array'], 'active' => ['required'], 'timeout' => ['required', 'integer', 'min:1', 'max:600'], ]); $webhook = new Webhook($validated); $webhook->active = $validated['active'] === 'true'; $webhook->save(); $webhook->updateTrackedEvents(array_values($validated['events'])); $this->logActivity(ActivityType::WEBHOOK_CREATE, $webhook); return redirect('/settings/webhooks'); } /** * Show the view to edit an existing webhook. */ public function edit(string $id) { /** @var Webhook $webhook */ $webhook = Webhook::query() ->with('trackedEvents') ->findOrFail($id); $this->setPageTitle(trans('settings.webhooks_edit')); return view('settings.webhooks.edit', ['webhook' => $webhook]); } /** * Update an existing webhook with the provided request data. */ public function update(Request $request, string $id) { $validated = $this->validate($request, [ 'name' => ['required', 'max:150'], 'endpoint' => ['required', 'url', 'max:500'], 'events' => ['required', 'array'], 'active' => ['required'], 'timeout' => ['required', 'integer', 'min:1', 'max:600'], ]); /** @var Webhook $webhook */ $webhook = Webhook::query()->findOrFail($id); $webhook->active = $validated['active'] === 'true'; $webhook->fill($validated)->save(); $webhook->updateTrackedEvents($validated['events']); $this->logActivity(ActivityType::WEBHOOK_UPDATE, $webhook); return redirect('/settings/webhooks'); } /** * Show the view to delete a webhook. */ public function delete(string $id) { /** @var Webhook $webhook */ $webhook = Webhook::query()->findOrFail($id); $this->setPageTitle(trans('settings.webhooks_delete')); return view('settings.webhooks.delete', ['webhook' => $webhook]); } /** * Destroy a webhook from the system. */ public function destroy(string $id) { /** @var Webhook $webhook */ $webhook = Webhook::query()->findOrFail($id); $webhook->trackedEvents()->delete(); $webhook->delete(); $this->logActivity(ActivityType::WEBHOOK_DELETE, $webhook); return redirect('/settings/webhooks'); } }
php
MIT
e6b754fad029d6c35e139b907d04e6510775997b
2026-01-04T15:02:34.418809Z
false