Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@owncloud.com>2016-03-24 11:33:00 +0300
committerJoas Schilling <nickvergessen@owncloud.com>2016-03-29 10:12:12 +0300
commitb5922e467ab2570d25ccbfce0d20115fbf831be8 (patch)
tree0843b6b48400b3be0eb75243406d093cf3cc4ebe /lib
parent1733b6e8c87069ab903d8e09c1fd457c76e60f71 (diff)
Allow the activity app to set the current user when sending emails
Diffstat (limited to 'lib')
-rw-r--r--lib/private/activitymanager.php20
-rw-r--r--lib/public/activity/imanager.php10
2 files changed, 29 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();
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
*