Skip to content

Commit

Permalink
Development (#804)
Browse files Browse the repository at this point in the history
  • Loading branch information
1day2die authored May 3, 2023
2 parents 633a3d4 + 7d93d45 commit 05173fd
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 21 deletions.
3 changes: 3 additions & 0 deletions app/Http/Controllers/Admin/PaymentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

class PaymentController extends Controller
{
const BUY_PERMISSION = 'user.shop.buy';
/**
* @return Application|Factory|View
*/
Expand All @@ -41,6 +42,8 @@ public function index(LocaleSettings $locale_settings)
*/
public function checkOut(ShopProduct $shopProduct, GeneralSettings $general_settings)
{
$this->checkPermission(self::BUY_PERMISSION);

$discount = PartnerDiscount::getDiscount();
$price = $shopProduct->price - ($shopProduct->price * $discount / 100);

Expand Down
3 changes: 3 additions & 0 deletions app/Http/Controllers/Admin/RoleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ public function dataTable()


return datatables($query)
->editColumn('id', function (Role $role) {
return $role->id;
})
->addColumn('actions', function (Role $role) {
return '
<a title="Edit" href="'.route("admin.roles.edit", $role).'" class="btn btn-sm btn-info"><i
Expand Down
8 changes: 8 additions & 0 deletions app/Http/Controllers/ServerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use App\Classes\PterodactylClient;
use App\Settings\GeneralSettings;
use Exception;
use GuzzleHttp\Promise\Create;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\Client\Response;
use Illuminate\Http\RedirectResponse;
Expand All @@ -24,6 +25,9 @@

class ServerController extends Controller
{
const CREATE_PERMISSION = 'user.server.create';
const UPGRADE_PERMISSION = 'user.server.upgrade';

private $pterodactyl;

public function __construct(PterodactylSettings $ptero_settings)
Expand Down Expand Up @@ -81,6 +85,8 @@ public function index(GeneralSettings $general_settings, PterodactylSettings $pt
/** Show the form for creating a new resource. */
public function create(UserSettings $user_settings, ServerSettings $server_settings, GeneralSettings $general_settings)
{
$this->checkPermission(self::CREATE_PERMISSION);

$validate_configuration = $this->validateConfigurationRules($user_settings, $server_settings);

if (!is_null($validate_configuration)) {
Expand Down Expand Up @@ -316,6 +322,8 @@ public function show(Server $server, ServerSettings $server_settings, GeneralSet

public function upgrade(Server $server, Request $request)
{
$this->checkPermission(self::UPGRADE_PERMISSION);

if ($server->user_id != Auth::user()->id) {
return redirect()->route('servers.index');
}
Expand Down
4 changes: 4 additions & 0 deletions app/Http/Controllers/TicketsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

class TicketsController extends Controller
{
const READ_PERMISSION = 'user.ticket.read';
const WRITE_PERMISSION = 'user.ticket.write';
public function index(LocaleSettings $locale_settings)
{
return view('ticket.index', [
Expand Down Expand Up @@ -74,6 +76,7 @@ public function store(Request $request, TicketSettings $ticket_settings)

public function show($ticket_id, PterodactylSettings $ptero_settings)
{
$this->checkPermission(self::READ_PERMISSION);
try {
$ticket = Ticket::where('ticket_id', $ticket_id)->firstOrFail();
} catch (Exception $e) {
Expand Down Expand Up @@ -118,6 +121,7 @@ public function reply(Request $request)

public function create()
{
$this->checkPermission(self::WRITE_PERMISSION);
//check in blacklist
$check = TicketBlacklist::where('user_id', Auth::user()->id)->first();
if ($check && $check->status == 'True') {
Expand Down
2 changes: 1 addition & 1 deletion config/permission.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
* By default wildcard permission lookups are disabled.
*/

'enable_wildcard_permission' => false,
'enable_wildcard_permission' => true,

'cache' => [

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ public function up(): void
$this->migrator->add(
'website.motd_message',
$table_exists ? $this->getOldValue("SETTINGS::SYSTEM:MOTD_MESSAGE") :
'<h1 style="text-align: center;"><img style="display: block; margin-left: auto; margin-right: auto;" src="https://ctrlpanel.gg/img/controlpanel.png" alt="" width="200" height="200"><span style="font-size: 36pt;">Controlpanel.gg</span></h1>
<p><span style="font-size: 18pt;">Thank you for using our Software</span></p>
<p><span style="font-size: 18pt;">If you have any questions, make sure to join our <a href="https://discord.com/invite/4Y6HjD2uyU" target="_blank" rel="noopener">Discord</a></span></p>
<p><span style="font-size: 10pt;">(you can change this message in the <a href="admin/settings#system">Settings</a> )</span></p>'
'<h1 style=\"text-align: center;\"><img style=\"display: block; margin-left: auto; margin-right: auto;\" src=\"https:\/\/ctrlpanel.gg\/img\/controlpanel.png\" alt=\"\" width=\"200\" height=\"200\"><span style=\"font-size: 36pt;\">Controlpanel.gg<\/span><\/h1>\r\n<p><span style=\"font-size: 18pt;\">Thank you for using our Software<\/span><\/p>\r\n<p><span style=\"font-size: 18pt;\">If you have any questions, make sure to join our <a href=\"https:\/\/discord.com\/invite\/4Y6HjD2uyU\" target=\"_blank\" rel=\"noopener\">Discord<\/a><\/span><\/p>\r\n<p><span style=\"font-size: 10pt;\">(you can change this message in the <a href=\"admin\/settings#system\">Settings<\/a> )<\/span><\/p>'
);
$this->migrator->add('website.show_imprint', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:SHOW_IMPRINT") : false);
$this->migrator->add('website.show_privacy', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:SHOW_PRIVACY") : false);
Expand Down
4 changes: 3 additions & 1 deletion themes/default/views/admin/roles/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class="fa fas fa-shield-alt pe-2"></i>{{__('Create role')}}</a>
<table id="datatable" class="table table-striped">
<thead>
<tr>
<th>{{__("ID")}}</th>
<th>{{__("Name")}}</th>
<th>{{__("User count")}}</th>
<th>{{__("Permissions count")}}</th>
Expand All @@ -40,10 +41,11 @@ class="fa fas fa-shield-alt pe-2"></i>{{__('Create role')}}</a>
url: '//cdn.datatables.net/plug-ins/1.11.3/i18n/{{config("SETTINGS::LOCALE:DATATABLES")}}.json'
},
processing: true,
serverSide: false, //increases loading times too much? change back to "true" if it does
serverSide: true, //increases loading times too much? change back to "true" if it does
stateSave: true,
ajax: "{{route('admin.roles.datatable')}}",
columns: [
{data: 'id'},
{data: 'name'},
{data: 'usercount'},
{data: 'permissionscount'},
Expand Down
4 changes: 4 additions & 0 deletions themes/default/views/admin/settings/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ class="custom-select w-100" name="{{ $key }}"
</div>
</div>
@endforeach

<!-- TODO: Display this only on the General tab
<div class="row">
<div class="col-4 d-flex align-items-center">
<label for="recaptcha_preview">{{__("ReCAPTCHA Preview")}}</label>
Expand All @@ -179,6 +182,7 @@ class="custom-select w-100" name="{{ $key }}"
</div>
</div>
</div>
-->


<div class="row">
Expand Down
2 changes: 2 additions & 0 deletions themes/default/views/layouts/main.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,15 @@ class="nav-link @if (Request::routeIs('store.*') || Request::routeIs('checkout')
@endif
@php($ticket_enabled = app(App\Settings\TicketSettings::class)->enabled)
@if ($ticket_enabled)
@canany(["user.ticket.read", "user.ticket.write"])
<li class="nav-item">
<a href="{{ route('ticket.index') }}"
class="nav-link @if (Request::routeIs('ticket.*')) active @endif">
<i class="nav-icon fas fas fa-ticket-alt"></i>
<p>{{ __('Support Ticket') }}</p>
</a>
</li>
@endcanany
@endif

@if ((Auth::user()->hasRole(1) || Auth::user()->role == 'moderator') && $ticket_enabled)
Expand Down
6 changes: 3 additions & 3 deletions themes/default/views/profile/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class="fa fa-coins mr-2"></i>{{ $user->Credits() }}</span>
</div>

@if($referral_enabled)
@if(($referral_allowed === "client" && $user->role != "member") || $referral_allowed === "everyone")
@can("user.referral")
<div class="mt-1">
<span class="badge badge-success"><i
class="fa fa-user-check mr-2"></i>
Expand All @@ -112,8 +112,8 @@ class="fa fa-user-check mr-2"></i>
@else
<span class="badge badge-warning"><i
class="fa fa-user-check mr-2"></i>
{{_("Make a purchase to reveal your referral-URL")}}</span>
@endif
{{_("You can not see your Referral Code")}}</span>
@endcan
</div>
@endif
</div>
Expand Down
16 changes: 8 additions & 8 deletions themes/default/views/servers/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@

<!-- CUSTOM CONTENT -->
<div class="d-flex justify-content-md-start justify-content-center mb-3 ">
<a @if (Auth::user()->Servers->count() >= Auth::user()->server_limit)
disabled="disabled" title="Server limit reached!"
@endif href="{{ route('servers.create') }}"
class="btn
@if (Auth::user()->Servers->count() >= Auth::user()->server_limit) disabled
@endif btn-primary"><i
class="fa fa-plus mr-2"></i>
<a @if (Auth::user()->Servers->count() >= Auth::user()->server_limit) disabled="disabled" title="Server limit reached!" @endif
@cannot("user.server.create") disabled="disabled" title="No Permission!" @endcannot
href="{{ route('servers.create') }}" class="btn
@if (Auth::user()->Servers->count() >= Auth::user()->server_limit) disabled @endif
@cannot("user.server.create") disabled @endcannot
btn-primary">
<i class="fa fa-plus mr-2"></i>
{{ __('Create Server') }}
</a>
@if (Auth::user()->Servers->count() > 0 && !empty($phpmyadmin_url))
<a
<a
href="{{ $phpmyadmin_url }}" target="_blank"
class="btn btn-secondary ml-2"><i title="manage"
class="fas fa-database mr-2"></i><span>{{ __('Database') }}</span>
Expand Down
2 changes: 1 addition & 1 deletion themes/default/views/servers/settings.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@
<div class="card-footer">
<div class="col-md-12 text-center">
<!-- Upgrade Button trigger modal -->
@if($server_enable_upgrade)
@if($server_enable_upgrade && Auth::user()->can("user.server.upgrade"))
<button type="button" data-toggle="modal" data-target="#UpgradeModal{{ $server->id }}" target="__blank"
class="btn btn-info btn-md">
<i class="fas fa-upload mr-2"></i>
Expand Down
2 changes: 1 addition & 1 deletion themes/default/views/store/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
{{ $product->display }}
</td>
<td><a href="{{ route('checkout', $product->id) }}"
class="btn btn-info">{{ __('Purchase') }}</a>
class="btn btn-info @cannot('user.shop.buy') disabled @endcannot">{{ __('Purchase') }}</a>
</td>
</tr>
@endforeach
Expand Down
4 changes: 2 additions & 2 deletions themes/default/views/ticket/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
<div class="card-header">
<div class="d-flex justify-content-between">
<h5 class="card-title"><i class="fas fa-ticket-alt mr-2"></i>{{__('My Ticket')}}</h5>
<a href="{{route('ticket.new')}}" class="btn btn-sm btn-primary"><i
class="fas fa-plus mr-1"></i>{{__('New Ticket')}}</a>
<a href="{{route('ticket.new')}}" class="btn btn-sm btn-primary @cannot("user.ticket.write")) disabled @endcannot">
<i class="fas fa-plus mr-1"></i>{{__('New Ticket')}}</a>
</div>
</div>
<div class="card-body table-responsive">
Expand Down

0 comments on commit 05173fd

Please sign in to comment.