Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
gruberroland committed Sep 3, 2024
1 parent dd2e023 commit 5871475
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions lam/lib/modules/ldapPublicKey.inc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

use \LAM\PDF\PDFTable;
use \LAM\PDF\PDFTableCell;
use \LAM\PDF\PDFTableRow;
use LAM\PDF\PDFTable;
use LAM\PDF\PDFTableCell;
use LAM\PDF\PDFTableRow;
use LAM\TYPES\ConfiguredType;

/*
Expand Down Expand Up @@ -41,7 +41,7 @@ use LAM\TYPES\ConfiguredType;
class ldapPublicKey extends baseModule {

/** session variable for existing keys in self service */
const SESS_KEY_LIST = 'ldapPublicKey_keyList';
private const SESS_KEY_LIST = 'ldapPublicKey_keyList';

/**
* Creates a new ldapPublicKey object.
Expand Down Expand Up @@ -87,7 +87,7 @@ class ldapPublicKey extends baseModule {
* @return boolean true if module fits
*/
public function can_manage() {
return in_array($this->get_scope(), ['user']);
return $this->get_scope() === 'user';
}

/**
Expand Down Expand Up @@ -133,7 +133,7 @@ class ldapPublicKey extends baseModule {
// profile options
if ($this->hasObjectClass()) {
$profileContainer = new htmlResponsiveRow();
$profileContainer->add(new htmlResponsiveInputCheckbox(static::class . '_addExt', false, _('Automatically add this extension'), 'autoAdd'), 12);
$profileContainer->add(new htmlResponsiveInputCheckbox(static::class . '_addExt', false, _('Automatically add this extension'), 'autoAdd'));
$return['profile_options'] = $profileContainer;
}
// upload fields
Expand Down Expand Up @@ -252,7 +252,7 @@ class ldapPublicKey extends baseModule {
$data = str_replace("\r", "\n", $data);
$lines = explode("\n", $data);
foreach ($lines as $line) {
if (!empty($line) && !(strpos($line, '#') === 0)) {
if (!empty($line) && !(str_starts_with($line, '#'))) {
$this->attributes[$this->getAttributeName()][] = $line;
}
}
Expand Down Expand Up @@ -380,9 +380,9 @@ class ldapPublicKey extends baseModule {
* Returns the meta HTML code to display the key area.
* This also includes the file upload.
*
* @return htmlTable key content
* @return htmlResponsiveRow key content
*/
private function getSelfServiceKeys() {
private function getSelfServiceKeys(): htmlResponsiveRow {
$keys = $_SESSION[self::SESS_KEY_LIST];
$content = new htmlResponsiveRow();
if (sizeof($keys) > 0) {
Expand All @@ -408,7 +408,7 @@ class ldapPublicKey extends baseModule {
$addLink = new htmlLink('', '#', '../../graphics/add.svg');
$addLink->setTitle(_('Add'));
$addLink->setOnClick('ldapPublicKeyAddKey(' . sizeof($keys) . ');return false;');
$content->add($addLink, 12);
$content->add($addLink);
}
// upload button
$uploadButtonGroup = new htmlGroup();
Expand Down Expand Up @@ -673,7 +673,7 @@ class ldapPublicKey extends baseModule {
$data = str_replace("\r", "\n", $data);
$lines = explode("\n", $data);
foreach ($lines as $line) {
if (!empty($line) && !(strpos($line, '#') === 0)) {
if (!empty($line) && !(str_starts_with($line, '#'))) {
$_SESSION[self::SESS_KEY_LIST][] = $line;
}
}
Expand Down

0 comments on commit 5871475

Please sign in to comment.