Compare commits
2 Commits
master
...
techdebt/n
Author | SHA1 | Date |
---|---|---|
Morris Jobke | 22ed863dd7 | |
Morris Jobke | e2042fb562 |
|
@ -34,6 +34,7 @@ use OC\Files\Cache\Wrapper\CacheJail;
|
||||||
use OC\Files\Storage\Wrapper\Jail;
|
use OC\Files\Storage\Wrapper\Jail;
|
||||||
use OCP\Files\Cache\ICacheEntry;
|
use OCP\Files\Cache\ICacheEntry;
|
||||||
use OCP\Files\StorageNotAvailableException;
|
use OCP\Files\StorageNotAvailableException;
|
||||||
|
use OCP\IUserManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Metadata cache for shared files
|
* Metadata cache for shared files
|
||||||
|
@ -41,15 +42,12 @@ use OCP\Files\StorageNotAvailableException;
|
||||||
* don't use this class directly if you need to get metadata, use \OC\Files\Filesystem::getFileInfo instead
|
* don't use this class directly if you need to get metadata, use \OC\Files\Filesystem::getFileInfo instead
|
||||||
*/
|
*/
|
||||||
class Cache extends CacheJail {
|
class Cache extends CacheJail {
|
||||||
/**
|
/** @var \OCA\Files_Sharing\SharedStorage */
|
||||||
* @var \OCA\Files_Sharing\SharedStorage
|
|
||||||
*/
|
|
||||||
private $storage;
|
private $storage;
|
||||||
|
/** @var ICacheEntry */
|
||||||
/**
|
|
||||||
* @var ICacheEntry
|
|
||||||
*/
|
|
||||||
private $sourceRootInfo;
|
private $sourceRootInfo;
|
||||||
|
/** @var IUserManager */
|
||||||
|
private $userManager;
|
||||||
|
|
||||||
private $rootUnchanged = true;
|
private $rootUnchanged = true;
|
||||||
|
|
||||||
|
@ -57,13 +55,10 @@ class Cache extends CacheJail {
|
||||||
|
|
||||||
private $numericId;
|
private $numericId;
|
||||||
|
|
||||||
/**
|
public function __construct(SharedStorage $storage, ICacheEntry $sourceRootInfo, IUserManager $userManager) {
|
||||||
* @param \OCA\Files_Sharing\SharedStorage $storage
|
|
||||||
* @param ICacheEntry $sourceRootInfo
|
|
||||||
*/
|
|
||||||
public function __construct($storage, ICacheEntry $sourceRootInfo) {
|
|
||||||
$this->storage = $storage;
|
$this->storage = $storage;
|
||||||
$this->sourceRootInfo = $sourceRootInfo;
|
$this->sourceRootInfo = $sourceRootInfo;
|
||||||
|
$this->userManager = $userManager;
|
||||||
$this->numericId = $sourceRootInfo->getStorageId();
|
$this->numericId = $sourceRootInfo->getStorageId();
|
||||||
|
|
||||||
parent::__construct(
|
parent::__construct(
|
||||||
|
@ -170,7 +165,13 @@ class Cache extends CacheJail {
|
||||||
|
|
||||||
private function getOwnerDisplayName() {
|
private function getOwnerDisplayName() {
|
||||||
if (!$this->ownerDisplayName) {
|
if (!$this->ownerDisplayName) {
|
||||||
$this->ownerDisplayName = \OC_User::getDisplayName($this->storage->getOwner(''));
|
$uid = $this->storage->getOwner('');
|
||||||
|
$user = $this->userManager->get($uid);
|
||||||
|
if ($user) {
|
||||||
|
$this->ownerDisplayName = $user->getDisplayName();
|
||||||
|
} else {
|
||||||
|
$this->ownerDisplayName = $uid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $this->ownerDisplayName;
|
return $this->ownerDisplayName;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@ use OCP\Files\Cache\ICacheEntry;
|
||||||
use OCP\Files\NotFoundException;
|
use OCP\Files\NotFoundException;
|
||||||
use OCP\Files\Storage\IDisableEncryptionStorage;
|
use OCP\Files\Storage\IDisableEncryptionStorage;
|
||||||
use OCP\Files\Storage\IStorage;
|
use OCP\Files\Storage\IStorage;
|
||||||
|
use OCP\IUserManager;
|
||||||
use OCP\Lock\ILockingProvider;
|
use OCP\Lock\ILockingProvider;
|
||||||
use OCP\Share\IShare;
|
use OCP\Share\IShare;
|
||||||
|
|
||||||
|
@ -386,7 +387,11 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedSto
|
||||||
return new FailedCache();
|
return new FailedCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->cache = new \OCA\Files_Sharing\Cache($storage, $sourceRoot, $this->superShare);
|
$this->cache = new \OCA\Files_Sharing\Cache(
|
||||||
|
$storage,
|
||||||
|
$sourceRoot,
|
||||||
|
\OC::$server->get(IUserManager::class)
|
||||||
|
);
|
||||||
return $this->cache;
|
return $this->cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,7 @@ use OCP\Defaults;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
use OCP\IInitialStateService;
|
use OCP\IInitialStateService;
|
||||||
use OCP\INavigationManager;
|
use OCP\INavigationManager;
|
||||||
|
use OCP\IUserSession;
|
||||||
use OCP\Support\Subscription\IRegistry;
|
use OCP\Support\Subscription\IRegistry;
|
||||||
use OCP\Util;
|
use OCP\Util;
|
||||||
|
|
||||||
|
@ -122,7 +123,12 @@ class TemplateLayout extends \OC_Template {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$userDisplayName = \OC_User::getDisplayName();
|
|
||||||
|
$userDisplayName = false;
|
||||||
|
$user = \OC::$server->get(IUserSession::class)->getUser();
|
||||||
|
if ($user) {
|
||||||
|
$userDisplayName = $user->getDisplayName();
|
||||||
|
}
|
||||||
$this->assign('user_displayname', $userDisplayName);
|
$this->assign('user_displayname', $userDisplayName);
|
||||||
$this->assign('user_uid', \OC_User::getUser());
|
$this->assign('user_uid', \OC_User::getUser());
|
||||||
|
|
||||||
|
@ -153,7 +159,11 @@ class TemplateLayout extends \OC_Template {
|
||||||
\OC_Util::addStyle('guest');
|
\OC_Util::addStyle('guest');
|
||||||
$this->assign('bodyid', 'body-login');
|
$this->assign('bodyid', 'body-login');
|
||||||
|
|
||||||
$userDisplayName = \OC_User::getDisplayName();
|
$userDisplayName = false;
|
||||||
|
$user = \OC::$server->get(IUserSession::class)->getUser();
|
||||||
|
if ($user) {
|
||||||
|
$userDisplayName = $user->getDisplayName();
|
||||||
|
}
|
||||||
$this->assign('user_displayname', $userDisplayName);
|
$this->assign('user_displayname', $userDisplayName);
|
||||||
$this->assign('user_uid', \OC_User::getUser());
|
$this->assign('user_uid', \OC_User::getUser());
|
||||||
} elseif ($renderAs === TemplateResponse::RENDER_AS_PUBLIC) {
|
} elseif ($renderAs === TemplateResponse::RENDER_AS_PUBLIC) {
|
||||||
|
|
|
@ -317,32 +317,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
|
* Set password
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue