ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilSamlIdpTableGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
25 final class ilSamlIdpTableGUI extends ilTable2GUI
26 {
27  public function __construct(
28  ilSamlSettingsGUI $parent_gui,
29  private readonly \ILIAS\UI\Factory $ui_factory,
30  private readonly \ILIAS\UI\Renderer $ui_renderer,
31  string $parent_cmd,
32  private readonly bool $hasWriteAccess
33  ) {
34  $this->setId('saml_idp_list');
35  parent::__construct($parent_gui, $parent_cmd);
36 
37  $this->setTitle($this->lng->txt('auth_saml_idps'));
38 
39  $federationMdUrl = rtrim(ILIAS_HTTP_PATH, '/') . '/Services/Saml/lib/metadata.php?client_id=' . CLIENT_ID;
40 
41  $this->setDescription(sprintf(
42  $this->lng->txt('auth_saml_idps_info'),
43  'auth/saml/config/config.php',
44  'auth/saml/config/authsources.php',
45  $this->ui_renderer->render($this->ui_factory->link()->standard(
46  'https://simplesamlphp.org/docs/stable/simplesamlphp-sp',
47  'https://simplesamlphp.org/docs/stable/simplesamlphp-sp'
48  )),
49  $this->ui_renderer->render($this->ui_factory->link()->standard($federationMdUrl, $federationMdUrl))
50  ));
51  $this->setRowTemplate('tpl.saml_idp_row.html', 'Services/Saml');
52 
53  $this->addColumn($this->lng->txt('saml_tab_head_idp'), '', '80%');
54  $this->addColumn($this->lng->txt('active'), '', '5%');
55  $this->addColumn($this->lng->txt('actions'), '', '15%');
56 
57  $this->getItems();
58  }
59 
60  private function getItems(): void
61  {
62  $idp_data = [];
63 
64  foreach (ilSamlIdp::getAllIdps() as $idp) {
65  $idp_data[] = $idp->toArray();
66  }
67 
68  $this->setData($idp_data);
69  }
70 
71  protected function fillRow(array $a_set): void
72  {
73  if ($a_set['is_active']) {
74  $this->tpl->setVariable('IMAGE_OK', ilUtil::getImagePath('standard/icon_ok.svg'));
75  $this->tpl->setVariable('TXT_OK', $this->lng->txt('active'));
76  } else {
77  $this->tpl->setVariable('IMAGE_OK', ilUtil::getImagePath('standard/icon_not_ok.svg'));
78  $this->tpl->setVariable('TXT_OK', $this->lng->txt('inactive'));
79  }
80 
81  $this->tpl->setVariable('NAME', $a_set['entity_id']);
82 
83  if ($this->hasWriteAccess) {
84  $buttons = [];
85 
86  $this->ctrl->setParameter($this->getParentObject(), 'saml_idp_id', $a_set['idp_id']);
87  $buttons[] = $this->ui_factory
88  ->button()
89  ->shy(
90  $this->lng->txt('edit'),
91  $this->ctrl->getLinkTarget($this->getParentObject(), 'showIdpSettings')
92  );
93  if ($a_set['is_active']) {
94  $buttons[] = $this->ui_factory
95  ->button()
96  ->shy(
97  $this->lng->txt('deactivate'),
98  $this->ctrl->getLinkTarget($this->getParentObject(), 'deactivateIdp')
99  );
100  } else {
101  $buttons[] = $this->ui_factory
102  ->button()
103  ->shy(
104  $this->lng->txt('activate'),
105  $this->ctrl->getLinkTarget($this->getParentObject(), 'activateIdp')
106  );
107  }
108  $buttons[] = $this->ui_factory
109  ->button()
110  ->shy(
111  $this->lng->txt('delete'),
112  $this->ctrl->getLinkTarget($this->getParentObject(), 'confirmDeleteIdp')
113  );
114  $this->ctrl->setParameter($this->getParentObject(), 'saml_idp_id', '');
115 
116  $drop_down = $this->ui_factory
117  ->dropdown()
118  ->standard($buttons)
119  ->withLabel($this->lng->txt('actions'));
120 
121  $this->tpl->setVariable('ACTIONS', $this->ui_renderer->render($drop_down));
122  }
123  }
124 }
Class ilSamlIdpTableGUI.
setData(array $a_data)
Class ChatMainBarProvider .
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
__construct(ilSamlSettingsGUI $parent_gui, private readonly \ILIAS\UI\Factory $ui_factory, private readonly \ILIAS\UI\Renderer $ui_renderer, string $parent_cmd, private readonly bool $hasWriteAccess)
setDescription(string $a_val)
setId(string $a_val)
__construct(VocabulariesInterface $vocabularies)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
const CLIENT_ID
Definition: constants.php:41
static getAllIdps()
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
Class ilSamlSettingsGUI.
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)