text
stringlengths
14
100k
source
stringclasses
1 value
repo
stringclasses
810 values
language
stringclasses
13 values
<|fim_prefix|><?php namespace BookStack\Access\Controllers; use BookStack\Access\LoginService; use BookStack\Access\RegistrationService; use BookStack\Access\SocialDriverManager; use BookStack\Exceptions\StoppedAuthenticationException; use BookStack\Exceptions\UserRegistrationException; use BookStack\Http\Controller;...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Access\Controllers; use BookStack\Access\LoginService; use BookStack\Activity\ActivityType; use BookStack\Http\Controller; use BookStack\Users\Models\User; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; use Illuminate\Support\Facades\Hash; use Illuminate\Sup...
fim
BookStackApp/BookStack
php
<|fim_suffix|>fail_authed', ['system' => config('saml2.name')])); return redirect('/login'); } $user = $this->samlService->processAcsResponse($requestId, $samlResponse); if (is_null($user)) { $this->showErrorNotification(trans('errors.saml_fail_authed', ['system' => con...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Access\Controllers; use BookStack\Access\LoginService; use BookStack\Access\RegistrationService; use BookStack\Access\SocialAuthService; use BookStack\Exceptions\SocialDriverNotConfigured; use BookStack\Exceptions\SocialSignInAccountNotUsed; use BookStack\Exceptions\SocialSignI...
fim
BookStackApp/BookStack
php
<?php namespace BookStack\Access\Controllers; use Illuminate\Cache\RateLimiter; use Illuminate\Http\Request; use Illuminate\Http\Response; use Illuminate\Support\Str; use Illuminate\Validation\ValidationException; trait ThrottlesLogins { /** * Determine if the user has too many failed login attempts. *...
fim
BookStackApp/BookStack
php
<|fim_suffix|>=> ['required', Password::default()], ]); try { $userId = $this->inviteService->checkTokenAndGetUserId($token); } catch (Exception $exception) { return $this->handleTokenException($exception); } $user = $this->userRepo->getById($userId); ...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Access; use BookStack\Access\Notifications\ConfirmEmailNotification; use Boo<|fim_suffix|>ify(new ConfirmEmailNotification($token)); } /** * Check if confirmation is required in this instance. */ public function confirmationRequired(): bool { ...
fim
BookStackApp/BookStack
php
<|fim_suffix|>n storage. * * @param Authenticatable $user * @param string $token * * @return void */ public function updateRememberToken(Authenticatable $user, $token) { // } /** * Retrieve a user by the given credentials. */ public function ...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Access; use BookStack\Users\Models\Role; use BookStack\Users\Models\User; use Illuminate\Support\Collection; class GroupSyncService { /** * Check a role against an array of group names to see if it matches. * Checked against role 'external_auth_id' if set otherwi...
fim
BookStackApp/BookStack
php
<?php namespace BookStack\Access\Guards; /** * External Auth Session Guard. * * The login process for external auth (SAML2/OIDC) is async in nature, meaning it does not fit very well * into the default laravel 'Guard' auth flow. Instead, most of the logic is done via the relevant * controller and services. This ...
fim
BookStackApp/BookStack
php
<?php namespace BookStack\Access\Guards; use BookStack\Access\RegistrationService; use Illuminate\Auth\GuardHelpers; use Illuminate\Contracts\Auth\Authenticatable; use Illuminate\Contracts\Auth\StatefulGuard; use Illuminate\Contracts\Auth\UserProvider; use Illuminate\Contracts\Session\Session; /** * Class BaseSessi...
fim
BookStackApp/BookStack
php
<?php namespace BookStack\Access\Guards; use BookStack\Access\LdapService; use BookStack\Access\RegistrationService; use BookStack\Exceptions\JsonDebugException; use BookStack\Exceptions\LdapException; use BookStack\Exceptions\LoginAttemptEmailNeededException; use BookStack\Exceptions\LoginAttemptException; use BookS...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Access; /** * Class Ldap * An object-orientated thin abstraction wrapper for common PHP LDAP functions. * Allows the standard LDAP functions to be mocked for testing. */ class Ldap { /** * Connect to an LDAP server. * * @return resource|\LDAP\Connection|f...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Access; use BookStack\Exceptions\JsonDebugException; use BookStack\Exceptions\LdapException; use BookStack\Uploads\UserAvatars; use BookStack\Users\Models\User; use ErrorException; use Illuminate\Support\Facades\Log; /** * Class LdapService * Handles any app-specific LDAP ta...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Access; use BookStack\Access\Mfa\MfaSession; use BookStack\Activity\ActivityType; use BookStack\Exceptions\LoginAttemptException; use BookStack\Exceptions\LoginAttemptInvalidUserException; use BookStack\Exceptions\StoppedAuthenticationException; use BookStack\Facades\Activity; ...
fim
BookStackApp/BookStack
php
<|fim_suffix|>unction inputCodeExistsInSet(string $code, string $codeSet): bool { $cleanCode = $this->cleanInputCode($code); $codes = json_decode($codeSet); return in_array($cleanCode, $codes); } /** * Remove the given input code from the given available options. * Will r...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Access\Mfa; use BookStack\Users\Models\User; class MfaSession { /** * Check if MFA is required for the given user. */ public function isRequiredForUser(User $user): bool { return $user->mfaValues()->exists() || $this->userRoleEnforcesMfa($user); ...
fim
BookStackApp/BookStack
php
<|fim_suffix|>D_BACKUP_CODES = 'backup_codes'; /** * Get all the MFA methods available. */ public static function allMethods(): array { return [self::METHOD_TOTP, self::METHOD_BACKUP_CODES]; } /** * Upsert a new MFA value for the given user and method * using the provid...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Access\Mfa; use BookStack\Exceptions\NotifyException; use BookStack\Users\Models\User; use Illuminate\Cache\RateLimiter; use Illuminate\Http\Request; use Illuminate\Http\Response;<|fim_suffix|>tooManyAttempts($this->getRequestKey($request), $this->maxIpAttemptsPerMinute + 1); ...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookSta<|fim_suffix|>ublic function verifyCode(string $code, string $secret): bool { /** @noinspection PhpUnhandledExceptionInspection */ return $this->google2fa->verifyKey($secret, $code); } } <|fim_middle|>ck\Access\Mfa; use BaconQrCode\Renderer\Color\Rgb; use B...
fim
BookStackApp/BookStack
php
<|fim_suffix|>} <|fim_prefix|><?php namespace BookStack\Access\Mfa; use Closure; use Illuminate\Contracts\Validation\ValidationRule; class TotpValidationRule implements ValidationRule { /** * Create a new rule instance. * Takes the TOTP secret that must be system provided, not user provided. */ ...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\<|fim_suffix|>->greeting(trans('auth.email_confirm_greeting', $appName)) ->line(trans('auth.email_confirm_text')) ->action(trans('auth.email_confirm_action'), url('/register/confirm/' . $this->token)); } } <|fim_middle|>Access\Notifications; ...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Access\Notifications; use BookStack\App\MailNotification; use BookStack\Users\Models\User; use Illuminate\Notifications\Messages\MailMessage; class ResetPasswordNotification extends MailNotification { public function __co<|fim_suffix|>ser $notifiable): MailMessage { ...
fim
BookStackApp/BookStack
php
<|fim_suffix|> ->greeting($locale->trans('auth.user_invite_email_greeting', $appName)) ->line($locale->trans('auth.user_invite_email_text')) ->action($locale->trans('auth.user_invite_email_action'), url('/register/invite/' . $this->token)); } } <|fim_prefix|><?php na...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Access\Oidc; use InvalidArgumentException; use League\OAuth2\Client\Token\AccessToken; class OidcAccessToken extends AccessToken { /** * Constructs an access token. * * @param array $options An array of options returned by the service provider * ...
fim
BookStackApp/BookStack
php
<|fim_suffix|>eption { } <|fim_prefix|><?php names<|fim_middle|>pace BookStack\Access\Oidc; use Exception; class OidcException extends Exc<|endoftext|>
fim
BookStackApp/BookStack
php
<|fim_suffix|>Claim contains its client_id value registered // at the Issuer identified by the iss (issuer) Claim as an audience. The ID Token MUST be rejected // if the ID Token does not list the Client as a valid audience, or if it contains additional // audiences not trusted by the Client. ...
fim
BookStackApp/BookStack
php
<|fim_suffix|>idKeyException extends \Exception { } <|fim_prefix|><?php namespace BookStack\A<|fim_middle|>ccess\Oidc; class OidcInval<|endoftext|>
fim
BookStackApp/BookStack
php
<|fim_suffix|>on { } <|fim_prefix|><?php <|fim_middle|> namespace BookStack\Access\Oidc; use Exception; class OidcInvalidTokenException extends Excepti<|endoftext|>
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Access\Oidc; use Exceptio<|fim_suffix|> extends Exception { } <|fim_middle|>n; class OidcIssuerDiscoveryException<|endoftext|>
fim
BookStackApp/BookStack
php
<?php namespace BookStack\Access\Oidc; use phpseclib3\Crypt\Common\PublicKey; use phpseclib3\Crypt\PublicKeyLoader; use phpseclib3\Crypt\RSA; use phpseclib3\Math\BigInteger; class OidcJwtSigningKey { protected PublicKey $key; /** * Can be created either from a JWK parameter array or local file path to ...
fim
BookStackApp/BookStack
php
<|fim_suffix|>okens. * As per https://openid.net/specs/openid-connect-basic-1_0.html#IDTokenValidation * and https://openid.net/specs/openid-connect-core-1_0.html#UserInfoResponse * * @throws OidcInvalidTokenException */ protected function validateCommonClaims(string $clientId): void { ...
fim
BookStackApp/BookStack
php
<|fim_suffix|> */ protected function getPkceMethod(): string { return static::PKCE_METHOD_S256; } } <|fim_prefix|><?php namespace BookStack\Access\Oidc; use League\OAuth2\Client\Grant\AbstractGrant; use League\OAuth2\Client\Provider\AbstractProvider; use League\OAuth2\Client\Provider\Exception\I...
fim
BookStackApp/BookStack
php
<|fim_suffix|>Settings; } /** * Filter the given JWK keys down to just those we support. */ protected function filterKeys(array $keys): array { return array_filter($keys, function (array $key) { $alg = $key['alg'] ?? 'RS256'; $use = $key['use'] ?? 'sig'; ...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Access\Oidc; use BookStack\Access\GroupSyncService; use BookStack\Access\LoginService; use BookStack\Access\RegistrationService; use BookStack\Exceptions\JsonDebugException; use BookStack\Exceptions\StoppedAuthenticationException; use BookStack\Exceptions\UserRegistrationExcept...
fim
BookStackApp/BookStack
php
<?php namespace BookStack\Access\Oidc; use Illuminate\Support\Arr; class OidcUserDetails { public function __construct( public ?string $externalId = null, public ?string $email = null, public ?string $name = null, public ?array $groups = null, public ?string $picture = nul...
fim
BookStackApp/BookStack
php
<|fim_suffix|>T on the request. // If the Client has provided a userinfo_encrypted_response_alg parameter during Registration, decrypt the UserInfo Response using the keys specified during Registration. // We don't currently support JWT encryption for OIDC // If the response was signed, the Cl...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Access\Oidc; interface ProvidesClaims { /** * Fetch a specific claim. * Returns null if it is null or does not<|fim_suffix|>getClaim(string $claim): mixed; /** * Get all contained claims. */ public function getAllClaims(): array; } <|fim_middle|...
fim
BookStackApp/BookStack
php
<?php namespace BookStack\Access; use BookStack\Activity\ActivityType; use BookStack\Exceptions\UserRegistrationException; use BookStack\Facades\Activity; use BookStack\Facades\Theme; use BookStack\Theming\ThemeEvents; use BookStack\Users\Models\User; use BookStack\Users\UserRepo; use Exception; use Illuminate\Suppor...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Access; use BookStack\Exceptions\JsonDebugException; use BookStack\Exceptions\SamlException; use BookStack\Exceptions\StoppedAuthenticationException; use BookStack\Exceptions\UserRegistrationException; use BookStack\Users\Models\User; use Exception; use OneLogin\Saml2\Auth; use...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Access; use BookStack\Activity\Models\Loggable; use BookStack\App\Model; use BookStack\Users\Models\User; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Relations\BelongsTo; /** * @property string $driver * @property User $user */ ...
fim
BookStackApp/BookStack
php
<?php namespace BookStack\Access; use BookStack\Exceptions\SocialDriverNotConfigured; use BookStack\Exceptions\SocialSignInAccountNotUsed; use BookStack\Exceptions\UserRegistrationException; use BookStack\Users\Models\User; use Illuminate\Support\Str; use Laravel\Socialite\Contracts\Factory as Socialite; use Laravel\...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Access; use BookStack\Exceptions\SocialDriverNotConfigured; use Illuminate\Support\Facades\Event; use Illuminate\Support\Str; use SocialiteProviders\Manager\SocialiteWasCalled; class SocialDriverManager { /** * The default built-in social drivers we support. * ...
fim
BookStackApp/BookStack
php
<|fim_suffix|>ption extends Exception { // } <|fim_prefix|><?php names<|fim_middle|>pace BookStack\Access; use Exception; class UserInviteExce<|endoftext|>
fim
BookStackApp/BookStack
php
<|fim_suffix|> $this->deleteByUser($user); $token = $this->createTokenForUser($user); try { $user->notify(new UserInviteNotification($token)); } catch (\Exception $exception) { throw new UserInviteException($exception->getMessage(), $exception->getCode(), $exception...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Access; use BookStack\Exceptions\UserTokenExpiredException; use BookStack\Exceptions\UserTokenNotFoundException; use BookStack\Users\Models\User; use Carbon\Carbon; use Illuminate\Support\Facades\DB; use Illuminate\Support\Str; use stdClass; class UserTokenService { /** ...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?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\P...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?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'; cons...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?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\Datab...
fim
BookStackApp/BookStack
php
<|fim_suffix|>rn $this->apiListingResponse($query, [ 'id', 'type', 'detail', 'user_id', 'loggable_id', 'loggable_type', 'ip', 'created_at', ]); } } <|fim_prefix|><?php namespace BookStack\Activity\Controllers; use BookStack\Activity\Models\Activity; <|fim_middle|>use BookStack\Http\ApiControll...
fim
BookStackApp/BookStack
php
<|fim_suffix|>(), $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('crea...
fim
BookStackApp/BookStack
php
<|fim_suffix|>Repo->getVisibleById(intval($id)); $this->checkOwnablePermission(Permission::CommentDelete, $comment); $this->commentRepo->delete($comment); return response('', 204); } } <|fim_prefix|><?php declare(strict_types=1); namespace BookStack\Activity\Controllers; use BookStack\A...
fim
BookStackApp/BookStack
php
<|fim_suffix|>turn view('comments.comment', [ 'comment' => $comment, 'readOnly' => false, ]); } /** * Mark a comment as archived. */ public function archive(int $id) { $comment = $this->commentRepo->getById($id); $this->checkOwnablePermission(Pe...
fim
BookStackApp/BookStack
php
<|fim_suffix|> public function remove(Request $request) { $modelInfo = $this->validate($request, $this->entityHelper->validationRules()); $entity = $this->entityHelper->getVisibleEntityFromRequestData($modelInfo); $entity->favourites()->where([ 'user_id' => user()->id, ]...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php declare(strict_types=1); namespace BookStack\Activity\Controllers; use BookStack\Activity\TagRepo; use BookStack\Http\ApiController; use Illuminate\Http\JsonR<|fim_suffix|>se; use Illuminate\Http\Request; /** * Endpoints to query data about tags in the system. * You'll only see results based o...
fim
BookStackApp/BookStack
php
<|fim_suffix|> $suggestions = $this->tagRepo->getValueSuggestions($searchTerm, $tagName); return response()->json($suggestions); } } <|fim_prefix|><?php namespace BookStack\Activity\Controllers; use BookStack\Activity\TagRepo; use BookStack\Http\Controller; use BookStack\Util\SimpleListOptions; us...
fim
BookStackApp/BookStack
php
<|fim_suffix|>ntityRequestHelper $entityHelper) { $this->checkPermission(Permission::ReceiveNotifications); $this->preventGuestAccess(); $requestData = $this->validate($request, array_merge([ 'level' => ['required', 'string'], ], $entityHelper->validationRules())); ...
fim
BookStackApp/BookStack
php
<|fim_suffix|> $validated = $this->validate($request, [ 'name' => ['required', 'max:150'], 'endpoint' => ['required', 'url', 'max:500'], 'events' => ['required', 'array'], 'active' => ['required'], 'timeout' => ['required', 'integer', 'min:1', 'ma...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?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 Bo...
fim
BookStackApp/BookStack
php
<|fim_suffix|>Activity matches the general information of another. */ public function isSimilarTo(self $activityB): bool { return [$this->type, $this->loggable_type, $this->loggable_id] === [$activityB->type, $activityB->loggable_type, $activityB->loggable_id]; } } <|fim_prefix|><?php namespac...
fim
BookStackApp/BookStack
php
<|fim_suffix|> * Scope the query to just the comments visible to the user based upon the * user visibility of what has been commented on. */ public function scopeVisible(Builder $query): Builder { return app()->make(PermissionApplicator::class) ->restrictEntityRelationQuery($query...
fim
BookStackApp/BookStack
php
<|fim_suffix|>d favourite instances. */ public function favourites(): MorphMany; } <|fim_prefix|><?php namespace BookStack\Activity\Models; use Illu<|fim_middle|>minate\Database\Eloquent\Relations\MorphMany; interface Favouritable { /** * Get the relate<|endoftext|>
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Activity\Models; use BookStack\App\Model; use BookStack\Permissions\Models\JointPermission; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\MorphTo; class Favourite extends Mo...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Act<|fim_suffix|> */ public function logDescriptor(): string; } <|fim_middle|>ivity\Models; interface Loggable { /** * Get the string descriptor for this item. <|endoftext|>
fim
BookStackApp/BookStack
php
<|fim_suffix|>ory'; } <|fim_prefix|><?php namespace BookStack\Activity\Model<|fim_middle|>s; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Carbon; /** * @property int $id * @property string $mentionable_type * @property int $mentionable_id * @property int $from_user_id * @property int $to_user_...
fim
BookStackApp/BookStack
php
<|fim_suffix|>ny { return $this->hasMany(JointPermission::class, 'entity_id', 'entity_id') ->whereColumn('tags.entity_type', '=', 'joint_permissions.entity_type'); } /** * Get a full URL to start a tag name search for this tag name. */ public function nameUrl(): string ...
fim
BookStackApp/BookStack
php
<|fim_suffix|>urn 0; } /** @var View $view */ $view = $viewable->views()->firstOrNew([ 'user_id' => $user->id, ], ['views' => 0]); $view->forceFill(['views' => $view->views + 1])->save(); return $view->views; } } <|fim_prefix|><?php namespace BookStack...
fim
BookStackApp/BookStack
php
<?php namespace BookStack\Activity\Models; use Illuminate\Database\Eloquent\Relations\MorphMany; interface Viewable { /** * Get all view instances for this viewable model. */ public function views(): MorphMany; } <|endoftext|>
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Activity\Models; use BookStack\Activity\WatchLevels; use BookStack\Permissions\Models\JointPermission; use Carbon\Carbon; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasMany; use Illum...
fim
BookStackApp/BookStack
php
<|fim_suffix|> } /** * Get the string descriptor for this item. */ public function logDescriptor(): string { return "({$this->id}) {$this->name}"; } } <|fim_prefix|><?php namespace BookStack\Activity\Models; use BookStack\Activity\ActivityType; use Carbon\Carbon; use Illuminate\Dat...
fim
BookStackApp/BookStack
php
<?php namespace BookStack\Activity\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; /** * @property int $id * @property int $webhook_id * @property string $event */ class WebhookTrackedEvent extends Model { use HasFactory; protected $fillable =...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Activity\Notifications\Handlers; use BookStack\Activity\Models\Loggable; use BookStack\Activity\Notifications\Messages\BaseActivityNotification; use BookStack\Entities\Models\Entity; use BookStack\Permissions\Permission; use BookStack\Permissions\PermissionApplicator; use BookS...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Activity\Notifications\Handlers; use BookStack\Activity\Models\Activity; use BookStack\Activity\Models\Comment; use BookStack\Activity\Models\Loggable; use BookStack\Activity\Notifications\Messages\CommentCreationNotification; use BookStack\Activity\Tools\EntityWatchers; use Bo...
fim
BookStackApp/BookStack
php
<|fim_suffix|>nt->getMorphClass()) ->pluck('to_user_id') ->toArray(); } } <|fim_prefix|><?php namespace BookStack\Activity\Notifications\Handlers; use BookStack\Activity\ActivityType; use BookStack\Activity\Models\Activity; use BookStack\Activity\Models\Comment; use BookStack\Activity\Mode...
fim
BookStackApp/BookStack
php
<|fim_suffix|>le; use BookStack\Users\Models\User; interface NotificationHandler { /** * Run this handler. * Provides the activity, related activity detail/model * along with the user that triggered the activity. */ public function handle(Activity $activity, string|Loggable $detail, User $u...
fim
BookStackApp/BookStack
php
<|fim_suffix|>fications must be a page"); } $watchers = new EntityWatchers($detail, WatchLevels::NEW); $this->sendNotificationToUserIds(PageCreationNotification::class, $watchers->getWatcherUserIds(), $user, $detail, $detail); } } <|fim_prefix|><?php namespace BookStack\Activity\Notificati...
fim
BookStackApp/BookStack
php
<|fim_suffix|>tificationPrefs = new UserNotificationPreferences($detail->ownedBy); if ($userNotificationPrefs->notifyOnOwnPageChanges()) { $watcherIds[] = $detail->owned_by; } } $this->sendNotificationToUserIds(PageUpdateNotification::class, $watcherIds, $user, $...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Activity\Notifications\MessageParts; use Book<|fim_suffix|>public function __construct( protected Entity $entity, protected int $nameLength = 120, ) { } public function toHtml(): string { return '<a href="' . e($this->entity->getUrl()) ....
fim
BookStackApp/BookStack
php
<|fim_suffix|>lic function __construct( protected array $entities ) { $this->entityLinks = array_map(fn (Entity $entity) => new EntityLinkMessageLine($entity, 24), $this->entities); } public function toHtml(): string { $entityHtmls = array_map(fn (EntityLinkMessageLine $line) =>...
fim
BookStackApp/BookStack
php
<|fim_suffix|>, ) { } public function toHtml(): string { $link = '<a href="' . e($this->url) . '">' . e($this->linkText) . '</a>'; return str_replace(':link', $link, e($this->line)); } public function __toString(): string { $link = "{$this->linkText} ({$this->url})"...
fim
BookStackApp/BookStack
php
<|fim_suffix|>able, Stringable { public function __construct( protected array $list ) { } public function toHtml(): string { $list = []; foreach ($this->list as $header => $content) { $list[] = '<strong>' . e($header) . '</strong> ' . e($content); } ...
fim
BookStackApp/BookStack
php
<?php namespace BookStack\Activity\Notifications\Messages; use BookStack\Activity\Models\Loggable; use BookStack\Activity\Notifications\MessageParts\EntityPathMessageLine; use BookStack\Activity\Notifications\MessageParts\LinkedMailMessageLine; use BookStack\App\MailNotification; use BookStack\Entities\Models\Entity;...
fim
BookStackApp/BookStack
php
<|fim_suffix|>ocale)); } } <|fim_prefix|><?php namespace BookStack\Activity\Notifications\Messages; use BookStack\Activity\Models\Comment; use BookStack\Activity\Notifications\MessageParts\EntityLinkMessageLine; use BookStack\Activity\Notifications\MessageParts\ListMessageLine; use BookStack\Entities\Models\Page;...
fim
BookStackApp/BookStack
php
<|fim_suffix|>t($locale->trans('notifications.comment_mention_subject', ['pageName' => $page->getShortName()])) ->line($locale->trans('notifications.comment_mention_intro', ['appName' => setting('app-name')])) ->line(new ListMessageLine($listLines)) ->action($locale->trans('notificat...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Activity\Notifications\Messages; use BookStack\Activity\Notifications\MessageParts\EntityLinkMessageLine; use BookStack\Activity\Notifications\MessageParts\ListMessageLine; use BookStack\Entities\Models\Page; use BookStack\Users\Models\User; use Illuminate\Notifications\Message...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Activity\Notifications\Messages; use BookStack\Activity\Notifications\Messa<|fim_suffix|>tification { public function toMail(User $notifiable): MailMessage { /** @var Page $page */ $page = $this->detail; $locale = $notifiable->getLocale(); ...
fim
BookStackApp/BookStack
php
<|fim_suffix|>PageUpdateNotificationHandler; use BookStack\Users\Models\User; class NotificationManager { /** * @var array<string, class-string<NotificationHandler>[]> */ protected array $handlersByActivity = []; public function handle(Activity $activity, string|Loggable $detail, User $user): vo...
fim
BookStackApp/BookStack
php
<|fim_suffix|> ->orderBy($listOptions->getSort(), $listOptions->getOrder()); if ($listOptions->getSearch()) { $term = '%' . $listOptions->getSearch() . '%'; $query->where(function ($query) use ($term) { $query->where('name', 'like', $term) ->orWher...
fim
BookStackApp/BookStack
php
<|fim_suffix|> })->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. */ p...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Activity\Tools; use BookStack\Activity\DispatchWebhookJob; use BookStack\Activity\Models\Activity; use BookStack\Activity\Models\Loggable; use BookStack\Activity\Models\Webhook; use<|fim_suffix|> BookStack\Theming\ThemeEvents; use Illuminate\Database\Eloquent\Builder; use Illum...
fim
BookStackApp/BookStack
php
<?php namespace BookStack\Activity\Tools; use BookStack\Activity\Models\Comment; use BookStack\Entities\Models\Page; use BookStack\Permissions\Permission; class CommentTree { /** * The built nested tree structure array. * @var CommentTreeNode[] */ protected array $tree; /** * A linea...
fim
BookStackApp/BookStack
php
<|fim_suffix|>struct(Comment $comment, int $depth, array $children) { $this->comment = $comment; $this->depth = $depth; $this->children = $children; } } <|fim_prefix|><?php namespace BookStack\Activity\Tools; use BookStack\Activity\Models\Comment; class CommentTreeNode { public Co...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Activity\Tools; use BookStack\Activity\Models\Watch; use BookStack\Entities\Models\BookChild; use BookStack\Entities\Models\Entity; use BookStack\Entities\Models\Page; use Illuminate\Database\Eloquent\Builder; class EntityWatchers { /** * @var int[] */ protec...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Activity\Tools; class IpFormatter { protected string $ip; protected int $precision; public function __construct(string $ip, int $precision) { $this->ip = trim($ip); $this->precision = max(0, min($precision, 4)); } public function format...
fim
BookStackApp/BookStack
php
<|fim_suffix|>); } } <|fim_prefix|><?php namespace BookStack\Activity\Tools; use BookStack\Util\HtmlDocument; use DOMElement; class MentionParser { public function parseUserIdsFromHtml(string $html): array { $doc = new HtmlDocument($html); $ids = []; $mentionLinks = $doc->queryXP...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Activity\Tools; use BookStack\Activity\Models\Tag; use BookStack\Entities\Models\BookChild; use BookStack\Entities\Models\Entity; use BookStack\Entities\Models\Page; use BookStack\Permissions\Permission; class TagClassGenerator { public function __construct( protec...
fim
BookStackApp/BookStack
php
<|fim_suffix|> 'user_id' => $this->user->id, ], [ 'level' => $levelValue, ]); $this->watchMap = null; } protected function remove(): void { $this->entityQuery()->delete(); $this->watchMap = null; } protected function entityQuery(): Builde...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Activity\Tools; use BookStack\Activity<|fim_suffix|> } public function ignoring(): bool { return $this->level === WatchLevels::IGNORE; } } <|fim_middle|>\WatchLevels; class WatchedParentDetails { public function __construct( public string $ty...
fim
BookStackApp/BookStack
php
<|fim_suffix|>): void { // Load entity owner, creator, updater details $this->addModelFormatter( fn ($event, $model) => ($model instanceof Entity), fn ($model) => $model->load(['ownedBy', 'createdBy', 'updatedBy']) ); // Load revision detail for page update a...
fim
BookStackApp/BookStack
php
<|fim_suffix|>faults 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'; } } <...
fim
BookStackApp/BookStack
php