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.

1699 lines
84 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: ./record.php
  11. // Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/record.php $
  12. // Author(s): Matthias Steffens <mailto:refbase@extracts.de>
  13. //
  14. // Created: 29-Jul-02, 16:39
  15. // Modified: $Date: 2017-04-13 02:00:18 +0000 (Thu, 13 Apr 2017) $
  16. // $Author: karnesky $
  17. // $Revision: 1416 $
  18. // Form that offers to add
  19. // records or edit/delete
  20. // existing ones.
  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:
  37. if (isset($_SESSION['errors']))
  38. {
  39. $errors = $_SESSION['errors']; // read session variable (only necessary if register globals is OFF!)
  40. // Note: though we clear the session variable, the current error message is still available to this script via '$errors':
  41. deleteSessionVariable("errors"); // function 'deleteSessionVariable()' is defined in 'include.inc.php'
  42. }
  43. else
  44. $errors = array(); // initialize the '$errors' variable in order to prevent 'Undefined variable...' messages
  45. if (isset($_SESSION['formVars']))
  46. {
  47. $formVars = $_SESSION['formVars']; // read session variable (only necessary if register globals is OFF!)
  48. // Note: though we clear the session variable, the current form variables are still available to this script via '$formVars':
  49. deleteSessionVariable("formVars"); // function 'deleteSessionVariable()' is defined in 'include.inc.php'
  50. }
  51. else
  52. $formVars = array();
  53. // Read out import data that were saved as a session variable:
  54. // NOTE: This is done by 'import_modify.php' (if a single record was imported via the web interface) in order to retain
  55. // large param/value strings (that would exceed the maximum string limit for GET requests). This works around a limitation
  56. // in Internet Explorer which has a maximum URL length of 2,083 characters & a maximum path length of 2,048 characters.
  57. // More info: <http://support.microsoft.com/kb/208427/EN-US/>
  58. if (isset($_SESSION['importData']))
  59. {
  60. foreach ($_SESSION['importData'] as $varname => $value)
  61. {
  62. $_POST[$varname] = $value;
  63. $_REQUEST[$varname] = $value;
  64. }
  65. deleteSessionVariable("importData"); // function 'deleteSessionVariable()' is defined in 'include.inc.php'
  66. }
  67. // --------------------------------------------------------------------
  68. if (isset($_REQUEST['recordAction']))
  69. $recordAction = $_REQUEST['recordAction']; // check whether the user wants to *add* a record or *edit* an existing one
  70. else
  71. $recordAction = ""; // if the 'recordAction' parameter wasn't set we set the '$recordAction' variable to the empty string ("") to prevent 'Undefined index: recordAction...' notification messages
  72. if (isset($_REQUEST['mode']))
  73. $mode = $_REQUEST['mode']; // check whether the user wants to add a record by use of an *import* form (e.g., the parameter "mode=import" will be set by 'import_modify.php' and 'import_csa_modify.php')
  74. else
  75. $mode = ""; // if the 'mode' parameter wasn't set we set the '$mode' variable to the empty string ("") to prevent 'Undefined index: mode...' notification messages
  76. if (isset($_REQUEST['importSource']))
  77. $importSource = $_REQUEST['importSource']; // get the source from which the imported data originate (e.g., if data have been imported via 'import_csa.php', the 'importSource' value will be 'csa')
  78. else
  79. $importSource = ""; // if the 'importSource' parameter wasn't set we set the '$importSource' variable to the empty string ("") to prevent 'Undefined index: importSource...' notification messages
  80. if (isset($_REQUEST['serialNo']))
  81. $serialNo = $_REQUEST['serialNo']; // fetch the serial number of the record to edit
  82. else
  83. $serialNo = ""; // this is actually unneccessary, but we do it for clarity reasons here
  84. // Setup some required variables:
  85. // If there's no stored message available:
  86. if (!isset($_SESSION['HeaderString'])) // if there's no stored message available
  87. {
  88. if (empty($errors)) // provide one of the default messages:
  89. {
  90. $errors = array(); // re-assign an empty array (in order to prevent 'Undefined variable "errors"...' messages when calling the 'fieldError' function later on)
  91. if ($recordAction == "edit") // *edit* record
  92. $HeaderString = $loc["EditRecordHeaderText"] . ":";
  93. else // *add* record will be the default action if no parameter is given
  94. {
  95. $HeaderString = $loc["AddRecordHeaderText"];
  96. if (isset($_REQUEST['source'])) // when importing data, we display the original source data if the 'source' parameter is present:
  97. $HeaderString .= ". Original source data:\n" . encodeHTML($_REQUEST['source']); // the 'source' parameter gets passed by 'import.php' or 'import_csa.php'
  98. else
  99. $HeaderString .= ":";
  100. }
  101. }
  102. else // -> there were errors validating the data entered by the user
  103. $HeaderString = $loc["Warning_InputDataError"];
  104. }
  105. else // there is already a stored message available
  106. {
  107. $HeaderString = $_SESSION['HeaderString']; // extract 'HeaderString' session variable (only necessary if register globals is OFF!)
  108. // Note: though we clear the session variable, the current message is still available to this script via '$HeaderString':
  109. deleteSessionVariable("HeaderString"); // function 'deleteSessionVariable()' is defined in 'include.inc.php'
  110. }
  111. // Extract the view type requested by the user (either 'Mobile', 'Print', 'Web' or ''):
  112. // ('' will produce the default 'Web' output style)
  113. if (isset($_REQUEST['viewType']))
  114. $viewType = $_REQUEST['viewType'];
  115. else
  116. $viewType = "";
  117. // if the user isn't logged in -OR- any normal user is logged in (not the admin)...
  118. if ((!isset($loginEmail)) OR ((isset($loginEmail)) AND ($loginEmail != $adminLoginEmail)))
  119. {
  120. $fieldLock = " readonly"; // ... lock the 'location' & 'file' fields
  121. $fieldLockLabel = " (" . $loc["readonly"] . ")"; // ... append a " (readonly)" indicator to the field description of the 'location' & 'file' fields
  122. }
  123. else // if the admin is logged in...
  124. {
  125. $fieldLock = ""; // ...the 'location' & 'file' fields won't be locked (since the admin should be able to freely add or edit any records)
  126. $fieldLockLabel = "";
  127. }
  128. if ($recordAction == "edit") // *edit* record
  129. {
  130. $pageTitle = $loc["EditRecord"]; // set the correct page title
  131. $addEditButtonTitle = $loc["ButtonTitle_EditRecord"]; // set the button name of the (default) submit button ('Edit Record')
  132. }
  133. else
  134. {
  135. $recordAction = "add"; // *add* record will be the default action if no parameter is given
  136. $pageTitle = $loc["AddRecord"]; // set the correct page title
  137. $addEditButtonTitle = $loc["ButtonTitle_AddRecord"]; // set the button name of the (default) submit button ('Add Record')
  138. $serialNo = $loc["not assigned yet"];
  139. // if the user isn't logged in -OR- any normal user is logged in (not the admin)...
  140. if ((!isset($loginEmail)) OR ((isset($loginEmail)) AND ($loginEmail != $adminLoginEmail)))
  141. // ...provide a generic info string within the (locked) 'location' field that informs the user about the automatic fill in of his user name & email address
  142. // (IMPORTANT: if you change this information string you must also edit the corresponding 'preg_match(...)' pattern in 'modify.php'!)
  143. $locationName = $loc["your name & email address will be filled in automatically"];
  144. else // if the admin is logged in...
  145. $locationName = ""; // ...keep the 'location' field empty
  146. }
  147. if (isset($loginEmail)) // if a user is logged in
  148. {
  149. // build a correct call number prefix for the currently logged-in user (e.g. 'IP� @ msteffens'):
  150. $callNumberPrefix = getCallNumberPrefix(); // function 'getCallNumberPrefix()' is defined in 'include.inc.php'
  151. }
  152. // Build HTML elements that allow for auto-completions of text entered by the user:
  153. if (isset($_SESSION['userAutoCompletions']) AND ($_SESSION['userAutoCompletions'] == "yes"))
  154. {
  155. $authorSuggestElements = buildSuggestElements("authorName", "authorSuggestions", "authorSuggestProgress", "col-author-", "\t\t", "';'"); // function 'buildSuggestElements()' is defined in 'include.inc.php'
  156. $titleSuggestElements = buildSuggestElements("titleName", "titleSuggestions", "titleSuggestProgress", "col-title-");
  157. $yearSuggestElements = buildSuggestElements("yearNo", "yearSuggestions", "yearSuggestProgress", "col-year-");
  158. $publicationSuggestElements = buildSuggestElements("publicationName", "publicationSuggestions", "publicationSuggestProgress", "col-publication-");
  159. $abbrevJournalSuggestElements = buildSuggestElements("abbrevJournalName", "abbrevJournalSuggestions", "abbrevJournalSuggestProgress", "col-abbrev_journal-");
  160. $volumeSuggestElements = buildSuggestElements("volumeNo", "volumeSuggestions", "volumeSuggestProgress", "col-volume-");
  161. $issueSuggestElements = buildSuggestElements("issueNo", "issueSuggestions", "issueSuggestProgress", "col-issue-");
  162. $pagesSuggestElements = buildSuggestElements("pagesNo", "pagesSuggestions", "pagesSuggestProgress", "col-pages-");
  163. $keywordsSuggestElements = buildSuggestElements("keywordsName", "keywordsSuggestions", "keywordsSuggestProgress", "col-keywords-", "\t\t", "';'");
  164. $addressSuggestElements = buildSuggestElements("addressName", "addressSuggestions", "addressSuggestProgress", "col-address-", "\t\t", "';'");
  165. $corporateAuthorSuggestElements = buildSuggestElements("corporateAuthorName", "corporateAuthorSuggestions", "corporateAuthorSuggestProgress", "col-corporate_author-", "\t\t", "';'");
  166. $publisherSuggestElements = buildSuggestElements("publisherName", "publisherSuggestions", "publisherSuggestProgress", "col-publisher-");
  167. $placeSuggestElements = buildSuggestElements("placeName", "placeSuggestions", "placeSuggestProgress", "col-place-", "\t\t", "[';',',']");
  168. $editorSuggestElements = buildSuggestElements("editorName", "editorSuggestions", "editorSuggestProgress", "col-editor-", "\t\t", "';'");
  169. $languageSuggestElements = buildSuggestElements("languageName", "languageSuggestions", "languageSuggestProgress", "col-language-", "\t\t", "';'");
  170. $summaryLanguageSuggestElements = buildSuggestElements("summaryLanguageName", "summaryLanguageSuggestions", "summaryLanguageSuggestProgress", "col-summary_language-", "\t\t", "';'");
  171. $origTitleSuggestElements = buildSuggestElements("origTitleName", "origTitleSuggestions", "origTitleSuggestProgress", "col-orig_title-");
  172. $seriesEditorSuggestElements = buildSuggestElements("seriesEditorName", "seriesEditorSuggestions", "seriesEditorSuggestProgress", "col-series_editor-", "\t\t", "';'");
  173. $seriesTitleSuggestElements = buildSuggestElements("seriesTitleName", "seriesTitleSuggestions", "seriesTitleSuggestProgress", "col-series_title-");
  174. $abbrevSeriesTitleSuggestElements = buildSuggestElements("abbrevSeriesTitleName", "abbrevSeriesTitleSuggestions", "abbrevSeriesTitleSuggestProgress", "col-abbrev_series_title-");
  175. $seriesVolumeSuggestElements = buildSuggestElements("seriesVolumeNo", "seriesVolumeSuggestions", "seriesVolumeSuggestProgress", "col-series_volume-");
  176. $seriesIssueSuggestElements = buildSuggestElements("seriesIssueNo", "seriesIssueSuggestions", "seriesIssueSuggestProgress", "col-series_issue-");
  177. $editionSuggestElements = buildSuggestElements("editionNo", "editionSuggestions", "editionSuggestProgress", "col-edition-");
  178. $issnSuggestElements = buildSuggestElements("issnName", "issnSuggestions", "issnSuggestProgress", "col-issn-");
  179. $isbnSuggestElements = buildSuggestElements("isbnName", "isbnSuggestions", "isbnSuggestProgress", "col-isbn-");
  180. $mediumSuggestElements = buildSuggestElements("mediumName", "mediumSuggestions", "mediumSuggestProgress", "col-medium-");
  181. $areaSuggestElements = buildSuggestElements("areaName", "areaSuggestions", "areaSuggestProgress", "col-area-", "\t\t", "';'");
  182. $expeditionSuggestElements = buildSuggestElements("expeditionName", "expeditionSuggestions", "expeditionSuggestProgress", "col-expedition-", "\t\t", "';'");
  183. $conferenceSuggestElements = buildSuggestElements("conferenceName", "conferenceSuggestions", "conferenceSuggestProgress", "col-conference-");
  184. $notesSuggestElements = buildSuggestElements("notesName", "notesSuggestions", "notesSuggestProgress", "col-notes-", "\t\t", "';'");
  185. if ((isset($loginEmail)) AND ($loginEmail == $adminLoginEmail)) // admin logged in
  186. {
  187. $locationSuggestElements = buildSuggestElements("locationName", "locationSuggestions", "locationSuggestProgress", "col-location-", "\t\t", "';'");
  188. $callNumberSuggestElements = buildSuggestElements("callNumberName", "callNumberSuggestions", "callNumberSuggestProgress", "col-call_number-", "\t\t", "[';','@']");
  189. }
  190. else // user isn't logged in -OR- any normal user is logged in
  191. {
  192. $locationSuggestElements = "";
  193. $callNumberSuggestElements = buildSuggestElements("callNumberNameUserOnly", "callNumberSuggestions", "callNumberSuggestProgress", "col-call_number-", "\t\t", "[';','@']");
  194. }
  195. $userKeysSuggestElements = buildSuggestElements("userKeysName", "userKeysSuggestions", "userKeysSuggestProgress", "col-user_keys-", "\t\t", "';'");
  196. $userNotesSuggestElements = buildSuggestElements("userNotesName", "userNotesSuggestions", "userNotesSuggestProgress", "col-user_notes-", "\t\t", "';'");
  197. $userFileSuggestElements = buildSuggestElements("userFileName", "userFileSuggestions", "userFileSuggestProgress", "col-user_file-");
  198. $userGroupsSuggestElements = buildSuggestElements("userGroupsName", "userGroupsSuggestions", "userGroupsSuggestProgress", "col-user_groups-", "\t\t", "';'");
  199. $citeKeySuggestElements = buildSuggestElements("citeKeyName", "citeKeySuggestions", "citeKeySuggestProgress", "col-cite_key-");
  200. $relatedSuggestElements = buildSuggestElements("relatedName", "relatedSuggestions", "relatedSuggestProgress", "col-related-", "\t\t", "';'");
  201. $urlSuggestElements = buildSuggestElements("urlName", "urlSuggestions", "urlSuggestProgress", "col-url-");
  202. $doiSuggestElements = buildSuggestElements("doiName", "doiSuggestions", "doiSuggestProgress", "col-doi-");
  203. $onlineCitationSuggestElements = buildSuggestElements("onlineCitationName", "onlineCitationSuggestions", "onlineCitationSuggestProgress", "col-online_citation-");
  204. }
  205. else
  206. {
  207. $authorSuggestElements = "";
  208. $titleSuggestElements = "";
  209. $yearSuggestElements = "";
  210. $publicationSuggestElements = "";
  211. $abbrevJournalSuggestElements = "";
  212. $volumeSuggestElements = "";
  213. $issueSuggestElements = "";
  214. $pagesSuggestElements = "";
  215. $keywordsSuggestElements = "";
  216. $addressSuggestElements = "";
  217. $corporateAuthorSuggestElements = "";
  218. $publisherSuggestElements = "";
  219. $placeSuggestElements = "";
  220. $editorSuggestElements = "";
  221. $languageSuggestElements = "";
  222. $summaryLanguageSuggestElements = "";
  223. $origTitleSuggestElements = "";
  224. $seriesEditorSuggestElements = "";
  225. $seriesTitleSuggestElements = "";
  226. $abbrevSeriesTitleSuggestElements = "";
  227. $seriesVolumeSuggestElements = "";
  228. $seriesIssueSuggestElements = "";
  229. $editionSuggestElements = "";
  230. $issnSuggestElements = "";
  231. $isbnSuggestElements = "";
  232. $mediumSuggestElements = "";
  233. $areaSuggestElements = "";
  234. $expeditionSuggestElements = "";
  235. $conferenceSuggestElements = "";
  236. $notesSuggestElements = "";
  237. $locationSuggestElements = "";
  238. $callNumberSuggestElements = "";
  239. $userKeysSuggestElements = "";
  240. $userNotesSuggestElements = "";
  241. $userFileSuggestElements = "";
  242. $userGroupsSuggestElements = "";
  243. $citeKeySuggestElements = "";
  244. $relatedSuggestElements = "";
  245. $urlSuggestElements = "";
  246. $doiSuggestElements = "";
  247. $onlineCitationSuggestElements = "";
  248. }
  249. // --------------------------------------------------------------------
  250. // CONSTRUCT SQL QUERY:
  251. // if the script was called with parameters (like: 'record.php?recordAction=edit&serialNo=...')
  252. if ($recordAction == "edit")
  253. {
  254. // for the selected record, select *all* available fields:
  255. $query = buildSELECTclause("Edit", "1"); // function 'buildSELECTclause()' is defined in 'include.inc.php'
  256. if (isset($_SESSION['loginEmail'])) // if a user is logged in, show user specific fields:
  257. $query .= " FROM $tableRefs LEFT JOIN $tableUserData ON serial = record_id AND user_id =" . quote_smart($loginUserID) . " WHERE serial RLIKE " . quote_smart("^(" . $serialNo . ")$"); // since we'll only fetch one record, the ORDER BY clause is obsolete here
  258. else // if NO user logged in, don't display any user specific fields:
  259. $query .= " FROM $tableRefs WHERE serial RLIKE " . quote_smart("^(" . $serialNo . ")$"); // since we'll only fetch one record, the ORDER BY clause is obsolete here
  260. }
  261. // --------------------------------------------------------------------
  262. // (1) OPEN CONNECTION, (2) SELECT DATABASE
  263. connectToMySQLDatabase(); // function 'connectToMySQLDatabase()' is defined in 'include.inc.php'
  264. // Initialize some variables (to prevent "Undefined variable..." messages):
  265. $isEditorCheckBox = "";
  266. $contributionIDCheckBox = "";
  267. $locationSelectorName = "";
  268. if ($recordAction == "edit" AND empty($errors))
  269. {
  270. // (3a) RUN the query on the database through the connection:
  271. $result = queryMySQLDatabase($query); // function 'queryMySQLDatabase()' is defined in 'include.inc.php'
  272. if (@ mysqli_num_rows($result) == 1) // this condition is added here to avoid the case that clicking on a search result item which got deleted in the meantime invokes a seemingly correct but empty 'edit record' search form
  273. {
  274. // (3b) EXTRACT results:
  275. $row = mysqli_fetch_array($result); //fetch the current row into the array $row (it'll be always *one* row, but anyhow)
  276. // fetch attributes of the current record into variables:
  277. $authorName = encodeHTML($row['author']);
  278. $titleName = encodeHTML($row['title']);
  279. $yearNo = encodeHTML($row['year']);
  280. $publicationName = encodeHTML($row['publication']);
  281. $abbrevJournalName = encodeHTML($row['abbrev_journal']);
  282. $volumeNo = encodeHTML($row['volume']);
  283. $issueNo = encodeHTML($row['issue']);
  284. $pagesNo = encodeHTML($row['pages']);
  285. $addressName = encodeHTML($row['address']);
  286. $corporateAuthorName = encodeHTML($row['corporate_author']);
  287. $keywordsName = encodeHTML($row['keywords']);
  288. $abstractName = encodeHTML($row['abstract']);
  289. $publisherName = encodeHTML($row['publisher']);
  290. $placeName = encodeHTML($row['place']);
  291. $editorName = encodeHTML($row['editor']);
  292. $languageName = encodeHTML($row['language']);
  293. $summaryLanguageName = encodeHTML($row['summary_language']);
  294. $origTitleName = encodeHTML($row['orig_title']);
  295. $seriesEditorName = encodeHTML($row['series_editor']);
  296. $seriesTitleName = encodeHTML($row['series_title']);
  297. $abbrevSeriesTitleName = encodeHTML($row['abbrev_series_title']);
  298. $seriesVolumeNo = encodeHTML($row['series_volume']);
  299. $seriesIssueNo = encodeHTML($row['series_issue']);
  300. $editionNo = encodeHTML($row['edition']);
  301. $issnName = encodeHTML($row['issn']);
  302. $isbnName = encodeHTML($row['isbn']);
  303. $mediumName = encodeHTML($row['medium']);
  304. $areaName = encodeHTML($row['area']);
  305. $expeditionName = encodeHTML($row['expedition']);
  306. $conferenceName = encodeHTML($row['conference']);
  307. $notesName = encodeHTML($row['notes']);
  308. $approvedRadio = encodeHTML($row['approved']);
  309. // we only show the contents of the 'location' field if the user is logged in:
  310. // (this is mostly done to shield user email addresses from exposure to search engines and/or email harvesting robots)
  311. if (isset($loginEmail))
  312. {
  313. $locationName = encodeHTML($row['location']);
  314. $rawLocationName = $row['location']; // we'll save the unencoded location string to a separate variable since it will be needed when generating the delete button
  315. }
  316. else
  317. {
  318. $locationName = "";
  319. $rawLocationName = "";
  320. }
  321. $callNumberName = $row['call_number']; // contents of the 'call_number' field will get encoded depending on who's logged in (normal user vs. admin)
  322. // (for normal users being logged in, the field's contents won't get HTML encoded at all, since the data will
  323. // get *rawurlencoded* when including them within a hidden form tag; for the admin being logged in, the data
  324. // will get HTML encoded below)
  325. // if a normal user is logged in, we'll only display the user's *own* call number within the 'call_number' field:
  326. if ((isset($loginEmail)) AND ($loginEmail != $adminLoginEmail))
  327. {
  328. if (preg_match("/(^|.*;) *$callNumberPrefix *@ +([^@;]+)/", $callNumberName)) // if the user's call number prefix occurs within the contents of the 'call_number' field
  329. {
  330. $callNumberNameUserOnly = preg_replace("/(^|.*;) *$callNumberPrefix *@ +([^@;]+).*/i", "\\2", $callNumberName); // extract the user's *own* call number from the full contents of the 'call_number' field
  331. $callNumberNameUserOnly = encodeHTML($callNumberNameUserOnly);
  332. }
  333. else
  334. $callNumberNameUserOnly = "";
  335. }
  336. elseif ((isset($loginEmail)) AND ($loginEmail == $adminLoginEmail)) // admin logged in
  337. {
  338. $callNumberNameUserOnly = ""; // the 'call_number' field will be empty if no user is logged in (note that '$callNumberNameUserOnly' won't be used at all, if the admin is logged in)
  339. $callNumberName = encodeHTML($callNumberName); // if the admin is logged in we display the full contents of the 'call_number' field, so we'll need to HTML encode the data
  340. }
  341. else // nobody logged in
  342. {
  343. $callNumberNameUserOnly = ""; // the 'call_number' field will be empty if no user is logged in (note that '$callNumberNameUserOnly' won't be used at all, if the admin is logged in)
  344. // note that, as for normal users being logged in, the call number field contents won't get HTML encoded here, since the data will get *rawurlencoded* when including them within a hidden form tag
  345. }
  346. $serialNo = encodeHTML($row['serial']);
  347. $typeName = encodeHTML($row['type']);
  348. $thesisName = encodeHTML($row['thesis']);
  349. if (isset($row['marked'])) // 'marked' field is only provided if a user is logged in
  350. $markedRadio = encodeHTML($row['marked']);
  351. else
  352. $markedRadio = "";
  353. if (isset($row['copy'])) // 'copy' field is only provided if a user is logged in
  354. $copyName = encodeHTML($row['copy']);
  355. else
  356. $copyName = "";
  357. if (isset($row['selected'])) // 'selected' field is only provided if a user is logged in
  358. $selectedRadio = encodeHTML($row['selected']);
  359. else
  360. $selectedRadio = "";
  361. if (isset($row['user_keys'])) // 'user_keys' field is only provided if a user is logged in
  362. $userKeysName = encodeHTML($row['user_keys']);
  363. else
  364. $userKeysName = "";
  365. if (isset($row['user_notes'])) // 'user_notes' field is only provided if a user is logged in
  366. $userNotesName = encodeHTML($row['user_notes']);
  367. else
  368. $userNotesName = "";
  369. if (isset($row['user_file'])) // 'user_file' field is only provided if a user is logged in
  370. $userFileName = encodeHTML($row['user_file']);
  371. else
  372. $userFileName = "";
  373. if (isset($row['user_groups'])) // 'user_groups' field is only provided if a user is logged in
  374. $userGroupsName = encodeHTML($row['user_groups']);
  375. else
  376. $userGroupsName = "";
  377. if (isset($row['cite_key'])) // 'cite_key' field is only provided if a user is logged in
  378. $citeKeyName = encodeHTML($row['cite_key']);
  379. else
  380. $citeKeyName = "";
  381. if (isset($row['related'])) // 'related' field is only provided if a user is logged in
  382. $relatedName = encodeHTML($row['related']);
  383. else
  384. $relatedName = "";
  385. // show the contents of the 'file' field if one of the following conditions is met:
  386. // - the variable '$fileVisibility' (defined in 'ini.inc.php') is set to 'everyone'
  387. // - the variable '$fileVisibility' is set to 'login' AND the user is logged in
  388. // - the variable '$fileVisibility' is set to 'user-specific' AND the 'user_permissions' session variable contains 'allow_download'
  389. if ($fileVisibility == "everyone" OR ($fileVisibility == "login" AND isset($_SESSION['loginEmail'])) OR ($fileVisibility == "user-specific" AND (isset($_SESSION['user_permissions']) AND preg_match("/allow_download/", $_SESSION['user_permissions']))))
  390. $fileName = encodeHTML($row['file']);
  391. else // if the user has no permission to download (and hence view) any files, 'modify.php' will take care that the empty form value won't overwrite any existing contents of the 'file' field
  392. $fileName = "";
  393. $urlName = encodeHTML($row['url']);
  394. $doiName = encodeHTML($row['doi']);
  395. $contributionID = $row['contribution_id'];
  396. $onlinePublication = $row['online_publication'];
  397. $onlineCitationName = $row['online_citation'];
  398. $createdDate = $row['created_date'];
  399. $createdTime = $row['created_time'];
  400. $createdBy = encodeHTML($row['created_by']);
  401. $modifiedDate = $row['modified_date'];
  402. $modifiedTime = $row['modified_time'];
  403. $modifiedBy = encodeHTML($row['modified_by']);
  404. $origRecord = $row['orig_record'];
  405. }
  406. else
  407. showErrorMsg($loc["The Query"].":\n<br>\n<br>\n<code>" . encodeHTML($query) . "</code>\n<br>\n<br>\n ". $loc["caused an error"].":", "");
  408. }
  409. else // if ($recordAction == "add") -OR- ($recordAction == "edit" but there were some errors on submit)
  410. {
  411. if ($recordAction == "add" AND $mode == "import" AND empty($errors)) // if the user wants to import record data by use of an import form (like 'import.php' or 'import_csa.php')
  412. {
  413. foreach($_REQUEST as $varname => $value)
  414. // remove slashes from parameter values if 'magic_quotes_gpc = On':
  415. $_REQUEST[$varname] = stripSlashesIfMagicQuotes($value); // function 'stripSlashesIfMagicQuotes()' is defined in 'include.inc.php'
  416. // read field data from a GET/POST request:
  417. if (isset($_REQUEST['author']))
  418. $authorName = encodeHTML($_REQUEST['author']);
  419. else
  420. $authorName = "";
  421. if (isset($_REQUEST['title']))
  422. $titleName = encodeHTML($_REQUEST['title']);
  423. else
  424. $titleName = "";
  425. if (isset($_REQUEST['year']))
  426. $yearNo = encodeHTML($_REQUEST['year']);
  427. else
  428. $yearNo = "";
  429. if (isset($_REQUEST['publication']))
  430. $publicationName = encodeHTML($_REQUEST['publication']);
  431. else
  432. $publicationName = "";
  433. if (isset($_REQUEST['abbrev_journal']))
  434. $abbrevJournalName = encodeHTML($_REQUEST['abbrev_journal']);
  435. else
  436. $abbrevJournalName = "";
  437. if (isset($_REQUEST['volume']))
  438. $volumeNo = encodeHTML($_REQUEST['volume']);
  439. else
  440. $volumeNo = "";
  441. if (isset($_REQUEST['issue']))
  442. $issueNo = encodeHTML($_REQUEST['issue']);
  443. else
  444. $issueNo = "";
  445. if (isset($_REQUEST['pages']))
  446. $pagesNo = encodeHTML($_REQUEST['pages']);
  447. else
  448. $pagesNo = "";
  449. if (isset($_REQUEST['address']))
  450. $addressName = encodeHTML($_REQUEST['address']);
  451. else
  452. $addressName = "";
  453. if (isset($_REQUEST['corporate_author']))
  454. $corporateAuthorName = encodeHTML($_REQUEST['corporate_author']);
  455. else
  456. $corporateAuthorName = "";
  457. if (isset($_REQUEST['keywords']))
  458. $keywordsName = encodeHTML($_REQUEST['keywords']);
  459. else
  460. $keywordsName = "";
  461. if (isset($_REQUEST['abstract']))
  462. $abstractName = encodeHTML($_REQUEST['abstract']);
  463. else
  464. $abstractName = "";
  465. if (isset($_REQUEST['publisher']))
  466. $publisherName = encodeHTML($_REQUEST['publisher']);
  467. else
  468. $publisherName = "";
  469. if (isset($_REQUEST['place']))
  470. $placeName = encodeHTML($_REQUEST['place']);
  471. else
  472. $placeName = "";
  473. if (isset($_REQUEST['editor']))
  474. $editorName = encodeHTML($_REQUEST['editor']);
  475. else
  476. $editorName = "";
  477. if (isset($_REQUEST['language']))
  478. $languageName = encodeHTML($_REQUEST['language']);
  479. else
  480. $languageName = "";
  481. if (isset($_REQUEST['summary_language']))
  482. $summaryLanguageName = encodeHTML($_REQUEST['summary_language']);
  483. else
  484. $summaryLanguageName = "";
  485. if (isset($_REQUEST['orig_title']))
  486. $origTitleName = encodeHTML($_REQUEST['orig_title']);
  487. else
  488. $origTitleName = "";
  489. if (isset($_REQUEST['series_editor']))
  490. $seriesEditorName = encodeHTML($_REQUEST['series_editor']);
  491. else
  492. $seriesEditorName = "";
  493. if (isset($_REQUEST['series_title']))
  494. $seriesTitleName = encodeHTML($_REQUEST['series_title']);
  495. else
  496. $seriesTitleName = "";
  497. if (isset($_REQUEST['abbrev_series_title']))
  498. $abbrevSeriesTitleName = encodeHTML($_REQUEST['abbrev_series_title']);
  499. else
  500. $abbrevSeriesTitleName = "";
  501. if (isset($_REQUEST['series_volume']))
  502. $seriesVolumeNo = encodeHTML($_REQUEST['series_volume']);
  503. else
  504. $seriesVolumeNo = "";
  505. if (isset($_REQUEST['series_issue']))
  506. $seriesIssueNo = encodeHTML($_REQUEST['series_issue']);
  507. else
  508. $seriesIssueNo = "";
  509. if (isset($_REQUEST['edition']))
  510. $editionNo = encodeHTML($_REQUEST['edition']);
  511. else
  512. $editionNo = "";
  513. if (isset($_REQUEST['issn']))
  514. $issnName = encodeHTML($_REQUEST['issn']);
  515. else
  516. $issnName = "";
  517. if (isset($_REQUEST['isbn']))
  518. $isbnName = encodeHTML($_REQUEST['isbn']);
  519. else
  520. $isbnName = "";
  521. $mediumName = "";
  522. if (isset($_REQUEST['area']))
  523. $areaName = encodeHTML($_REQUEST['area']);
  524. else
  525. $areaName = "";
  526. $expeditionName = "";
  527. if (isset($_REQUEST['conference']))
  528. $conferenceName = encodeHTML($_REQUEST['conference']);
  529. else
  530. $conferenceName = "";
  531. if (isset($_REQUEST['notes']))
  532. $notesName = encodeHTML($_REQUEST['notes']);
  533. else
  534. $notesName = "";
  535. $approvedRadio = "";
  536. $locationName = $locationName; // supply some generic info: "(...will be filled in automatically)" [as defined at the top of this script]
  537. $rawLocationName = "";
  538. if (isset($_REQUEST['call_number']))
  539. {
  540. // if the data did originate from an import form -AND- (if the user isn't logged in -OR- any normal user is logged in (not the admin))...
  541. if ($recordAction == "add" AND $mode == "import" AND ((!isset($loginEmail)) OR ((isset($loginEmail)) AND ($loginEmail != $adminLoginEmail))))
  542. {
  543. $callNumberName = "";
  544. $callNumberNameUserOnly = encodeHTML($_REQUEST['call_number']); // for import, we assume that the contents of the call number field fully belong to the current user
  545. }
  546. else // if the data didn't originate from an import form or if the admin is logged in...
  547. {
  548. $callNumberName = encodeHTML($_REQUEST['call_number']);
  549. $callNumberNameUserOnly = "";
  550. }
  551. }
  552. else
  553. {
  554. $callNumberName = "";
  555. $callNumberNameUserOnly = "";
  556. }
  557. $serialNo = $serialNo; // supply some generic info: "(not assigned yet)" [as defined at the top of this script]
  558. if (isset($_REQUEST['type']))
  559. $typeName = encodeHTML($_REQUEST['type']);
  560. else
  561. $typeName = "";
  562. if (isset($_REQUEST['thesis']))
  563. $thesisName = encodeHTML($_REQUEST['thesis']);
  564. else
  565. $thesisName = "";
  566. if (isset($_REQUEST['marked']))
  567. $markedRadio = encodeHTML($_REQUEST['marked']);
  568. else
  569. $markedRadio = "";
  570. if (isset($_REQUEST['copy']))
  571. $copyName = encodeHTML($_REQUEST['copy']);
  572. else
  573. $copyName = "";
  574. if (isset($_REQUEST['selected']))
  575. $selectedRadio = encodeHTML($_REQUEST['selected']);
  576. else
  577. $selectedRadio = "";
  578. if (isset($_REQUEST['user_keys']))
  579. $userKeysName = encodeHTML($_REQUEST['user_keys']);
  580. else
  581. $userKeysName = "";
  582. if (isset($_REQUEST['user_notes']))
  583. $userNotesName = encodeHTML($_REQUEST['user_notes']);
  584. else
  585. $userNotesName = "";
  586. if (isset($_REQUEST['user_file']))
  587. $userFileName = encodeHTML($_REQUEST['user_file']);
  588. else
  589. $userFileName = "";
  590. if (isset($_REQUEST['user_groups']))
  591. $userGroupsName = encodeHTML($_REQUEST['user_groups']);
  592. else
  593. $userGroupsName = "";
  594. if (isset($_REQUEST['cite_key']))
  595. $citeKeyName = encodeHTML($_REQUEST['cite_key']);
  596. else
  597. $citeKeyName = "";
  598. if (isset($_REQUEST['related']))
  599. $relatedName = encodeHTML($_REQUEST['related']);
  600. else
  601. $relatedName = "";
  602. // NOTE: currently, we only allow for file URLs with full URL paths
  603. //
  604. // TODO: - ensure that there aren't any security issues
  605. // - should we accept local file paths/names from the import data? if so, how should we handle them?
  606. // - make sure that any recognized PDF files get renamed & filed according to the settings in 'initialize/ini.inc.php';
  607. // in case of remote file URLs, this may mean downloading the remote PDF, and filing/renaming it according to preference
  608. if (isset($_REQUEST['file']) AND preg_match("#^(https?|ftp|file)://#i", $_REQUEST['file'])) // if the 'file' field contains a full URL (starting with "http://", "https://", "ftp://" or "file://")
  609. $fileName = encodeHTML($_REQUEST['file']);
  610. else
  611. $fileName = "";
  612. if (isset($_REQUEST['url']))
  613. $urlName = encodeHTML($_REQUEST['url']);
  614. else
  615. $urlName = "";
  616. if (isset($_REQUEST['doi']))
  617. $doiName = encodeHTML($_REQUEST['doi']);
  618. else
  619. $doiName = "";
  620. $contributionID = "";
  621. $onlinePublication = "";
  622. $onlineCitationName = "";
  623. $createdDate = ""; // for INSERTs, 'created_...' and 'modified_...' variables will get fresh values in 'modify.php' anyhow
  624. $createdTime = "";
  625. $createdBy = "";
  626. $modifiedDate = "";
  627. $modifiedTime = "";
  628. $modifiedBy = "";
  629. $origRecord = "";
  630. }
  631. else // the user tried to add or edit a record but...
  632. {
  633. if (!empty($errors)) // ...there were some errors on submit. -> Re-load the data that were submitted by the user:
  634. {
  635. foreach($formVars as $varname => $value)
  636. // remove slashes from parameter values if 'magic_quotes_gpc = On':
  637. $formVars[$varname] = stripSlashesIfMagicQuotes($value); // function 'stripSlashesIfMagicQuotes()' is defined in 'include.inc.php'
  638. if (isset($formVars['authorName']))
  639. $authorName = $formVars['authorName'];
  640. else
  641. $authorName = "";
  642. if (isset($formVars['isEditorCheckBox'])) // the user did mark the "is Editor" checkbox
  643. $isEditorCheckBox = $formVars['isEditorCheckBox'];
  644. if (isset($formVars['titleName']))
  645. $titleName = $formVars['titleName'];
  646. else
  647. $titleName = "";
  648. if (isset($formVars['yearNo']))
  649. $yearNo = $formVars['yearNo'];
  650. else
  651. $yearNo = "";
  652. if (isset($formVars['publicationName']))
  653. $publicationName = $formVars['publicationName'];
  654. else
  655. $publicationName = "";
  656. if (isset($formVars['abbrevJournalName']))
  657. $abbrevJournalName = $formVars['abbrevJournalName'];
  658. else
  659. $abbrevJournalName = "";
  660. if (isset($formVars['volumeNo']))
  661. $volumeNo = $formVars['volumeNo'];
  662. else
  663. $volumeNo = "";
  664. if (isset($formVars['issueNo']))
  665. $issueNo = $formVars['issueNo'];
  666. else
  667. $issueNo = "";
  668. if (isset($formVars['pagesNo']))
  669. $pagesNo = $formVars['pagesNo'];
  670. else
  671. $pagesNo = "";
  672. if (isset($formVars['addressName']))
  673. $addressName = $formVars['addressName'];
  674. else
  675. $addressName = "";
  676. if (isset($formVars['corporateAuthorName']))
  677. $corporateAuthorName = $formVars['corporateAuthorName'];
  678. else
  679. $corporateAuthorName = "";
  680. if (isset($formVars['keywordsName']))
  681. $keywordsName = $formVars['keywordsName'];
  682. else
  683. $keywordsName = "";
  684. if (isset($formVars['abstractName']))
  685. $abstractName = $formVars['abstractName'];
  686. else
  687. $abstractName = "";
  688. if (isset($formVars['publisherName']))
  689. $publisherName = $formVars['publisherName'];
  690. else
  691. $publisherName = "";
  692. if (isset($formVars['placeName']))
  693. $placeName = $formVars['placeName'];
  694. else
  695. $placeName = "";
  696. if (isset($formVars['editorName']))
  697. $editorName = $formVars['editorName'];
  698. else
  699. $editorName = "";
  700. if (isset($formVars['languageName']))
  701. $languageName = $formVars['languageName'];
  702. else
  703. $languageName = "";
  704. if (isset($formVars['summaryLanguageName']))
  705. $summaryLanguageName = $formVars['summaryLanguageName'];
  706. else
  707. $summaryLanguageName = "";
  708. if (isset($formVars['origTitleName']))
  709. $origTitleName = $formVars['origTitleName'];
  710. else
  711. $origTitleName = "";
  712. if (isset($formVars['seriesEditorName']))
  713. $seriesEditorName = $formVars['seriesEditorName'];
  714. else
  715. $seriesEditorName = "";
  716. if (isset($formVars['seriesTitleName']))
  717. $seriesTitleName = $formVars['seriesTitleName'];
  718. else
  719. $seriesTitleName = "";
  720. if (isset($formVars['abbrevSeriesTitleName']))
  721. $abbrevSeriesTitleName = $formVars['abbrevSeriesTitleName'];
  722. else
  723. $abbrevSeriesTitleName = "";
  724. if (isset($formVars['seriesVolumeNo']))
  725. $seriesVolumeNo = $formVars['seriesVolumeNo'];
  726. else
  727. $seriesVolumeNo = "";
  728. if (isset($formVars['seriesIssueNo']))
  729. $seriesIssueNo = $formVars['seriesIssueNo'];
  730. else
  731. $seriesIssueNo = "";
  732. if (isset($formVars['editionNo']))
  733. $editionNo = $formVars['editionNo'];
  734. else
  735. $editionNo = "";
  736. if (isset($formVars['issnName']))
  737. $issnName = $formVars['issnName'];
  738. else
  739. $issnName = "";
  740. if (isset($formVars['isbnName']))
  741. $isbnName = $formVars['isbnName'];
  742. else
  743. $isbnName = "";
  744. if (isset($formVars['mediumName']))
  745. $mediumName = $formVars['mediumName'];
  746. else
  747. $mediumName = "";
  748. if (isset($formVars['areaName']))
  749. $areaName = $formVars['areaName'];
  750. else
  751. $areaName = "";
  752. if (isset($formVars['expeditionName']))
  753. $expeditionName = $formVars['expeditionName'];
  754. else
  755. $expeditionName = "";
  756. if (isset($formVars['conferenceName']))
  757. $conferenceName = $formVars['conferenceName'];
  758. else
  759. $conferenceName = "";
  760. if (isset($formVars['notesName']))
  761. $notesName = $formVars['notesName'];
  762. else
  763. $notesName = "";
  764. if (isset($formVars['approvedRadio']))
  765. $approvedRadio = $formVars['approvedRadio'];
  766. else
  767. $approvedRadio = "";
  768. if ($recordAction == "edit")
  769. {
  770. if (isset($formVars['locationName']))
  771. {
  772. $locationName = $formVars['locationName'];
  773. $rawLocationName = $formVars['locationName'];
  774. }
  775. else
  776. {
  777. $locationName = "";
  778. $rawLocationName = "";
  779. }
  780. }
  781. else
  782. {
  783. $locationName = $locationName; // supply some generic info: "(...will be filled in automatically)" [as defined at the top of this script]
  784. $rawLocationName = "";
  785. }
  786. if (isset($formVars['callNumberName']))
  787. $callNumberName = $formVars['callNumberName'];
  788. else
  789. $callNumberName = "";
  790. if (preg_match("/%40/", $callNumberName)) // if '$callNumberName' still contains URL encoded data... ('%40' is the URL encoded form of the character '@', see note below!)
  791. $callNumberName = rawurldecode($callNumberName); // ...URL decode 'callNumberName' variable contents (it was URL encoded before incorporation into a hidden tag of the 'record' form to avoid any HTML syntax errors)
  792. // NOTE: URL encoded data that are included within a *link* will get URL decoded automatically *before* extraction via '$_POST'!
  793. // But, opposed to that, URL encoded data that are included within a form by means of a *hidden form tag* will NOT get URL decoded automatically! Then, URL decoding has to be done manually (as is done here)!
  794. if (isset($formVars['callNumberNameUserOnly']))
  795. $callNumberNameUserOnly = $formVars['callNumberNameUserOnly'];
  796. else
  797. $callNumberNameUserOnly = "";
  798. if ($recordAction == "edit")
  799. $serialNo = $formVars['serialNo'];
  800. else
  801. $serialNo = $serialNo; // supply some generic info: "(not assigned yet)" [as defined at the top of this script]
  802. if (isset($formVars['typeName']))
  803. $typeName = $formVars['typeName'];
  804. else
  805. $typeName = "";
  806. if (isset($formVars['thesisName']))
  807. $thesisName = $formVars['thesisName'];
  808. else
  809. $thesisName = "";
  810. if (isset($formVars['markedRadio']))
  811. $markedRadio = $formVars['markedRadio'];
  812. else
  813. $markedRadio = "";
  814. if (isset($formVars['copyName']))
  815. $copyName = $formVars['copyName'];
  816. else
  817. $copyName = "";
  818. if (isset($formVars['selectedRadio']))
  819. $selectedRadio = $formVars['selectedRadio'];
  820. else
  821. $selectedRadio = "";
  822. if (isset($formVars['userKeysName']))
  823. $userKeysName = $formVars['userKeysName'];
  824. else
  825. $userKeysName = "";
  826. if (isset($formVars['userNotesName']))
  827. $userNotesName = $formVars['userNotesName'];
  828. else
  829. $userNotesName = "";
  830. if (isset($formVars['userFileName']))
  831. $userFileName = $formVars['userFileName'];
  832. else
  833. $userFileName = "";
  834. if (isset($formVars['userGroupsName']))
  835. $userGroupsName = $formVars['userGroupsName'];
  836. else
  837. $userGroupsName = "";
  838. if (isset($formVars['citeKeyName']))
  839. $citeKeyName = $formVars['citeKeyName'];
  840. else
  841. $citeKeyName = "";
  842. if (isset($formVars['relatedName']))
  843. $relatedName = $formVars['relatedName'];
  844. else
  845. $relatedName = "";
  846. if (isset($formVars['fileName']))
  847. $fileName = $formVars['fileName'];
  848. else
  849. $fileName = "";
  850. if (isset($formVars['urlName']))
  851. $urlName = $formVars['urlName'];
  852. else
  853. $urlName = "";
  854. if (isset($formVars['doiName']))
  855. $doiName = $formVars['doiName'];
  856. else
  857. $doiName = "";
  858. if (isset($formVars['contributionIDName']))
  859. $contributionID = $formVars['contributionIDName'];
  860. else
  861. $contributionID = "";
  862. $contributionID = rawurldecode($contributionID); // URL decode 'contributionID' variable contents (it was URL encoded before incorporation into a hidden tag of the 'record' form to avoid any HTML syntax errors) [see above!]
  863. // check if we need to set the checkbox in front of "This is a ... publication.":
  864. if (isset($formVars['contributionIDCheckBox'])) // the user did mark the contribution ID checkbox
  865. $contributionIDCheckBox = $formVars['contributionIDCheckBox'];
  866. if (isset($formVars['locationSelectorName']))
  867. $locationSelectorName = $formVars['locationSelectorName'];
  868. else
  869. $locationSelectorName = "";
  870. // check if we need to set the "Online publication" checkbox:
  871. if (isset($formVars['onlinePublicationCheckBox'])) // the user did mark the "Online publication" checkbox
  872. $onlinePublication = "yes";
  873. else
  874. $onlinePublication = "no";
  875. if (isset($formVars['onlineCitationName']))
  876. $onlineCitationName = $formVars['onlineCitationName'];
  877. else
  878. $onlineCitationName = "";
  879. $createdDate = ""; // for INSERTs, 'created_...' and 'modified_...' variables will get fresh values in 'modify.php' anyhow
  880. $createdTime = "";
  881. $createdBy = "";
  882. $modifiedDate = "";
  883. $modifiedTime = "";
  884. $modifiedBy = "";
  885. if (isset($formVars['origRecord']))
  886. $origRecord = $formVars['origRecord'];
  887. else
  888. $origRecord = "";
  889. }
  890. else // add a new record -> display an empty form (i.e., set all variables to an empty string [""] or their default values, respectively):
  891. {
  892. $authorName = "";
  893. $titleName = "";
  894. $yearNo = "";
  895. $publicationName = "";
  896. $abbrevJournalName = "";
  897. $volumeNo = "";
  898. $issueNo = "";
  899. $pagesNo = "";
  900. $addressName = "";
  901. $corporateAuthorName = "";
  902. $keywordsName = "";
  903. $abstractName = "";
  904. $publisherName = "";
  905. $placeName = "";
  906. $editorName = "";
  907. $languageName = "";
  908. $summaryLanguageName = "";
  909. $origTitleName = "";
  910. $seriesEditorName = "";
  911. $seriesTitleName = "";
  912. $abbrevSeriesTitleName = "";
  913. $seriesVolumeNo = "";
  914. $seriesIssueNo = "";
  915. $editionNo = "";
  916. $issnName = "";
  917. $isbnName = "";
  918. $mediumName = "";
  919. $areaName = "";
  920. $expeditionName = "";
  921. $conferenceName = "";
  922. $notesName = "";
  923. $approvedRadio = "";
  924. $locationName = $locationName; // supply some generic info: "(...will be filled in automatically)" [as defined at the top of this script]
  925. $rawLocationName = "";
  926. $callNumberName = "";
  927. $callNumberNameUserOnly = "";
  928. $serialNo = $serialNo; // supply some generic info: "(not assigned yet)" [as defined at the top of this script]
  929. $typeName = "Journal Article";
  930. $thesisName = "";
  931. $markedRadio = "";
  932. $copyName = "true";
  933. $selectedRadio = "";
  934. $userKeysName = "";
  935. $userNotesName = "";
  936. $userFileName = "";
  937. $userGroupsName = "";
  938. $citeKeyName = "";
  939. $relatedName = "";
  940. $fileName = "";
  941. $urlName = "";
  942. $doiName = "";
  943. $contributionID = "";
  944. $onlinePublication = "";
  945. $onlineCitationName = "";
  946. $createdDate = ""; // for INSERTs, 'created_...' and 'modified_...' variables will get fresh values in 'modify.php' anyhow
  947. $createdTime = "";
  948. $createdBy = "";
  949. $modifiedDate = "";
  950. $modifiedTime = "";
  951. $modifiedBy = "";
  952. $origRecord = "";
  953. }
  954. }
  955. }
  956. // Show the login status:
  957. showLogin(); // (function 'showLogin()' is defined in 'include.inc.php')
  958. // (4a) DISPLAY header:
  959. // call the 'displayHTMLhead()' and 'showPageHeader()' functions (which are defined in 'header.inc.php'):
  960. displayHTMLhead(encodeHTML($officialDatabaseName) . " -- " . $pageTitle, "index,follow", "Add, edit or delete a record in the " . encodeHTML($officialDatabaseName), "", false, "", $viewType, array());
  961. showPageHeader($HeaderString);
  962. // (4b) DISPLAY results:
  963. // Start <form> and <table> holding the form elements:
  964. echo "\n<form enctype=\"multipart/form-data\" action=\"modify.php?proc=1\" method=\"POST\" accept-charset=\"" . $contentTypeCharset . "\" name=\"record\">"; // '$contentTypeCharset' is defined in 'ini.inc.php'
  965. echo "\n<input type=\"hidden\" name=\"formType\" value=\"record\">";
  966. echo "\n<input type=\"hidden\" name=\"submit\" value=\"" . $addEditButtonTitle . "\">"; // provide a default value for the 'submit' form tag (then, hitting <enter> within a text entry field will act as if the user clicked the 'Add/Edit Record' button)
  967. echo "\n<input type=\"hidden\" name=\"recordAction\" value=\"" . $recordAction . "\">";
  968. echo "\n<input type=\"hidden\" name=\"contributionIDName\" value=\"" . rawurlencode($contributionID) . "\">";
  969. echo "\n<input type=\"hidden\" name=\"origRecord\" value=\"" . $origRecord . "\">";
  970. if ($recordAction == "edit")
  971. {
  972. // the following hidden form tags are included in order to have their values available when a record is moved to the 'deleted' table:
  973. echo "\n<input type=\"hidden\" name=\"createdDate\" value=\"" . $createdDate . "\">";
  974. echo "\n<input type=\"hidden\" name=\"createdTime\" value=\"" . $createdTime . "\">";
  975. echo "\n<input type=\"hidden\" name=\"createdBy\" value=\"" . $createdBy . "\">";
  976. echo "\n<input type=\"hidden\" name=\"modifiedDate\" value=\"" . $modifiedDate . "\">";
  977. echo "\n<input type=\"hidden\" name=\"modifiedTime\" value=\"" . $modifiedTime . "\">";
  978. echo "\n<input type=\"hidden\" name=\"modifiedBy\" value=\"" . $modifiedBy . "\">";
  979. }
  980. // include a hidden tag that indicates the login status *at the time this page was loaded*:
  981. // Background: We use the session variable "$loginEmail" to control whether a user is logged in or not. However, if a user is working in different browser windows/tabs
  982. // the state/contents of a particular window might have changed due to any login/logout actions performed by the user. As an example, a user (who's currently NOT logged in!)
  983. // could open several records in edit view to *different* browser windows. Then he realizes that he forgot to login and logs in on the last browser window. He submits that
  984. // window and displays the next of his windows (where he still appears to be logged out). He doesn't notice the obsolete login status and goes on editing/submitting this window.
  985. // Since the session variable is global, it WILL be possible to submit the form in that window! This proceedure will cause the following problems:
  986. // Problems: 1. For normal users, the user's *own* call number will get removed from the 'call_number' field contents! The user's call number prefix will remain, though.
  987. // (the user's call number gets deleted, since the call number form field is left blank if a user isn't logged in)
  988. // 2. For normal users as well as for admins, any contribution ID that exists within the "contribution_id" field will be removed
  989. // (this is, since the contribution ID checkbox isn't shown when the user isn't logged in)
  990. // Solution: Since the above problems can't be circumvented easily with the current design, we simply include a hidden form tag, that indicates the user's login status on a
  991. // *per page* basis. Then, 'modify.php' will only allow submitting of forms where "pageLoginStatus=logged in". If a user is already logged in, but the "pageLoginStatus" of the currently
  992. // displayed page still states "logged out", he'll need to reload the page or click on the login link to update the "pageLoginStatus" first. This will avoid the problems outlined above.
  993. if (isset($loginEmail)) // if a user is logged in...
  994. echo "\n<input type=\"hidden\" name=\"pageLoginStatus\" value=\"logged in\">"; // ...the user was logged IN when loading this page
  995. else // if no user is logged in...
  996. echo "\n<input type=\"hidden\" name=\"pageLoginStatus\" value=\"logged out\">"; // ...the user was logged OUT when loading this page
  997. // if the user isn't logged in -OR- any normal user is logged in (not the admin)...
  998. if ((!isset($loginEmail)) OR ((isset($loginEmail)) AND ($loginEmail != $adminLoginEmail)))
  999. // except the admin, no user will be presented with the complete contents of the 'call_number' field! This is to prevent normal users
  1000. // to mess with other user's personal call numbers. Instead, normal users will always only see their own id number within the 'call_number' field.
  1001. // This should also avoid confusion how this field should/must be edited properly. Of course, the full contents of the 'call_number' field must be
  1002. // preserved, therefore we include them within a hidden form tag:
  1003. echo "\n<input type=\"hidden\" name=\"callNumberName\" value=\"" . rawurlencode($callNumberName) . "\">"; // ...include the *full* contents of the 'call_number' field
  1004. echo "\n<table align=\"center\" border=\"0\" cellpadding=\"5\" cellspacing=\"0\" width=\"600\" summary=\"This table holds a form that offers to add records or edit existing ones\">"
  1005. . "\n<tr>"
  1006. . "\n\t<td width=\"74\" class=\"mainfieldsbg\"><b>". $loc["Author"]."</b></td>"
  1007. . "\n\t<td colspan=\"4\" class=\"mainfieldsbg\">"
  1008. . "\n\t\t" . fieldError("authorName", $errors) . "<input type=\"text\" id=\"authorName\" name=\"authorName\" value=\"$authorName\" size=\"60\" title=\"". $loc["DescriptionAuthor"]."\">" . $authorSuggestElements
  1009. . "\n\t</td>";
  1010. if ($isEditorCheckBox == "1" OR preg_match("/ *\(eds?\)$/", $authorName)) // if the '$isEditorCheckBox' variable is set to 1 -OR- if 'author' field ends with either " (ed)" or " (eds)"
  1011. $isEditorCheckBoxIsChecked = " checked"; // mark the 'is Editor' checkbox
  1012. else
  1013. $isEditorCheckBoxIsChecked = ""; // don't mark the 'is Editor' checkbox
  1014. echo "\n\t<td align=\"right\" class=\"mainfieldsbg\"><input type=\"checkbox\" id=\"isEditorCheckBox\" name=\"isEditorCheckBox\" value=\"1\"$isEditorCheckBoxIsChecked title=\"". $loc["DescriptionEditorCheckBox"]."\">&nbsp;&nbsp;<b>". $loc["isEditor"]."</b></td>"
  1015. . "\n</tr>"
  1016. . "\n<tr>"
  1017. . "\n\t<td width=\"74\" class=\"mainfieldsbg\"><b>". $loc["Title"]."</b></td>"
  1018. . "\n\t<td colspan=\"3\" class=\"mainfieldsbg\">"
  1019. . "\n\t\t" . fieldError("titleName", $errors) . "<input type=\"text\" id=\"titleName\" name=\"titleName\" value=\"$titleName\" size=\"47\" title=\"". $loc["DescriptionTitle"]."\">" . $titleSuggestElements
  1020. . "\n\t</td>"
  1021. . "\n\t<td width=\"74\" class=\"mainfieldsbg\"><b>". $loc["Type"]."</b></td>";
  1022. if (!isset($_SESSION['user_types']))
  1023. $documentTypeDisabled = " disabled"; // disable the type popup if the session variable holding the user's types isn't available
  1024. else
  1025. $documentTypeDisabled = "";
  1026. $recordType = "\n\t<td align=\"right\" class=\"mainfieldsbg\">"
  1027. . "\n\t\t<select id=\"typeName\" name=\"typeName\" title=\"". $loc["DescriptionType"]."\" $documentTypeDisabled>";
  1028. if (isset($_SESSION['user_types']))
  1029. {
  1030. $userTypesAvail = explode("; ", $_SESSION['user_types']);
  1031. $userTypesAvailInv = array_flip($userTypesAvail);
  1032. $localizedTypeName = array(
  1033. 'Journal Article' => $loc['typeJournal Article'],
  1034. 'Abstract' => $loc['typeAbstract'],
  1035. 'Book Chapter' => $loc['typeBook Chapter'],
  1036. 'Book Whole' => $loc['typeBook Whole'],
  1037. 'Conference Article' => $loc['typeConference Article'],
  1038. 'Conference Volume' => $loc['typeConference Volume'],
  1039. 'Journal' => $loc['typeJournal'],
  1040. 'Magazine Article' => $loc['typeMagazine Article'],
  1041. 'Manual' => $loc['typeManual'],
  1042. 'Manuscript' => $loc['typeManuscript'],
  1043. 'Map' => $loc['typeMap'],
  1044. 'Miscellaneous' => $loc['typeMiscellaneous'],
  1045. 'Newspaper Article' => $loc['typeNewspaper Article'],
  1046. 'Patent' => $loc['typePatent'],
  1047. 'Report' => $loc['typeReport'],
  1048. 'Software' => $loc['typeSoftware'],
  1049. );
  1050. $userTypesArray = array_intersect_key($localizedTypeName, $userTypesAvailInv);
  1051. $optionTags = buildSelectMenuOptions($userTypesArray, "//", "\t\t\t", true); // build properly formatted <option value=""> tag elements from the items listed in the 'user_types' session variable
  1052. $recordType .= $optionTags;
  1053. if ($recordAction == "edit" || $mode == "import") // for the edit (or import) record form, the current type is added to the drop down if it isn't one of the user's types
  1054. {
  1055. $userTypes = preg_split("/ *; */", $_SESSION['user_types']);
  1056. $optionPresent = false;
  1057. foreach ($userTypes as $userType)
  1058. {
  1059. if ($userType == $typeName)
  1060. {
  1061. $optionPresent = true;
  1062. }
  1063. }
  1064. if ($optionPresent != true)
  1065. {
  1066. $recordType .= "\n\t\t\t<option value=\"$typeName\" selected>$localizedTypeName[$typeName]</option>";
  1067. }
  1068. }
  1069. }
  1070. else
  1071. $recordType .= "<option>(no types available)</option>";
  1072. $recordType .= "\n\t\t</select>"
  1073. . "\n\t</td>";
  1074. if (!empty($typeName))
  1075. $recordType = preg_replace("/(value=\"$typeName\")/i", "\\1 selected", $recordType);
  1076. echo "$recordType"
  1077. . "\n</tr>"
  1078. . "\n<tr>"
  1079. . "\n\t<td width=\"74\" class=\"mainfieldsbg\"><b>". $loc["Year"]."</b></td>"
  1080. . "\n\t<td class=\"mainfieldsbg\">"
  1081. . "\n\t\t" . fieldError("yearNo", $errors) . "<input type=\"text\" id=\"yearNo\" name=\"yearNo\" value=\"$yearNo\" size=\"14\" title=\"". $loc["DescriptionYear"]."\">" . $yearSuggestElements
  1082. . "\n\t</td>"
  1083. . "\n\t<td width=\"74\" class=\"mainfieldsbg\"><b>". $loc["Publication"]."</b></td>"
  1084. . "\n\t<td class=\"mainfieldsbg\">"
  1085. . "\n\t\t" . fieldError("publicationName", $errors) . "<input type=\"text\" id=\"publicationName\" name=\"publicationName\" value=\"$publicationName\" size=\"14\" title=\"". $loc["DescriptionPublicationName"]."\">" . $publicationSuggestElements
  1086. . "\n\t</td>"
  1087. . "\n\t<td width=\"74\" class=\"mainfieldsbg\"><b>". $loc["JournalAbbr"]."</b></td>"
  1088. . "\n\t<td align=\"right\" class=\"mainfieldsbg\">"
  1089. . "\n\t\t" . fieldError("abbrevJournalName", $errors) . "<input type=\"text\" id=\"abbrevJournalName\" name=\"abbrevJournalName\" value=\"$abbrevJournalName\" size=\"14\" title=\"". $loc["DescriptionJournalAbbr"]."\">" . $abbrevJournalSuggestElements
  1090. . "\n\t</td>"
  1091. . "\n</tr>"
  1092. . "\n<tr>"
  1093. . "\n\t<td width=\"74\" class=\"mainfieldsbg\"><b>". $loc["Volume"]."</b></td>"
  1094. . "\n\t<td class=\"mainfieldsbg\">"
  1095. . "\n\t\t" . fieldError("volumeNo", $errors) . "<input type=\"text\" id=\"volumeNo\" name=\"volumeNo\" value=\"$volumeNo\" size=\"14\" title=\"". $loc["DescriptionVolume"]."\">" . $volumeSuggestElements
  1096. . "\n\t</td>"
  1097. . "\n\t<td width=\"74\" class=\"mainfieldsbg\"><b>". $loc["Issue"]."</b></td>"
  1098. . "\n\t<td class=\"mainfieldsbg\">"
  1099. . "\n\t\t<input type=\"text\" id=\"issueNo\" name=\"issueNo\" value=\"$issueNo\" size=\"14\" title=\"". $loc["DescriptionIssue"]."\">" . $issueSuggestElements
  1100. . "\n\t</td>"
  1101. . "\n\t<td width=\"74\" class=\"mainfieldsbg\"><b>". $loc["Pages"]."</b></td>"
  1102. . "\n\t<td align=\"right\" class=\"mainfieldsbg\">"
  1103. . "\n\t\t" . fieldError("pagesNo", $errors) . "<input type=\"text\" id=\"pagesNo\" name=\"pagesNo\" value=\"$pagesNo\" size=\"14\" title=\"". $loc["DescriptionPages"]."\">" . $pagesSuggestElements
  1104. . "\n\t</td>"
  1105. . "\n</tr>"
  1106. . "\n<tr>"
  1107. . "\n\t<td width=\"74\" class=\"otherfieldsbg\"><b>". $loc["Keywords"]."</b></td>"
  1108. . "\n\t<td colspan=\"5\" class=\"otherfieldsbg\">"
  1109. . "\n\t\t<input type=\"text\" id=\"keywordsName\" name=\"keywordsName\" value=\"$keywordsName\" size=\"84\" title=\"". $loc["DescriptionKeywords"]."\">" . $keywordsSuggestElements
  1110. . "\n\t</td>"
  1111. . "\n</tr>"
  1112. . "\n<tr>"
  1113. . "\n\t<td width=\"74\" class=\"otherfieldsbg\"><b>". $loc["Abstract"]."</b></td>"
  1114. . "\n\t<td colspan=\"5\" class=\"otherfieldsbg\"><textarea id=\"abstractName\" name=\"abstractName\" rows=\"6\" cols=\"83\" title=\"". $loc["DescriptionAbstract"]."\">$abstractName</textarea></td>"
  1115. . "\n</tr>"
  1116. . "\n<tr>"
  1117. . "\n\t<td width=\"74\" class=\"otherfieldsbg\"><b>". $loc["Address"]."</b></td>"
  1118. . "\n\t<td colspan=\"5\" class=\"otherfieldsbg\">"
  1119. . "\n\t\t<input type=\"text\" id=\"addressName\" name=\"addressName\" value=\"$addressName\" size=\"84\" title=\"". $loc["DescriptionAdress"]."\">" . $addressSuggestElements
  1120. . "\n\t</td>"
  1121. . "\n</tr>"
  1122. . "\n<tr>"
  1123. . "\n\t<td width=\"74\" class=\"otherfieldsbg\"><b>". $loc["CorporateAuthor"]."</b></td>"
  1124. . "\n\t<td colspan=\"3\" class=\"otherfieldsbg\">"
  1125. . "\n\t\t<input type=\"text\" id=\"corporateAuthorName\" name=\"corporateAuthorName\" value=\"$corporateAuthorName\" size=\"47\" title=\"". $loc["DescriptionCorporate"]."\">" . $corporateAuthorSuggestElements
  1126. . "\n\t</td>"
  1127. . "\n\t<td width=\"74\" class=\"otherfieldsbg\"><b>". $loc["Thesis"]."</b></td>";
  1128. $thesisType = "\n\t<td align=\"right\" class=\"otherfieldsbg\">\n\t\t<select id=\"thesisName\" name=\"thesisName\" title=\"". $loc["DescriptionThesis"]."\">\n\t\t\t<option></option>\n\t\t\t<option value=\"Bachelor's thesis\">" . $loc["Bachelor's thesis"] . "</option>\n\t\t\t<option value=\"Master's thesis\">" . $loc["Master's thesis"] . "</option>\n\t\t\t<option value=\"Ph.D. thesis\">" . $loc["Ph.D. thesis"] . "</option>\n\t\t\t<option value=\"Diploma thesis\">" . $loc["Diploma thesis"] . "</option>\n\t\t\t<option value=\"Doctoral thesis\">" . $loc["Doctoral thesis"] . "</option>\n\t\t\t<option value=\"Habilitation thesis\">" . $loc["Habilitation thesis"] . "</option>\n\t\t</select>\n\t</td>";
  1129. if (!empty($thesisName))
  1130. $thesisType = preg_replace("/<option (value=\"" . $thesisName . "\")>/", "<option \\1 selected>", $thesisType);
  1131. echo "$thesisType"
  1132. . "\n</tr>"
  1133. . "\n<tr>"
  1134. . "\n\t<td width=\"74\" class=\"otherfieldsbg\"><b>". $loc["Publisher"]."</b></td>"
  1135. . "\n\t<td class=\"otherfieldsbg\">"
  1136. . "\n\t\t<input type=\"text\" id=\"publisherName\" name=\"publisherName\" value=\"$publisherName\" size=\"14\" title=\"". $loc["DescriptionPublisher"]."\">" . $publisherSuggestElements
  1137. . "\n\t</td>"
  1138. . "\n\t<td width=\"74\" class=\"otherfieldsbg\"><b>". $loc["PublisherPlace"]."</b></td>"
  1139. . "\n\t<td class=\"otherfieldsbg\">"
  1140. . "\n\t\t<input type=\"text\" id=\"placeName\" name=\"placeName\" value=\"$placeName\" size=\"14\" title=\"". $loc["DescriptionPublisherPlace"]."\">" . $placeSuggestElements
  1141. . "\n\t</td>"
  1142. . "\n\t<td width=\"74\" class=\"otherfieldsbg\"><b>". $loc["Editor"]."</b></td>"
  1143. . "\n\t<td align=\"right\" class=\"otherfieldsbg\">"
  1144. . "\n\t\t<input type=\"text\" id=\"editorName\" name=\"editorName\" value=\"$editorName\" size=\"14\" title=\"". $loc["DescriptionEditor"]."\">" . $editorSuggestElements
  1145. . "\n\t</td>"
  1146. . "\n</tr>"
  1147. . "\n<tr>"
  1148. . "\n\t<td width=\"74\" class=\"otherfieldsbg\"><b>". $loc["Language"]."</b></td>"
  1149. . "\n\t<td class=\"otherfieldsbg\">"
  1150. . "\n\t\t" . fieldError("languageName", $errors) . "<input type=\"text\" id=\"languageName\" name=\"languageName\" value=\"$languageName\" size=\"14\" title=\"". $loc["DescriptionLanguage"]."\">" . $languageSuggestElements
  1151. . "\n\t</td>"
  1152. . "\n\t<td width=\"74\" class=\"otherfieldsbg\"><b>". $loc["LanguageSummary"]."</b></td>"
  1153. . "\n\t<td class=\"otherfieldsbg\">"
  1154. . "\n\t\t<input type=\"text\" id=\"summaryLanguageName\" name=\"summaryLanguageName\" value=\"$summaryLanguageName\" size=\"14\" title=\"". $loc["DescriptionLanguageSummary"]."\">" . $summaryLanguageSuggestElements
  1155. . "\n\t</td>"
  1156. . "\n\t<td width=\"74\" class=\"otherfieldsbg\"><b>". $loc["TitleOriginal"]."</b></td>"
  1157. . "\n\t<td align=\"right\" class=\"otherfieldsbg\">"
  1158. . "\n\t\t<input type=\"text\" id=\"origTitleName\" name=\"origTitleName\" value=\"$origTitleName\" size=\"14\" title=\"". $loc["DescriptionTitleOriginal"]."\">" . $origTitleSuggestElements
  1159. . "\n\t</td>"
  1160. . "\n</tr>"
  1161. . "\n<tr>"
  1162. . "\n\t<td width=\"74\" class=\"otherfieldsbg\"><b>". $loc["SeriesEditor"]."</b></td>"
  1163. . "\n\t<td class=\"otherfieldsbg\">"
  1164. . "\n\t\t<input type=\"text\" id=\"seriesEditorName\" name=\"seriesEditorName\" value=\"$seriesEditorName\" size=\"14\" title=\"". $loc["DescriptionSeriesEditor"]."\">" . $seriesEditorSuggestElements
  1165. . "\n\t</td>"
  1166. . "\n\t<td width=\"74\" class=\"otherfieldsbg\"><b>". $loc["TitleSeries"]."</b></td>"
  1167. . "\n\t<td class=\"otherfieldsbg\">"
  1168. . "\n\t\t<input type=\"text\" id=\"seriesTitleName\" name=\"seriesTitleName\" value=\"$seriesTitleName\" size=\"14\" title=\"". $loc["DescriptionTitleSeries"]."\">" . $seriesTitleSuggestElements
  1169. . "\n\t</td>"
  1170. . "\n\t<td width=\"74\" class=\"otherfieldsbg\"><b>". $loc["TitleSeriesAbbr"]."</b></td>"
  1171. . "\n\t<td align=\"right\" class=\"otherfieldsbg\">"
  1172. . "\n\t\t<input type=\"text\" id=\"abbrevSeriesTitleName\" name=\"abbrevSeriesTitleName\" value=\"$abbrevSeriesTitleName\" size=\"14\" title=\"". $loc["DescriptionTitleSeriesAbbr"]."\">" . $abbrevSeriesTitleSuggestElements
  1173. . "\n\t</td>"
  1174. . "\n</tr>"
  1175. . "\n<tr>"
  1176. . "\n\t<td width=\"74\" class=\"otherfieldsbg\"><b>". $loc["SeriesVolume"]."</b></td>"
  1177. . "\n\t<td class=\"otherfieldsbg\">"
  1178. . "\n\t\t<input type=\"text\" id=\"seriesVolumeNo\" name=\"seriesVolumeNo\" value=\"$seriesVolumeNo\" size=\"14\" title=\"". $loc["DescriptionSeriesVolume"]."\">" . $seriesVolumeSuggestElements
  1179. . "\n\t</td>"
  1180. . "\n\t<td width=\"74\" class=\"otherfieldsbg\"><b>". $loc["SeriesIssue"]."</b></td>"
  1181. . "\n\t<td class=\"otherfieldsbg\">"
  1182. . "\n\t\t<input type=\"text\" id=\"seriesIssueNo\" name=\"seriesIssueNo\" value=\"$seriesIssueNo\" size=\"14\" title=\"". $loc["DescriptionSeriesIssue"]."\">" . $seriesIssueSuggestElements
  1183. . "\n\t</td>"
  1184. . "\n\t<td width=\"74\" class=\"otherfieldsbg\"><b>". $loc["Edition"]."</b></td>"
  1185. . "\n\t<td align=\"right\" class=\"otherfieldsbg\">"
  1186. . "\n\t\t<input type=\"text\" id=\"editionNo\" name=\"editionNo\" value=\"$editionNo\" size=\"14\" title=\"". $loc["DescriptionEdition"]."\">" . $editionSuggestElements
  1187. . "\n\t</td>"
  1188. . "\n</tr>"
  1189. . "\n<tr>"
  1190. . "\n\t<td width=\"74\" class=\"otherfieldsbg\"><b>". $loc["ISSN"]."</b></td>"
  1191. . "\n\t<td class=\"otherfieldsbg\">"
  1192. . "\n\t\t<input type=\"text\" id=\"issnName\" name=\"issnName\" value=\"$issnName\" size=\"14\" title=\"". $loc["DescriptionISSN"]."\">" . $issnSuggestElements
  1193. . "\n\t</td>"
  1194. . "\n\t<td width=\"74\" class=\"otherfieldsbg\"><b>". $loc["ISBN"]."</b></td>"
  1195. . "\n\t<td class=\"otherfieldsbg\">"
  1196. . "\n\t\t<input type=\"text\" id=\"isbnName\" name=\"isbnName\" value=\"$isbnName\" size=\"14\" title=\"". $loc["DescriptionISBN"]."\">" . $isbnSuggestElements
  1197. . "\n\t</td>"
  1198. . "\n\t<td width=\"74\" class=\"otherfieldsbg\"><b>". $loc["Medium"]."</b></td>"
  1199. . "\n\t<td align=\"right\" class=\"otherfieldsbg\">"
  1200. . "\n\t\t<input type=\"text\" id=\"mediumName\" name=\"mediumName\" value=\"$mediumName\" size=\"14\" title=\"". $loc["DescriptionMedium"]."\">" . $mediumSuggestElements
  1201. . "\n\t</td>"
  1202. . "\n</tr>"
  1203. . "\n<tr>"
  1204. . "\n\t<td width=\"74\" class=\"otherfieldsbg\"><b>". $loc["Area"]."</b></td>"
  1205. . "\n\t<td class=\"otherfieldsbg\">"
  1206. . "\n\t\t<input type=\"text\" id=\"areaName\" name=\"areaName\" value=\"$areaName\" size=\"14\" title=\"". $loc["DescriptionArea"]."\">" . $areaSuggestElements
  1207. . "\n\t</td>"
  1208. . "\n\t<td width=\"74\" class=\"otherfieldsbg\"><b>". $loc["Expedition"]."</b></td>"
  1209. . "\n\t<td class=\"otherfieldsbg\">"
  1210. . "\n\t\t<input type=\"text\" id=\"expeditionName\" name=\"expeditionName\" value=\"$expeditionName\" size=\"14\" title=\"". $loc["DescriptionExpedition"]."\">" . $expeditionSuggestElements
  1211. . "\n\t</td>"
  1212. . "\n\t<td width=\"74\" class=\"otherfieldsbg\"><b>". $loc["Conference"]."</b></td>"
  1213. . "\n\t<td align=\"right\" class=\"otherfieldsbg\">"
  1214. . "\n\t\t<input type=\"text\" id=\"conferenceName\" name=\"conferenceName\" value=\"$conferenceName\" size=\"14\" title=\"". $loc["DescriptionConference"]."\">" . $conferenceSuggestElements
  1215. . "\n\t</td>"
  1216. . "\n</tr>"
  1217. . "\n<tr>"
  1218. . "\n\t<td width=\"74\" class=\"otherfieldsbg\"><b>". $loc["Notes"]."</b></td>"
  1219. . "\n\t<td colspan=\"3\" class=\"otherfieldsbg\">"
  1220. . "\n\t\t<input type=\"text\" id=\"notesName\" name=\"notesName\" value=\"$notesName\" size=\"47\" title=\"". $loc["DescriptionNotes"]."\">" . $notesSuggestElements
  1221. . "\n\t</td>"
  1222. . "\n\t<td width=\"74\" class=\"otherfieldsbg\"><b>". $loc["Approved"]."</b></td>";
  1223. $approved = "\n\t<td align=\"right\" class=\"otherfieldsbg\"><input type=\"radio\" id=\"approvedRadioA\" name=\"approvedRadio\" value=\"yes\" title=\"". $loc["DescriptionApproved"]."\">&nbsp;&nbsp;". $loc["yes"]."&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"radio\" id=\"approvedRadioB\" name=\"approvedRadio\" value=\"no\" title=\"". $loc["DescriptionApproved"]."\">&nbsp;&nbsp;". $loc["no"]."</td>";
  1224. if ($approvedRadio == "yes")
  1225. $approved = preg_replace("/name=\"approvedRadio\" value=\"yes\"/", "name=\"approvedRadio\" value=\"yes\" checked", $approved);
  1226. else // ($approvedRadio == "no")
  1227. $approved = preg_replace("/name=\"approvedRadio\" value=\"no\"/", "name=\"approvedRadio\" value=\"no\" checked", $approved);
  1228. echo "$approved"
  1229. . "\n</tr>"
  1230. . "\n<tr>"
  1231. . "\n\t<td width=\"74\" class=\"otherfieldsbg\"><b>". $loc["Location"]."</b></td>"
  1232. . "\n\t<td colspan=\"5\" class=\"otherfieldsbg\">"
  1233. . "\n\t\t<input type=\"text\" id=\"locationName\" name=\"locationName\" value=\"$locationName\" size=\"84\" title=\"". $loc["DescriptionLocation"]."$fieldLockLabel\"$fieldLock>" . $locationSuggestElements
  1234. . "\n\t</td>"
  1235. . "\n</tr>"
  1236. . "\n<tr>"
  1237. . "\n\t<td width=\"74\" class=\"mainfieldsbg\"><b>". $loc["CallNumber"]."</b></td>";
  1238. // if the user isn't logged in -OR- any normal user is logged in (not the admin)...
  1239. if ((!isset($loginEmail)) OR ((isset($loginEmail)) AND ($loginEmail != $adminLoginEmail)))
  1240. {
  1241. // ...we just show the user's own call number (if any):
  1242. echo "\n\t<td colspan=\"3\" class=\"mainfieldsbg\">"
  1243. . "\n\t\t" . fieldError("callNumberNameUserOnly", $errors) . "<input type=\"text\" id=\"callNumberNameUserOnly\" name=\"callNumberNameUserOnly\" value=\"$callNumberNameUserOnly\" size=\"47\" title=\"". $loc["DescriptionCallNumber"]."\">" . $callNumberSuggestElements
  1244. . "\n\t</td>";
  1245. }
  1246. else // if the admin is logged in...
  1247. {
  1248. // ...we display the full contents of the 'call_number' field:
  1249. echo "\n\t<td colspan=\"3\" class=\"mainfieldsbg\">"
  1250. . "\n\t\t<input type=\"text\" id=\"callNumberName\" name=\"callNumberName\" value=\"$callNumberName\" size=\"47\" title=\"". $loc["DescriptionCallNumberFull"]."\">" . $callNumberSuggestElements
  1251. . "\n\t</td>";
  1252. }
  1253. echo "\n\t<td width=\"74\" class=\"mainfieldsbg\"><b>". $loc["Serial"]."</b></td>"
  1254. . "\n\t<td align=\"right\" class=\"mainfieldsbg\"><input type=\"text\" id=\"serialNo\" name=\"serialNo\" value=\"$serialNo\" size=\"14\" title=\"". $loc["DescriptionSerial"]."\" readonly></td>"
  1255. . "\n</tr>"
  1256. . "\n<tr>"
  1257. . "\n\t<td width=\"74\" class=\"userfieldsbg\"><b>". $loc["Marked"]."</b></td>";
  1258. $marked = "\n\t<td class=\"userfieldsbg\"><input type=\"radio\" id=\"markedRadioA\" name=\"markedRadio\" value=\"yes\" title=\"". $loc["DescriptionMarked"]."\">&nbsp;&nbsp;". $loc["yes"]."&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"radio\" id=\"markedRadioB\" name=\"markedRadio\" value=\"no\" title=\"". $loc["DescriptionMarked"]."\">&nbsp;&nbsp;". $loc["no"]."</td>";
  1259. if ($markedRadio == "yes")
  1260. $marked = preg_replace("/name=\"markedRadio\" value=\"yes\"/", "name=\"markedRadio\" value=\"yes\" checked", $marked);
  1261. else // ($markedRadio == "no")
  1262. $marked = preg_replace("/name=\"markedRadio\" value=\"no\"/", "name=\"markedRadio\" value=\"no\" checked", $marked);
  1263. echo "$marked"
  1264. . "\n\t<td width=\"74\" class=\"userfieldsbg\"><b>". $loc["Copy"]."</b></td>";
  1265. $copy = "\n\t<td class=\"userfieldsbg\">\n\t\t<select id=\"copyName\" name=\"copyName\" title=\"". $loc["DescriptionCopy"]."\">\n\t\t\t<option value=\"true\">". $loc["true"]."</option>\n\t\t\t<option value=\"fetch\">". $loc["fetch"]."</option>\n\t\t\t<option value=\"ordered\">". $loc["ordered"]."</option>\n\t\t\t<option value=\"false\">". $loc["false"]."</option>\n\t\t</select>\n\t</td>";
  1266. if (!empty($copyName))
  1267. $copy = preg_replace("/<option(.*?)>" . $loc[$copyName] . "/", "<option\\1 selected>" . $loc[$copyName], $copy);
  1268. echo "$copy"
  1269. . "\n\t<td width=\"74\" class=\"userfieldsbg\"><b>". $loc["Selected"]."</b></td>";
  1270. $selected = "\n\t<td align=\"right\" class=\"userfieldsbg\"><input type=\"radio\" id=\"selectedRadioA\" name=\"selectedRadio\" value=\"yes\" title=\"". $loc["DescriptionSelected"]."\">&nbsp;&nbsp;". $loc["yes"]."&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"radio\" id=\"selectedRadioB\" name=\"selectedRadio\" value=\"no\" title=\"". $loc["DescriptionSelected"]."\">&nbsp;&nbsp;". $loc["no"]."</td>";
  1271. if ($selectedRadio == "yes")
  1272. $selected = preg_replace("/name=\"selectedRadio\" value=\"yes\"/", "name=\"selectedRadio\" value=\"yes\" checked", $selected);
  1273. else // ($selectedRadio == "no")
  1274. $selected = preg_replace("/name=\"selectedRadio\" value=\"no\"/", "name=\"selectedRadio\" value=\"no\" checked", $selected);
  1275. echo "$selected"
  1276. . "\n</tr>"
  1277. . "\n<tr>"
  1278. . "\n\t<td width=\"74\" class=\"userfieldsbg\"><b>". $loc["UserKeys"]."</b></td>"
  1279. . "\n\t<td colspan=\"5\" class=\"userfieldsbg\">"
  1280. . "\n\t\t<input type=\"text\" id=\"userKeysName\" name=\"userKeysName\" value=\"$userKeysName\" size=\"84\" title=\"". $loc["DescriptionUserKeys"]."\">" . $userKeysSuggestElements
  1281. . "\n\t</td>"
  1282. . "\n</tr>"
  1283. . "\n<tr>"
  1284. . "\n\t<td width=\"74\" class=\"userfieldsbg\"><b>". $loc["UserNotes"]."</b></td>"
  1285. . "\n\t<td colspan=\"3\" class=\"userfieldsbg\">"
  1286. . "\n\t\t<input type=\"text\" id=\"userNotesName\" name=\"userNotesName\" value=\"$userNotesName\" size=\"47\" title=\"". $loc["DescriptionUserNotes"]."\">" . $userNotesSuggestElements
  1287. . "\n\t</td>"
  1288. . "\n\t<td width=\"74\" class=\"userfieldsbg\"><b>". $loc["UserFile"]."</b></td>"
  1289. . "\n\t<td align=\"right\" class=\"userfieldsbg\">"
  1290. . "\n\t\t<input type=\"text\" id=\"userFileName\" name=\"userFileName\" value=\"$userFileName\" size=\"14\" title=\"". $loc["DescriptionUserFile"]."\">" . $userFileSuggestElements
  1291. . "\n\t</td>"
  1292. . "\n</tr>"
  1293. . "\n<tr>"
  1294. . "\n\t<td width=\"74\" class=\"userfieldsbg\"><b>". $loc["UserGroups"]."</b></td>";
  1295. if (isset($_SESSION['user_permissions']) AND preg_match("/allow_user_groups/", $_SESSION['user_permissions'])) // if the 'user_permissions' session variable contains 'allow_user_groups'...
  1296. // adjust the title string for the user groups text entry field:
  1297. {
  1298. $userGroupsFieldLock = "";
  1299. $userGroupsTitle = $loc["DescriptionUserGroups"];
  1300. }
  1301. else
  1302. {
  1303. $userGroupsFieldLock = " disabled"; // it would be more consistent to remove the user groups field completely from the form if the user has no permission to use the user groups feature; but since this would complicate the processing quite a bit, we just disable the field (for now)
  1304. $userGroupsTitle = $loc["NoPermission"] . $loc["NoPermission_ForUserGroups"];
  1305. }
  1306. echo "\n\t<td colspan=\"3\" class=\"userfieldsbg\">"
  1307. . "\n\t\t<input type=\"text\" id=\"userGroupsName\" name=\"userGroupsName\" value=\"$userGroupsName\" size=\"47\"$userGroupsFieldLock title=\"$userGroupsTitle\">" . $userGroupsSuggestElements
  1308. . "\n\t</td>"
  1309. . "\n\t<td width=\"74\" class=\"userfieldsbg\"><b>". $loc["CiteKey"]."</b></td>"
  1310. . "\n\t<td align=\"right\" class=\"userfieldsbg\">"
  1311. . "\n\t\t<input type=\"text\" id=\"citeKeyName\" name=\"citeKeyName\" value=\"$citeKeyName\" size=\"14\" title=\"". $loc["DescriptionCiteKey"]."\">" . $citeKeySuggestElements
  1312. . "\n\t</td>"
  1313. . "\n</tr>"
  1314. . "\n<tr>"
  1315. . "\n\t<td width=\"74\" class=\"userfieldsbg\"><b>". $loc["Related"]."</b></td>"
  1316. . "\n\t<td colspan=\"5\" class=\"userfieldsbg\">"
  1317. . "\n\t\t<input type=\"text\" id=\"relatedName\" name=\"relatedName\" value=\"$relatedName\" size=\"84\" title=\"". $loc["DescriptionRelated"]."\">" . $relatedSuggestElements
  1318. . "\n\t</td>"
  1319. . "\n</tr>"
  1320. . "\n<tr>"
  1321. . "\n\t<td width=\"74\" class=\"otherfieldsbg\"><b>". $loc["File"]."</b></td>"
  1322. . "\n\t<td colspan=\"3\" class=\"otherfieldsbg\"><input type=\"text\" id=\"fileName\" name=\"fileName\" value=\"$fileName\" size=\"47\" title=\"". $loc["DescriptionFile"]."\"$fieldLock></td>";
  1323. if (isset($_SESSION['user_permissions']) AND preg_match("/allow_upload/", $_SESSION['user_permissions'])) // if the 'user_permissions' session variable contains 'allow_upload'...
  1324. // adjust the title string for the upload button:
  1325. {
  1326. $uploadButtonLock = "";
  1327. $uploadTitle = $loc["DescriptionFileUpload"];
  1328. }
  1329. else
  1330. {
  1331. $uploadButtonLock = " disabled"; // disabling of the upload button doesn't seem to work in all browsers (e.g., it doesn't work in Safari on MacOSX Panther, but does work with Mozilla & Camino) ?:-/
  1332. $uploadTitle = $loc["NoPermission"] . $loc["NoPermission_ForFileUpload"]; // similarily, not all browsers will show title strings for disabled buttons (Safari does, Mozilla & Camino do not)
  1333. }
  1334. echo "\n\t<td valign=\"bottom\" colspan=\"2\" class=\"otherfieldsbg\">" . fieldError("uploadFile", $errors) . "<input type=\"file\" id=\"uploadFile\" name=\"uploadFile\" size=\"17\"$uploadButtonLock title=\"$uploadTitle\"></td>"
  1335. . "\n</tr>"
  1336. . "\n<tr>"
  1337. . "\n\t<td width=\"74\" class=\"otherfieldsbg\"><b>". $loc["URL"]."</b></td>"
  1338. . "\n\t<td colspan=\"3\" class=\"otherfieldsbg\">"
  1339. . "\n\t\t<input type=\"text\" id=\"urlName\" name=\"urlName\" value=\"$urlName\" size=\"47\" title=\"". $loc["DescriptionURL"]."\">" . $urlSuggestElements
  1340. . "\n\t</td>"
  1341. . "\n\t<td width=\"74\" class=\"otherfieldsbg\"><b>". $loc["DOI"]."</b></td>"
  1342. . "\n\t<td align=\"right\" class=\"otherfieldsbg\">"
  1343. . "\n\t\t<input type=\"text\" id=\"doiName\" name=\"doiName\" value=\"$doiName\" size=\"14\" title=\"". $loc["DescriptionDOI"]."\">" . $doiSuggestElements
  1344. . "\n\t</td>"
  1345. . "\n</tr>";
  1346. if ($onlinePublication == "yes") // if the 'online_publication' field value is "yes"
  1347. $onlinePublicationCheckBoxIsChecked = " checked"; // mark the 'Online publication' checkbox
  1348. else
  1349. $onlinePublicationCheckBoxIsChecked = ""; // don't mark the 'Online publication' checkbox
  1350. echo "\n<tr>"
  1351. . "\n\t<td width=\"74\" class=\"otherfieldsbg\">&nbsp;</td>"
  1352. . "\n\t<td colspan=\"3\" class=\"otherfieldsbg\">\n\t\t<input type=\"checkbox\" id=\"onlinePublicationCheckBox\" name=\"onlinePublicationCheckBox\" value=\"1\"$onlinePublicationCheckBoxIsChecked title=\"". $loc["DescriptionOnlinePublicationCheckbox"]."\">&nbsp;"
  1353. . "\n\t\t". $loc["Online publication. Cite with this text:"]."&nbsp;"
  1354. . "\n\t\t<input type=\"text\" id=\"onlineCitationName\" name=\"onlineCitationName\" value=\"$onlineCitationName\" size=\"7\" title=\"". $loc["DescriptionOnlinePublicationCitation"]."\">" . $onlineCitationSuggestElements
  1355. . "\n\t</td>";
  1356. if (isset($loginEmail)) // if a user is logged in...
  1357. {
  1358. // ...we'll show a checkbox where the user can state that the current publication stems form his own institution
  1359. if ($contributionIDCheckBox == "1" OR preg_match("/$abbrevInstitution/", $contributionID)) // if the '$contributionIDCheckBox' variable is set to 1 -OR- if the currrent user's abbreviated institution name is listed within the 'contribution_id' field
  1360. $contributionIDCheckBoxIsChecked = " checked";
  1361. else
  1362. $contributionIDCheckBoxIsChecked = "";
  1363. if ($origRecord > 0) // if the current record has been identified as duplicate entry...
  1364. $contributionIDCheckBoxLock = " disabled"; // ...we lock the check box (since the original entry, and not the dup entry, should be marked instead)
  1365. else
  1366. $contributionIDCheckBoxLock = "";
  1367. echo "\n\t<td colspan=\"2\" class=\"otherfieldsbg\">\n\t\t<input type=\"checkbox\" id=\"contributionIDCheckBox\" name=\"contributionIDCheckBox\" value=\"1\"$contributionIDCheckBoxIsChecked title=\"". $loc["DescriptionOwnPublication"]."\"$contributionIDCheckBoxLock>&nbsp;"
  1368. . "\n\t\t". encodeHTML($abbrevInstitution) . " " . $loc["publication"] . "\n\t</td>"; // we make use of the session variable '$abbrevInstitution' here
  1369. }
  1370. else
  1371. {
  1372. echo "\n\t<td colspan=\"2\" class=\"otherfieldsbg\">&nbsp;</td>";
  1373. }
  1374. echo "\n</tr>"
  1375. . "\n<tr>"
  1376. . "\n\t<td width=\"74\">&nbsp;</td>"
  1377. . "\n\t<td colspan=\"5\">&nbsp;</td>"
  1378. . "\n</tr>";
  1379. echo "\n<tr>"
  1380. . "\n\t<td width=\"74\">". $loc["Location Field"].":</td>";
  1381. $locationSelector = "\n\t<td colspan=\"3\">\n\t\t<select id=\"locationSelectorName\" name=\"locationSelectorName\" title=\"". $loc["DescriptionLocationSelector"]."\">\n\t\t\t<option value=\"don't touch\">". $loc["don't touch"]."</option>\n\t\t\t<option value=\"add\">". $loc["add"]."</option>\n\t\t\t<option value=\"remove\">". $loc["remove"]."</option>\n\t\t</select>&nbsp;&nbsp;\n\t\t". $loc["my name & email address"]."\n\t</td>";
  1382. if ($recordAction == "edit" AND !empty($locationSelectorName))
  1383. $locationSelector = preg_replace("/<option(.*?)>" . $loc[$locationSelectorName] . "/", "<option\\1 selected>" . $loc[$locationSelectorName], $locationSelector);
  1384. elseif ($recordAction == "add")
  1385. {
  1386. $locationSelector = preg_replace("/<option(.*?)>" . $loc["add"] . "/", "<option\\1 selected>" . $loc["add"], $locationSelector); // select the appropriate menu entry ...
  1387. if ((!isset($loginEmail)) OR ((isset($loginEmail)) AND ($loginEmail != $adminLoginEmail))) // ... and if the user isn't logged in -OR- any normal user is logged in (not the admin) ...
  1388. $locationSelector = preg_replace("/<select/i", "<select disabled", $locationSelector); // ... disable the popup menu. This is, since the current user & email address will be always written to the location field when adding new records. An orphaned record would be produced if the user could chose anything other than 'add'! (Note that the admin is permitted to override this behaviour)
  1389. }
  1390. echo "$locationSelector"
  1391. . "\n\t<td align=\"right\" colspan=\"2\">";
  1392. // Note that, normally, we don't show interface items which the user isn't allowed to use (see the delete button). But, in the case of the add/edit button we make an exception here and just grey the button out.
  1393. // This is, since otherwise the form would have no submit button at all, which would be pretty odd. The title string of the button explains why it is disabled.
  1394. if ($recordAction == "edit") // adjust the title string for the edit button
  1395. {
  1396. if (isset($_SESSION['user_permissions']) AND preg_match("/allow_edit/", $_SESSION['user_permissions'])) // if the 'user_permissions' session variable contains 'allow_edit'...
  1397. {
  1398. $addEditButtonLock = "";
  1399. $addEditTitle = $loc["DescriptionEditButton"];
  1400. }
  1401. else
  1402. {
  1403. $addEditButtonLock = " disabled";
  1404. $addEditTitle = $loc["NoPermission"] . $loc["NoPermission_ForEditRecords"];
  1405. }
  1406. }
  1407. else // if ($recordAction == "add") // adjust the title string for the add button
  1408. {
  1409. if (isset($_SESSION['user_permissions']) AND preg_match("/allow_add/", $_SESSION['user_permissions'])) // if the 'user_permissions' session variable contains 'allow_add'...
  1410. {
  1411. $addEditButtonLock = "";
  1412. $addEditTitle = $loc["DescriptionAddButton"];
  1413. }
  1414. else
  1415. {
  1416. $addEditButtonLock = " disabled";
  1417. $addEditTitle = $loc["NoPermission"] . $loc["NoPermission_ForAddRecords"];
  1418. }
  1419. }
  1420. // display an ADD/EDIT button:
  1421. echo "<input type=\"submit\" name=\"submit\" value=\"$addEditButtonTitle\"$addEditButtonLock title=\"$addEditTitle\">";
  1422. if (isset($_SESSION['user_permissions']) AND preg_match("/allow_delete/", $_SESSION['user_permissions'])) // if the 'user_permissions' session variable contains 'allow_delete'...
  1423. // ... display a delete button:
  1424. {
  1425. if ($recordAction == "edit") // add a DELETE button (CAUTION: the delete button must be displayed *AFTER* the edit button, otherwise DELETE will be the default action if the user hits return!!)
  1426. // (this is since the first displayed submit button represents the default submit action in several browsers!! [like OmniWeb or Mozilla])
  1427. {
  1428. if (!isset($loginEmail) OR ((!preg_match("/" . $loginEmail . "/", $locationName) OR preg_match("/;/", $rawLocationName)) AND ($loginEmail != $adminLoginEmail))) // if the user isn't logged in -OR- any normal user is logged in & the 'location' field doesn't list her email address -OR- if the 'location' field contains more than one user (which is indicated by a semicolon character)...
  1429. // Note that we use '$rawLocationName' instead of the '$locationName' variable for those tests that check for the existence of a semicolon since for '$locationName' high ASCII characters were converted into HTML entities.
  1430. // E.g., the german umlaut '�' would be presented as '&uuml;', thus containing a semicolon character *within* the user's name!
  1431. {
  1432. // build an informative title string:
  1433. if (!isset($loginEmail)) // if the user isn't logged in
  1434. $deleteTitle = $loc["DescriptionDeleteButtonDisabled"] . $loc["DescriptionDeleteButtonDisabledNotLoggedIn"];
  1435. elseif (!preg_match("/" . $loginEmail . "/", $locationName)) // if any normal user is logged in & the 'location' field doesn't list her email address
  1436. $deleteTitle = $loc["DescriptionDeleteButtonDisabled"] . $loc["DescriptionDeleteButtonDisabledNotYours"];
  1437. elseif (preg_match("/;/", $rawLocationName)) // if the 'location' field contains more than one user (which is indicated by a semicolon character)
  1438. {
  1439. // if we made it here, the current user is listed within the 'location' field of this record
  1440. if (preg_match("/^[^;]+;[^;]+$/", $rawLocationName)) // the 'location' field does contain exactly one ';' => two authors, i.e., there's only one "other user" listed within the 'location' field
  1441. $deleteTitle = $loc["DescriptionDeleteButtonDisabled"] . $loc["DescriptionDeleteButtonDisabledOtherUser"];
  1442. elseif (preg_match("/^[^;]+;[^;]+;[^;]+/", $rawLocationName)) // the 'location' field does contain at least two ';' => more than two authors, i.e., there are two or more "other users" listed within the 'location' field
  1443. $deleteTitle = $loc["DescriptionDeleteButtonDisabled"] . $loc["DescriptionDeleteButtonDisabledOtherUsers"];
  1444. }
  1445. $deleteButtonLock = " disabled"; // ...we lock the delete button (since a normal user shouldn't be allowed to delete records that belong to other users)
  1446. }
  1447. else
  1448. {
  1449. $deleteTitle = $loc["DescriptionDeleteButton"];
  1450. $deleteButtonLock = "";
  1451. }
  1452. echo "&nbsp;&nbsp;&nbsp;<input type=\"submit\" name=\"submit\" value=\"" . $loc["ButtonTitle_DeleteRecord"] . "\"$deleteButtonLock title=\"$deleteTitle\">";
  1453. }
  1454. }
  1455. echo "</td>"
  1456. . "\n</tr>"
  1457. . "\n</table>"
  1458. . "\n</form>";
  1459. // (5) CLOSE the database connection:
  1460. disconnectFromMySQLDatabase(); // function 'disconnectFromMySQLDatabase()' is defined in 'include.inc.php'
  1461. // --------------------------------------------------------------------
  1462. // SHOW ERROR IN RED:
  1463. function fieldError($fieldName, $errors)
  1464. {
  1465. if (isset($errors[$fieldName]))
  1466. return "<b><span class=\"warning2\">" . $errors[$fieldName] . "</span></b><br>";
  1467. }
  1468. // --------------------------------------------------------------------
  1469. // DISPLAY THE HTML FOOTER:
  1470. // call the 'showPageFooter()' and 'displayHTMLfoot()' functions (which are defined in 'footer.inc.php')
  1471. showPageFooter($HeaderString);
  1472. displayHTMLfoot();
  1473. // --------------------------------------------------------------------
  1474. ?>