Skip to content

Commit 31a78ca

Browse files
authored
Merge pull request #2004 from Admidio/configurable-discspace-path
2 parents afaab04 + 9e1998c commit 31a78ca

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

install/db_scripts/preferences.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
'system_url_imprint' => '',
3737
'system_url_data_protection' => '',
3838
'password_min_strength' => '1',
39+
'path_for_calculating_disk_usage' => '',
3940

4041
// Theme
4142
'theme' => 'simple',

languages/en.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@
177177
<string name="ORG_PASSWORD_MIN_STRENGTH_MID">Middle</string>
178178
<string name="ORG_PASSWORD_MIN_STRENGTH_NO">None</string>
179179
<string name="ORG_PASSWORD_MIN_STRENGTH_VERY_HIGH">Very high</string>
180+
<string name="ORG_PATH_FOR_CALCULATING_DISK_USAGE">Path for calculating disk usage</string>
181+
<string name="ORG_PATH_FOR_CALCULATING_DISK_USAGE_DESC">The path to the folder for calculating the disk usage. This is used in the system information to calculate the disk usage of the Admidio installation. The path can be defined as an absolute path or as a relative path to the Admidio main directory. If the path is left blank, the disk usage will be calculated for the server\'s root directory. (default: empty)</string>
180182
<string name="ORG_PIXEL">Pixel</string>
181183
<string name="ORG_PROFILE_FIELDS">Profile fields</string>
182184
<string name="ORG_REFUSE_REGISTRATION">Notification on refusal of registration</string>

src/UI/Presenter/PreferencesPresenter.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,12 @@ public function createCommonForm(): string
618618
(bool) $formValues['system_browser_update_check'],
619619
array('helpTextId' => 'ORG_BROWSER_UPDATE_CHECK_DESC')
620620
);
621+
$formCommon->addInput(
622+
'path_for_calculating_disk_usage',
623+
$gL10n->get('ORG_PATH_FOR_CALCULATING_DISK_USAGE'),
624+
$formValues['path_for_calculating_disk_usage'],
625+
array('maxLength' => 250, 'helpTextId' => 'ORG_PATH_FOR_CALCULATING_DISK_USAGE_DESC')
626+
);
621627
$formCommon->addSubmitButton(
622628
'adm_button_save_common',
623629
$gL10n->get('SYS_SAVE'),
@@ -2456,7 +2462,7 @@ public function createSsoForm(): string
24562462
*/
24572463
public function createSystemInformationForm(): string
24582464
{
2459-
global $gL10n, $gDb, $gLogger, $gDebug, $gImportDemoData, $gSystemComponent;
2465+
global $gL10n, $gDb, $gLogger, $gDebug, $gImportDemoData, $gSystemComponent, $gSettingsManager;
24602466

24612467
// Admidio Version and Update
24622468
$component = new ComponentUpdate($gDb);
@@ -2554,7 +2560,18 @@ public function createSystemInformationForm(): string
25542560
$this->assignSmartyVariable('importModeText', $importModeText);
25552561

25562562
try {
2557-
$diskSpace = FileSystemUtils::getDiskSpace();
2563+
if ($gSettingsManager->has('path_for_calculating_disk_usage') && !empty($gSettingsManager->get('path_for_calculating_disk_usage'))) {
2564+
$pathForCalculatingDiskUsage = $gSettingsManager->get('path_for_calculating_disk_usage');
2565+
// if it's a relative path, we have to add the Admidio base path, otherwise we would calculate the disk usage for the whole system root if the relative path is empty or just the wrong path if its not empty
2566+
if (!str_starts_with($pathForCalculatingDiskUsage, '/') && !str_starts_with($pathForCalculatingDiskUsage, '\\')) {
2567+
$pathForCalculatingDiskUsage = ADMIDIO_PATH . DIRECTORY_SEPARATOR . $pathForCalculatingDiskUsage;
2568+
}
2569+
if (is_dir($pathForCalculatingDiskUsage)) {
2570+
$diskSpace = FileSystemUtils::getDiskSpace($pathForCalculatingDiskUsage);
2571+
}
2572+
} else {
2573+
$diskSpace = FileSystemUtils::getDiskSpace();
2574+
}
25582575
$progressBarClass = '';
25592576

25602577
$diskUsagePercent = round(($diskSpace['used'] / $diskSpace['total']) * 100, 1);

themes/simple/templates/preferences/preferences.common.tpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
{include 'sys-template-parts/form.input.tpl' data=$elements['system_url_imprint']}
1414
{include 'sys-template-parts/form.checkbox.tpl' data=$elements['system_js_editor_enabled']}
1515
{include 'sys-template-parts/form.checkbox.tpl' data=$elements['system_browser_update_check']}
16+
{include 'sys-template-parts/form.input.tpl' data=$elements['path_for_calculating_disk_usage']}
1617
{include 'sys-template-parts/form.button.tpl' data=$elements['adm_button_save_common']}
1718
<div class="form-alert" style="display: none;">&nbsp;</div>
1819
</form>

0 commit comments

Comments
 (0)