Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F81495133
removeDoctypeEDS.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
Fri, Sep 6, 09:10
Size
14 KB
Mime Type
text/x-c
Expires
Sun, Sep 8, 09:10 (2 d)
Engine
blob
Format
Raw Data
Handle
20585067
Attached To
R3600 invenio-infoscience
removeDoctypeEDS.php.wml
View Options
## $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="Referees" \
navtrail_previous_links="<a class=navtrail href=<WEBURL>/admin/<lang:star: index.*.html>>_(Admin Area)_</a> > <a class=navtrail href=<WEBURL>/admin/websubmit/>_(WebSubmit Administration)_</a>" \
navbar_name="admin" \
navbar_select="websubmit_deldoctype"
<?
<protect>
## $Id$
## DO NOT EDIT THIS FILE! IT WAS AUTOMATICALLY GENERATED FROM CDSware WML SOURCES.
function displayRemoveDoctypePage($killIt)
{
global $doc2delete;
if($killIt)
{
# In this case, this is the second call to this script, and the
# user has selected the doctype that they wish to kill, and have
# confirmed that they indeed wish to kill it. We can therefore
# begin the removing process. We need to delete from the
# "sbmCATEGORIES", "sbmDOCTYPE", "sbmIMPLEMENT", and "sbmFIELD" tables.
# Get all rows of the sbmIMPLEMENT table relating to this doctype...
$q1Res = mysql_query("SELECT subname FROM sbmIMPLEMENT WHERE "
. "docname = '$doc2delete'");
if($q1Res)
{
while($sub = mysql_fetch_array($q1Res))
{
# Delete all elements & pages for the given submission.
$q2Str = "DELETE FROM sbmFIELD WHERE subname = '"
. $sub["subname"] . "'";
$q2Res = mysql_query($q2Str);
if(!$q2Res)
{
# Query failed. Output detailed error message
print("<SCRIPT TYPE=\"text/javascript\">\nalert('ERROR:"
. "\\n\\nIt was not possible to conduct a delete query"
. " in order to remove any rows belonging to the "
. $sub["subname"] . " submission\\nof the $doc2delete "
. "document type from the sbmFIELD table.\\n\\nWhen the "
. "delete query was executed, it produced an error. "
. "This means that it is necessary\\nto manually remove"
. " any rows belonging to the " . $sub["subname"]
. " submission of the $doc2delete document type from "
. "the sbmFIELD table.');\n</SCRIPT>\n");
} // END if
} // END while
# Now delete all of the submissions for the current document
# type from the sbmIMPLEMENT table...
$q3Str = "DELETE FROM sbmIMPLEMENT WHERE docname = "
. "'$doc2delete'";
$q3Res = mysql_query($q3Str);
if(!$q3Res)
{
# query failed
print("<SCRIPT TYPE=\"text/javascript\">\nalert('ERROR:\\n"
. "\\nIt was not possible to conduct a delete query in "
. "order to remove any rows belonging to the $doc2delete"
. " document type from the sbmIMPLEMENT table.\\nWhen the "
. "delete query was executed, it produced an error. This"
. " means that it is necessary\\nto manually remove any "
. "rows belonging to the $doc2delete doctype that may be "
. "present in the sbmIMPLEMENT table.');\n</SCRIPT>\n");
} // END if
# Now delete the record of the doctype from the "sbmCATEGORIES"
# table
$q4Res = mysql_query("DELETE FROM sbmCATEGORIES WHERE doctype = "
. "'$doc2delete'");
if(!$q4Res)
{
# Unable to delete doctype details from
# sbmCATEGORIES table. Alert user
print("<SCRIPT TYPE=\"text/javascript\">\nalert('ERROR:\\n"
. "\\nIt was not possible to conduct a delete query in "
. "order to remove any rows belonging to the $doc2delete "
. "document type from the sbmCATEGORIES table.\\nWhen the "
. "delete query was executed, it produced an error. This "
. "means that it is necessary\\nto manually remove any "
. "rows belonging to the $doc2delete doctype that may be "
. "present in the sbmCATEGORIES table.');\n</SCRIPT>\n");
} // END if
# Now delete the entries for the doctype's function in the actual functions
# table.
$q6Res = mysql_query("DELETE FROM sbmFUNCTIONS WHERE doctype = '"
. "$doc2delete'");
if(!$q6Res)
{
# Unable to delete. Alert the user.
print("<SCRIPT TYPE=\"text/javascript\">\nalert('ERROR:\\n"
. "\\nIt was not possible to delete the functions\\nof the "
. "$doc2delete document type from the functions table.\\n"
. "\\nThis means that it will be necessary to manually "
. "delete any rows in this table relating to the "
. "$doc2delete doctype.');\n</SCRIPT>\n");
} // END if
# Now delete the entries for the doctype's parameters in the actual parameters
# table.
$q7Res = mysql_query("DELETE FROM sbmPARAMETERS WHERE doctype = '"
. "$doc2delete'");
if(!$q7Res)
{
# Unable to delete. Alert the user.
print("<SCRIPT TYPE=\"text/javascript\">\nalert('ERROR:\\n"
. "\\nIt was not possible to delete the parameters\\nof the "
. "$doc2delete document type from the parameters table.\\n"
. "\\nThis means that it will be necessary to manually "
. "delete any rows in this table relating to the "
. "$doc2delete doctype.');\n</SCRIPT>\n");
} // END if
# Now delete the entry for the doctype in the "sbmSUBMISSIONS"
# table.
$q8Res = mysql_query("DELETE FROM sbmSUBMISSIONS WHERE doctype = '"
. "$doc2delete'");
if(!$q8Res)
{
# Unable to delete. Alert the user.
print("<SCRIPT TYPE=\"text/javascript\">\nalert('ERROR:\\n"
. "\\nIt was not possible to delete the details\\nof the "
. "$doc2delete document type from the sbmSUBMISSIONS table.\\n"
. "\\nThis means that it will be necessary to manually "
. "delete any rows in this table relating to the "
. "$doc2delete doctype.');\n</SCRIPT>\n");
} // END if
# Now delete the entry for the doctype in the "sbmCOLLECTION_sbmDOCTYPE"
# table.
$q9Res = mysql_query("DELETE FROM sbmCOLLECTION_sbmDOCTYPE WHERE id_son = '"
. "$doc2delete'");
if(!$q9Res)
{
# Unable to delete. Alert the user.
print("<SCRIPT TYPE=\"text/javascript\">\nalert('ERROR:\\n"
. "\\nIt was not possible to delete the details\\nof the "
. "$doc2delete document type from the sbmCOLLECTION_sbmDOCTYPE table.\\n"
. "\\nThis means that it will be necessary to manually "
. "delete any rows in this table relating to the "
. "$doc2delete doctype.');\n</SCRIPT>\n");
} // END if
# Now delete the entry for the doctype in the actual "sbmDOCTYPE"
# table.
$q5Res = mysql_query("DELETE FROM sbmDOCTYPE WHERE sdocname = '"
. "$doc2delete'");
if(!$q5Res)
{
# Unable to delete the record of the doctype from the
# sbmDOCTYPE table. Alert the user.
print("<SCRIPT TYPE=\"text/javascript\">\nalert('ERROR:\\n"
. "\\nIt was not possible to delete the details\\nof the "
. "$doc2delete document type from the sbmDOCTYPE table.\\n"
. "\\nThis means that it will be necessary to manually "
. "delete any rows in this table relating to the "
. "$doc2delete doctype.');\n</SCRIPT>\n");
} // END if
print("<P STYLE=\"text-size: medium; color: green; text-align"
. ": center; font-weight: bold\">The $doc2delete document typ"
. "e has been deleted from the " . DOCS_DATABASE
. " database.</P>\n");
print("<SCRIPT TYPE=\"text/javascript\">\nalert('The "
. "$doc2delete document type has been deleted from the "
. DOCS_DATABASE . " database.\\n\\nYou should not ignore any "
. "warnings that you may have received on the screen during "
. "the process of this deletion, as these may refer to\\nrows"
. " that could not be deleted for this doctype.');\n"
. "</SCRIPT>\n");
print("<FORM ACTION=\"index.php\" METHOD=\"post\" "
. "NAME=\"referForm\">\n"
. "<INPUT TYPE=\"hidden\">\n</FORM>\n");
print("<SCRIPT TYPE=\"text/javascript\">\n"
. "setTimeout(\"document.referForm.submit();\", 0);\n"
. "</SCRIPT>\n");
} // END if
else
{
# Alert the user, and redirect browser
print("<SCRIPT TYPE=\"text/javascript\">\nalert('ERROR:\\n\\n"
. "It was not possible to conduct a query to retrieve the "
. "details of the submissions belonging\\nto the $doc2delete "
. "document type from the sbmIMPLEMENT table of the "
. DOCS_DATABASE . " database.\\n\\nWhen the query to retrieve "
. "this information was executed, it produced an error.\\n\\n"
. "This meant that it was not possible to delete the details "
. "of the $doc2delete document type from the " . DOCS_DATABASE
. " database,\\nas if it has any submissions, they could not "
. "be deleted, and as a result, data inconsistencies would be"
. " created.\\n\\nAs no further action can be taken by the "
. "WebSubmit Administrator regarding this doctype deletion, your "
. "browser has\\nbeen redirected to the main page. However, "
. "you should look into the cause of this query error,\\nas "
. "it should not have occurred.');\n</SCRIPT>\n");
} // END else
} // END if
else
{
# first call to page
print("<P CLASS=\"errorMsg\">Delete A Doctype</P>\n");
# Get all doctypes
$myRes = mysql_query("SELECT sdocname, ldocname FROM sbmDOCTYPE "
. "ORDER BY ldocname");
if($myRes)
{
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\">You can "
. "delete a doctype and all of its submissions and their "
. "elements.<BR>Simply choose the doctype from the list, "
. "and click on the \"REMOVE DOCTYPE\" button.</P>\n</TD>\n"
. "</TR>\n</TABLE>\n");
# Make the input form for the element deletion
print("<FORM ACTION=\"removeDoctypeEDS.php\" METHOD=\"post\">\n"
. "<INPUT TYPE=\"hidden\" NAME=\"killIt\" VALUE=\"true\">\n"
. "<TABLE ALIGN=\"center\" CELLSPACING=0 CELLPADDING=0 "
. "BORDER=0>\n<TR>\n<TH ALIGN=\"right\" BGCOLOR=\"#87CEFA\">"
. "Document Type: </TH>\n<TD BGCOLOR=\"#FFFFCC\" "
. "ALIGN=\"center\"><SELECT NAME=\"doc2delete\"><OPTION SELECTED "
. "VALUE=\"DO_NOT_DELETE\">Select A Doctype To Delete"
. "</OPTION>");
# Now fill the select list with all of the doctype values
while(list($code, $desc) = mysql_fetch_row($myRes))
{
print("<OPTION VALUE=\""
. ereg_replace("\"",""",ereg_replace("'", "'",
htmlspecialchars($code)))
. "\">"
. ereg_replace("\"",""",ereg_replace("'", "'",
htmlspecialchars($desc)))
. "</OPTION>\n");
} // END while
print("</SELECT></TD>\n</TR>\n</TABLE>\n");
print("<TABLE ALIGN=\"center\" BORDER=0>\n<TR>\n<TD ALIGN=\""
. "center\"><INPUT TYPE=\"button\" VALUE=\"REMOVE DOCTYPE\" "
. "onClick=\"for(i=0; i < doc2delete.length; i++) { "
. "if(doc2delete[i].selected) { break; } }"
. " if(doc2delete[i].value != 'DO_NOT_DELETE') { "
. "if(confirm('WARNING! YOU ARE ABOUT TO REMOVE THIS "
. "DOCTYPE FROM EDS!\\n ARE YOU SURE?')) { submit(); }}"
. " else { alert('Select A document Type from the list!'); "
. "}\">\n</TD>\n</TR>\n</TABLE>\n</FORM>\n");
} // END if
else
{
# query failed
print("<P CLASS=\"errorMsg\"><SPAN STYLE=\"color: red\">ERRO"
. "R:</SPAN> It was not possible to obtain a list of documen"
. "t types from the sbmDOCTYPE table.<BR>This means that it is "
. "not possible to delete a doctype.</P>\n");
print("<FORM ACTION=\"index.php\" METHOD=\"post\">\n<TABLE ALIG"
. "N=\"center\" BORDER=0 CELLSPACING=0 CELLPADDING=0>\n<TR>\n<"
. "TD ALIGN=\"center\">\n<INPUT TYPE=\"button\" VALUE=\"OK\" "
. "onClick=\"submit();\">\n</TD>\n</TR>\n</TABLE>\n</FORM>"
. "\n");
} // END else
} // 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
displayRemoveDoctypePage($killIt);
/************************End of main script***************************/
</protect>
?>
Event Timeline
Log In to Comment