Преглед изворни кода

Merge pull request #958 from aledeg/config_ui

Add a system configuration page
Alexandre Alapetite пре 10 година
родитељ
комит
ebcebfe431

+ 34 - 0
app/Controllers/configureController.php

@@ -293,4 +293,38 @@ class FreshRSS_configure_Controller extends Minz_ActionController {
 		Minz_Request::good(_t('feedback.conf.query_created', $query['name']),
 		Minz_Request::good(_t('feedback.conf.query_created', $query['name']),
 		                   array('c' => 'configure', 'a' => 'queries'));
 		                   array('c' => 'configure', 'a' => 'queries'));
 	}
 	}
+
+	/**
+	 * This action handles the system configuration page.
+	 *
+	 * It displays the system configuration page.
+	 * If this action is reach through a POST request, it stores all new
+	 * configuration values then sends a notification to the user.
+	 *
+	 * The options available on the page are:
+	 *   - user limit (default: 1)
+	 *   - user category limit (default: 16384)
+	 *   - user feed limit (default: 16384)
+	 */
+	public function systemAction() {
+		if (!FreshRSS_Auth::hasAccess('admin')) {
+			Minz_Error::error(403);
+		}
+		if (Minz_Request::isPost()) {
+			$limits = FreshRSS_Context::$system_conf->limits;
+			$limits['max_registrations'] = Minz_Request::param('max-registrations', 1);
+			$limits['max_feeds'] = Minz_Request::param('max-feeds', 16384);
+			$limits['max_categories'] = Minz_Request::param('max-categories', 16384);
+			FreshRSS_Context::$system_conf->limits = $limits;
+			FreshRSS_Context::$system_conf->title = Minz_Request::param('instance-name', 'FreshRSS');
+			FreshRSS_Context::$system_conf->save();
+
+			invalidateHttpCache();
+
+			Minz_Session::_param('notification', array(
+				'type' => 'good',
+				'content' => _t('feedback.conf.updated')
+			));
+		}
+	}
 }
 }

+ 0 - 24
app/Controllers/userController.php

@@ -272,28 +272,4 @@ class FreshRSS_user_Controller extends Minz_ActionController {
 
 
 		Minz_Request::forward($redirect_url, true);
 		Minz_Request::forward($redirect_url, true);
 	}
 	}
-
-	/**
-	 * This action updates the max number of registrations.
-	 *
-	 * Request parameter is:
-	 *   - max-registrations (int >= 0)
-	 */
-	public function setRegistrationAction() {
-		if (Minz_Request::isPost() && FreshRSS_Auth::hasAccess('admin')) {
-			$limits = FreshRSS_Context::$system_conf->limits;
-			$limits['max_registrations'] = Minz_Request::param('max-registrations', 1);
-			FreshRSS_Context::$system_conf->limits = $limits;
-			FreshRSS_Context::$system_conf->save();
-
-			invalidateHttpCache();
-
-			Minz_Session::_param('notification', array(
-				'type' => 'good',
-				'content' => _t('feedback.user.set_registration')
-			));
-		}
-
-		Minz_Request::forward(array('c' => 'user', 'a' => 'manage'), true);
-	}
 }
 }

+ 10 - 5
app/i18n/cz/admin.php

@@ -146,6 +146,16 @@ return array(
 		'title' => 'Statistika',
 		'title' => 'Statistika',
 		'top_feed' => 'Top ten kanálů',
 		'top_feed' => 'Top ten kanálů',
 	),
 	),
