You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

640 lines
29 KiB

  1. <?php
  2. // turn on warnings and notice during developement
  3. include('initialize/PhpErrorSettings.inc.php');
  4. // Project: Web Reference Database (refbase) <http://www.refbase.net>
  5. // Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's
  6. // original author(s).
  7. //
  8. // This code is distributed in the hope that it will be useful,
  9. // but WITHOUT ANY WARRANTY. Please see the GNU General Public
  10. // License for more details.
  11. //
  12. // File: ./user_receipt.php
  13. // Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/user_receipt.php $
  14. // Author(s): Matthias Steffens <mailto:refbase@extracts.de>
  15. //
  16. // Created: 16-Apr-02, 10:54
  17. // Modified: $Date: 2017-04-13 02:00:18 +0000 (Thu, 13 Apr 2017) $
  18. // $Author: karnesky $
  19. // $Revision: 1416 $
  20. // This script shows the user a receipt for their user UPDATE or INSERT.
  21. // It carries out no database actions and can be bookmarked.
  22. // The user must be logged in to view it.
  23. // TODO: I18n, better separate HTML code from PHP code
  24. // Incorporate some include files:
  25. include 'initialize/db.inc.php'; // 'db.inc.php' is included to hide username and password
  26. include 'includes/header.inc.php'; // include header
  27. include 'includes/footer.inc.php'; // include footer
  28. include 'includes/include.inc.php'; // include common functions
  29. include 'initialize/ini.inc.php'; // include common variables
  30. // --------------------------------------------------------------------
  31. // START A SESSION:
  32. // call the 'start_session()' function (from 'include.inc.php') which will also read out available session variables:
  33. start_session(true);
  34. // --------------------------------------------------------------------
  35. // Initialize preferred display language:
  36. // (note that 'locales.inc.php' has to be included *after* the call to the 'start_session()' function)
  37. include 'includes/locales.inc.php'; // include the locales
  38. // --------------------------------------------------------------------
  39. // Extract the 'userID' parameter from the request:
  40. if (isset($_REQUEST['userID']) AND preg_match("/^-?[0-9]+$/", $_REQUEST['userID']))
  41. $userID = $_REQUEST['userID'];
  42. else
  43. $userID = ""; // we do it for clarity reasons here (and in order to prevent any 'Undefined variable...' messages)
  44. // Check if the user is logged in
  45. if (!isset($_SESSION['loginEmail']) && ($userID != -1))
  46. // Note: 'user_validation.php' uses the non-existing user ID '-1' as trigger to show the email notification receipt page (instead of the standard receipt page)
  47. {
  48. // save an error message:
  49. $HeaderString = "You must login to view your user account details and options!";
  50. // save the URL of the currently displayed page:
  51. $referer = $_SERVER['HTTP_REFERER'];
  52. // Write back session variables:
  53. saveSessionVariable("HeaderString", $HeaderString); // function 'saveSessionVariable()' is defined in 'include.inc.php'
  54. saveSessionVariable("referer", $referer);
  55. header("Location: user_login.php");
  56. exit;
  57. }
  58. // Check the correct parameters have been passed
  59. if ($userID == "")
  60. {
  61. // save an error message:
  62. $HeaderString = "Incorrect parameters to script 'user_receipt.php'!";
  63. // Write back session variables:
  64. saveSessionVariable("HeaderString", $HeaderString); // function 'saveSessionVariable()' is defined in 'include.inc.php'
  65. // Redirect the browser back to the calling page
  66. header("Location: " . $referer); // variable '$referer' is globally defined in function 'start_session()' in 'include.inc.php'
  67. exit;
  68. }
  69. // Check if the logged-in user is allowed to modify his account details and options
  70. if (isset($_SESSION['loginEmail']) AND preg_match("/^\d+$/", $userID) AND isset($_SESSION['user_permissions']) AND !preg_match("/allow_modify_options/", $_SESSION['user_permissions'])) // if a user is logged in but the 'user_permissions' session variable does NOT contain 'allow_modify_options'...
  71. {
  72. // save an error message:
  73. $HeaderString = "You have no permission to modify your user account details and options!";
  74. // Write back session variables:
  75. saveSessionVariable("HeaderString", $HeaderString); // function 'saveSessionVariable()' is defined in 'include.inc.php'
  76. // Redirect the browser back to the calling page
  77. header("Location: " . $referer);
  78. exit;
  79. }
  80. // --------------------------------------------------------------------
  81. // (1) OPEN CONNECTION, (2) SELECT DATABASE
  82. connectToMySQLDatabase(); // function 'connectToMySQLDatabase()' is defined in 'include.inc.php'
  83. // --------------------------------------------------------------------
  84. // For regular users, validate that the correct userID has been passed to the script:
  85. if (isset($_SESSION['loginEmail']) && ($loginEmail != $adminLoginEmail))
  86. // check this user matches the userID (viewing user account details is only allowed to the admin)
  87. if ($userID != getUserID($loginEmail))
  88. {
  89. // otherwise save an error message:
  90. $HeaderString = "You can only view your own user receipt!";
  91. // Write back session variables:
  92. saveSessionVariable("HeaderString", $HeaderString); // function 'saveSessionVariable()' is defined in 'include.inc.php'
  93. $userID = getUserID($loginEmail); // and re-establish the user's correct user_id
  94. }
  95. // Extract the type of action requested by the user, either 'delete' or ''.
  96. // ('' or anything else will be treated equal to 'edit').
  97. // We actually extract the variable 'userAction' only if the admin is logged in
  98. // (since only the admin will be allowed to delete a user):
  99. if (isset($_SESSION['loginEmail']) && ($loginEmail == $adminLoginEmail)) // ('$adminLoginEmail' is specified in 'ini.inc.php')
  100. {
  101. if (isset($_REQUEST['userAction']))
  102. $userAction = $_REQUEST['userAction'];
  103. else
  104. $userAction = ""; // we do it for clarity reasons here (and in order to prevent any 'Undefined variable...' messages)
  105. if ($userAction == "Delete")
  106. {
  107. if ($userID == getUserID($loginEmail)) // if the admin userID was passed to the script
  108. {
  109. // save an error message:
  110. $HeaderString = "You cannot delete your own user data!";
  111. // Write back session variables:
  112. saveSessionVariable("HeaderString", $HeaderString); // function 'saveSessionVariable()' is defined in 'include.inc.php'
  113. $userAction = "Edit"; // and re-set the user action to 'edit'
  114. }
  115. }
  116. else
  117. $userAction = "Edit"; // everything that isn't a 'delete' action will be an 'edit' action
  118. }
  119. else // otherwise we simply assume an 'edit' action, no matter what was passed to the script (thus, no regular user will be able to delete a user)
  120. $userAction = "Edit";
  121. // Extract the view type requested by the user (either 'Mobile', 'Print', 'Web' or ''):
  122. // ('' will produce the default 'Web' output style)
  123. if (isset($_REQUEST['viewType']))
  124. $viewType = $_REQUEST['viewType'];
  125. else
  126. $viewType = "";
  127. // --------------------------------------------------------------------
  128. // Show the login status:
  129. showLogin(); // (function 'showLogin()' is defined in 'include.inc.php')
  130. // Show the user confirmation:
  131. if ($userID == -1) // 'userID=-1' is sent by 'user_validation.php' to indicate a NEW user who has successfully submitted 'user_details.php'
  132. showEmailConfirmation($userID);
  133. else
  134. showUserData($userID, $userAction, $connection);
  135. // ----------------------------------------------
  136. // (5) CLOSE the database connection:
  137. disconnectFromMySQLDatabase(); // function 'disconnectFromMySQLDatabase()' is defined in 'include.inc.php'
  138. // --------------------------------------------------------------------
  139. // Show a new user a confirmation screen, confirming that the submitted user data have been correctly received:
  140. function showEmailConfirmation($userID)
  141. {
  142. global $HeaderString;
  143. global $viewType;
  144. global $loginWelcomeMsg;
  145. global $loginStatus;
  146. global $loginLinks;
  147. global $loginEmail;
  148. global $adminLoginEmail;
  149. global $officialDatabaseName;
  150. // Build the correct header message:
  151. if (!isset($_SESSION['HeaderString']))
  152. $HeaderString = "Submission confirmation:"; // provide the default message
  153. else
  154. {
  155. $HeaderString = $_SESSION['HeaderString']; // extract 'HeaderString' session variable (only necessary if register globals is OFF!)
  156. // Note: though we clear the session variable, the current message is still available to this script via '$HeaderString':
  157. deleteSessionVariable("HeaderString"); // function 'deleteSessionVariable()' is defined in 'include.inc.php'
  158. }
  159. // Call the 'displayHTMLhead()' and 'showPageHeader()' functions (which are defined in 'header.inc.php'):
  160. displayHTMLhead(encodeHTML($officialDatabaseName) . " -- User Receipt", "noindex,nofollow", "Receipt page confirming correct submission of new user details to the " . encodeHTML($officialDatabaseName), "", false, "", $viewType, array());
  161. showPageHeader($HeaderString);
  162. $confirmationText = "Thanks for your interest in the " . encodeHTML($officialDatabaseName) . "!"
  163. . "<br><br>The data you provided have been sent to our database admin."
  164. . "<br>We'll process your request and mail back to you as soon as we can!"
  165. . "<br><br>[Back to <a href=\"index.php\">" . encodeHTML($officialDatabaseName) . " Home</a>]";
  166. // Start a table:
  167. echo "\n<table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"10\" width=\"95%\" summary=\"This table displays user submission feedback\">";
  168. echo "\n<tr>\n\t<td>" . $confirmationText . "</td>\n</tr>";
  169. echo "\n</table>";
  170. }
  171. // --------------------------------------------------------------------
  172. // Show the user an UPDATE receipt:
  173. // (if the admin is logged in, this function will also provide a 'new user INSERT' receipt)
  174. function showUserData($userID, $userAction, $connection)
  175. {
  176. global $HeaderString;
  177. global $viewType;
  178. global $loginWelcomeMsg;
  179. global $loginStatus;
  180. global $loginLinks;
  181. global $loginEmail;
  182. global $adminLoginEmail;
  183. global $officialDatabaseName;
  184. global $defaultLanguage;
  185. global $tableUsers; // defined in 'db.inc.php'
  186. global $loc; // '$loc' is made globally available in 'core.php'
  187. // CONSTRUCT SQL QUERY:
  188. $query = "SELECT * FROM $tableUsers WHERE user_id = " . quote_smart($userID);
  189. // (3) RUN the query on the database through the connection:
  190. $result = queryMySQLDatabase($query); // function 'queryMySQLDatabase()' is defined in 'include.inc.php'
  191. // (4) EXTRACT results (since 'user_id' is the unique primary key for the 'users' table, there will be only one matching row)
  192. $row = @ mysqli_fetch_array($result);
  193. // Build the correct header message:
  194. if (!isset($_SESSION['HeaderString'])) // if there's no saved message
  195. if ($userAction == "Delete") // provide an appropriate header message:
  196. $HeaderString = "Delete user " . encodeHTML($row["first_name"]) . " " . encodeHTML($row["last_name"]) . " (" . $row["email"] . "):";
  197. elseif (empty($userID))
  198. $HeaderString = "Account details and options for anyone who isn't logged in:";
  199. else // provide the default message:
  200. $HeaderString = "Account details and options for " . encodeHTML($row["first_name"]) . " " . encodeHTML($row["last_name"]) . " (" . $row["email"] . "):";
  201. else
  202. {
  203. $HeaderString = $_SESSION['HeaderString']; // extract 'HeaderString' session variable (only necessary if register globals is OFF!)
  204. // Note: though we clear the session variable, the current message is still available to this script via '$HeaderString':
  205. deleteSessionVariable("HeaderString"); // function 'deleteSessionVariable()' is defined in 'include.inc.php'
  206. }
  207. // Get the list of "main fields" preferred by the current user:
  208. // NOTE: We have to call function 'getMainFields()' up here since it updates
  209. // session variable 'userMainFields' which gets used in function
  210. // 'buildQuickSearchElements()' (which, in turn, is called from within
  211. // function 'showPageHeader()')
  212. $mainFieldsArray = getMainFields($userID); // function 'getMainFields()' is defined in 'include.inc.php'
  213. // Get the user's preference for displaying auto-completions:
  214. // (see note for '$mainFieldsArray' which also applies here)
  215. $showAutoCompletions = getPrefAutoCompletions($userID); // function 'getPrefAutoCompletions()' is defined in 'include.inc.php'
  216. // Map MySQL field names to localized column names:
  217. $fieldNamesArray = mapFieldNames(); // function 'mapFieldNames()' is defined in 'include.inc.php'
  218. $localizedMainFieldsArray = array();
  219. foreach ($mainFieldsArray as $field)
  220. {
  221. if (isset($fieldNamesArray[$field]))
  222. $localizedMainFieldsArray[$field] = $fieldNamesArray[$field];
  223. else // no localized field name exists, so we use the original field name
  224. $localizedMainFieldsArray[$field] = $field;
  225. }
  226. // Call the 'displayHTMLhead()' and 'showPageHeader()' functions (which are defined in 'header.inc.php'):
  227. displayHTMLhead(encodeHTML($officialDatabaseName) . " -- User Receipt", "noindex,nofollow", "Receipt page confirming correct entry of user details and options for the " . encodeHTML($officialDatabaseName), "", false, "", $viewType, array());
  228. showPageHeader($HeaderString);
  229. // Start main table:
  230. echo "\n<table id=\"accountinfo\" align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"10\" width=\"95%\" summary=\"This table displays user account details and options\">";
  231. echo "\n<tr>"
  232. . "\n\t<td valign=\"top\" width=\"28%\">";
  233. // Start left sub-table:
  234. echo "\n\t\t<table id=\"accountdetails\" border=\"0\" cellpadding=\"0\" cellspacing=\"10\" summary=\"User account details\">";
  235. echo "\n\t\t<tr>\n\t\t\t<td align=\"left\"><b>Account Details:</b></td>";
  236. if (mysqli_num_rows($result) == 1) // If there's a user associated with this user ID
  237. {
  238. // Add edit/delete button:
  239. echo "\n\t\t\t<td align=\"left\">";
  240. // If the admin is logged in, allow the display of a button that will delete the currently shown user:
  241. if (isset($_SESSION['loginEmail']) && ($loginEmail == $adminLoginEmail)) // ('$adminLoginEmail' is specified in 'ini.inc.php')
  242. {
  243. if ($userAction == "Delete")
  244. echo "<a href=\"user_removal.php?userID=" . $userID . "\"><img src=\"img/delete.gif\" alt=\"" . $loc["delete"] . "\" title=\"" . $loc["LinkTitle_DeleteUser"] . "\" width=\"11\" height=\"17\" hspace=\"0\" border=\"0\"></a>";
  245. }
  246. if ($userAction != "Delete")
  247. echo "<a href=\"user_details.php?userID=" . $userID . "\"><img src=\"img/edit.gif\" alt=\"" . $loc["edit"] . "\" title=\"" . $loc["LinkTitle_EditDetails"] . "\" width=\"11\" height=\"17\" hspace=\"0\" border=\"0\"></a>";
  248. echo "</td>\n\t\t</tr>";
  249. // Display a password reminder:
  250. // (but only if a normal user is logged in -OR- the admin is logged in AND the updated user data are his own!)
  251. if (($loginEmail != $adminLoginEmail) | (($loginEmail == $adminLoginEmail) && ($userID == getUserID($loginEmail))))
  252. echo "\n\t\t<tr>\n\t\t\t<td colspan=\"2\"><i>Please record your password somewhere safe for future use!</i></td>\n\t\t</tr>";
  253. // Print title, first name, last name and institutional abbreviation:
  254. echo "\n\t\t<tr>\n\t\t\t<td colspan=\"2\">\n\t\t\t\t";
  255. if (!empty($row["title"]))
  256. echo $row["title"] . ". ";
  257. echo encodeHTML($row["first_name"]) . " " . encodeHTML($row["last_name"]) . " (" . encodeHTML($row["abbrev_institution"]) . ")"; // Since the first name, last name and abbrev. institution fields are mandatory, we don't need to check if they're empty
  258. // Print institution name:
  259. if (!empty($row["institution"]))
  260. echo "\n\t\t\t\t<br>\n\t\t\t\t" . encodeHTML($row["institution"]);
  261. // Print corporate institution name:
  262. if (!empty($row["corporate_institution"]))
  263. echo "\n\t\t\t\t<br>\n\t\t\t\t" . encodeHTML($row["corporate_institution"]);
  264. // If any of the address lines contain data, add a spacer row:
  265. if (!empty($row["address_line_1"]) || !empty($row["address_line_2"]) || !empty($row["address_line_3"]) || !empty($row["zip_code"]) || !empty($row["city"]) || !empty($row["state"]) || !empty($row["country"]))
  266. echo "\n\t\t\t\t<br>";
  267. // Print first address line:
  268. if (!empty($row["address_line_1"]))
  269. echo "\n\t\t\t\t<br>\n\t\t\t\t" . encodeHTML($row["address_line_1"]);
  270. // Print second address line:
  271. if (!empty($row["address_line_2"]))
  272. echo "\n\t\t\t\t<br>\n\t\t\t\t" . encodeHTML($row["address_line_2"]);
  273. // Print third address line:
  274. if (!empty($row["address_line_3"]))
  275. echo "\n\t\t\t\t<br>\n\t\t\t\t" . encodeHTML($row["address_line_3"]);
  276. // Print zip code and city:
  277. if (!empty($row["zip_code"]) && !empty($row["city"])) // both fields are available
  278. echo "\n\t\t\t\t<br>\n\t\t\t\t" . encodeHTML($row["zip_code"]) . " " . encodeHTML($row["city"]);
  279. elseif (!empty($row["zip_code"]) && empty($row["city"])) // only 'zip_code' available
  280. echo "\n\t\t\t\t<br>\n\t\t\t\t" . encodeHTML($row["zip_code"]);
  281. elseif (empty($row["zip_code"]) && !empty($row["city"])) // only 'city' field available
  282. echo "\n\t\t\t\t<br>\n\t\t\t\t" . encodeHTML($row["city"]);
  283. // Print state:
  284. if (!empty($row["state"]))
  285. echo "\n\t\t\t\t<br>\n\t\t\t\t" . encodeHTML($row["state"]);
  286. // Print country:
  287. if (!empty($row["country"]))
  288. echo "\n\t\t\t\t<br>\n\t\t\t\t" . encodeHTML($row["country"]);
  289. // If any of the phone/url/email fields contain data, add a spacer row:
  290. if (!empty($row["phone"]) || !empty($row["url"]) || !empty($row["email"]))
  291. echo "\n\t\t\t\t<br>";
  292. // Print phone number:
  293. if (!empty($row["phone"]))
  294. echo "\n\t\t\t\t<br>\n\t\t\t\t" . "Phone: " . encodeHTML($row["phone"]);
  295. // Print URL:
  296. if (!empty($row["url"]))
  297. echo "\n\t\t\t\t<br>\n\t\t\t\t" . "URL: <a href=\"" . $row["url"] . "\">" . $row["url"] . "</a>";
  298. // Print email:
  299. echo "\n\t\t\t\t<br>\n\t\t\t\t" . "Email: <a href=\"mailto:" . $row["email"] . "\">" . $row["email"] . "</a>"; // Since the email field is mandatory, we don't need to check if it's empty
  300. echo "\n\t\t\t</td>\n\t\t</tr>";
  301. }
  302. else // no user exists with this user ID
  303. {
  304. echo "\n\t\t\t<td align=\"right\"></td>\n\t\t</tr>";
  305. echo "\n\t\t<tr>\n\t\t\t<td colspan=\"2\">(none)</td>\n\t\t</tr>";
  306. }
  307. // Close left sub-table:
  308. echo "\n\t\t</table>";
  309. // Close left table cell of main table:
  310. echo "\n\t</td>";
  311. if ($userAction != "Delete") // we omit user options and permissions when displaying info for a user pending deletion
  312. {
  313. // ------------------------------------------------------------
  314. // Start middle table cell of main table:
  315. echo "\n\t<td valign=\"top\">";
  316. // Start middle sub-table:
  317. echo "\n\t\t<table id=\"accountopt\" border=\"0\" cellpadding=\"0\" cellspacing=\"10\" summary=\"User account options\">";
  318. echo "\n\t\t<tr>\n\t\t\t<td align=\"left\"><b>Display Options:</b></td>"
  319. . "\n\t\t\t<td align=\"right\">";
  320. if ((mysqli_num_rows($result) == 1) OR ($userID == 0)) // If there's a user associated with this user ID (or if we're supposed to display options/permissions for anyone who isn't logged in)
  321. echo "<a href=\"user_options.php?userID=" . $userID . "\"><img src=\"img/options.gif\" alt=\"" . $loc["options"] . "\" title=\"" . $loc["LinkTitle_EditOptions"] . "\" width=\"11\" height=\"17\" hspace=\"0\" border=\"0\"></a>";
  322. echo "</td>\n\t\t</tr>";
  323. // Show the user's selected interface language:
  324. echo "\n\t\t<tr valign=\"top\">"
  325. . "\n\t\t\t<td>Use language:</td>";
  326. if (mysqli_num_rows($result) == 1) // If there's a user associated with this user ID
  327. echo "\n\t\t\t<td>\n\t\t\t\t<ul>\n\t\t\t\t\t<li>" . $row["language"] . "</li>\n\t\t\t\t</ul>\n\t\t\t</td>";
  328. else // no user exists with this user ID
  329. echo "\n\t\t\t<td>\n\t\t\t\t<ul>\n\t\t\t\t\t<li>" . $defaultLanguage . "</li>\n\t\t\t\t</ul>\n\t\t\t</td>";
  330. echo "\n\t\t</tr>";
  331. // get the default number of records per page preferred by the current user:
  332. $recordsPerPage = getDefaultNumberOfRecords($userID); // function 'getDefaultNumberOfRecords()' is defined in 'include.inc.php'
  333. // show the user's default number of records per page:
  334. echo "\n\t\t<tr valign=\"top\">"
  335. . "\n\t\t\t<td>Show records per page:</td>"
  336. . "\n\t\t\t<td>\n\t\t\t\t<ul>\n\t\t\t\t\t<li>" . $recordsPerPage . "</li>\n\t\t\t\t</ul>\n\t\t\t</td>"
  337. . "\n\t\t</tr>";
  338. // show the user's preference for displaying auto-completions:
  339. echo "\n\t\t<tr valign=\"top\">"
  340. . "\n\t\t\t<td>Show auto-completions:</td>"
  341. . "\n\t\t\t<td>\n\t\t\t\t<ul>\n\t\t\t\t\t<li>" . $loc[$showAutoCompletions] . "</li>\n\t\t\t\t</ul>\n\t\t\t</td>"
  342. . "\n\t\t</tr>";
  343. if ($loginEmail == $adminLoginEmail) // if the admin is logged in
  344. {
  345. $ShowEnabledDescriptor = "Enabled";
  346. // get all formats/styles/types that are available and were enabled by the admin for the current user:
  347. $userTypesArray = getEnabledUserFormatsStylesTypes($userID, "type", "", false); // function 'getEnabledUserFormatsStylesTypes()' is defined in 'include.inc.php'
  348. $citationStylesArray = getEnabledUserFormatsStylesTypes($userID, "style", "", false);
  349. $citationFormatsArray = getEnabledUserFormatsStylesTypes($userID, "format", "cite", false);
  350. $exportFormatsArray = getEnabledUserFormatsStylesTypes($userID, "format", "export", false);
  351. }
  352. else // if a normal user is logged in
  353. {
  354. $ShowEnabledDescriptor = "Show";
  355. // get all formats/styles/types that were selected by the current user
  356. // and (if some formats/styles/types were found) save them as semicolon-delimited string to an appropriate session variable:
  357. $userTypesArray = getVisibleUserFormatsStylesTypes($userID, "type", ""); // function 'getVisibleUserFormatsStylesTypes()' is defined in 'include.inc.php'
  358. $citationStylesArray = getVisibleUserFormatsStylesTypes($userID, "style", "");
  359. $citationFormatsArray = getVisibleUserFormatsStylesTypes($userID, "format", "cite");
  360. $exportFormatsArray = getVisibleUserFormatsStylesTypes($userID, "format", "export");
  361. // Note: the function 'getVisibleUserFormatsStylesTypes()' will only update the appropriate session variables if
  362. // either a normal user is logged in -OR- the admin is logged in AND the updated user data are his own(*);
  363. // otherwise, the function will simply return an array containing all matching values
  364. // (*) the admin-condition won't apply here, though, since this function gets only called for normal users. This means, that
  365. // the admin is currently not able to hide any items from his popup lists via the admin interface (he'll need to hack the MySQL tables)!
  366. }
  367. // list types:
  368. echo "\n\t\t<tr valign=\"top\">"
  369. . "\n\t\t\t<td>" . $ShowEnabledDescriptor . " reference types:</td>"
  370. . "\n\t\t\t<td>\n\t\t\t\t<ul>\n\t\t\t\t\t<li>";
  371. if (empty($userTypesArray))
  372. echo "(none)";
  373. else
  374. echo implode("</li>\n\t\t\t\t\t<li>", $userTypesArray);
  375. echo "</li>\n\t\t\t\t</ul>\n\t\t\t</td>"
  376. . "\n\t\t</tr>";
  377. // list styles:
  378. echo "\n\t\t<tr valign=\"top\">"
  379. . "\n\t\t\t<td>" . $ShowEnabledDescriptor . " citation styles:</td>"
  380. . "\n\t\t\t<td>\n\t\t\t\t<ul>\n\t\t\t\t\t<li>";
  381. if (empty($citationStylesArray))
  382. echo "(none)";
  383. else
  384. echo implode("</li>\n\t\t\t\t\t<li>", $citationStylesArray);
  385. echo "</li>\n\t\t\t\t</ul>\n\t\t\t</td>"
  386. . "\n\t\t</tr>";
  387. // list cite formats:
  388. echo "\n\t\t<tr valign=\"top\">"
  389. . "\n\t\t\t<td>" . $ShowEnabledDescriptor . " citation formats:</td>"
  390. . "\n\t\t\t<td>\n\t\t\t\t<ul>\n\t\t\t\t\t<li>";
  391. if (empty($citationFormatsArray))
  392. echo "(none)";
  393. else
  394. echo implode("</li>\n\t\t\t\t\t<li>", $citationFormatsArray);
  395. echo "</li>\n\t\t\t\t</ul>\n\t\t\t</td>"
  396. . "\n\t\t</tr>";
  397. // list export formats:
  398. echo "\n\t\t<tr valign=\"top\">"
  399. . "\n\t\t\t<td>" . $ShowEnabledDescriptor . " export formats:</td>"
  400. . "\n\t\t\t<td>\n\t\t\t\t<ul>\n\t\t\t\t\t<li>";
  401. if (empty($exportFormatsArray))
  402. echo "(none)";
  403. else
  404. echo implode("</li>\n\t\t\t\t\t<li>", $exportFormatsArray);
  405. echo "</li>\n\t\t\t\t</ul>\n\t\t\t</td>"
  406. . "\n\t\t</tr>";
  407. // list all fields that were selected by the current user as "main fields":
  408. echo "\n\t\t<tr valign=\"top\">"
  409. . "\n\t\t\t<td>\"Main fields\" searches:</td>"
  410. . "\n\t\t\t<td>\n\t\t\t\t<ul>\n\t\t\t\t\t<li>";
  411. if (empty($localizedMainFieldsArray))
  412. echo "(none)";
  413. else
  414. echo implode("</li>\n\t\t\t\t\t<li>", $localizedMainFieldsArray);
  415. echo "</li>\n\t\t\t\t</ul>\n\t\t\t</td>"
  416. . "\n\t\t</tr>";
  417. // Close middle sub-table:
  418. echo "\n\t\t</table>";
  419. // Close middle table cell of main table:
  420. echo "\n\t</td>";
  421. // ------------------------------------------------------------
  422. // Start right table cell of main table:
  423. echo "\n\t<td valign=\"top\">";
  424. // Start right sub-table:
  425. echo "\n\t\t<table id=\"accountperm\" border=\"0\" cellpadding=\"0\" cellspacing=\"10\" summary=\"User account permissions\">";
  426. if ($loginEmail == $adminLoginEmail) // if the admin is logged in
  427. {
  428. // get all user permissions for the current user:
  429. $userPermissionsArray = getPermissions($userID, "user", false); // function 'getPermissions()' is defined in 'include.inc.php'
  430. // map raw field names from table 'user_permissions' with items of the global localization array ('$loc'):
  431. $localizedUserPermissionsArray = array('allow_add' => 'UserPermission_AllowAdd',
  432. 'allow_edit' => 'UserPermission_AllowEdit',
  433. 'allow_delete' => 'UserPermission_AllowDelete',
  434. 'allow_download' => 'UserPermission_AllowDownload',
  435. 'allow_upload' => 'UserPermission_AllowUpload',
  436. 'allow_list_view' => 'UserPermission_AllowListView',
  437. 'allow_details_view' => 'UserPermission_AllowDetailsView',
  438. 'allow_print_view' => 'UserPermission_AllowPrintView',
  439. 'allow_browse_view' => 'UserPermission_AllowBrowseView',
  440. 'allow_sql_search' => 'UserPermission_AllowSQLSearch',
  441. 'allow_user_groups' => 'UserPermission_AllowUserGroups',
  442. 'allow_user_queries' => 'UserPermission_AllowUserQueries',
  443. 'allow_rss_feeds' => 'UserPermission_AllowRSSFeeds',
  444. 'allow_import' => 'UserPermission_AllowImport',
  445. 'allow_export' => 'UserPermission_AllowExport',
  446. 'allow_cite' => 'UserPermission_AllowCite',
  447. 'allow_batch_import' => 'UserPermission_AllowBatchImport',
  448. 'allow_batch_export' => 'UserPermission_AllowBatchExport',
  449. 'allow_modify_options' => 'UserPermission_AllowModifyOptions',
  450. 'allow_edit_call_number' => 'UserPermission_AllowEditCallNumber');
  451. $enabledUserActionsArray = array(); // initialize array variables
  452. $disabledUserActionsArray = array();
  453. // separate enabled permission settings from disabled ones and assign localized permission names:
  454. foreach($userPermissionsArray as $permissionKey => $permissionValue)
  455. {
  456. if ($permissionValue == 'yes')
  457. $enabledUserActionsArray[] = $loc[$localizedUserPermissionsArray[$permissionKey]]; // append this field's localized permission name to the array of enabled user actions
  458. else
  459. $disabledUserActionsArray[] = $loc[$localizedUserPermissionsArray[$permissionKey]]; // append this field's localized permission name to the array of disabled user actions
  460. }
  461. if (empty($enabledUserActionsArray))
  462. $enabledUserActionsArray[] = "(none)";
  463. if (empty($disabledUserActionsArray))
  464. $disabledUserActionsArray[] = "(none)";
  465. echo "\n\t\t<tr>\n\t\t\t<td align=\"left\"><b>User Permissions:</b></td>"
  466. . "\n\t\t\t<td align=\"right\">";
  467. if ((mysqli_num_rows($result) == 1) OR ($userID == 0)) // If there's a user associated with this user ID (or if we're supposed to display options/permissions for anyone who isn't logged in)
  468. echo "<a href=\"user_options.php?userID=" . $userID . "#permissions\"><img src=\"img/options.gif\" alt=\"" . $loc["permissions"] . "\" title=\"" . $loc["LinkTitle_EditPermissions"] . "\" width=\"11\" height=\"17\" hspace=\"0\" border=\"0\"></a>";
  469. echo "</td>\n\t\t</tr>";
  470. echo "\n\t\t<tr valign=\"top\">"
  471. . "\n\t\t\t<td>Enabled features:</td>"
  472. . "\n\t\t\t<td>\n\t\t\t\t<ul>\n\t\t\t\t\t<li>" . implode("</li>\n\t\t\t\t\t<li>", $enabledUserActionsArray) . "</li>\n\t\t\t\t</ul>\n\t\t\t</td>"
  473. . "\n\t\t</tr>";
  474. echo "\n\t\t<tr valign=\"top\">"
  475. . "\n\t\t\t<td>Disabled features:</td>"
  476. . "\n\t\t\t<td>\n\t\t\t\t<ul>\n\t\t\t\t\t<li>" . implode("</li>\n\t\t\t\t\t<li>", $disabledUserActionsArray) . "</li>\n\t\t\t\t</ul>\n\t\t\t</td>"
  477. . "\n\t\t</tr>";
  478. }
  479. // Close right sub-table:
  480. echo "\n\t\t</table>";
  481. // Close right table cell of main table:
  482. echo "\n\t</td>";
  483. }
  484. echo "\n</tr>";
  485. // Close main table:
  486. echo "\n</table>";
  487. }
  488. // --------------------------------------------------------------------
  489. // DISPLAY THE HTML FOOTER:
  490. // call the 'showPageFooter()' and 'displayHTMLfoot()' functions (which are defined in 'footer.inc.php')
  491. showPageFooter($HeaderString);
  492. displayHTMLfoot();
  493. // --------------------------------------------------------------------
  494. ?>