diff options
| author | 2014-08-09 21:32:06 +0200 | |
|---|---|---|
| committer | 2014-08-09 21:32:06 +0200 | |
| commit | fce624218eb247d7174cdb186026174a8a6e5e8b (patch) | |
| tree | f399b3bd6264d9c0f5f9597e3055adab532314b0 | |
| parent | b6e89d4e06814541802c428c4df0e28633f551cd (diff) | |
| parent | d477373ef2879bdeeaa3c157287c0fab98afefdc (diff) | |
Merge branch 'dev' into 411-update-system
| -rw-r--r-- | CHANGELOG | 2 | ||||
| -rwxr-xr-x | app/Controllers/configureController.php | 1 | ||||
| -rw-r--r-- | app/Models/Configuration.php | 4 | ||||
| -rw-r--r-- | app/Models/UserDAO.php | 35 | ||||
| -rw-r--r-- | app/SQL/install.sql.sqlite.php | 1 | ||||
| -rw-r--r-- | app/i18n/en.php | 1 | ||||
| -rw-r--r-- | app/i18n/fr.php | 1 | ||||
| -rw-r--r-- | app/layout/aside_flux.phtml | 2 | ||||
| -rw-r--r-- | app/layout/nav_menu.phtml | 4 | ||||
| -rw-r--r-- | app/views/configure/reading.phtml | 29 | ||||
| -rw-r--r-- | app/views/importExport/index.phtml | 8 | ||||
| -rw-r--r-- | lib/Minz/ModelPdo.php | 20 |
12 files changed, 71 insertions, 37 deletions
@@ -5,6 +5,7 @@ * UI * Hide categories/feeds with unread articles when showing only unread articles * Dynamic favicon showing the number of unread articles + * New theme: Screwdriver by Mister aiR * Statistics * New page with article repartition * Improvements @@ -12,6 +13,7 @@ * Basic protection against XSRF (Cross-Site Request Forgery) based on HTTP Referer (POST requests only) * Misc. * Changed lazyload implementation + * Support of HTML5 notifications for new upcoming articles * Bux fixes in export function, add/remove users, keyboard shortcuts, etc. diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php index 79f40b30b..0bf58880f 100755 --- a/app/Controllers/configureController.php +++ b/app/Controllers/configureController.php @@ -184,6 +184,7 @@ class FreshRSS_configure_Controller extends Minz_ActionController { $this->view->conf->_default_view((int)Minz_Request::param('default_view', FreshRSS_Entry::STATE_ALL)); $this->view->conf->_auto_load_more(Minz_Request::param('auto_load_more', false)); $this->view->conf->_display_posts(Minz_Request::param('display_posts', false)); + $this->view->conf->_hide_read_feeds(Minz_Request::param('hide_read_feeds', false)); $this->view->conf->_onread_jump_next(Minz_Request::param('onread_jump_next', false)); $this->view->conf->_lazyload(Minz_Request::param('lazyload', false)); $this->view->conf->_sticky_post(Minz_Request::param('sticky_post', false)); diff --git a/app/Models/Configuration.php b/app/Models/Configuration.php index 7596c54cd..2f47312c0 100644 --- a/app/Models/Configuration.php +++ b/app/Models/Configuration.php @@ -17,6 +17,7 @@ class FreshRSS_Configuration { 'default_view' => FreshRSS_Entry::STATE_NOT_READ, 'auto_load_more' => true, 'display_posts' => false, + 'hide_read_feeds' => true, 'onread_jump_next' => true, 'lazyload' => true, 'sticky_post' => true, @@ -141,6 +142,9 @@ class FreshRSS_Configuration { public function _display_posts ($value) { $this->data['display_posts'] = ((bool)$value) && $value !== 'no'; } + public function _hide_read_feeds($value) { + $this->data['hide_read_feeds'] = (bool)$value; + } public function _onread_jump_next ($value) { $this->data['onread_jump_next'] = ((bool)$value) && $value !== 'no'; } diff --git a/app/Models/UserDAO.php b/app/Models/UserDAO.php index 1763fac67..9f64fb4a7 100644 --- a/app/Models/UserDAO.php +++ b/app/Models/UserDAO.php @@ -4,18 +4,21 @@ class FreshRSS_UserDAO extends Minz_ModelPdo { public function createUser($username) { $db = Minz_Configuration::dataBase(); require_once(APP_PATH . '/SQL/install.sql.' . $db['type'] . '.php'); - - if (defined('SQL_CREATE_TABLES')) { + + $userPDO = new Minz_ModelPdo($username); + + $ok = false; + if (defined('SQL_CREATE_TABLES')) { //E.g. MySQL $sql = sprintf(SQL_CREATE_TABLES, $db['prefix'] . $username . '_', Minz_Translate::t('default_category')); - $stm = $this->bd->prepare($sql); + $stm = $userPDO->bd->prepare($sql); $ok = $stm && $stm->execute(); - } else { + } else { //E.g. SQLite global $SQL_CREATE_TABLES; if (is_array($SQL_CREATE_TABLES)) { $ok = true; foreach ($SQL_CREATE_TABLES as $instruction) { $sql = sprintf($instruction, '', Minz_Translate::t('default_category')); - $stm = $c->prepare($sql); + $stm = $userPDO->bd->prepare($sql); $ok &= ($stm && $stm->execute()); } } @@ -24,7 +27,7 @@ class FreshRSS_UserDAO extends Minz_ModelPdo { if ($ok) { return true; } else { - $info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo(); + $info = empty($stm) ? array(2 => 'syntax error') : $stm->errorInfo(); Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR); return false; } @@ -34,14 +37,20 @@ class FreshRSS_UserDAO extends Minz_ModelPdo { $db = Minz_Configuration::dataBase(); require_once(APP_PATH . '/SQL/install.sql.' . $db['type'] . '.php'); - $sql = sprintf(SQL_DROP_TABLES, $db['prefix'] . $username . '_'); - $stm = $this->bd->prepare($sql); - if ($stm && $stm->execute()) { - return true; + if ($db['type'] === 'sqlite') { + return unlink(DATA_PATH . '/' . $username . '.sqlite'); } else { - $info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo(); - Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR); - return false; + $userPDO = new Minz_ModelPdo($username); + + $sql = sprintf(SQL_DROP_TABLES, $db['prefix'] . $username . '_'); + $stm = $userPDO->bd->prepare($sql); + if ($stm && $stm->execute()) { + return true; + } else { + $info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo(); + Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR); + return false; + } } } } diff --git a/app/SQL/install.sql.sqlite.php b/app/SQL/install.sql.sqlite.php index b90a5ef5e..7988ada04 100644 --- a/app/SQL/install.sql.sqlite.php +++ b/app/SQL/install.sql.sqlite.php @@ -1,4 +1,5 @@ <?php +global $SQL_CREATE_TABLES; $SQL_CREATE_TABLES = array( 'CREATE TABLE IF NOT EXISTS `%1$scategory` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, diff --git a/app/i18n/en.php b/app/i18n/en.php index 532327e4a..d80299b10 100644 --- a/app/i18n/en.php +++ b/app/i18n/en.php @@ -262,6 +262,7 @@ return array ( 'sort_order' => 'Sort order', 'auto_load_more' => 'Load next articles at the page bottom', 'display_articles_unfolded' => 'Show articles unfolded by default', + 'hide_read_feeds' => 'Hide categories & feeds with no unread article (only in “unread articles” display mode)', 'after_onread' => 'After “mark all as read”,', 'jump_next' => 'jump to next unread sibling (feed or category)', 'article_icons' => 'Article icons', diff --git a/app/i18n/fr.php b/app/i18n/fr.php index 0705d80b2..4be028ac3 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -262,6 +262,7 @@ return array ( 'sort_order' => 'Ordre de tri', 'auto_load_more' => 'Charger les articles suivants en bas de page', 'display_articles_unfolded' => 'Afficher les articles dépliés par défaut', + 'hide_read_feeds' => 'Cacher les catégories & flux sans article non-lu (uniquement en affichage “articles non lus”)', 'after_onread' => 'Après “marquer tout comme lu”,', 'jump_next' => 'sauter au prochain voisin non lu (flux ou catégorie)', 'article_icons' => 'Icônes d’article', diff --git a/app/layout/aside_flux.phtml b/app/layout/aside_flux.phtml index cc04e757c..aee8f8754 100644 --- a/app/layout/aside_flux.phtml +++ b/app/layout/aside_flux.phtml @@ -1,4 +1,4 @@ -<div class="aside aside_flux<?php if (($this->state & FreshRSS_Entry::STATE_NOT_READ) && !($this->state & FreshRSS_Entry::STATE_READ)) echo ' state_unread'; ?>" id="aside_flux"> +<div class="aside aside_flux<?php if ($this->conf->hide_read_feeds && ($this->state & FreshRSS_Entry::STATE_NOT_READ) && !($this->state & FreshRSS_Entry::STATE_READ)) echo ' state_unread'; ?>" id="aside_flux"> <a class="toggle_aside" href="#close"><?php echo FreshRSS_Themes::icon('close'); ?></a> <ul class="categories"> diff --git a/app/layout/nav_menu.phtml b/app/layout/nav_menu.phtml index 29ea9032c..73a921c5d 100644 --- a/app/layout/nav_menu.phtml +++ b/app/layout/nav_menu.phtml @@ -221,7 +221,9 @@ <?php $url_output['params']['output'] = 'rss'; - $url_output['params']['token'] = $this->conf->token; + if ($this->conf->token) { + $url_output['params']['token'] = $this->conf->token; + } ?> <a class="view_rss btn" target="_blank" title="<?php echo Minz_Translate::t ('rss_view'); ?>" href="<?php echo Minz_Url::display($url_output); ?>"> <?php echo FreshRSS_Themes::icon('rss'); ?> diff --git a/app/views/configure/reading.phtml b/app/views/configure/reading.phtml index d56726730..e96bcea42 100644 --- a/app/views/configure/reading.phtml +++ b/app/views/configure/reading.phtml @@ -44,10 +44,9 @@ <div class="form-group"> <div class="group-controls"> - <label class="checkbox" for="auto_load_more"> - <input type="checkbox" name="auto_load_more" id="auto_load_more" value="1"<?php echo $this->conf->auto_load_more ? ' checked="checked"' : ''; ?> /> - <?php echo Minz_Translate::t ('auto_load_more'); ?> - <noscript> — <strong><?php echo Minz_Translate::t ('javascript_should_be_activated'); ?></strong></noscript> + <label class="checkbox" for="hide_read_feeds"> + <input type="checkbox" name="hide_read_feeds" id="hide_read_feeds" value="1"<?php echo $this->conf->hide_read_feeds ? ' checked="checked"' : ''; ?> /> + <?php echo Minz_Translate::t('hide_read_feeds'); ?> </label> </div> </div> @@ -64,9 +63,9 @@ <div class="form-group"> <div class="group-controls"> - <label class="checkbox" for="lazyload"> - <input type="checkbox" name="lazyload" id="lazyload" value="1"<?php echo $this->conf->lazyload ? ' checked="checked"' : ''; ?> /> - <?php echo Minz_Translate::t ('img_with_lazyload'); ?> + <label class="checkbox" for="sticky_post"> + <input type="checkbox" name="sticky_post" id="sticky_post" value="1"<?php echo $this->conf->sticky_post ? ' checked="checked"' : ''; ?> /> + <?php echo Minz_Translate::t ('sticky_post'); ?> <noscript> — <strong><?php echo Minz_Translate::t ('javascript_should_be_activated'); ?></strong></noscript> </label> </div> @@ -74,9 +73,19 @@ <div class="form-group"> <div class="group-controls"> - <label class="checkbox" for="sticky_post"> - <input type="checkbox" name="sticky_post" id="sticky_post" value="1"<?php echo $this->conf->sticky_post ? ' checked="checked"' : ''; ?> /> - <?php echo Minz_Translate::t ('sticky_post'); ?> + <label class="checkbox" for="auto_load_more"> + <input type="checkbox" name="auto_load_more" id="auto_load_more" value="1"<?php echo $this->conf->auto_load_more ? ' checked="checked"' : ''; ?> /> + <?php echo Minz_Translate::t ('auto_load_more'); ?> + <noscript> — <strong><?php echo Minz_Translate::t ('javascript_should_be_activated'); ?></strong></noscript> + </label> + </div> + </div> + + <div class="form-group"> + <div class="group-controls"> + <label class="checkbox" for="lazyload"> + <input type="checkbox" name="lazyload" id="lazyload" value="1"<?php echo $this->conf->lazyload ? ' checked="checked"' : ''; ?> /> + <?php echo Minz_Translate::t ('img_with_lazyload'); ?> <noscript> — <strong><?php echo Minz_Translate::t ('javascript_should_be_activated'); ?></strong></noscript> </label> </div> diff --git a/app/views/importExport/index.phtml b/app/views/importExport/index.phtml index 96cd2b4e7..e1458e916 100644 --- a/app/views/importExport/index.phtml +++ b/app/views/importExport/index.phtml @@ -30,18 +30,18 @@ </label> <label class="checkbox" for="export_starred"> - <input type="checkbox" name="export_starred" id="export_starred" value="1" checked="checked" /> + <input type="checkbox" name="export_starred" id="export_starred" value="1" <?php echo extension_loaded('zip') ? 'checked="checked"' : ''; ?> /> <?php echo _t('export_starred'); ?> </label> <?php $select_args = ''; if (extension_loaded('zip')) { - $select_args = ' size="<?php echo min(10, count($this->feeds)); ?>" multiple="multiple"'; + $select_args = ' size="' . min(10, count($this->feeds)) .'" multiple="multiple"'; } ?> - <select name="export_feeds[]"<?php echo $select_arg; ?>> - <?php echo extension_loaded('zip')? '': '<option></option>'; ?> + <select name="export_feeds[]"<?php echo $select_args; ?>> + <?php echo extension_loaded('zip') ? '' : '<option></option>'; ?> <?php foreach ($this->feeds as $feed) { ?> <option value="<?php echo $feed->id(); ?>"><?php echo $feed->name(); ?></option> <?php } ?> diff --git a/lib/Minz/ModelPdo.php b/lib/Minz/ModelPdo.php index 1f56f09c2..45a1e9451 100644 --- a/lib/Minz/ModelPdo.php +++ b/lib/Minz/ModelPdo.php @@ -33,8 +33,8 @@ class Minz_ModelPdo { * Créé la connexion à la base de données à l'aide des variables * HOST, BASE, USER et PASS définies dans le fichier de configuration */ - public function __construct() { - if (self::$useSharedBd && self::$sharedBd != null) { + public function __construct($currentUser = null) { + if (self::$useSharedBd && self::$sharedBd != null && $currentUser === null) { $this->bd = self::$sharedBd; $this->prefix = self::$sharedPrefix; return; @@ -42,6 +42,10 @@ class Minz_ModelPdo { $db = Minz_Configuration::dataBase(); + if ($currentUser === null) { + $currentUser = Minz_Session::param('currentUser', '_'); + } + try { $type = $db['type']; if ($type === 'mysql') { @@ -51,9 +55,9 @@ class Minz_ModelPdo { $driver_options = array( PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8', ); - $this->prefix = $db['prefix'] . Minz_Session::param('currentUser', '_') . '_'; + $this->prefix = $db['prefix'] . $currentUser . '_'; } elseif ($type === 'sqlite') { - $string = 'sqlite:' . DATA_PATH . '/' . Minz_Session::param('currentUser', '_') . '.sqlite'; + $string = 'sqlite:' . DATA_PATH . '/' . $currentUser . '.sqlite'; $driver_options = array( //PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, ); @@ -67,7 +71,7 @@ class Minz_ModelPdo { self::$sharedDbType = $type; self::$sharedPrefix = $this->prefix; - $this->bd = new FreshPDO( + $this->bd = new MinzPDO( $string, $db['user'], $db['password'], @@ -98,7 +102,7 @@ class Minz_ModelPdo { } } -class FreshPDO extends PDO { +class MinzPDO extends PDO { private static function check($statement) { if (preg_match('/^(?:UPDATE|INSERT|DELETE)/i', $statement)) { invalidateHttpCache(); @@ -106,12 +110,12 @@ class FreshPDO extends PDO { } public function prepare($statement, $driver_options = array()) { - FreshPDO::check($statement); + MinzPDO::check($statement); return parent::prepare($statement, $driver_options); } public function exec($statement) { - FreshPDO::check($statement); + MinzPDO::check($statement); return parent::exec($statement); } } |
