Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F78659731
editDoctypeEDS.php.wml
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Aug 22, 06:07
Size
22 KB
Mime Type
text/x-c
Expires
Sat, Aug 24, 06:07 (2 d)
Engine
blob
Format
Raw Data
Handle
20061902
Attached To
R3600 invenio-infoscience
editDoctypeEDS.php.wml
View Options
## $Id$
## This file is part of the CERN Document Server Software (CDSware).
## Copyright (C) 2002 CERN.
##
## The CDSware is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation; either version 2 of the
## License, or (at your option) any later version.
##
## The CDSware is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with CDSware; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
<?
require("commonPhpFunctions.php");
?>
#include "cdspage.wml" \
title="Edit details of the <i><protect><?print $doctype;?></protect></i> type of document" \
navtrail_previous_links="<a class=navtrail href=<WEBURL>/admin/<lang:star: index.*.html>><MSG_ADMIN_AREA></a> > <a class=navtrail href=<WEBURL>/admin/websubmit/><MSG_ADMIN_SUBMIT></a>" \
navbar_name="admin" \
navbar_select="websubmit"
<?
<protect>
## $Id$
## DO NOT EDIT THIS FILE! IT WAS AUTOMATICALLY GENERATED FROM CDSware WML SOURCES.
</protect>
?>
<SCRIPT TYPE='text/javascript'>
<!-- hide
function checkRequired(param)
// This is a function to ensure that the user enters the required
// parameter for the action.
// Author: Nicholas Robinson
// Email: Nicholas.Robinson@cern.ch
// ca8nro@yahoo.co.uk
// Created: Long ago!
// Last Modified: 16/11/2000
{
// If the field is left blank by the user...
if(param == "")
{ // Alert them, and return false.
alert("You must enter a value in the Long Document Name field.");
return false;
} // End if
else // If level has been filled by the user...
{
return true;
} // End else
} // End function checkRequired(param)
function verifyChanges(curLdocname, sugLdocname, curDocfi1, sugDocfi1)
// Function to test whether the values for the parameters to be changed
// have actually been changed by the user when they submit them to the
// database for update. If not, the function returns false. If so, the
// function returns true.
// Author: Nicholas Robinson
// Email: Nicholas.Robinson@cern.ch
// Created: 27/07/2000
// Last Modified: 16/11/2000
{
if( (curLdocname == sugLdocname) &&
(curDocfi1 == sugDocfi1))
{
alert("No Change In The Data Has Been Made! Cannot Submit.");
return false;
} // End if
else
{
return true;
} // End else
} // End function verifyChanges()
// -->
</SCRIPT>
<?php
/*********************Function Descriptions***************************/
<protect>
function makeEDSdoctypeButtons($dataRow)
{
/**************************************************************
This function has the simple task of creating and displaying the
"SAVE CHANGES" button, the "RESET" button and the "FINISHED"
button for the edit doctype form. It is bundled into a function,
as it is quite a messy piece of code due to the large parameters
to the JavaScript function "verifyChanges".
Author: Nicholas Robinson
Email: Nicholas.Robinson@cern.ch
ca8nro@yahoo.co.uk
Created: 16/11/2000
Last Modified: 10/01/2001
**************************************************************/
print("<P>\n");
print("<TABLE ALIGN='center' BORDER=0 CELLSPACING=0 "
. "CELLPADDING=0>\n<TR>\n<TD ALIGN='right'>"
. "\n<INPUT TYPE='button' VALUE='SAVE CHANGES' onClick=\""
. "if(verifyChanges(escape('" . ereg_replace("'","\\'",
htmlspecialchars($dataRow["ldocname"]))
. "'), escape(ldocname.value), escape('"
. ereg_replace("[\n\r]+","\\n",ereg_replace("'","\\'",
htmlspecialchars($dataRow["description"])))
. "'), escape(description.value))) { if(checkRequired("
. "ldocname.value)) { if(confirm('Are You Sure You Wish To Alter "
. "These Details?')) { submit(); } } }\">\n</TD>\n<TD ALIGN='"
. "center'><INPUT TYPE='button' VALUE='RESET' onClick=\"reset();"
. "\">\n</TD>\n</FORM>\n<FORM ACTION='documentEDS.php' METHOD='"
. "post'>\n<INPUT TYPE='hidden' NAME='doctype' VALUE='"
. $dataRow["sdocname"] . "'>\n<TD ALIGN='left'>\n<INPUT TYPE='"
. "button' VALUE='FINISHED' onClick=\"submit();\">\n</TD>\n</FORM>"
. "\n</TR>\n</TABLE>\n</P>\n");
} // END function makeEDSdoctypeButtons($dataRow)
//*************
function displayEDSdoctypeForm($doctype)
{
/*******************************************************************
This function has the task of creating the main form in which the
details of the given document type are displayed. each data item
of the doctype appears in an input box, so that the user can
modify its value, and then save the changes that they have made.
The fields that should not ever be modified by the user (such as
the modification date, etc) are displayed in readonly text fields
so that the user can not tamper with them.
Author: Nicholas Robinson
Email: Nicholas.Robinson@cern.ch
ca8nro@yahoo.co.uk
Created: 16/11/2000
Last Modified: 10/01/2001
*******************************************************************/
# Execute a query on the sbmsbmDOCTYPE table for the given action...
$queryResult = mysql_query("SELECT * from sbmDOCTYPE WHERE sdocname = "
. "'$doctype'");
if($queryResult)
{
# The query has executed successfully, so we can continue with
# the production of the page...
# Produce the appropriate output, depending upon the number of
# rows returned by the query...
if(mysql_num_rows($queryResult) == 1)
{
# In this case, as expected, there is one entry for the given
# doctype in the sbmDOCTYPE table..
# Now, display a quick set of page instructions for the user..
print("<TABLE WIDTH='90%' BGCOLOR='#D3DCE3' ALIGN='center' "
. "CELLSPACING=0 CELLPADDING=0 BORDER=1><TR><TD "
. "ALIGN='center'><P STYLE=\"color: blue; text-align: "
. "center; font-size: small; font-weight: bold\">Below are "
. "the details of the <EM>$doctype</EM> document type.<BR>You"
. "can edit them by alterring values in boxes, and clicking "
. "on \"SAVE CHANGES\".</P></TD></TR></TABLE>");
# Make a horizontal rule to divide the page sections...
drawSeparator();
# Now, we are ready to display the details of the given
# doctype in a table. Each data item will be contained within
# a form input box so that it can be edited if this is
# desirable.
print("<FORM ACTION='editDoctypeEDS.php' METHOD='post'>"
. "<INPUT TYPE='hidden' NAME='update' VALUE='true'>"
. "<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0 ALIGN='center"
. "' WIDTH='100%'>");
# Now make the table: names & fields...
# Get the columns list
$columns = mysql_list_fields(DOCS_DATABASE, "sbmDOCTYPE");
# Get the number of fields
$numTblFlds = mysql_num_fields($columns);
# Get the row of data
$dataRow = mysql_fetch_array($queryResult);
# Before we display most of the table, we can first display
# the upper part of the table, which will be the sactname, cd,
# and md fields, that can't be modified...
print("<TABLE WIDTH='100%' ALIGN='center' CELLSPACING=0 "
. "CELLPADDING=0 BORDER=0><TR><TH BGCOLOR='#D3DCE3' ALIGN"
. "='right' WIDTH='20%'>Document Type ID: </TH><TD "
. "ALIGN='left' BGCOLOR='#FFFFCC' WIDTH='80%'><INPUT "
. "TYPE='readonly' NAME='sdocname' VALUE='"
. $dataRow["sdocname"] . "'></TD></TR><TR><TH "
. "BGCOLOR='#D3DCE3' ALIGN='right' WIDTH='20%'>Creation "
. "Date: </TH><TD WIDTH='80%' ALIGN='left' BGCOLOR="
. "'#FFFFCC'><INPUT TYPE='readonly' NAME='cd' VALUE='"
. $dataRow["cd"] . "'></TD></TR><TR><TH WIDTH='20%'"
. " BGCOLOR='#D3DCE3' ALIGN='right'>Modification "
. "Date: </TH><TD WIDTH='80%' ALIGN='left' "
. "BGCOLOR='#FFFFCC'><INPUT TYPE='readonly' NAME='md' "
. "VALUE='" . $dataRow["md"] . "'></TD></TR>");
# Now fill this new table with all of the details...
for($indx = 0; $indx < $numTblFlds; $indx++)
{
# Get the name of the current field...
$currentField = mysql_field_name($columns, $indx);
# Ensure that we don't once again print our non-editable
# fields out...
if(($currentField != "sdocname") && ($currentField != "cd")
&& ($currentField != "md"))
{
# First, display the field name...
print("<TR><TH BGCOLOR='#87CEFA' ALIGN='right' "
. "WIDTH='20%'>");
if($currentField == "ldocname")
{
print("Document Type Description: ");
} // END if
else
{
print("$currentField" . ": ");
} // END else
if ($currentField == "description")
{
print (" </TH><TD ALIGN='left' WIDTH='80%' "
. "BGCOLOR='#FFFFCC'><TEXTAREA COLS=60 ROWS=5 WRAP NAME='description'>"
. ereg_replace("'", "'",
htmlspecialchars($dataRow[$indx]))
. "</TEXTAREA></TD></TR>");
} //END if
else
{
print(" </TH><TD ALIGN='left' WIDTH='80%' "
. "BGCOLOR='#FFFFCC'><INPUT TYPE='text' NAME="
. "'$currentField' SIZE=");
if(mysql_field_type($columns, $indx) == "blob")
{
# This is a text field (lots of characters allowed -
# too many for HTML form in browser to display), so
# just give it a visible length of 60 characters.
print("60");
} // END if
else
{
print(mysql_field_len($columns, $indx));
} // END else
print(" VALUE='" . ereg_replace("'", "'",
htmlspecialchars($dataRow[$indx]))
. "'></TD></TR>");
} // END else
} // END if
} // END for
# Now that the table has been filled with all of the actions
# details, it can be closed..
print("</TABLE>");
# Now that the form has been drawn, it is possible to produce
# a new table underneath, containing buttons. There will be a
# "SAVE" button, and a "FINISHED button.
makeEDSdoctypeButtons($dataRow);
} // END if
elseif(mysql_num_rows($queryResult) > 1)
{
# In this case, there are many rows for the given doctype in
# the sbmDOCTYPE table, which means that the sbmDOCTYPE table has
# primary key violations..
print("<P CLASS='errorMsg'><SPAN STYLE=\"color: red\">"
. "ERROR:</SPAN> More "
. "than one row of data concerning the <EM>$doctype</EM> "
. "document type was returned from the <EM>sbmDOCTYPE</EM> table"
. "of the" . DOCS_DATABASE . " database.<BR>This indicates "
. "primary key duplication in this table.<BR>Please inform "
. "system administrator.</P>");
# Send a mail to the system admin people to warn them about
# this serious error..
# Get the current date and time...
$dateDets = getdate();
$msgTxt = "When the editDoctypeEDS.php attempted to retrieve"
. "the details of the $doctype document type, several "
. "rows were returned for this document type from the sbmDOCTYPE"
. " table. The query was made using the \"sdocname\" field "
. "as the search key. As the \"sdocname\" field is the "
. "primary key for the sbmDOCTYPE table, this means that there "
. "must be key violations in this table.This problem "
. "should be corrected immediately.WebSubmit Administrator (";
$msgTxt .= makeDate();
$msgTxt .= ")";
# Now send the mail..
mail(ADMIN_EMAIL, "sbmDOCTYPE Table Key Violation!", $msgTxt,
"From: WebSubmit_Administrator");
} // END elseif
elseif(mysql_num_rows($queryResult) == 0)
{
# This means that the given doctype has no row in the sbmDOCTYPE
# table..Signifies a database inconsistency error.
print("<P CLASS='errorMsg'><SPAN STYLE=\"color: red\">"
. "ERROR:</SPAN> No data"
. " concerning the <EM>$doctype</EM> doctype was found in the"
. " <EM>sbmDOCTYPE</EM> table.<BR>This suggests a data "
. "consistency error in the " . DOCS_DATABASE . " database."
. "<BR>Please inform the system administrator.</P>");
# Now send an email to the administrator(s) to inform them of
# this serious error...
$msgTxt = "When the editDoctypeEDS.php script attempted to "
. "retrieve the details of the $doctype document type, no "
. "rows were returned from the sbmDOCTYPE table for this "
. "document type.Because the user had to click a link to"
. " get to this page fpr the given doctype, the details of "
. "this doctype, must be referred to in other tables of EDS."
. " This suggests that there are either data inconsistencies"
. " or concurrency problems within EDS.This should be "
. "investigated and corrected ASAP.WebSubmit Administrator (";
$msgTxt .= makeDate();
$msgTxt .= ")";
# Now send the mail..
mail(ADMIN_EMAIL, "$doctype Possible Data Inconsistency "
. "Error!", $msgTxt, "From: WebSubmit_Administrator");
} // END elseif
else
{
# Some other sort of error has ocurred, so present the error
# message on the screen.
print("<P CLASS='errorMsg'><SPAN STYLE=\"color: red\">"
. "ERROR:</SPAN> Unable"
. " to correctly retrieve data from the <EM>sbmDOCTYPE</EM> "
. "table of " . DOCS_DATABASE . ".<BR>Please inform system "
. "administrator.</P>");
} // END else
} // END if
else
{
# Unfortunately, the query has failed, so we can display an error
# message.
print("<P CLASS='errorMsg'><SPAN STYLE=\"color: red\">"
. "ERROR:</SPAN> Unable to conduct a query on the "
. "<EM>sbmDOCTYPE</EM> table of " . DOCS_DATABASE . ".<BR>Please"
. " inform system administrator.</P>");
} // END else
} // END function displayEDSdoctypeForm($doctype)
function displayEditPage($update,$doctype)
{
global $ldocname,$description,$sdocname;
# Conduct a test to see if this is the first call to this script, or
# if it is a self-referential call, whereby the user has chosen to
# update values of the given action...
if($update)
{
# In this case, this is a call to update the doctypes details...
# Free memory space associated with $update...
unset($update);
# Get the date, so that it can be committed for the modification
# date field (md)...
$modifiedDate = makeEDSmdDate();
# Begin constructing the UPDATE query string...
$queryString = "UPDATE sbmDOCTYPE SET ldocname = '$ldocname', description = "
. "'$description', md = '$modifiedDate' WHERE "
. "sdocname = '$sdocname'";
# Now actually execute the update query
$updateResult = mysql_query($queryString);
if($updateResult)
{
# If the query could actually be executed without error
if(mysql_affected_rows() == 1)
{
# In this case, only 1 rows was updated, which is as
# expected
# Display a nice message informing the user that the update
# has been carried out...
print("<P STYLE=\"color: green; text-align: center; font-"
. "style: bold; font-size: large\">Document Type "
. "Modification Complete</P>");
# Send the administrator a message to inform them of the
# update that has taken place...
$msgTxt = "An update has been carried out on the $sdocname"
. " document type in the " . DOCS_DATABASE
. " database.WebSubmit Administrator (";
$msgTxt .= makeDate();
$msgTxt .= ")";
# Now send the mail..
mail(ADMIN_EMAIL, "EDS Doctype Updated", $msgTxt,
"From: WebSubmit_Administrator");
# We can now redirect the browser to the the page showing
# the details of this document type...
print("<FORM ACTION='documentEDS.php' METHOD='post' "
. "NAME='referForm'>"
. "<INPUT TYPE='hidden' NAME='doctype' VALUE='$sdocname'"
. "></FORM>");
print("<SCRIPT LANGUAGE=\"JavaScript\">"
. "setTimeout(\"document.referForm.submit();\", 0);"
. "</SCRIPT>");
} // END if
elseif(mysql_affected_rows() > 1)
{
# More than 1 row was updated -> bad news: key duplication
# Display an error message about this...
print("<P CLASS='errorMsg'><SPAN STYLE=\"color: red\">"
. "ERROR:</SPAN> Multiple rows have been updated in the "
. "<EM>sbmDOCTYPE</EM> table.<BR>This has resulted from an "
. "attempt to update the <EM>$sdocname</EM> document type."
. "<BR>Please inform the system administrator.</P>");
# Now, email the administrator to let them know this, as it
# is a potentially dangerous error.
$msgTxt = "When a user updated the details of "
. "the $sdocname document type using the EDS Administrat"
. "or, several rows were affected in the sbmDOCTYPE table. "
. " The update was conducted using the \"sdocname\" field "
. "as the key. As the \"sdocname\" field is the primary "
. "key for the sbmDOCTYPE table, this means that there must "
. "be key violations in this table. There should only "
. "have been 1 row affected by this update.This "
. "problem should be investigated and corrected immediate"
. "ly.WebSubmit Administrator (";
$msgTxt .= makeDate();
$msgTxt .= ")";
# Now send the mail..
mail(ADMIN_EMAIL, "ERROR: sbmDOCTYPE Table Multiple Row"
. " Update!", $msgTxt, "From: WebSubmit_Administrator");
} // END elseif
else
{
# No rows were updated -> Something strange here!
# Display an error message about this...
print("<P CLASS='errorMsg'><SPAN STYLE=\"color: red\">"
. "ERROR:</SPAN> No rows have been updated in the <EM>"
. "sbmDOCTYPE</EM> table.<BR>This suggests that there could "
. "be data inconsistencies or concurrency problems.<BR>"
. "Please inform the system administrator.</P>");
# Better email the administrator & let them know...
$msgTxt = "When a user attempted to update the details of "
. "the $sdocname document type using the WebSubmit Administrator"
. ", no rows were affected in the sbmDOCTYPE table by this "
. "update.Because the user must have altered a documen"
. "t types details to submit an update on it, it must have"
. " been present at around the time that the user submitte"
. "d their update.This suggests the possibility of "
. "concurrency or data inconsistency problems in this "
. "table.This should be investigated and corrected "
. "ASAP.WebSubmit Administrator (";
$msgTxt .= makeDate();
$msgTxt .= ")";
# Now send the mail..
mail(ADMIN_EMAIL, "Error: Possible Concurrency Problems",
$msgTxt, "From: WebSubmit_Administrator");
} // END else
} // END if
else
{
# Display an error message about this...
print("<P CLASS='errorMsg'><SPAN STYLE=\"color: red\">"
. "ERROR:</SPAN> No rows have been updated in the <EM>sbmDOCTYPE"
. "</EM> table.<BR>This suggests that there could be data "
. "inconsistencies or concurrency problems.<BR>Please inform"
. " the system administrator.</P>");
} // END else
} // END if
else
{
# In this case, this is the first call to the page, so we can
# basically just display the details of the given doctype in a
# form...
displayEDSdoctypeForm($doctype);
} // END else
}
/**********************Start of main script***************************/
# Connect to the MySQL server
serverConnect(MYSQLDOCMACHINE, MYSQLDOCUSERID, MYSQLDOCPASSWORD);
# Select the CDS Search database...
dbSelect(DOCS_DATABASE);
if (!canUseWebSubmitAdmin($uid,$doctype))
outWarning("You are not allowed to access WebSubmit Admin for this "
. "type of documents");
else
displayEditPage($update,$doctype);
/************************End of main script***************************/
</protect>
?>
Event Timeline
Log In to Comment