diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/activitymanager.php | 23 | ||||
-rw-r--r-- | lib/public/activity/imanager.php | 10 |
2 files changed, 31 insertions, 2 deletions
diff --git a/lib/private/activitymanager.php b/lib/private/activitymanager.php index 9258b7298cc..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 * @@ -321,7 +324,8 @@ class ActivityManager implements IManager { * @return bool */ public function isFormattingFilteredObject() { - return $this->formattingObjectType === $this->request->getParam('object_type') + return $this->formattingObjectType !== null && $this->formattingObjectId !== null + && $this->formattingObjectType === $this->request->getParam('object_type') && $this->formattingObjectId === $this->request->getParam('object_id'); } @@ -475,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 @@ -483,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(); diff --git a/lib/public/activity/imanager.php b/lib/public/activity/imanager.php index 0b97f8a07ed..cbd08722410 100644 --- a/lib/public/activity/imanager.php +++ b/lib/public/activity/imanager.php @@ -204,6 +204,16 @@ interface IManager { */ public function getQueryForFilter($filter); + + /** + * Set the user we need to use + * + * @param string|null $currentUserId + * @throws \UnexpectedValueException If the user is invalid + * @since 9.0.1 + */ + public function setCurrentUserId($currentUserId); + /** * Get the user we need to use * |