ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilLDAPServerTableGUI.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
25 {
27  private int $ref_id = 0 ;
28  private \ILIAS\UI\Factory $ui_factory;
29  private \ILIAS\UI\Renderer $ui_renderer;
30 
31  public function __construct(?object $a_parent_obj, string $a_parent_cmd = "", string $a_template_context = "")
32  {
33  parent::__construct($a_parent_obj, $a_parent_cmd, $a_template_context);
34 
35  global $DIC;
36  $this->rbacSystem = $DIC->rbac()->system();
37  $this->ui_factory = $DIC->ui()->factory();
38  $this->ui_renderer = $DIC->ui()->renderer();
39 
40  $http_wrapper = $DIC->http()->wrapper();
41  $refinery = $DIC->refinery();
42  if ($http_wrapper->query()->has('ref_id')) {
43  $this->ref_id = (int) $http_wrapper->query()->retrieve(
44  'ref_id',
45  $refinery->kindlyTo()->int()
46  );
47  }
48  $this->setId('ldap_server_list');
49 
50  $this->setTitle($this->lng->txt('ldap_servers'));
51  $this->setRowTemplate('tpl.ldap_server_row.html', 'Services/LDAP');
52 
53  $this->addColumn($this->lng->txt('active'), '', '1%');
54  $this->addColumn($this->lng->txt('title'), '', '80%');
55  $this->addColumn($this->lng->txt('user'), "", "4%");
56  $this->addColumn($this->lng->txt('actions'), '', '15%');
57 
58  $this->importData();
59  }
60 
61  private function importData(): void
62  {
64  $this->setData($data);
65  }
66 
70  protected function fillRow(array $a_set): void
71  {
72  if ($a_set['active']) {
73  $this->tpl->setVariable('IMAGE_OK', ilUtil::getImagePath('standard/icon_ok.svg'));
74  $this->tpl->setVariable('TXT_OK', $this->lng->txt('active'));
75  } else {
76  $this->tpl->setVariable('IMAGE_OK', ilUtil::getImagePath('standard/icon_not_ok.svg'));
77  $this->tpl->setVariable('TXT_OK', $this->lng->txt('inactive'));
78  }
79 
80  $this->tpl->setVariable('VAL_TITLE', $a_set["name"]);
81 
82  //user
83  $user = count(ilObjUser::_getExternalAccountsByAuthMode("ldap_" . $a_set["server_id"]));
84  $this->tpl->setVariable('VAL_USER', $user);
85 
86  $this->ctrl->setParameter($this->getParentObject(), 'ldap_server_id', $a_set['server_id']);
87  $this->tpl->setVariable('EDIT_LINK', $this->ctrl->getLinkTarget($this->getParentObject(), 'editServerSettings'));
88 
89  //actions
90  if ($this->rbacSystem->checkAccess("write", $this->ref_id)) {
91  $dropdown_elements = [];
92 
93  $dropdown_elements[] = $this->ui_factory->link()->standard(
94  $this->lng->txt('edit'),
95  $this->ctrl->getLinkTarget($this->getParentObject(), 'editServerSettings')
96  );
97 
98  if ($a_set['active']) {
99  $dropdown_elements[] = $this->ui_factory->link()->standard(
100  $this->lng->txt('deactivate'),
101  $this->ctrl->getLinkTarget($this->getParentObject(), 'deactivateServer')
102  );
103  } else {
104  $dropdown_elements[] = $this->ui_factory->link()->standard(
105  $this->lng->txt('activate'),
106  $this->ctrl->getLinkTarget($this->getParentObject(), 'activateServer')
107  );
108  }
109 
110  $dropdown_elements[] = $this->ui_factory->link()->standard(
111  $this->lng->txt('delete'),
112  $this->ctrl->getLinkTarget($this->getParentObject(), 'confirmDeleteServerSettings')
113  );
114 
115  $dropdown = $this->ui_factory->dropdown()->standard([
116  $dropdown_elements
117  ])->withLabel($this->lng->txt('actions'));
118 
119  $this->tpl->setVariable('ACTIONS', $this->ui_renderer->render($dropdown));
120  }
121  }
122 }
setData(array $a_data)
__construct(?object $a_parent_obj, string $a_parent_cmd="", string $a_template_context="")
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static _getAllServer()
Get list of all configured servers.
setId(string $a_val)
global $DIC
Definition: feed.php:28
static _getExternalAccountsByAuthMode(string $a_auth_mode, bool $a_read_auth_default=false)
Get list of external account by authentication method Note: If login == ext_account for two user with...
__construct(VocabulariesInterface $vocabularies)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
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)
Refinery Factory $refinery