ソースを参照

Détails multi-utilisateur

https://github.com/marienfressinaud/FreshRSS/issues/126
Alexandre Alapetite 12 年 前
コミット
50c41d9bb2

+ 18 - 29
app/Controllers/usersController.php

@@ -10,9 +10,10 @@ class FreshRSS_users_Controller extends Minz_ActionController {
 		}
 	}
 
-	public function idAction() {
+	public function authAction() {
 		if (Minz_Request::isPost()) {
 			$ok = true;
+
 			$mail = Minz_Request::param('mail_login', false);
 			$this->view->conf->_mail_login($mail);
 			$ok &= $this->view->conf->save();
@@ -25,36 +26,24 @@ class FreshRSS_users_Controller extends Minz_ActionController {
 				@unlink($personaFile);
 				$ok &= (file_put_contents($personaFile, Minz_Session::param('currentUser', '_')) !== false);
 			}
-			invalidateHttpCache();
 
-			//TODO: use $ok
-			$notif = array(
-				'type' => 'good',
-				'content' => Minz_Translate::t('configuration_updated')
-			);
-			Minz_Session::_param('notification', $notif);
-
-			Minz_Request::forward(array('c' => 'configure', 'a' => 'users'), true);
-		}
-	}
-
-	public function authAction() {
-		if (Minz_Request::isPost() && Minz_Configuration::isAdmin(Minz_Session::param('currentUser', '_'))) {
-			$ok = true;
-			$current_token = $this->view->conf->token;
-			$token = Minz_Request::param('token', $current_token);
-			$this->view->conf->_token($token);
-			$ok &= $this->view->conf->save();
-
-			$anon = Minz_Request::param('anon_access', false);
-			$anon = ((bool)$anon) && ($anon !== 'no');
-			$auth_type = Minz_Request::param('auth_type', 'none');
-			if ($anon != Minz_Configuration::allowAnonymous() ||
-				$auth_type != Minz_Configuration::authType()) {
-				Minz_Configuration::_allowAnonymous($anon);
-				Minz_Configuration::_authType($auth_type);
-				$ok &= Minz_Configuration::writeFile();
+			if (Minz_Configuration::isAdmin(Minz_Session::param('currentUser', '_'))) {
+				$current_token = $this->view->conf->token;
+				$token = Minz_Request::param('token', $current_token);
+				$this->view->conf->_token($token);
+				$ok &= $this->view->conf->save();
+
+				$anon = Minz_Request::param('anon_access', false);
+				$anon = ((bool)$anon) && ($anon !== 'no');
+				$auth_type = Minz_Request::param('auth_type', 'none');
+				if ($anon != Minz_Configuration::allowAnonymous() ||
+					$auth_type != Minz_Configuration::authType()) {
+					Minz_Configuration::_allowAnonymous($anon);
+					Minz_Configuration::_authType($auth_type);
+					$ok &= Minz_Configuration::writeFile();
+				}
 			}
+
 			invalidateHttpCache();
 
 			$notif = array(

+ 2 - 2
app/views/configure/archiving.phtml

@@ -17,8 +17,8 @@
 		<div class="form-group">
 			<label class="group-name" for="keep_history_default"><?php echo Minz_Translate::t('keep_history'), ' ', Minz_Translate::t('by_feed'); ?></label>
 			<div class="group-controls">
-				<select class="number" name="keep_history_default" id="keep_history_default"><?php
-					foreach (array(-3 => '', 0 => '0', 10 => '10', 50 => '50', 100 => '100', 500 => '500', 1000 => '1 000', 5000 => '5 000', 10000 => '10 000', -1 => '∞') as $v => $t) {
+				<select class="number" name="keep_history_default" id="keep_history_default" required="required"><?php
+					foreach (array('' => '', 0 => '0', 10 => '10', 50 => '50', 100 => '100', 500 => '500', 1000 => '1 000', 5000 => '5 000', 10000 => '10 000', -1 => '∞') as $v => $t) {
 						echo '<option value="' . $v . ($this->conf->keep_history_default == $v ? '" selected="selected' : '') . '">' . $t . ' </option>';
 					}
 				?></select> (<?php echo Minz_Translate::t('by_default'); ?>)

+ 2 - 2
app/views/configure/feed.phtml

@@ -87,8 +87,8 @@
 		<div class="form-group">
 			<label class="group-name" for="keep_history"><?php echo Minz_Translate::t ('keep_history'); ?></label>
 			<div class="group-controls">
-				<select class="number" name="keep_history" id="keep_history"><?php
-					foreach (array(-3 => '', -2 => Minz_Translate::t('by_default'), 0 => '0', 10 => '10', 50 => '50', 100 => '100', 500 => '500', 1000 => '1 000', 5000 => '5 000', 10000 => '10 000', -1 => '∞') as $v => $t) {
+				<select class="number" name="keep_history" id="keep_history" required="required"><?php
+					foreach (array('' => '', -2 => Minz_Translate::t('by_default'), 0 => '0', 10 => '10', 50 => '50', 100 => '100', 500 => '500', 1000 => '1 000', 5000 => '5 000', 10000 => '10 000', -1 => '∞') as $v => $t) {
 						echo '<option value="' . $v . ($this->flux->keepHistory() === $v ? '" selected="selected' : '') . '">' . $t . '</option>';
 					}
 				?></select>

+ 4 - 5
app/views/configure/users.phtml

@@ -3,7 +3,7 @@
 <div class="post">
 	<a href="<?php echo _url('index', 'index'); ?>"><?php echo Minz_Translate::t('back_to_rss_feeds'); ?></a>
 
-	<form method="post" action="<?php echo _url('users', 'id'); ?>">
+	<form method="post" action="<?php echo _url('users', 'auth'); ?>">
 		<legend><?php echo Minz_Translate::t('login_configuration'); ?></legend>
 
 		<div class="form-group">
@@ -34,20 +34,19 @@
 			</div>
 		</div>
 		<?php } ?>
-	</form>
 
 	<?php if (Minz_Configuration::isAdmin(Minz_Session::param('currentUser', '_'))) { ?>
 
-	<form method="post" action="<?php echo _url('users', 'auth'); ?>">
 		<legend><?php echo Minz_Translate::t('auth_type'); ?></legend>
 
 		<div class="form-group">
 			<label class="group-name" for="auth_type"><?php echo Minz_Translate::t('auth_type'); ?></label>
 			<div class="group-controls">
-				<select id="auth_type" name="auth_type">
+				<select id="auth_type" name="auth_type" required="required">
+					<option value=""></option>
 					<option value="none"<?php echo Minz_Configuration::authType() === 'none' ? ' selected="selected"' : ''; ?>><?php echo Minz_Translate::t('auth_none'); ?></option>
 					<option value="http_auth"<?php echo Minz_Configuration::authType() === 'http_auth' ? ' selected="selected"' : '', httpAuthUser() == '' ? ' disabled="disabled"' : ''; ?>>HTTP Auth</option>
-					<option value="persona"<?php echo Minz_Configuration::authType() === 'persona' ? ' selected="selected"' : ''; ?>>Mozilla Persona</option>
+					<option value="persona"<?php echo Minz_Configuration::authType() === 'persona' ? ' selected="selected"' : '', $this->conf->mail_login == '' ? ' disabled="disabled"' : ''; ?>>Mozilla Persona</option>
 				</select>
 				<code>$_SERVER['REMOTE_USER'] = `<?php echo httpAuthUser(); ?>`</code>
 			</div>

+ 1 - 1
p/themes/default/global.css

@@ -112,7 +112,7 @@ input, select, textarea {
 		border-color: #33BBFF;
 		box-shadow: 0 2px 2px #DDDDFF inset;
 	}
-	input:invalid {
+	input:invalid, select:invalid {
 		border-color: red;
 		box-shadow: 0 0 2px 1px red;
 	}

+ 1 - 1
p/themes/flat-design/global.css

@@ -113,7 +113,7 @@ input, select, textarea {
 		color: #333;
 		border-color: #2980b9;
 	}
-	input:invalid {
+	input:invalid, select:invalid {
 		border-color: red;
 		box-shadow: 0 0 2px 1px red;
 	}