summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Authentication/Token/DefaultTokenProvider.php1
-rw-r--r--lib/private/Installer.php25
-rw-r--r--lib/private/Server.php10
-rw-r--r--lib/private/Setup.php28
-rw-r--r--lib/private/Share20/DefaultShareProvider.php3
-rw-r--r--lib/private/Share20/Manager.php39
-rw-r--r--lib/private/Updater.php19
-rw-r--r--lib/private/legacy/app.php16
-rw-r--r--lib/private/legacy/util.php11
9 files changed, 86 insertions, 66 deletions
diff --git a/lib/private/Authentication/Token/DefaultTokenProvider.php b/lib/private/Authentication/Token/DefaultTokenProvider.php
index 3fca122d287..36a8b1d5464 100644
--- a/lib/private/Authentication/Token/DefaultTokenProvider.php
+++ b/lib/private/Authentication/Token/DefaultTokenProvider.php
@@ -97,6 +97,7 @@ class DefaultTokenProvider implements IProvider {
$dbToken->setType($type);
$dbToken->setRemember($remember);
$dbToken->setLastActivity($this->time->getTime());
+ $dbToken->setLastCheck($this->time->getTime());
$this->mapper->insert($dbToken);
diff --git a/lib/private/Installer.php b/lib/private/Installer.php
index 45bec26831e..48bd57f4c10 100644
--- a/lib/private/Installer.php
+++ b/lib/private/Installer.php
@@ -67,6 +67,10 @@ class Installer {
private $logger;
/** @var IConfig */
private $config;
+ /** @var array - for caching the result of app fetcher */
+ private $apps = null;
+ /** @var bool|null - for caching the result of the ready status */
+ private $isInstanceReadyForUpdates = null;
/**
* @param AppFetcher $appFetcher
@@ -187,7 +191,7 @@ class Installer {
* @return bool
*/
public function updateAppstoreApp($appId) {
- if(self::isUpdateAvailable($appId, $this->appFetcher)) {
+ if($this->isUpdateAvailable($appId)) {
try {
$this->downloadApp($appId);
} catch (\Exception $e) {
@@ -375,27 +379,26 @@ class Installer {
* Check if an update for the app is available
*
* @param string $appId
- * @param AppFetcher $appFetcher
* @return string|false false or the version number of the update
*/
- public static function isUpdateAvailable($appId,
- AppFetcher $appFetcher) {
- static $isInstanceReadyForUpdates = null;
-
- if ($isInstanceReadyForUpdates === null) {
+ public function isUpdateAvailable($appId) {
+ if ($this->isInstanceReadyForUpdates === null) {
$installPath = OC_App::getInstallPath();
if ($installPath === false || $installPath === null) {
- $isInstanceReadyForUpdates = false;
+ $this->isInstanceReadyForUpdates = false;
} else {
- $isInstanceReadyForUpdates = true;
+ $this->isInstanceReadyForUpdates = true;
}
}
- if ($isInstanceReadyForUpdates === false) {
+ if ($this->isInstanceReadyForUpdates === false) {
return false;
}
- $apps = $appFetcher->get();
+ if ($this->apps === null) {
+ $apps = $this->appFetcher->get();
+ }
+
foreach($apps as $app) {
if($app['id'] === $appId) {
$currentVersion = OC_App::getAppVersion($appId);
diff --git a/lib/private/Server.php b/lib/private/Server.php
index faa0ce2f2ac..0c6338f6a4c 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -1099,6 +1099,16 @@ class Server extends ServerContainer implements IServerContainer {
$c->query(\OCP\Share\IManager::class)
);
});
+
+ $this->registerService(Installer::class, function(Server $c) {
+ return new Installer(
+ $c->getAppFetcher(),
+ $c->getHTTPClientService(),
+ $c->getTempManager(),
+ $c->getLogger(),
+ $c->getConfig()
+ );
+ });
}
/**
diff --git a/lib/private/Setup.php b/lib/private/Setup.php
index 8214db2d4ef..92246e8322e 100644
--- a/lib/private/Setup.php
+++ b/lib/private/Setup.php
@@ -65,6 +65,8 @@ class Setup {
protected $logger;
/** @var ISecureRandom */
protected $random;
+ /** @var Installer */
+ protected $installer;
/**
* @param SystemConfig $config
@@ -73,13 +75,15 @@ class Setup {
* @param Defaults $defaults
* @param ILogger $logger
* @param ISecureRandom $random
+ * @param Installer $installer
*/
public function __construct(SystemConfig $config,
IniGetWrapper $iniWrapper,
IL10N $l10n,
Defaults $defaults,
ILogger $logger,
- ISecureRandom $random
+ ISecureRandom $random,
+ Installer $installer
) {
$this->config = $config;
$this->iniWrapper = $iniWrapper;
@@ -87,6 +91,7 @@ class Setup {
$this->defaults = $defaults;
$this->logger = $logger;
$this->random = $random;
+ $this->installer = $installer;
}
static protected $dbSetupClasses = [
@@ -371,18 +376,11 @@ class Setup {
// Install shipped apps and specified app bundles
Installer::installShippedApps();
- $installer = new Installer(
- \OC::$server->getAppFetcher(),
- \OC::$server->getHTTPClientService(),
- \OC::$server->getTempManager(),
- \OC::$server->getLogger(),
- \OC::$server->getConfig()
- );
$bundleFetcher = new BundleFetcher(\OC::$server->getL10N('lib'));
$defaultInstallationBundles = $bundleFetcher->getDefaultInstallationBundle();
foreach($defaultInstallationBundles as $bundle) {
try {
- $installer->installAppBundle($bundle);
+ $this->installer->installAppBundle($bundle);
} catch (Exception $e) {}
}
@@ -444,9 +442,15 @@ class Setup {
$webRoot = !empty(\OC::$WEBROOT) ? \OC::$WEBROOT : '/';
}
- $setupHelper = new \OC\Setup($config, \OC::$server->getIniWrapper(),
- \OC::$server->getL10N('lib'), \OC::$server->query(Defaults::class), \OC::$server->getLogger(),
- \OC::$server->getSecureRandom());
+ $setupHelper = new \OC\Setup(
+ $config,
+ \OC::$server->getIniWrapper(),
+ \OC::$server->getL10N('lib'),
+ \OC::$server->query(Defaults::class),
+ \OC::$server->getLogger(),
+ \OC::$server->getSecureRandom(),
+ \OC::$server->query(Installer::class)
+ );
$htaccessContent = file_get_contents($setupHelper->pathToHtaccess());
$content = "#### DO NOT CHANGE ANYTHING ABOVE THIS LINE ####\n";
diff --git a/lib/private/Share20/DefaultShareProvider.php b/lib/private/Share20/DefaultShareProvider.php
index a440c36406b..844b36b2994 100644
--- a/lib/private/Share20/DefaultShareProvider.php
+++ b/lib/private/Share20/DefaultShareProvider.php
@@ -183,6 +183,9 @@ class DefaultShareProvider implements IShareProvider {
throw new ShareNotFound();
}
+ $mailSendValue = $share->getMailSend();
+ $data['mail_send'] = ($mailSendValue === null) ? true : $mailSendValue;
+
$share = $this->createShare($data);
return $share;
}
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php
index 83fe4ec0d19..b22bfbc3878 100644
--- a/lib/private/Share20/Manager.php
+++ b/lib/private/Share20/Manager.php
@@ -669,26 +669,31 @@ class Manager implements IManager {
$this->eventDispatcher->dispatch('OCP\Share::postShare', $event);
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
- $user = $this->userManager->get($share->getSharedWith());
- if ($user !== null) {
- $emailAddress = $user->getEMailAddress();
- if ($emailAddress !== null && $emailAddress !== '') {
- $userLang = $this->config->getUserValue($share->getSharedWith(), 'core', 'lang', null);
- $l = $this->l10nFactory->get('lib', $userLang);
- $this->sendMailNotification(
- $l,
- $share->getNode()->getName(),
- $this->urlGenerator->linkToRouteAbsolute('files.viewcontroller.showFile', [ 'fileid' => $share->getNode()->getId() ]),
- $share->getSharedBy(),
- $emailAddress,
- $share->getExpirationDate()
- );
- $this->logger->debug('Send share notification to ' . $emailAddress . ' for share with ID ' . $share->getId(), ['app' => 'share']);
+ $mailSend = $share->getMailSend();
+ if($mailSend === true) {
+ $user = $this->userManager->get($share->getSharedWith());
+ if ($user !== null) {
+ $emailAddress = $user->getEMailAddress();
+ if ($emailAddress !== null && $emailAddress !== '') {
+ $userLang = $this->config->getUserValue($share->getSharedWith(), 'core', 'lang', null);
+ $l = $this->l10nFactory->get('lib', $userLang);
+ $this->sendMailNotification(
+ $l,
+ $share->getNode()->getName(),
+ $this->urlGenerator->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $share->getNode()->getId()]),
+ $share->getSharedBy(),
+ $emailAddress,
+ $share->getExpirationDate()
+ );
+ $this->logger->debug('Send share notification to ' . $emailAddress . ' for share with ID ' . $share->getId(), ['app' => 'share']);
+ } else {
+ $this->logger->debug('Share notification not send to ' . $share->getSharedWith() . ' because email address is not set.', ['app' => 'share']);
+ }
} else {
- $this->logger->debug('Share notification not send to ' . $share->getSharedWith() . ' because email address is not set.', ['app' => 'share']);
+ $this->logger->debug('Share notification not send to ' . $share->getSharedWith() . ' because user could not be found.', ['app' => 'share']);
}
} else {
- $this->logger->debug('Share notification not send to ' . $share->getSharedWith() . ' because user could not be found.', ['app' => 'share']);
+ $this->logger->debug('Share notification not send because mailsend is false.', ['app' => 'share']);
}
}
diff --git a/lib/private/Updater.php b/lib/private/Updater.php
index 4f5bb45ae15..996163daacc 100644
--- a/lib/private/Updater.php
+++ b/lib/private/Updater.php
@@ -63,6 +63,9 @@ class Updater extends BasicEmitter {
/** @var Checker */
private $checker;
+ /** @var Installer */
+ private $installer;
+
/** @var bool */
private $skip3rdPartyAppsDisable;
@@ -78,13 +81,16 @@ class Updater extends BasicEmitter {
* @param IConfig $config
* @param Checker $checker
* @param ILogger $log
+ * @param Installer $installer
*/
public function __construct(IConfig $config,
Checker $checker,
- ILogger $log = null) {
+ ILogger $log = null,
+ Installer $installer) {
$this->log = $log;
$this->config = $config;
$this->checker = $checker;
+ $this->installer = $installer;
// If at least PHP 7.0.0 is used we don't need to disable apps as we catch
// fatal errors and exceptions and disable the app just instead.
@@ -461,17 +467,10 @@ class Updater extends BasicEmitter {
private function upgradeAppStoreApps(array $disabledApps) {
foreach($disabledApps as $app) {
try {
- $installer = new Installer(
- \OC::$server->getAppFetcher(),
- \OC::$server->getHTTPClientService(),
- \OC::$server->getTempManager(),
- $this->log,
- \OC::$server->getConfig()
- );
$this->emit('\OC\Updater', 'checkAppStoreAppBefore', [$app]);
- if (Installer::isUpdateAvailable($app, \OC::$server->getAppFetcher())) {
+ if ($this->installer->isUpdateAvailable($app)) {
$this->emit('\OC\Updater', 'upgradeAppStoreApp', [$app]);
- $installer->updateAppstoreApp($app);
+ $this->installer->updateAppstoreApp($app);
}
$this->emit('\OC\Updater', 'checkAppStoreApp', [$app]);
} catch (\Exception $ex) {
diff --git a/lib/private/legacy/app.php b/lib/private/legacy/app.php
index d2b0f96d593..1b9fc28873e 100644
--- a/lib/private/legacy/app.php
+++ b/lib/private/legacy/app.php
@@ -375,13 +375,7 @@ class OC_App {
self::$enabledAppsCache = []; // flush
// Check if app is already downloaded
- $installer = new Installer(
- \OC::$server->getAppFetcher(),
- \OC::$server->getHTTPClientService(),
- \OC::$server->getTempManager(),
- \OC::$server->getLogger(),
- \OC::$server->getConfig()
- );
+ $installer = \OC::$server->query(Installer::class);
$isDownloaded = $installer->isDownloaded($appId);
if(!$isDownloaded) {
@@ -415,13 +409,7 @@ class OC_App {
return false;
}
- $installer = new Installer(
- \OC::$server->getAppFetcher(),
- \OC::$server->getHTTPClientService(),
- \OC::$server->getTempManager(),
- \OC::$server->getLogger(),
- \OC::$server->getConfig()
- );
+ $installer = \OC::$server->query(Installer::class);
return $installer->removeApp($app);
}
diff --git a/lib/private/legacy/util.php b/lib/private/legacy/util.php
index 1e9090960c1..3ce11746672 100644
--- a/lib/private/legacy/util.php
+++ b/lib/private/legacy/util.php
@@ -708,8 +708,15 @@ class OC_Util {
}
$webServerRestart = false;
- $setup = new \OC\Setup($config, \OC::$server->getIniWrapper(), \OC::$server->getL10N('lib'),
- \OC::$server->query(\OCP\Defaults::class), \OC::$server->getLogger(), \OC::$server->getSecureRandom());
+ $setup = new \OC\Setup(
+ $config,
+ \OC::$server->getIniWrapper(),
+ \OC::$server->getL10N('lib'),
+ \OC::$server->query(\OCP\Defaults::class),
+ \OC::$server->getLogger(),
+ \OC::$server->getSecureRandom(),
+ \OC::$server->query(\OC\Installer::class)
+ );
$urlGenerator = \OC::$server->getURLGenerator();