Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
gruberroland committed Aug 21, 2024
1 parent 8c67dbc commit f84c33a
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 37 deletions.
40 changes: 20 additions & 20 deletions lam/lib/modules/posixAccount.inc
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,10 @@ class posixAccount extends baseModule implements passwordService, AccountStatusP
// self service configuration settings
$selfServiceContainer = new htmlResponsiveRow();
$selfServiceContainer->add(new htmlResponsiveSelect('posixAccount_pwdHash', getSupportedHashTypes(),
['CRYPT-SHA512'], _("Password hash type"), ['pwdHash', get_class($this)]), 12);
$selfServiceContainer->add(new htmlResponsiveInputTextarea('posixAccount_shells', implode("\r\n", $this->getShells()), 30, 4, _('Login shells'), ['loginShells', get_class($this)]), 12);
$selfServiceContainer->add(new htmlResponsiveInputField(_('Group DN'), 'posixAccount_groupDn', '', ['groupDn', get_class($this)]), 12);
$selfServiceContainer->add(new htmlResponsiveInputCheckbox('posixAccount_useOldPwd', false, _('Password change with old password'), ['useOldPwd', get_class($this)]), 12);
['CRYPT-SHA512'], _("Password hash type"), ['pwdHash', static::class]), 12);
$selfServiceContainer->add(new htmlResponsiveInputTextarea('posixAccount_shells', implode("\r\n", $this->getShells()), 30, 4, _('Login shells'), ['loginShells', static::class]), 12);
$selfServiceContainer->add(new htmlResponsiveInputField(_('Group DN'), 'posixAccount_groupDn', '', ['groupDn', static::class]), 12);
$selfServiceContainer->add(new htmlResponsiveInputCheckbox('posixAccount_useOldPwd', false, _('Password change with old password'), ['useOldPwd', static::class]), 12);
$return['selfServiceSettings'] = $selfServiceContainer;
}
// profile checks
Expand Down Expand Up @@ -1641,7 +1641,7 @@ class posixAccount extends baseModule implements passwordService, AccountStatusP
$modules = $this->getAccountContainer()->get_type()->getModules();
$homeDirAttr = $this->getHomedirAttrName($modules);
for ($i = 0; $i < sizeof($lamdaemonServers); $i++) {
if (isset($_POST['form_subpage_' . get_class($this) . '_homedir_create_' . $i])) {
if (isset($_POST['form_subpage_' . static::class . '_homedir_create_' . $i])) {
$remote = new \LAM\REMOTE\Remote();
try {
$remote->connect($lamdaemonServers[$i]);
Expand All @@ -1662,7 +1662,7 @@ class posixAccount extends baseModule implements passwordService, AccountStatusP
}
}
}
elseif (isset($_POST['form_subpage_' . get_class($this) . '_homedir_delete_' . $i])) {
elseif (isset($_POST['form_subpage_' . static::class . '_homedir_delete_' . $i])) {
$remote = new \LAM\REMOTE\Remote();
try {
$remote->connect($lamdaemonServers[$i]);
Expand Down Expand Up @@ -1826,7 +1826,7 @@ class posixAccount extends baseModule implements passwordService, AccountStatusP
if (!$this->isBooleanConfigOptionSet('posixAccount_' . $typeId . '_hidegon') || !$this->isBooleanConfigOptionSet('posixAccount_' . $typeId . '_hideposixGroups')) {
$return->addLabel(new htmlOutputText(_('Additional groups')));
$additionalGroups = new htmlGroup();
$additionalGroups->addElement(new htmlAccountPageButton(get_class($this), 'group', 'open', _('Edit groups')));
$additionalGroups->addElement(new htmlAccountPageButton(static::class, 'group', 'open', _('Edit groups')));
$additionalGroups->addElement(new htmlHelpLink('addgroup'));
$return->addField($additionalGroups);
}
Expand Down Expand Up @@ -1857,7 +1857,7 @@ class posixAccount extends baseModule implements passwordService, AccountStatusP
}
else {
$return->addLabel(new htmlOutputText('&nbsp;', false));
$return->addField(new htmlAccountPageButton(get_class($this), 'homedir', 'open', _('Check home directories')));
$return->addField(new htmlAccountPageButton(static::class, 'homedir', 'open', _('Check home directories')));
}
}
$selectedShell = [];
Expand Down Expand Up @@ -2023,10 +2023,10 @@ class posixAccount extends baseModule implements passwordService, AccountStatusP
$return->addVerticalSpacer('1rem');
if ($showGonSync) {
$syncButtons = new htmlGroup();
$u2gonButton = new htmlAccountPageButton(get_class($this), 'group', 'syncU2GON', _('Sync Unix to group of names'));
$u2gonButton = new htmlAccountPageButton(static::class, 'group', 'syncU2GON', _('Sync Unix to group of names'));
$syncButtons->addElement($u2gonButton);
$syncButtons->addElement(new htmlSpacer('2rem', null));
$gon2uButton = new htmlAccountPageButton(get_class($this), 'group', 'syncGON2U', _('Sync group of names to Unix'));
$gon2uButton = new htmlAccountPageButton(static::class, 'group', 'syncGON2U', _('Sync group of names to Unix'));
$syncButtons->addElement($gon2uButton);
$return->add($syncButtons, 12, 12, 12, 'text-center');
if ($showWindowsSync) {
Expand All @@ -2035,14 +2035,14 @@ class posixAccount extends baseModule implements passwordService, AccountStatusP
}
if ($showWindowsSync) {
$syncButtons = new htmlGroup();
$gon2uButton = new htmlAccountPageButton(get_class($this), 'group', 'syncWin2U', _('Sync Windows to Unix'));
$gon2uButton = new htmlAccountPageButton(static::class, 'group', 'syncWin2U', _('Sync Windows to Unix'));
$syncButtons->addElement($gon2uButton);
$return->add($syncButtons, 12, 12, 12, 'text-center');
}
}

$return->addVerticalSpacer('2rem');
$backButton = new htmlAccountPageButton(get_class($this), 'attributes', 'back', _('Back'));
$backButton = new htmlAccountPageButton(static::class, 'attributes', 'back', _('Back'));
$return->add($backButton, 12);
return $return;
}
Expand Down Expand Up @@ -2089,15 +2089,15 @@ class posixAccount extends baseModule implements passwordService, AccountStatusP
$okGroup = new htmlGroup();
$okGroup->addElement(new htmlImage('../../graphics/pass.svg', 16, 16));
$okGroup->addElement(new htmlSpacer('5px', null));
$okGroup->addElement(new htmlAccountPageButton(get_class($this), 'homedir', 'delete_' . $i, _('Delete')));
$okGroup->addElement(new htmlAccountPageButton(static::class, 'homedir', 'delete_' . $i, _('Delete')));
$return->addField($okGroup);
}
elseif ($returnValue == 'missing') {
$return->addLabel(new htmlOutputText($label));
$failGroup = new htmlGroup();
$failGroup->addElement(new htmlImage('../../graphics/del.svg', 16, 16));
$failGroup->addElement(new htmlSpacer('5px', null));
$failGroup->addElement(new htmlAccountPageButton(get_class($this), 'homedir', 'create_' . $i, _('Create')));
$failGroup->addElement(new htmlAccountPageButton(static::class, 'homedir', 'create_' . $i, _('Create')));
$return->addField($failGroup);
}
elseif (trim($returnValue) != '') {
Expand All @@ -2116,7 +2116,7 @@ class posixAccount extends baseModule implements passwordService, AccountStatusP
}
}
$return->addVerticalSpacer('2rem');
$return->add(new htmlAccountPageButton(get_class($this), 'attributes', 'back', _('Back')), 12, 12, 12, 'text-center');
$return->add(new htmlAccountPageButton(static::class, 'attributes', 'back', _('Back')), 12, 12, 12, 'text-center');
return $return;
}

