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.

156 lines
8.1 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: ./receipt.php
  11. // Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/receipt.php $
  12. // Author(s): Matthias Steffens <mailto:refbase@extracts.de>
  13. //
  14. // Created: 02-Jan-03, 22:43
  15. // Modified: $Date: 2012-02-27 20:25:30 +0000 (Mon, 27 Feb 2012) $
  16. // $Author: msteffens $
  17. // $Revision: 1337 $
  18. // This php script will display a feedback page after any action of
  19. // adding/editing/deleting a record. It will display links to the
  20. // modified/added record as well as to the previous search results page (if any)
  21. // TODO: I18n
  22. // Incorporate some include files:
  23. include 'initialize/db.inc.php'; // 'db.inc.php' is included to hide username and password
  24. include 'includes/header.inc.php'; // include header
  25. include 'includes/footer.inc.php'; // include footer
  26. include 'includes/include.inc.php'; // include common functions
  27. include 'initialize/ini.inc.php'; // include common variables
  28. // --------------------------------------------------------------------
  29. // START A SESSION:
  30. // call the 'start_session()' function (from 'include.inc.php') which will also read out available session variables:
  31. start_session(true);
  32. // --------------------------------------------------------------------
  33. // Initialize preferred display language:
  34. // (note that 'locales.inc.php' has to be included *after* the call to the 'start_session()' function)
  35. include 'includes/locales.inc.php'; // include the locales
  36. // --------------------------------------------------------------------
  37. // First of all, check if this script was called by something else than 'record.php' (via 'modify.php'):
  38. // Notes: - although 'receipt.php' gets actually called by 'modify.php', the referrer will be still set to 'record.php'
  39. // - if a user clicks on Login/Logout while viewing a 'receipt.php' page she should get directed back to this receipt page (which is why 'receipt.php' must be also among the recognized referrers)
  40. if (!preg_match("/.*(record|receipt)\.php.*/", $referer)) // variable '$referer' is globally defined in function 'start_session()' in 'include.inc.php'
  41. {
  42. // return an appropriate error message:
  43. $HeaderString = returnMsg($loc["Warning_InvalidCallToScript"] . " '" . scriptURL() . "'!", "warning", "strong", "HeaderString"); // functions 'returnMsg()' and 'scriptURL()' are defined in 'include.inc.php'
  44. header("Location: " . $referer); // redirect to calling page
  45. exit; // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> !EXIT! <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  46. }
  47. // [ Extract form variables sent through POST/GET by use of the '$_REQUEST' variable ]
  48. // [ !! NOTE !!: for details see <http://www.php.net/release_4_2_1.php> & <http://www.php.net/manual/en/language.variables.predefined.php> ]
  49. // Extract the type of action requested by the user (either 'add', 'edit', 'delet' or ''):
  50. // ('' will be treated equal to 'add')
  51. $recordAction = $_REQUEST['recordAction'];
  52. if ("$recordAction" == "")
  53. $recordAction = "add"; // '' will be treated equal to 'add'
  54. // Extract the id number of the record that was added/edited/deleted by the user:
  55. $serialNo = $_REQUEST['serialNo'];
  56. // Extract the header message that was returned by 'modify.php':
  57. $HeaderString = $_REQUEST['headerMsg'];
  58. // Function 'showLogin()' in 'include.inc.php' requires the header string being available in the '$headerMsg' variable so that it gets included within the Login/Logout links:
  59. $headerMsg = $HeaderString;
  60. // Extract the view type requested by the user (either 'Mobile', 'Print', 'Web' or ''):
  61. // ('' will produce the default 'Web' output style)
  62. if (isset($_REQUEST['viewType']))
  63. $viewType = $_REQUEST['viewType'];
  64. else
  65. $viewType = "";
  66. // Get the query URL of the last multi-record query:
  67. if (isset($_SESSION['oldMultiRecordQuery']))
  68. $oldMultiRecordQuery = $_SESSION['oldMultiRecordQuery'];
  69. else
  70. $oldMultiRecordQuery = "";
  71. // --------------------------------------------------------------------
  72. // (4) DISPLAY HEADER & RESULTS
  73. // (NOTE: Since there's no need to query the database here, we won't perform any of the following: (1) OPEN CONNECTION, (2) SELECT DATABASE, (3) RUN QUERY, (5) CLOSE CONNECTION)
  74. // Show the login status:
  75. showLogin(); // (function 'showLogin()' is defined in 'include.inc.php')
  76. // (4a) DISPLAY header:
  77. // call the 'displayHTMLhead()' and 'showPageHeader()' functions (which are defined in 'header.inc.php'):
  78. displayHTMLhead(encodeHTML($officialDatabaseName) . " -- Record Action Feedback", "noindex,nofollow", "Feedback page that confirms any adding, editing or deleting of records in the " . encodeHTML($officialDatabaseName), "", false, "", $viewType, array());
  79. showPageHeader($HeaderString);
  80. // (4b) DISPLAY results:
  81. // construct the correct SQL query that will link back to the added/edited record:
  82. $sqlQuery = buildSELECTclause("Display", "1", "", true, false); // function 'buildSELECTclause()' is defined in 'include.inc.php'
  83. if (isset($_SESSION['loginEmail'])) // if a user is logged in, show user specific fields:
  84. $sqlQuery .= " FROM $tableRefs LEFT JOIN $tableUserData ON serial = record_id AND user_id = " . quote_smart($loginUserID) . " WHERE serial RLIKE " . quote_smart("^(" . $serialNo . ")$") . " ORDER BY author, year DESC, publication"; // we simply use the fixed default ORDER BY clause here
  85. else // if NO user logged in, don't display any user specific fields:
  86. $sqlQuery .= " FROM $tableRefs WHERE serial RLIKE " . quote_smart("^(" . $serialNo . ")$") . " ORDER BY author, year DESC, publication"; // we simply use the fixed default ORDER BY clause here
  87. $sqlQuery = rawurlencode($sqlQuery);
  88. // Generate a 'search.php' URL that points to the formerly displayed results page:
  89. if (!empty($oldMultiRecordQuery))
  90. $oldMultiRecordQueryURL = generateURL("search.php", "html", $oldMultiRecordQuery, true); // function 'generateURL()' is defined in 'include.inc.php'
  91. // Build a TABLE, containing one ROW and DATA tag:
  92. echo "\n<table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"10\" width=\"95%\" summary=\"This table holds links to the added/edited records as well as to the previously displayed search results page\">"
  93. . "\n<tr>"
  94. . "\n\t<td valign=\"top\">"
  95. . "\n\t\tChoose how to proceed:&nbsp;&nbsp;";
  96. if (isset($_SESSION['user_permissions']) AND preg_match("/allow_details_view/", $_SESSION['user_permissions'])) // if the 'user_permissions' session variable does contain 'allow_details_view'...
  97. {
  98. if ($recordAction != "delet")
  99. echo "\n\t\t<a href=\"search.php?sqlQuery=" . $sqlQuery . "&amp;showQuery=0&amp;showLinks=1&amp;formType=sqlSearch&amp;submit=Display\">Show " . $recordAction . "ed record</a>";
  100. if ($recordAction != "delet" && !empty($oldMultiRecordQuery))
  101. echo "\n\t\t&nbsp;&nbsp;-OR-&nbsp;&nbsp;";
  102. }
  103. if (!empty($oldMultiRecordQuery)) // only provide a link to any previous search results if '$oldMultiRecordQuery' isn't empty
  104. echo "\n\t\t<a href=\"" . $oldMultiRecordQueryURL . "\">Display previous search results</a>";
  105. if ((isset($_SESSION['user_permissions']) AND preg_match("/allow_details_view/", $_SESSION['user_permissions']) AND ($recordAction != "delet")) || !empty($oldMultiRecordQuery))
  106. echo "\n\t\t&nbsp;&nbsp;-OR-&nbsp;&nbsp;";
  107. echo "\n\t\t<a href=\"index.php\">Goto " . encodeHTML($officialDatabaseName) . " Home</a>"; // we include the link to the home page here so that "Choose how to proceed:" never stands without any link to go
  108. echo "\n\t</td>"
  109. . "\n</tr>"
  110. . "\n</table>";
  111. // --------------------------------------------------------------------
  112. // DISPLAY THE HTML FOOTER:
  113. // call the 'showPageFooter()' and 'displayHTMLfoot()' functions (which are defined in 'footer.inc.php')
  114. showPageFooter($HeaderString);
  115. displayHTMLfoot();
  116. // --------------------------------------------------------------------
  117. ?>