Allow the activity app to set the current user when sending emails
This commit is contained in:
parent
1733b6e8c8
commit
b5922e467a
|
@ -49,6 +49,9 @@ class ActivityManager implements IManager {
|
||||||
/** @var int */
|
/** @var int */
|
||||||
protected $formattingObjectId;
|
protected $formattingObjectId;
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
protected $currentUserId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* constructor of the controller
|
* constructor of the controller
|
||||||
*
|
*
|
||||||
|
@ -475,6 +478,19 @@ class ActivityManager implements IManager {
|
||||||
return array(' and ((' . implode(') or (', $conditions) . '))', $parameters);
|
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
|
* 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
|
* @throws \UnexpectedValueException If the token is invalid, does not exist or is not unique
|
||||||
*/
|
*/
|
||||||
public function getCurrentUserId() {
|
public function getCurrentUserId() {
|
||||||
if (!$this->session->isLoggedIn()) {
|
if ($this->currentUserId !== null) {
|
||||||
|
return $this->currentUserId;
|
||||||
|
} else if (!$this->session->isLoggedIn()) {
|
||||||
return $this->getUserFromToken();
|
return $this->getUserFromToken();
|
||||||
} else {
|
} else {
|
||||||
return $this->session->getUser()->getUID();
|
return $this->session->getUser()->getUID();
|
||||||
|
|
|
@ -204,6 +204,16 @@ interface IManager {
|
||||||
*/
|
*/
|
||||||
public function getQueryForFilter($filter);
|
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
|
* Get the user we need to use
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue