| 1 |
<?php |
| 2 |
|
| 3 |
namespace LAM\HELP; |
| 4 |
/* |
| 5 |
|
| 6 |
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) |
| 7 |
Copyright (C) 2003 - 2006 Michael Duergner |
| 8 |
2008 - 2024 Roland Gruber |
| 9 |
|
| 10 |
This program is free software; you can redistribute it and/or modify |
| 11 |
it under the terms of the GNU General Public License as published by |
| 12 |
the Free Software Foundation; either version 2 of the License, or |
| 13 |
(at your option) any later version. |
| 14 |
|
| 15 |
This program is distributed in the hope that it will be useful, |
| 16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 |
GNU General Public License for more details. |
| 19 |
|
| 20 |
You should have received a copy of the GNU General Public License |
| 21 |
along with this program; if not, write to the Free Software |
| 22 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 23 |
|
| 24 |
|
| 25 |
LDAP Account Manager display help pages. |
| 26 |
*/ |
| 27 |
|
| 28 |
use ScopeAndModuleValidation; |
| 29 |
|
| 30 |
/** |
| 31 |
* LDAP Account Manager help page. |
| 32 |
* |
| 33 |
* @author Michael Duergner |
| 34 |
* @author Roland Gruber |
| 35 |
* @package Help |
| 36 |
*/ |
| 37 |
|
| 38 |
/** LDAP connection */ |
| 39 |
include_once(__DIR__ . "/../lib/ldap.inc"); |
| 40 |
|
| 41 |
/** configuration */ |
| 42 |
include_once(__DIR__ . "/../lib/config.inc"); |
| 43 |
|
| 44 |
/** self-service functions */ |
| 45 |
include_once(__DIR__ . "/../lib/selfService.inc"); |
| 46 |
if (!empty($_GET['selfService']) && ($_GET['selfService'] === '1')) { |
| 47 |
session_name('SELFSERVICE'); |
| 48 |
} |
| 49 |
|
| 50 |
if (isFileBasedSession()) { |
| 51 |
session_save_path("../sess"); |
| 52 |
} |
| 53 |
lam_start_session(); |
| 54 |
|
| 55 |
/** status messages */ |
| 56 |
include_once(__DIR__ . "/../lib/status.inc"); |
| 57 |
|
| 58 |
setlanguage(); |
| 59 |
|
| 60 |
/** help data */ |
| 61 |
include_once(__DIR__ . "/../help/help.inc"); // Include help/help.inc which provides $helpArray where the help pages are stored |
| 62 |
|
| 63 |
|
| 64 |
/** |
| 65 |
* Print HTML header of the help page. |
| 66 |
*/ |
| 67 |
function echoHTMLHead(): void { |
| 68 |
echo $_SESSION['header']; |
| 69 |
$title = "LDAP Account Manager Help"; |
| 70 |
printHeaderContents($title, '..'); |
| 71 |
?> |
| 72 |
</head> |
| 73 |
<body> |
| 74 |
<?php |
| 75 |
// include all JavaScript files |
| 76 |
printJsIncludes('..'); |
| 77 |
} |
| 78 |
|
| 79 |
/** |
| 80 |
* Print HTML footer of the help page. |
| 81 |
*/ |
| 82 |
function echoHTMLFoot(): void { |
| 83 |
?> |
| 84 |
</body> |
| 85 |
</html> |
| 86 |
<?php |
| 87 |
} |
| 88 |
|
| 89 |
/** |
| 90 |
* Print help site for a specific help number. |
| 91 |
* |
| 92 |
* @param array<mixed> $helpEntry the help entry that is to be displayed. |
| 93 |
*/ |
| 94 |
function displayHelp(array $helpEntry): void { |
| 95 |
echoHTMLHead(); |
| 96 |
echo "<h1 class=\"help\">" . $helpEntry['Headline'] . "</h1>\n"; |
| 97 |
$format = "<p class=\"help\">" . $helpEntry['Text'] . "</p>\n"; |
| 98 |
if (isset($helpEntry['attr'])) { |
| 99 |
$format .= '<br><hr>' . _('Technical name') . ': <i>' . $helpEntry['attr'] . '</i>'; |
| 100 |
} |
| 101 |
echo $format; |
| 102 |
if (isset($helpEntry['SeeAlso']) && is_array($helpEntry['SeeAlso'])) { |
| 103 |
echo '<p class="help">' . _('See also') . ': <a class="helpSeeAlso" href="' . $helpEntry['SeeAlso']['link'] . '">' . $helpEntry['SeeAlso']['text'] . '</a></p>'; |
| 104 |
} |
| 105 |
echoHTMLFoot(); |
| 106 |
} |
| 107 |
|
| 108 |
/* If no help number was submitted print error message */ |
| 109 |
if (!isset($_GET['HelpNumber'])) { |
| 110 |
$errorMessage = "Sorry no help number submitted."; |
| 111 |
echoHTMLHead(); |
| 112 |
statusMessage("ERROR", "", $errorMessage); |
| 113 |
echoHTMLFoot(); |
| 114 |
exit; |
| 115 |
} |
| 116 |
|
| 117 |
$helpEntry = []; |
| 118 |
|
| 119 |
// module help |
| 120 |
if (isset($_GET['module']) && ($_GET['module'] != 'main') && ($_GET['module'] != '')) { |
| 121 |
include_once(__DIR__ . "/../lib/modules.inc"); |
| 122 |
$moduleName = $_GET['module']; |
| 123 |
if (!ScopeAndModuleValidation::isValidModuleName($moduleName)) { |
| 124 |
logNewMessage(LOG_ERR, 'Invalid module name: ' . $moduleName); |
| 125 |
die(); |
| 126 |
} |
| 127 |
$scope = empty($_GET['scope']) ? 'user' : $_GET['scope']; |
| 128 |
if (!ScopeAndModuleValidation::isValidScopeName($scope)) { |
| 129 |
logNewMessage(LOG_ERR, 'Invalid scope name: ' . $scope); |
| 130 |
die(); |
| 131 |
} |
| 132 |
$helpEntry = getHelp($moduleName, $_GET['HelpNumber'], $scope); |
| 133 |
if (!$helpEntry) { |
| 134 |
$variables = [htmlspecialchars((string) $_GET['HelpNumber']), htmlspecialchars((string) $moduleName)]; |
| 135 |
$errorMessage = _("Sorry, the help id '%s' is not available for the module '%s'."); |
| 136 |
echoHTMLHead(); |
| 137 |
statusMessage("ERROR", "", $errorMessage, $variables); |
| 138 |
echoHTMLFoot(); |
| 139 |
exit; |
| 140 |
} |
| 141 |
} |
| 142 |
elseif (!array_key_exists($_GET['HelpNumber'], $helpArray)) { |
| 143 |
/* If submitted help number is not in help/help.inc print error message */ |
| 144 |
$variables = [htmlspecialchars((string) $_GET['HelpNumber'])]; |
| 145 |
$errorMessage = _("Sorry, the help number %s is not available."); |
| 146 |
echoHTMLHead(); |
| 147 |
statusMessage("ERROR", "", $errorMessage, $variables); |
| 148 |
echoHTMLFoot(); |
| 149 |
exit; |
| 150 |
} |
| 151 |
else { |
| 152 |
$helpEntry = $helpArray[$_GET['HelpNumber']]; |
| 153 |
} |
| 154 |
|
| 155 |
displayHelp($helpEntry); |