// Copyright: Matthias Steffens and the file's // original author(s). // // This code is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY. Please see the GNU General Public // License for more details. // // File: ./duplicate_manager.php // Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/duplicate_manager.php $ // Author(s): Matthias Steffens // // Created: 27-Jan-07, 21:18 // Modified: $Date: 2015-02-16 20:53:19 +0000 (Mon, 16 Feb 2015) $ // $Author: karnesky $ // $Revision: 1405 $ // This script enables you to manually manage duplicate records by entering their database serial numbers // into the provided form. The form lets you flag (i.e. identify) an "original" record and its related // duplicate entries. The script will then update the 'orig_record' field in table 'refs' accordingly. // TODO: I18n // Incorporate some include files: include 'initialize/db.inc.php'; // 'db.inc.php' is included to hide username and password include 'includes/header.inc.php'; // include header include 'includes/footer.inc.php'; // include footer include 'includes/include.inc.php'; // include common functions include 'initialize/ini.inc.php'; // include common variables // -------------------------------------------------------------------- // START A SESSION: // call the 'start_session()' function (from 'include.inc.php') which will also read out available session variables: start_session(true); // -------------------------------------------------------------------- // Initialize preferred display language: // (note that 'locales.inc.php' has to be included *after* the call to the 'start_session()' function) include 'includes/locales.inc.php'; // include the locales // -------------------------------------------------------------------- // Extract session variables (only necessary if register globals is OFF!): if (isset($_SESSION['errors'])) $errors = $_SESSION['errors']; else $errors = array(); // initialize variable (in order to prevent 'Undefined index/variable...' messages) if (isset($_SESSION['formVars'])) $formVars = $_SESSION['formVars']; else $formVars = array(); // initialize variable (in order to prevent 'Undefined index/variable...' messages) // The current values of the session variables 'errors' and 'formVars' get stored in '$errors' or '$formVars', respectively. (either automatically if // register globals is ON, or explicitly if register globals is OFF [by uncommenting the code above]). // We need to clear these session variables here, since they would otherwise be still there on a subsequent call of 'duplicate_manager.php'! // Note: though we clear the session variables, the current error message (or form variables) is still available to this script via '$errors' (or '$formVars', respectively). deleteSessionVariable("errors"); // function 'deleteSessionVariable()' is defined in 'include.inc.php' deleteSessionVariable("formVars"); // -------------------------------------------------------------------- // TODO: enable checking for 'allow_flag_duplicates' permission // CAUTION: Since there's not a 'allow_flag_duplicates' permission setting (yet), we currently just check whether a user is logged in! if (!isset($_SESSION['loginEmail'])) // if a user isn't logged in... // In order to flag any records as duplicates, a user must be logged in AND must be allowed to flag duplicates in the database: // if (!(isset($_SESSION['loginEmail']) AND (isset($_SESSION['user_permissions']) AND preg_match("/allow_flag_duplicates/", $_SESSION['user_permissions'])))) // if a user isn't logged in OR if the 'user_permissions' session variable does NOT contain 'allow_flag_duplicates'... { // return an appropriate error message: $HeaderString = returnMsg($loc["NoPermission"] . $loc["NoPermission_ForFlagDups"] . "!", "warning", "strong", "HeaderString"); // function 'returnMsg()' is defined in 'include.inc.php' // save the URL of the currently displayed page: $referer = $_SERVER['HTTP_REFERER']; // Write back session variables: saveSessionVariable("referer", $referer); // function 'saveSessionVariable()' is defined in 'include.inc.php' header("Location: index.php"); exit; // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> !EXIT! <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< } // -------------------------------------------------------------------- // Extract the view type requested by the user (either 'Mobile', 'Print', 'Web' or ''): // ('' will produce the default 'Web' output style) if (isset($_REQUEST['viewType'])) $viewType = $_REQUEST['viewType']; else $viewType = ""; // Setup some required variables: // If there's no stored message available: if (!isset($_SESSION['HeaderString'])) { if (empty($errors)) // provide one of the default messages: { $errors = array(); // re-assign an empty array (in order to prevent 'Undefined variable "errors"...' messages when calling the 'fieldError' function later on) $HeaderString = "Flag records as original or duplicate entries:"; // Provide the default message } else // -> there were errors validating the data entered by the user $HeaderString = "There were validation errors regarding the data you entered:"; } else { $HeaderString = $_SESSION['HeaderString']; // extract 'HeaderString' session variable (only necessary if register globals is OFF!) // Note: though we clear the session variable, the current message is still available to this script via '$HeaderString': deleteSessionVariable("HeaderString"); // function 'deleteSessionVariable()' is defined in 'include.inc.php' } // -------------------------------------------------------------------- // Assign correct values to the form variables: if (!empty($errors)) // if there were some errors on submit { // load the form data that were entered by the user: $origRecord = $formVars['origRecord']; $dupRecords = $formVars['dupRecords']; } else { $origRecord = ""; $dupRecords = ""; } // -------------------------------------------------------------------- // Show the login status: showLogin(); // (function 'showLogin()' is defined in 'include.inc.php') // (2a) Display header: // call the 'displayHTMLhead()' and 'showPageHeader()' functions (which are defined in 'header.inc.php'): displayHTMLhead(encodeHTML($officialDatabaseName) . " -- " . "Manage Duplicates", "index,follow", "Manage duplicate records in the " . encodeHTML($officialDatabaseName), "", false, "", $viewType, array()); showPageHeader($HeaderString); // (2b) Start
and holding the form elements: // note: we provide a default value for the 'submit' form tag so that hitting within a text entry field will act as if the user clicked the 'Flag Duplicates' button ?>
:
:
 
')" title=""> <?php echo $loc[" width="9" height="9" hspace="0" border="0">
" . $errors[$fieldName] . "
"; } // -------------------------------------------------------------------- // DISPLAY THE HTML FOOTER: // call the 'showPageFooter()' and 'displayHTMLfoot()' functions (which are defined in 'footer.inc.php') showPageFooter($HeaderString); displayHTMLfoot(); // -------------------------------------------------------------------- ?>