+	'system' => array(
+		'_' => 'System configuration', // @todo translate
+		'instance-name' => 'Instance name', // @todo translate
+		'max-categories' => 'Categories per user limit', // @todo translate
+		'max-feeds' => 'Feeds per user limit', // @todo translate
+		'registration' => array(
+			'help' => '0 znamená žádná omezení účtu',
+			'number' => 'Maximální počet účtů',
+		),
+	),
 	'update' => array(
 	'update' => array(
 		'_' => 'Aktualizace systému',
 		'_' => 'Aktualizace systému',
 		'apply' => 'Použít',
 		'apply' => 'Použít',
@@ -164,11 +174,6 @@ return array(
 		'numbers' => 'Zatím je vytvořeno %d účtů',
 		'numbers' => 'Zatím je vytvořeno %d účtů',
 		'password_form' => 'Heslo<br /><small>(pro přihlášení webovým formulářem)</small>',
 		'password_form' => 'Heslo<br /><small>(pro přihlášení webovým formulářem)</small>',
 		'password_format' => 'Alespoň 7 znaků',
 		'password_format' => 'Alespoň 7 znaků',
-		'registration' => array(
-			'allow' => 'Povolit vytváření účtů',
-			'help' => '0 znamená žádná omezení účtu',
-			'number' => 'Maximální počet účtů',
-		),
 		'title' => 'Správa uživatelů',
 		'title' => 'Správa uživatelů',
 		'user_list' => 'Seznam uživatelů',
 		'user_list' => 'Seznam uživatelů',
 		'username' => 'Přihlašovací jméno',
 		'username' => 'Přihlašovací jméno',

+ 0 - 1
app/i18n/cz/feedback.php

@@ -102,7 +102,6 @@ return array(
 			'_' => 'Uživatel %s byl smazán',
 			'_' => 'Uživatel %s byl smazán',
 			'error' => 'Uživatele %s nelze smazat',
 			'error' => 'Uživatele %s nelze smazat',
 		),
 		),
-		'set_registration' => 'Maximální počet účtů byl změněn',
 	),
 	),
 	'profile' => array(
 	'profile' => array(
 		'error' => 'Váš profil nelze změnit',
 		'error' => 'Váš profil nelze změnit',

+ 1 - 0
app/i18n/cz/gen.php

@@ -138,6 +138,7 @@ return array(
 		'sharing' => 'Sdílení',
 		'sharing' => 'Sdílení',
 		'shortcuts' => 'Zkratky',
 		'shortcuts' => 'Zkratky',
 		'stats' => 'Statistika',
 		'stats' => 'Statistika',
+		'system' => 'System configuration',// @todo translate
 		'update' => 'Aktualizace',
 		'update' => 'Aktualizace',
 		'user_management' => 'Správa uživatelů',
 		'user_management' => 'Správa uživatelů',
 		'user_profile' => 'Profil',
 		'user_profile' => 'Profil',

+ 10 - 5
app/i18n/de/admin.php

@@ -146,6 +146,16 @@ return array(
 		'title' => 'Statistiken',
 		'title' => 'Statistiken',
 		'top_feed' => 'Top 10-Feeds',
 		'top_feed' => 'Top 10-Feeds',
 	),
 	),
+	'system' => array(
+		'_' => 'System configuration', // @todo translate
+		'instance-name' => 'Instance name', // @todo translate
+		'max-categories' => 'Categories per user limit', // @todo translate
+		'max-feeds' => 'Feeds per user limit', // @todo translate
+		'registration' => array(
+			'help' => '0 meint, dass es kein Account Limit gibt',
+			'number' => 'Maximale Anzahl von Accounts',
+		),
+	),
 	'update' => array(
 	'update' => array(
 		'_' => 'System aktualisieren',
 		'_' => 'System aktualisieren',
 		'apply' => 'Anwenden',
 		'apply' => 'Anwenden',
@@ -164,11 +174,6 @@ return array(
 		'numbers' => 'Es wurden bis jetzt %d Accounts erstellt',
 		'numbers' => 'Es wurden bis jetzt %d Accounts erstellt',
 		'password_form' => 'Passwort<br /><small>(für die Anmeldemethode per Webformular)</small>',
 		'password_form' => 'Passwort<br /><small>(für die Anmeldemethode per Webformular)</small>',
 		'password_format' => 'mindestens 7 Zeichen',
 		'password_format' => 'mindestens 7 Zeichen',
-		'registration' => array(
-			'allow' => 'Erlaube die Accounterstellung',
-			'help' => '0 meint, dass es kein Account Limit gibt',
-			'number' => 'Maximale Anzahl von Accounts',
-		),
 		'title' => 'Benutzer verwalten',
 		'title' => 'Benutzer verwalten',
 		'user_list' => 'Liste der Benutzer',
 		'user_list' => 'Liste der Benutzer',
 		'username' => 'Nutzername',
 		'username' => 'Nutzername',

+ 0 - 1
app/i18n/de/feedback.php

@@ -102,7 +102,6 @@ return array(
 			'_' => 'Der Benutzer %s ist gelöscht worden',
 			'_' => 'Der Benutzer %s ist gelöscht worden',
 			'error' => 'Der Benutzer %s kann nicht gelöscht werden',
 			'error' => 'Der Benutzer %s kann nicht gelöscht werden',
 		),
 		),
-		'set_registration' => 'Die maximale Anzahl von Accounts wurde aktualisiert.',
 	),
 	),
 	'profile' => array(
 	'profile' => array(
 		'error' => 'Ihr Profil kann nicht geändert werden',
 		'error' => 'Ihr Profil kann nicht geändert werden',

+ 1 - 0
app/i18n/de/gen.php

@@ -138,6 +138,7 @@ return array(
 		'sharing' => 'Teilen',
 		'sharing' => 'Teilen',
 		'shortcuts' => 'Tastaturkürzel',
 		'shortcuts' => 'Tastaturkürzel',
 		'stats' => 'Statistiken',
 		'stats' => 'Statistiken',
+		'system' => 'System configuration',// @todo translate
 		'update' => 'Aktualisieren',
 		'update' => 'Aktualisieren',
 		'user_management' => 'Benutzer verwalten',
 		'user_management' => 'Benutzer verwalten',
 		'user_profile' => 'Profil',
 		'user_profile' => 'Profil',

+ 10 - 5
app/i18n/en/admin.php

@@ -146,6 +146,16 @@ return array(
 		'title' => 'Statistics',
 		'title' => 'Statistics',
 		'top_feed' => 'Top ten feeds',
 		'top_feed' => 'Top ten feeds',
 	),
 	),
+	'system' => array(
+		'_' => 'System configuration',
+		'instance-name' => 'Instance name',
+		'max-categories' => 'Categories per user limit',
+		'max-feeds' => 'Feeds per user limit',
+		'registration' => array(
+			'help' => '0 means that there is no account limit',
+			'number' => 'Max number of accounts',
+		),
+	),
 	'update' => array(
 	'update' => array(
 		'_' => 'Update system',
 		'_' => 'Update system',
 		'apply' => 'Apply',
 		'apply' => 'Apply',
@@ -164,11 +174,6 @@ return array(
 		'numbers' => 'There are %d accounts created yet',
 		'numbers' => 'There are %d accounts created yet',
 		'password_form' => 'Password<br /><small>(for the Web-form login method)</small>',
 		'password_form' => 'Password<br /><small>(for the Web-form login method)</small>',
 		'password_format' => 'At least 7 characters',
 		'password_format' => 'At least 7 characters',
-		'registration' => array(
-			'allow' => 'Allow account creation',
-			'help' => '0 means that there is no account limit',
-			'number' => 'Max number of accounts',
-		),
 		'title' => 'Manage users',
 		'title' => 'Manage users',
 		'user_list' => 'List of users',
 		'user_list' => 'List of users',
 		'username' => 'Username',
 		'username' => 'Username',

+ 0 - 1
app/i18n/en/feedback.php

@@ -102,7 +102,6 @@ return array(
 			'_' => 'User %s has been deleted',
 			'_' => 'User %s has been deleted',
 			'error' => 'User %s cannot be deleted',
 			'error' => 'User %s cannot be deleted',
 		),
 		),
-		'set_registration' => 'The maximum amount of accounts has been updated.',
 	),
 	),
 	'profile' => array(
 	'profile' => array(
 		'error' => 'Your profile cannot be modified',
 		'error' => 'Your profile cannot be modified',

+ 1 - 0
app/i18n/en/gen.php

@@ -138,6 +138,7 @@ return array(
 		'sharing' => 'Sharing',
 		'sharing' => 'Sharing',
 		'shortcuts' => 'Shortcuts',
 		'shortcuts' => 'Shortcuts',
 		'stats' => 'Statistics',
 		'stats' => 'Statistics',
+		'system' => 'System configuration',
 		'update' => 'Update',
 		'update' => 'Update',
 		'user_management' => 'Manage users',
 		'user_management' => 'Manage users',
 		'user_profile' => 'Profile',
 		'user_profile' => 'Profile',

+ 10 - 5
app/i18n/fr/admin.php

@@ -146,6 +146,16 @@ return array(
 		'title' => 'Statistiques',
 		'title' => 'Statistiques',
 		'top_feed' => 'Les dix plus gros flux',
 		'top_feed' => 'Les dix plus gros flux',
 	),
 	),
+	'system' => array(
+		'_' => 'Configuration du système',
+		'instance-name' => 'Nom de l’instance',
+		'max-categories' => 'Limite de catégories par utilisateur',
+		'max-feeds' => 'Limite de flux par utilisateur',
+		'registration' => array(
+			'help' => 'Un chiffre de 0 signifie que l’on peut créer un nombre infini de comptes',
+			'number' => 'Nombre max de comptes',
+		),
+	),
 	'update' => array(
 	'update' => array(
 		'_' => 'Système de mise à jour',
 		'_' => 'Système de mise à jour',
 		'apply' => 'Appliquer la mise à jour',
 		'apply' => 'Appliquer la mise à jour',
@@ -164,11 +174,6 @@ return array(
 		'numbers' => '%d comptes ont déjà été créés',
 		'numbers' => '%d comptes ont déjà été créés',
 		'password_form' => 'Mot de passe<br /><small>(pour connexion par formulaire)</small>',
 		'password_form' => 'Mot de passe<br /><small>(pour connexion par formulaire)</small>',
 		'password_format' => '7 caractères minimum',
 		'password_format' => '7 caractères minimum',
-		'registration' => array(
-			'allow' => 'Autoriser la création de comptes',
-			'help' => 'Un chiffre de 0 signifie que l’on peut créer un nombre infini de comptes',
-			'number' => 'Nombre max de comptes',
-		),
 		'title' => 'Gestion des utilisateurs',
 		'title' => 'Gestion des utilisateurs',
 		'user_list' => 'Liste des utilisateurs',
 		'user_list' => 'Liste des utilisateurs',
 		'username' => 'Nom d’utilisateur',
 		'username' => 'Nom d’utilisateur',

+ 0 - 1
app/i18n/fr/feedback.php

@@ -102,7 +102,6 @@ return array(
 			'_' => 'L’utilisateur %s a été supprimé.',
 			'_' => 'L’utilisateur %s a été supprimé.',
 			'error' => 'L’utilisateur %s ne peut pas être supprimé.',
 			'error' => 'L’utilisateur %s ne peut pas être supprimé.',
 		),
 		),
-		'set_registration' => 'Le nombre maximal de comptes a été mis à jour.',
 	),
 	),
 	'profile' => array(
 	'profile' => array(
 		'error' => 'Votre profil n’a pas pu être mis à jour',
 		'error' => 'Votre profil n’a pas pu être mis à jour',

+ 1 - 0
app/i18n/fr/gen.php

@@ -138,6 +138,7 @@ return array(
 		'sharing' => 'Partage',
 		'sharing' => 'Partage',
 		'shortcuts' => 'Raccourcis',
 		'shortcuts' => 'Raccourcis',
 		'stats' => 'Statistiques',
 		'stats' => 'Statistiques',
+		'system' => 'Configuration du système',
 		'update' => 'Mise à jour',
 		'update' => 'Mise à jour',
 		'user_management' => 'Gestion des utilisateurs',
 		'user_management' => 'Gestion des utilisateurs',
 		'user_profile' => 'Profil',
 		'user_profile' => 'Profil',

+ 3 - 0
app/layout/aside_configure.phtml

@@ -27,6 +27,9 @@
 	</li>
 	</li>
 	<?php if (FreshRSS_Auth::hasAccess('admin')) { ?>
 	<?php if (FreshRSS_Auth::hasAccess('admin')) { ?>
 	<li class="nav-header"><?php echo _t('gen.menu.admin'); ?></li>
 	<li class="nav-header"><?php echo _t('gen.menu.admin'); ?></li>
+	<li class="item<?php echo Minz_Request::actionName() === 'system' ? ' active' : ''; ?>">
+		<a href="<?php echo _url('configure', 'system')?>"><?php echo _t('gen.menu.system'); ?></a>
+	</li>
 	<li class="item<?php echo Minz_Request::controllerName() === 'user' &&
 	<li class="item<?php echo Minz_Request::controllerName() === 'user' &&
 	                          Minz_Request::actionName() === 'manage' ? ' active' : ''; ?>">
 	                          Minz_Request::actionName() === 'manage' ? ' active' : ''; ?>">
 		<a href="<?php echo _url('user', 'manage'); ?>"><?php echo _t('gen.menu.user_management'); ?></a>
 		<a href="<?php echo _url('user', 'manage'); ?>"><?php echo _t('gen.menu.user_management'); ?></a>

+ 1 - 0
app/layout/header.phtml

@@ -67,6 +67,7 @@ if (FreshRSS_Auth::accessNeedsAction()) {
 				<?php if (FreshRSS_Auth::hasAccess('admin')) { ?>
 				<?php if (FreshRSS_Auth::hasAccess('admin')) { ?>
 				<li class="separator"></li>
 				<li class="separator"></li>
 				<li class="dropdown-header"><?php echo _t('gen.menu.admin'); ?></li>
 				<li class="dropdown-header"><?php echo _t('gen.menu.admin'); ?></li>
+				<li class="item"><a href="<?php echo _url('configure', 'system'); ?>"><?php echo _t('gen.menu.system'); ?></a></li>
 				<li class="item"><a href="<?php echo _url('user', 'manage'); ?>"><?php echo _t('gen.menu.user_management'); ?></a></li>
 				<li class="item"><a href="<?php echo _url('user', 'manage'); ?>"><?php echo _t('gen.menu.user_management'); ?></a></li>
 				<li class="item"><a href="<?php echo _url('auth', 'index'); ?>"><?php echo _t('gen.menu.authentication'); ?></a></li>
 				<li class="item"><a href="<?php echo _url('auth', 'index'); ?>"><?php echo _t('gen.menu.authentication'); ?></a></li>
 				<li class="item"><a href="<?php echo _url('update', 'checkInstall'); ?>"><?php echo _t('gen.menu.check_install'); ?></a></li>
 				<li class="item"><a href="<?php echo _url('update', 'checkInstall'); ?>"><?php echo _t('gen.menu.check_install'); ?></a></li>

+ 54 - 0
app/views/configure/system.phtml

@@ -0,0 +1,54 @@
+<?php $this->partial('aside_configure'); ?>
+
+<div class="post">
+	<a href="<?php echo _url('index', 'index'); ?>"><?php echo _t('gen.action.back_to_rss_feeds'); ?></a>
+
+	<form method="post" action="<?php echo _url('configure', 'system'); ?>">
+		<legend><?php echo _t('admin.system'); ?></legend>
+
+		<div class="form-group">
+			<label class="group-name" for="instance-name"><?php echo _t('admin.system.instance-name'); ?></label>
+			<div class="group-controls">
+			    <input type="text" id="max-feeds" name="instance-name" value="<?php echo FreshRSS_Context::$system_conf->title; ?>" min="1" data-leave-validation="<?php echo FreshRSS_Context::$system_conf->title; ?>"/>
+			</div>
+		</div>
+
+		<div class="form-group">
+			<label class="group-name" for="max-registrations"><?php echo _t('admin.system.registration.number'); ?></label>
+			<div class="group-controls">
+				<input type="number" id="max-registrations" name="max-registrations" value="<?php echo FreshRSS_Context::$system_conf->limits['max_registrations']; ?>" min="0" data-leave-validation="<?php echo FreshRSS_Context::$system_conf->limits['max_registrations']; ?>"/>
+				<?php echo _i('help'); ?> <?php echo _t('admin.system.registration.help'); ?>
+			</div>
+		</div>
+
+		<div class="form-group">
+			<div class="group-controls">
+				<?php
+					$number = count(listUsers());
+					echo _t($number > 1 ? 'admin.user.numbers' : 'admin.user.number', $number);
+				?>
+			</div>
+		</div>
+
+		<div class="form-group">
+			<label class="group-name" for="max-feeds"><?php echo _t('admin.system.max-feeds'); ?></label>
+			<div class="group-controls">
+			    <input type="number" id="max-feeds" name="max-feeds" value="<?php echo FreshRSS_Context::$system_conf->limits['max_feeds']; ?>" min="1" data-leave-validation="<?php echo FreshRSS_Context::$system_conf->limits['max_feeds']; ?>"/>
+			</div>
+		</div>
+
+		<div class="form-group">
+			<label class="group-name" for="max-categories"><?php echo _t('admin.system.max-categories'); ?></label>
+			<div class="group-controls">
+			    <input type="number" id="max-categories" name="max-categories" value="<?php echo FreshRSS_Context::$system_conf->limits['max_categories']; ?>" min="1" data-leave-validation="<?php echo FreshRSS_Context::$system_conf->limits['max_categories']; ?>"/>
+			</div>
+		</div>
+
+		<div class="form-group form-actions">
+			<div class="group-controls">
+				<button type="submit" class="btn btn-important"><?php echo _t('gen.action.submit'); ?></button>
+				<button type="reset" class="btn"><?php echo _t('gen.action.cancel'); ?></button>
+			</div>
+		</div>
+	</form>
+</div>

+ 0 - 28
app/views/user/manage.phtml

@@ -3,34 +3,6 @@
 <div class="post">
 <div class="post">
 	<a href="<?php echo _url('index', 'index'); ?>"><?php echo _t('gen.action.back_to_rss_feeds'); ?></a>
 	<a href="<?php echo _url('index', 'index'); ?>"><?php echo _t('gen.action.back_to_rss_feeds'); ?></a>
 
 
-	<form method="post" action="<?php echo _url('user', 'setRegistration'); ?>">
-		<legend><?php echo _t('admin.user.registration.allow'); ?></legend>
-
-		<div class="form-group">
-			<label class="group-name" for="max-registrations"><?php echo _t('admin.user.registration.number'); ?></label>
-			<div class="group-controls">
-				<input type="number" id="max-registrations" name="max-registrations" value="<?php echo FreshRSS_Context::$system_conf->limits['max_registrations']; ?>" min="0" data-leave-validation="<?php echo FreshRSS_Context::$system_conf->limits['max_registrations']; ?>"/>
-				<?php echo _i('help'); ?> <?php echo _t('admin.user.registration.help'); ?>
-			</div>
-		</div>
-
-		<div class="form-group">
-			<div class="group-controls">
-				<?php
-					$number = count(listUsers());
-					echo _t($number > 1 ? 'admin.user.numbers' : 'admin.user.number', $number);
-				?>
-			</div>
-		</div>
-
-		<div class="form-group form-actions">
-			<div class="group-controls">
-				<button type="submit" class="btn btn-important"><?php echo _t('gen.action.submit'); ?></button>
-				<button type="reset" class="btn"><?php echo _t('gen.action.cancel'); ?></button>
-			</div>
-		</div>
-	</form>
-
 	<form method="post" action="<?php echo _url('user', 'create'); ?>">
 	<form method="post" action="<?php echo _url('user', 'create'); ?>">
 		<legend><?php echo _t('admin.user.create'); ?></legend>
 		<legend><?php echo _t('admin.user.create'); ?></legend>