| Server IP : 93.86.61.54 / Your IP : 216.73.216.60 Web Server : Apache/2.4.62 (Ubuntu) System : Linux rasin.ddns.net 6.8.0-124-generic #124~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 21:05:19 UTC x86_64 User : www-data ( 33) PHP Version : 8.4.22 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/html/projects/nextcloud/apps/bbb/lib/ |
Upload File : |
<?php
namespace OCA\BigBlueButton;
use OCA\BigBlueButton\AppInfo\Application;
use OCP\App\IAppManager;
class CircleHelper {
private $api;
/** @var Application */
private $app;
/** @var IAppManager */
private $appManager;
private $cache = [];
public function __construct(
Application $app,
IAppManager $appManager
) {
$this->app = $app;
$this->appManager = $appManager;
}
public function isInCircle(string $userId, string $circleId): bool {
return \in_array($circleId, $this->getCircleIds($userId));
}
public function getCircleIds(string $userId): array {
if (!\array_key_exists($userId, $this->cache)) {
$this->cache[$userId] = [];
$api = $this->getCircleAPI();
if ($api !== false) {
// since v0.19.x \OCA\Circles\Api\v1\Circles can be used
$circles = $api->listCircles(\OCA\Circles\Model\Circle::CIRCLES_ALL, '', \OCA\Circles\Model\Member::LEVEL_MEMBER);
foreach ($circles as $circle) {
$this->cache[$userId][] = $circle->getUniqueId();
}
}
}
return $this->cache[$userId];
}
public function getCircleAPI() {
if ($this->api === null) {
if ($this->appManager->isEnabledForUser('circles') && class_exists('\OCA\Circles\Api\v1\Circles')) {
$container = $this->app->getContainer();
$this->api = $container->query(\OCA\Circles\Api\v1\Circles::class);
} else {
$this->api = false;
}
}
return $this->api;
}
}