Skip to content

Commit

Permalink
chore(deps): bump glob-parent from 3.1.0 to 5.1.2 in /extensions/emoj…
Browse files Browse the repository at this point in the history
…i/js (#3345)

* chore(deps): bump glob-parent in /extensions/emoji/js

Bumps [glob-parent](https://github.com/gulpjs/glob-parent) from 3.1.0 to 5.1.2.
- [Release notes](https://github.com/gulpjs/glob-parent/releases)
- [Changelog](https://github.com/gulpjs/glob-parent/blob/main/CHANGELOG.md)
- [Commits](gulpjs/glob-parent@v3.1.0...v5.1.2)

---
updated-dependencies:
- dependency-name: glob-parent
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

* Apply fixes from StyleCI

[ci skip] [skip ci]

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: StyleCI Bot <[email protected]>
  • Loading branch information
dependabot[bot] and StyleCIBot authored Mar 11, 2022
1 parent 715a679 commit 344e8e7
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 27 deletions.
14 changes: 6 additions & 8 deletions extend.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<?php

/*
* This file is part of flarum/nickname.
* This file is part of Flarum.
*
* Copyright (c) 2020 Flarum.
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/

namespace Flarum\Nicknames;
Expand All @@ -21,12 +19,12 @@

return [
(new Extend\Frontend('forum'))
->js(__DIR__ . '/js/dist/forum.js'),
->js(__DIR__.'/js/dist/forum.js'),

(new Extend\Frontend('admin'))
->js(__DIR__ . '/js/dist/admin.js'),
->js(__DIR__.'/js/dist/admin.js'),

new Extend\Locales(__DIR__ . '/locale'),
new Extend\Locales(__DIR__.'/locale'),

(new Extend\User())
->displayNameDriver('nickname', NicknameDriver::class),
Expand Down
17 changes: 12 additions & 5 deletions migrations/2020_11_23_000000_add_nickname_column.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
<?php

/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Schema\Builder;

return [
'up' => function(Builder $schema) {
if (!$schema->hasColumn('users', 'nickname')) {
$schema->table('users', function (Blueprint $table) use ($schema) {
'up' => function (Builder $schema) {
if (! $schema->hasColumn('users', 'nickname')) {
$schema->table('users', function (Blueprint $table) {
$table->string('nickname', 150)->after('username')->index()->nullable();
});
}
},
'down' => function(Builder $schema) {
$schema->table('users', function (Blueprint $table) use ($schema) {
'down' => function (Builder $schema) {
$schema->table('users', function (Blueprint $table) {
$table->dropColumn('nickname');
});
}
Expand Down
7 changes: 7 additions & 0 deletions migrations/2021_11_16_000000_nickname_column_nullable.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<?php

/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Schema\Builder;

Expand Down
6 changes: 3 additions & 3 deletions src/Access/UserPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ public function __construct(SettingsRepositoryInterface $settings)
*/
public function editNickname(User $actor, User $user)
{
if ($actor->isGuest() && !$user->exists && $this->settings->get('flarum-nicknames.set_on_registration')) {
if ($actor->isGuest() && ! $user->exists && $this->settings->get('flarum-nicknames.set_on_registration')) {
return $this->allow();
} else if ($actor->id === $user->id && $actor->hasPermission('user.editOwnNickname')) {
} elseif ($actor->id === $user->id && $actor->hasPermission('user.editOwnNickname')) {
return $this->allow();
} else if ($actor->can('edit', $user)) {
} elseif ($actor->can('edit', $user)) {
return $this->allow();
}
}
Expand Down
13 changes: 9 additions & 4 deletions src/AddNicknameValidation.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<?php

/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/

namespace Flarum\Nicknames;

Expand All @@ -19,7 +25,6 @@ class AddNicknameValidation
*/
protected $translator;


public function __construct(SettingsRepositoryInterface $settings, TranslatorInterface $translator)
{
$this->settings = $settings;
Expand All @@ -34,12 +39,12 @@ public function __invoke($flarumValidator, Validator $validator)
$rules['nickname'] = [
function ($attribute, $value, $fail) {
$regex = $this->settings->get('flarum-nicknames.regex');
if ($regex && !preg_match_all("/$regex/", $value)) {
if ($regex && ! preg_match_all("/$regex/", $value)) {
$this->translator->trans('flarum-nicknames.api.invalid_nickname_message');
}
},
'min:' . $this->settings->get('flarum-nicknames.min'),
'max:' . $this->settings->get('flarum-nicknames.max'),
'min:'.$this->settings->get('flarum-nicknames.min'),
'max:'.$this->settings->get('flarum-nicknames.max'),
'nullable'
];

Expand Down
11 changes: 9 additions & 2 deletions src/NicknameDriver.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
<?php

/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/

namespace Flarum\Nicknames;

use Flarum\User\DisplayName\DriverInterface;
use Flarum\User\User;

class NicknameDriver implements DriverInterface {

class NicknameDriver implements DriverInterface
{
public function displayName(User $user): string
{
return $user->nickname ? $user->nickname : $user->username;
Expand Down
9 changes: 7 additions & 2 deletions src/NicknameFullTextGambit.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<?php

/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/

namespace Flarum\Nicknames;

Expand All @@ -14,7 +20,6 @@
use Flarum\Search\SearchState;
use Flarum\User\UserRepository;


class NicknameFullTextGambit implements GambitInterface
{
/**
Expand All @@ -40,7 +45,7 @@ private function getUserSearchSubQuery($searchValue)
->query()
->select('id')
->where('username', 'like', "{$searchValue}%")
->orWhere('nickname', 'like',"{$searchValue}%");
->orWhere('nickname', 'like', "{$searchValue}%");
}

/**
Expand Down
14 changes: 11 additions & 3 deletions src/SaveNicknameToDatabase.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
<?php

/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/

namespace Flarum\Nicknames;

use Flarum\Settings\SettingsRepositoryInterface;
use Flarum\User\Event\Saving;
use Flarum\User\Exception\PermissionDeniedException;
use Illuminate\Support\Arr;

class SaveNicknameToDatabase {
class SaveNicknameToDatabase
{
/**
* @var SettingsRepositoryInterface
*/
protected $settings;

public function __construct(SettingsRepositoryInterface $settings) {
public function __construct(SettingsRepositoryInterface $settings)
{
$this->settings = $settings;
}

Expand Down

0 comments on commit 344e8e7

Please sign in to comment.