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.

158 lines
8.2 KiB

  1. <?php
  2. // turn on warnings and notice during developement
  3. include('initialize/PhpErrorSettings.inc.php');
  4. // Project: Web Reference Database (refbase) <http://www.refbase.net>
  5. // Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's
  6. // original author(s).
  7. //
  8. // This code is distributed in the hope that it will be useful,
  9. // but WITHOUT ANY WARRANTY. Please see the GNU General Public
  10. // License for more details.
  11. //
  12. // File: ./receipt.php
  13. // Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/receipt.php $
  14. // Author(s): Matthias Steffens <mailto:refbase@extracts.de>
  15. //
  16. // Created: 02-Jan-03, 22:43
  17. // Modified: $Date: 2012-02-27 20:25:30 +0000 (Mon, 27 Feb 2012) $
  18. // $Author: msteffens $
  19. // $Revision: 1337 $
  20. // This php script will display a feedback page after any action of
  21. // adding/editing/deleting a record. It will display links to the
  22. // modified/added record as well as to the previous search results page (if any)
  23. // TODO: I18n
  24. // Incorporate some include files:
  25. include 'initialize/db.inc.php'; // 'db.inc.php' is included to hide username and password
  26. include 'includes/header.inc.php'; // include header
  27. include 'includes/footer.inc.php'; // include footer
  28. include 'includes/include.inc.php'; // include common functions
  29. include 'initialize/ini.inc.php'; // include common variables
  30. // --------------------------------------------------------------------
  31. // START A SESSION:
  32. // call the 'start_session()' function (from 'include.inc.php') which will also read out available session variables:
  33. start_session(true);
  34. // --------------------------------------------------------------------
  35. // Initialize preferred display language:
  36. // (note that 'locales.inc.php' has to be included *after* the call to the 'start_session()' function)
  37. include 'includes/locales.inc.php'; // include the locales
  38. // --------------------------------------------------------------------
  39. // First of all, check if this script was called by something else than 'record.php' (via 'modify.php'):
  40. // Notes: - although 'receipt.php' gets actually called by 'modify.php', the referrer will be still set to 'record.php'
  41. // - 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)
  42. if (!preg_match("/.*(record|receipt)\.php.*/", $referer)) // variable '$referer' is globally defined in function 'start_session()' in 'include.inc.php'
  43. {
  44. // return an appropriate error message:
  45. $HeaderString = returnMsg($loc["Warning_InvalidCallToScript"] . " '" . scriptURL() . "'!", "warning", "strong", "HeaderString"); // functions 'returnMsg()' and 'scriptURL()' are defined in 'include.inc.php'
  46. header("Location: " . $referer); // redirect to calling page
  47. exit; // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> !EXIT! <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  48. }
  49. // [ Extract form variables sent through POST/GET by use of the '$_REQUEST' variable ]
  50. // [ !! NOTE !!: for details see <http://www.php.net/release_4_2_1.php> & <http://www.php.net/manual/en/language.variables.predefined.php> ]
  51. // Extract the type of action requested by the user (either 'add', 'edit', 'delet' or ''):
  52. // ('' will be treated equal to 'add')
  53. $recordAction = $_REQUEST['recordAction'];
  54. if ("$recordAction" == "")
  55. $recordAction = "add"; // '' will be treated equal to 'add'
  56. // Extract the id number of the record that was added/edited/deleted by the user:
  57. $serialNo = $_REQUEST['serialNo'];
  58. // Extract the header message that was returned by 'modify.php':
  59. $HeaderString = $_REQUEST['headerMsg'];
  60. // 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:
  61. $headerMsg = $HeaderString;
  62. // Extract the view type requested by the user (either 'Mobile', 'Print', 'Web' or ''):
  63. // ('' will produce the default 'Web' output style)
  64. if (isset($_REQUEST['viewType']))
  65. $viewType = $_REQUEST['viewType'];
  66. else
  67. $viewType = "";
  68. // Get the query URL of the last multi-record query:
  69. if (isset($_SESSION['oldMultiRecordQuery']))
  70. $oldMultiRecordQuery = $_SESSION['oldMultiRecordQuery'];
  71. else
  72. $oldMultiRecordQuery = "";
  73. // --------------------------------------------------------------------
  74. // (4) DISPLAY HEADER & RESULTS
  75. // (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)
  76. // Show the login status:
  77. showLogin(); // (function 'showLogin()' is defined in 'include.inc.php')
  78. // (4a) DISPLAY header:
  79. // call the 'displayHTMLhead()' and 'showPageHeader()' functions (which are defined in 'header.inc.php'):
  80. 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());
  81. showPageHeader($HeaderString);
  82. // (4b) DISPLAY results:
  83. // construct the correct SQL query that will link back to the added/edited record:
  84. $sqlQuery = buildSELECTclause("Display", "1", "", true, false); // function 'buildSELECTclause()' is defined in 'include.inc.php'
  85. if (isset($_SESSION['loginEmail'])) // if a user is logged in, show user specific fields:
  86. $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
  87. else // if NO user logged in, don't display any user specific fields:
  88. $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
  89. $sqlQuery = rawurlencode($sqlQuery);
  90. // Generate a 'search.php' URL that points to the formerly displayed results page:
  91. if (!empty($oldMultiRecordQuery))
  92. $oldMultiRecordQueryURL = generateURL("search.php", "html", $oldMultiRecordQuery, true); // function 'generateURL()' is defined in 'include.inc.php'
  93. // Build a TABLE, containing one ROW and DATA tag:
  94. 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\">"
  95. . "\n<tr>"
  96. . "\n\t<td valign=\"top\">"
  97. . "\n\t\tChoose how to proceed:&nbsp;&nbsp;";
  98. 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'...
  99. {
  100. if ($recordAction != "delet")
  101. 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>";
  102. if ($recordAction != "delet" && !empty($oldMultiRecordQuery))
  103. echo "\n\t\t&nbsp;&nbsp;-OR-&nbsp;&nbsp;";
  104. }
  105. if (!empty($oldMultiRecordQuery)) // only provide a link to any previous search results if '$oldMultiRecordQuery' isn't empty
  106. echo "\n\t\t<a href=\"" . $oldMultiRecordQueryURL . "\">Display previous search results</a>";
  107. if ((isset($_SESSION['user_permissions']) AND preg_match("/allow_details_view/", $_SESSION['user_permissions']) AND ($recordAction != "delet")) || !empty($oldMultiRecordQuery))
  108. echo "\n\t\t&nbsp;&nbsp;-OR-&nbsp;&nbsp;";
  109. 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
  110. echo "\n\t</td>"
  111. . "\n</tr>"
  112. . "\n</table>";
  113. // --------------------------------------------------------------------
  114. // DISPLAY THE HTML FOOTER:
  115. // call the 'showPageFooter()' and 'displayHTMLfoot()' functions (which are defined in 'footer.inc.php')
  116. showPageFooter($HeaderString);
  117. displayHTMLfoot();
  118. // --------------------------------------------------------------------
  119. ?>