summaryrefslogtreecommitdiffstats
path: root/lib/private/legacy
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/legacy')
-rw-r--r--lib/private/legacy/OC_App.php13
-rw-r--r--lib/private/legacy/OC_DB.php6
-rw-r--r--lib/private/legacy/OC_DB_StatementWrapper.php2
-rw-r--r--lib/private/legacy/OC_Defaults.php10
-rw-r--r--lib/private/legacy/OC_EventSource.php7
-rw-r--r--lib/private/legacy/OC_FileChunking.php2
-rw-r--r--lib/private/legacy/OC_Files.php6
-rw-r--r--lib/private/legacy/OC_Helper.php22
-rw-r--r--lib/private/legacy/OC_Hook.php8
-rw-r--r--lib/private/legacy/OC_Image.php1
-rw-r--r--lib/private/legacy/OC_JSON.php5
-rw-r--r--lib/private/legacy/OC_Response.php1
-rw-r--r--lib/private/legacy/OC_Template.php3
-rw-r--r--lib/private/legacy/OC_User.php39
-rw-r--r--lib/private/legacy/OC_Util.php62
-rw-r--r--lib/private/legacy/template/functions.php5
16 files changed, 74 insertions, 118 deletions
diff --git a/lib/private/legacy/OC_App.php b/lib/private/legacy/OC_App.php
index 65365c85e36..bca0a3dd08e 100644
--- a/lib/private/legacy/OC_App.php
+++ b/lib/private/legacy/OC_App.php
@@ -135,7 +135,14 @@ class OC_App {
ob_start();
foreach ($apps as $app) {
if (!isset(self::$loadedApps[$app]) && ($types === [] || self::isType($app, $types))) {
- self::loadApp($app);
+ try {
+ self::loadApp($app);
+ } catch (\Throwable $e) {
+ \OC::$server->get(LoggerInterface::class)->emergency('Error during app loading: ' . $e->getMessage(), [
+ 'exception' => $e,
+ 'app' => $app,
+ ]);
+ }
}
}
ob_end_clean();
@@ -453,10 +460,6 @@ class OC_App {
* @return string|false
*/
public static function getInstallPath() {
- if (\OC::$server->getSystemConfig()->getValue('appstoreenabled', true) == false) {
- return false;
- }
-
foreach (OC::$APPSROOTS as $dir) {
if (isset($dir['writable']) && $dir['writable'] === true) {
return $dir['path'];
diff --git a/lib/private/legacy/OC_DB.php b/lib/private/legacy/OC_DB.php
index a3919fd1f17..1fbc233f535 100644
--- a/lib/private/legacy/OC_DB.php
+++ b/lib/private/legacy/OC_DB.php
@@ -3,7 +3,6 @@
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Andreas Fischer <bantu@owncloud.com>
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
* @author Bart Visscher <bartv@thisnet.nl>
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Joas Schilling <coding@schilljs.com>
@@ -29,11 +28,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
-
-/**
- * This class manages the access to the database. It basically is a wrapper for
- * Doctrine with some adaptions.
- */
class OC_DB {
/**
diff --git a/lib/private/legacy/OC_DB_StatementWrapper.php b/lib/private/legacy/OC_DB_StatementWrapper.php
index cc2320015a3..d8e8f0ae37f 100644
--- a/lib/private/legacy/OC_DB_StatementWrapper.php
+++ b/lib/private/legacy/OC_DB_StatementWrapper.php
@@ -2,7 +2,6 @@
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
* @author Bart Visscher <bartv@thisnet.nl>
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Joas Schilling <coding@schilljs.com>
@@ -27,7 +26,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
-
use OCP\DB\IPreparedStatement;
/**
diff --git a/lib/private/legacy/OC_Defaults.php b/lib/private/legacy/OC_Defaults.php
index e4ca3a2407f..707df7279bb 100644
--- a/lib/private/legacy/OC_Defaults.php
+++ b/lib/private/legacy/OC_Defaults.php
@@ -36,6 +36,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
+
class OC_Defaults {
private $theme;
@@ -53,6 +54,7 @@ class OC_Defaults {
private $defaultSlogan;
private $defaultColorPrimary;
private $defaultTextColorPrimary;
+ private $defaultProductName;
public function __construct() {
$config = \OC::$server->getConfig();
@@ -70,6 +72,7 @@ class OC_Defaults {
$this->defaultDocVersion = \OC_Util::getVersion()[0]; // used to generate doc links
$this->defaultColorPrimary = '#0082c9';
$this->defaultTextColorPrimary = '#ffffff';
+ $this->defaultProductName = 'Nextcloud';
$themePath = OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php';
if (file_exists($themePath)) {
@@ -344,4 +347,11 @@ class OC_Defaults {
}
return $this->defaultTextColorPrimary;
}
+
+ public function getProductName() {
+ if ($this->themeExist('getProductName')) {
+ return $this->theme->getProductName();
+ }
+ return $this->defaultProductName;
+ }
}
diff --git a/lib/private/legacy/OC_EventSource.php b/lib/private/legacy/OC_EventSource.php
index 2d29f3109cf..c733316050f 100644
--- a/lib/private/legacy/OC_EventSource.php
+++ b/lib/private/legacy/OC_EventSource.php
@@ -26,13 +26,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
-
-/**
- * wrapper for server side events (https://en.wikipedia.org/wiki/Server-sent_events)
- * includes a fallback for older browsers and IE
- *
- * use server side events with caution, to many open requests can hang the server
- */
class OC_EventSource implements \OCP\IEventSource {
/**
* @var bool
diff --git a/lib/private/legacy/OC_FileChunking.php b/lib/private/legacy/OC_FileChunking.php
index 1c24f0d8067..e3782cabb4a 100644
--- a/lib/private/legacy/OC_FileChunking.php
+++ b/lib/private/legacy/OC_FileChunking.php
@@ -28,8 +28,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
-
-
class OC_FileChunking {
protected $info;
protected $cache;
diff --git a/lib/private/legacy/OC_Files.php b/lib/private/legacy/OC_Files.php
index addee2358dd..d1af5b24bdd 100644
--- a/lib/private/legacy/OC_Files.php
+++ b/lib/private/legacy/OC_Files.php
@@ -21,6 +21,7 @@
* @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Thibaut GRIDEL <tgridel@free.fr>
* @author Thomas Müller <thomas.mueller@tmit.eu>
+ * @author Valdnet <47037905+Valdnet@users.noreply.github.com>
* @author Victor Dubiniuk <dubiniuk@owncloud.com>
* @author Vincent Petry <vincent@nextcloud.com>
*
@@ -39,7 +40,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
-
use bantu\IniGetWrapper\IniGetWrapper;
use OC\Files\View;
use OC\Streamer;
@@ -216,13 +216,13 @@ class OC_Files {
self::unlockAllTheFiles($dir, $files, $getType, $view, $filename);
OC::$server->getLogger()->logException($ex);
$l = \OC::$server->getL10N('lib');
- \OC_Template::printErrorPage($l->t('Can\'t read file'), $ex->getMessage(), 200);
+ \OC_Template::printErrorPage($l->t('Cannot read file'), $ex->getMessage(), 200);
} catch (\Exception $ex) {
self::unlockAllTheFiles($dir, $files, $getType, $view, $filename);
OC::$server->getLogger()->logException($ex);
$l = \OC::$server->getL10N('lib');
$hint = method_exists($ex, 'getHint') ? $ex->getHint() : '';
- \OC_Template::printErrorPage($l->t('Can\'t read file'), $hint, 200);
+ \OC_Template::printErrorPage($l->t('Cannot read file'), $hint, 200);
}
}
diff --git a/lib/private/legacy/OC_Helper.php b/lib/private/legacy/OC_Helper.php
index 5249416654e..52c49f1d795 100644
--- a/lib/private/legacy/OC_Helper.php
+++ b/lib/private/legacy/OC_Helper.php
@@ -43,8 +43,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
-
use bantu\IniGetWrapper\IniGetWrapper;
+use OCP\Files\Mount\IMountPoint;
+use OCP\IUser;
use Symfony\Component\Process\ExecutableFinder;
/**
@@ -518,7 +519,7 @@ class OC_Helper {
$quota = OC_Util::getUserQuota($user);
if ($quota !== \OCP\Files\FileInfo::SPACE_UNLIMITED) {
// always get free space / total space from root + mount points
- return self::getGlobalStorageInfo($quota);
+ return self::getGlobalStorageInfo($quota, $user, $mount);
}
}
@@ -570,11 +571,8 @@ class OC_Helper {
/**
* Get storage info including all mount points and quota
- *
- * @param int $quota
- * @return array
*/
- private static function getGlobalStorageInfo($quota) {
+ private static function getGlobalStorageInfo(int $quota, IUser $user, IMountPoint $mount): array {
$rootInfo = \OC\Files\Filesystem::getFileInfo('', 'ext');
$used = $rootInfo['size'];
if ($used < 0) {
@@ -594,12 +592,22 @@ class OC_Helper {
$relative = 0;
}
+ if (substr_count($mount->getMountPoint(), '/') < 3) {
+ $mountPoint = '';
+ } else {
+ [,,,$mountPoint] = explode('/', $mount->getMountPoint(), 4);
+ }
+
return [
'free' => $free,
'used' => $used,
'total' => $total,
'relative' => $relative,
- 'quota' => $quota
+ 'quota' => $quota,
+ 'owner' => $user->getUID(),
+ 'ownerDisplayName' => $user->getDisplayName(),
+ 'mountType' => $mount->getMountType(),
+ 'mountPoint' => trim($mountPoint, '/'),
];
}
diff --git a/lib/private/legacy/OC_Hook.php b/lib/private/legacy/OC_Hook.php
index cf0e9881e4c..b223b0fa6d6 100644
--- a/lib/private/legacy/OC_Hook.php
+++ b/lib/private/legacy/OC_Hook.php
@@ -28,10 +28,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
-
-/**
- * @deprecated 18.0.0 use events and the \OCP\EventDispatcher\IEventDispatcher service
- */
class OC_Hook {
public static $thrownExceptions = [];
@@ -85,7 +81,7 @@ class OC_Hook {
* @param string $signalName name of signal
* @param mixed $params default: array() array with additional data
* @return bool true if slots exists or false if not
- * @throws \OC\HintException
+ * @throws \OCP\HintException
* @throws \OC\ServerNotAvailableException Emits a signal. To get data from the slot use references!
*
* TODO: write example
@@ -111,7 +107,7 @@ class OC_Hook {
} catch (Exception $e) {
self::$thrownExceptions[] = $e;
\OC::$server->getLogger()->logException($e);
- if ($e instanceof \OC\HintException) {
+ if ($e instanceof \OCP\HintException) {
throw $e;
}
if ($e instanceof \OC\ServerNotAvailableException) {
diff --git a/lib/private/legacy/OC_Image.php b/lib/private/legacy/OC_Image.php
index f1b9101045a..59d51773528 100644
--- a/lib/private/legacy/OC_Image.php
+++ b/lib/private/legacy/OC_Image.php
@@ -39,7 +39,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
-
use OCP\IImage;
/**
diff --git a/lib/private/legacy/OC_JSON.php b/lib/private/legacy/OC_JSON.php
index 3094879af38..7734e29c545 100644
--- a/lib/private/legacy/OC_JSON.php
+++ b/lib/private/legacy/OC_JSON.php
@@ -27,11 +27,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
-
-/**
- * Class OC_JSON
- * @deprecated Use a AppFramework JSONResponse instead
- */
class OC_JSON {
/**
diff --git a/lib/private/legacy/OC_Response.php b/lib/private/legacy/OC_Response.php
index f4c2356aecd..6cfd53d2651 100644
--- a/lib/private/legacy/OC_Response.php
+++ b/lib/private/legacy/OC_Response.php
@@ -27,7 +27,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
-
class OC_Response {
/**
* Sets the content disposition header (with possible workarounds)
diff --git a/lib/private/legacy/OC_Template.php b/lib/private/legacy/OC_Template.php
index 468f6acad44..b4bc290429a 100644
--- a/lib/private/legacy/OC_Template.php
+++ b/lib/private/legacy/OC_Template.php
@@ -10,7 +10,7 @@
* @author Jakob Sack <mail@jakobsack.de>
* @author Jan-Christoph Borchardt <hey@jancborchardt.net>
* @author Joas Schilling <coding@schilljs.com>
- * @author John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
+ * @author John Molakvoæ <skjnldsv@protonmail.com>
* @author Jörn Friedrich Dreyer <jfd@butonic.de>
* @author Julius Härtl <jus@bitgrid.net>
* @author Lukas Reschke <lukas@statuscode.ch>
@@ -37,7 +37,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
-
use OC\TemplateLayout;
use OCP\AppFramework\Http\TemplateResponse;
diff --git a/lib/private/legacy/OC_User.php b/lib/private/legacy/OC_User.php
index c8d9b51eaba..f955c5c6938 100644
--- a/lib/private/legacy/OC_User.php
+++ b/lib/private/legacy/OC_User.php
@@ -35,8 +35,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
-
+use OCP\EventDispatcher\IEventDispatcher;
use OCP\ILogger;
+use OCP\IUserManager;
+use OCP\User\Events\UserLoggedInEvent;
/**
* This class provides wrapper methods for user management. Multiple backends are
@@ -186,6 +188,15 @@ class OC_User {
'isTokenLogin' => false,
]
);
+ /** @var IEventDispatcher $dispatcher */
+ $dispatcher = \OC::$server->get(IEventDispatcher::class);
+ $dispatcher->dispatchTyped(new UserLoggedInEvent(
+ \OC::$server->get(IUserManager::class)->get($uid),
+ $uid,
+ '',
+ false)
+ );
+
//trigger creation of user home and /files folder
\OC::$server->getUserFolder($uid);
}
@@ -318,32 +329,6 @@ class OC_User {
}
/**
- * get the display name of the user currently logged in.
- *
- * @param string $uid
- * @return string|bool uid or false
- * @deprecated 8.1.0 fetch \OCP\IUser (has getDisplayName()) by using method
- * get() of \OCP\IUserManager - \OC::$server->getUserManager()
- */
- public static function getDisplayName($uid = null) {
- if ($uid) {
- $user = \OC::$server->getUserManager()->get($uid);
- if ($user) {
- return $user->getDisplayName();
- } else {
- return $uid;
- }
- } else {
- $user = \OC::$server->getUserSession()->getUser();
- if ($user) {
- return $user->getDisplayName();
- } else {
- return false;
- }
- }
- }
-
- /**
* Set password
*
* @param string $uid The username
diff --git a/lib/private/legacy/OC_Util.php b/lib/private/legacy/OC_Util.php
index f1e88166e97..333b621e359 100644
--- a/lib/private/legacy/OC_Util.php
+++ b/lib/private/legacy/OC_Util.php
@@ -23,7 +23,7 @@
* @author Individual IT Services <info@individual-it.net>
* @author Jakob Sack <mail@jakobsack.de>
* @author Joas Schilling <coding@schilljs.com>
- * @author John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
+ * @author John Molakvoæ <skjnldsv@protonmail.com>
* @author Jörn Friedrich Dreyer <jfd@butonic.de>
* @author Julius Härtl <jus@bitgrid.net>
* @author Kawohl <john@owncloud.com>
@@ -43,6 +43,7 @@
* @author Stefan Weil <sw@weilnetz.de>
* @author Thomas Müller <thomas.mueller@tmit.eu>
* @author Thomas Tanghus <thomas@tanghus.net>
+ * @author Valdnet <47037905+Valdnet@users.noreply.github.com>
* @author Victor Dubiniuk <dubiniuk@owncloud.com>
* @author Vincent Petry <vincent@nextcloud.com>
* @author Volkan Gezer <volkangezer@gmail.com>
@@ -72,6 +73,7 @@ use OCP\IGroupManager;
use OCP\ILogger;
use OCP\IUser;
use OCP\IUserSession;
+use OCP\Share\IManager;
use Psr\Log\LoggerInterface;
class OC_Util {
@@ -336,8 +338,9 @@ class OC_Util {
* @suppress PhanDeprecatedFunction
*/
public static function isPublicLinkPasswordRequired() {
- $enforcePassword = \OC::$server->getConfig()->getAppValue('core', 'shareapi_enforce_links_password', 'no');
- return $enforcePassword === 'yes';
+ /** @var IManager $shareManager */
+ $shareManager = \OC::$server->get(IManager::class);
+ return $shareManager->shareApiLinkEnforcePassword();
}
/**
@@ -348,25 +351,10 @@ class OC_Util {
* @return bool
*/
public static function isSharingDisabledForUser(IConfig $config, IGroupManager $groupManager, $user) {
- if ($config->getAppValue('core', 'shareapi_exclude_groups', 'no') === 'yes') {
- $groupsList = $config->getAppValue('core', 'shareapi_exclude_groups_list', '');
- $excludedGroups = json_decode($groupsList);
- if (is_null($excludedGroups)) {
- $excludedGroups = explode(',', $groupsList);
- $newValue = json_encode($excludedGroups);
- $config->setAppValue('core', 'shareapi_exclude_groups_list', $newValue);
- }
- $usersGroups = $groupManager->getUserGroupIds($user);
- if (!empty($usersGroups)) {
- $remainingGroups = array_diff($usersGroups, $excludedGroups);
- // if the user is only in groups which are disabled for sharing then
- // sharing is also disabled for the user
- if (empty($remainingGroups)) {
- return true;
- }
- }
- }
- return false;
+ /** @var IManager $shareManager */
+ $shareManager = \OC::$server->get(IManager::class);
+ $userId = $user ? $user->getUID() : null;
+ return $shareManager->sharingDisabledForUser($userId);
}
/**
@@ -376,14 +364,9 @@ class OC_Util {
* @suppress PhanDeprecatedFunction
*/
public static function isDefaultExpireDateEnforced() {
- $isDefaultExpireDateEnabled = \OC::$server->getConfig()->getAppValue('core', 'shareapi_default_expire_date', 'no');
- $enforceDefaultExpireDate = false;
- if ($isDefaultExpireDateEnabled === 'yes') {
- $value = \OC::$server->getConfig()->getAppValue('core', 'shareapi_enforce_expire_date', 'no');
- $enforceDefaultExpireDate = $value === 'yes';
- }
-
- return $enforceDefaultExpireDate;
+ /** @var IManager $shareManager */
+ $shareManager = \OC::$server->get(IManager::class);
+ return $shareManager->shareApiLinkDefaultExpireDateEnforced();
}
/**
@@ -747,10 +730,10 @@ class OC_Util {
$config,
\OC::$server->get(IniGetWrapper::class),
\OC::$server->getL10N('lib'),
- \OC::$server->query(\OCP\Defaults::class),
- \OC::$server->getLogger(),
+ \OC::$server->get(\OCP\Defaults::class),
+ \OC::$server->get(LoggerInterface::class),
\OC::$server->getSecureRandom(),
- \OC::$server->query(\OC\Installer::class)
+ \OC::$server->get(\OC\Installer::class)
);
$urlGenerator = \OC::$server->getURLGenerator();
@@ -786,7 +769,7 @@ class OC_Util {
$errors[] = [
'error' => $l->t('Cannot write into "apps" directory'),
'hint' => $l->t('This can usually be fixed by giving the webserver write access to the apps directory'
- . ' or disabling the appstore in the config file.')
+ . ' or disabling the App Store in the config file.')
];
}
}
@@ -1232,7 +1215,7 @@ class OC_Util {
$fp = @fopen($testFile, 'w');
if (!$fp) {
- throw new OC\HintException('Can\'t create test file to check for working .htaccess file.',
+ throw new \OCP\HintException('Can\'t create test file to check for working .htaccess file.',
'Make sure it is possible for the webserver to write to ' . $testFile);
}
fwrite($fp, $testContent);
@@ -1243,10 +1226,11 @@ class OC_Util {
/**
* Check if the .htaccess file is working
+ *
* @param \OCP\IConfig $config
* @return bool
* @throws Exception
- * @throws \OC\HintException If the test file can't get written.
+ * @throws \OCP\HintException If the test file can't get written.
*/
public function isHtaccessWorking(\OCP\IConfig $config) {
if (\OC::$CLI || !$config->getSystemValue('check_for_working_htaccess', true)) {
@@ -1440,7 +1424,7 @@ class OC_Util {
*
* @param \OC\SystemConfig $config
* @return bool whether the core or any app needs an upgrade
- * @throws \OC\HintException When the upgrade from the given version is not allowed
+ * @throws \OCP\HintException When the upgrade from the given version is not allowed
*/
public static function needUpgrade(\OC\SystemConfig $config) {
if ($config->getValue('installed', false)) {
@@ -1460,11 +1444,11 @@ class OC_Util {
return true;
} else {
// downgrade attempt, throw exception
- throw new \OC\HintException('Downgrading is not supported and is likely to cause unpredictable issues (from ' . $installedVersion . ' to ' . $currentVersion . ')');
+ throw new \OCP\HintException('Downgrading is not supported and is likely to cause unpredictable issues (from ' . $installedVersion . ' to ' . $currentVersion . ')');
}
} elseif ($versionDiff < 0) {
// downgrade attempt, throw exception
- throw new \OC\HintException('Downgrading is not supported and is likely to cause unpredictable issues (from ' . $installedVersion . ' to ' . $currentVersion . ')');
+ throw new \OCP\HintException('Downgrading is not supported and is likely to cause unpredictable issues (from ' . $installedVersion . ' to ' . $currentVersion . ')');
}
// also check for upgrades for apps (independently from the user)
diff --git a/lib/private/legacy/template/functions.php b/lib/private/legacy/template/functions.php
index 4613e36f9f2..6b18c9476b4 100644
--- a/lib/private/legacy/template/functions.php
+++ b/lib/private/legacy/template/functions.php
@@ -31,11 +31,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
-
-/**
- * Prints a sanitized string
- * @param string $string the string which will be escaped and printed
- */
function p($string) {
print(\OCP\Util::sanitizeHTML($string));
}