Allow the activity app to set the current user when sending emails

This commit is contained in:
Joas Schilling 2016-03-24 09:33:00 +01:00
parent 1733b6e8c8
commit b5922e467a
2 changed files with 29 additions and 1 deletions

View File

@ -49,6 +49,9 @@ class ActivityManager implements IManager {
/** @var int */
protected $formattingObjectId;
/** @var string */
protected $currentUserId;
/**
* constructor of the controller
*
@ -475,6 +478,19 @@ class ActivityManager implements IManager {
return array(' and ((' . implode(') or (', $conditions) . '))', $parameters);
}
/**
* 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
*
@ -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();

View File

@ -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
*