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.

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