From 3e02d5aff85babc3ffbfcf52313f2108e313aa23 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 13 Apr 2024 13:46:43 +0200 Subject: Adding upstream version 2.12.1. Signed-off-by: Daniel Baumann --- library/Icinga/Web/RememberMeUserList.php | 106 ++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 library/Icinga/Web/RememberMeUserList.php (limited to 'library/Icinga/Web/RememberMeUserList.php') diff --git a/library/Icinga/Web/RememberMeUserList.php b/library/Icinga/Web/RememberMeUserList.php new file mode 100644 index 0000000..bb95dc9 --- /dev/null +++ b/library/Icinga/Web/RememberMeUserList.php @@ -0,0 +1,106 @@ + 'common-table table-row-selectable', + 'data-base-target' => '_next', + ]; + + /** + * @var array + */ + protected $users; + + /** + * @var string + */ + protected $url; + + /** + * @return string + */ + public function getUrl() + { + return $this->url; + } + + /** + * @param string $url + * + * @return $this + */ + public function setUrl($url) + { + $this->url = $url; + + return $this; + } + + /** + * @return array + */ + public function getUsers() + { + return $this->users; + } + + /** + * @param array $users + * + * @return $this + */ + public function setUsers($users) + { + $this->users = $users; + + return $this; + } + + protected function assemble() + { + $thead = Html::tag('thead'); + $theadRow = Html::tag('tr') + ->add(Html::tag( + 'th', + t('List of users who stay logged in') + )); + + $thead->add($theadRow); + $tbody = Html::tag('tbody'); + + if (empty($this->getUsers())) { + $tbody->add(Html::tag('td', t('No user found'))); + } else { + foreach ($this->getUsers() as $user) { + $element = Html::tag('tr'); + $link = new Link( + $user->username, + iplWebUrl::fromPath($this->getUrl())->addParams(['name' => $user->username]), + ['title' => sprintf(t('Device list of %s'), $user->username)] + ); + + $element->add(Html::tag('td', $link)); + $tbody->add($element); + } + } + + $this->add($thead); + $this->add($tbody); + } +} -- cgit v1.2.3