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.

829 lines
31 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_options.php
  11. // Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/user_options.php $
  12. // Author(s): Matthias Steffens <mailto:refbase@extracts.de>
  13. //
  14. // Created: 24-Oct-04, 19:31
  15. // Modified: $Date: 2017-04-13 02:00:18 +0000 (Thu, 13 Apr 2017) $
  16. // $Author: karnesky $
  17. // $Revision: 1416 $
  18. // This script provides options which are individual for each user.
  19. //
  20. // TODO: - I18n, more encodeHTML fixes?
  21. // Incorporate some include files:
  22. include 'initialize/db.inc.php'; // 'db.inc.php' is included to hide username and password
  23. include 'includes/header.inc.php'; // include header
  24. include 'includes/footer.inc.php'; // include footer
  25. include 'includes/include.inc.php'; // include common functions
  26. include 'initialize/ini.inc.php'; // include common variables
  27. // --------------------------------------------------------------------
  28. // START A SESSION:
  29. // call the 'start_session()' function (from 'include.inc.php') which will also read out available session variables:
  30. start_session(true);
  31. // --------------------------------------------------------------------
  32. // Initialize preferred display language:
  33. // (note that 'locales.inc.php' has to be included *after* the call to the 'start_session()' function)
  34. include 'includes/locales.inc.php'; // include the locales
  35. // --------------------------------------------------------------------
  36. // Extract session variables (only necessary if register globals is OFF!):
  37. if (isset($_SESSION['errors']))
  38. $errors = $_SESSION['errors'];
  39. else
  40. $errors = array(); // initialize variable (in order to prevent 'Undefined index/variable...' messages)
  41. if (isset($_SESSION['formVars']))
  42. $formVars = $_SESSION['formVars'];
  43. else
  44. $formVars = array(); // initialize variable (in order to prevent 'Undefined index/variable...' messages)
  45. // The current values of the session variables 'errors' and 'formVars' get stored in '$errors' or '$formVars', respectively. (either automatically if
  46. // register globals is ON, or explicitly if register globals is OFF).
  47. // We need to clear these session variables here, since they would otherwise be there even if 'user_options.php' gets called with a different userID!
  48. // Note: though we clear the session variables, the current error message (or form variables) is still available to this script via '$errors' (or '$formVars', respectively).
  49. deleteSessionVariable("errors"); // function 'deleteSessionVariable()' is defined in 'include.inc.php'
  50. deleteSessionVariable("formVars");
  51. // --------------------------------------------------------------------
  52. // (1) OPEN CONNECTION, (2) SELECT DATABASE
  53. connectToMySQLDatabase(); // function 'connectToMySQLDatabase()' is defined in 'include.inc.php'
  54. // --------------------------------------------------------------------
  55. // A user must be logged in in order to call 'user_options.php':
  56. if (!isset($_SESSION['loginEmail']))
  57. {
  58. // save an error message:
  59. $HeaderString = "You must login to view your user account options!";
  60. // save the URL of the currently displayed page:
  61. $referer = $_SERVER['HTTP_REFERER'];
  62. // Write back session variables:
  63. saveSessionVariable("HeaderString", $HeaderString); // function 'saveSessionVariable()' is defined in 'include.inc.php'
  64. saveSessionVariable("referer", $referer);
  65. header("Location: user_login.php");
  66. exit;
  67. }
  68. // --------------------------------------------------------------------
  69. // Set the '$userID' variable:
  70. if (isset($_REQUEST['userID']) AND preg_match("/^[0-9]+$/", $_REQUEST['userID'])) // for normal users NOT being logged in -OR- for the admin:
  71. $userID = $_REQUEST['userID'];
  72. else
  73. $userID = NULL; // '$userID = ""' wouldn't be correct here, since then any later 'isset($userID)' statement would resolve to true!
  74. if (isset($_SESSION['loginEmail']) && ($loginEmail != $adminLoginEmail)) // a normal user IS logged in ('$adminLoginEmail' is specified in 'ini.inc.php')
  75. // Check this user matches the userID (viewing and modifying other user's account options is only allowed to the admin)
  76. if ($userID != getUserID($loginEmail)) // (function 'getUserID()' is defined in 'include.inc.php')
  77. {
  78. // save an error message:
  79. $HeaderString = "You can only edit your own user data!";
  80. // Write back session variables:
  81. saveSessionVariable("HeaderString", $HeaderString); // function 'saveSessionVariable()' is defined in 'include.inc.php'
  82. $userID = getUserID($loginEmail); // re-establish the user's correct user_id
  83. }
  84. // --------------------------------------------------------------------
  85. // Check the correct parameters have been passed
  86. if ($userID == "") // note that we can't use 'empty($userID)' here, since 'userID=0' must be allowed so that the admin can edit options for the default user (= no user logged in)
  87. {
  88. // save an error message:
  89. $HeaderString = "Missing parameters for script 'user_options.php'!";
  90. // Write back session variables:
  91. saveSessionVariable("HeaderString", $HeaderString); // function 'saveSessionVariable()' is defined in 'include.inc.php'
  92. // Redirect the browser back to the calling page
  93. header("Location: " . $referer); // variable '$referer' is globally defined in function 'start_session()' in 'include.inc.php'
  94. exit;
  95. }
  96. // --------------------------------------------------------------------
  97. // Check if the logged-in user is allowed to modify his account options:
  98. 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'...
  99. {
  100. // save an error message:
  101. $HeaderString = "You have no permission to modify your user account options!";
  102. // Write back session variables:
  103. saveSessionVariable("HeaderString", $HeaderString); // function 'saveSessionVariable()' is defined in 'include.inc.php'
  104. // Redirect the browser back to the calling page
  105. header("Location: " . $referer);
  106. exit;
  107. }
  108. // --------------------------------------------------------------------
  109. // Set header message:
  110. if (!isset($_SESSION['HeaderString'])) // if there's no stored message available
  111. {
  112. if (empty($errors)) // provide the default messages:
  113. $HeaderString = "Modify your account options:";
  114. else // -> there were errors validating the user's options
  115. $HeaderString = "There were validation errors regarding the options you selected. Please check the comments above the respective fields:";
  116. }
  117. else
  118. {
  119. $HeaderString = $_SESSION['HeaderString']; // extract 'HeaderString' session variable (only necessary if register globals is OFF!)
  120. // Note: though we clear the session variable, the current message is still available to this script via '$HeaderString':
  121. deleteSessionVariable("HeaderString"); // function 'deleteSessionVariable()' is defined in 'include.inc.php'
  122. }
  123. // Extract the view type requested by the user (either 'Mobile', 'Print', 'Web' or ''):
  124. // ('' will produce the default 'Web' output style)
  125. if (isset($_REQUEST['viewType']))
  126. $viewType = $_REQUEST['viewType'];
  127. else
  128. $viewType = "";
  129. // CONSTRUCT SQL QUERY:
  130. $query = "SELECT first_name, last_name, email, language FROM $tableUsers WHERE user_id = " . quote_smart($userID);
  131. // (3a) RUN the query on the database through the connection:
  132. $result = queryMySQLDatabase($query); // function 'queryMySQLDatabase()' is defined in 'include.inc.php'
  133. // (3b) EXTRACT results:
  134. $row = mysqli_fetch_array($result); // fetch the current row into the array $row
  135. // If the admin is logged in AND the displayed user data are NOT his own, we overwrite the default header message:
  136. // (Since the admin is allowed to view and edit account data from other users, we have to provide a dynamic header message in that case)
  137. if (($loginEmail == $adminLoginEmail) && (!empty($userID)) && ($userID != getUserID($loginEmail))) // ('$adminLoginEmail' is specified in 'ini.inc.php')
  138. $HeaderString = "Edit account options for " . encodeHTML($row["first_name"]) . " " . encodeHTML($row["last_name"]) . " (" . $row["email"] . "):";
  139. elseif (empty($userID))
  140. $HeaderString = "Edit account options for anyone who isn't logged in:";
  141. // Show the login status:
  142. showLogin(); // (function 'showLogin()' is defined in 'include.inc.php')
  143. // (4) DISPLAY header:
  144. // call the 'displayHTMLhead()' and 'showPageHeader()' functions (which are defined in 'header.inc.php'):
  145. displayHTMLhead(encodeHTML($officialDatabaseName) . " -- User Options", "noindex,nofollow", "User options offered by the " . encodeHTML($officialDatabaseName), "\n\t<meta http-equiv=\"expires\" content=\"0\">", true, "", $viewType, array());
  146. showPageHeader($HeaderString);
  147. // --------------------------------------------------------------------
  148. if (empty($errors))
  149. {
  150. // Reset the '$formVars' variable (since we're loading from the user tables):
  151. $formVars = array();
  152. // Reset the '$errors' variable:
  153. $errors = array();
  154. // Load all the form variables with user data & options:
  155. $formVars["language"] = $row["language"];
  156. }
  157. // Initialize variables which will set form elements according to the current user's options:
  158. // Get all user options for the current user:
  159. $userOptionsArray = getUserOptions($userID); // function 'getUserOptions()' is defined in 'include.inc.php'
  160. // Display Options:
  161. if (!empty($userID))
  162. {
  163. // Get all languages that were setup and enabled by the admin:
  164. $languagesArray = getLanguages(""); // function 'getLanguages()' is defined in 'include.inc.php'
  165. $fieldDisabled = "";
  166. }
  167. else // if '$userID == 0' which indicates a user not being logged in
  168. {
  169. $languagesArray = array($defaultLanguage); // for a user who's not logged in, we fall back to the default language (defined in 'ini.inc.php')
  170. $fieldDisabled = " disabled"; // disable some fields if the user isn't logged in (in which case the display language, no. of records per page, show auto-completions & the "main fields" search option will be taken from global variables in 'ini.inc.php')
  171. }
  172. $languageOptionTags = buildSelectMenuOptions($languagesArray, "/ *; */", "\t\t\t", false); // build properly formatted <option> tag elements from language items returned by function 'getLanguages()'
  173. $userLanguage = getLanguages($userID); // get the preferred language for the current user
  174. $languageOptionTags = preg_replace("/<option>$userLanguage[0]/i", "<option selected>$userLanguage[0]", $languageOptionTags); // select the user's preferred language
  175. // Get the default number of records per page preferred by the current user:
  176. // 'records_per_page' option:
  177. $recordsPerPage = getDefaultNumberOfRecords($userID); // function 'getDefaultNumberOfRecords()' is defined in 'include.inc.php'
  178. // Get the user's preference for displaying auto-completions:
  179. // 'show_auto_completions' option:
  180. $showAutoCompletions = getPrefAutoCompletions($userID); // function 'getPrefAutoCompletions()' is defined in 'include.inc.php'
  181. if ($showAutoCompletions == "yes")
  182. {
  183. $showAutoCompletionsChecked = " checked";
  184. $dontShowAutoCompletionsChecked = "";
  185. }
  186. else
  187. {
  188. $showAutoCompletionsChecked = "";
  189. $dontShowAutoCompletionsChecked = " checked";
  190. }
  191. // Get all reference types that are available (admin logged in) or which were enabled for the current user (normal user logged in):
  192. $typeOptionTags = returnFormatsStylesTypesAsOptionTags($userID, "type", ""); // function 'returnFormatsStylesTypesAsOptionTags()' is defined in 'include.inc.php'
  193. // Get all citation styles that are available (admin logged in) or which were enabled for the current user (normal user logged in):
  194. $styleOptionTags = returnFormatsStylesTypesAsOptionTags($userID, "style", "");
  195. // Get all citation formats that are available (admin logged in) or which were enabled for the current user (normal user logged in):
  196. $citeFormatOptionTags = returnFormatsStylesTypesAsOptionTags($userID, "format", "cite");
  197. // Get all export formats that are available (admin logged in) or which were enabled for the current user (normal user logged in):
  198. $exportFormatOptionTags = returnFormatsStylesTypesAsOptionTags($userID, "format", "export");
  199. if ($loginEmail == $adminLoginEmail) // if the admin is logged in
  200. $selectListIdentifier = "Enabled";
  201. else // if ($loginEmail != $adminLoginEmail) // if a normal user is logged in
  202. $selectListIdentifier = "Show";
  203. // Map MySQL field names to localized column names:
  204. $fieldNamesArray = mapFieldNames(true); // function 'mapFieldNames()' is defined in 'include.inc.php'
  205. $mainFieldsArray = array();
  206. // Define fields that can be designated as "main fields":
  207. foreach ($availableMainFields as $field) // variable '$availableMainFields' is defined in 'ini.inc.php'
  208. if (isset($fieldNamesArray[$field]))
  209. $mainFieldsArray[$field] = $fieldNamesArray[$field];
  210. // Build properly formatted <option> tag elements from array items given in '$mainFieldsArray':
  211. $mainFieldsOptionTags = buildSelectMenuOptions($mainFieldsArray, "//", "\t\t\t", true); // function 'buildSelectMenuOptions()' is defined in 'include.inc.php'
  212. // Get the list of "main fields" preferred by the current user:
  213. // 'main_fields' option:
  214. $userMainFieldsArray = getMainFields($userID);
  215. // select all fields that shall be searched when the "main fields" search option is chosen:
  216. // (these fields will also be included as separate entries in the "Quick Search drop-down menu)
  217. foreach($userMainFieldsArray as $userMainField)
  218. $mainFieldsOptionTags = preg_replace("/<option([^>]*)>" . $mainFieldsArray[$userMainField] . "<\\/option>/", "<option\\1 selected>" . $mainFieldsArray[$userMainField] . "</option>", $mainFieldsOptionTags);
  219. // Cite Options:
  220. // 'use_custom_text_citation_format' option:
  221. if (!empty($userOptionsArray) AND ($userOptionsArray['use_custom_text_citation_format'] == "yes"))
  222. $useCustomTextCitationFormatChecked = " checked";
  223. else
  224. $useCustomTextCitationFormatChecked = "";
  225. // 'text_citation_format' option:
  226. if (!empty($userOptionsArray['text_citation_format']))
  227. $textCitationFormat = $userOptionsArray['text_citation_format'];
  228. else
  229. $textCitationFormat = "";
  230. // Export Options:
  231. // 'export_cite_keys' option:
  232. if (!empty($userOptionsArray) AND ($userOptionsArray['export_cite_keys'] == "yes"))
  233. $exportCiteKeysChecked = " checked";
  234. else
  235. $exportCiteKeysChecked = "";
  236. // 'autogenerate_cite_keys' option:
  237. if (!empty($userOptionsArray) AND ($userOptionsArray['autogenerate_cite_keys'] == "yes"))
  238. $autogenerateCiteKeysChecked = " checked";
  239. else
  240. $autogenerateCiteKeysChecked = "";
  241. // 'prefer_autogenerated_cite_keys' option:
  242. if (!empty($userOptionsArray) AND ($userOptionsArray['prefer_autogenerated_cite_keys'] == "yes"))
  243. {
  244. $preferAutogeneratedCiteKeysChecked = " checked";
  245. $dontPreferAutogeneratedCiteKeysChecked = "";
  246. }
  247. else
  248. {
  249. $preferAutogeneratedCiteKeysChecked = "";
  250. $dontPreferAutogeneratedCiteKeysChecked = " checked";
  251. }
  252. // 'use_custom_cite_key_format' option:
  253. if (!empty($userOptionsArray) AND ($userOptionsArray['use_custom_cite_key_format'] == "yes"))
  254. $useCustomCiteKeyFormatChecked = " checked";
  255. else
  256. $useCustomCiteKeyFormatChecked = "";
  257. // 'cite_key_format' option:
  258. if (!empty($userOptionsArray['cite_key_format']))
  259. $citeKeyFormat = $userOptionsArray['cite_key_format'];
  260. else
  261. $citeKeyFormat = "";
  262. // 'uniquify_duplicate_cite_keys' option:
  263. if (!empty($userOptionsArray) AND ($userOptionsArray['uniquify_duplicate_cite_keys'] == "yes"))
  264. $uniquifyDuplicateCiteKeysChecked = " checked";
  265. else
  266. $uniquifyDuplicateCiteKeysChecked = "";
  267. // define variable holding drop-down elements:
  268. $dropDownItemArray = array("transliterate" => "transliterate",
  269. "strip" => "strip",
  270. "keep" => "keep");
  271. // build properly formatted <option> tag elements from array items given in '$dropDownItemArray':
  272. $nonASCIICharsInCiteKeysOptionTags = buildSelectMenuOptions($dropDownItemArray, "//", "\t\t\t", true); // function 'buildSelectMenuOptions()' is defined in 'include.inc.php'
  273. // 'nonascii_chars_in_cite_keys' option:
  274. if (!empty($userOptionsArray['nonascii_chars_in_cite_keys']))
  275. {
  276. $useCustomHandlingOfNonASCIICharsInCiteKeysChecked = " checked";
  277. // select the drop down option chosen by the current user:
  278. $nonASCIICharsInCiteKeysOptionTags = preg_replace("/<option([^>]*)>" . $userOptionsArray['nonascii_chars_in_cite_keys'] . "/", "<option\\1 selected>" . $userOptionsArray['nonascii_chars_in_cite_keys'], $nonASCIICharsInCiteKeysOptionTags);
  279. }
  280. else
  281. $useCustomHandlingOfNonASCIICharsInCiteKeysChecked = "";
  282. // Start <form> and <table> holding all the form elements:
  283. ?>
  284. <form method="POST" action="user_options_modify.php" name="userOptions">
  285. <input type="hidden" name="userID" value="<?php echo encodeHTML($userID) ?>">
  286. <table align="center" border="0" cellpadding="0" cellspacing="10" width="95%" summary="This table holds a form with user options">
  287. <tr>
  288. <td align="left" width="169"><b><a id="display">Display Options:</a></b></td>
  289. <td align="left" width="169">Use language:</td>
  290. <td><?php echo fieldError("languageName", $errors); ?>
  291. <select name="languageName"<?php echo $fieldDisabled; ?>><?php echo $languageOptionTags; ?>
  292. </select>
  293. </td>
  294. </tr>
  295. <tr>
  296. <td align="left"></td>
  297. <td align="left">Show records per page:</td>
  298. <td><?php echo fieldError("recordsPerPageNo", $errors); ?>
  299. <input type="text" name="recordsPerPageNo" value="<?php echo encodeHTML($recordsPerPage); ?>" size="5"<?php echo $fieldDisabled; ?>>
  300. </td>
  301. </tr>
  302. <tr>
  303. <td align="left"></td>
  304. <td align="left">Show auto-completions:</td>
  305. <td>
  306. <input type="radio" name="showAutoCompletionsRadio" value="yes"<?php echo $showAutoCompletionsChecked . $fieldDisabled; ?>>&nbsp;&nbsp;yes
  307. &nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="showAutoCompletionsRadio" value="no"<?php echo $dontShowAutoCompletionsChecked . $fieldDisabled; ?>>&nbsp;&nbsp;no
  308. </td>
  309. </tr>
  310. <tr>
  311. <td align="left"></td>
  312. <td align="left" valign="top"><?php echo $selectListIdentifier; ?> reference types:</td>
  313. <td valign="top"><?php echo fieldError("referenceTypeSelector", $errors); ?>
  314. <select name="referenceTypeSelector[]" multiple><?php echo $typeOptionTags; ?>
  315. </select>
  316. </td>
  317. </tr>
  318. <tr>
  319. <td align="left"></td>
  320. <td align="left" valign="top"><?php echo $selectListIdentifier; ?> citation styles:</td>
  321. <td valign="top"><?php echo fieldError("citationStyleSelector", $errors); ?>
  322. <select name="citationStyleSelector[]" multiple><?php echo $styleOptionTags; ?>
  323. </select>
  324. </td>
  325. </tr>
  326. <tr>
  327. <td align="left"></td>
  328. <td align="left" valign="top"><?php echo $selectListIdentifier; ?> citation formats:</td>
  329. <td valign="top"><?php echo fieldError("citationFormatSelector", $errors); ?>
  330. <select name="citationFormatSelector[]" multiple><?php echo $citeFormatOptionTags; ?>
  331. </select>
  332. </td>
  333. </tr>
  334. <tr>
  335. <td align="left"></td>
  336. <td align="left" valign="top"><?php echo $selectListIdentifier; ?> export formats:</td>
  337. <td valign="top"><?php echo fieldError("exportFormatSelector", $errors); ?>
  338. <select name="exportFormatSelector[]" multiple><?php echo $exportFormatOptionTags; ?>
  339. </select>
  340. </td>
  341. </tr>
  342. <tr>
  343. <td align="left"></td>
  344. <td align="left" valign="top">"Main fields" searches:</td>
  345. <td valign="top"><?php echo fieldError("mainFieldsSelector", $errors); ?>
  346. <select name="mainFieldsSelector[]" multiple<?php echo $fieldDisabled; ?>><?php echo $mainFieldsOptionTags; ?>
  347. </select>
  348. </td>
  349. </tr>
  350. <tr>
  351. <td align="left"></td>
  352. <td colspan="2">
  353. <input type="submit" value="Submit">
  354. </td>
  355. </tr>
  356. <tr>
  357. <td align="left" height="15"></td>
  358. <td colspan="2"></td>
  359. </tr>
  360. <tr>
  361. <td align="left"><b><a id="cite">Cite Options:</a></b></td>
  362. <td colspan="2">
  363. <input type="checkbox" name="use_custom_text_citation_format" value="yes"<?php echo $useCustomTextCitationFormatChecked; ?>>&nbsp;&nbsp;Use custom text citation format:
  364. </td>
  365. </tr>
  366. <tr>
  367. <td align="left"></td>
  368. <td colspan="2">
  369. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="text_citation_format" value="<?php echo encodeHTML($textCitationFormat); ?>" size="46">
  370. </td>
  371. </tr>
  372. <tr>
  373. <td align="left"></td>
  374. <td colspan="2"></td>
  375. </tr>
  376. <tr>
  377. <td align="left"></td>
  378. <td colspan="2">
  379. <input type="submit" value="Submit">
  380. </td>
  381. </tr>
  382. <tr>
  383. <td align="left" height="15"></td>
  384. <td colspan="2"></td>
  385. </tr>
  386. <tr>
  387. <td align="left"><b><a id="export">Import/Export Options:</a></b></td>
  388. <td colspan="2">
  389. <input type="checkbox" name="export_cite_keys" value="yes"<?php echo $exportCiteKeysChecked; ?>>&nbsp;&nbsp;Include or generate cite keys
  390. </td>
  391. </tr>
  392. <tr>
  393. <td align="left"></td>
  394. <td colspan="2">
  395. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="autogenerate_cite_keys" value="yes"<?php echo $autogenerateCiteKeysChecked; ?>>&nbsp;&nbsp;Auto-generate cite keys for:
  396. </td>
  397. </tr>
  398. <tr>
  399. <td align="left"></td>
  400. <td colspan="2">
  401. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="prefer_autogenerated_cite_keys" value="yes"<?php echo $preferAutogeneratedCiteKeysChecked; ?>>&nbsp;&nbsp;all records
  402. </td>
  403. </tr>
  404. <tr>
  405. <td align="left"></td>
  406. <td colspan="2">
  407. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="prefer_autogenerated_cite_keys" value="no"<?php echo $dontPreferAutogeneratedCiteKeysChecked; ?>>&nbsp;&nbsp;records with empty 'Cite Key' (ID) field
  408. </td>
  409. </tr>
  410. <tr>
  411. <td align="left"></td>
  412. <td colspan="2">
  413. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="use_custom_cite_key_format" value="yes"<?php echo $useCustomCiteKeyFormatChecked; ?>>&nbsp;&nbsp;Use custom format for auto-generated cite keys:
  414. </td>
  415. </tr>
  416. <tr>
  417. <td align="left"></td>
  418. <td colspan="2">
  419. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="cite_key_format" value="<?php echo encodeHTML($citeKeyFormat); ?>" size="46">
  420. </td>
  421. </tr>
  422. <tr>
  423. <td align="left"></td>
  424. <td colspan="2">
  425. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="use_custom_handling_of_nonascii_chars_in_cite_keys" value="yes"<?php echo $useCustomHandlingOfNonASCIICharsInCiteKeysChecked; ?>>&nbsp;&nbsp;Use custom handling of non-ASCII characters in cite keys:
  426. </td>
  427. </tr>
  428. <tr>
  429. <td align="left"></td>
  430. <td colspan="2">
  431. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  432. <select name="nonascii_chars_in_cite_keys"><?php echo $nonASCIICharsInCiteKeysOptionTags; ?>
  433. </select>
  434. </td>
  435. </tr>
  436. <tr>
  437. <td align="left"></td>
  438. <td colspan="2">
  439. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="uniquify_duplicate_cite_keys" value="yes"<?php echo $uniquifyDuplicateCiteKeysChecked; ?>>&nbsp;&nbsp;Append incrementing numbers to duplicate cite keys
  440. </td>
  441. </tr>
  442. <tr>
  443. <td align="left"></td>
  444. <td colspan="2"></td>
  445. </tr>
  446. <tr>
  447. <td align="left"></td>
  448. <td colspan="2">
  449. <input type="submit" value="Submit">
  450. </td>
  451. </tr><?php
  452. if ($loginEmail == $adminLoginEmail) // if the admin is logged in, add form elements to set the user's permissions:
  453. {
  454. // Get the user permissions for the current user:
  455. $userPermissionsArray = getPermissions($userID, "user", false); // function 'getPermissions()' is defined in 'include.inc.php'
  456. // Setup variables to mark the checkboxes according to the user's permissions:
  457. if ($userPermissionsArray['allow_add'] == 'yes')
  458. $allowAddChecked = " checked";
  459. else
  460. $allowAddChecked = "";
  461. if ($userPermissionsArray['allow_edit'] == 'yes')
  462. $allowEditChecked = " checked";
  463. else
  464. $allowEditChecked = "";
  465. if ($userPermissionsArray['allow_delete'] == 'yes')
  466. $allowDeleteChecked = " checked";
  467. else
  468. $allowDeleteChecked = "";
  469. if ($userPermissionsArray['allow_download'] == 'yes')
  470. $allowDownloadChecked = " checked";
  471. else
  472. $allowDownloadChecked = "";
  473. if ($userPermissionsArray['allow_upload'] == 'yes')
  474. $allowUploadChecked = " checked";
  475. else
  476. $allowUploadChecked = "";
  477. if ($userPermissionsArray['allow_list_view'] == 'yes')
  478. $allowListViewChecked = " checked";
  479. else
  480. $allowListViewChecked = "";
  481. if ($userPermissionsArray['allow_details_view'] == 'yes')
  482. $allowDetailsViewChecked = " checked";
  483. else
  484. $allowDetailsViewChecked = "";
  485. if ($userPermissionsArray['allow_print_view'] == 'yes')
  486. $allowPrintViewChecked = " checked";
  487. else
  488. $allowPrintViewChecked = "";
  489. if ($userPermissionsArray['allow_browse_view'] == 'yes') // 'Browse view' isn't presented as visible option yet
  490. $allowBrowseViewChecked = " checked";
  491. else
  492. $allowBrowseViewChecked = "";
  493. if ($userPermissionsArray['allow_sql_search'] == 'yes')
  494. $allowSQLSearchChecked = " checked";
  495. else
  496. $allowSQLSearchChecked = "";
  497. if ($userPermissionsArray['allow_user_groups'] == 'yes')
  498. $allowUserGroupsChecked = " checked";
  499. else
  500. $allowUserGroupsChecked = "";
  501. if ($userPermissionsArray['allow_user_queries'] == 'yes')
  502. $allowUserQueriesChecked = " checked";
  503. else
  504. $allowUserQueriesChecked = "";
  505. if ($userPermissionsArray['allow_rss_feeds'] == 'yes')
  506. $allowRSSFeedsChecked = " checked";
  507. else
  508. $allowRSSFeedsChecked = "";
  509. if ($userPermissionsArray['allow_import'] == 'yes')
  510. $allowImportChecked = " checked";
  511. else
  512. $allowImportChecked = "";
  513. if ($userPermissionsArray['allow_batch_import'] == 'yes')
  514. $allowBatchImportChecked = " checked";
  515. else
  516. $allowBatchImportChecked = "";
  517. if ($userPermissionsArray['allow_export'] == 'yes')
  518. $allowExportChecked = " checked";
  519. else
  520. $allowExportChecked = "";
  521. if ($userPermissionsArray['allow_batch_export'] == 'yes')
  522. $allowBatchExportChecked = " checked";
  523. else
  524. $allowBatchExportChecked = "";
  525. if ($userPermissionsArray['allow_cite'] == 'yes')
  526. $allowCiteChecked = " checked";
  527. else
  528. $allowCiteChecked = "";
  529. if ($userPermissionsArray['allow_modify_options'] == 'yes')
  530. $allowChangePersonInfoChecked = " checked";
  531. else
  532. $allowChangePersonInfoChecked = "";
  533. ?>
  534. <tr>
  535. <td align="left" height="15"></td>
  536. <td colspan="2"></td>
  537. </tr>
  538. <tr>
  539. <td align="left"><b><a id="permissions">User Permissions:</a></b></td>
  540. <td>
  541. <input type="checkbox" name="allow_add" value="yes"<?php echo $allowAddChecked; ?>>&nbsp;&nbsp;<?php echo $loc['UserPermission_AllowAdd']; ?>
  542. </td>
  543. <td>
  544. <input type="checkbox" name="allow_download" value="yes"<?php echo $allowDownloadChecked; ?>>&nbsp;&nbsp;<?php echo $loc['UserPermission_AllowDownload']; ?>
  545. </td>
  546. </tr>
  547. <tr>
  548. <td align="left" class="small">
  549. <!--<a href="JavaScript:checkall(true,'allow*')" title="select all permission options">Select All</a>&nbsp;&nbsp;&nbsp;-->
  550. <!--<a href="JavaScript:checkall(false,'allow*')" title="deselect all permission options">Deselect All</a>-->
  551. </td>
  552. <td>
  553. <input type="checkbox" name="allow_edit" value="yes"<?php echo $allowEditChecked; ?>>&nbsp;&nbsp;<?php echo $loc['UserPermission_AllowEdit']; ?>
  554. </td>
  555. <td>
  556. <input type="checkbox" name="allow_upload" value="yes"<?php echo $allowUploadChecked; ?>>&nbsp;&nbsp;<?php echo $loc['UserPermission_AllowUpload']; ?>
  557. </td>
  558. </tr>
  559. <tr>
  560. <td align="left"></td>
  561. <td>
  562. <input type="checkbox" name="allow_delete" value="yes"<?php echo $allowDeleteChecked; ?>>&nbsp;&nbsp;<?php echo $loc['UserPermission_AllowDelete']; ?>
  563. </td>
  564. <td></td>
  565. </tr>
  566. <tr>
  567. <td align="left"></td>
  568. <td colspan="2"></td>
  569. </tr>
  570. <tr>
  571. <td align="left"></td>
  572. <td>
  573. <input type="checkbox" name="allow_list_view" value="yes"<?php echo $allowListViewChecked; ?>>&nbsp;&nbsp;<?php echo $loc['UserPermission_AllowListView']; ?>
  574. </td>
  575. <td>
  576. <input type="checkbox" name="allow_print_view" value="yes"<?php echo $allowPrintViewChecked; ?>>&nbsp;&nbsp;<?php echo $loc['UserPermission_AllowPrintView']; ?>
  577. </td>
  578. </tr>
  579. <tr>
  580. <td align="left"></td>
  581. <td>
  582. <input type="checkbox" name="allow_details_view" value="yes"<?php echo $allowDetailsViewChecked; ?>>&nbsp;&nbsp;<?php echo $loc['UserPermission_AllowDetailsView']; ?>
  583. </td>
  584. <td></td>
  585. </tr>
  586. <tr>
  587. <td align="left"></td>
  588. <td colspan="2"></td>
  589. </tr>
  590. <tr>
  591. <td align="left"></td>
  592. <td>
  593. <input type="checkbox" name="allow_sql_search" value="yes"<?php echo $allowSQLSearchChecked; ?>>&nbsp;&nbsp;<?php echo $loc['UserPermission_AllowSQLSearch']; ?>
  594. </td>
  595. <td></td>
  596. </tr>
  597. <tr>
  598. <td align="left"></td>
  599. <td colspan="2"></td>
  600. </tr>
  601. <tr>
  602. <td align="left"></td>
  603. <td>
  604. <input type="checkbox" name="allow_user_groups" value="yes"<?php echo $allowUserGroupsChecked; ?>>&nbsp;&nbsp;<?php echo $loc['UserPermission_AllowUserGroups']; ?>
  605. </td>
  606. <td>
  607. <input type="checkbox" name="allow_rss_feeds" value="yes"<?php echo $allowRSSFeedsChecked; ?>>&nbsp;&nbsp;<?php echo $loc['UserPermission_AllowRSSFeeds']; ?>
  608. </td>
  609. </tr>
  610. <tr>
  611. <td align="left"></td>
  612. <td>
  613. <input type="checkbox" name="allow_user_queries" value="yes"<?php echo $allowUserQueriesChecked; ?>>&nbsp;&nbsp;<?php echo $loc['UserPermission_AllowUserQueries']; ?>
  614. </td>
  615. <td></td>
  616. </tr>
  617. <tr>
  618. <td align="left"></td>
  619. <td colspan="2"></td>
  620. </tr>
  621. <tr>
  622. <td align="left"></td>
  623. <td>
  624. <input type="checkbox" name="allow_import" value="yes"<?php echo $allowImportChecked; ?>>&nbsp;&nbsp;<?php echo $loc['UserPermission_AllowImport']; ?>
  625. </td>
  626. <td>
  627. <input type="checkbox" name="allow_batch_import" value="yes"<?php echo $allowBatchImportChecked; ?>>&nbsp;&nbsp;<?php echo $loc['UserPermission_AllowBatchImport']; ?>
  628. </td>
  629. </tr>
  630. <tr>
  631. <td align="left"></td>
  632. <td>
  633. <input type="checkbox" name="allow_export" value="yes"<?php echo $allowExportChecked; ?>>&nbsp;&nbsp;<?php echo $loc['UserPermission_AllowExport']; ?>
  634. </td>
  635. <td>
  636. <input type="checkbox" name="allow_batch_export" value="yes"<?php echo $allowBatchExportChecked; ?>>&nbsp;&nbsp;<?php echo $loc['UserPermission_AllowBatchExport']; ?>
  637. </td>
  638. </tr>
  639. <tr>
  640. <td align="left"></td>
  641. <td>
  642. <input type="checkbox" name="allow_cite" value="yes"<?php echo $allowCiteChecked; ?>>&nbsp;&nbsp;<?php echo $loc['UserPermission_AllowCite']; ?>
  643. </td>
  644. <td></td>
  645. </tr>
  646. <tr>
  647. <td align="left"></td>
  648. <td colspan="2"></td>
  649. </tr>
  650. <tr>
  651. <td align="left"></td>
  652. <td>
  653. <input type="checkbox" name="allow_modify_options" value="yes"<?php echo $allowChangePersonInfoChecked; ?>>&nbsp;&nbsp;<?php echo $loc['UserPermission_AllowModifyOptions']; ?>
  654. </td>
  655. <td></td>
  656. </tr>
  657. <tr>
  658. <td align="left"></td>
  659. <td colspan="2"></td>
  660. </tr>
  661. <tr>
  662. <td align="left"></td>
  663. <td colspan="2">
  664. <input type="submit" value="Submit">
  665. </td>
  666. </tr><?php
  667. }
  668. ?>
  669. </table>
  670. </form><?php
  671. // --------------------------------------------------------------------
  672. // (5) CLOSE the database connection:
  673. disconnectFromMySQLDatabase(); // function 'disconnectFromMySQLDatabase()' is defined in 'include.inc.php'
  674. // SHOW ERROR IN RED:
  675. function fieldError($fieldName, $errors)
  676. {
  677. if (isset($errors[$fieldName]))
  678. echo "\n\t\t<b><span class=\"warning\">" . $errors[$fieldName] . "</span></b>\n\t\t<br>";
  679. }
  680. // --------------------------------------------------------------------
  681. // DISPLAY THE HTML FOOTER:
  682. // call the 'showPageFooter()' and 'displayHTMLfoot()' functions (which are defined in 'footer.inc.php')
  683. showPageFooter($HeaderString);
  684. displayHTMLfoot();
  685. // --------------------------------------------------------------------
  686. ?>