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 8e2f9bf commit 8c67dbc
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
14 changes: 7 additions & 7 deletions lam/lib/modules/sambaGroupMapping.inc
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ class sambaGroupMapping extends baseModule {
// local group members
$memberLabel = new htmlOutputText(_('Local members'));
$return->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'));
$addMemberButton->alignment = htmlElement::ALIGN_TOP;
$memberHelp = new htmlHelpLink('sambaSIDList');
Expand Down Expand Up @@ -440,7 +440,7 @@ class sambaGroupMapping extends baseModule {
$return = new htmlResponsiveRow();
$typeManager = new TypeManager();
// show list of possible new members
if ((isset($_POST['form_subpage_' . get_class($this) . '_members_select']) || isset($_POST['setFilter'])) && isset($_POST['type'])) {
if ((isset($_POST['form_subpage_' . static::class . '_members_select']) || isset($_POST['setFilter'])) && isset($_POST['type'])) {
$type = $typeManager->getConfiguredType($_POST['type']);
$this->loadSIDCache();
$options = [];
Expand Down Expand Up @@ -482,8 +482,8 @@ class sambaGroupMapping extends baseModule {
$filterGroup->addElement(new htmlHiddenInput('type', $type->getId()));
$return->add($filterGroup, 12);
$return->addVerticalSpacer('2rem');
$return->addLabel(new htmlAccountPageButton(get_class($this), 'attributes', 'addMembers', _('Add')));
$return->addField(new htmlAccountPageButton(get_class($this), 'attributes', 'cancel', _('Cancel')));
$return->addLabel(new htmlAccountPageButton(static::class, 'attributes', 'addMembers', _('Add')));
$return->addField(new htmlAccountPageButton(static::class, 'attributes', 'cancel', _('Cancel')));
return $return;
}
$types = $typeManager->getConfiguredTypesForScopes(['user', 'group', 'host']);
Expand All @@ -500,9 +500,9 @@ class sambaGroupMapping extends baseModule {
$typeSelect->setHasDescriptiveElements(true);
$return->addField($typeSelect);
$return->addLabel(new htmlOutputText(' ', false));
$return->addField(new htmlAccountPageButton(get_class($this), 'members', 'select', _('Ok')));
$return->addField(new htmlAccountPageButton(static::class, 'members', 'select', _('Ok')));
$return->addVerticalSpacer('2rem');
$return->add(new htmlAccountPageButton(get_class($this), 'attributes', 'membersBack', _('Back')), 12, 12, 12, 'text-center');
$return->add(new htmlAccountPageButton(static::class, 'attributes', 'membersBack', _('Back')), 12, 12, 12, 'text-center');
return $return;
}

Expand All @@ -514,7 +514,7 @@ class sambaGroupMapping 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['sambaSIDList'][] = $_POST['members'][$i];
}
Expand Down
42 changes: 21 additions & 21 deletions lam/lib/modules/sambaSamAccount.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,7 @@ class sambaSamAccount extends baseModule implements passwordService, AccountStat
$expireDateGroup = new htmlGroup();
$expireDateGroup->addElement(new htmlOutputText($dateValue, false));
$expireDateGroup->addElement(new htmlSpacer('0.5rem', null));
$expireDateGroup->addElement(new htmlAccountPageButton(get_class($this), 'time', 'sambaKickoffTime', _('Change')));
$expireDateGroup->addElement(new htmlAccountPageButton(static::class, 'time', 'sambaKickoffTime', _('Change')));
$expireDateGroup->addElement(new htmlSpacer('0.5rem', null));
$expireDateGroup->addElement(new htmlHelpLink('expireDate'), true);
$return->addField($expireDateGroup);
Expand Down Expand Up @@ -1218,7 +1218,7 @@ class sambaSamAccount extends baseModule implements passwordService, AccountStat
$sambaProfilePathGroup->addElement(new htmlInputField('sambaProfilePath', $sambaProfilePath));
if (($_SESSION['config']->get_scriptPath() != null) && ($_SESSION['config']->get_scriptPath() != '')) {
if (get_preg($sambaProfilePath, 'homeDirectory')) {
$sambaProfilePathButton = new htmlAccountPageButton(get_class($this), 'profilePath', 'manage', '../graphics/folder.svg', true);
$sambaProfilePathButton = new htmlAccountPageButton(static::class, 'profilePath', 'manage', '../graphics/folder.svg', true);
$sambaProfilePathButton->setTitle(_('Manage profile directory'));
$sambaProfilePathGroup->addElement($sambaProfilePathButton);
}
Expand All @@ -1237,7 +1237,7 @@ class sambaSamAccount extends baseModule implements passwordService, AccountStat
if (!$this->isBooleanConfigOptionSet('sambaSamAccount_hideWorkstations')) {
$return->addLabel(new htmlOutputText(_('Samba workstations')));
$userWorkstationsGroup = new htmlGroup();
$userWorkstationsGroup->addElement(new htmlAccountPageButton(get_class($this), 'sambaUserWorkstations', 'open', _('Edit workstations')));
$userWorkstationsGroup->addElement(new htmlAccountPageButton(static::class, 'sambaUserWorkstations', 'open', _('Edit workstations')));
$userWorkstationsGroup->addElement(new htmlSpacer('0.5rem', null));
$userWorkstationsGroup->addElement(new htmlHelpLink('userWorkstations'));
$return->addField($userWorkstationsGroup);
Expand Down Expand Up @@ -1286,15 +1286,15 @@ class sambaSamAccount extends baseModule implements passwordService, AccountStat
if (!$this->isBooleanConfigOptionSet('sambaSamAccount_hideLogonHours')) {
$return->addLabel(new htmlOutputText(_('Logon hours')));
$logonHoursGroup = new htmlGroup();
$logonHoursGroup->addElement(new htmlAccountPageButton(get_class($this), 'logonHours', 'open', _('Edit')));
$logonHoursGroup->addElement(new htmlAccountPageButton(static::class, 'logonHours', 'open', _('Edit')));
$logonHoursGroup->addElement(new htmlSpacer('0.5rem', null));
$logonHoursGroup->addElement(new htmlHelpLink('logonHours'));
$return->addField($logonHoursGroup);
}
if (!$this->isBooleanConfigOptionSet('sambaSamAccount_hideTerminalServer')) {
$return->addLabel(new htmlOutputText(_('Terminal server options')));
$terminalServerGroup = new htmlGroup();
$terminalServerGroup->addElement(new htmlAccountPageButton(get_class($this), 'terminalServer', 'open', _('Edit')));
$terminalServerGroup->addElement(new htmlAccountPageButton(static::class, 'terminalServer', 'open', _('Edit')));
$terminalServerGroup->addElement(new htmlSpacer('0.5rem', null));
$terminalServerGroup->addElement(new htmlHelpLink('terminalServer'));
$return->addField($terminalServerGroup);
Expand Down Expand Up @@ -1381,7 +1381,7 @@ class sambaSamAccount extends baseModule implements passwordService, AccountStat

$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 @@ -1446,8 +1446,8 @@ class sambaSamAccount extends baseModule implements passwordService, AccountStat
$return->add(new htmlResponsiveTable($titles, $data), 12);

$return->addVerticalSpacer('2rem');
$return->addLabel(new htmlAccountPageButton(get_class($this), 'attributes', 'submit', _('Ok')));
$return->addField(new htmlAccountPageButton(get_class($this), 'attributes', 'abort', _('Cancel')));
$return->addLabel(new htmlAccountPageButton(static::class, 'attributes', 'submit', _('Ok')));
$return->addField(new htmlAccountPageButton(static::class, 'attributes', 'abort', _('Cancel')));
return $return;
}

Expand Down Expand Up @@ -1502,13 +1502,13 @@ class sambaSamAccount extends baseModule implements passwordService, AccountStat
}
$return->addVerticalSpacer('2rem');
$buttons = new htmlGroup();
$buttons->addElement(new htmlAccountPageButton(get_class($this), 'attributes', 'change' . $attr, _('Change')));
$buttons->addElement(new htmlAccountPageButton(static::class, 'attributes', 'change' . $attr, _('Change')));
$buttons->addElement(new htmlSpacer('0.5rem', null));
if (isset($this->attributes[$attr][0])) {
$buttons->addElement(new htmlAccountPageButton(get_class($this), 'attributes', 'del' . $attr, _('Remove')));
$buttons->addElement(new htmlAccountPageButton(static::class, 'attributes', 'del' . $attr, _('Remove')));
$buttons->addElement(new htmlSpacer('0.5rem', null));
}
$buttons->addElement(new htmlAccountPageButton(get_class($this), 'attributes', 'back' . $attr, _('Cancel')));
$buttons->addElement(new htmlAccountPageButton(static::class, 'attributes', 'back' . $attr, _('Cancel')));
$return->add($buttons, 12, 12, 12, 'text-center');
return $return;
}
Expand Down Expand Up @@ -1593,8 +1593,8 @@ class sambaSamAccount extends baseModule implements passwordService, AccountStat
$return->add($reconnectSelect, 12);
// buttons
$return->addVerticalSpacer('2rem');
$return->addLabel(new htmlAccountPageButton(get_class($this), 'attributes', 'submit', _('Ok')));
$return->addField(new htmlAccountPageButton(get_class($this), 'attributes', 'abort', _('Cancel')));
$return->addLabel(new htmlAccountPageButton(static::class, 'attributes', 'submit', _('Ok')));
$return->addField(new htmlAccountPageButton(static::class, 'attributes', 'abort', _('Cancel')));
return $return;
}

Expand Down Expand Up @@ -1639,15 +1639,15 @@ class sambaSamAccount extends baseModule implements passwordService, AccountStat
$editGroup = new htmlGroup();
$editGroup->addElement(new htmlImage('../../graphics/pass.svg', 16, 16));
$editGroup->addElement(new htmlSpacer('0.5rem', null));
$editGroup->addElement(new htmlAccountPageButton(get_class($this), 'homedir', 'delete_' . $i, _('Delete')));
$editGroup->addElement(new htmlAccountPageButton(static::class, 'homedir', 'delete_' . $i, _('Delete')));
$return->addField($editGroup);
}
elseif ($returnValue == 'missing') {
$return->addLabel(new htmlOutputText($label));
$editGroup = new htmlGroup();
$editGroup->addElement(new htmlImage('../../graphics/del.svg', 16, 16));
$editGroup->addElement(new htmlSpacer('0.5rem', null));
$editGroup->addElement(new htmlAccountPageButton(get_class($this), 'homedir', 'create_' . $i, _('Create')));
$editGroup->addElement(new htmlAccountPageButton(static::class, 'homedir', 'create_' . $i, _('Create')));
$return->addField($editGroup);
}
elseif (trim($returnValue) != '') {
Expand All @@ -1666,7 +1666,7 @@ class sambaSamAccount extends baseModule implements passwordService, AccountStat
}
}
$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 All @@ -1688,7 +1688,7 @@ class sambaSamAccount extends baseModule implements passwordService, AccountStat
$remoteServers = $_SESSION['config']->getConfiguredScriptServers();
for ($i = 0; $i < sizeof($remoteServers); $i++) {
$remoteServer = $remoteServers[$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($remoteServer);
Expand Down Expand Up @@ -1719,7 +1719,7 @@ class sambaSamAccount extends baseModule implements passwordService, AccountStat
}
}
}
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($remoteServer);
Expand Down Expand Up @@ -2333,15 +2333,15 @@ class sambaSamAccount extends baseModule implements passwordService, AccountStat
public function getSelfServiceSettings($profile) {
$selfServiceContainer = new htmlResponsiveRow();
// domain suffix
$selfServiceDomainSuffix = new htmlResponsiveInputField(_('Domain suffix'), 'sambaSamAccount_domainSuffix', null, ['domainSuffix', get_class($this)]);
$selfServiceDomainSuffix = new htmlResponsiveInputField(_('Domain suffix'), 'sambaSamAccount_domainSuffix', null, ['domainSuffix', static::class]);
$selfServiceContainer->add($selfServiceDomainSuffix, 12);
// password history
$historyOptions = [
_('yes - ordered ascending') => 'yes_deleteLast',
_('yes - ordered descending') => 'yes_deleteFirst',
_('no') => 'no'
];
$historySelect = new htmlResponsiveSelect('sambaSamAccount_history', $historyOptions, ['yes_deleteLast'], _("Password history"), ['history', get_class($this)]);
$historySelect = new htmlResponsiveSelect('sambaSamAccount_history', $historyOptions, ['yes_deleteLast'], _("Password history"), ['history', static::class]);
$historySelect->setHasDescriptiveElements(true);
$selfServiceContainer->add($historySelect, 12);
return $selfServiceContainer;
Expand Down Expand Up @@ -2570,7 +2570,7 @@ class sambaSamAccount extends baseModule implements passwordService, AccountStat
* @see passwordService::passwordChangeRequested
*/
public function passwordChangeRequested($password, $modules, $forcePasswordChange) {
if (!in_array(get_class($this), $modules)) {
if (!in_array(static::class, $modules)) {
return [];
}
$errors = [];
Expand Down

0 comments on commit 8c67dbc

Please sign in to comment.