use new meta HTML classes

This commit is contained in:
Roland Gruber 2010-09-28 18:36:22 +00:00
parent 68170dd6fd
commit 38fd16c7c9
1 changed files with 76 additions and 44 deletions

View File

@ -548,6 +548,7 @@ class sambaSamAccount extends baseModule implements passwordService {
$configContainer = new htmlTable(); $configContainer = new htmlTable();
$timezoneSelect = new htmlTableExtendedSelect('sambaSamAccount_timeZone', $timezones, array('0'), _("Time zone"), 'timeZone'); $timezoneSelect = new htmlTableExtendedSelect('sambaSamAccount_timeZone', $timezones, array('0'), _("Time zone"), 'timeZone');
$timezoneSelect->setHasDescriptiveElements(true); $timezoneSelect->setHasDescriptiveElements(true);
$timezoneSelect->setSortElements(false);
$configContainer->addElement($timezoneSelect, true); $configContainer->addElement($timezoneSelect, true);
$yesNo = array(_('yes') => 'yes', _('no') => 'no'); $yesNo = array(_('yes') => 'yes', _('no') => 'no');
$yesNoSelect = new htmlTableExtendedSelect('sambaSamAccount_lmHash', $yesNo, array('yes'), _("Disable LM hashes"), 'lmHash'); $yesNoSelect = new htmlTableExtendedSelect('sambaSamAccount_lmHash', $yesNo, array('yes'), _("Disable LM hashes"), 'lmHash');
@ -877,12 +878,15 @@ class sambaSamAccount extends baseModule implements passwordService {
// Load attributes // Load attributes
if ($this->get_scope()=='user') { if ($this->get_scope()=='user') {
if (isset($_POST['availableSambaUserWorkstations']) && isset($_POST['sambaUserWorkstations_add'])) { // Add workstations to list if (isset($_POST['availableSambaUserWorkstations']) && isset($_POST['sambaUserWorkstations_add'])) { // Add workstations to list
$temp = str_replace(' ', '', $this->attributes['sambaUserWorkstations'][0]); $workstations = array();
$workstations = explode (',', $temp); if (isset($this->attributes['sambaUserWorkstations'][0])) {
for ($i=0; $i<count($workstations); $i++) { $temp = str_replace(' ', '', $this->attributes['sambaUserWorkstations'][0]);
if ($workstations[$i]=='') unset($workstations[$i]); $workstations = explode (',', $temp);
for ($i=0; $i<count($workstations); $i++) {
if ($workstations[$i]=='') unset($workstations[$i]);
}
$workstations = array_values($workstations);
} }
$workstations = array_values($workstations);
// Add new // Add workstations // Add new // Add workstations
$workstations = array_merge($workstations, $_POST['availableSambaUserWorkstations']); $workstations = array_merge($workstations, $_POST['availableSambaUserWorkstations']);
// remove doubles // remove doubles
@ -908,9 +912,12 @@ class sambaSamAccount extends baseModule implements passwordService {
// Remove unwanted workstations from array // Remove unwanted workstations from array
$workstations = array_delete($_POST['sambaUserWorkstations'], $workstations); $workstations = array_delete($_POST['sambaUserWorkstations'], $workstations);
// Recreate workstation string // Recreate workstation string
$this->attributes['sambaUserWorkstations'][0] = $workstations[0]; unset($this->attributes['sambaUserWorkstations'][0]);
for ($i=1; $i<count($workstations); $i++) { if (sizeof($workstations) > 0) {
$this->attributes['sambaUserWorkstations'][0] = $this->attributes['sambaUserWorkstations'][0] . "," . $workstations[$i]; $this->attributes['sambaUserWorkstations'][0] = $workstations[0];
for ($i=1; $i<count($workstations); $i++) {
$this->attributes['sambaUserWorkstations'][0] = $this->attributes['sambaUserWorkstations'][0] . "," . $workstations[$i];
}
} }
} }
} }
@ -1249,33 +1256,48 @@ class sambaSamAccount extends baseModule implements passwordService {
/** /**
* This function will create the HTML page to edit the allowed workstations. * This function will create the HTML page to edit the allowed workstations.
* *
* @return array meta HTML code * @return htmlElement meta HTML code
*/ */
function display_html_sambaUserWorkstations() { function display_html_sambaUserWorkstations() {
$return = new htmlTable();
if ($this->get_scope()=='user') { if ($this->get_scope()=='user') {
// Get list of all hosts. // Get list of all hosts.
$userWorkstations = array();
$availableUserWorkstations = array();
$result = $_SESSION['cache']->get_cache('uid', 'sambaSamAccount', 'host'); $result = $_SESSION['cache']->get_cache('uid', 'sambaSamAccount', 'host');
if (is_array($result)) { if (is_array($result)) {
foreach ($result as $host) $availableUserWorkstations[] = str_replace("$", '', $host[0]); foreach ($result as $host) $availableUserWorkstations[] = str_replace("$", '', $host[0]);
sort($availableUserWorkstations, SORT_STRING); sort($availableUserWorkstations, SORT_STRING);
$result = str_replace(' ', '', $this->attributes['sambaUserWorkstations'][0]); if (isset($this->attributes['sambaUserWorkstations'][0])) {
$userWorkstations = explode (',', $result); $result = str_replace(' ', '', $this->attributes['sambaUserWorkstations'][0]);
$userWorkstations = explode (',', $result);
}
$availableUserWorkstations = array_delete($userWorkstations, $availableUserWorkstations); $availableUserWorkstations = array_delete($userWorkstations, $availableUserWorkstations);
} }
$return[] = array( 0 => array ( 'kind' => 'fieldset', 'legend' => _("Allowed workstations"), 'value' => $return->addElement(new htmlSubTitle(_("Allowed workstations")), true);
array ( 0 => array ( 0 => array ('kind' => 'fieldset', 'td' => array ('valign' => 'top'), 'legend' => _("Allowed workstations"), 'value' => $return->addElement(new htmlOutputText(_("Allowed workstations")));
array ( 0 => array ( 0 => array ( 'kind' => 'select', 'name' => 'sambaUserWorkstations', 'size' => '15', 'multiple' => true, 'options' => $userWorkstations)))), $return->addElement(new htmlOutputText(''));
1 => array ( 'kind' => 'table', 'value' => array ( 0 => array ( 0 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'sambaUserWorkstations_add', $return->addElement(new htmlOutputText(_("Available workstations")));
'value' => '<=')), 1 => array ( 0 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'sambaUserWorkstations_remove', 'value' => '=>' )), $return->addNewLine();
2 => array ( 0 => array ( 'kind' => 'help', 'value' => 'sambaUserWorkstations' )))), $wsSelect = new htmlSelect('sambaUserWorkstations', $userWorkstations, array(), 15);
2 => array ('kind' => 'fieldset', 'td' => array ('valign' => 'top'), 'legend' => _("Available workstations"), 'value' => $wsSelect->setMultiSelect(true);
array ( 0 => array ( 0 => array ( 'kind' => 'select', 'name' => 'availableSambaUserWorkstations', 'size' => '15', 'multiple' => true, 'options' => $availableUserWorkstations)))) $return->addElement($wsSelect);
)))); $buttonContainer = new htmlTable();
$buttonContainer->addElement(new htmlButton('sambaUserWorkstations_add', 'back.gif', true), true);
$return[] = array ( 0 => array ( 'kind' => 'input', 'name' => 'form_subpage_sambaSamAccount_attributes_back', 'type' => 'submit', 'value' => _('Back') ), $buttonContainer->addElement(new htmlButton('sambaUserWorkstations_remove', 'forward.gif', true), true);
1 => array ( 'kind' => 'text'), $buttonContainer->addElement(new htmlHelpLink('userWorkstations'));
2 => array ('kind' => 'text')); $return->addElement($buttonContainer);
$wsAvailSelect = new htmlSelect('availableSambaUserWorkstations', $availableUserWorkstations, array(), 15);
$wsAvailSelect->setMultiSelect(true);
$return->addElement($wsAvailSelect);
$return->addNewLine();
$return->addElement(new htmlSpacer(null, '10px'), true);
$backButton = new htmlAccountPageButton(get_class($this), 'attributes', 'back', _('Back'));
$backButton->colspan = 3;
$return->addElement($backButton);
} }
return $return; return $return;
} }
@ -1283,16 +1305,17 @@ class sambaSamAccount extends baseModule implements passwordService {
/** /**
* This function will create the HTML page to edit logon hours. * This function will create the HTML page to edit logon hours.
* *
* @return array meta HTML code * @return htmlElement meta HTML code
*/ */
function display_html_logonHours() { function display_html_logonHours() {
$return = new htmlTable();
$timeZone = 0; $timeZone = 0;
if (isset($this->moduleSettings['sambaSamAccount_timeZone']) && is_array($this->moduleSettings['sambaSamAccount_timeZone'])) { if (isset($this->moduleSettings['sambaSamAccount_timeZone']) && is_array($this->moduleSettings['sambaSamAccount_timeZone'])) {
$timeZone = $this->moduleSettings['sambaSamAccount_timeZone'][0]; $timeZone = $this->moduleSettings['sambaSamAccount_timeZone'][0];
} }
$days = array(1 => _('Monday'), 2 => _('Tuesday'), 3 => _('Wednesday'), 4 => _('Thursday'), $days = array(1 => _('Monday'), 2 => _('Tuesday'), 3 => _('Wednesday'), 4 => _('Thursday'),
5 => _('Friday'), 6 => _('Saturday'), 0 => _('Sunday')); 5 => _('Friday'), 6 => _('Saturday'), 0 => _('Sunday'));
if (!$this->attributes['sambaLogonHours'][0]) { if (!isset($this->attributes['sambaLogonHours'][0]) || ($this->attributes['sambaLogonHours'][0] == '')) {
$this->attributes['sambaLogonHours'][0] = 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'; $this->attributes['sambaLogonHours'][0] = 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF';
} }
// convert existing logonHours string to bit array // convert existing logonHours string to bit array
@ -1312,6 +1335,13 @@ class sambaSamAccount extends baseModule implements passwordService {
$hour[$i] = substr($logonHours, $i, 1); $hour[$i] = substr($logonHours, $i, 1);
} }
// display input // display input
$return->addElement(new htmlOutputText(_('Time')));
for ($i = 0; $i < sizeof($days); $i++) {
$return->addElement(new htmlOutputText('&nbsp;' . $days[$i] . '&nbsp;', false));
}
$return->addNewLine();
$boxes = array();
// dynamically place boxes depending on time zone
for ($i = 0; $i < 24*7; $i++) { for ($i = 0; $i < 24*7; $i++) {
$hr = $i + $timeZone; $hr = $i + $timeZone;
if ($hr < 0) { if ($hr < 0) {
@ -1320,33 +1350,35 @@ class sambaSamAccount extends baseModule implements passwordService {
elseif ($hr >= 24*7) { elseif ($hr >= 24*7) {
$hr = $hr - 24*7; $hr = $hr - 24*7;
} }
if ($i % 7 == 0) { $checkbox = new htmlInputCheckbox('lh_' . $hr, $hour[$hr] ? true : false);
$return[0][floor($i / 24)+1] = array('kind' => 'text', $checkbox->alignment = htmlTable::ALIGN_CENTER;
'text' => '<b>' . $days[floor($i / 24)] . '</b>', $boxes[$i % 24][floor($i/24)] = $checkbox;
'td' => array('width' => "11%", 'align' => 'center'));
}
$return[$i % 24 + 1][floor($i/24) + 1] = array('kind' => 'input',
'name' => 'lh_' . $hr,
'type' => 'checkbox',
'checked' => $hour[$hr] ? true : false,
'td' => array('align' => 'center'));
} }
$return[0][0] = array('kind' => 'text', 'text' => '<b>' . _('Time') . '</b>', 'td' => array('width' => "12.5%"));
for ($h = 0; $h < 24; $h++) { for ($h = 0; $h < 24; $h++) {
$return[1 + $h][0] = array('kind' => 'text', 'text' => "$h:00 - $h:59"); $hour = $h;
if ($h < 10) {
$hour = '0' . $h;
}
$return->addElement(new htmlOutputText("$hour:00 - $hour:59"));
for ($d = 0; $d < 7; $d++) {
$return->addElement($boxes[$h][$d]);
}
$return->addNewLine();
} }
$return[] = array(0 => array('kind' => 'text', 'text' => '&nbsp;', 'td' => array('colspan' => 8)));
$return[] = array( $return->addElement(new htmlSpacer(null, '10px'), true);
array('kind' => 'input', 'name' => 'form_subpage_sambaSamAccount_attributes_submit', 'type' => 'submit', 'value' => _('Ok'), 'td' => array('align' => 'right')), $buttonContainer = new htmlTable();
array('kind' => 'input', 'name' => 'form_subpage_sambaSamAccount_attributes_abort', 'type' => 'submit', 'value' => _('Cancel'), 'td' => array('align' => 'left')) $buttonContainer->colspan = 5;
); $buttonContainer->addElement(new htmlAccountPageButton(get_class($this), 'attributes', 'submit', _('Ok')));
$buttonContainer->addElement(new htmlAccountPageButton(get_class($this), 'attributes', 'abort', _('Cancel')));
$return->addElement($buttonContainer);
return $return; return $return;
} }
/** /**
* This function will create the meta HTML code to show a page to change time values. * This function will create the meta HTML code to show a page to change time values.
* *
* @return array meta HTML code * @return htmlElement meta HTML code
*/ */
function display_html_time() { function display_html_time() {
$return = array(); $return = array();