From 55821e04c188997d258645975220828e195d0df4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Mon, 5 Aug 2013 15:54:37 +0200 Subject: share email +twitter / class messages --- inc/poche/Poche.class.php | 27 ++++++++++++++++++++++----- inc/poche/Tools.class.php | 11 +++++++++++ inc/poche/config.inc.php | 5 ++++- 3 files changed, 37 insertions(+), 6 deletions(-) (limited to 'inc/poche') diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index f9bcf85b..80bf6919 100644 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -12,6 +12,7 @@ class Poche { public $store; public $tpl; + public $messages; function __construct($storage_type) { @@ -41,6 +42,9 @@ class Poche 'cache' => CACHE, )); $this->tpl->addExtension(new Twig_Extensions_Extension_I18n()); + # filter to display domain name of an url + $filter = new Twig_SimpleFilter('getDomain', 'Tools::getDomain'); + $this->tpl->addFilter($filter); Tools::initPhp(); Session::init(); @@ -113,10 +117,12 @@ class Poche case 'toggle_fav' : $this->store->favoriteById($id); Tools::logm('mark as favorite link #' . $id); + Tools::redirect(); break; case 'toggle_archive' : $this->store->archiveById($id); Tools::logm('archive link #' . $id); + Tools::redirect(); break; default: break; @@ -174,16 +180,21 @@ class Poche public function updatePassword() { - if (isset($_POST['password']) && isset($_POST['password_repeat'])) { - if ($_POST['password'] == $_POST['password_repeat'] && $_POST['password'] != "") { - if (!MODE_DEMO) { + if (MODE_DEMO) { + $this->messages->add('i', 'in demo mode, you can\'t update your password'); + Tools::logm('in demo mode, you can\'t do this'); + } + else { + if (isset($_POST['password']) && isset($_POST['password_repeat'])) { + if ($_POST['password'] == $_POST['password_repeat'] && $_POST['password'] != "") { Tools::logm('password updated'); + $this->messages->add('s', 'your password has been updated'); $this->store->updatePassword(Tools::encodeString($_POST['password'] . $_SESSION['login'])); Session::logout(); Tools::redirect(); } else { - Tools::logm('in demo mode, you can\'t do this'); + $this->messages->add('e', 'the two fields have to be filled & the password must be the same in the two fields'); } } } @@ -194,7 +205,7 @@ class Poche if (!empty($_POST['login']) && !empty($_POST['password'])) { if (Session::login($_SESSION['login'], $_SESSION['pass'], $_POST['login'], Tools::encodeString($_POST['password'] . $_POST['login']))) { Tools::logm('login successful'); - + $this->messages->add('s', 'login successful, welcome to your poche'); if (!empty($_POST['longlastingsession'])) { $_SESSION['longlastingsession'] = 31536000; $_SESSION['expires_on'] = time() + $_SESSION['longlastingsession']; @@ -205,9 +216,11 @@ class Poche session_regenerate_id(true); Tools::redirect($referer); } + $this->messages->add('e', 'login failed, bad login or password'); Tools::logm('login failed'); Tools::redirect(); } else { + $this->messages->add('e', 'login failed, you have to fill all fields'); Tools::logm('login failed'); Tools::redirect(); } @@ -215,6 +228,7 @@ class Poche public function logout() { + $this->messages->add('s', 'logout successful, see you soon!'); Tools::logm('logout'); Session::logout(); Tools::redirect(); @@ -244,6 +258,7 @@ class Poche # the second
    is for read links $read = 1; } + $this->messages->add('s', 'import from instapaper completed'); Tools::logm('import from instapaper completed'); Tools::redirect(); } @@ -272,6 +287,7 @@ class Poche # the second