aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/Updater.php
diff options
context:
space:
mode:
Diffstat (limited to 'application/Updater.php')
-rw-r--r--application/Updater.php74
1 files changed, 73 insertions, 1 deletions
diff --git a/application/Updater.php b/application/Updater.php
index 8d2bd577..c2aa1568 100644
--- a/application/Updater.php
+++ b/application/Updater.php
@@ -2,6 +2,7 @@
2use Shaarli\Config\ConfigJson; 2use Shaarli\Config\ConfigJson;
3use Shaarli\Config\ConfigPhp; 3use Shaarli\Config\ConfigPhp;
4use Shaarli\Config\ConfigManager; 4use Shaarli\Config\ConfigManager;
5use Shaarli\Thumbnailer;
5 6
6/** 7/**
7 * Class Updater. 8 * Class Updater.
@@ -31,6 +32,11 @@ class Updater
31 protected $isLoggedIn; 32 protected $isLoggedIn;
32 33
33 /** 34 /**
35 * @var array $_SESSION
36 */
37 protected $session;
38
39 /**
34 * @var ReflectionMethod[] List of current class methods. 40 * @var ReflectionMethod[] List of current class methods.
35 */ 41 */
36 protected $methods; 42 protected $methods;
@@ -42,13 +48,17 @@ class Updater
42 * @param LinkDB $linkDB LinkDB instance. 48 * @param LinkDB $linkDB LinkDB instance.
43 * @param ConfigManager $conf Configuration Manager instance. 49 * @param ConfigManager $conf Configuration Manager instance.
44 * @param boolean $isLoggedIn True if the user is logged in. 50 * @param boolean $isLoggedIn True if the user is logged in.
51 * @param array $session $_SESSION (by reference)
52 *
53 * @throws ReflectionException
45 */ 54 */
46 public function __construct($doneUpdates, $linkDB, $conf, $isLoggedIn) 55 public function __construct($doneUpdates, $linkDB, $conf, $isLoggedIn, &$session = [])
47 { 56 {
48 $this->doneUpdates = $doneUpdates; 57 $this->doneUpdates = $doneUpdates;
49 $this->linkDB = $linkDB; 58 $this->linkDB = $linkDB;
50 $this->conf = $conf; 59 $this->conf = $conf;
51 $this->isLoggedIn = $isLoggedIn; 60 $this->isLoggedIn = $isLoggedIn;
61 $this->session = &$session;
52 62
53 // Retrieve all update methods. 63 // Retrieve all update methods.
54 $class = new ReflectionClass($this); 64 $class = new ReflectionClass($this);
@@ -445,6 +455,68 @@ class Updater
445 $this->linkDB->save($this->conf->get('resource.page_cache')); 455 $this->linkDB->save($this->conf->get('resource.page_cache'));
446 return true; 456 return true;
447 } 457 }
458
459 /**
460 * Change privateonly session key to visibility.
461 */
462 public function updateMethodVisibilitySession()
463 {
464 if (isset($_SESSION['privateonly'])) {
465 unset($_SESSION['privateonly']);
466 $_SESSION['visibility'] = 'private';
467 }
468 return true;
469 }
470
471 /**
472 * Add download size and timeout to the configuration file
473 *
474 * @return bool true if the update is successful, false otherwise.
475 */
476 public function updateMethodDownloadSizeAndTimeoutConf()
477 {
478 if ($this->conf->exists('general.download_max_size')
479 && $this->conf->exists('general.download_timeout')
480 ) {
481 return true;
482 }
483
484 if (! $this->conf->exists('general.download_max_size')) {
485 $this->conf->set('general.download_max_size', 1024*1024*4);
486 }
487
488 if (! $this->conf->exists('general.download_timeout')) {
489 $this->conf->set('general.download_timeout', 30);
490 }
491
492 $this->conf->write($this->isLoggedIn);
493 return true;
494 }
495
496 /**
497 * * Move thumbnails management to WebThumbnailer, coming with new settings.
498 */
499 public function updateMethodWebThumbnailer()
500 {
501 if ($this->conf->exists('thumbnails.mode')) {
502 return true;
503 }
504
505 $thumbnailsEnabled = $this->conf->get('thumbnail.enable_thumbnails', true);
506 $this->conf->set('thumbnails.mode', $thumbnailsEnabled ? Thumbnailer::MODE_ALL : Thumbnailer::MODE_NONE);
507 $this->conf->set('thumbnails.width', 125);
508 $this->conf->set('thumbnails.height', 90);
509 $this->conf->remove('thumbnail');
510 $this->conf->write(true);
511
512 if ($thumbnailsEnabled) {
513 $this->session['warnings'][] = t(
514 'You have enabled or changed thumbnails mode. <a href="?do=thumbs_update">Please synchronize them</a>.'
515 );
516 }
517
518 return true;
519 }
448} 520}
449 521
450/** 522/**