New Admin Panel settings (enableWebDAV & shareMaxUploadSize)
This commit is contained in:
@@ -35,7 +35,9 @@ class AdminController
|
||||
* @OA\Property(property="disableBasicAuth", type="boolean", example=false),
|
||||
* @OA\Property(property="disableOIDCLogin", type="boolean", example=false)
|
||||
* ),
|
||||
* @OA\Property(property="globalOtpauthUrl", type="string", example="")
|
||||
* @OA\Property(property="globalOtpauthUrl", type="string", example=""),
|
||||
* @OA\Property(property="enableWebDAV", type="boolean", example=false),
|
||||
* @OA\Property(property="sharedMaxUploadSize", type="integer", example=52428800)
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(
|
||||
@@ -88,7 +90,9 @@ class AdminController
|
||||
* @OA\Property(property="disableBasicAuth", type="boolean", example=false),
|
||||
* @OA\Property(property="disableOIDCLogin", type="boolean", example=false)
|
||||
* ),
|
||||
* @OA\Property(property="globalOtpauthUrl", type="string", example="")
|
||||
* @OA\Property(property="globalOtpauthUrl", type="string", example=""),
|
||||
* @OA\Property(property="enableWebDAV", type="boolean", example=false),
|
||||
* @OA\Property(property="sharedMaxUploadSize", type="integer", example=52428800)
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(
|
||||
@@ -149,7 +153,7 @@ class AdminController
|
||||
exit;
|
||||
}
|
||||
|
||||
// Prepare configuration array.
|
||||
// Prepare existing settings
|
||||
$headerTitle = isset($data['header_title']) ? trim($data['header_title']) : "";
|
||||
$oidc = isset($data['oidc']) ? $data['oidc'] : [];
|
||||
$oidcProviderUrl = isset($oidc['providerUrl']) ? filter_var($oidc['providerUrl'], FILTER_SANITIZE_URL) : '';
|
||||
@@ -183,20 +187,38 @@ class AdminController
|
||||
}
|
||||
$globalOtpauthUrl = isset($data['globalOtpauthUrl']) ? trim($data['globalOtpauthUrl']) : "";
|
||||
|
||||
// ── NEW: enableWebDAV flag ──────────────────────────────────────
|
||||
$enableWebDAV = false;
|
||||
if (array_key_exists('enableWebDAV', $data)) {
|
||||
$enableWebDAV = filter_var($data['enableWebDAV'], FILTER_VALIDATE_BOOLEAN);
|
||||
} elseif (isset($data['features']['enableWebDAV'])) {
|
||||
$enableWebDAV = filter_var($data['features']['enableWebDAV'], FILTER_VALIDATE_BOOLEAN);
|
||||
}
|
||||
|
||||
// ── NEW: sharedMaxUploadSize ──────────────────────────────────────
|
||||
$sharedMaxUploadSize = null;
|
||||
if (array_key_exists('sharedMaxUploadSize', $data)) {
|
||||
$sharedMaxUploadSize = filter_var($data['sharedMaxUploadSize'], FILTER_VALIDATE_INT);
|
||||
} elseif (isset($data['features']['sharedMaxUploadSize'])) {
|
||||
$sharedMaxUploadSize = filter_var($data['features']['sharedMaxUploadSize'], FILTER_VALIDATE_INT);
|
||||
}
|
||||
|
||||
$configUpdate = [
|
||||
'header_title' => $headerTitle,
|
||||
'oidc' => [
|
||||
'providerUrl' => $oidcProviderUrl,
|
||||
'clientId' => $oidcClientId,
|
||||
'clientSecret' => $oidcClientSecret,
|
||||
'redirectUri' => $oidcRedirectUri,
|
||||
'header_title' => $headerTitle,
|
||||
'oidc' => [
|
||||
'providerUrl' => $oidcProviderUrl,
|
||||
'clientId' => $oidcClientId,
|
||||
'clientSecret' => $oidcClientSecret,
|
||||
'redirectUri' => $oidcRedirectUri,
|
||||
],
|
||||
'loginOptions' => [
|
||||
'loginOptions' => [
|
||||
'disableFormLogin' => $disableFormLogin,
|
||||
'disableBasicAuth' => $disableBasicAuth,
|
||||
'disableOIDCLogin' => $disableOIDCLogin,
|
||||
],
|
||||
'globalOtpauthUrl' => $globalOtpauthUrl
|
||||
'globalOtpauthUrl' => $globalOtpauthUrl,
|
||||
'enableWebDAV' => $enableWebDAV,
|
||||
'sharedMaxUploadSize' => $sharedMaxUploadSize // ← NEW
|
||||
];
|
||||
|
||||
// Delegate to the model.
|
||||
@@ -207,4 +229,4 @@ class AdminController
|
||||
echo json_encode($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -401,6 +401,20 @@ class FolderController
|
||||
*
|
||||
* @return void Outputs HTML content.
|
||||
*/
|
||||
|
||||
function formatBytes($bytes)
|
||||
{
|
||||
if ($bytes < 1024) {
|
||||
return $bytes . " B";
|
||||
} elseif ($bytes < 1024 * 1024) {
|
||||
return round($bytes / 1024, 2) . " KB";
|
||||
} elseif ($bytes < 1024 * 1024 * 1024) {
|
||||
return round($bytes / (1024 * 1024), 2) . " MB";
|
||||
} else {
|
||||
return round($bytes / (1024 * 1024 * 1024), 2) . " GB";
|
||||
}
|
||||
}
|
||||
|
||||
public function shareFolder(): void
|
||||
{
|
||||
// Retrieve GET parameters.
|
||||
@@ -495,12 +509,14 @@ class FolderController
|
||||
exit;
|
||||
}
|
||||
|
||||
// Extract data for the HTML view.
|
||||
$folderName = $data['folder'];
|
||||
$files = $data['files'];
|
||||
$currentPage = $data['currentPage'];
|
||||
$totalPages = $data['totalPages'];
|
||||
// Load admin config so we can pull the sharedMaxUploadSize
|
||||
require_once PROJECT_ROOT . '/src/models/AdminModel.php';
|
||||
$adminConfig = AdminModel::getConfig();
|
||||
$sharedMaxUploadSize = isset($adminConfig['sharedMaxUploadSize']) && is_numeric($adminConfig['sharedMaxUploadSize'])
|
||||
? (int)$adminConfig['sharedMaxUploadSize']
|
||||
: null;
|
||||
|
||||
// For human‐readable formatting
|
||||
function formatBytes($bytes)
|
||||
{
|
||||
if ($bytes < 1024) {
|
||||
@@ -514,6 +530,12 @@ class FolderController
|
||||
}
|
||||
}
|
||||
|
||||
// Extract data for the HTML view.
|
||||
$folderName = $data['folder'];
|
||||
$files = $data['files'];
|
||||
$currentPage = $data['currentPage'];
|
||||
$totalPages = $data['totalPages'];
|
||||
|
||||
// Build the HTML view.
|
||||
header("Content-Type: text/html; charset=utf-8");
|
||||
?>
|
||||
@@ -717,7 +739,11 @@ class FolderController
|
||||
<!-- Upload Container (if uploads are allowed by the share record) -->
|
||||
<?php if (isset($data['record']['allowUpload']) && $data['record']['allowUpload'] == 1): ?>
|
||||
<div class="upload-container">
|
||||
<h3>Upload File (50mb max size)</h3>
|
||||
<h3>Upload File
|
||||
<?php if ($sharedMaxUploadSize !== null): ?>
|
||||
(<?php echo formatBytes($sharedMaxUploadSize); ?> max size)
|
||||
<?php endif; ?>
|
||||
</h3>
|
||||
<form action="/api/folder/uploadToSharedFolder.php" method="post" enctype="multipart/form-data">
|
||||
<!-- Pass the share token so the upload endpoint can verify -->
|
||||
<input type="hidden" name="token" value="<?php echo htmlspecialchars($token, ENT_QUOTES, 'UTF-8'); ?>">
|
||||
|
||||
Reference in New Issue
Block a user