aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/files_sharing/lib/Controller/ShareAPIController.php49
-rw-r--r--apps/files_sharing/src/share.js2
-rw-r--r--apps/files_versions/lib/Storage.php32
-rw-r--r--apps/files_versions/lib/Versions/VersionManager.php51
-rw-r--r--apps/provisioning_api/lib/Controller/UsersController.php8
-rw-r--r--apps/provisioning_api/tests/Controller/UsersControllerTest.php157
-rw-r--r--apps/settings/l10n/fi.js1
-rw-r--r--apps/settings/l10n/fi.json1
-rw-r--r--apps/settings/l10n/ru.js2
-rw-r--r--apps/settings/l10n/ru.json2
-rw-r--r--apps/user_ldap/lib/Access.php5
-rw-r--r--apps/user_ldap/lib/AccessFactory.php7
-rw-r--r--apps/user_ldap/lib/Group_LDAP.php15
-rw-r--r--apps/user_ldap/lib/Group_Proxy.php6
-rw-r--r--apps/user_ldap/lib/Jobs/Sync.php19
-rw-r--r--apps/user_ldap/tests/Jobs/SyncTest.php3
16 files changed, 276 insertions, 84 deletions
diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php
index e1595a98ea3..3287d9447d8 100644
--- a/apps/files_sharing/lib/Controller/ShareAPIController.php
+++ b/apps/files_sharing/lib/Controller/ShareAPIController.php
@@ -627,16 +627,6 @@ class ShareAPIController extends OCSController {
$share->setSendPasswordByTalk(true);
}
-
- //Expire date
- if ($expireDate !== '') {
- try {
- $expireDate = $this->parseDate($expireDate);
- $share->setExpirationDate($expireDate);
- } catch (\Exception $e) {
- throw new OCSNotFoundException($this->l->t('Invalid date, date format must be YYYY-MM-DD'));
- }
- }
} elseif ($shareType === IShare::TYPE_REMOTE) {
if (!$this->shareManager->outgoingServer2ServerSharesAllowed()) {
throw new OCSForbiddenException($this->l->t('Sharing %1$s failed because the back end does not allow shares from type %2$s', [$node->getPath(), $shareType]));
@@ -710,6 +700,16 @@ class ShareAPIController extends OCSController {
throw new OCSBadRequestException($this->l->t('Unknown share type'));
}
+ //Expire date
+ if ($expireDate !== '') {
+ try {
+ $expireDate = $this->parseDate($expireDate);
+ $share->setExpirationDate($expireDate);
+ } catch (\Exception $e) {
+ throw new OCSNotFoundException($this->l->t('Invalid date, date format must be YYYY-MM-DD'));
+ }
+ }
+
$share->setShareType($shareType);
if ($note !== '') {
@@ -1216,17 +1216,6 @@ class ShareAPIController extends OCSController {
$permissions = $newPermissions;
}
- if ($expireDate === '') {
- $share->setExpirationDate(null);
- } elseif ($expireDate !== null) {
- try {
- $expireDate = $this->parseDate($expireDate);
- } catch (\Exception $e) {
- throw new OCSBadRequestException($e->getMessage(), $e);
- }
- $share->setExpirationDate($expireDate);
- }
-
if ($password === '') {
$share->setPassword(null);
} elseif ($password !== null) {
@@ -1256,17 +1245,17 @@ class ShareAPIController extends OCSController {
if ($permissions !== null) {
$share->setPermissions($permissions);
}
+ }
- if ($expireDate === '') {
- $share->setExpirationDate(null);
- } elseif ($expireDate !== null) {
- try {
- $expireDate = $this->parseDate($expireDate);
- } catch (\Exception $e) {
- throw new OCSBadRequestException($e->getMessage(), $e);
- }
- $share->setExpirationDate($expireDate);
+ if ($expireDate === '') {
+ $share->setExpirationDate(null);
+ } elseif ($expireDate !== null) {
+ try {
+ $expireDate = $this->parseDate($expireDate);
+ } catch (\Exception $e) {
+ throw new OCSBadRequestException($e->getMessage(), $e);
}
+ $share->setExpirationDate($expireDate);
}
try {
diff --git a/apps/files_sharing/src/share.js b/apps/files_sharing/src/share.js
index 06eea5807a1..a54f2f13698 100644
--- a/apps/files_sharing/src/share.js
+++ b/apps/files_sharing/src/share.js
@@ -94,7 +94,7 @@ import { getCapabilities } from '@nextcloud/capabilities'
}
if (_.isFunction(fileData.canDownload) && !fileData.canDownload()) {
delete fileActions.actions.all.Download
- if (fileData.permissions & OC.PERMISSION_UPDATE === 0) {
+ if ((fileData.permissions & OC.PERMISSION_UPDATE) === 0) {
// neither move nor copy is allowed, remove the action completely
delete fileActions.actions.all.MoveCopy
}
diff --git a/apps/files_versions/lib/Storage.php b/apps/files_versions/lib/Storage.php
index 85d8660f240..9141e6c4c65 100644
--- a/apps/files_versions/lib/Storage.php
+++ b/apps/files_versions/lib/Storage.php
@@ -443,24 +443,26 @@ class Storage {
$view->lockFile($path1, ILockingProvider::LOCK_EXCLUSIVE);
$view->lockFile($path2, ILockingProvider::LOCK_EXCLUSIVE);
- // TODO add a proper way of overwriting a file while maintaining file ids
- if ($storage1->instanceOfStorage('\OC\Files\ObjectStore\ObjectStoreStorage') || $storage2->instanceOfStorage('\OC\Files\ObjectStore\ObjectStoreStorage')) {
- $source = $storage1->fopen($internalPath1, 'r');
- $target = $storage2->fopen($internalPath2, 'w');
- [, $result] = \OC_Helper::streamCopy($source, $target);
- fclose($source);
- fclose($target);
-
- if ($result !== false) {
- $storage1->unlink($internalPath1);
+ try {
+ // TODO add a proper way of overwriting a file while maintaining file ids
+ if ($storage1->instanceOfStorage('\OC\Files\ObjectStore\ObjectStoreStorage') || $storage2->instanceOfStorage('\OC\Files\ObjectStore\ObjectStoreStorage')) {
+ $source = $storage1->fopen($internalPath1, 'r');
+ $target = $storage2->fopen($internalPath2, 'w');
+ [, $result] = \OC_Helper::streamCopy($source, $target);
+ fclose($source);
+ fclose($target);
+
+ if ($result !== false) {
+ $storage1->unlink($internalPath1);
+ }
+ } else {
+ $result = $storage2->moveFromStorage($storage1, $internalPath1, $internalPath2);
}
- } else {
- $result = $storage2->moveFromStorage($storage1, $internalPath1, $internalPath2);
+ } finally {
+ $view->unlockFile($path1, ILockingProvider::LOCK_EXCLUSIVE);
+ $view->unlockFile($path2, ILockingProvider::LOCK_EXCLUSIVE);
}
- $view->unlockFile($path1, ILockingProvider::LOCK_EXCLUSIVE);
- $view->unlockFile($path2, ILockingProvider::LOCK_EXCLUSIVE);
-
return ($result !== false);
}
diff --git a/apps/files_versions/lib/Versions/VersionManager.php b/apps/files_versions/lib/Versions/VersionManager.php
index b3b6d6f85e8..3e769000da7 100644
--- a/apps/files_versions/lib/Versions/VersionManager.php
+++ b/apps/files_versions/lib/Versions/VersionManager.php
@@ -27,8 +27,13 @@ namespace OCA\Files_Versions\Versions;
use OCP\Files\File;
use OCP\Files\FileInfo;
+use OCP\Files\IRootFolder;
+use OCP\Files\Lock\ILock;
+use OCP\Files\Lock\ILockManager;
+use OCP\Files\Lock\LockContext;
use OCP\Files\Storage\IStorage;
use OCP\IUser;
+use OCP\Lock\ManuallyLockedException;
class VersionManager implements IVersionManager, INameableVersionBackend, IDeletableVersionBackend {
/** @var (IVersionBackend[])[] */
@@ -94,7 +99,7 @@ class VersionManager implements IVersionManager, INameableVersionBackend, IDelet
public function rollback(IVersion $version) {
$backend = $version->getBackend();
- $result = $backend->rollback($version);
+ $result = self::handleAppLocks(fn(): ?bool => $backend->rollback($version));
// rollback doesn't have a return type yet and some implementations don't return anything
if ($result === null || $result === true) {
\OC_Hook::emit('\OCP\Versions', 'rollback', [
@@ -133,4 +138,48 @@ class VersionManager implements IVersionManager, INameableVersionBackend, IDelet
$backend->deleteVersion($version);
}
}
+
+ /**
+ * Catch ManuallyLockedException and retry in app context if possible.
+ *
+ * Allow users to go back to old versions via the versions tab in the sidebar
+ * even when the file is opened in the viewer next to it.
+ *
+ * Context: If a file is currently opened for editing
+ * the files_lock app will throw ManuallyLockedExceptions.
+ * This prevented the user from rolling an opened file back to a previous version.
+ *
+ * Text and Richdocuments can handle changes of open files.
+ * So we execute the rollback under their lock context
+ * to let them handle the conflict.
+ *
+ * @param callable $callback function to run with app locks handled
+ * @return bool|null
+ * @throws ManuallyLockedException
+ *
+ */
+ private static function handleAppLocks(callable $callback): ?bool {
+ try {
+ return $callback();
+ } catch (ManuallyLockedException $e) {
+ $owner = (string) $e->getOwner();
+ $appsThatHandleUpdates = array("text", "richdocuments");
+ if (!in_array($owner, $appsThatHandleUpdates)) {
+ throw $e;
+ }
+ // The LockWrapper in the files_lock app only compares the lock type and owner
+ // when checking the lock against the current scope.
+ // So we do not need to get the actual node here
+ // and use the root node instead.
+ $root = \OC::$server->get(IRootFolder::class);
+ $lockContext = new LockContext($root, ILock::TYPE_APP, $owner);
+ $lockManager = \OC::$server->get(ILockManager::class);
+ $result = null;
+ $lockManager->runInScope($lockContext, function() use ($callback, &$result) {
+ $result = $callback();
+ });
+ return $result;
+ }
+ }
+
}
diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php
index bc97e32faa4..b005acc4d7f 100644
--- a/apps/provisioning_api/lib/Controller/UsersController.php
+++ b/apps/provisioning_api/lib/Controller/UsersController.php
@@ -942,11 +942,11 @@ class UsersController extends AUserData {
if (filter_var($value, FILTER_VALIDATE_EMAIL) && $value !== $targetUser->getSystemEMailAddress()) {
$userAccount = $this->accountManager->getAccount($targetUser);
$mailCollection = $userAccount->getPropertyCollection(IAccountManager::COLLECTION_EMAIL);
- foreach ($mailCollection->getProperties() as $property) {
- if ($property->getValue() === $value) {
- break;
- }
+
+ if ($mailCollection->getPropertyByValue($value)) {
+ throw new OCSException('', 102);
}
+
$mailCollection->addPropertyWithDefaults($value);
$this->accountManager->updateAccount($userAccount);
} else {
diff --git a/apps/provisioning_api/tests/Controller/UsersControllerTest.php b/apps/provisioning_api/tests/Controller/UsersControllerTest.php
index b8b8fa8715c..419f9eceb79 100644
--- a/apps/provisioning_api/tests/Controller/UsersControllerTest.php
+++ b/apps/provisioning_api/tests/Controller/UsersControllerTest.php
@@ -52,7 +52,9 @@ use OCA\Settings\Mailer\NewUserMailHelper;
use OCP\Accounts\IAccount;
use OCP\Accounts\IAccountManager;
use OCP\Accounts\IAccountProperty;
+use OCP\Accounts\IAccountPropertyCollection;
use OCP\AppFramework\Http\DataResponse;
+use OCP\AppFramework\OCS\OCSException;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IConfig;
use OCP\IGroup;
@@ -1544,7 +1546,162 @@ class UsersControllerTest extends TestCase {
$this->assertEquals([], $this->api->editUser('UserToEdit', 'email', 'demo@nextcloud.com')->getData());
}
+ public function testEditUserRegularUserSelfEditAddAdditionalEmailValid(): void {
+ $loggedInUser = $this->getMockBuilder(IUser::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $loggedInUser
+ ->expects($this->any())
+ ->method('getUID')
+ ->willReturn('UID');
+ $targetUser = $this->getMockBuilder(IUser::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->userSession
+ ->expects($this->once())
+ ->method('getUser')
+ ->willReturn($loggedInUser);
+ $this->userManager
+ ->expects($this->once())
+ ->method('get')
+ ->with('UserToEdit')
+ ->willReturn($targetUser);
+ $targetUser
+ ->expects($this->any())
+ ->method('getUID')
+ ->willReturn('UID');
+
+ $backend = $this->createMock(UserInterface::class);
+ $targetUser
+ ->expects($this->any())
+ ->method('getBackend')
+ ->willReturn($backend);
+
+ $userAccount = $this->createMock(IAccount::class);
+
+ $this->accountManager
+ ->expects($this->once())
+ ->method('getAccount')
+ ->with($targetUser)
+ ->willReturn($userAccount);
+ $this->accountManager
+ ->expects($this->once())
+ ->method('updateAccount')
+ ->with($userAccount);
+
+ $this->assertEquals([], $this->api->editUser('UserToEdit', 'additional_mail', 'demo1@nextcloud.com')->getData());
+ }
+
+ public function testEditUserRegularUserSelfEditAddAdditionalEmailMainAddress(): void {
+ $loggedInUser = $this->getMockBuilder(IUser::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $loggedInUser
+ ->expects($this->any())
+ ->method('getUID')
+ ->willReturn('UID');
+ $targetUser = $this->getMockBuilder(IUser::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->userSession
+ ->expects($this->once())
+ ->method('getUser')
+ ->willReturn($loggedInUser);
+ $this->userManager
+ ->expects($this->once())
+ ->method('get')
+ ->with('UserToEdit')
+ ->willReturn($targetUser);
+ $targetUser
+ ->expects($this->any())
+ ->method('getUID')
+ ->willReturn('UID');
+
+ $backend = $this->createMock(UserInterface::class);
+ $targetUser
+ ->expects($this->any())
+ ->method('getBackend')
+ ->willReturn($backend);
+ $targetUser
+ ->expects($this->any())
+ ->method('getSystemEMailAddress')
+ ->willReturn('demo@nextcloud.com');
+
+ $userAccount = $this->createMock(IAccount::class);
+ $this->accountManager
+ ->expects($this->never())
+ ->method('getAccount')
+ ->with($targetUser)
+ ->willReturn($userAccount);
+ $this->accountManager
+ ->expects($this->never())
+ ->method('updateAccount')
+ ->with($userAccount);
+
+ $this->expectException(OCSException::class);
+ $this->expectExceptionCode(102);
+ $this->api->editUser('UserToEdit', 'additional_mail', 'demo@nextcloud.com')->getData();
+ }
+
+ public function testEditUserRegularUserSelfEditAddAdditionalEmailDuplicate(): void {
+ $loggedInUser = $this->getMockBuilder(IUser::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $loggedInUser
+ ->expects($this->any())
+ ->method('getUID')
+ ->willReturn('UID');
+ $targetUser = $this->getMockBuilder(IUser::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->userSession
+ ->expects($this->once())
+ ->method('getUser')
+ ->willReturn($loggedInUser);
+ $this->userManager
+ ->expects($this->once())
+ ->method('get')
+ ->with('UserToEdit')
+ ->willReturn($targetUser);
+ $targetUser
+ ->expects($this->any())
+ ->method('getUID')
+ ->willReturn('UID');
+
+ $backend = $this->createMock(UserInterface::class);
+ $targetUser
+ ->expects($this->any())
+ ->method('getBackend')
+ ->willReturn($backend);
+
+ $property = $this->createMock(IAccountProperty::class);
+ $property->method('getValue')
+ ->willReturn('demo1@nextcloud.com');
+ $collection = $this->createMock(IAccountPropertyCollection::class);
+ $collection->method('getPropertyByValue')
+ ->with('demo1@nextcloud.com')
+ ->willReturn($property);
+
+ $userAccount = $this->createMock(IAccount::class);
+ $userAccount->method('getPropertyCollection')
+ ->with(IAccountManager::COLLECTION_EMAIL)
+ ->willReturn($collection);
+
+ $this->accountManager
+ ->expects($this->once())
+ ->method('getAccount')
+ ->with($targetUser)
+ ->willReturn($userAccount);
+ $this->accountManager
+ ->expects($this->never())
+ ->method('updateAccount')
+ ->with($userAccount);
+
+ $this->expectException(OCSException::class);
+ $this->expectExceptionCode(102);
+ $this->api->editUser('UserToEdit', 'additional_mail', 'demo1@nextcloud.com')->getData();
+ }
public function testEditUserRegularUserSelfEditChangeEmailInvalid() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class);
diff --git a/apps/settings/l10n/fi.js b/apps/settings/l10n/fi.js
index ec224881578..b252cdff030 100644
--- a/apps/settings/l10n/fi.js
+++ b/apps/settings/l10n/fi.js
@@ -237,6 +237,7 @@ OC.L10N.register(
"Upload profile picture" : "Lähetä profiilikuva",
"Choose profile picture from Files" : "Valitse profiilikuva tiedostoista",
"Remove profile picture" : "Poista profiilikuva",
+ "The file must be a PNG or JPG" : "Tiedoston tulee olla PNG tai JPG",
"Picture provided by original account" : "Kuvan tarjoaa alkuperäinen tili",
"Cancel" : "Peru",
"Set as profile picture" : "Aseta profiilikuvaksi",
diff --git a/apps/settings/l10n/fi.json b/apps/settings/l10n/fi.json
index 3cbe0e7fd2f..49150fde99f 100644
--- a/apps/settings/l10n/fi.json
+++ b/apps/settings/l10n/fi.json
@@ -235,6 +235,7 @@
"Upload profile picture" : "Lähetä profiilikuva",
"Choose profile picture from Files" : "Valitse profiilikuva tiedostoista",
"Remove profile picture" : "Poista profiilikuva",
+ "The file must be a PNG or JPG" : "Tiedoston tulee olla PNG tai JPG",
"Picture provided by original account" : "Kuvan tarjoaa alkuperäinen tili",
"Cancel" : "Peru",
"Set as profile picture" : "Aseta profiilikuvaksi",
diff --git a/apps/settings/l10n/ru.js b/apps/settings/l10n/ru.js
index 90cd711f410..805ffc1c42a 100644
--- a/apps/settings/l10n/ru.js
+++ b/apps/settings/l10n/ru.js
@@ -425,7 +425,7 @@ OC.L10N.register(
"App bundles" : "Пакеты приложений",
"Featured apps" : "Рекомендуемые приложения",
"Show to everyone" : "Видим для всех",
- "Show to logged in users only" : "Видим только для пользователей, вошедших в систему",
+ "Show to logged in users only" : "Видим только для вошедших в систему",
"Hide" : "Скрыт",
"Download and enable" : "Скачать и включить",
"Enable untested app" : "Включить непроверенное приложение",
diff --git a/apps/settings/l10n/ru.json b/apps/settings/l10n/ru.json
index 4575793ac0f..63f94cf89d2 100644
--- a/apps/settings/l10n/ru.json
+++ b/apps/settings/l10n/ru.json
@@ -423,7 +423,7 @@
"App bundles" : "Пакеты приложений",
"Featured apps" : "Рекомендуемые приложения",
"Show to everyone" : "Видим для всех",
- "Show to logged in users only" : "Видим только для пользователей, вошедших в систему",
+ "Show to logged in users only" : "Видим только для вошедших в систему",
"Hide" : "Скрыт",
"Download and enable" : "Скачать и включить",
"Enable untested app" : "Включить непроверенное приложение",
diff --git a/apps/user_ldap/lib/Access.php b/apps/user_ldap/lib/Access.php
index 9a97a28c376..3f120caefe6 100644
--- a/apps/user_ldap/lib/Access.php
+++ b/apps/user_ldap/lib/Access.php
@@ -631,7 +631,7 @@ class Access extends LDAPUtility {
* gives back the user names as they are used ownClod internally
*
* @param array $ldapUsers as returned by fetchList()
- * @return array an array with the user names to use in Nextcloud
+ * @return array<int,string> an array with the user names to use in Nextcloud
*
* gives back the user names as they are used ownClod internally
* @throws \Exception
@@ -644,7 +644,7 @@ class Access extends LDAPUtility {
* gives back the group names as they are used ownClod internally
*
* @param array $ldapGroups as returned by fetchList()
- * @return array an array with the group names to use in Nextcloud
+ * @return array<int,string> an array with the group names to use in Nextcloud
*
* gives back the group names as they are used ownClod internally
* @throws \Exception
@@ -655,6 +655,7 @@ class Access extends LDAPUtility {
/**
* @param array[] $ldapObjects as returned by fetchList()
+ * @return array<int,string>
* @throws \Exception
*/
private function ldap2NextcloudNames(array $ldapObjects, bool $isUsers): array {
diff --git a/apps/user_ldap/lib/AccessFactory.php b/apps/user_ldap/lib/AccessFactory.php
index f0820f1444f..693f7e8ba12 100644
--- a/apps/user_ldap/lib/AccessFactory.php
+++ b/apps/user_ldap/lib/AccessFactory.php
@@ -26,11 +26,11 @@ namespace OCA\User_LDAP;
use OCA\User_LDAP\User\Manager;
use OCP\IConfig;
use OCP\IUserManager;
+use OCP\Server;
use Psr\Log\LoggerInterface;
class AccessFactory {
private ILDAPWrapper $ldap;
- private Manager $userManager;
private Helper $helper;
private IConfig $config;
private IUserManager $ncUserManager;
@@ -38,13 +38,11 @@ class AccessFactory {
public function __construct(
ILDAPWrapper $ldap,
- Manager $userManager,
Helper $helper,
IConfig $config,
IUserManager $ncUserManager,
LoggerInterface $logger) {
$this->ldap = $ldap;
- $this->userManager = $userManager;
$this->helper = $helper;
$this->config = $config;
$this->ncUserManager = $ncUserManager;
@@ -52,10 +50,11 @@ class AccessFactory {
}
public function get(Connection $connection): Access {
+ /* Each Access instance gets its own Manager instance, see OCA\User_LDAP\AppInfo\Application::register() */
return new Access(
$connection,
$this->ldap,
- $this->userManager,
+ Server::get(Manager::class),
$this->helper,
$this->config,
$this->ncUserManager,
diff --git a/apps/user_ldap/lib/Group_LDAP.php b/apps/user_ldap/lib/Group_LDAP.php
index b32e031175f..84267171d37 100644
--- a/apps/user_ldap/lib/Group_LDAP.php
+++ b/apps/user_ldap/lib/Group_LDAP.php
@@ -45,11 +45,11 @@
namespace OCA\User_LDAP;
use Exception;
+use OC\ServerNotAvailableException;
use OCP\Cache\CappedMemoryCache;
use OCP\GroupInterface;
use OCP\Group\Backend\IDeleteGroupBackend;
use OCP\Group\Backend\IGetDisplayNameBackend;
-use OC\ServerNotAvailableException;
use Psr\Log\LoggerInterface;
class Group_LDAP extends BackendUtility implements GroupInterface, IGroupLDAP, IGetDisplayNameBackend, IDeleteGroupBackend {
@@ -466,7 +466,7 @@ class Group_LDAP extends BackendUtility implements GroupInterface, IGroupLDAP, I
}
/**
- * @return array A list of users that have the given group as gid number
+ * @return array<int,string> A list of users that have the given group as gid number
* @throws ServerNotAvailableException
*/
public function getUsersInGidNumber(
@@ -591,6 +591,7 @@ class Group_LDAP extends BackendUtility implements GroupInterface, IGroupLDAP, I
/**
* @throws ServerNotAvailableException
+ * @return array<int,string>
*/
public function getUsersInPrimaryGroup(
string $groupDN,
@@ -840,7 +841,7 @@ class Group_LDAP extends BackendUtility implements GroupInterface, IGroupLDAP, I
* @param string $search
* @param int $limit
* @param int $offset
- * @return array with user ids
+ * @return array<int,string> user ids
* @throws Exception
* @throws ServerNotAvailableException
*/
@@ -909,7 +910,11 @@ class Group_LDAP extends BackendUtility implements GroupInterface, IGroupLDAP, I
if (empty($ldap_users)) {
break;
}
- $groupUsers[] = $this->access->dn2username($ldap_users[0]['dn'][0]);
+ $uid = $this->access->dn2username($ldap_users[0]['dn'][0]);
+ if (!$uid) {
+ break;
+ }
+ $groupUsers[] = $uid;
break;
default:
//we got DNs, check if we need to filter by search or we can give back all of them
@@ -1163,7 +1168,7 @@ class Group_LDAP extends BackendUtility implements GroupInterface, IGroupLDAP, I
* Returns the supported actions as int to be
* compared with GroupInterface::CREATE_GROUP etc.
*/
- public function implementsActions($actions) {
+ public function implementsActions($actions): bool {
return (bool)((GroupInterface::COUNT_USERS |
GroupInterface::DELETE_GROUP |
$this->groupPluginManager->getImplementedActions()) & $actions);
diff --git a/apps/user_ldap/lib/Group_Proxy.php b/apps/user_ldap/lib/Group_Proxy.php
index c8c986318ec..5f8d0562fd9 100644
--- a/apps/user_ldap/lib/Group_Proxy.php
+++ b/apps/user_ldap/lib/Group_Proxy.php
@@ -171,7 +171,7 @@ class Group_Proxy extends Proxy implements \OCP\GroupInterface, IGroupLDAP, IGet
/**
* get a list of all users in a group
*
- * @return string[] with user ids
+ * @return array<int,string> user ids
*/
public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
$this->setup();
@@ -334,4 +334,8 @@ class Group_Proxy extends Proxy implements \OCP\GroupInterface, IGroupLDAP, IGet
public function getBackendName(): string {
return 'LDAP';
}
+
+ public function searchInGroup(string $gid, string $search = '', int $limit = -1, int $offset = 0): array {
+ return $this->handleRequest($gid, 'searchInGroup', [$gid, $search, $limit, $offset]);
+ }
}
diff --git a/apps/user_ldap/lib/Jobs/Sync.php b/apps/user_ldap/lib/Jobs/Sync.php
index 1ba24af5399..f8a9b14d02f 100644
--- a/apps/user_ldap/lib/Jobs/Sync.php
+++ b/apps/user_ldap/lib/Jobs/Sync.php
@@ -31,7 +31,6 @@ use OCA\User_LDAP\ConnectionFactory;
use OCA\User_LDAP\Helper;
use OCA\User_LDAP\LDAP;
use OCA\User_LDAP\Mapping\UserMapping;
-use OCA\User_LDAP\User\Manager;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\TimedJob;
use OCP\IAvatarManager;
@@ -48,8 +47,6 @@ class Sync extends TimedJob {
protected $ldapHelper;
/** @var LDAP */
protected $ldap;
- /** @var Manager */
- protected $userManager;
/** @var UserMapping */
protected $mapper;
/** @var IConfig */
@@ -69,9 +66,8 @@ class Sync extends TimedJob {
/** @var AccessFactory */
protected $accessFactory;
- public function __construct(Manager $userManager, ITimeFactory $time) {
+ public function __construct(ITimeFactory $time) {
parent::__construct($time);
- $this->userManager = $userManager;
$this->setInterval(
(int)\OC::$server->getConfig()->getAppValue(
'user_ldap',
@@ -350,10 +346,6 @@ class Sync extends TimedJob {
$this->notificationManager = \OC::$server->getNotificationManager();
}
- if (isset($argument['userManager'])) {
- $this->userManager = $argument['userManager'];
- }
-
if (isset($argument['mapper'])) {
$this->mapper = $argument['mapper'];
} else {
@@ -369,14 +361,7 @@ class Sync extends TimedJob {
if (isset($argument['accessFactory'])) {
$this->accessFactory = $argument['accessFactory'];
} else {
- $this->accessFactory = new AccessFactory(
- $this->ldap,
- $this->userManager,
- $this->ldapHelper,
- $this->config,
- $this->ncUserManager,
- $this->logger
- );
+ $this->accessFactory = \OCP\Server::get(AccessFactory::class);
}
}
}
diff --git a/apps/user_ldap/tests/Jobs/SyncTest.php b/apps/user_ldap/tests/Jobs/SyncTest.php
index 8d23efb4da8..3d9fc54e631 100644
--- a/apps/user_ldap/tests/Jobs/SyncTest.php
+++ b/apps/user_ldap/tests/Jobs/SyncTest.php
@@ -43,7 +43,6 @@ use OCP\Notification\IManager;
use Test\TestCase;
class SyncTest extends TestCase {
-
/** @var array */
protected $arguments;
/** @var Helper|\PHPUnit\Framework\MockObject\MockObject */
@@ -99,7 +98,7 @@ class SyncTest extends TestCase {
'accessFactory' => $this->accessFactory,
];
- $this->sync = new Sync($this->userManager, $this->createMock(ITimeFactory::class));
+ $this->sync = new Sync($this->createMock(ITimeFactory::class));
}
public function intervalDataProvider() {