Page MenuHomec4science

addCheckEDS.php.wml
No OneTemporary

File Metadata

Created
Sun, Jun 30, 17:35

addCheckEDS.php.wml

## $Id$
## This file is part of CDS Invenio.
## Copyright (C) 2002, 2003, 2004, 2005, 2006 CERN.
##
## CDS Invenio 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.
##
## CDS Invenio 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 CDS Invenio; 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 javascript checking function" \
navtrail_previous_links="<a class=navtrail href=<WEBURL>/admin/<lang:star: index.*.html>>_(Admin Area)_</a> &gt; <a class=navtrail href=<WEBURL>/admin/websubmit/>_(WebSubmit Administration)_</a>" \
navbar_name="admin" \
navbar_select="websubmit_listchecks"
<?
<protect>
## $Id$
## DO NOT EDIT THIS FILE! IT WAS AUTOMATICALLY GENERATED FROM CDS Invenio WML SOURCES.
/********************Function Declarations****************************/
function makeChecksInputFormEDS($chdesc = "", $chname = "")
{
/*******************************************************************
This function has the task of displaying a form for the inputting
of a new check. The function is passed 3 variables. These are
the $link variable, the $chdesc variable (which is the
description of the check i.e. the actual JavaScript code itself),
and the chname variable (which is the unique name of the check.
The chdesc and chname 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 check, we may want to refuse
committment of the check, 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: 18/12/2000
Last Modified: 18/12/2000
*******************************************************************/
# 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 check to EDS.<BR><BR>"
. "An EDS check is a checking function written in JavaScript"
. " that can be applied to a given EDS submission page or "
. "element(s),<BR>to perform some sort of validation task."
. "<BR><BR>It is important that when you create new EDS "
. "checks, you do not give them a name that is already in "
. "use, as the check name must<BR>be unique due to the fact "
. "that it is used to identify a given check when the EDS "
. "system attempts to use it.<BR><BR>When the check has been "
. "written in the text area provided (Check Description), "
. "click on the \"SAVE DETAILS\" button<BR>to commit this new"
. " check 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 sbmCHECKS table
$columns = mysql_list_fields(DOCS_DATABASE, "sbmCHECKS");
# Now begin making the form...
print("<TABLE WIDTH='100%' ALIGN='center' BORDER=0 CELLSPACING=0 "
. "CELLPADDING=0>\n<FORM ACTION='addCheckEDS.php' METHOD='post'>\n"
. "<INPUT TYPE='hidden' NAME='addIt' VALUE='true'>\n"
. "<TR>\n<TH BGCOLOR='#D3DCE3' ALIGN='right' WIDTH='20%'>Creation "
. "Date:&nbsp;</TH>\n<TD ALIGN='left' BGCOLOR='#FFFFCC' WIDTH='80%'"
. "><INPUT TYPE='readonly' NAME='cd' VALUE='$modifiedDate'></TD>\n"
. "<TR>\n<TH BGCOLOR='#D3DCE3' ALIGN='right' WIDTH='20%'>Modificat"
. "ion Date:&nbsp;</TH>\n<TD ALIGN='left' BGCOLOR='#FFFFCC' WIDTH="
. "'80%'><INPUT TYPE='readonly' NAME='md' VALUE='$modifiedDate'>"
. "</TD>\n</TR>\n<TR>\n<TH BGCOLOR='#87CEFA' ALIGN='right' WIDTH="
. "'20%'>Check Name:&nbsp;</TH>\n<TD ALIGN='left' WIDTH='80%' "
. "BGCOLOR='#FFFFCC'><INPUT TYPE='text' NAME='chname' SIZE="
. mysql_field_len($columns, 0) . " VALUE='$chname'>\n</TD>\n</TR>"
. "\n<TR>\n<TH "
. "BGCOLOR='#87CEFA' ALIGN='right' WIDTH='20%'>Check Description:"
. "&nbsp;</TH>\n<TD ALIGN='left' BGCOLOR='#FFFFCC' WIDTH='80%'><"
. "TEXTAREA COLS=50 ROWS=20 NAME='chdesc'>$chdesc"
. "</TEXTAREA></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 check
# addition (this will send the browser back to "allChecksEDS.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(chname.value != '') { submit(); } else { alert("
. "'The \'Check Name\' Field Is Mandatory'); }\"></TD>\n<TD ALIGN='"
. "center'><INPUT TYPE='button' VALUE='RESET' onClick=\"reset();\">"
. "</TD>\n</FORM>\n<FORM ACTION='allChecksEDS.php' METHOD='post'>\n"
. "<TD ALIGN='left'><INPUT TYPE='button' VALUE='CANCEL' onClick=\""
. "submit();\"></TD>\n</TR>\n</TABLE>\n");
} // END function makeChecksInputFormEDS()
function displayPage()
{
global $addIt,$chname,$chdesc;
if($addIt)
{
# In this case, the user has filled in the form to add a new
# check, and has submitted it...
# The first thing to do is to run a quick query to ensure that
# there is not already a check with the same name as that that we
# have just entered...
$quickRes = mysql_query("SELECT chname FROM sbmCHECKS WHERE chname "
. "= '$chname'");
if($quickRes)
{
# Query successful
if(mysql_num_rows($quickRes) != 0)
{
# Check name already used...redisplay form, with the check
# in it
print("<P CLASS=\"errorMsg\"><SPAN STYLE=\"color: red\">"
. "ERROR:</SPAN> Checkname Entered Already Exists. Try "
. "Another.</P>\n");
makeChecksInputFormEDS($chdesc);
} // END if
else
{
# Checkname 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 sbmCHECKS (chname, chdesc, cd, md, "
. "chefi1, chefi2) VALUES('$chname', '$chdesc', '$cd', "
. "'$md', '', '')";
# Execute this query...
$insRes = mysql_query($insStr);
if($insRes)
{
# The new check has been entered into the database!
# Inform the user & the administrator, and redirect the
# browser to "allChecksEDS.php".
print("<SCRIPT TYPE='text/javascript'>\nalert('The "
. "$chname check has been successfully added to "
. "EDS.');\n</SCRIPT>\n");
$msgTxt = "The $chname check has been added to the EDS "
. "Database.\n\nWebSubmit Administrator (";
$msgTxt .= makeDate();
$msgTxt .= ")";
# Now send the mail..
mail(ADMIN_EMAIL, "EDS: $chname Check Added",
$msgTxt, "From: WebSubmit_Administrator");
# Make a background...
print("<P STYLE=\"color: green; font-size: large; text-"
. "align: center\">The $chname Check Has Been Added To "
. DOCS_DATABASE . "</P>\n");
# Redirect the browser
print("<FORM ACTION='allChecksEDS.php' METHOD='post' "
. "NAME='referForm'>\n<INPUT TYPE='hidden'></FORM>\n");
print("<SCRIPT LANGUAGE=\"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 check.\\nPlease"
. " try again or inform the system administrator');\n"
. "</SCRIPT>\n");
makeChecksInputFormEDS($chdesc);
} // END else
} // END else
} // END if
else
{
# In this case, we were unable to read from the sbmCHECKS table
# to see if there was already a check with the name of the
# current check. This means that we should not try to commit
# the new check, simply redisplay the form with the check
# details in it, and display an error message to the user...
print("<SCRIPT TYPE='text/javascript'>\nalert('Error: Unable "
. "to verify check name details.\\nContact system administrat"
. "or or retry later.');\n</SCRIPT>\n");
# Redisplay the form wih all of the details in it...
makeChecksInputFormEDS($chdesc, $chname);
} // 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
# JavaScript check can be entered...
makeChecksInputFormEDS();
} // END else
}
/**********************Start of main script***************************/
# Connect to the MySQL server
serverConnect(MYSQLDOCMACHINE, MYSQLDOCUSERID, MYSQLDOCPASSWORD);
# Select the CDS Search database...
dbSelect(DOCS_DATABASE);
$auth = canUseWebSubmitAdmin($uid);
if (!$auth[0])
outWarning($auth[1]);
else
displayPage();
/************************End of main script***************************/
</protect>
?>

Event Timeline