Page MenuHomec4science

viewModifyEDS.php.wml
No OneTemporary

File Metadata

Created
Thu, Aug 29, 17:17

viewModifyEDS.php.wml

## $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 the <i><protect><?print $modn;?></protect></i> modification text" \
navtrail_previous_links="<a class=navtrail href=<WEBURL>/admin/<lang:star: index.*.html>><MSG_ADMIN_AREA></a> &gt; <a class=navtrail href=<WEBURL>/admin/websubmit/><MSG_ADMIN_SUBMIT></a>" \
navbar_name="admin" \
navbar_select="websubmit_listmodify" \
cdspageboxlefttopadd="<protect><?displayLoginMenu('submit');?></protect>"
<?
<protect>
## $Id$
## DO NOT EDIT THIS FILE! IT WAS AUTOMATICALLY GENERATED FROM CDSware WML SOURCES.
/********************Function Declarations****************************/
function errorOKbutton()
{
/*******************************************************************
This function has the simple task of creating an "OK" button,
which when pressed, sends the browser back to the
"allModifyEDS.php" page. It will only be displayed when there has
been some sort of error ocurrence.
Author: Nicholas Robinson
Email: Nicholas.Robinson@cern.ch
ca8nro@yahoo.co.uk
Created: 19/12/2000
Last Modified: 12/01/2001
*******************************************************************/
print("<TABLE ALIGN='center' CELLSPACING=0 CELLPADDING=0 BORDER=0>"
. "\n<FORM ACTION='allModifyEDS.php' METHOD='post'>\n<TR><TD ALIGN"
. "='center'>\n<INPUT TYPE='button' VALUE='OK' onClick=\"submit();"
. "\">\n</TD>\n</TR>\n</FORM>\n</TABLE>\n");
} // END function errorOKbutton()
//************
function displayEDSmodifyDetsForm($modn)
{
/*****************************************************************
This function has the task of constructing the form that contains
the details of a given modify item that is to be viewed or
editied. It first conducts a query on the sbmMODIFY table to
retrieve the details of the modify item. If it can't, it
displays the relevant error messages. Otherwise, it displays all
of the details of the modify item in an HTML form. It also of
course displays the buttons to submit the form, or go back to
another page.
Author: Nicholas Robinson
Email: Nicholas.Robinson@cern.ch
ca8nro@yahoo.co.uk
Created: 12/01/2001
Last Modified: 16/01/2001
*****************************************************************/
# Execute a query to retrieve the details of the given modify
$qRes = mysql_query("SELECT * FROM sbmMODIFY WHERE modn = "
. "'$modn'");
if($qRes)
{
# In this case, the query worked sans probleme
if(mysql_num_rows($qRes) < 1)
{
# Oh dear, the current modify doesn't seem to exist.
print("<P CLASS=\"errorMsg\"><SPAN STYLE=\"color: red\">ERR"
. "OR:</SPAN> The $modn Modify Item Does Not Exist "
. "In " . DOCS_DATABASE . ".<BR>Inform System Administrator."
. "</P>\n");
# Display a button...
errorOKbutton();
# Now mail the admin to tell them this news.
$msgTxt = "An error has ocurred while attempting to retrieve "
. "the details of the $modn modify item from "
. DOCS_DATABASE . ". The query to select the details of this "
. "modify item returned no rows. There must have been "
. "a record for this modify item however, because the "
. "user must have clicked on a link for it to retrieve the "
. "details of it.\n\nThis suggests that there is a problem "
. "with concurrency. Perhaps another user deleted the modify"
. " item from " . DOCS_DATABASE . " just before the user who "
. "tried to view its details clicked on the link to it.\n\n"
. "WebSubmit Administrator (";
$msgTxt .= makeDate();
$msgTxt .= ")";
# Now send the mail..
mail(ADMIN_EMAIL, "ERROR: Cannot Retrieve $modn Modify "
. "Details", $msgTxt, "From: WebSubmit_Administrator");
} // END if
elseif(mysql_num_rows($qRes) > 1)
{
# Oh dear...several instances of the current modify!
print("<P CLASS=\"errorMsg\"><SPAN STYLE=\"color: red\">ERR"
. "OR:</SPAN> Several Rows Have Been Retrieved For The "
. "<EM>$modn</EM> Modify Item.<BR>Inform System "
. "Administrator.</P>\n");
errorOKbutton();
# Now mail the admin to tell them this news.
$msgTxt = "An error has ocurred while attempting to retrieve "
. "the details of the $modn modify item from "
. DOCS_DATABASE . ". The query to select the details of this "
. "modify item returned several rows. The 'modn' "
. "field of the sbmMODIFY table should be unique, as it is used "
. "as the key of the table. This means that there should "
. "only ever be 1 row in the sbmMODIFY table for a given modn "
. "value.\n\nThis means that there must be key violations in "
. "the sbmMODIFY table, and this problem should be examined and "
. "corrected immediately.\n\nWebSubmit Administrator (";
$msgTxt .= makeDate();
$msgTxt .= ")";
# Now send the mail..
mail(ADMIN_EMAIL, "ERROR: sbmMODIFY Table Key Violation",
$msgTxt, "From: WebSubmit_Administrator");
} // END elseif
else
{
# Perfect! Only one row for this modify, as expected...
# Provide a quick description of the pages function...
print("<TABLE WIDTH='90%' BGCOLOR='#D3DCE3' ALIGN='center' "
. "CELLSPACING=0 CELLPADDING=0 BORDER=1>\n<TR><TD "
. "ALIGN='center'>\n<P STYLE=\"color: blue; text-align: "
. "center; font-size: small; font-weight: bold\">Below, is a"
. " table that allows you to view or edit the details of an "
. "EDS Modify Item.<BR><BR>If you wish to "
. "edit the modify item, you can edit the details of "
. "the <EM>Modify Item Description</EM> field, and then click"
. " onn the \"SAVE CHANGES\" button.<BR>If you do not wish to"
. " make any changes to the modify item, simply click "
. " on the \"FINISHED\" button, which will return you to the "
. "page<BR>displaying a list of all modify items.</P>\n</TD>"
. "\n</TR>\n</TABLE>\n");
# Make a horizontal rule to divide the page sections...
drawSeparator();
# Get a list of the fields in the sbmMODIFY table
$columns = mysql_list_fields(DOCS_DATABASE, "sbmMODIFY");
# Get the details of the current check to display
$dataRow = mysql_fetch_array($qRes);
# Now begin making the form...
print("<TABLE WIDTH='100%' ALIGN='center' BORDER=0 "
. "CELLSPACING=0 CELLPADDING=0>\n<FORM ACTION='viewModifyEDS"
. ".php' METHOD='post'>\n<INPUT TYPE='hidden' NAME='update"
. "Modify' VALUE='true'>\n<TR>\n<TH BGCOLOR='#D3DCE3' ALIGN"
. "='right' WIDTH='20%'>Creation Date:&nbsp;</TH>\n<TD ALI"
. "GN='left' BGCOLOR='#FFFFCC' WIDTH='80%'><INPUT TYPE='"
. "readonly' NAME='cd' VALUE='". $dataRow["cd"] . "'></TD>\n"
. "</TR><TR>\n<TH BGCOLOR='#D3DCE3' ALIGN='right' WIDTH='20%'"
. ">Modification Date:&nbsp;</TH>\n<TD ALIGN='left' BGCOLOR='"
. "#FFFFCC' WIDTH='80%'><INPUT TYPE='readonly' NAME='md' "
. "VALUE='" . $dataRow["md"] . "'></TD>\n</TR>\n<TR>\n<TH BG"
. "COLOR='#D3DCE3' ALIGN='right' WIDTH='20%'>Modify Item "
. "Name:&nbsp;</TH>\n<TD ALIGN='left' WIDTH='80%' BGCOLOR='"
. "#FFFFCC'><INPUT TYPE='readonly' NAME='modn' VALUE='"
. $dataRow["modn"] . "'>\n</TD>\n</TR>\n<TR>\n<TH "
. "BGCOLOR='#87CEFA' ALIGN='right' WIDTH='20%'>Modify Item "
. "Description:&nbsp;</TH>\n<TD ALIGN='left' BGCOLOR='#FFFFC"
. "C' WIDTH='80%'><INPUT TYPE='text' SIZE=60 MALXLENGTH="
. mysql_field_len($columns, 1)
. " NAME='modd' VALUE='"
. ereg_replace("'", "&#39;",
htmlspecialchars($dataRow["modd"]))
. "'></TD>\n</TR>\n</TABLE>\n");
# Now make an other table to hold the various buttons...
print("<TABLE BORDER=0 CELLPADDING=2 CELLSPACING=2 ALIGN='"
. "center'>\n<TR>\n<TD ALIGN='right'><INPUT TYPE='button' "
. "VALUE='SAVE CHANGES' onClick=\"if(confirm('Are You Sure "
. "That You Wish To Alter This Modify Item Description"
. "?')) { submit(); }\"></TD>\n<TD ALIGN='center'><INPUT "
. "TYPE='button' "
. "VALUE='RESET' onClick=\"reset();\"></TD>\n</FORM>\n<FORM "
. "ACTION='allModifyEDS.php' METHOD='post'>\n<TD ALIGN='left"
. "'><INPUT TYPE='button' VALUE='FINISH' onClick=\"submit();"
. "\"></TD>\n</TR>\n</TABLE>\n");
} // END else
} // END if
else
{
# In this case, the query to retrieve the details of the given
# check failed, so we can simply output an error message...
print("<P CLASS=\"errorMsg\"><SPAN STYLE=\"color: red\">ERROR:"
. "</SPAN> Could not query the <EM>sbmMODIFY</EM> table of "
. DOCS_DATABASE . ".<BR>Contact System Administrator.</P>\n");
# Add a button...
errorOKbutton();
} // END else
} // END function displayEDSmodifyDetsForm()
function displayPage()
{
global $updateModify,$modd,$modn;
if($updateModify)
{
# In this case, this call to the script is a call to commit
# updated details of the given modify item to the database.
# Get the date for the md field...
$modifiedDate = makeEDSmdDate();
# Make an update string...
$updStr = "UPDATE sbmMODIFY SET md = '$modifiedDate', modd = '"
. "$modd' WHERE modn = '$modn'";
# Now execute the update...
$updRes = mysql_query($updStr);
if($updRes)
{
# The query has worked...
if(mysql_affected_rows() == 1)
{
# In this case, the check has been updated, and we can
# simply let the user know of the update, inform the admin
# of it, and redisplay the check in the form.
print("<SCRIPT TYPE='text/javascript'>\nalert('The Modify "
. "Item Has Been Updated.');\n</SCRIPT>\n");
$msgTxt = "The $modn modify item has been updated in "
. DOCS_DATABASE . ".\n\nWebSubmit Administrator (";
$msgTxt .= makeDate();
$msgTxt .= ")";
# Now send the mail..
mail(ADMIN_EMAIL, "$modn Modify Item Updated",
$msgTxt, "From: WebSubmit_Administrator");
# Now free the update query result...
mysql_free_result($updRes);
# Redisplay the form with the check in it
displayEDSmodifyDetsForm($modn);
} // END if
else
{
# The query didn't actually update anything. Hmm.
print("<SCRIPT TYPE='text/javascript'>alert('The Modify "
. "Item Was Not Updated. It Is Possible That The Modify"
. " Item Description Was Not Changed.');\n</SCRIPT>\n");
print("<P STYLE=\"color: red; font-size: medium; font-we"
. "ight: bold; text-align: center\">\nModify Item Not "
. "Updated. Ensure Details Are Changed Before Submitting"
. ".</P>\n");
displayEDSmodifyDetsForm($modn);
} // END else
} // END if
else
{
# In this case, the update has failed, so we can just inform
# the user of this, and redisplay the details of the modify in
# the form (pre update - perhaps the user wrote weird stuff,
# or too much).
print("<SCRIPT TYPE='text/javascript'>\nalert('ERROR: It was "
. "not possible to update this modify item. The current sav"
. "ed version of it has been redisplayed.\\nIt is possible "
. "that the values entered for the modify item were in some "
. "way invalid.\\n\\nPlease inform the system administrator "
. "if you think there is a problem.');\n</SCRIPT>\n");
print("<P STYLE=\"color: red; font-size: medium; font-weight:"
. " bold; text-align: center\">\nModify Item Not Updated. "
. "Perhaps Entered Description Was Invalid.</P>\n");
# Now redisplay the check details in the form...
displayEDSmodifyDetsForm($modn);
} // END else
} // END if
else
{
# In this case, this is the first call to the script, and we must
# simply display the details of the given modify item in a form,
# ready for viewing or updating as appropriate.
# Display the interface...
displayEDSmodifyDetsForm($modn);
} // 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))
outWarning("You are not allowed to access WebSubmit Admin for this "
. "type of documents");
else
displayPage();
/************************End of main script***************************/
</protect>
?>

Event Timeline