ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilECSCommunity.php
Go to the documentation of this file.
1 <?php
2 
18 declare(strict_types=1);
19 
24 {
25  protected object $json_obj;
26  protected string $title = '';
27  protected string $description = '';
28  protected int $id = 0;
29 
30  protected array $participants = array();
31  protected int $position = 0;
32 
38  public function __construct(object $json_obj)
39  {
40  $this->json_obj = $json_obj;
41  $this->read();
42  }
43 
47  public function getTitle(): string
48  {
49  return $this->title;
50  }
51 
55  public function getDescription(): string
56  {
57  return $this->description;
58  }
59 
65  public function getParticipants(): array
66  {
67  return $this->participants ?: [];
68  }
69 
73  public function getMids(): array
74  {
75  $mids = [];
76  foreach ($this->getParticipants() as $part) {
77  $mids[] = $part->getMID();
78  }
79  return $mids;
80  }
81 
85  public function getOwnId(): int
86  {
87  foreach ($this->getParticipants() as $part) {
88  if ($part->isSelf()) {
89  return $part->getMID();
90  }
91  }
92  return 0;
93  }
94 
95 
99  public function getId(): int
100  {
101  return $this->id;
102  }
103 
104 
108  private function read(): void
109  {
110  $this->title = $this->json_obj->community->name;
111  $this->description = $this->json_obj->community->description;
112  $this->id = $this->json_obj->community->cid;
113 
114  foreach ($this->json_obj->participants as $participant) {
115  $this->participants[] = new ilECSParticipant($participant, $this->getId());
116  }
117  }
118 }
read()
Read community entries and participants.
getParticipants()
get participants
getDescription()
getDescription
getOwnId()
Get own mid of community.
__construct(object $json_obj)
Constructor.
getMids()
Get array of mids of all participants.