return;
}
- if (!empty($_SESSION['submanage'])) {
+ if (DI::userSession()->getSubManagedUserId()) {
return;
}
return;
}
- if (!empty($_SESSION['submanage'])) {
+ if (DI::userSession()->getSubManagedUserId()) {
return;
}
return Login::form();
}
- if (!empty($_SESSION['submanage'])) {
+ if (DI::userSession()->getSubManagedUserId()) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
return '';
}
$nav['messages']['outbox'] = ['message/sent', DI::l10n()->t('Outbox'), '', DI::l10n()->t('Outbox')];
$nav['messages']['new'] = ['message/new', DI::l10n()->t('New Message'), '', DI::l10n()->t('New Message')];
- if (User::hasIdentities(DI::session()->get('submanage') ?: DI::userSession()->getLocalUserId())) {
+ if (User::hasIdentities(DI::userSession()->getSubManagedUserId() ?: DI::userSession()->getLocalUserId())) {
$nav['delegation'] = ['delegation', DI::l10n()->t('Accounts'), '', DI::l10n()->t('Manage other pages')];
}
*/
public function isAuthenticated(): bool;
+ /**
+ * Returns User ID of the managed user in case it's a different identity
+ *
+ * @return int|bool uid of the manager or false
+ */
+ public function getSubManagedUserId();
+
+ /**
+ * Sets the User ID of the managed user in case it's a different identity
+ *
+ * @param int $managed_uid The user id of the managing user
+ */
+ public function setSubManagedUserId(int $managed_uid): void;
+
/**
* Set the session variable that contains the contact IDs for the visitor's contact URL
*
{
$this->session->set('remote', Contact::getVisitorByUrl($this->session->get('my_url')));
}
+
+ /** {@inheritDoc} */
+ public function getSubManagedUserId()
+ {
+ return $this->session->get('submanage') ?? false;
+ }
+
+ /** {@inheritDoc} */
+ public function setSubManagedUserId(int $managed_uid): void
+ {
+ $this->session->set('submanage', $managed_uid);
+ }
}
throw new HTTPException\ForbiddenException(DI::l10n()->t('You don\'t have access to administration pages.'));
}
- if (!empty($_SESSION['submanage'])) {
+ if (DI::userSession()->getSubManagedUserId()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Submanaged account can\'t access the administration pages. Please log back in as the main account.'));
}
}
$uid = DI::userSession()->getLocalUserId();
$orig_record = User::getById(DI::app()->getLoggedInUserId());
- if (DI::session()->get('submanage')) {
- $user = User::getById(DI::session()->get('submanage'));
+ if (DI::userSession()->getSubManagedUserId()) {
+ $user = User::getById(DI::userSession()->getSubManagedUserId());
if (DBA::isResult($user)) {
$uid = intval($user['uid']);
$orig_record = $user;
DI::auth()->setForUser(DI::app(), $user, true, true);
if ($limited_id) {
- DI::session()->set('submanage', $original_id);
+ DI::userSession()->setSubManagedUserId($original_id);
}
$ret = [];
throw new ForbiddenException(DI::l10n()->t('Permission denied.'));
}
- $identities = User::identities(DI::session()->get('submanage', DI::userSession()->getLocalUserId()));
+ $identities = User::identities(DI::userSession()->getSubManagedUserId() ?: DI::userSession()->getLocalUserId());
//getting additinal information for each identity
foreach ($identities as $key => $identity) {
$user_id = $args->get(3);
if ($action === 'add' && $user_id) {
- if (DI::session()->get('submanage')) {
+ if (DI::userSession()->getSubManagedUserId()) {
DI::sysmsg()->addNotice(DI::l10n()->t('Delegated administrators can view but not change delegation permissions.'));
DI::baseUrl()->redirect('settings/delegation');
}
}
if ($action === 'remove' && $user_id) {
- if (DI::session()->get('submanage')) {
+ if (DI::userSession()->getSubManagedUserId()) {
DI::sysmsg()->addNotice(DI::l10n()->t('Delegated administrators can view but not change delegation permissions.'));
DI::baseUrl()->redirect('settings/delegation');
}