jenkins-bot has submitted this change and it was merged. Change subject: PermissionManager: add config and handler for max num of backups ......................................................................
PermissionManager: add config and handler for max num of backups correct indention as in comments set default value for maxbackups in bsconfig param as mentioned in comment Change-Id: I5e9dd812e9470d5585f8fd4c08842b19caa147b9 --- M PermissionManager/PermissionManager.class.php M PermissionManager/i18n/de.json M PermissionManager/i18n/en.json M PermissionManager/i18n/qqq.json 4 files changed, 17 insertions(+), 0 deletions(-) Approvals: Mglaser: Looks good to me, approved jenkins-bot: Verified diff --git a/PermissionManager/PermissionManager.class.php b/PermissionManager/PermissionManager.class.php index 731bd52..e19978f 100644 --- a/PermissionManager/PermissionManager.class.php +++ b/PermissionManager/PermissionManager.class.php @@ -23,6 +23,7 @@ * For further information visit http://www.blue-spice.org * * @author Sebastian Ulbricht <[email protected]> + * @author Leonid Verhovskij <[email protected]> * @version 2.23.1 * @package BlueSpice_Extensions * @subpackage PermissionManager @@ -130,6 +131,7 @@ BsConfig::registerVar( 'MW::PermissionManager::Lockmode', false, BsConfig::LEVEL_PUBLIC | BsConfig::TYPE_BOOL, 'bs-permissionmanager-pref-lockmode', 'toggle' ); BsConfig::registerVar( 'MW::PermissionManager::SkipSystemNS', false, BsConfig::LEVEL_PUBLIC | BsConfig::TYPE_BOOL, 'bs-permissionmanager-pref-skipsysns', 'toggle' ); BsConfig::registerVar( 'MW::PermissionManager::RealityCheck', false, BsConfig::LEVEL_PUBLIC | BsConfig::TYPE_BOOL | BsConfig::RENDER_AS_JAVASCRIPT, 'bs-permissionmanager-pref-enablerealitycheck', 'toggle' ); + BsConfig::registerVar( 'MW::PermissionManager::MaxBackups', 5, BsConfig::LEVEL_PUBLIC | BsConfig::TYPE_INT, 'bs-permissionmanager-pref-max-backups' ); $this->setHook( 'BSWikiAdminUserManagerBeforeUserListSend' ); $this->setHook( 'BSGroupManagerGroupNameChanged' ); @@ -702,5 +704,17 @@ file_put_contents( $backupFile, file_get_contents( $bsgConfigFiles['PermissionManager'] ) ); } + + //remove old backup files if max number exceeded + $arrConfigFiles = scandir( dirname( $bsgConfigFiles['PermissionManager'] ) . "/", SCANDIR_SORT_ASCENDING ); + $arrBackupFiles = array_filter( $arrConfigFiles, function( $elem ) { + return ( strpos( $elem, "pm-settings-backup-" ) !== FALSE ) ? true : false; + } ); + + //default limit to 5 backups, remove all backup files until "maxbackups" files left + while( count( $arrBackupFiles ) > BsConfig::get( "MW::PermissionManager::MaxBackups" ) ) { + $oldBackupFile = dirname( $bsgConfigFiles['PermissionManager'] ) . "/". array_shift( $arrBackupFiles ); + unlink( $oldBackupFile ); + } } } diff --git a/PermissionManager/i18n/de.json b/PermissionManager/i18n/de.json index bcde542..d8b41f1 100644 --- a/PermissionManager/i18n/de.json +++ b/PermissionManager/i18n/de.json @@ -40,6 +40,7 @@ "bs-permissionmanager-pref-lockmode": "Lockmode aktivieren", "bs-permissionmanager-pref-skipsysns": "Systemnamensräume bei eingschaltetem Lockmode ignorieren", "bs-permissionmanager-pref-enablerealitycheck": "Rechteprüfung aktivieren", + "bs-permissionmanager-pref-max-backups": "Maximale Anzahl an Sicherungen", "bs-permissionmanager-unsaved-changes": "Es existieren ungespeicherte Änderungen. Willst du die Seite wirklich verlassen? Die ungespeicherten Änderungen gehen in diesem Fall verloren", "bs-permissionmanager-error-lockout": "Mindestens eine Benutzergruppe muss das Recht \"$1\" besitzen.\nDie Änderungen konnten nicht gespeichert werden.", "log-name-bs-permission-manager": "Rechteverwaltung-Logbuch", diff --git a/PermissionManager/i18n/en.json b/PermissionManager/i18n/en.json index 379dd4b..d2456cd 100644 --- a/PermissionManager/i18n/en.json +++ b/PermissionManager/i18n/en.json @@ -39,6 +39,7 @@ "bs-permissionmanager-pref-lockmode": "Activate lockmode", "bs-permissionmanager-pref-skipsysns": "Skip system namespaces if lockmode is active", "bs-permissionmanager-pref-enablerealitycheck": "Activate permission check", + "bs-permissionmanager-pref-max-backups": "Backup limit", "bs-permissionmanager-unsaved-changes": "There are unsaved changes. Do you really want to leave the page now? The unsaved changes will be lost.", "bs-permissionmanager-error-lockout": "At least one group must own the right \"$1\".\nChanges couldn't be saved.", "log-name-bs-permission-manager": "Permission manager log", diff --git a/PermissionManager/i18n/qqq.json b/PermissionManager/i18n/qqq.json index 2c81ef6..891169e 100644 --- a/PermissionManager/i18n/qqq.json +++ b/PermissionManager/i18n/qqq.json @@ -41,6 +41,7 @@ "bs-permissionmanager-pref-lockmode": "Option in [{{canonicalurl:Special:WikiAdmin|mode=Preferences}} Special:WikiAdmin?mode=Preferences], checkbox label for activate lockmode", "bs-permissionmanager-pref-skipsysns": "Option in [{{canonicalurl:Special:WikiAdmin|mode=Preferences}} Special:WikiAdmin?mode=Preferences], checkbox label for skip system namespaces if lockmode is active", "bs-permissionmanager-pref-enablerealitycheck": "Option in [{{canonicalurl:Special:WikiAdmin|mode=Preferences}} Special:WikiAdmin?mode=Preferences], checkbox label for activate permission check", + "bs-permissionmanager-pref-max-backups": "Option in [{{canonicalurl:Special:WikiAdmin|mode=Preferences}} Special:WikiAdmin?mode=Preferences], label for number of maximum backups", "bs-permissionmanager-unsaved-changes": "Hint about data loss when a user leaves the page without saving her/his changes", "bs-permissionmanager-error-lockout": "Error message for changes in settings that couldn't be saved, because some essential rights are not enabled for any user group.", "log-name-bs-permission-manager": "Used in [[Special:Log]], title of the log type", -- To view, visit https://gerrit.wikimedia.org/r/280415 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I5e9dd812e9470d5585f8fd4c08842b19caa147b9 Gerrit-PatchSet: 4 Gerrit-Project: mediawiki/extensions/BlueSpiceExtensions Gerrit-Branch: master Gerrit-Owner: Ljonka <[email protected]> Gerrit-Reviewer: Dvogel hallowelt <[email protected]> Gerrit-Reviewer: Mglaser <[email protected]> Gerrit-Reviewer: Pwirth <[email protected]> Gerrit-Reviewer: Robert Vogel <[email protected]> Gerrit-Reviewer: Siebrand <[email protected]> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
