54 lines
1.2 KiB
PHP
54 lines
1.2 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace OCA\Agency\Controller;
|
|
|
|
use OCP\IRequest;
|
|
use OCP\AppFramework\Http\TemplateResponse;
|
|
use OCP\AppFramework\Controller;
|
|
use OCP\Util;
|
|
use OCP\AppFramework\Http\JSONResponse;
|
|
use OCP\AppFramework\Http\DataResponse;
|
|
|
|
|
|
use OCA\Agency\Agency\AgencyManager;
|
|
use OCP\IDBConnection;
|
|
|
|
use OCP\IGroupManager;
|
|
use OCP\IUserManager;
|
|
|
|
class TestController extends Controller {
|
|
|
|
protected $appName;
|
|
protected $agencyManager;
|
|
|
|
private $groupManager;
|
|
private $userManager;
|
|
|
|
public function __construct($appName, IRequest $request, IDBConnection $db, IGroupManager $gm, IUserManager $userManager) {
|
|
parent::__construct($appName, $request);
|
|
$this->appName = $appName;
|
|
$this->agencyManager = new AgencyManager($db);
|
|
$this->groupManager = $gm;
|
|
$this->userManager = $userManager;
|
|
}
|
|
|
|
/**
|
|
* @NoAdminRequired
|
|
* @NoCSRFRequired
|
|
*/
|
|
public function filetest() {
|
|
$user = $this->userManager->get('holger');
|
|
$groups = $this->groupManager->getUserGroups($user);
|
|
|
|
$agency_group_id = "";
|
|
foreach($groups as $group){
|
|
if(str_contains($group->getGId(), 'agency')){
|
|
$agency_group_id = explode("_", strval($group->getGId()))[1];
|
|
}
|
|
}
|
|
|
|
return $agency_group_id;
|
|
}
|
|
|
|
} |