From 22febc135134511b43a8543ea45c49c7aeec6f84 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sat, 27 Jul 2013 13:58:58 +0200 Subject: [PATCH] Fix issue #101 : option interdiction anonymes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ajout d'une option pour interdire la lecture anonyme (interdit par défaut) Correction de l'internationalisation pour la pagination des logs --- app/controllers/configureController.php | 3 ++ app/i18n/en.php | 10 +++++++ app/i18n/fr.php | 10 +++++++ app/layout/header.phtml | 8 ++++-- app/layout/persona.phtml | 25 +++++++---------- app/models/RSSConfiguration.php | 28 +++++++++++++++++++ app/views/configure/display.phtml | 4 +++ app/views/helpers/logs_pagination.phtml | 8 +++--- .../helpers/{ => view}/global_view.phtml | 0 .../helpers/{ => view}/normal_view.phtml | 0 .../helpers/{ => view}/reader_view.phtml | 0 app/views/helpers/{ => view}/rss_view.phtml | 0 app/views/index/index.phtml | 25 ++++++++++++----- 13 files changed, 93 insertions(+), 28 deletions(-) rename app/views/helpers/{ => view}/global_view.phtml (100%) rename app/views/helpers/{ => view}/normal_view.phtml (100%) rename app/views/helpers/{ => view}/reader_view.phtml (100%) rename app/views/helpers/{ => view}/rss_view.phtml (100%) diff --git a/app/controllers/configureController.php b/app/controllers/configureController.php index ce53e1040..b91582520 100755 --- a/app/controllers/configureController.php +++ b/app/controllers/configureController.php @@ -147,6 +147,7 @@ class configureController extends ActionController { $sort = Request::param ('sort_order', 'low_to_high'); $old = Request::param ('old_entries', 3); $mail = Request::param ('mail_login', false); + $anon = Request::param ('anon_access', 'no'); $openArticle = Request::param ('mark_open_article', 'no'); $openSite = Request::param ('mark_open_site', 'no'); $scroll = Request::param ('mark_scroll', 'no'); @@ -161,6 +162,7 @@ class configureController extends ActionController { $this->view->conf->_sortOrder ($sort); $this->view->conf->_oldEntries ($old); $this->view->conf->_mailLogin ($mail); + $this->view->conf->_anonAccess ($anon); $this->view->conf->_markWhen (array ( 'article' => $openArticle, 'site' => $openSite, @@ -178,6 +180,7 @@ class configureController extends ActionController { 'sort_order' => $this->view->conf->sortOrder (), 'old_entries' => $this->view->conf->oldEntries (), 'mail_login' => $this->view->conf->mailLogin (), + 'anon_access' => $this->view->conf->anonAccess (), 'mark_when' => $this->view->conf->markWhen (), 'url_shaarli' => $this->view->conf->urlShaarli (), ); diff --git a/app/i18n/en.php b/app/i18n/en.php index 0ea64ac32..3287e3a15 100644 --- a/app/i18n/en.php +++ b/app/i18n/en.php @@ -45,6 +45,12 @@ return array ( 'older_first' => 'Oldest first', 'newer_first' => 'Newer first', + // Pagination + 'first' => 'First', + 'previous' => 'Previous', + 'next' => 'Next', + 'last' => 'Last', + // CONTROLLERS 'article_published_on' => 'This article originally appeared on %s', 'article_published_on_author' => 'This article originally appeared on %s by %s', @@ -144,6 +150,7 @@ return array ( 'delete_articles_every' => 'Remove articles every', 'month' => 'months', 'persona_connection_email' => 'Login mail address (use Persona)', + 'allow_anonymous' => 'Allow anonymous reading', 'reading_configuration' => 'Reading configuration', 'articles_per_page' => 'Number of articles per page', 'default_view' => 'Default view', @@ -196,6 +203,9 @@ return array ( 'logs' => 'Logs', 'logs_empty' => 'Log file is empty', + 'forbidden_access' => 'Forbidden access', + 'forbidden_access_description' => 'Access is password protected, please sign in to read your feeds.', + // DATE 'january' => 'january', 'february' => 'february', diff --git a/app/i18n/fr.php b/app/i18n/fr.php index 022cd38bb..d5a7f8fa0 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -45,6 +45,12 @@ return array ( 'older_first' => 'Plus anciens en premier', 'newer_first' => 'Plus récents en premier', + // Pagination + 'first' => 'Début', + 'previous' => 'Précédent', + 'next' => 'Suivant', + 'last' => 'Fin', + // CONTROLLERS 'article_published_on' => 'Article publié initialement sur %s', 'article_published_on_author' => 'Article publié initialement sur %s par %s', @@ -144,6 +150,7 @@ return array ( 'delete_articles_every' => 'Supprimer les articles tous les', 'month' => 'mois', 'persona_connection_email' => 'Adresse mail de connexion (utilise Persona)', + 'allow_anonymous' => 'Autoriser la lecture anonyme', 'reading_configuration' => 'Configuration de lecture', 'articles_per_page' => 'Nombre d\'articles par page', 'default_view' => 'Vue par défaut', @@ -196,6 +203,9 @@ return array ( 'logs' => 'Logs', 'logs_empty' => 'Les logs sont vides', + 'forbidden_access' => 'Accès interdit', + 'forbidden_access_description' => 'L\'accès est protégé par un mot de passe, veuillez vous connecter pour accéder aux flux.', + // DATE 'january' => 'janvier', 'february' => 'février', diff --git a/app/layout/header.phtml b/app/layout/header.phtml index 4131f8687..a46864482 100644 --- a/app/layout/header.phtml +++ b/app/layout/header.phtml @@ -1,9 +1,9 @@ conf)) { ?> @@ -15,6 +15,9 @@ conf) || is_logged ()) { ?> diff --git a/app/layout/persona.phtml b/app/layout/persona.phtml index 8db8d5167..f25e4c3fd 100644 --- a/app/layout/persona.phtml +++ b/app/layout/persona.phtml @@ -1,4 +1,5 @@ conf)) { ?> + 'login')); ?>"; logout_url = " 'logout')); ?>"; currentUser = ; -var signinLink = $('a#signin'); -if (signinLink) { - signinLink.click(function() { - navigator.id.request(); - return false; - }); -}; - -var signoutLink = $('a#signout'); -if (signoutLink) { - signoutLink.click(function() { - navigator.id.logout(); - return false; - }); -}; +$('a.signin').click(function() { + navigator.id.request(); + return false; +}); + +$('a.signout').click(function() { + navigator.id.logout(); + return false; +}); navigator.id.watch({ loggedInUser: currentUser, diff --git a/app/models/RSSConfiguration.php b/app/models/RSSConfiguration.php index dde120e4a..798ce2d0c 100755 --- a/app/models/RSSConfiguration.php +++ b/app/models/RSSConfiguration.php @@ -17,6 +17,8 @@ class RSSConfiguration extends Model { private $mail_login = ''; private $mark_when = array (); private $url_shaarli = ''; + private $theme; + private $anon_access; public function __construct () { $confDAO = new RSSConfigurationDAO (); @@ -32,6 +34,8 @@ class RSSConfiguration extends Model { $this->_mailLogin ($confDAO->mail_login); $this->_markWhen ($confDAO->mark_when); $this->_urlShaarli ($confDAO->url_shaarli); + $this->_theme ($confDAO->theme); + $this->_anonAccess ($confDAO->anon_access); } public function availableLanguages () { @@ -82,6 +86,12 @@ class RSSConfiguration extends Model { public function urlShaarli () { return $this->url_shaarli; } + public function theme () { + return $this->theme; + } + public function anonAccess () { + return $this->anon_access; + } public function _language ($value) { if (!isset ($this->available_languages[$value])) { @@ -171,6 +181,16 @@ class RSSConfiguration extends Model { $this->url_shaarli = $value; } } + public function _theme ($value) { + $this->theme = $value; + } + public function _anonAccess ($value) { + if ($value == 'yes') { + $this->anon_access = 'yes'; + } else { + $this->anon_access = 'no'; + } + } } class RSSConfigurationDAO extends Model_array { @@ -198,6 +218,8 @@ class RSSConfigurationDAO extends Model_array { 'scroll' => 'no' ); public $url_shaarli = ''; + public $theme = 'default'; + public $anon_access = 'no'; public function __construct () { parent::__construct (PUBLIC_PATH . '/data/Configuration.array.php'); @@ -238,6 +260,12 @@ class RSSConfigurationDAO extends Model_array { if (isset ($this->array['url_shaarli'])) { $this->url_shaarli = $this->array['url_shaarli']; } + if (isset ($this->array['theme'])) { + $this->theme = $this->array['theme']; + } + if (isset ($this->array['anon_access'])) { + $this->anon_access = $this->array['anon_access']; + } } public function update ($values) { diff --git a/app/views/configure/display.phtml b/app/views/configure/display.phtml index 7ed5989e2..f8e94c0f2 100644 --- a/app/views/configure/display.phtml +++ b/app/views/configure/display.phtml @@ -31,6 +31,10 @@
+
diff --git a/app/views/helpers/logs_pagination.phtml b/app/views/helpers/logs_pagination.phtml index 0088dabc6..9f1d6cb23 100755 --- a/app/views/helpers/logs_pagination.phtml +++ b/app/views/helpers/logs_pagination.phtml @@ -9,14 +9,14 @@
  • currentPage > 1) { ?> - « Début + «
  • currentPage - 1; ?>
  • currentPage > 1) { ?> - ‹ Précédent + ‹
  • @@ -34,13 +34,13 @@ currentPage + 1; ?>
  • currentPage < $this->nbPage) { ?> - Suivant › + ›
  • nbPage; ?>
  • currentPage < $this->nbPage) { ?> - Fin » + »
  • diff --git a/app/views/helpers/global_view.phtml b/app/views/helpers/view/global_view.phtml similarity index 100% rename from app/views/helpers/global_view.phtml rename to app/views/helpers/view/global_view.phtml diff --git a/app/views/helpers/normal_view.phtml b/app/views/helpers/view/normal_view.phtml similarity index 100% rename from app/views/helpers/normal_view.phtml rename to app/views/helpers/view/normal_view.phtml diff --git a/app/views/helpers/reader_view.phtml b/app/views/helpers/view/reader_view.phtml similarity index 100% rename from app/views/helpers/reader_view.phtml rename to app/views/helpers/view/reader_view.phtml diff --git a/app/views/helpers/rss_view.phtml b/app/views/helpers/view/rss_view.phtml similarity index 100% rename from app/views/helpers/rss_view.phtml rename to app/views/helpers/view/rss_view.phtml diff --git a/app/views/index/index.phtml b/app/views/index/index.phtml index 46ff33b3a..4bf82f9b4 100644 --- a/app/views/index/index.phtml +++ b/app/views/index/index.phtml @@ -2,12 +2,23 @@ $output = Request::param ('output', 'normal'); -if ($output == 'rss') { - $this->renderHelper ('rss_view'); -} elseif($output == 'reader') { - $this->renderHelper ('reader_view'); -} elseif($output == 'global') { - $this->renderHelper ('global_view'); +if(!login_is_conf ($this->conf) || + is_logged() || + $this->conf->anonAccess() == 'yes') { + if($output == 'rss') { + $this->renderHelper ('view/rss_view'); + } elseif($output == 'reader') { + $this->renderHelper ('view/reader_view'); + } elseif($output == 'global') { + $this->renderHelper ('view/global_view'); + } else { + $this->renderHelper ('view/normal_view'); + } } else { - $this->renderHelper ('normal_view'); +?> +
    +

    +

    +
    +