aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc/poche/Poche.class.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/poche/Poche.class.php')
-rw-r--r--inc/poche/Poche.class.php36
1 files changed, 19 insertions, 17 deletions
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php
index 789d6647..2c0c73f9 100644
--- a/inc/poche/Poche.class.php
+++ b/inc/poche/Poche.class.php
@@ -10,6 +10,7 @@
10 10
11class Poche 11class Poche
12{ 12{
13 public $user;
13 public $store; 14 public $store;
14 public $tpl; 15 public $tpl;
15 public $messages; 16 public $messages;
@@ -26,17 +27,20 @@ class Poche
26 { 27 {
27 $this->install(); 28 $this->install();
28 } 29 }
29
30 $this->saveUser();
31 } 30 }
32 31
33 private function init() 32 private function init()
34 { 33 {
34 Tools::initPhp();
35 Session::init();
36 $this->user = isset($_SESSION['poche_user']) ? $_SESSION['poche_user'] : array();
37
35 # l10n 38 # l10n
36 putenv('LC_ALL=' . LANG); 39 $language = ($this->user->getConfigValue('language')) ? $this->user->getConfigValue('language') : LANG;
37 setlocale(LC_ALL, LANG); 40 putenv('LC_ALL=' . $language);
38 bindtextdomain(LANG, LOCALE); 41 setlocale(LC_ALL, $language);
39 textdomain(LANG); 42 bindtextdomain($language, LOCALE);
43 textdomain($language);
40 44
41 # template engine 45 # template engine
42 $loader = new Twig_Loader_Filesystem(TPL); 46 $loader = new Twig_Loader_Filesystem(TPL);
@@ -48,10 +52,9 @@ class Poche
48 $filter = new Twig_SimpleFilter('getDomain', 'Tools::getDomain'); 52 $filter = new Twig_SimpleFilter('getDomain', 'Tools::getDomain');
49 $this->tpl->addFilter($filter); 53 $this->tpl->addFilter($filter);
50 54
51 $this->pagination = new Paginator(PAGINATION, 'p'); 55 # Pagination
52 56 $pager = ($this->user->getConfigValue('pager')) ? $this->user->getConfigValue('pager') : PAGINATION;
53 Tools::initPhp(); 57 $this->pagination = new Paginator($pager, 'p');
54 Session::init();
55 } 58 }
56 59
57 private function install() 60 private function install()
@@ -77,12 +80,6 @@ class Poche
77 exit(); 80 exit();
78 } 81 }
79 82
80 private function saveUser()
81 {
82 $_SESSION['login'] = (isset ($_SESSION['login'])) ? $_SESSION['login'] : $this->store->getLogin();
83 $_SESSION['pass'] = (isset ($_SESSION['pass'])) ? $_SESSION['pass'] : $this->store->getPassword();
84 }
85
86 /** 83 /**
87 * Call action (mark as fav, archive, delete, etc.) 84 * Call action (mark as fav, archive, delete, etc.)
88 */ 85 */
@@ -221,7 +218,11 @@ class Poche
221 public function login($referer) 218 public function login($referer)
222 { 219 {
223 if (!empty($_POST['login']) && !empty($_POST['password'])) { 220 if (!empty($_POST['login']) && !empty($_POST['password'])) {
224 if (Session::login($_SESSION['login'], $_SESSION['pass'], $_POST['login'], Tools::encodeString($_POST['password'] . $_POST['login']))) { 221 $user = $this->store->login($_POST['login'], Tools::encodeString($_POST['password'] . $_POST['login']));
222 if ($user != array()) {
223 # Save login into Session
224 Session::login($user['username'], $user['password'], $_POST['login'], Tools::encodeString($_POST['password'] . $_POST['login']), array('poche_user' => new User($user)));
225
225 Tools::logm('login successful'); 226 Tools::logm('login successful');
226 $this->messages->add('s', 'welcome to your poche'); 227 $this->messages->add('s', 'welcome to your poche');
227 if (!empty($_POST['longlastingsession'])) { 228 if (!empty($_POST['longlastingsession'])) {
@@ -248,6 +249,7 @@ class Poche
248 { 249 {
249 $this->messages->add('s', 'see you soon!'); 250 $this->messages->add('s', 'see you soon!');
250 Tools::logm('logout'); 251 Tools::logm('logout');
252 $this->user = array();
251 Session::logout(); 253 Session::logout();
252 Tools::redirect(); 254 Tools::redirect();
253 } 255 }