Page MenuHomec4science

addModifyEDS.php.wml
No OneTemporary

File Metadata

Created
Tue, Jul 30, 00:38

addModifyEDS.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="Add a 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 makeModifyInputFormEDS($modd = "", $modn = "")
{
/*******************************************************************
This function has the task of displaying a form for the inputting
of a new modify. The function is passed 3 variables. These are
the $link variable, the $modd variable (which is the
description of the modify and the modn variable (which is the
unique name of the modify. The modd and modn variables can be
defaulted to nothing when they are left out. This is because
depending upon certain error conditions when we attempt to add a
modify, we may want to refuse committment of the modify, and
redisplay the form with its details for certain parts to be
changed.
Author: Nicholas Robinson
Email: Nicholas.Robinson@cern.ch
ca8nro@yahoo.co.uk
Created: 14/01/2001
Last Modified: 14/01/2001
*******************************************************************/
# 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"
. " form that allows you to add a new modify item to EDS."
. "<BR><BR>It is important that when you create new EDS "
. "modify items, you do not give them a name that is already "
. "in use, as the modify item name must<BR>be unique due to "
. "the fact that it is used to identify a given modify item "
. "when the EDS system attempts to use it.<BR><BR>When the "
. "modify item has been entered into the form provided, "
. "click on the \"SAVE DETAILS\" button<BR>to commit this new"
. " modify item to EDS.</P>\n</TD>\n</TR>\n</TABLE>\n");
# Make a horizontal rule to divide the page sections...
drawSeparator();
# Get the current date...
$modifiedDate = makeEDSmdDate();
# Get a list of the fields in the sbmMODIFY table
$columns = mysql_list_fields(DOCS_DATABASE, "sbmMODIFY");
# Now begin making the form...
print("<TABLE WIDTH='100%' ALIGN='center' BORDER=0 CELLSPACING=0 "
. "CELLPADDING=0>\n<FORM ACTION='addModifyEDS.php' METHOD='post'>\n"
. "<INPUT TYPE='hidden' NAME='addIt' VALUE='true'>\n"
. "<INPUT TYPE='hidden' NAME='cd' VALUE='$modifiedDate'>\n"
. "<INPUT TYPE='hidden' NAME='md' VALUE='$modifiedDate'>"
. "<TR>\n<TH BGCOLOR='#87CEFA' ALIGN='right' WIDTH="
. "'20%'>Modify Item Name:&nbsp;</TH>\n<TD ALIGN='left' WIDTH='80%'"
. " BGCOLOR='#FFFFCC'><INPUT TYPE='text' NAME='modn' SIZE="
. mysql_field_len($columns, 0) . " VALUE='$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='#FFFFCC' "
. "WIDTH='80%'><INPUT TYPE='text' NAME='modd' SIZE=60 "
. " VALUE='$modd'>\n</TD>\n</TR>\n"
. "</TABLE>\n");
# Now make a table to contain a set of buttons for the submission of
# the form, resetting of the form, and cancelling of a modify
# addition (this will send the browser back to "allModifyEDS.php").
print("<TABLE BORDER=0 CELLPADDING=2 CELLSPACING=2 ALIGN='center'>"
. "\n<TR>\n<TD ALIGN='right'><INPUT TYPE='button' VALUE='SAVE DETAI"
. "LS' onClick=\"if(modn.value != '') { submit(); } else { alert("
. "'The \'Modify Item Name\' Field Is Mandatory'); }\"></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='"
. "CANCEL' onClick=\"submit();\"></TD>\n</TR>\n</TABLE>\n");
} // END function makeModifyInputFormEDS()
function displayPage()
{
global $addIt,$modn,$modd;
if($addIt)
{
# In this case, the user has filled in the form to add a new
# modify, and has submitted it...
# The first thing to do is to run a quick query to ensure that
# there is not already a modify with the same name as that that
# we have just entered...(do this as long as the modn field is
# not blank)
if($modn != "")
{
$quickRes = mysql_query("SELECT modn FROM sbmMODIFY WHERE modn ="
. " '$modn'");
} // END if
if($quickRes)
{
# Query successful
if(mysql_num_rows($quickRes) != 0)
{
# Modify name already used...redisplay form, with the
# modify in it
print("<P CLASS=\"errorMsg\"><SPAN STYLE=\"color: red\">"
. "ERROR:</SPAN> Modify Name Entered Already Exists. Try"
. " Another.</P>\n");
makeModifyInputFormEDS($modd);
} // END if
else
{
# Modify name not used, so commit these new details to the
# database
# free the above result for speeds sakes.
mysql_free_result($quickRes);
# Build an insert query string...
$insStr = "INSERT INTO sbmMODIFY (modn, modd, cd, md, modfi1"
. ", modfi2) VALUES('$modn', '$modd', '$cd', '$md', NULL, "
. "NULL)";
# Execute this query...
$insRes = mysql_query($insStr);
if($insRes)
{
# The new modify has been entered into the database!
# Inform the user & the administrator, and redirect the
# browser to "allModifyEDS.php".
print("<SCRIPT TYPE='text/javascript'>\nalert('The "
. "$modn modify item has been successfully added to "
. "EDS.');\n</SCRIPT>\n");
$msgTxt = "The $modn modify item has been added to the "
. DOCS_DATABASE . " Database.\n\nWebSubmit Administrator (";
$msgTxt .= makeDate();
$msgTxt .= ")";
# Now send the mail..
mail(ADMIN_EMAIL, "$modn Modify Item Added",
$msgTxt, "From: WebSubmit_Administrator");
# Make a background...
print("<P STYLE=\"color: green; font-size: large; text-"
. "align: center\">The $modn Modify Item Has Been Added"
. " To " . DOCS_DATABASE . "</P>\n");
# Redirect the browser
print("<FORM ACTION='allModifyEDS.php' METHOD='post' "
. "NAME='referForm'>\n<TABLE ALIGN='center' BORDER=0>\n"
. "<TR>\n<TD ALIGN='center'>\n<INPUT TYPE='button' "
. "VALUE='OK' onClick=\"submit();\">\n</TD>\n</TR>\n"
. "</TABLE>\n</FORM>\n");
print("<SCRIPT TYPE='text/javascript'>\n"
. "setTimeout(\"document.referForm.submit();\", "
. "1000);\n</SCRIPT>\n");
} // END if
else
{
# The insert query has failed for some reason.
print("<SCRIPT TYPE='text/javascript'>\nalert('ERROR: "
. "Unable to commit the details of this modify item."
. "\\nPlease try again or inform the system "
. "administrator');\n</SCRIPT>\n");
print("<P CLASS='errorMsg'>\n<SPAN STYLE=\"color: "
. "red\">"
. "ERROR:</SPAN> Unable to commit new modify item. Try"
. " again or inform system administrator.</P>\n");
makeModifyInputFormEDS($modd);
} // END else
} // END else
} // END if
else
{
# In this case, we were unable to read from the sbmMODIFY table
# to see if there was already a modify with the name of the
# current modify. This means that we should not try to commit
# the new modify, simply redisplay the form with the modify
# details in it, and display an error message to the user...
print("<SCRIPT TYPE='text/javascript'>\nalert('Error: Unable "
. "to verify modify item name details.\\nContact system "
. "administrator or retry.');\n</SCRIPT>\n");
# Redisplay the form wih all of the details in it...
makeModifyInputFormEDS($modd, $modn);
} // END else
} // END if
else
{
# In this case, this is the first call to this script, so it can
# simply display the form in which the details of the new modify
# item can be entered...
makeModifyInputFormEDS();
} // 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