summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2013-12-30 01:03:32 +0100
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2013-12-30 01:03:32 +0100
commit92efd68a3a13e49fe7bbfb8441611c0dcd639415 (patch)
treee6228848744b9369ad4e4e52c541075f5c723b6d /lib
parent220341b40642771f9b5db97296edfb1913182464 (diff)
Début de mode multi-utilisateur avec http_auth
+ Légère optimisation de Minz_View. + Encore plus de tests de bibliothèques dans install.php Contribue à https://github.com/marienfressinaud/FreshRSS/issues/126 et https://github.com/marienfressinaud/FreshRSS/issues/303
Diffstat (limited to 'lib')
-rw-r--r--lib/Minz/Configuration.php12
-rw-r--r--lib/Minz/View.php29
-rw-r--r--lib/lib_rss.php16
3 files changed, 26 insertions, 31 deletions
diff --git a/lib/Minz/Configuration.php b/lib/Minz/Configuration.php
index d0c530ef7..e6d7ae471 100644
--- a/lib/Minz/Configuration.php
+++ b/lib/Minz/Configuration.php
@@ -107,6 +107,12 @@ class Minz_Configuration {
public static function authType() {
return self::$auth_type;
}
+ public static function needsLogin() {
+ return self::$auth_type !== 'none';
+ }
+ public static function canLogIn() {
+ return self::$auth_type === 'persona';
+ }
public static function _allowAnonymous($allow = false) {
self::$allow_anonymous = (bool)$allow;
@@ -114,13 +120,17 @@ class Minz_Configuration {
public static function _authType($value) {
$value = strtolower($value);
switch ($value) {
- case 'none':
case 'http_auth':
case 'persona':
+ case 'none':
self::$auth_type = $value;
break;
}
}
+ public static function _currentUser($user) {
+ self::$current_user = $user;
+ }
+
/**
* Initialise les variables de configuration
diff --git a/lib/Minz/View.php b/lib/Minz/View.php
index c8d0aefed..ba9555cd7 100644
--- a/lib/Minz/View.php
+++ b/lib/Minz/View.php
@@ -13,7 +13,7 @@ class Minz_View {
const LAYOUT_FILENAME = '/layout.phtml';
private $view_filename = '';
- private $use_layout = false;
+ private $use_layout = null;
private static $title = '';
private static $styles = array ();
@@ -31,12 +31,6 @@ class Minz_View {
. Minz_Request::controllerName () . '/'
. Minz_Request::actionName () . '.phtml';
- if (file_exists (APP_PATH
- . self::LAYOUT_PATH_NAME
- . self::LAYOUT_FILENAME)) {
- $this->use_layout = true;
- }
-
self::$title = Minz_Configuration::title ();
}
@@ -44,6 +38,9 @@ class Minz_View {
* Construit la vue
*/
public function build () {
+ if ($this->use_layout === null) { //TODO: avoid file_exists and require views to be explicit
+ $this->use_layout = file_exists (APP_PATH . self::LAYOUT_PATH_NAME . self::LAYOUT_FILENAME);
+ }
if ($this->use_layout) {
$this->buildLayout ();
} else {
@@ -66,10 +63,8 @@ class Minz_View {
* Affiche la Vue en elle-même
*/
public function render () {
- if (file_exists ($this->view_filename)) {
- include ($this->view_filename);
- } else {
- Minz_Log::record ('File doesn\'t exist : `'
+ if ((@include($this->view_filename)) === false) {
+ Minz_Log::record ('File not found: `'
. $this->view_filename . '`',
Minz_Log::NOTICE);
}
@@ -84,10 +79,8 @@ class Minz_View {
. self::LAYOUT_PATH_NAME . '/'
. $part . '.phtml';
- if (file_exists ($fic_partial)) {
- include ($fic_partial);
- } else {
- Minz_Log::record ('File doesn\'t exist : `'
+ if ((@include($fic_partial)) === false) {
+ Minz_Log::record ('File not found: `'
. $fic_partial . '`',
Minz_Log::WARNING);
}
@@ -102,10 +95,8 @@ class Minz_View {
. '/views/helpers/'
. $helper . '.phtml';
- if (file_exists ($fic_helper)) {
- include ($fic_helper);
- } else {
- Minz_Log::record ('File doesn\'t exist : `'
+ if ((@include($fic_helper)) === false) {;
+ Minz_Log::record ('File not found: `'
. $fic_helper . '`',
Minz_Log::WARNING);
}
diff --git a/lib/lib_rss.php b/lib/lib_rss.php
index 3f55c7d58..b266fa5c7 100644
--- a/lib/lib_rss.php
+++ b/lib/lib_rss.php
@@ -56,16 +56,6 @@ function checkUrl($url) {
}
}
-// vérifie qu'on est connecté
-function is_logged () {
- return Minz_Session::param ('mail') != false;
-}
-
-// vérifie que le système d'authentification est configuré
-function login_is_conf ($conf) {
- return $conf->mail_login != '';
-}
-
// tiré de Shaarli de Seb Sauvage //Format RFC 4648 base64url
function small_hash ($txt) {
$t = rtrim (base64_encode (hash ('crc32', $txt, true)), '=');
@@ -173,7 +163,7 @@ function uSecString() {
return str_pad($t['usec'], 6, '0');
}
-function invalidateHttpCache() {
+function invalidateHttpCache($currentUser = '') { //TODO: Make multi-user compatible
file_put_contents(DATA_PATH . '/touch.txt', uTimeString());
}
@@ -185,6 +175,10 @@ function usernameFromPath($userPath) {
}
}
+function isValidUser($user) {
+ return $user != '' && ctype_alnum($user) && file_exists(DATA_PATH . '/' . $user . '_user.php');
+}
+
function listUsers() {
return array_map('usernameFromPath', glob(DATA_PATH . '/*_user.php'));
}