aboutsummaryrefslogtreecommitdiffhomepage
path: root/application
diff options
context:
space:
mode:
Diffstat (limited to 'application')
-rw-r--r--application/PageBuilder.php28
-rw-r--r--application/Router.php12
-rw-r--r--application/Updater.php25
-rw-r--r--application/config/ConfigManager.php7
4 files changed, 58 insertions, 14 deletions
diff --git a/application/PageBuilder.php b/application/PageBuilder.php
index 3dba7677..5da70811 100644
--- a/application/PageBuilder.php
+++ b/application/PageBuilder.php
@@ -22,10 +22,20 @@ class PageBuilder
22 protected $conf; 22 protected $conf;
23 23
24 /** 24 /**
25 * @var array $_SESSION
26 */
27 protected $session;
28
29 /**
25 * @var LinkDB $linkDB instance. 30 * @var LinkDB $linkDB instance.
26 */ 31 */
27 protected $linkDB; 32 protected $linkDB;
28 33
34 /**
35 * @var null|string XSRF token
36 */
37 protected $token;
38
29 /** @var bool $isLoggedIn Whether the user is logged in **/ 39 /** @var bool $isLoggedIn Whether the user is logged in **/
30 protected $isLoggedIn = false; 40 protected $isLoggedIn = false;
31 41
@@ -33,14 +43,17 @@ class PageBuilder
33 * PageBuilder constructor. 43 * PageBuilder constructor.
34 * $tpl is initialized at false for lazy loading. 44 * $tpl is initialized at false for lazy loading.
35 * 45 *
36 * @param ConfigManager $conf Configuration Manager instance (reference). 46 * @param ConfigManager $conf Configuration Manager instance (reference).
37 * @param LinkDB $linkDB instance. 47 * @param array $session $_SESSION array
38 * @param string $token Session token 48 * @param LinkDB $linkDB instance.
49 * @param string $token Session token
50 * @param bool $isLoggedIn
39 */ 51 */
40 public function __construct(&$conf, $linkDB = null, $token = null, $isLoggedIn = false) 52 public function __construct(&$conf, $session, $linkDB = null, $token = null, $isLoggedIn = false)
41 { 53 {
42 $this->tpl = false; 54 $this->tpl = false;
43 $this->conf = $conf; 55 $this->conf = $conf;
56 $this->session = $session;
44 $this->linkDB = $linkDB; 57 $this->linkDB = $linkDB;
45 $this->token = $token; 58 $this->token = $token;
46 $this->isLoggedIn = $isLoggedIn; 59 $this->isLoggedIn = $isLoggedIn;
@@ -110,6 +123,11 @@ class PageBuilder
110 $this->tpl->assign('thumbnails_width', $this->conf->get('thumbnails.width')); 123 $this->tpl->assign('thumbnails_width', $this->conf->get('thumbnails.width'));
111 $this->tpl->assign('thumbnails_height', $this->conf->get('thumbnails.height')); 124 $this->tpl->assign('thumbnails_height', $this->conf->get('thumbnails.height'));
112 125
126 if (! empty($_SESSION['warnings'])) {
127 $this->tpl->assign('global_warnings', $_SESSION['warnings']);
128 unset($_SESSION['warnings']);
129 }
130
113 // To be removed with a proper theme configuration. 131 // To be removed with a proper theme configuration.
114 $this->tpl->assign('conf', $this->conf); 132 $this->tpl->assign('conf', $this->conf);
115 } 133 }
diff --git a/application/Router.php b/application/Router.php
index 4df0387c..bf86b884 100644
--- a/application/Router.php
+++ b/application/Router.php
@@ -7,6 +7,8 @@
7 */ 7 */
8class Router 8class Router
9{ 9{
10 public static $AJAX_THUMB_UPDATE = 'ajax_thumb_update';
11
10 public static $PAGE_LOGIN = 'login'; 12 public static $PAGE_LOGIN = 'login';
11 13
12 public static $PAGE_PICWALL = 'picwall'; 14 public static $PAGE_PICWALL = 'picwall';
@@ -47,6 +49,8 @@ class Router
47 49
48 public static $PAGE_SAVE_PLUGINSADMIN = 'save_pluginadmin'; 50 public static $PAGE_SAVE_PLUGINSADMIN = 'save_pluginadmin';
49 51
52 public static $PAGE_THUMBS_UPDATE = 'thumbs_update';
53
50 public static $GET_TOKEN = 'token'; 54 public static $GET_TOKEN = 'token';
51 55
52 /** 56 /**
@@ -101,6 +105,14 @@ class Router
101 return self::$PAGE_FEED_RSS; 105 return self::$PAGE_FEED_RSS;
102 } 106 }
103 107
108 if (startsWith($query, 'do='. self::$PAGE_THUMBS_UPDATE)) {
109 return self::$PAGE_THUMBS_UPDATE;
110 }
111
112 if (startsWith($query, 'do='. self::$AJAX_THUMB_UPDATE)) {
113 return self::$AJAX_THUMB_UPDATE;
114 }
115
104 // At this point, only loggedin pages. 116 // At this point, only loggedin pages.
105 if (!$loggedIn) { 117 if (!$loggedIn) {
106 return self::$PAGE_LINKLIST; 118 return self::$PAGE_LINKLIST;
diff --git a/application/Updater.php b/application/Updater.php
index 6fbe3e00..f6b9e205 100644
--- a/application/Updater.php
+++ b/application/Updater.php
@@ -31,6 +31,11 @@ class Updater
31 protected $isLoggedIn; 31 protected $isLoggedIn;
32 32
33 /** 33 /**
34 * @var array $_SESSION
35 */
36 protected $session;
37
38 /**
34 * @var ReflectionMethod[] List of current class methods. 39 * @var ReflectionMethod[] List of current class methods.
35 */ 40 */
36 protected $methods; 41 protected $methods;
@@ -42,13 +47,17 @@ class Updater
42 * @param LinkDB $linkDB LinkDB instance. 47 * @param LinkDB $linkDB LinkDB instance.
43 * @param ConfigManager $conf Configuration Manager instance. 48 * @param ConfigManager $conf Configuration Manager instance.
44 * @param boolean $isLoggedIn True if the user is logged in. 49 * @param boolean $isLoggedIn True if the user is logged in.
50 * @param array $session $_SESSION (by reference)
51 *
52 * @throws ReflectionException
45 */ 53 */
46 public function __construct($doneUpdates, $linkDB, $conf, $isLoggedIn) 54 public function __construct($doneUpdates, $linkDB, $conf, $isLoggedIn, &$session = [])
47 { 55 {
48 $this->doneUpdates = $doneUpdates; 56 $this->doneUpdates = $doneUpdates;
49 $this->linkDB = $linkDB; 57 $this->linkDB = $linkDB;
50 $this->conf = $conf; 58 $this->conf = $conf;
51 $this->isLoggedIn = $isLoggedIn; 59 $this->isLoggedIn = $isLoggedIn;
60 $this->session = &$session;
52 61
53 // Retrieve all update methods. 62 // Retrieve all update methods.
54 $class = new ReflectionClass($this); 63 $class = new ReflectionClass($this);
@@ -488,11 +497,23 @@ class Updater
488 */ 497 */
489 public function updateMethodWebThumbnailer() 498 public function updateMethodWebThumbnailer()
490 { 499 {
491 $this->conf->set('thumbnails.enabled', $this->conf->get('thumbnail.enable_thumbnails', true)); 500 if ($this->conf->exists('thumbnails.enabled')) {
501 return true;
502 }
503
504 $thumbnailsEnabled = $this->conf->get('thumbnail.enable_thumbnails', true);
505 $this->conf->set('thumbnails.enabled', $thumbnailsEnabled);
492 $this->conf->set('thumbnails.width', 125); 506 $this->conf->set('thumbnails.width', 125);
493 $this->conf->set('thumbnails.height', 90); 507 $this->conf->set('thumbnails.height', 90);
494 $this->conf->remove('thumbnail'); 508 $this->conf->remove('thumbnail');
495 $this->conf->write(true); 509 $this->conf->write(true);
510
511 if ($thumbnailsEnabled) {
512 $this->session['warnings'][] = t(
513 'You have enabled thumbnails. <a href="?do=thumbs_update">Please synchonize them</a>.'
514 );
515 }
516
496 return true; 517 return true;
497 } 518 }
498} 519}
diff --git a/application/config/ConfigManager.php b/application/config/ConfigManager.php
index faf25426..96e2e912 100644
--- a/application/config/ConfigManager.php
+++ b/application/config/ConfigManager.php
@@ -367,10 +367,6 @@ class ConfigManager
367 $this->setEmpty('general.enabled_plugins', self::$DEFAULT_PLUGINS); 367 $this->setEmpty('general.enabled_plugins', self::$DEFAULT_PLUGINS);
368 $this->setEmpty('general.default_note_title', 'Note: '); 368 $this->setEmpty('general.default_note_title', 'Note: ');
369 369
370 $this->setEmpty('thumbnails.enabled', true);
371 $this->setEmpty('thumbnails.width', 120);
372 $this->setEmpty('thumbnails.height', 120);
373
374 $this->setEmpty('updates.check_updates', false); 370 $this->setEmpty('updates.check_updates', false);
375 $this->setEmpty('updates.check_updates_branch', 'stable'); 371 $this->setEmpty('updates.check_updates_branch', 'stable');
376 $this->setEmpty('updates.check_updates_interval', 86400); 372 $this->setEmpty('updates.check_updates_interval', 86400);
@@ -385,9 +381,6 @@ class ConfigManager
385 // default state of the 'remember me' checkbox of the login form 381 // default state of the 'remember me' checkbox of the login form
386 $this->setEmpty('privacy.remember_user_default', true); 382 $this->setEmpty('privacy.remember_user_default', true);
387 383
388 $this->setEmpty('thumbnail.enable_thumbnails', true);
389 $this->setEmpty('thumbnail.enable_localcache', true);
390
391 $this->setEmpty('redirector.url', ''); 384 $this->setEmpty('redirector.url', '');
392 $this->setEmpty('redirector.encode_url', true); 385 $this->setEmpty('redirector.encode_url', true);
393 386