Page MenuHomec4science

newDoctypeEDS.php.wml
No OneTemporary

File Metadata

Created
Sun, Jun 23, 07:31

newDoctypeEDS.php.wml

## $Id$
## This file is part of the CERN Document Server Software (CDSware).
## Copyright (C) 2002, 2003, 2004, 2005, 2006 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="Create New Document Type" \
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_newdoctype"
<?
<protect>
## $Id$
## DO NOT EDIT THIS FILE! IT WAS AUTOMATICALLY GENERATED FROM CDSware WML SOURCES.
?>
<SCRIPT TYPE='text/javascript'>
<!-- hide
function checkRequired(ldocname, sdocname, hurl, combon, combot, description,
docfi2)
// This is a function to ensure that the user enters the required
// parameters for the doctype.
// Author: Nicholas Robinson
// Email: Nicholas.Robinson@cern.ch
// ca8nro@yahoo.co.uk
// Created: Long ago!
// Last Modified: 19/12/2000
{
// If the field is left blank by the user...
if((sdocname == "") || (ldocname == ""))
{ // Alert them, and return false.
alert("Values must be entered into the Doctype Code and "
+ "Long Document Name fields.");
return false;
} // End if
else // If level has been filled by the user...
{
return true;
} // End else
} // End function checkRequired(param)
// -->
</SCRIPT>
<?
function displayDoctypeFormEDS()
{
/*******************************************************************
It is the task of this function to display the form that the user
sees to allow them to enter the details for a new EDS document
type. After all of the details of this document type have been
entered into this form, there is also a select list. This select
list contains the names of all of the other EDS Doctypes. If one
of these doctypes is selected, the new doctype will be cloned
from it.
Author: Nicholas Robinson
Email: Nicholas.Robinson@cern.ch
ca8nro@yahoo.co.uk
Created: 19/12/2000
Last Modified: 12/04/2001
*******************************************************************/
# 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>\n<TR><TD "
. "ALIGN='center'>\n<P STYLE=\"color: blue; text-align: "
. "center; font-size: small; font-weight: bold\">The form below is"
. "used for entering the details of a new document type.<BR><BR>It"
. " is possible to clone this document type from another EDS "
. "document type by selecting it from the list.<BR>If you do not "
. "wish to clone the document type, simply leave the list on the "
. "selected \"NO CLONE\" option.<BR><BR>When the details have been"
. " entered, click on the \"SAVE DETAILS\" button to commit it to "
. "the database.</P>\n</TD>\n</TR>\n</TABLE>\n");
# Make a horizontal rule to divide the page sections...
drawSeparator();
# Now display the form...
print("<FORM ACTION='newDoctypeEDS.php' METHOD='post'>\n"
. "<INPUT TYPE='hidden' NAME='addDoctype' VALUE='true'>\n");
# Get the columns list
$columns = mysql_list_fields(DOCS_DATABASE, "sbmDOCTYPE");
# Get the number of fields
$numTblFlds = mysql_num_fields($columns);
# Get the current date...
$modifiedDate = makeEDSmdDate();
# Display the system generated fields...
print("<TABLE WIDTH='100%' ALIGN='center' CELLSPACING=0 "
. "CELLPADDING=0 BORDER=0>\n<TR>\n<TH BGCOLOR='#D3DCE3' "
. "ALIGN='right' WIDTH='20%'>\nCreation Date:&nbsp;</TH>\n"
. "<TD WIDTH='80%' ALIGN='left' BGCOLOR='#FFFFCC'><INPUT "
. "TYPE='readonly' NAME='cd' VALUE='$modifiedDate'>\n</TD>\n"
. "</TR>\n<TR>\n<TH WIDTH='20%' BGCOLOR='#D3DCE3' ALIGN='"
. "right'>\nModification Date:&nbsp;</TH>\n<TD WIDTH='80%' "
. "ALIGN='left' BGCOLOR='#FFFFCC'><INPUT TYPE='readonly' "
. "NAME='md' VALUE='$modifiedDate'>\n</TD>\n</TR>\n");
print("<TR>\n<TH BGCOLOR='#87CEFA' ALIGN='right' WIDTH='20%'>\n"
. "Document Type ID:&nbsp;</TH>\n<TD WIDTH='80%' ALIGN='left' "
. "BGCOLOR='#FFFFCC'>\n<INPUT TYPE='text' NAME='sdocname' SIZE="
. mysql_field_len($columns, 1) . ">\n</TD>\n</TR>\n");
# Now add the other fields...
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>\n<TH BGCOLOR='#87CEFA' ALIGN='right' WIDTH='"
. "20%'>\n");
if($currentField == "ldocname")
{
print("Document Type Name:&nbsp;");
} // END if
elseif($currentField == "description")
{
print("Document Type Description:&nbsp;");
} // END elseif
else
{
print("$currentField" . ":&nbsp;");
} // END else
if ($currentField == "description")
{
print "&nbsp;</TH>\n<TD ALIGN='left' WIDTH='80%' "
. "BGCOLOR='#FFFFCC'>\n<TEXTAREA NAME="
. "'$currentField' cols=60 rows=4></TEXTAREA>"
. "\n</TD>\n</TR>\n";
}
else
{
print("&nbsp;</TH>\n<TD ALIGN='left' WIDTH='80%' "
. "BGCOLOR='#FFFFCC'>\n<INPUT TYPE='text' NAME="
. "'$currentField' SIZE=");
if(mysql_field_type($columns, $indx) == "blob")
{
print("60");
} // END if
else
{
print(mysql_field_len($columns, $indx));
} // END else
print(">\n</TD>\n</TR>\n");
}
} // END if
} // END for
# Now, we want to create a select list of EDS doctypes...
$queryResult = mysql_query("SELECT sdocname, ldocname FROM sbmDOCTYPE "
. "ORDER BY sdocname");
if($queryResult)
{
print("<TR>\n<TH BGCOLOR='#87CEFA' ALIGN='right' WIDTH='"
. "20%'>\nDoctype To Clone:&nbsp;</TH>\n<TD ALIGN='left'"
. " WIDTH='80%' BGCOLOR='#FFFFCC'>\n");
print("<SELECT NAME='doc2clone'>\n<OPTION SELECTED VALUE='"
. "NO_CLONE'>None</OPTION>\n");
while($dox = mysql_fetch_array($queryResult))
{
print("<OPTION VALUE='"
. htmlspecialchars($dox["sdocname"])
. "'>" . htmlspecialchars($dox["ldocname"])
. "</OPTION>\n");
} // END while
print("\n</SELECT>\n</TD>\n</TR>\n");
} // END if
# Now close the table...
print("</TABLE>\n");
# Now create the buttons for the form...
print("<TABLE ALIGN='center' CELLSPACING=2 CELLPADDING=2 BORDER=0>"
. "<TR>\n<TD ALIGN='left'>\n<INPUT TYPE='button' VALUE='SAVE DETAIL"
. "S' onClick=\"if(checkRequired(ldocname.value, sdocname.value"
. ")) { if(confirm('Really Commit This New Doctype"
. "?')) { submit(); } else { return false; } }\">\n</TD><TD ALIGN='"
. "center'>\n<INPUT TYPE='button' VALUE='RESET' onClick=\"reset();"
. "\">\n</TD>\n</FORM>\n<FORM ACTION='index.php' METHOD='post'>\n"
. "<TD ALIGN='left'>\n<INPUT TYPE='button' VALUE='CANCEL' onClick="
. "\"submit();\">\n</TD>\n</FORM>\n</TR>\n</TABLE>\n");
} // END function displayDoctypeFormEDS()
//*************
function processCloningEDS($doc2clone, $sdocname)
{
/*******************************************************************
This function actually deals with the cloning of a document type
from another document type in EDS. This means that it is
necessary for it to search through the sbmIMPLEMENT table looking
for all submissions that belong to the given doctype that is
being cloned. It then changes the 'cd' and 'md' fields to hold
todays date (the date on which the new doctype is being created),
changes the doctype field to hold the doctype of the new doctype,
and changes the subname field to have the action code combined
with the new doctype code, as opposed to the doctype code of the
doctype being cloned along with the action code. All of this
data is then committed to the database.
Author: Nicholas Robinson
Email: Nicholas.Robinson@cern.ch
ca8nro@yahoo.co.uk
Created: 19/12/2000
Last Modified: 25/01/2001
*******************************************************************/
# Run a query to get all of the submission types for the doctype to
# be cloned...
$cloneRes1 = mysql_query("SELECT * FROM sbmIMPLEMENT WHERE docname ="
. " '$doc2clone' ORDER BY actname");
if($cloneRes1)
{
# Fine, the query has worked...
# Get the current date...
$modDate = makeEDSmdDate();
# Okay, for each submission
while($sub2Clone = mysql_fetch_array($cloneRes1))
{
# Clone functions
$res = mysql_query("select * from sbmFUNCTIONS where doctype='$doc2clone' and action='".$sub2Clone["actname"]."'");
while ($row = mysql_fetch_array($res))
{
$res2 = mysql_query("select 1 from sbmFUNCTIONS where doctype='$sdocname' and action='".$row["action"]."' and function='".$row["function"]."' and score='".$row['score']."' and step='".$row['step']."'");
if (mysql_num_rows($res2) < 1)
mysql_query("insert into sbmFUNCTIONS(action, doctype, function, score, step) values ('".$row['action']."','$sdocname','".$row['function']."','".$row['score']."','".$row['step']."')");
}
#clone parameters
$res = mysql_query("select * from sbmPARAMETERS where doctype='$doc2clone'");
while ($row = mysql_fetch_array($res))
{
$res2 = mysql_query("select 1 from sbmPARAMETERS where doctype='$sdocname' and name='".$row['name']."'");
if (mysql_num_rows($res2) < 1)
mysql_query("insert into sbmPARAMETERS(doctype, name, value) values ('$sdocname','".$row['name']."','".$row['value']."')");
}
# Make a query to insert this submission data for the new
# doctype...
$subCloneStr = "INSERT INTO sbmIMPLEMENT (docname, actname, displayed, subname, nbpg, cd, md, buttonorder, statustext, level, score, stpage, endtxt) "
. "VALUES ('"
. ereg_replace("'", "\'", $sdocname) . "', '"
. ereg_replace("'", "\'", $sub2Clone["actname"]) . "', '"
. ereg_replace("'", "\'", $sub2Clone["displayed"]) . "', '"
. ereg_replace("'", "\'", $sub2Clone["actname"])
. ereg_replace("'", "\'", $sdocname) . "', '"
. ereg_replace("'", "\'", $sub2Clone["nbpg"])
. "', '$modDate', '$modDate', '"
. ereg_replace("'", "\'", $sub2Clone["buttonorder"]) . "', '"
. ereg_replace("'", "\'", $sub2Clone["statustext"]) . "', '"
. ereg_replace("'", "\'", $sub2Clone["level"]) . "', '"
. ereg_replace("'", "\'", $sub2Clone["score"]) . "', '"
. ereg_replace("'", "\'", $sub2Clone["stpage"]) . "', '"
. ereg_replace("'", "\'", $sub2Clone["endtxt"]) . "')";
$subCloneRes = mysql_query($subCloneStr);
if($subCloneRes)
{
# Good...no query errors.
if(mysql_affected_rows() == 1)
{
# Good...the query inserted the row! Now we can get the
# elements for this submission, and insert them for the
# new doctype.
# Now conduct a select query to get all of the elements
# for this submission.
$cloneStr2 = "SELECT * FROM sbmFIELD WHERE subname = '"
. $sub2Clone["subname"] . "'";
$cloneRes2 = mysql_query($cloneStr2);
if($cloneRes2)
{
# Fine, the query worked...
# For each element of the submission
while($anElement = mysql_fetch_array($cloneRes2))
{
$eleCloneStr = "INSERT INTO sbmFIELD (subname, "
. "pagenb, fieldnb, fidesc, fitext, level, sdesc,"
. " checkn, cd, md, fiefi1, fiefi2) VALUES ('"
. ereg_replace("'", "\'",
$sub2Clone["actname"])
. ereg_replace("'", "\'",
$sdocname) . "', '"
. ereg_replace("'", "\'",
$anElement["pagenb"]) . "', '"
. ereg_replace("'", "\'",
$anElement["fieldnb"]) . "', '"
. ereg_replace("'", "\'",
$anElement["fidesc"]) . "', '"
. ereg_replace("'", "\'",
$anElement["fitext"]) . "', '"
. ereg_replace("'", "\'",
$anElement["level"]) . "', '"
. ereg_replace("'", "\'",
$anElement["sdesc"]) . "', '"
. ereg_replace("'", "\'",
$anElement["checkn"]) . "', '$modDate', '"
. "$modDate', '"
. ereg_replace("'", "\'",
$anElement["fiefi1"]) . "', '"
. ereg_replace("'", "\'",
$anElement["fiefi2"]) . "')";
# Now we can execute this query...
$eleCloneRes = mysql_query($eleCloneStr);
# Now test that all went well with the insert...
if($eleCloneRes)
{
# Good...the query was correct...
if(mysql_affected_rows() != 1)
{
# For some reason, the element was not
# inserted
# Tell the user...
print("<SCRIPT TYPE='text/javascript'>\n"
. "alert('ERROR: Unable to insert element "
. $anElement["fieldnb"] . " ("
. $anElement["fitext"] . ") of page "
. $anElement["pagenb"] . " of the "
. $sub2Clone["actname"] . "$sdocname "
. "submission.\\nThis may have caused "
. "element numberring errors and should be"
. " corrected immediately.\\n\\nPlease inf"
. "orm the system administrator.');\n"
. "</SCRIPT>\n");
# Email the administrator...
$msgTxt = "An error ocurred during the "
."creation of the new $sdocname document "
."type. It was not possible to commit the "
. "details for the " . $anElement["fidesc"]
. " element (number "
. $anElement["fieldnb"]
. ") on page " . $anElement["pagenb"]
. " of the " . $sub2Clone["actname"]
. "$sdocname submission for somereason. "
. " This means that the element will be "
. "missing, and therefore other elements "
. "could be out of sequence, which could be"
. " dangerous for the EDS system.\n\nYou "
. "should fix this problem at once.\n\nEDS "
."Administrator (";
$msgTxt .= makeDate();
$msgTxt .= ")";
# Now send the mail..
mail(ADMIN_EMAIL, "$sdocname creation "
."Error - " . $anElement["fidesc"]
. " Element Missed from "
. $sub2Clone["actname"] . "$sdocname",
$msgTxt, "From: WebSubmit_Administrator");
} // END else
} // END if
else
{
# Bad news! the query didn't work.
# Inform the user of the missing element
print("<SCRIPT TYPE='text/javascript'>\nalert("
. "'ERROR: It was not possible to commit the "
. "details for the " . $anElement["fidesc"]
. " element (number " . $anElement["fieldnb"]
. ") of the " . $sub2Clone["actname"]
. "$sdocname submission.');\n</SCRIPT>\n");
# Inform the administrator...
$msgTxt = "An error ocurred during the "
."creation of the new $sdocname document type."
." It was not possible to commit the "
. "details for the " . $anElement["fidesc"]
. " element (number " . $anElement["fieldnb"]
. ") on page " . $anElement["pagenb"]
. " of the " . $sub2Clone["actname"]
. "$sdocname submission, due to a query error."
. " This means that the element will be "
. "missing, and therefore other elements "
. "could be out of sequence, which could be "
. "dangerous for the EDS system.\n\nYou should"
. " fix this problem at once.\n\nEDS "
."Administrator (";
$msgTxt .= makeDate();
$msgTxt .= ")";
# Now send the mail..
mail(ADMIN_EMAIL, "$sdocname Creation Error"
." - " . $anElement["fidesc"] . " Element "
. "Missed From " . $sub2Clone["actname"]
. "$sdocname", $msgTxt,
"From: WebSubmit_Administrator");
} // END else
} // END while
} // END if
else
{
# We couldn't get the details of the elements for the
# current submission. This means that we can simply
# ignore them, and let both the user & admin know.
print("<SCRIPT TYPE='text/javascript'>\nalert('ERROR"
. ": It was not possible to retrieve details of the "
. "elements for the " . $sub2Clone["subname"]
. "submission.\\nThis meant that it was not possible"
. " to clone these elements\\nfor the new "
. $sub2Clone["actname"] . "$sdocname submission.\\n"
. "\\nIt will therefore be necessary to manually add"
. " any elements to this submission.');\n</SCRIPT>"
. "\n");
# Email the admin...
$msgTxt = "An error ocurred during the creation of "
. "the new $sdocname document type. This new "
. "doctype was being cloned from the $doc2clone "
. "document type. When an attempt was made to read"
. " details of the elements of the "
. $sub2Clone["subname"] . " however, it was not "
. "possible to retrieve these details due to a query"
. " error. This meant that the elements of the new "
. $sub2Clone["actname"] . "$sdocname submission "
. "could not be created, so the submission will have"
. " blank pages. It will be necessary to manually "
. "add these pages to this submission.\n\nEDS "
. "Administrator (";
$msgTxt .= makeDate();
$msgTxt .= ")";
# Now send the mail..
mail(ADMIN_EMAIL, "$sdocname Creation Error - "
.$sub2Clone["actname"] . "$sdocname "
. "Elements Not Cloned", $msgTxt,
"From: WebSubmit_Administrator");
} // END else
} // END if
else
{
# New submission was not inserted. Forget the elements
# for it then!
print("<SCRIPT TYPE='text/javascript'>\nalert('ERROR: "
. "unable to commit the new " . $sub2Clone["actname"]
. "$sdocname to the sbmIMPLEMENT table. Cloned elements "
. "therefore have not been committed.');\n</SCRIPT>\n");
# Mail the administrator...
# Inform the administrator
$msgTxt = "An error ocurred during the creation of the "
. "new $sdocname document type. This new doctype was "
."being cloned from the $doc2clone document type. When"
." an attempt was made to write details for the new "
. $sub2Clone["actname"] . "$sdocname submission, which "
. "was to be cloned from the " . $sub2Clone["subname"]
. " submission, to the sbmIMPLEMENT table, no data was "
. "written. This meant that the "
. $sub2Clone["actname"] . "$sdocname submission could "
. "not be created, and therefore does not exist for the"
. "$sdocname document type.\n\nWebSubmit Administrator (";
$msgTxt .= makeDate();
$msgTxt .= ")";
# Now send the mail..
mail(ADMIN_EMAIL, "$sdocname Creation Error - "
. $sub2Clone["actname"] . " Submission Not "
. "Cloned", $msgTxt,
"From: WebSubmit_Administrator");
} // END else
} // END if
else
{
$error = mysql_error();
# query failed.
print("<SCRIPT TYPE='text/javascript'>\nalert('ERROR: "
. "Could not conduct an insert query on the sbmIMPLEMENT "
. "table.\\n" . $sub2Clone["actname"] . "$sdocname "
. "submission and its elements therefore could not be "
."added.\\n error msg: $error');\n</SCRIPT>\n");
# Inform the administrator
$msgTxt = "An error ocurred during the creation of the new"
. " $sdocname document type. This new doctype was being "
. "cloned from the $doc2clone document type. When an "
. "attempt was made to write details for the new "
. $sub2Clone["actname"] . "$sdocname submission, which was"
. " to be cloned from the " . $sub2Clone["subname"]
. " submission, to the sbmIMPLEMENT table, this attempt "
. "failed due to a query error. This meant that the "
. $sub2Clone["actname"] . "$sdocname submission could not "
. "be created, and therefore does not exist for the "
. "$sdocname document type.";
$msgTxt .= makeDate();
$msgTxt .= ")";
# Now send the mail..
mail(ADMIN_EMAIL, "$sdocname Creation Error - "
. $sub2Clone["actname"] . "$sdocname Submission "
. "Not Cloned", $msgTxt,
"From: WebSubmit_Administrator");
} // END else
} // END while
# Now that we have cloned the submissions & their pages, we can
# clone the Categories...
$catCloneRes = mysql_query("SELECT * FROM sbmCATEGORIES WHERE "
. "doctype = '$doc2clone' ORDER BY sname");
if($catCloneRes)
{
# Cool. Query successful.
while($cat = mysql_fetch_array($catCloneRes))
{
$catInsStr = "INSERT INTO sbmCATEGORIES (doctype, sname, "
. "lname) VALUES('$sdocname', '" . $cat["sname"]
. "', '" . $cat["lname"] . "')";
$catInsRes = mysql_query($catInsStr);
if(!$catInsRes)
{
# Insert query didn't work
print("<SCRIPT TYPE='text/javascript'>\nalert('"
. "ERROR: Unable to clone " . $cat["sname"]
. " category from $doc2clone doctype.');\n"
. "</SCRIPT>\n");
} // END if
} // END while
} // END if
else
{
# D'oh! Query unsuccessful.
print("<SCRIPT TYPE='text/javascript'>\nalert('ERROR: "
. "Couldn't retrieve details of the categories of the "
. "$doc2clone doctype.\\n\\nThis meant it was not possib"
. "le to clone them.');\n</SCRIPT>\n");
# Inform the administrator
$msgTxt = "An error ocurred during the creation of the new"
. " $sdocname document type. This new doctype was being "
. "cloned from the $doc2clone document type. When an "
. "attempt was made to retrieve details of the categories "
. "of the $doc2clone doctype, this attempt "
. "failed due to a query error. This meant that the "
. "categories could not be cloned, and therefore do not "
. "exist for the $sdocname document type.";
$msgTxt .= makeDate();
$msgTxt .= ")";
# Now send the mail..
mail(ADMIN_EMAIL, "$sdocname Creation Error - "
."Categories Not Cloned", $msgTxt,
"From: WebSubmit_Administrator");
} // END else
} // END if
else
{
# D'OH! The query didn't work...We can't clone here, so we had
# better just let the user know, and terminate this cloning
# function.
print("<SCRIPT TYPE='text/javascript'>\nalert('ERROR: It was not"
. " possible to conduct a query to retrieve the submissions for "
. "the $doc2clone doctype.\\nThis meant that it was impossible "
. "to clone this doctype, and so the cloning process\\nfor the "
. "new $sdocname doctype was terminated.\\n\\nPlease inform the "
. "system administrator.');\n</SCRIPT>\n");
# Mail the administrator...
$msgTxt = "An error ocurred while attempting to create the "
. "$sdocname document type. The user had opted to clone this "
. "new document type from the $doc2clone document type. "
. "However, when this cloning was attempted, it was not possible"
. " to conduct a query on the sbmIMPLEMENT table in order to obtain"
. " details of the submissions belonging to that doctype.\n\nThi"
. "smeant that the cloning of this doctype was not possible, so "
. "infact the new $sdocname document type has not been cloned "
. "from any other doctypes.\n\nWebSubmit Administrator (";
$msgTxt .= makeDate();
$msgTxt .= ")";
# Now send the mail..
mail(ADMIN_EMAIL, "$sdocname Creation Cloning Failure",
$msgTxt, "From: WebSubmit_Administrator");
} // END else
} // END function processCloningEDS()
//*************
function processDoctypeAdditionEDS($ldocname, $sdocname, $cd,
$md, $description, $docfi2, $doc2clone)
{
/*******************************************************************
This function deals with the actions to take after the form to
enter a new doctype has been submitted.
Author: Nicholas Robinson (Adapted from it's WebSubmit Manager
Counterpart (processCloning()), also
written by Nicholas Robinson).
Email: Nicholas.Robinson@cern.ch
ca8nro@yahoo.co.uk
Created: 19/12/2000
Last Modified: 12/04/2001
*******************************************************************/
# Ensure that the doctype code is in uppercase
$sdocname = strtoupper($sdocname);
# Make a test query to see if the current doctype code already
# exists in sbmDOCTYPE
$duplctRes = mysql_query("SELECT sdocname FROM sbmDOCTYPE WHERE "
. "sdocname = '" . ereg_replace("'", "\'", $sdocname) . "'");
if($duplctRes && mysql_num_rows($duplctRes) < 1)
{
# In this case, the doctype has not been duplicated (and the test
# query worked. We can therefore let them attemp to add the new
# doctype. We wouldn't bother if the test query didn't work, or
# there was already a doctype with this code.
# Insert the new doctype values into the
$qRes1str = "INSERT INTO sbmDOCTYPE (ldocname, sdocname, "
. "cd, md, description) VALUES "
. "('" . ereg_replace("'", "\'", $ldocname) . "', '"
. ereg_replace("'", "\'", $sdocname) . "', '$cd', '$md', '"
. ereg_replace("'", "\'", $description) . "')";
# Execute the above query string...
$qRes1 = mysql_query($qRes1str);
} // END if
# Now test to see if the query was successful...
if(!$qRes1) # If it wasn't...
{
print("<P CLASS=\"errorMsg\"><SPAN STYLE=\"color: red\">ERROR:"
. "</SPAN>New Document Type Could Not Be Committed To "
. "Database.<BR>Ensure Doctype Code Is Not Duplicated."
. "</P>\n");
print("<TABLE ALIGN='center' CELLSPACING=0 CELLPADDING=0 BORDER"
. "=0>\n<TR>\n<FORM ACTION='index.php' METHOD='post'>\n<TD ALIGN"
. "='center'>\n<INPUT TYPE='button' VALUE='OK' onClick=\"submit"
. "();\">\n</TD>\n</FORM>\n</TR>\n</TABLE>\n");
} // END if
else # If it was successful...
{
# Mail the administrators to inform of the new doctype addition
# Get the current date and time...
$dateDets = getdate();
# make a message string for the created doctype mail message...
$msgTxt = "Please be advised that the $sdocname document"
. " type was created in EDS on "
. $dateDets['weekday'] . " " . $dateDets['mday'] . " "
. $dateDets['month'] . " " . $dateDets['year']
. ", at " . $dateDets['hours'] . ":"
. $dateDets['minutes'] . "."
. "\n\nThis new doctype was ";
if($doc2clone != "NO_CLONE")
{
$msgTxt .= "cloned from the $doc2clone document type.";
}// END if
else
{
$msgTxt .= "not cloned from another document type.";
} // END else
$msgTxt .= "\n\nWebSubmit Administrator.";
# Mail the administrator(s) to inform them of the deletion...
mail(ADMIN_EMAIL, "$sdocname Document Type Created", $msgTxt,
"From: WebSubmit_Administrator");
# Print a message on the screen informing the user of the
# successful addition of the doctype...
print("<P STYLE=\"color: green; text-align: center; font-size:"
. " medium\">The <EM>$sdocname</EM> document type has been add"
. "ed to EDS.<BR>If the doctype was cloned however, it is "
. "entirely possible that the cloning process may not have been"
. "100% successful.<BR>If you receive any warning messages about"
. "submissions/pages/elements not cloning properly, do not "
. "ignore them.</P>\n");
# Now, if the user opted to clone another doctype, begin the
# process...
if($doc2clone != "NO_CLONE")
{
processCloningEDS($doc2clone, $sdocname);
} // END if
# Now that the process of adding the doctype is complete, we can
# simply redirect the page to the "documentEDS.php" page, so that
# the user can further view or configure the new doctype.
# Redirect the browser...
print("<FORM ACTION='documentEDS.php' METHOD='post' "
. "NAME='referForm'>\n<INPUT TYPE='hidden' NAME='doctyp"
. "e' VALUE='$sdocname'>\n</FORM>\n");
print("<SCRIPT TYPE='text/javascript'>\n"
. "setTimeout(\"document.referForm.submit();\", "
. "1000);\n</SCRIPT>\n");
} // END else
} // END function processDoctypeAdditionEDS()
function displayNewDoctypeForm($addDoctype)
{
global $ldocname, $sdocname, $cd, $md, $description, $docfi2, $doc2clone;
# Test to see what kind of call to the page this actually is...
if($addDoctype)
{
# This is a call to actually commit the details of the new
# doctype
unset($addDoctype);
# Begin the long process!
processDoctypeAdditionEDS($ldocname, $sdocname, $cd, $md,
$description, $docfi2, $doc2clone);
} // END if
else
{
# This is the first call to the page, so just display the input
# form
displayDoctypeFormEDS();
} // 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
displayNewDoctypeForm($addDoctype);
/************************End of main script***************************/
</protect>
?>

Event Timeline