瀏覽代碼

Fix last calls to Minz_Configuration methods

- We have still to fix actualize_script and greader api (refactoring?)
- We have to fix the FreshRSS_Configuration calls
- We have to fix availableLanguages calls

See https://github.com/FreshRSS/FreshRSS/issues/730
Marien Fressinaud 11 年之前
父節點
當前提交
5f9672111f

+ 3 - 4
app/Controllers/authController.php

@@ -310,7 +310,7 @@ class FreshRSS_auth_Controller extends Minz_ActionController {
 		}
 
 		// TODO #730
-		$conf = new FreshRSS_Configuration(Minz_Configuration::defaultUser());
+		$conf = new FreshRSS_Configuration(FreshRSS_Context::$system_conf->default_user);
 		// Admin user must have set its master password.
 		if (!$conf->passwordHash) {
 			$this->view->message = array(
@@ -334,9 +334,8 @@ class FreshRSS_auth_Controller extends Minz_ActionController {
 			);
 
 			if ($ok) {
-				// TODO #730
-				Minz_Configuration::_authType('form');
-				$ok = Minz_Configuration::writeFile();
+				FreshRSS_Context::$system_conf->auth_type = 'form';
+				$ok = FreshRSS_Context::$system_conf->save();
 
 				if ($ok) {
 					Minz_Request::good(_t('feedback.auth.form.set'));

+ 12 - 2
app/Models/Auth.php

@@ -158,7 +158,16 @@ class FreshRSS_Auth {
 	/**
 	 * Return if authentication is enabled on this instance of FRSS.
 	 */
-	public static function accessNeedLogin() {
+	public static function accessNeedsLogin() {
+		$conf = Minz_Configuration::get('system');
+		$auth_type = $conf->auth_type;
+		return $auth_type !== 'none';
+	}
+
+	/**
+	 * Return if authentication requires a PHP action.
+	 */
+	public static function accessNeedsAction() {
 		$conf = Minz_Configuration::get('system');
 		$auth_type = $conf->auth_type;
 		return $auth_type === 'form' || $auth_type === 'persona';
@@ -206,7 +215,8 @@ class FreshRSS_FormAuth {
 
 	public static function makeCookie($username, $password_hash) {
 		do {
-			$token = sha1(Minz_Configuration::salt() . $username . uniqid(mt_rand(), true));
+			$conf = Minz_Configuration::get('system');
+			$token = sha1($conf->salt . $username . uniqid(mt_rand(), true));
 			$token_file = DATA_PATH . '/tokens/' . $token . '.txt';
 		} while (file_exists($token_file));
 

+ 1 - 1
app/Models/EntryDAO.php

@@ -586,7 +586,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo {
 	}
 
 	public function size($all = false) {
-		$db = Minz_Configuration::dataBase();
+		$db = FreshRSS_Context::$system_conf->db;
 		$sql = 'SELECT SUM(data_length + index_length) FROM information_schema.TABLES WHERE table_schema=?';	//MySQL
 		$values = array($db['base']);
 		if (!$all) {

+ 2 - 2
app/Models/UserDAO.php

@@ -2,7 +2,7 @@
 
 class FreshRSS_UserDAO extends Minz_ModelPdo {
 	public function createUser($username) {
-		$db = Minz_Configuration::dataBase();
+		$db = FreshRSS_Context::$system_conf->db;
 		require_once(APP_PATH . '/SQL/install.sql.' . $db['type'] . '.php');
 
 		$userPDO = new Minz_ModelPdo($username);
@@ -34,7 +34,7 @@ class FreshRSS_UserDAO extends Minz_ModelPdo {
 	}
 
 	public function deleteUser($username) {
-		$db = Minz_Configuration::dataBase();
+		$db = FreshRSS_Context::$system_conf->db;
 		require_once(APP_PATH . '/SQL/install.sql.' . $db['type'] . '.php');
 
 		if ($db['type'] === 'sqlite') {

+ 1 - 1
app/layout/aside_feed.phtml

@@ -15,7 +15,7 @@
 		<a class="btn btn-important" href="<?php echo _url('subscription', 'index'); ?>"><?php echo _t('index.menu.subscription'); ?></a>
 		<a class="btn btn-important" href="<?php echo _url('importExport', 'index'); ?>"><?php echo _i('import'); ?></a>
 	</div>
-	<?php } elseif (Minz_Configuration::needsLogin()) { ?>
+	<?php } elseif (FreshRSS_Auth::accessNeedsLogin()) { ?>
 	<a href="<?php echo _url('index', 'about'); ?>"><?php echo _t('index.menu.about'); ?></a>
 	<?php } ?>
 

+ 3 - 3
app/layout/header.phtml

@@ -1,6 +1,6 @@
 <?php
 
-if (FreshRSS_Auth::accessNeedLogin()) {
+if (FreshRSS_Auth::accessNeedsAction()) {
 	?><ul class="nav nav-head nav-login"><?php
 		if (FreshRSS_Auth::hasAccess()) {
 			?><li class="item"><?php echo _i('logout'); ?> <a class="signout" href="<?php echo _url('auth', 'logout'); ?>"><?php echo _t('gen.auth.logout'); ?></a></li><?php
@@ -77,14 +77,14 @@ if (FreshRSS_Auth::accessNeedLogin()) {
 				<li class="item"><a href="<?php echo _url('index', 'logs'); ?>"><?php echo _t('gen.menu.logs'); ?></a></li>
 				<li class="item"><a href="<?php echo _url('index', 'about'); ?>"><?php echo _t('gen.menu.about'); ?></a></li>
 				<?php
-				if (FreshRSS_Auth::accessNeedLogin()) {
+				if (FreshRSS_Auth::accessNeedsAction()) {
 					?><li class="separator"></li>
 				<li class="item"><a class="signout" href="<?php echo _url('auth', 'logout'); ?>"><?php echo _i('logout'), ' ', _t('gen.auth.logout'); ?></a></li><?php
 				} ?>
 			</ul>
 		</div>
 	</div>
-	<?php } elseif (FreshRSS_Auth::accessNeedLogin()) { ?>
+	<?php } elseif (FreshRSS_Auth::accessNeedsAction()) { ?>
 	<div class="item configure">
 		<?php echo _i('login'); ?><a class="signin" href="<?php echo _url('auth', 'login'); ?>"><?php echo _t('gen.auth.login'); ?></a>
 	</div>

+ 0 - 1
app/layout/layout.phtml

@@ -10,7 +10,6 @@
 <?php $this->renderHelper('javascript_vars'); ?>
 		//]]></script>
 <?php
-	$conf = Minz_Configuration::get('system');
 	$url_base = Minz_Request::currentRequest();
 	if (FreshRSS_Context::$next_id !== '') {
 		$url_next = $url_base;

+ 1 - 1
app/layout/nav_menu.phtml

@@ -193,7 +193,7 @@
 		<?php echo _i($icon); ?>
 	</a>
 	
-	<?php if (FreshRSS_Auth::hasAccess() || Minz_Configuration::allowAnonymousRefresh()) { ?>
+	<?php if (FreshRSS_Auth::hasAccess() || FreshRSS_Context::$system_conf->allow_anonymous_refresh) { ?>
 	<a id="actualize" class="btn" href="<?php echo _url('feed', 'actualize'); ?>" title="<?php echo _t('gen.action.actualize'); ?>"><?php echo _i('refresh'); ?></a>
 	<?php } ?>
 </div>

+ 16 - 16
app/views/auth/index.phtml

@@ -10,13 +10,13 @@
 			<label class="group-name" for="auth_type"><?php echo _t('admin.auth.type'); ?></label>
 			<div class="group-controls">
 				<select id="auth_type" name="auth_type" required="required">
-					<?php if (!in_array(Minz_Configuration::authType(), array('form', 'persona', 'http_auth', 'none'))) { ?>
+					<?php if (!in_array(FreshRSS_Context::$system_conf->auth_type, array('form', 'persona', 'http_auth', 'none'))) { ?>
 						<option selected="selected"></option>
 					<?php } ?>
-					<option value="form"<?php echo Minz_Configuration::authType() === 'form' ? ' selected="selected"' : '', cryptAvailable() ? '' : ' disabled="disabled"'; ?>><?php echo _t('admin.auth.form'); ?></option>
-					<option value="persona"<?php echo Minz_Configuration::authType() === 'persona' ? ' selected="selected"' : '', FreshRSS_Context::$user_conf->mail_login == '' ? ' disabled="disabled"' : ''; ?>><?php echo _t('admin.auth.persona'); ?></option>
-					<option value="http_auth"<?php echo Minz_Configuration::authType() === 'http_auth' ? ' selected="selected"' : '', httpAuthUser() == '' ? ' disabled="disabled"' : ''; ?>><?php echo _t('admin.auth.http'); ?> (REMOTE_USER = '<?php echo httpAuthUser(); ?>')</option>
-					<option value="none"<?php echo Minz_Configuration::authType() === 'none' ? ' selected="selected"' : ''; ?>><?php echo _t('admin.auth.none'); ?></option>
+					<option value="form"<?php echo FreshRSS_Context::$system_conf->auth_type === 'form' ? ' selected="selected"' : '', cryptAvailable() ? '' : ' disabled="disabled"'; ?>><?php echo _t('admin.auth.form'); ?></option>
+					<option value="persona"<?php echo FreshRSS_Context::$system_conf->auth_type === 'persona' ? ' selected="selected"' : '', FreshRSS_Context::$user_conf->mail_login == '' ? ' disabled="disabled"' : ''; ?>><?php echo _t('admin.auth.persona'); ?></option>
+					<option value="http_auth"<?php echo FreshRSS_Context::$system_conf->auth_type === 'http_auth' ? ' selected="selected"' : '', httpAuthUser() == '' ? ' disabled="disabled"' : ''; ?>><?php echo _t('admin.auth.http'); ?> (REMOTE_USER = '<?php echo httpAuthUser(); ?>')</option>
+					<option value="none"<?php echo FreshRSS_Context::$system_conf->auth_type === 'none' ? ' selected="selected"' : ''; ?>><?php echo _t('admin.auth.none'); ?></option>
 				</select>
 			</div>
 		</div>
@@ -24,9 +24,9 @@
 		<div class="form-group">
 			<div class="group-controls">
 				<label class="checkbox" for="anon_access">
-					<input type="checkbox" name="anon_access" id="anon_access" value="1"<?php echo Minz_Configuration::allowAnonymous() ? ' checked="checked"' : '',
-						Minz_Configuration::canLogIn() ? '' : ' disabled="disabled"'; ?> />
-					<?php echo _t('admin.auth.allow_anonymous', Minz_Configuration::defaultUser()); ?>
+					<input type="checkbox" name="anon_access" id="anon_access" value="1"<?php echo FreshRSS_Context::$system_conf->allow_anonymous ? ' checked="checked"' : '',
+						FreshRSS_Auth::accessNeedsAction() ? '' : ' disabled="disabled"'; ?> />
+					<?php echo _t('admin.auth.allow_anonymous', FreshRSS_Context::$system_conf->default_user); ?>
 				</label>
 			</div>
 		</div>
@@ -34,8 +34,8 @@
 		<div class="form-group">
 			<div class="group-controls">
 				<label class="checkbox" for="anon_refresh">
-					<input type="checkbox" name="anon_refresh" id="anon_refresh" value="1"<?php echo Minz_Configuration::allowAnonymousRefresh() ? ' checked="checked"' : '',
-						Minz_Configuration::canLogIn() ? '' : ' disabled="disabled"'; ?> />
+					<input type="checkbox" name="anon_refresh" id="anon_refresh" value="1"<?php echo FreshRSS_Context::$system_conf->allow_anonymous_refresh ? ' checked="checked"' : '',
+						FreshRSS_Auth::accessNeedsAction() ? '' : ' disabled="disabled"'; ?> />
 					<?php echo _t('admin.auth.allow_anonymous_refresh'); ?>
 				</label>
 			</div>
@@ -44,21 +44,21 @@
 		<div class="form-group">
 			<div class="group-controls">
 				<label class="checkbox" for="unsafe_autologin">
-					<input type="checkbox" name="unsafe_autologin" id="unsafe_autologin" value="1"<?php echo Minz_Configuration::unsafeAutologinEnabled() ? ' checked="checked"' : '',
-						Minz_Configuration::canLogIn() ? '' : ' disabled="disabled"'; ?> />
+					<input type="checkbox" name="unsafe_autologin" id="unsafe_autologin" value="1"<?php echo FreshRSS_Context::$system_conf->unsafe_autologin_enabled ? ' checked="checked"' : '',
+						FreshRSS_Auth::accessNeedsAction() ? '' : ' disabled="disabled"'; ?> />
 					<?php echo _t('admin.auth.unsafe_autologin'); ?>
 					<kbd><?php echo Minz_Url::display(array('c' => 'auth', 'a' => 'login', 'params' => array('u' => 'alice', 'p' => '1234')), 'html', true); ?></kbd>
 				</label>
 			</div>
 		</div>
 
-		<?php if (Minz_Configuration::canLogIn()) { ?>
+		<?php if (FreshRSS_Auth::accessNeedsAction()) { ?>
 		<div class="form-group">
 			<label class="group-name" for="token"><?php echo _t('admin.auth.token'); ?></label>
 			<?php $token = FreshRSS_Context::$user_conf->token; ?>
 			<div class="group-controls">
 				<input type="text" id="token" name="token" value="<?php echo $token; ?>" placeholder="<?php echo _t('gen.short.blank_to_disable'); ?>"<?php
-					echo Minz_Configuration::canLogIn() ? '' : ' disabled="disabled"'; ?> />
+					echo FreshRSS_Auth::accessNeedsAction() ? '' : ' disabled="disabled"'; ?> />
 				<?php echo _i('help'); ?> <?php echo _t('admin.auth.token_help'); ?>
 				<kbd><?php echo Minz_Url::display(array('params' => array('output' => 'rss', 'token' => $token)), 'html', true); ?></kbd>
 			</div>
@@ -68,8 +68,8 @@
 		<div class="form-group">
 			<div class="group-controls">
 				<label class="checkbox" for="api_enabled">
-					<input type="checkbox" name="api_enabled" id="api_enabled" value="1"<?php echo Minz_Configuration::apiEnabled() ? ' checked="checked"' : '',
-						Minz_Configuration::needsLogin() ? '' : ' disabled="disabled"'; ?> />
+					<input type="checkbox" name="api_enabled" id="api_enabled" value="1"<?php echo FreshRSS_Context::$system_conf->api_enabled ? ' checked="checked"' : '',
+						FreshRSS_Auth::accessNeedsLogin() ? '' : ' disabled="disabled"'; ?> />
 					<?php echo _t('admin.auth.api_enabled'); ?>
 				</label>
 			</div>

+ 1 - 1
app/views/helpers/export/opml.phtml

@@ -2,7 +2,7 @@
 
 $opml_array = array(
 	'head' => array(
-		'title' => Minz_Configuration::title(),
+		'title' => FreshRSS_Context::$system_conf->title,
 		'dateCreated' => date('D, d M Y H:i:s')
 	),
 	'body' => array()

+ 1 - 1
app/views/index/index.phtml

@@ -2,7 +2,7 @@
 
 $output = Minz_Request::param('output', 'normal');
 
-if (FreshRSS_Auth::hasAccess() || Minz_Configuration::allowAnonymous()) {
+if (FreshRSS_Auth::hasAccess() || FreshRSS_Context::$system_conf->allow_anonymous) {
 	if ($output === 'normal') {
 		$this->renderHelper('view/normal_view');
 	} elseif ($output === 'reader') {

+ 1 - 1
app/views/user/profile.phtml

@@ -28,7 +28,7 @@
 			</div>
 		</div>
 
-		<?php if (Minz_Configuration::apiEnabled()) { ?>
+		<?php if (FreshRSS_Context::$system_conf->api_enabled) { ?>
 		<div class="form-group">
 			<label class="group-name" for="apiPasswordPlain"><?php echo _t('conf.profile.password_api'); ?></label>
 			<div class="group-controls">