Expand Down Expand Up @@ -2335,11 +2335,11 @@ class posixAccount extends baseModule implements passwordService, AccountStatusP
// user options
$configUserContainer = new htmlResponsiveRow();
$configUserContainer->add(new htmlSubTitle(_("Users")), 12);
foreach ($allScopes[get_class($this)] as $typeId) {
foreach ($allScopes[static::class] as $typeId) {
if (!(getScopeFromTypeId($typeId) === 'user')) {
continue;
}
if (sizeof($allScopes[get_class($this)]) > 1) {
if (sizeof($allScopes[static::class]) > 1) {
$title = new htmlDiv(null, new htmlOutputText($typeManager->getConfiguredType($typeId)->getAlias()));
$title->setCSSClasses(['bold', 'responsiveLabel']);
$configUserContainer->add($title, 12, 6);
Expand Down Expand Up @@ -2406,11 +2406,11 @@ class posixAccount extends baseModule implements passwordService, AccountStatusP
if ($hasHostConfig) {
$configHostContainer = new htmlResponsiveRow();
$configHostContainer->add(new htmlSubTitle(_("Hosts")), 12);
foreach ($allScopes[get_class($this)] as $typeId) {
foreach ($allScopes[static::class] as $typeId) {
if (!(getScopeFromTypeId($typeId) === 'host')) {
continue;
}
if (sizeof($allScopes[get_class($this)]) > 1) {
if (sizeof($allScopes[static::class]) > 1) {
$title = new htmlDiv(null, new htmlOutputText($typeManager->getConfiguredType($typeId)->getAlias()));
$title->setCSSClasses(['bold', 'responsiveLabel']);
$configHostContainer->add($title, 12, 6);
Expand Down Expand Up @@ -3564,7 +3564,7 @@ class posixAccount extends baseModule implements passwordService, AccountStatusP
* @see passwordService::passwordChangeRequested
*/
public function passwordChangeRequested($password, $modules, $forcePasswordChange) {
if (!in_array(get_class($this), $modules)) {
if (!in_array(static::class, $modules)) {
return [];
}
$accountModules = $this->getAccountContainer()->get_type()->getModules();
Expand Down
12 changes: 6 additions & 6 deletions lam/lib/modules/posixGroup.inc
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ class posixGroup extends baseModule implements passwordService {
$return->addLabel(new htmlOutputText(_("Group members")));
$membersGroup = new htmlGroup();
if (!$this->isBooleanConfigOptionSet('posixGroup_autoSyncGon')) {
$membersGroup->addElement(new htmlAccountPageButton(get_class($this), 'user', 'open', _('Edit members')));
$membersGroup->addElement(new htmlAccountPageButton(static::class, 'user', 'open', _('Edit members')));
}
$membersGroup->addElement(new htmlHelpLink('members'));
$return->addField($membersGroup);
Expand Down Expand Up @@ -352,7 +352,7 @@ class posixGroup extends baseModule implements passwordService {

// back button
$return->addVerticalSpacer('2rem');
$return->add(new htmlAccountPageButton(get_class($this), 'attributes', 'back', _('Back')), 12);
$return->add(new htmlAccountPageButton(static::class, 'attributes', 'back', _('Back')), 12);

return $return;
}
Expand Down Expand Up @@ -509,8 +509,8 @@ class posixGroup extends baseModule implements passwordService {
// configuration options
$configContainer = new htmlResponsiveRow();
$configContainer->add(new htmlSubTitle(_("Groups")), 12);
foreach ($allScopes[get_class($this)] as $typeId) {
if (sizeof($allScopes[get_class($this)]) > 1) {
foreach ($allScopes[static::class] as $typeId) {
if (sizeof($allScopes[static::class]) > 1) {
$title = new htmlDiv(null, new htmlOutputText($typeManager->getConfiguredType($typeId)->getAlias()));
$title->setCSSClasses(['bold', 'responsiveLabel']);
$configContainer->add($title, 12, 6);
Expand Down Expand Up @@ -672,7 +672,7 @@ class posixGroup extends baseModule implements passwordService {
$this->addSimplePDFField($return, 'cn', _('Group name'));
$this->addSimplePDFField($return, 'gidNumber', _('GID number'));
$this->addSimplePDFField($return, 'description', _('Description'));
if (in_array(get_class($this) . '_memberUidPrimary', $pdfKeys)) {
if (in_array(static::class . '_memberUidPrimary', $pdfKeys)) {
$members = !empty($this->attributes['memberUid']) ? $this->attributes['memberUid'] : [];
if (!empty($this->attributes['gidNumber'])) {
$filter = "(&(&" . get_ldap_filter('user') . ")(gidNumber=" . $this->attributes['gidNumber'][0] . "))";
Expand Down Expand Up @@ -1288,7 +1288,7 @@ class posixGroup extends baseModule implements passwordService {
* @see passwordService::passwordChangeRequested
*/
public function passwordChangeRequested($password, $modules, $forcePasswordChange) {
if (!in_array(get_class($this), $modules)) {
if (!in_array(static::class, $modules)) {
return [];
}
$this->attributes[$this->passwordAttrName][0] = pwd_hash($password, true, $this->moduleSettings['posixAccount_pwdHash'][0]);
Expand Down
8 changes: 4 additions & 4 deletions lam/lib/modules/pykotaPrinter.inc
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ class pykotaPrinter extends baseModule {
// printer members
$memberLabel = new htmlOutputText(_('Group members'));
$container->addLabel($memberLabel);
$addMemberButton = new htmlAccountPageButton(get_class($this), 'members', 'open', 'add.svg', true);
$addMemberButton = new htmlAccountPageButton(static::class, 'members', 'open', 'add.svg', true);
$addMemberButton->setTitle(_('Add'));
$memberHelp = new htmlHelpLink('uniqueMember');
$memberTable = new htmlTable();
Expand Down Expand Up @@ -432,9 +432,9 @@ class pykotaPrinter extends baseModule {
$return->add($filterGroup, 12);
$return->addVerticalSpacer('2rem');
$buttonTable = new htmlGroup();
$buttonTable->addElement(new htmlAccountPageButton(get_class($this), 'attributes', 'addMembers', _('Add')));
$buttonTable->addElement(new htmlAccountPageButton(static::class, 'attributes', 'addMembers', _('Add')));
$buttonTable->addElement(new htmlSpacer('0.5rem', null));
$buttonTable->addElement(new htmlAccountPageButton(get_class($this), 'attributes', 'cancel', _('Cancel')));
$buttonTable->addElement(new htmlAccountPageButton(static::class, 'attributes', 'cancel', _('Cancel')));
$return->add($buttonTable, 12);
return $return;
}
Expand All @@ -447,7 +447,7 @@ class pykotaPrinter extends baseModule {
*/
function process_members() {
$return = [];
if (isset($_POST['form_subpage_' . get_class($this) . '_attributes_addMembers']) && isset($_POST['members'])) {
if (isset($_POST['form_subpage_' . static::class . '_attributes_addMembers']) && isset($_POST['members'])) {
for ($i = 0; $i < sizeof($_POST['members']); $i++) {
$this->attributes['uniqueMember'][] = $_POST['members'][$i];
}
Expand Down
14 changes: 7 additions & 7 deletions lam/lib/modules/pykotaUser.inc
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,9 @@ class pykotaUser extends baseModule {
'pykotaJobHistory' => _('Job history'),
];
// self service settings
if (get_class($this) == 'pykotaUser') {
if (static::class == 'pykotaUser') {
$selfServiceContainer = new htmlResponsiveRow();
$selfServiceContainer->add(new htmlResponsiveInputField(_('Job suffix'), 'pykotaUser_jobSuffix', null, ['jobSuffix', get_class($this)]), 12);
$selfServiceContainer->add(new htmlResponsiveInputField(_('Job suffix'), 'pykotaUser_jobSuffix', null, ['jobSuffix', static::class]), 12);
$return['selfServiceSettings'] = $selfServiceContainer;
}
// configuration checks
Expand Down Expand Up @@ -350,10 +350,10 @@ class pykotaUser extends baseModule {
$container->addField($balanceGroup);
$container->addLabel(new htmlOutputText('&nbsp;', false));
$historyGroup = new htmlGroup();
$historyGroup->addElement(new htmlAccountPageButton(get_class($this), 'payments', 'open', _('Payment history')));
$historyGroup->addElement(new htmlAccountPageButton(static::class, 'payments', 'open', _('Payment history')));
if (!$this->getAccountContainer()->isNewAccount && !empty($this->moduleSettings['pykotaUser_jobSuffix'][0])) {
$historyGroup->addElement(new htmlSpacer('5px', null));
$historyGroup->addElement(new htmlAccountPageButton(get_class($this), 'jobs', 'open', _('Job history')));
$historyGroup->addElement(new htmlAccountPageButton(static::class, 'jobs', 'open', _('Job history')));
}
$historyGroup->addElement(new htmlSpacer('5px', null));
$historyGroup->addElement(new htmlHelpLink('pykotaPayments'), true);
Expand Down Expand Up @@ -595,7 +595,7 @@ class pykotaUser extends baseModule {
}
// back button
$container->addVerticalSpacer('2rem');
$backButton = new htmlAccountPageButton(get_class($this), 'attributes', 'back', _('Back'));
$backButton = new htmlAccountPageButton(static::class, 'attributes', 'back', _('Back'));
$container->add($backButton, 12);
return $container;
}
Expand Down Expand Up @@ -638,7 +638,7 @@ class pykotaUser extends baseModule {
$container->add($table, 12);
// back button
$container->addVerticalSpacer('2rem');
$backButton = new htmlAccountPageButton(get_class($this), 'attributes', 'back', _('Back'));
$backButton = new htmlAccountPageButton(static::class, 'attributes', 'back', _('Back'));
$container->add($backButton, 12);
return $container;
}
Expand Down Expand Up @@ -1047,7 +1047,7 @@ class pykotaUser extends baseModule {
*/
public function checkSelfServiceSettings(&$options, &$profile) {
$errors = [];
if ((get_class($this) == 'pykotaUser')
if ((static::class == 'pykotaUser')
&& !empty($options['pykotaUser_jobSuffix'][0])
&& !get_preg($options['pykotaUser_jobSuffix'][0], 'dn')) {
$errors[] = $this->messages['jobSuffix'][0];
Expand Down

0 comments on commit f84c33a

Please sign in to comment.