Skip to content

Commit f9a1e7e

Browse files
committed
emulate entity on Admin OCS API
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
1 parent b6b3409 commit f9a1e7e

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

lib/Controller/AdminController.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131

3232
namespace OCA\Circles\Controller;
3333

34-
use OCA\Circles\Tools\Traits\TDeserialize;
35-
use OCA\Circles\Tools\Traits\TNCLogger;
3634
use Exception;
3735
use OCA\Circles\Exceptions\ContactAddressBookNotFoundException;
3836
use OCA\Circles\Exceptions\ContactFormatException;
@@ -52,6 +50,8 @@
5250
use OCA\Circles\Service\MemberService;
5351
use OCA\Circles\Service\MembershipService;
5452
use OCA\Circles\Service\SearchService;
53+
use OCA\Circles\Tools\Traits\TDeserialize;
54+
use OCA\Circles\Tools\Traits\TNCLogger;
5555
use OCP\AppFramework\Http\DataResponse;
5656
use OCP\AppFramework\OCS\OCSException;
5757
use OCP\AppFramework\OCSController;
@@ -263,6 +263,7 @@ public function memberLevel(string $emulated, string $circleId, string $memberId
263263
* @param string $emulated
264264
* @param int $limit
265265
* @param int $offset
266+
*
266267
* @return DataResponse
267268
* @throws OCSException
268269
*/
@@ -482,9 +483,6 @@ public function editSetting(string $emulated, string $circleId, string $setting,
482483
}
483484

484485

485-
486-
487-
488486
/**
489487
* @param string $emulated
490488
* @param string $circleId
@@ -543,6 +541,18 @@ public function link(string $emulated, string $circleId, string $singleId): Data
543541
private function setLocalFederatedUser(string $emulated): void {
544542
$user = $this->userSession->getUser();
545543
$this->federatedUserService->setCurrentPatron($user->getUID());
544+
545+
if (strpos($emulated, '=') > 0) {
546+
[$type, $id] = explode('=', $emulated, 2);
547+
switch (strtolower($type)) {
548+
case 'singleid':
549+
$federatedUser = $this->federatedUserService->getFederatedUser($id, Member::TYPE_SINGLE);
550+
$this->federatedUserService->setCurrentUser($federatedUser);
551+
break;
552+
}
553+
554+
return;
555+
}
546556
$this->federatedUserService->setLocalCurrentUserId($emulated);
547557
}
548558
}

0 commit comments

Comments
 (0)