ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilECSCommunityTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25{
28
29 private \ILIAS\UI\Factory $ui_factory;
30 private \ILIAS\UI\Renderer $ui_renderer;
31
32 public function __construct(ilECSSetting $set, ?object $a_parent_obj, string $a_parent_cmd, int $cid)
33 {
34 parent::__construct($a_parent_obj, $a_parent_cmd);
35
36 global $DIC;
37
38 $this->access = $DIC->access();
39 $this->ui_factory = $DIC->ui()->factory();
40 $this->ui_renderer = $DIC->ui()->renderer();
41
42 // TODO: set id
43 $this->setId($set->getServerId() . '_' . $cid . '_' . 'community_table');
44
45 $this->addColumn($this->lng->txt('ecs_participants'), 'participants', "35%");
46 $this->addColumn($this->lng->txt('ecs_participants_infos'), 'infos', "35%");
47 $this->addColumn($this->lng->txt('ecs_tbl_export'), 'export', '5%');
48 $this->addColumn($this->lng->txt('ecs_tbl_import'), 'import', '5%');
49 $this->addColumn($this->lng->txt('ecs_tbl_import_type'), 'type', '10%');
50
51 if ($this->access->checkAccess('write', '', (int) $_REQUEST["ref_id"])) {
52 $this->addColumn('', 'actions', '10%');
53 }
54
55 $this->disable('form');
56 $this->setRowTemplate("tpl.participant_row.html", "components/ILIAS/WebServices/ECS");
57 $this->setDefaultOrderField('participants');
58 $this->setDefaultOrderDirection("desc");
59
60 $this->server = $set;
61 }
62
66 public function getServer(): ilECSSetting
67 {
68 return $this->server;
69 }
70
76 protected function fillRow(array $a_set): void
77 {
78 $this->tpl->setVariable('S_ID', $this->getServer()->getServerId());
79 $this->tpl->setVariable('M_ID', $a_set['mid']);
80 $this->tpl->setVariable('VAL_ID', $this->getServer()->getServerId() . '_' . $a_set['mid']);
81 $this->tpl->setVariable('VAL_ORG', (string) $a_set['org']);
82 $this->tpl->setVariable('VAL_TITLE', $a_set['participants']);
83 $this->tpl->setVariable('VAL_DESC', $a_set['description']);
84 $this->tpl->setVariable('VAL_EMAIL', $a_set['email']);
85 $this->tpl->setVariable('VAL_DNS', $a_set['dns']);
86 $this->tpl->setVariable('VAL_ABR', $a_set['abr']);
87 $this->tpl->setVariable('TXT_EMAIL', $this->lng->txt('ecs_email'));
88 $this->tpl->setVariable('TXT_DNS', $this->lng->txt('ecs_dns'));
89 $this->tpl->setVariable('TXT_ABR', $this->lng->txt('ecs_abr'));
90 $this->tpl->setVariable('TXT_ID', $this->lng->txt('ecs_unique_id'));
91 $this->tpl->setVariable('TXT_ORG', $this->lng->txt('organization'));
92
93 $part = new ilECSParticipantSetting($this->getServer()->getServerId(), $a_set['mid']);
94
95
96 if ($part->isExportEnabled()) {
97 foreach ($part->getExportTypes() as $obj_type) {
98 $this->tpl->setCurrentBlock('obj_erow');
99 $this->tpl->setVariable('TXT_OBJ_EINFO', $this->lng->txt('objs_' . $obj_type));
100 $this->tpl->parseCurrentBlock();
101 }
102 } else {
103 $this->lng->loadLanguageModule('administration');
104 $this->tpl->setVariable('TXT_OBJ_EINFO', $this->lng->txt('disabled'));
105 }
106
107 if ($part->isImportEnabled()) {
108 foreach ($part->getImportTypes() as $obj_type) {
109 $this->tpl->setCurrentBlock('obj_irow');
110 $this->tpl->setVariable('TXT_OBJ_IINFO', $this->lng->txt('objs_' . $obj_type));
111 $this->tpl->parseCurrentBlock();
112 }
113 } else {
114 $this->lng->loadLanguageModule('administration');
115 $this->tpl->setVariable('TXT_OBJ_IINFO', $this->lng->txt('disabled'));
116 }
117 // :TODO: what types are to be supported?
119 $part->getImportType(),
120 'import_type[' . $this->getServer()->getServerId() . '][' . $a_set['mid'] . ']',
121 array(
122 ilECSParticipantSetting::IMPORT_RCRS => $this->lng->txt('obj_rcrs'),
123 ilECSParticipantSetting::IMPORT_CRS => $this->lng->txt('obj_crs'),
124 ilECSParticipantSetting::IMPORT_CMS => $this->lng->txt('ecs_import_cms')
125 ),
126 false,
127 true
128 );
129 $this->tpl->setVariable('IMPORT_SEL', $sel);
130
131 $items = [];
132 $this->ctrl->setParameter($this->getParentObject(), 'server_id', $this->getServer()->getServerId());
133 $this->ctrl->setParameter($this->getParentObject(), 'mid', $a_set['mid']);
134 $items[] = [ $this->lng->txt('edit'),
135 $this->ctrl->getLinkTargetByClass('ilecsparticipantsettingsgui', 'settings')
136 ];
137
138 switch ($part->getImportType()) {
140 // Do nothing
141 break;
142
144 // Possible action => Edit course allocation
145 $this->ctrl->setParameter($this->getParentObject(), 'server_id', $this->getServer()->getServerId());
146 $this->ctrl->setParameter($this->getParentObject(), 'mid', $a_set['mid']);
147 $items[] = [
148 $this->lng->txt('ecs_crs_alloc_set'),
149 $this->ctrl->getLinkTargetByClass('ilecsmappingsettingsgui', 'cStart')
150 ];
151 break;
152
154
155 $this->ctrl->setParameter($this->getParentObject(), 'server_id', $this->getServer()->getServerId());
156 $this->ctrl->setParameter($this->getParentObject(), 'mid', $a_set['mid']);
157 // Possible action => Edit course allocation, edit node mapping
158 $items[] = [
159 $this->lng->txt('ecs_dir_alloc_set'),
160 $this->ctrl->getLinkTargetByClass('ilecsmappingsettingsgui', 'dStart')
161 ];
162 $items[] = [
163 $this->lng->txt('ecs_crs_alloc_set'),
164 $this->ctrl->getLinkTargetByClass('ilecsmappingsettingsgui', 'cStart')
165 ];
166 break;
167 }
168
169 if ($this->access->checkAccess('write', '', (int) $_REQUEST["ref_id"])) {
170 $this->tpl->setCurrentBlock("actions");
171 $render_items = [];
172 foreach ($items as $item) {
173 $render_items[] = $this->ui_factory->button()->shy(...$item);
174 }
175 $this->tpl->setVariable('ACTIONS', $this->ui_renderer->render($this->ui_factory->dropdown()->standard($render_items)->withLabel($this->lng->txt('actions'))));
176 $this->tpl->parseCurrentBlock();
177 }
178 }
179
183 public function parse(array $participants): void
184 {
185 foreach ($participants as $participant) {
186 $tmp_arr['mid'] = $participant->getMID();
187 $tmp_arr['participants'] = $participant->getParticipantName();
188 $tmp_arr['description'] = $participant->getDescription();
189 $tmp_arr['email'] = $participant->getEmail();
190 $tmp_arr['dns'] = $participant->getDNS();
191
192 if ($participant->getOrganisation() instanceof ilECSOrganisation) {
193 $tmp_arr['abr'] = $participant->getOrganisation()->getAbbreviation();
194 $tmp_arr['org'] = $participant->getOrganisation()->getName();
195 }
196 $def[] = $tmp_arr;
197 }
198
199 $this->setData($def ?? []);
200 }
201}
__construct(ilECSSetting $set, ?object $a_parent_obj, string $a_parent_cmd, int $cid)
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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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)
setDefaultOrderField(string $a_defaultorderfield)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setDefaultOrderDirection(string $a_defaultorderdirection)
setData(array $a_data)
Set table data.
disable(string $a_module_name)
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26