Skip to content

Commit 4ed7b26

Browse files
committed
Merge branch 'develop' of https://github.com/Pterodactyl/Panel into develop
2 parents eafb0c0 + 80bf6ba commit 4ed7b26

29 files changed

+414
-137
lines changed

app/Console/Commands/Environment/EmailSettingsCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ public function __construct(ConfigRepository $config)
6565
public function handle()
6666
{
6767
$this->variables['MAIL_DRIVER'] = $this->option('driver') ?? $this->choice(
68-
trans('command/messages.environment.mail.ask_driver'), [
68+
trans('command/messages.environment.mail.ask_driver'), [
6969
'smtp' => 'SMTP Server',
7070
'mail' => 'PHP\'s Internal Mail Function',
7171
'mailgun' => 'Mailgun Transactional Email',
7272
'mandrill' => 'Mandrill Transactional Email',
7373
'postmark' => 'Postmarkapp Transactional Email',
7474
], $this->config->get('mail.driver', 'smtp')
75-
);
75+
);
7676

7777
$method = 'setup' . studly_case($this->variables['MAIL_DRIVER']) . 'DriverVariables';
7878
if (method_exists($this, $method)) {

app/Contracts/Repository/UserRepositoryInterface.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,12 @@ public function getAllUsersWithCounts(): LengthAwarePaginator;
2222
* @return \Illuminate\Support\Collection
2323
*/
2424
public function filterUsersByQuery(?string $query): Collection;
25+
26+
/**
27+
* Returns a user with the given id in a format that can be used for dropdowns.
28+
*
29+
* @param int $id
30+
* @return \Pterodactyl\Models\Model
31+
*/
32+
public function filterById(int $id): \Pterodactyl\Models\Model;
2533
}

app/Helpers/Utilities.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Carbon\Carbon;
77
use Cron\CronExpression;
88
use Illuminate\Support\Facades\Log;
9+
use Illuminate\Support\ViewErrorBag;
910

1011
class Utilities
1112
{
@@ -50,4 +51,15 @@ public static function getScheduleNextRunDate(string $minute, string $hour, stri
5051
sprintf('%s %s %s * %s', $minute, $hour, $dayOfMonth, $dayOfWeek)
5152
)->getNextRunDate());
5253
}
54+
55+
public static function checked($name, $default)
56+
{
57+
$errors = session('errors');
58+
59+
if (isset($errors) && $errors instanceof ViewErrorBag && $errors->any()) {
60+
return old($name) ? 'checked' : '';
61+
}
62+
63+
return ($default) ? 'checked' : '';
64+
}
5365
}

app/Http/Controllers/Admin/DatabaseController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ public function update(DatabaseHostFormRequest $request, DatabaseHost $host): Re
165165
$this->alert->danger(
166166
sprintf('There was an error while trying to connect to the host or while executing a query: "%s"', $exception->getMessage())
167167
)->flash();
168+
168169
return $redirect->withInput($request->normalize());
169170
} else {
170171
throw $exception;

app/Http/Controllers/Admin/UserController.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,15 @@ public function update(UserFormRequest $request, User $user)
177177
* Get a JSON response of users on the system.
178178
*
179179
* @param \Illuminate\Http\Request $request
180-
* @return \Illuminate\Support\Collection
180+
* @return \Illuminate\Support\Collection|\Pterodactyl\Models\Model
181181
*/
182182
public function json(Request $request)
183183
{
184+
// Handle single user requests.
185+
if ($request->query('user_id')) {
186+
return $this->repository->filterById($request->input('user_id'));
187+
}
188+
184189
return $this->repository->filterUsersByQuery($request->input('q'));
185190
}
186191
}

app/Http/Controllers/Api/Client/Servers/ScheduleTaskController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function update(StoreTaskRequest $request, Server $server, Schedule $sche
8686
}
8787

8888
$this->repository->update($task->id, [
89-
'action' => $request->input('action'),
89+
'action' => $request->input('action'),
9090
'payload' => $request->input('payload'),
9191
'time_offset' => $request->input('time_offset'),
9292
]);

app/Http/Controllers/Api/Remote/Servers/ServerBackupController.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
namespace Pterodactyl\Http\Controllers\Api\Remote\Servers;
44

55
use Carbon\Carbon;
6-
use Illuminate\Http\Request;
7-
use Pterodactyl\Models\Server;
86
use Illuminate\Http\JsonResponse;
97
use Pterodactyl\Http\Controllers\Controller;
108
use Pterodactyl\Repositories\Eloquent\BackupRepository;

app/Repositories/Eloquent/UserRepository.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,22 @@ public function filterUsersByQuery(?string $query): Collection
5454
return $item;
5555
});
5656
}
57+
58+
/**
59+
* Returns a user with the given id in a format that can be used for dropdowns.
60+
*
61+
* @param int $id
62+
* @return \Pterodactyl\Models\Model
63+
*/
64+
public function filterById(int $id): \Pterodactyl\Models\Model
65+
{
66+
$this->setColumns([
67+
'id', 'email', 'username', 'name_first', 'name_last',
68+
]);
69+
70+
$model = $this->getBuilder()->findOrFail($id, $this->getColumns())->getModel();
71+
$model->md5 = md5(strtolower($model->email));
72+
73+
return $model;
74+
}
5775
}

app/Services/Nodes/NodeCreationService.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ public function __construct(Encrypter $encrypter, NodeRepositoryInterface $repos
4141
*/
4242
public function handle(array $data)
4343
{
44-
$data['daemon_token'] = Str::random(Node::DAEMON_TOKEN_LENGTH);
45-
$data['daemon_token_id'] = $this->encrypter->encrypt(Str::random(Node::DAEMON_TOKEN_ID_LENGTH));
44+
$data['daemon_token'] = $this->encrypter->encrypt(Str::random(Node::DAEMON_TOKEN_LENGTH));
45+
$data['daemon_token_id'] = Str::random(Node::DAEMON_TOKEN_ID_LENGTH);
4646

4747
return $this->repository->create($data, true, true);
4848
}

config/ide-helper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@
168168
| Cast the given "real type" to the given "type".
169169
|
170170
*/
171-
'type_overrides' => [
171+
'type_overrides' => [
172172
'integer' => 'int',
173173
'boolean' => 'bool',
174-
],
174+
],
175175
];

0 commit comments

Comments
 (0)