ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilECSCommunityTableGUI.php
Go to the documentation of this file.
1 <?php
2 
18 declare(strict_types=1);
19 
24 {
27 
28  private \ILIAS\UI\Factory $ui_factory;
29  private \ILIAS\UI\Renderer $ui_renderer;
30 
31  public function __construct(ilECSSetting $set, ?object $a_parent_obj, string $a_parent_cmd, int $cid)
32  {
33  parent::__construct($a_parent_obj, $a_parent_cmd);
34 
35  global $DIC;
36 
37  $this->access = $DIC->access();
38  $this->ui_factory = $DIC->ui()->factory();
39  $this->ui_renderer = $DIC->ui()->renderer();
40 
41  // TODO: set id
42  $this->setId($set->getServerId() . '_' . $cid . '_' . 'community_table');
43 
44  $this->addColumn($this->lng->txt('ecs_participants'), 'participants', "35%");
45  $this->addColumn($this->lng->txt('ecs_participants_infos'), 'infos', "35%");
46  $this->addColumn($this->lng->txt('ecs_tbl_export'), 'export', '5%');
47  $this->addColumn($this->lng->txt('ecs_tbl_import'), 'import', '5%');
48  $this->addColumn($this->lng->txt('ecs_tbl_import_type'), 'type', '10%');
49 
50  if ($this->access->checkAccess('write', '', (int) $_REQUEST["ref_id"])) {
51  $this->addColumn('', 'actions', '10%');
52  }
53 
54  $this->disable('form');
55  $this->setRowTemplate("tpl.participant_row.html", "Services/WebServices/ECS");
56  $this->setDefaultOrderField('participants');
57  $this->setDefaultOrderDirection("desc");
58 
59  $this->server = $set;
60  }
61 
65  public function getServer(): ilECSSetting
66  {
67  return $this->server;
68  }
69 
75  protected function fillRow(array $a_set): void
76  {
77  $this->tpl->setVariable('S_ID', $this->getServer()->getServerId());
78  $this->tpl->setVariable('M_ID', $a_set['mid']);
79  $this->tpl->setVariable('VAL_ID', $this->getServer()->getServerId() . '_' . $a_set['mid']);
80  $this->tpl->setVariable('VAL_ORG', (string) $a_set['org']);
81  $this->tpl->setVariable('VAL_TITLE', $a_set['participants']);
82  $this->tpl->setVariable('VAL_DESC', $a_set['description']);
83  $this->tpl->setVariable('VAL_EMAIL', $a_set['email']);
84  $this->tpl->setVariable('VAL_DNS', $a_set['dns']);
85  $this->tpl->setVariable('VAL_ABR', $a_set['abr']);
86  $this->tpl->setVariable('TXT_EMAIL', $this->lng->txt('ecs_email'));
87  $this->tpl->setVariable('TXT_DNS', $this->lng->txt('ecs_dns'));
88  $this->tpl->setVariable('TXT_ABR', $this->lng->txt('ecs_abr'));
89  $this->tpl->setVariable('TXT_ID', $this->lng->txt('ecs_unique_id'));
90  $this->tpl->setVariable('TXT_ORG', $this->lng->txt('organization'));
91 
92  $part = new ilECSParticipantSetting($this->getServer()->getServerId(), $a_set['mid']);
93 
94 
95  if ($part->isExportEnabled()) {
96  foreach ($part->getExportTypes() as $obj_type) {
97  $this->tpl->setCurrentBlock('obj_erow');
98  $this->tpl->setVariable('TXT_OBJ_EINFO', $this->lng->txt('objs_' . $obj_type));
99  $this->tpl->parseCurrentBlock();
100  }
101  } else {
102  $this->lng->loadLanguageModule('administration');
103  $this->tpl->setVariable('TXT_OBJ_EINFO', $this->lng->txt('disabled'));
104  }
105 
106  if ($part->isImportEnabled()) {
107  foreach ($part->getImportTypes() as $obj_type) {
108  $this->tpl->setCurrentBlock('obj_irow');
109  $this->tpl->setVariable('TXT_OBJ_IINFO', $this->lng->txt('objs_' . $obj_type));
110  $this->tpl->parseCurrentBlock();
111  }
112  } else {
113  $this->lng->loadLanguageModule('administration');
114  $this->tpl->setVariable('TXT_OBJ_IINFO', $this->lng->txt('disabled'));
115  }
116  // :TODO: what types are to be supported?
118  $part->getImportType(),
119  'import_type[' . $this->getServer()->getServerId() . '][' . $a_set['mid'] . ']',
120  array(
121  ilECSParticipantSetting::IMPORT_RCRS => $this->lng->txt('obj_rcrs'),
122  ilECSParticipantSetting::IMPORT_CRS => $this->lng->txt('obj_crs'),
123  ilECSParticipantSetting::IMPORT_CMS => $this->lng->txt('ecs_import_cms')
124  ),
125  false,
126  true
127  );
128  $this->tpl->setVariable('IMPORT_SEL', $sel);
129 
130  $items = [];
131  $this->ctrl->setParameter($this->getParentObject(), 'server_id', $this->getServer()->getServerId());
132  $this->ctrl->setParameter($this->getParentObject(), 'mid', $a_set['mid']);
133  $items[] = [ $this->lng->txt('edit'),
134  $this->ctrl->getLinkTargetByClass('ilecsparticipantsettingsgui', 'settings')
135  ];
136 
137  switch ($part->getImportType()) {
139  // Do nothing
140  break;
141 
143  // Possible action => Edit course allocation
144  $this->ctrl->setParameter($this->getParentObject(), 'server_id', $this->getServer()->getServerId());
145  $this->ctrl->setParameter($this->getParentObject(), 'mid', $a_set['mid']);
146  $items[] = [
147  $this->lng->txt('ecs_crs_alloc_set'),
148  $this->ctrl->getLinkTargetByClass('ilecsmappingsettingsgui', 'cStart')
149  ];
150  break;
151 
153 
154  $this->ctrl->setParameter($this->getParentObject(), 'server_id', $this->getServer()->getServerId());
155  $this->ctrl->setParameter($this->getParentObject(), 'mid', $a_set['mid']);
156  // Possible action => Edit course allocation, edit node mapping
157  $items[] = [
158  $this->lng->txt('ecs_dir_alloc_set'),
159  $this->ctrl->getLinkTargetByClass('ilecsmappingsettingsgui', 'dStart')
160  ];
161  $items[] = [
162  $this->lng->txt('ecs_crs_alloc_set'),
163  $this->ctrl->getLinkTargetByClass('ilecsmappingsettingsgui', 'cStart')
164  ];
165  break;
166  }
167 
168  if ($this->access->checkAccess('write', '', (int) $_REQUEST["ref_id"])) {
169  $this->tpl->setCurrentBlock("actions");
170  $render_items = [];
171  foreach ($items as $item) {
172  $render_items[] = $this->ui_factory->button()->shy(...$item);
173  }
174  $this->tpl->setVariable('ACTIONS', $this->ui_renderer->render($this->ui_factory->dropdown()->standard($render_items)->withLabel($this->lng->txt('actions'))));
175  $this->tpl->parseCurrentBlock();
176  }
177  }
178 
182  public function parse(array $participants): void
183  {
184  foreach ($participants as $participant) {
185  $tmp_arr['mid'] = $participant->getMID();
186  $tmp_arr['participants'] = $participant->getParticipantName();
187  $tmp_arr['description'] = $participant->getDescription();
188  $tmp_arr['email'] = $participant->getEmail();
189  $tmp_arr['dns'] = $participant->getDNS();
190 
191  if ($participant->getOrganisation() instanceof ilECSOrganisation) {
192  $tmp_arr['abr'] = $participant->getOrganisation()->getAbbreviation();
193  $tmp_arr['org'] = $participant->getOrganisation()->getName();
194  }
195  $def[] = $tmp_arr;
196  }
197 
198  $this->setData($def ?? []);
199  }
200 }
setData(array $a_data)
getServerId()
Get current server id.
static formSelect( $selected, string $varname, array $options, bool $multiple=false, bool $direct_text=false, int $size=0, string $style_class="", array $attribs=[], bool $disabled=false)
Builds a select form field with options and shows the selected option first.
setId(string $a_val)
global $DIC
Definition: feed.php:28
__construct(VocabulariesInterface $vocabularies)
setDefaultOrderField(string $a_defaultorderfield)
__construct(ilECSSetting $set, ?object $a_parent_obj, string $a_parent_cmd, int $cid)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setDefaultOrderDirection(string $a_defaultorderdirection)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
disable(string $a_module_name)