19declare(strict_types=1);
52 $this->
logger = $DIC->logger()->wsrv();
60 $this->
logger->debug(__METHOD__ .
': Finished reading communities');
94 return $this->own_ids ?: [];
105 return $this->communities ?: [];
116 foreach ($this->communities as $community) {
117 if ($community->getId() === $a_id) {
131 foreach ($community->getParticipants() as $participant) {
132 if ($participant->getPid() === $a_pid) {
148 return $this->participants[$a_mid] ??
false;
153 return isset($this->participants[$a_mid]) ?
154 $this->participants[$a_mid]->getParticipantName() :
163 foreach ($this->communities as $community) {
164 foreach ($community->getParticipants() as $part) {
165 if ($part->getMID() === $a_mid) {
179 $en = $ps->getEnabledParticipants();
182 foreach ($community->getParticipants() as $participant) {
183 if (in_array($participant->getMid(), $en,
true)) {
184 $e_part[] = $participant;
199 $res = $this->connector->getMemberships();
201 if (!is_array(
$res->getResult())) {
204 foreach (
$res->getResult() as $community) {
206 foreach ($tmp_comm->getParticipants() as $participant) {
207 $this->participants[$participant->getMID()] = $participant;
208 if ($participant->isSelf()) {
209 $this->own_ids[] = $participant->getMID();
212 $this->communities[] = $tmp_comm;
217 $this->
logger->error(__METHOD__ .
': Error connecting to ECS server. ' .
$e->getMessage());
225 "SELECT mid FROM ecs_part_settings WHERE sid = %s",
227 [$this->connector->getServer()->getServerId()]
229 $existing_ids = array_map(fn($row) => $row[
'mid'], $this->
database->fetchAll($query));
230 $missing_ids = array_diff(array_keys($this->participants), $existing_ids);
232 foreach ($missing_ids as $mid) {
237 $part_settings->setTitle($participant->getParticipantName());
238 $part_settings->setCommunityName($community->getTitle());
239 $part_settings->update();
static getInstance(int $a_server_id, int $mid)
Get instance by server id and mid.
static getInstanceByServerId(int $a_server_id)
Get instance by server id.
getServerId()
Get current server id.
static getInstanceByServerId(int $a_server_id)
Get singleton instance per server.
Component logger with individual log levels by component id.