diff options
Diffstat (limited to 'lib/private/activitymanager.php')
-rw-r--r-- | lib/private/activitymanager.php | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/private/activitymanager.php b/lib/private/activitymanager.php index 373105291dd..e522dca9e3b 100644 --- a/lib/private/activitymanager.php +++ b/lib/private/activitymanager.php @@ -49,6 +49,9 @@ class ActivityManager implements IManager { /** @var int */ protected $formattingObjectId; + /** @var string */ + protected $currentUserId; + /** * constructor of the controller * @@ -476,6 +479,19 @@ class ActivityManager implements IManager { } /** + * Set the user we need to use + * + * @param string|null $currentUserId + * @throws \UnexpectedValueException If the user is invalid + */ + public function setCurrentUserId($currentUserId) { + if (!is_string($currentUserId) && $currentUserId !== null) { + throw new \UnexpectedValueException('The given current user is invalid'); + } + $this->currentUserId = $currentUserId; + } + + /** * Get the user we need to use * * Either the user is logged in, or we try to get it from the token @@ -484,7 +500,9 @@ class ActivityManager implements IManager { * @throws \UnexpectedValueException If the token is invalid, does not exist or is not unique */ public function getCurrentUserId() { - if (!$this->session->isLoggedIn()) { + if ($this->currentUserId !== null) { + return $this->currentUserId; + } else if (!$this->session->isLoggedIn()) { return $this->getUserFromToken(); } else { return $this->session->getUser()->getUID(); |