refactoring

This commit is contained in:
Roland Gruber 2018-12-23 11:01:29 +01:00
parent e289cabe3f
commit 2a10013f36
10 changed files with 45 additions and 28 deletions

View File

@ -192,24 +192,24 @@ class lamList {
// show form // show form
echo "<div class=\"ui-tabs-panel ui-widget-content ui-corner-bottom\">"; echo "<div class=\"ui-tabs-panel ui-widget-content ui-corner-bottom\">";
echo "<div id=\"listTabContentArea\">\n"; echo "<div id=\"listTabContentArea\">\n";
echo ("<form action=\"list.php?type=" . $this->type->getId() . "&amp;norefresh=true\" method=\"post\">\n"); echo "<form action=\"list.php?type=" . $this->type->getId() . "&amp;norefresh=true\" method=\"post\">\n";
// draw account list if accounts were found // draw account list if accounts were found
if (sizeof($this->entries) > 0) { if (sizeof($this->entries) > 0) {
// buttons // buttons
$this->listPrintButtons(false); $this->listPrintButtons(false);
echo ("<br>\n"); echo "<br>\n";
// navigation bar // navigation bar
$this->listDrawNavigationBar(sizeof($this->entries)); $this->listDrawNavigationBar(sizeof($this->entries));
echo ("<br>\n"); echo "<br>\n";
$this->printAccountTable($this->entries); $this->printAccountTable($this->entries);
} }
else { else {
// buttons // buttons
$this->listPrintButtons(true); $this->listPrintButtons(true);
echo ("<br>\n"); echo "<br>\n";
// navigation bar // navigation bar
$this->listDrawNavigationBar(sizeof($this->entries)); $this->listDrawNavigationBar(sizeof($this->entries));
echo ("<br>\n"); echo "<br>\n";
$accounts = array(); $accounts = array();
$this->printAccountTable($accounts); $this->printAccountTable($accounts);
echo "</table><br>\n"; echo "</table><br>\n";
@ -267,8 +267,9 @@ class lamList {
* @param array $info the account list * @param array $info the account list
*/ */
protected function listCreateSortMapping(&$info) { protected function listCreateSortMapping(&$info) {
if (!is_array($this->attrArray)) return; if (!is_array($this->attrArray) || !is_string($this->sortColumn)) {
if (!is_string($this->sortColumn)) return; return;
}
$toSort = array(); $toSort = array();
$col = $this->sortColumn; $col = $this->sortColumn;
$size = sizeof($info); $size = sizeof($info);
@ -498,8 +499,12 @@ class lamList {
private function addDataElements(&$data, &$info, &$onClickEvents, &$onDoubleClickEvents) { private function addDataElements(&$data, &$info, &$onClickEvents, &$onDoubleClickEvents) {
// calculate which rows to show // calculate which rows to show
$table_begin = ($this->page - 1) * $this->maxPageEntries; $table_begin = ($this->page - 1) * $this->maxPageEntries;
if (($this->page * $this->maxPageEntries) > sizeof($info)) $table_end = sizeof($info); if (($this->page * $this->maxPageEntries) > sizeof($info)) {
else $table_end = ($this->page * $this->maxPageEntries); $table_end = sizeof($info);
}
else {
$table_end = ($this->page * $this->maxPageEntries);
}
// get sort mapping // get sort mapping
$sortMapping = &$this->sortMapping; $sortMapping = &$this->sortMapping;
if (empty($sortMapping)) { if (empty($sortMapping)) {
@ -964,8 +969,12 @@ class lamList {
exit(); exit();
} }
// get current page // get current page
if (!empty($_GET["page"])) $this->page = $_GET["page"]; if (!empty($_GET["page"])) {
else $this->page = 1; $this->page = $_GET["page"];
}
else {
$this->page = 1;
}
// generate attribute-description table // generate attribute-description table
$temp_array = $this->listGetAttributeDescriptionList(); $temp_array = $this->listGetAttributeDescriptionList();
$this->attrArray = array_keys($temp_array); // list of LDAP attributes to show $this->attrArray = array_keys($temp_array); // list of LDAP attributes to show

View File

@ -152,7 +152,7 @@ $tabindex = 1;
echo $_SESSION['header']; echo $_SESSION['header'];
printHeaderContents(_("LDAP Account Manager Configuration"), '../..'); printHeaderContents(_("LDAP Account Manager Configuration"), '../..');
echo ("<body class=\"admin\">\n"); echo "<body class=\"admin\">\n";
// include all JavaScript files // include all JavaScript files
printJsIncludes('../..'); printJsIncludes('../..');
printConfigurationPageHeaderBar($conf); printConfigurationPageHeaderBar($conf);
@ -171,7 +171,7 @@ if (sizeof($errorsToDisplay) > 0) {
} }
// display formular // display formular
echo ("<form enctype=\"multipart/form-data\" action=\"confmain.php\" method=\"post\" autocomplete=\"off\">\n"); echo "<form enctype=\"multipart/form-data\" action=\"confmain.php\" method=\"post\" autocomplete=\"off\">\n";
printConfigurationPageTabs(ConfigurationPageTab::GENERAL); printConfigurationPageTabs(ConfigurationPageTab::GENERAL);

View File

@ -117,9 +117,11 @@ printJsIncludes('../..');
printConfigurationPageHeaderBar($conf); printConfigurationPageHeaderBar($conf);
// print error messages // print error messages
for ($i = 0; $i < sizeof($errorsToDisplay); $i++) call_user_func_array('StatusMessage', $errorsToDisplay[$i]); for ($i = 0; $i < sizeof($errorsToDisplay); $i++) {
call_user_func_array('StatusMessage', $errorsToDisplay[$i]);
}
echo ("<form id=\"inputForm\" action=\"confmodules.php\" method=\"post\" onSubmit=\"saveScrollPosition('inputForm')\">\n"); echo "<form id=\"inputForm\" action=\"confmodules.php\" method=\"post\" onSubmit=\"saveScrollPosition('inputForm')\">\n";
printConfigurationPageTabs(ConfigurationPageTab::MODULES); printConfigurationPageTabs(ConfigurationPageTab::MODULES);

View File

@ -143,9 +143,11 @@ printJsIncludes('../..');
printConfigurationPageHeaderBar($conf); printConfigurationPageHeaderBar($conf);
// print error messages // print error messages
for ($i = 0; $i < sizeof($errorsToDisplay); $i++) call_user_func_array('StatusMessage', $errorsToDisplay[$i]); for ($i = 0; $i < sizeof($errorsToDisplay); $i++) {
call_user_func_array('StatusMessage', $errorsToDisplay[$i]);
}
echo ("<form action=\"conftypes.php\" method=\"post\">\n"); echo "<form action=\"conftypes.php\" method=\"post\">\n";
printConfigurationPageTabs(ConfigurationPageTab::TYPES); printConfigurationPageTabs(ConfigurationPageTab::TYPES);

View File

@ -111,9 +111,11 @@ printJsIncludes('../..');
printConfigurationPageHeaderBar($conf); printConfigurationPageHeaderBar($conf);
// print error messages // print error messages
for ($i = 0; $i < sizeof($errorsToDisplay); $i++) call_user_func_array('StatusMessage', $errorsToDisplay[$i]); for ($i = 0; $i < sizeof($errorsToDisplay); $i++) {
call_user_func_array('StatusMessage', $errorsToDisplay[$i]);
}
echo ("<form id=\"inputForm\" action=\"moduleSettings.php\" method=\"post\" autocomplete=\"off\" onSubmit=\"saveScrollPosition('inputForm')\">\n"); echo "<form id=\"inputForm\" action=\"moduleSettings.php\" method=\"post\" autocomplete=\"off\" onSubmit=\"saveScrollPosition('inputForm')\">\n";
printConfigurationPageTabs(ConfigurationPageTab::MODULE_SETTINGS); printConfigurationPageTabs(ConfigurationPageTab::MODULE_SETTINGS);

View File

@ -229,7 +229,7 @@ function display_LoginPage($licenseValidator, $error_message) {
</td> </td>
<td align="center" height=30 width="34%"> <td align="center" height=30 width="34%">
<span class="hide-for-small"> <span class="hide-for-small">
<a href="http://www.ldap-account-manager.org/lamcms/lamPro"> <?php if (!isLAMProVersion()) { echo (_("Want more features? Get LAM Pro!"));} ?> </a> <a href="http://www.ldap-account-manager.org/lamcms/lamPro"> <?php if (!isLAMProVersion()) { echo _("Want more features? Get LAM Pro!");} ?> </a>
</span> </span>
</td> </td>
<td align="right" height=30 width="34%"> <td align="right" height=30 width="34%">

View File

@ -62,7 +62,9 @@ startSecureSession();
enforceUserIsLoggedIn(); enforceUserIsLoggedIn();
// die if no write access // die if no write access
if (!checkIfWriteAccessIsAllowed()) die(); if (!checkIfWriteAccessIsAllowed()) {
die();
}
checkIfToolIsActive('ImportExport'); checkIfToolIsActive('ImportExport');
@ -175,7 +177,7 @@ function printImportTabContent(&$tabindex) {
addSecurityTokenToMetaHTML($container); addSecurityTokenToMetaHTML($container);
parseHtml(null, $container, array(), false, $tabindex, 'user'); parseHtml(null, $container, array(), false, $tabindex, 'user');
echo ("</form>\n"); echo "</form>\n";
} }
/** /**
@ -220,7 +222,7 @@ function printImportTabProcessing(&$tabindex) {
addSecurityTokenToMetaHTML($container); addSecurityTokenToMetaHTML($container);
parseHtml(null, $container, array(), false, $tabindex, 'user'); parseHtml(null, $container, array(), false, $tabindex, 'user');
echo ("</form>\n"); echo "</form>\n";
} }
/** /**
@ -303,7 +305,7 @@ function printExportTabContent(&$tabindex) {
addSecurityTokenToMetaHTML($container); addSecurityTokenToMetaHTML($container);
parseHtml(null, $container, array(), false, $tabindex, 'user'); parseHtml(null, $container, array(), false, $tabindex, 'user');
echo ("</form>\n"); echo "</form>\n";
} }
/** /**
@ -380,7 +382,7 @@ function printExportTabProcessing(&$tabindex) {
addSecurityTokenToMetaHTML($container); addSecurityTokenToMetaHTML($container);
parseHtml(null, $container, array(), false, $tabindex, 'user'); parseHtml(null, $container, array(), false, $tabindex, 'user');
echo ("</form>\n"); echo "</form>\n";
} }
/** /**

View File

@ -201,7 +201,7 @@ function displayStartPage() {
addSecurityTokenToMetaHTML($container); addSecurityTokenToMetaHTML($container);
parseHtml(null, $container, array(), false, $tabindex, 'user'); parseHtml(null, $container, array(), false, $tabindex, 'user');
echo ("</form>\n"); echo "</form>\n";
echo '</div>'; echo '</div>';
include '../../lib/adminFooter.inc'; include '../../lib/adminFooter.inc';
} }

View File

@ -228,7 +228,7 @@ function display_main($message, $error) {
addSecurityTokenToMetaHTML($container); addSecurityTokenToMetaHTML($container);
parseHtml(null, $container, array(), false, $tabindex, 'user'); parseHtml(null, $container, array(), false, $tabindex, 'user');
echo ("</form>\n"); echo "</form>\n";
echo '</div>'; echo '</div>';
include '../../lib/adminFooter.inc'; include '../../lib/adminFooter.inc';
} }

View File

@ -15,4 +15,4 @@ sonar.links.issue=https://github.com/LDAPAccountManager/lam
sonar.sources=lam sonar.sources=lam
sonar.tests=lam/tests sonar.tests=lam/tests
sonar.exclusions=**/3rdParty/**,**/lib/extra/**,**/lib/*jquery*.js,**/tests/**,**/style/*jquery*.css,,**/style/*cropper*.css,**/style/*magnific*.css sonar.exclusions=**/3rdParty/**,**/lib/extra/**,**/lib/*jquery*.js,**/tests/**,**/style/*jquery*.css,,**/style/*cropper*.css,**/style/*magnific*.css,**/schema.inc