namespace OCA\Files_External\Config;
use OCP\IRequest;
+use OCP\IUser;
+use OCP\IUserManager;
use OCP\IUserSession;
use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IManager as ShareManager;
/** @var IRequest */
private $request;
- private $user;
+ /** @var string */
+ private $userId;
- public function __construct(IUserSession $session, ShareManager $manager, IRequest $request) {
+ /** @var IUserManager */
+ private $userManager;
+
+ public function __construct(IUserSession $session, ShareManager $manager, IRequest $request, IUserManager $userManager) {
$this->session = $session;
$this->shareManager = $manager;
$this->request = $request;
+ $this->userManager = $userManager;
}
public function getSession(): IUserSession {
return $this->session;
}
- public function setUser($user): void {
- $this->user = $user;
+ public function setUserId(string $userId): void {
+ $this->userId = $userId;
}
protected function getUserId(): ?string {
- if ($this->user !== null) {
- return $this->user;
+ if ($this->userId !== null) {
+ return $this->userId;
}
if($this->session && $this->session->getUser() !== null) {
return $this->session->getUser()->getUID();
return null;
}
+ protected function getUser(): ?IUser {
+ $userId = $this->getUserId();
+ if($userId !== null) {
+ return $this->userManager->get($userId);
+ }
+ return null;
+ }
+
}
/**
* @param mixed $input
+ * @param string|null $userId
* @return mixed
* @throws \OCP\AppFramework\QueryException
* @since 16.0.0
*/
- public static function substitutePlaceholdersInConfig($input, $user = null) {
+ public static function substitutePlaceholdersInConfig($input, string $userId = null) {
/** @var BackendService $backendService */
$backendService = self::$app->getContainer()->query(BackendService::class);
/** @var IConfigHandler[] $handlers */