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.

637 lines
29 KiB

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