A free, self-hostable news aggregator…
Début de multi-utilisateurs
Alexandre Alapetite9ec13c6c32ad
diff --git a/app/i18n/en.php b/app/i18n/en.phpindex 8243756bd..e5aec3bc1 100644--- a/app/i18n/en.php+++ b/app/i18n/en.php@@ -151,7 +151,8 @@ return array ('language' => 'Language','delete_articles_every' => 'Remove articles every','month' => 'months',- 'persona_connection_email' => 'Login mail address (use <a href="https://persona.org/">Persona</a>)',+ 'default_user' => 'Username of the default user (maximum 16 alphanumeric characters)',+ 'persona_connection_email' => 'Login mail address (use <a href="https://persona.org/">Mozilla Persona</a>)','allow_anonymous' => 'Allow anonymous reading','auth_token' => 'Authentication token','explain_token' => 'Allows to access RSS output without authentication.<br />%s?token=%s',diff --git a/app/i18n/fr.php b/app/i18n/fr.phpindex 8040a6a44..8bffd5287 100644--- a/app/i18n/fr.php+++ b/app/i18n/fr.php@@ -151,7 +151,8 @@ return array ('language' => 'Langue','delete_articles_every' => 'Supprimer les articles tous les','month' => 'mois',- 'persona_connection_email' => 'Adresse courriel de connexion (utilise <a href="https://persona.org/">Persona</a>)',+ 'default_user' => 'Nom de l’utilisateur par défaut (16 caractères alphanumériques maximum)',+ 'persona_connection_email' => 'Adresse courriel de connexion (utilise <a href="https://persona.org/">Mozilla Persona</a>)','allow_anonymous' => 'Autoriser la lecture anonyme','auth_token' => 'Jeton d’identification','explain_token' => 'Permet d’accéder à la sortie RSS sans besoin de s’authentifier.<br />%s?output=rss&token=%s',diff --git a/app/models/Entry.php b/app/models/Entry.phpindex 8b817cc14..c4856af8b 100755--- a/app/models/Entry.php+++ b/app/models/Entry.php@@ -311,11 +311,11 @@ class EntryDAO extends Model_pdo {$affected = $stm->rowCount();if ($affected > 0) {- $sql = 'UPDATE freshrss_feed f '+ $sql = 'UPDATE ' . $this->prefix . 'feed f '. 'LEFT OUTER JOIN ('. 'SELECT e.id_feed, '. 'COUNT(*) AS nbUnreads '- . 'FROM freshrss_entry e '+ . 'FROM ' . $this->prefix . 'entry e '. 'WHERE e.is_read = 0 '. 'GROUP BY e.id_feed'. ') x ON x.id_feed=f.id '@@ -364,11 +364,11 @@ class EntryDAO extends Model_pdo {$affected = $stm->rowCount();if ($affected > 0) {- $sql = 'UPDATE freshrss_feed f '+ $sql = 'UPDATE ' . $this->prefix . 'feed f '. 'LEFT OUTER JOIN ('. 'SELECT e.id_feed, '. 'COUNT(*) AS nbUnreads '- . 'FROM freshrss_entry e '+ . 'FROM ' . $this->prefix . 'entry e '. 'WHERE e.is_read = 0 '. 'GROUP BY e.id_feed'. ') x ON x.id_feed=f.id 'diff --git a/app/models/Feed.php b/app/models/Feed.phpindex adc8e1677..549603664 100644--- a/app/models/Feed.php+++ b/app/models/Feed.php@@ -530,12 +530,12 @@ class FeedDAO extends Model_pdo {return $res[0]['count'];}public function updateCachedValues () { //For one single feed, call updateLastUpdate($id)- $sql = 'UPDATE freshrss_feed f '+ $sql = 'UPDATE ' . $this->prefix . 'feed f '. 'INNER JOIN ('. 'SELECT e.id_feed, '. 'COUNT(CASE WHEN e.is_read = 0 THEN 1 END) AS nbUnreads, '. 'COUNT(e.id) AS nbEntries '- . 'FROM freshrss_entry e '+ . 'FROM ' . $this->prefix . 'entry e '. 'GROUP BY e.id_feed'. ') x ON x.id_feed=f.id '. 'SET f.cache_nbEntries=x.nbEntries, f.cache_nbUnreads=x.nbUnreads';diff --git a/app/models/RSSConfiguration.php b/app/models/RSSConfiguration.phpindex f8379a625..9604bee1d 100755--- a/app/models/RSSConfiguration.php+++ b/app/models/RSSConfiguration.php@@ -348,7 +348,7 @@ class RSSConfigurationDAO extends Model_array {public $bottomline_link = 'yes';public function __construct () {- parent::__construct (DATA_PATH . '/Configuration.array.php');+ parent::__construct (DATA_PATH . Configuration::currentUser () . '_user.php');// TODO : simplifier ce code, une boucle for() devrait suffir !if (isset ($this->array['language'])) {@@ -441,5 +441,6 @@ class RSSConfigurationDAO extends Model_array {}$this->writeFile($this->array);+ touch(DATA_PATH . '/touch.txt');}}diff --git a/data/.gitignore b/data/.gitignoreindex 0e407f099..9c60990ac 100644--- a/data/.gitignore+++ b/data/.gitignore@@ -1,6 +1,6 @@cachelogapplication.ini-Configuration.array.php+*_user.php*.sqlitetouch.txt\ No newline at end of filediff --git a/lib/minz/Configuration.php b/lib/minz/Configuration.phpindex bdd6af0fb..5be2ea63d 100755--- a/lib/minz/Configuration.php+++ b/lib/minz/Configuration.php@@ -50,6 +50,8 @@ class Configuration {private static $language = 'en';private static $cache_enabled = false;private static $delay_cache = 3600;+ private static $default_user = '';+ private static $current_user = '';private static $db = array ('host' => false,@@ -88,6 +90,12 @@ class Configuration {public static function dataBase () {return self::$db;}+ public static function defaultUser () {+ return self::$default_user;+ }+ public static function currentUser () {+ return self::$current_user;+ }/*** Initialise les variables de configuration@@ -193,6 +201,10 @@ class Configuration {if (isset ($general['delay_cache'])) {self::$delay_cache = $general['delay_cache'];}+ if (isset ($general['default_user'])) {+ self::$default_user = $general['default_user'];+ self::$current_user = self::$default_user;+ }// Base de données$db = false;diff --git a/lib/minz/dao/Model_pdo.php b/lib/minz/dao/Model_pdo.phpindex beeb65ea8..810e69847 100755--- a/lib/minz/dao/Model_pdo.php+++ b/lib/minz/dao/Model_pdo.php@@ -60,7 +60,8 @@ class Model_pdo {);self::$sharedBd = $this->bd;- $this->prefix = $db['prefix'];+ $userPrefix = Configuration::currentUser ();+ $this->prefix = $db['prefix'] . (empty($userPrefix) ? '' : ($userPrefix . '_'));self::$sharedPrefix = $this->prefix;} catch (Exception $e) {throw new PDOConnectionException (diff --git a/public/index.php b/public/index.phpindex d989bc11d..108853fb7 100755--- a/public/index.php+++ b/public/index.php@@ -28,7 +28,6 @@ if (file_exists ('install.php')) {$dateLastModification = max(@filemtime(DATA_PATH . '/touch.txt'),@filemtime(LOG_PATH . '/application.log'),- @filemtime(DATA_PATH . '/Configuration.array.php'),@filemtime(DATA_PATH . '/application.ini'));if (httpConditional($dateLastModification, 0, 0, false, false, true)) {diff --git a/public/install.php b/public/install.phpindex 085a412ff..42f2d2651 100644--- a/public/install.php+++ b/public/install.php@@ -159,6 +159,7 @@ function saveStep2 () {$_SESSION['old_entries'] = 3;}$_SESSION['mail_login'] = addslashes ($_POST['mail_login']);+ $_SESSION['default_user'] = substr(0, 16, preg_replace ('/[^a-zA-Z0-9]/', '', $_POST['default_user']));$token = '';if ($_SESSION['mail_login']) {@@ -166,7 +167,7 @@ function saveStep2 () {. small_hash ($_SESSION['base_url'] . $_SESSION['sel']);}- $file_data = DATA_PATH . '/Configuration.array.php';+ $file_data = DATA_PATH . '/' . $_SESSION['default_user'] . '_user.php';$f = fopen ($file_data, 'w');writeLine ($f, '<?php');@@ -207,6 +208,7 @@ function saveStep3 () {writeLine ($f, 'sel_application = "' . $_SESSION['sel'] . '"');writeLine ($f, 'base_url = "' . $_SESSION['base_url'] . '"');writeLine ($f, 'title = "' . $_SESSION['title'] . '"');+ writeLine ($f, 'default_user = "' . $_SESSION['default_user'] . '"');writeLine ($f, '[db]');writeLine ($f, 'type = "' . $_SESSION['bd_type'] . '"');writeLine ($f, 'host = "' . $_SESSION['bd_host'] . '"');@@ -288,8 +290,9 @@ function checkStep2 () {isset ($_SESSION['base_url']) &&isset ($_SESSION['title']) &&isset ($_SESSION['old_entries']) &&- isset ($_SESSION['mail_login']);- $data = file_exists (DATA_PATH . '/Configuration.array.php');+ isset ($_SESSION['mail_login']) &&+ isset ($_SESSION['default_user']);+ $data = file_exists (DATA_PATH . '/' . $_SESSION['default_user'] . '_user.php');return array ('conf' => $conf ? 'ok' : 'ko',@@ -512,6 +515,13 @@ function printStep2 () {</div></div>+ <div class="form-group">+ <label class="group-name" for="default_user"><?php echo _t ('default_user'); ?></label>+ <div class="group-controls">+ <input type="text" id="default_user" name="default_user" maxlength="16" value="<?php echo isset ($_SESSION['default_user']) ? $_SESSION['default_user'] : ''; ?>" placeholder="user1" />+ </div>+ </div>+<div class="form-group"><label class="group-name" for="mail_login"><?php echo _t ('persona_connection_email'); ?></label><div class="group-controls">@@ -586,14 +596,14 @@ function printStep3 () {<div class="form-group"><label class="group-name" for="base"><?php echo _t ('bdd'); ?></label><div class="group-controls">- <input type="text" id="base" name="base" value="<?php echo isset ($_SESSION['bd_name']) ? $_SESSION['bd_name'] : ''; ?>" />+ <input type="text" id="base" name="base" maxlength="64" value="<?php echo isset ($_SESSION['bd_name']) ? $_SESSION['bd_name'] : ''; ?>" /></div></div><div class="form-group"><label class="group-name" for="prefix"><?php echo _t ('prefix'); ?></label><div class="group-controls">- <input type="text" id="prefix" name="prefix" value="<?php echo isset ($_SESSION['bd_prefix']) ? $_SESSION['bd_prefix'] : 'freshrss_'; ?>" />+ <input type="text" id="prefix" name="prefix" maxlength="16" value="<?php echo isset ($_SESSION['bd_prefix']) ? $_SESSION['bd_prefix'] : 'freshrss_'; ?>" /></div></div>