File transfer
This commit is contained in:
51
app/Addons/AdvancedAdmin/Models/FileRevision.php
Normal file
51
app/Addons/AdvancedAdmin/Models/FileRevision.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Ball Studios <https://git.balls.studio>
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Addons\AdvancedAdmin\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property int $server_id
|
||||
* @property string $file_path
|
||||
* @property string $path_hash
|
||||
* @property string $content_hash
|
||||
* @property int $revision_number
|
||||
* @property string $storage_key
|
||||
* @property string $storage_type
|
||||
* @property int $size_bytes
|
||||
* @property int $compressed_size
|
||||
* @property int $author_id
|
||||
* @property string $change_summary
|
||||
*/
|
||||
class FileRevision extends Model
|
||||
{
|
||||
protected $table = 'addon_file_revisions';
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
'server_id', 'file_path', 'path_hash', 'content_hash',
|
||||
'revision_number', 'storage_key', 'storage_type',
|
||||
'size_bytes', 'compressed_size', 'author_id', 'change_summary',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'created_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function server(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(\Pterodactyl\Models\Server::class, 'server_id');
|
||||
}
|
||||
|
||||
public function author(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(\Pterodactyl\Models\User::class, 'author_id');
|
||||
}
|
||||
}
|
||||
20
app/Addons/AdvancedAdmin/Models/FileRevisionStorageUsage.php
Normal file
20
app/Addons/AdvancedAdmin/Models/FileRevisionStorageUsage.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Ball Studios <https://git.balls.studio>
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Addons\AdvancedAdmin\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class FileRevisionStorageUsage extends Model
|
||||
{
|
||||
protected $table = 'addon_file_revision_storage_usage';
|
||||
protected $primaryKey = 'server_id';
|
||||
public $incrementing = false;
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = ['server_id', 'total_bytes'];
|
||||
}
|
||||
73
app/Addons/AdvancedAdmin/Models/Role.php
Normal file
73
app/Addons/AdvancedAdmin/Models/Role.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Ball Studios <https://git.balls.studio>
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Addons\AdvancedAdmin\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $description
|
||||
* @property string $color
|
||||
* @property int $priority
|
||||
* @property bool $is_default
|
||||
* @property int $created_by
|
||||
*/
|
||||
class Role extends Model
|
||||
{
|
||||
protected $table = 'addon_roles';
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'description',
|
||||
'color',
|
||||
'priority',
|
||||
'is_default',
|
||||
'created_by',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'priority' => 'integer',
|
||||
'is_default' => 'boolean',
|
||||
];
|
||||
|
||||
public function permissions(): HasMany
|
||||
{
|
||||
return $this->hasMany(RolePermission::class, 'role_id');
|
||||
}
|
||||
|
||||
public function assignments(): HasMany
|
||||
{
|
||||
return $this->hasMany(ServerRoleAssignment::class, 'role_id');
|
||||
}
|
||||
|
||||
public function creator(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(\Pterodactyl\Models\User::class, 'created_by');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this role is still assigned anywhere.
|
||||
*/
|
||||
public function isInUse(): bool
|
||||
{
|
||||
return $this->assignments()->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get permission value for a given key.
|
||||
* Returns 'allow', 'deny', or null (not set).
|
||||
*/
|
||||
public function getPermission(string $permission): ?string
|
||||
{
|
||||
$perm = $this->permissions()->where('permission', $permission)->first();
|
||||
return $perm?->value;
|
||||
}
|
||||
}
|
||||
52
app/Addons/AdvancedAdmin/Models/RoleAuditLog.php
Normal file
52
app/Addons/AdvancedAdmin/Models/RoleAuditLog.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Ball Studios <https://git.balls.studio>
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Addons\AdvancedAdmin\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class RoleAuditLog extends Model
|
||||
{
|
||||
protected $table = 'addon_role_audit_log';
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
'actor_id',
|
||||
'action',
|
||||
'target_type',
|
||||
'target_id',
|
||||
'payload',
|
||||
'ip_address',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'payload' => 'array',
|
||||
'created_at' => 'datetime',
|
||||
];
|
||||
|
||||
/**
|
||||
* Write a structured audit entry.
|
||||
*/
|
||||
public static function record(
|
||||
?int $actorId,
|
||||
string $action,
|
||||
string $targetType = '',
|
||||
?int $targetId = null,
|
||||
array $payload = [],
|
||||
string $ip = ''
|
||||
): void {
|
||||
static::create([
|
||||
'actor_id' => $actorId,
|
||||
'action' => $action,
|
||||
'target_type' => $targetType,
|
||||
'target_id' => $targetId,
|
||||
'payload' => $payload,
|
||||
'ip_address' => $ip ?: request()->ip(),
|
||||
'created_at' => now(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
23
app/Addons/AdvancedAdmin/Models/RolePermission.php
Normal file
23
app/Addons/AdvancedAdmin/Models/RolePermission.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Ball Studios <https://git.balls.studio>
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Addons\AdvancedAdmin\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class RolePermission extends Model
|
||||
{
|
||||
protected $table = 'addon_role_permissions';
|
||||
|
||||
protected $fillable = ['role_id', 'permission', 'value'];
|
||||
|
||||
public function role(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Role::class, 'role_id');
|
||||
}
|
||||
}
|
||||
21
app/Addons/AdvancedAdmin/Models/ServerPermissionOverride.php
Normal file
21
app/Addons/AdvancedAdmin/Models/ServerPermissionOverride.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Ball Studios <https://git.balls.studio>
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Addons\AdvancedAdmin\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ServerPermissionOverride extends Model
|
||||
{
|
||||
protected $table = 'addon_server_permission_overrides';
|
||||
|
||||
protected $fillable = ['server_id', 'user_id', 'permission', 'value', 'set_by'];
|
||||
|
||||
public function isAllow(): bool { return $this->value === 'allow'; }
|
||||
public function isDeny(): bool { return $this->value === 'deny'; }
|
||||
public function isUnset(): bool { return $this->value === 'unset'; }
|
||||
}
|
||||
33
app/Addons/AdvancedAdmin/Models/ServerRoleAssignment.php
Normal file
33
app/Addons/AdvancedAdmin/Models/ServerRoleAssignment.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Ball Studios <https://git.balls.studio>
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Addons\AdvancedAdmin\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class ServerRoleAssignment extends Model
|
||||
{
|
||||
protected $table = 'addon_server_role_assignments';
|
||||
|
||||
protected $fillable = ['server_id', 'user_id', 'role_id', 'assigned_by'];
|
||||
|
||||
public function role(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Role::class, 'role_id');
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(\Pterodactyl\Models\User::class, 'user_id');
|
||||
}
|
||||
|
||||
public function server(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(\Pterodactyl\Models\Server::class, 'server_id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user