ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilECSCommunity.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25{
26 protected object $json_obj;
27 protected string $title = '';
28 protected string $description = '';
29 protected int $id = 0;
30
31 protected array $participants = array();
32 protected int $position = 0;
33
39 public function __construct(object $json_obj)
40 {
41 $this->json_obj = $json_obj;
42 $this->read();
43 }
44
48 public function getTitle(): string
49 {
50 return $this->title;
51 }
52
56 public function getDescription(): string
57 {
58 return $this->description;
59 }
60
66 public function getParticipants(): array
67 {
68 return $this->participants ?: [];
69 }
70
74 public function getMids(): array
75 {
76 $mids = [];
77 foreach ($this->getParticipants() as $part) {
78 $mids[] = $part->getMID();
79 }
80 return $mids;
81 }
82
86 public function getOwnId(): int
87 {
88 foreach ($this->getParticipants() as $part) {
89 if ($part->isSelf()) {
90 return $part->getMID();
91 }
92 }
93 return 0;
94 }
95
96
100 public function getId(): int
101 {
102 return $this->id;
103 }
104
105
109 private function read(): void
110 {
111 $this->title = $this->json_obj->community->name;
112 $this->description = $this->json_obj->community->description;
113 $this->id = $this->json_obj->community->cid;
114
115 foreach ($this->json_obj->participants as $participant) {
116 $this->participants[] = new ilECSParticipant($participant, $this->getId());
117 }
118 }
119}
__construct(object $json_obj)
Constructor.
getDescription()
getDescription
getParticipants()
get participants
read()
Read community entries and participants.
getMids()
Get array of mids of all participants.
getOwnId()
Get own mid of community.