Welcome to mirror list, hosted at ThFree Co, Russian Federation.

UserApiController.php « Controller « lib - github.com/nextcloud/text.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 64e788a249a3af9359a54a4ae8ab25a7603f1d58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php

namespace OCA\Text\Controller;

use \OCP\AppFramework\ApiController;
use OCP\Collaboration\Collaborators\ISearch;
use \OCP\IRequest;
use OCP\Share\IShare;

class UserApiController extends ApiController {

	protected ISearch $collaboratorSearch;

    public function __construct($appName, IRequest $request, ISearch $ISearch) {
        parent::__construct($appName, $request);

        $this->collaboratorSearch = $ISearch;
    }

    /**
     * @NoAdminRequired
     * @param string $filter
     */
    public function index(string $filter, int $limit = 5) {
		$users = [];
		[$result] = $this->collaboratorSearch->search($filter, [IShare::TYPE_USER], false, $limit, 0);

        foreach ($result['users'] as ['label' => $label, 'value' => $value]) {
			if (isset($value['shareWith'])) {
				$id = $value['shareWith'];
            	$users[$id] = $label;
			}
        }

		return $users;
	}

}