Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F81497629
doctypeCategoriesEDS.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:31
Size
21 KB
Mime Type
text/x-c
Expires
Sun, Sep 8, 09:31 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
20585627
Attached To
R3600 invenio-infoscience
doctypeCategoriesEDS.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="Edit categories of the <i><protect><?print $doctype;?></protect></i> document type" \
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"
<?
<protect>
## $Id$
## DO NOT EDIT THIS FILE! IT WAS AUTOMATICALLY GENERATED FROM CDSware WML SOURCES.
/*********************Function Descriptions***************************/
function showCatsEDS($doctype)
{
/*******************************************************************
This function has the task of effectively making the page that
displays all of the categories of the current doctype in a table.
It also makes a button allowing the user to add a new category if
they wish.
Author: Nicholas Robinson
Email: Nicholas.Robinson@cern.ch
ca8nro@yahoo.co.uk
Created: 15/01/2001
Last Modified: 15/01/2001
*******************************************************************/
global $IMAGES;
$dataRes = mysql_query("SELECT * FROM sbmCATEGORIES WHERE doctype = "
. "'$doctype' ORDER BY sname");
if($dataRes)
{
# In this case, the query executed successfully.
if(mysql_num_rows($dataRes) > 0)
{
print("<TABLE WIDTH='50%' ALIGN='center' BORDER=1 "
. "CELLSPACING=0 CELLPADDING=0><TR BGCOLOR='#CCDDFF'>"
. "<TH>Category ID</TH><TH>Category"
. " Description</TH><TH> </TH><TH> </TH>"
. "</TR>");
while($row = mysql_fetch_array($dataRes))
{
print("<TR BGCOLOR='#FFFFCC'><TD ALIGN='center'>"
. $row["sname"] . " </TD><TD ALIGN='center'>"
. $row["lname"] . " </TD>");
# Now add a form for editing this cat.
print("<FORM ACTION='doctypeCategoriesEDS.php' METHOD='"
. "post'><INPUT TYPE='hidden' NAME='editCatForm' VALUE="
. "'true'><INPUT TYPE='hidden' NAME='doctype' VALUE='"
. "$doctype'><INPUT TYPE='hidden' NAME='sname' VALUE='"
. $row["sname"] . "'><TD ALIGN='center'><INPUT TYPE='"
. "image' SRC='".$IMAGES."/edit1.gif' BORDER=0 onClick=\""
. "submit();\" ALIGN='center' WIDTH=18 HEIGHT=18></TD>"
. "</FORM>");
# Now add a form for deleting this cat
print("<FORM ACTION='doctypeCategoriesEDS.php' METHOD='"
. "post'><INPUT TYPE='hidden' NAME='delCat' VALUE='"
. "true'><INPUT TYPE='hidden' NAME='doctype' VALUE='"
. "$doctype'><INPUT TYPE='hidden' NAME='sname' VALUE='"
. $row["sname"] . "'><TD ALIGN='center'><INPUT TYPE='"
. "image' SRC='".$IMAGES."/answer_bad.gif' BORDER=0 ALIGN='"
. "center' WIDTH=14 HEIGHT=14></TD></FORM>");
print("</TR>");
} // END while
print("</TABLE>");
} // END if
else
{
# No rows returned - output a message saying that the
# current doctype does not yet have any categories
print("<P STYLE=\"color: green; font-size: large; text-align:"
. " center; font-weight: bold\"><EM>$doctype</EM> "
. "Document Type Has No Categories</P>");
} // END else
# Now make a button that the user can press in order to add a new
# category
print("<FORM ACTION='doctypeCategoriesEDS.php' METHOD='post'>"
. "<INPUT TYPE='hidden' NAME='addCatForm' VALUE='true'>"
. "<INPUT TYPE='hidden' NAME='doctype' VALUE='$doctype'>"
. "<TABLE ALIGN='center' BORDER=0><TR><TD ALIGN='center'>"
. "<INPUT TYPE='button' VALUE='ADD A CATEGORY' onClick=\""
. "submit();\"></TD></TR></TABLE></FORM>");
mysql_free_result($dataRes);
} // END if
else
{
# In this case, the query failed, so we just output the warning
print("<P CLASS=\"errorMsg\"><SPAN STYLE=\"color: red\">ERROR"
. ":</SPAN> Unable To Retrieve Details of Categories for "
. "<EM>$doctype</EM> Document Type.<BR>Inform System Adminis"
. "trator.</P>");
} // END else
print("<FORM ACTION='documentEDS.php' METHOD='post'><INPUT "
. "TYPE='hidden' NAME='doctype' VALUE='$doctype'><TABLE "
. "ALIGN='center' BORDER=0><TR><TD ALIGN='center'>"
. "<INPUT TYPE='button' VALUE='FINISHED' onClick=\"submit();"
. "\"></TD></TR></TABLE></FORM>");
} // END function showCatsEDS($doctype)
//************
function addEditCatForm($doctype, $formType, $sname = "")
{
/*******************************************************************
This function has the task of creating an html form. This form
will contain the details of a given category for the given
doctype. It is called for both the adding of a new category, and
the editing of an existing category description. The difference
is that a value is passed to the function. This value is a
string containing a word that will be used to determine whether
or not to present the form in a manner in which all details can
be entered into it (for a cat addition), or in a manner in
which there are already cat dets in the form, and only the cat
descr can be edited. When the form is submitted, the relevant
update/insert is carried out.
Author: Nicholas Robinson
Email: Nicholas.Robinson@cern.ch
ca8nro@yahoo.co.uk
Created: 15/01/2001
Last Modified: 15/01/2001
*******************************************************************/
# Reset error flag
$editQError = 0;
if($formType != "ADD")
{
$res = mysql_query("SELECT * FROM sbmCATEGORIES WHERE doctype = '"
. "$doctype' AND sname = '$sname'");
if(!$res)
{
$editQError = 1;
print("<P CLASS=\"errorMsg\"><SPAN STYLE=\"color: red\">"
. "ERROR:</SPAN> Unable To Retrieve Details Of <EM>$sname</EM"
. "> Category.</P>");
showCatsEDS($doctype);
} // END if
else
{
if(mysql_num_rows($res) < 1)
{
$editQError = 1;
print("<P CLASS=\"errorMsg\"><SPAN STYLE=\"color: red\">"
. "ERROR:</SPAN> Unable To Retrieve Details Of <EM>$sname"
. "</EM> Category.</P>");
showCatsEDS($doctype);
} // END if
elseif(mysql_num_rows($res) > 1)
{
# Too many rows. Data inconsistency problem.
$editQError = 1;
print("<P CLASS=\"errorMsg\"><SPAN STYLE=\"color: red\">"
. "ERROR:</SPAN> More Than 1 Category Was Found With The "
. "ID <EM>$sname</EM For The <EM>$doctype</EM> Document "
. "Type.<BR>Inform System Administrator.</P>");
showCatsEDS($doctype);
} // END elseif
else
{
$dataRow = mysql_fetch_array($res);
} // END else
} // END else
} // END if
# if the $editQError flag has not been set, continue building form
if(!$editQError)
{
# Get a list of the fields in the sbmCATEGORIES table
$columns = mysql_list_fields(DOCS_DATABASE, "sbmCATEGORIES");
print("<P CLASS=\"errorMsg\">");
print("</P><TABLE WIDTH='90%' BGCOLOR='#D3DCE3' ALIGN='"
. "center' BGCOLOR='#D3DCE3' BORDER=1 CELLSPACING=0 CELLPADDING"
. "=0><TR><TD ALIGN='center'><P STYLE=\"color: blue; text"
. "-align: center; font-size: small; font-weight: bold\">Below, "
. "is a form that allows you to ");
if($formType == "ADD")
{
print("enter the details of a new category for the <EM>"
. "$doctype</EM> document type.<BR><BR>It is important that "
. "when you create a new category, you do not give it a name "
. "that is already in use for a category,<BR>as the category "
. "name must be unique due to the fact that it is used to ide"
. "ntify a given EDS document category.<BR><BR>When the "
. "category has been entered, click on the \"SAVE DETAILS\""
. " button to commit this new category to EDS.");
} // END if
else
{
print("edit a category description for the <EM>$doctype</EM> "
. "document type.<BR><BR>When the description has been "
. "edited, click on the \"SAVE DETAILS\" button to commit the"
. " changes.");
} // END else
print("</P></TD></TR></TABLE>");
drawSeparator();
print("<TABLE WIDTH='100%' ALIGN='center' BORDER=0 CELLSPACING=0"
. " CELLPADDING=0><FORM ACTION='doctypeCategoriesEDS.php' "
. "METHOD='post'><INPUT TYPE='hidden' NAME='");
# We must ensure that we tell our script next time whether to
# insert the details in the form, or simply update the
# description details.
if($formType == "ADD")
{
print("addCatCommit");
} // END if
else
{
print("editCatCommit");
} // END else
print("' VALUE='true'><TR><TH BGCOLOR='#D3DCE3' ALIGN='"
. "right'WIDTH='20%'>Document Type ID: </TH><TD ALIGN"
. "='left'BGCOLOR='#FFFFCC' WIDTH='80%'><INPUT TYPE='readonl"
. "y' NAME='doctype' VALUE='$doctype'></TD></TR><TR>"
. "<TH BGCOLOR='");
if($formType == "ADD")
{
print("#87CEFA' ALIGN='right' WIDTH='20%'>Category ID: "
. "</TH><TD ALIGN='left' WIDTH='80%' BGCOLOR='#FFFFCC'>"
. "<INPUT TYPE='text' NAME='sname' SIZE="
. mysql_field_len($columns, 1)
. "></TD></TR>");
} // END if
else
{
print("#D3DCE3' ALIGN='right' WIDTH='20%'>Category ID: "
. "</TH><TD ALIGN='left' WIDTH='80%' BGCOLOR='#FFFFCC'>"
. "<INPUT TYPE='readonly' NAME='sname' VALUE='$sname'></TD>"
. "</TR>");
} // END else
print("<TR><TH BGCOLOR='#87CEFA' ALIGN='right' WIDTH='20%'>"
. "Category Description: </TH><TD ALIGN='left' WIDTH='"
. "80%' BGCOLOR='#FFFFCC'><INPUT TYPE='text' NAME='lname' ");
if($formType != "ADD")
{
# If we're not adding, then there must be a value to edit!
print("VALUE='" . ereg_replace("'","\\'",
htmlspecialchars($dataRow["lname"]))
. "' ");
} // END if
print("SIZE=" . mysql_field_len($columns, 2)
. "></TD></TR></TABLE>");
# Now we can make another table containing the buttons (save,
# reset & cancel)
print("<TABLE ALIGN='center' CELLSPACING=2 CELLPADDING=2 "
. "BORDER=0><TR><TD ALIGN='right'><INPUT TYPE='button' "
. "VALUE='SAVE DETAILS' onClick=\"submit();\"></TD><TD "
. "ALIGN='center'><INPUT TYPE='button' VALUE='RESET' "
. "onClick=\"reset();\"></TD></FORM><FORM ACTION='"
. "doctypeCategoriesEDS.php' METHOD='post'><INPUT TYPE='"
. "hidden' NAME='doctype' VALUE='$doctype'><TD ALIGN='center"
. "'><INPUT TYPE='button' VALUE='CANCEL' onClick=\"submit();"
. "\"></TD></FORM></TR></TABLE>");
} // END if (!$editQError)
} // END function addEditCatForm()
function displayCategoriesList($doctype,$delCat,$addCatForm,$editCatForm,$editCatCommit,$addCatCommit)
{
global $sname,$lname;
if(isset($delCat))
{
# This is a call to delete a given category from the current doctype
unset($delCat);
$delStr = "DELETE FROM sbmCATEGORIES WHERE doctype = '$doctype' AND"
. " sname = '$sname'";
$delRes = mysql_query($delStr);
if($delRes && mysql_affected_rows() > 0)
{
# Print a message letting the user know of the delete
print("<P STYLE=\"color: red; text-align: center; font-size: "
. "small; font-weight: bold\">Category Deleted</P>");
# Get the date, so that it can be committed for the
# modification date field (md) for the current doctype in
# sbmDOCTYPE
$modifiedDate = makeEDSmdDate();
$mdRes = mysql_query("UPDATE sbmDOCTYPE SET md = '$modifiedDate'"
. " WHERE sdocname = '$doctype'");
if($mdRes)
{
mysql_free_result($mdRes);
} // END if
else
{
print("<SCRIPT TYPE='text/javascript'>alert('Unable To "
. "Update Modification Date For $doctype Doctype.');"
. "</SCRIPT>");
} // END else
$msgTxt ="The $sname category has been deleted from the "
. "$doctype"
. " document type in the " . DOCS_DATABASE . " database."
. "WebSubmit Administrator (";
$msgTxt .= makeDate();
$msgTxt .= ")";
mail(ADMIN_EMAIL, "${doctype}.$sname Category Deleted",
$msgTxt, "From: WebSubmit_Administrator");
# redisplay the table containing the categories
showCatsEDS($doctype);
} // END if
else
{
print("<P CLASS=\"errorMsg\"><SPAN STYLE=\"color: red\">"
. "ERROR:</SPAN> Unable To Delete Category. Retry or Inform"
. " System Administrator.</P>");
} // END else
} // END if
elseif(isset($addCatForm))
{
unset($addCatForm);
addEditCatForm($doctype, "ADD");
} // END elseif
elseif(isset($addCatCommit))
{
# commit new categ to the database
unset($addCatCommit);
if($sname != "" && test_key_legal($sname))
{
$testRes = mysql_query("SELECT * FROM sbmCATEGORIES WHERE "
. "doctype = '$doctype' AND sname = '$sname'");
if($testRes)
{
if(mysql_num_rows($testRes) > 0)
{
# Category does not have unique name. warn user.
print("<P CLASS=\"errorMsg\"><SPAN STYLE=\"color: "
. "red\">Warning.</SPAN> The Category Was Not Given A"
. " Unique Name.<BR>Could Not Commit.</P>");
showCatsEDS($doctype);
} // END if
else
{
$addStr = "INSERT INTO sbmCATEGORIES (doctype, sname, "
. "lname) VALUES('$doctype', '$sname', '$lname')";
$addRes = mysql_query($addStr);
if($addRes && mysql_affected_rows() == 1)
{
print("<P STYLE=\"color: red; font-size: medium; "
. "font-weight: bold; text-align: center\">Categ"
. "ory Added</P>");
# update modify date for doctype
$modifiedDate = makeEDSmdDate();
$mdRes = mysql_query("UPDATE sbmDOCTYPE SET md = '"
. "$modifiedDate' WHERE sdocname = '$doctype'");
if($mdRes)
{
mysql_free_result($mdRes);
} // END if
else
{
print("<SCRIPT TYPE='text/javascript'>alert('Un"
. "able To Update Modification Date For $doctype "
. "Doctype.');</SCRIPT>");
} // END else
$msgTxt = "The $sname Category has been added to the"
. " $doctype doctype in the " . DOCS_DATABASE
. " database.WebSubmit Administrator (";
$msgTxt .= makeDate();
$msgTxt .= ")";
mail(ADMIN_EMAIL, "$sname Category Added To "
. "$doctype",
$msgTxt, "From: WebSubmit_Administrator");
showCatsEDS($doctype);
} // END if
else
{
print("<P CLASS=\"errorMsg\"><SPAN STYLE=\"color: "
. "red\">ERROR:</SPAN> Unable to insert category "
. "correctly.</P>");
showCatsEDS($doctype);
} // END else
} // END else
} // END if
else
{
# Unable to retrieve results of test query. Therefore cant
# commit new cat.
print("<P CLASS=\"errorMsg\"><SPAN STYLE=\"color: red\">"
. "ERROR:</SPAN> Unable to Verify Category Name. Cannot "
. "Insert.</P>");
showCatsEDS($doctype);
} // END else
} // END if
else
{
print("<P STYLE=\"color: red; text-align: center; font-weig"
. "ht: bold; font-size: medium\">Illegal Characters Used In"
. " Category Name. Please Retry.</P>");
showCatsEDS($doctype);
} // END else
} // END elseif
elseif(isset($editCatForm))
{
# In this case, we must display the details of the selected cat
# in a form for editing
unset($editCatForm);
addEditCatForm($doctype, "EDIT", $sname);
} // END elseif
elseif(isset($editCatCommit))
{
# In this case, the user has alterred the details of the selected
# cat, and we must commit the update to the DB.
unset($editCatCommit);
$updRes = mysql_query("UPDATE sbmCATEGORIES SET lname = '$lname' "
. "WHERE doctype = '$doctype' AND sname = '$sname'");
if($updRes)
{
if(mysql_affected_rows() > 0)
{
# Now update modify date for doctype
$modifiedDate = makeEDSmdDate();
$mdRes = mysql_query("UPDATE sbmDOCTYPE SET md = '"
. "$modifiedDate' WHERE sdocname = '$doctype'");
if($mdRes)
{
mysql_free_result($mdRes);
} // END if
else
{
print("<SCRIPT TYPE='text/javascript'>alert('Unabl"
. "e To Update Modification Date For $doctype "
. "Doctype.');</SCRIPT>");
} // END else
$msgTxt = "The description of the $sname Category of the"
. " $doctype doctype has been updated in the "
. DOCS_DATABASE . " database.WebSubmit Administrator (";
$msgTxt .= makeDate();
$msgTxt .= ")";
mail(ADMIN_EMAIL, "${doctype}.$sname Category Updated",
$msgTxt, "From: WebSubmit_Administrator");
print("<P STYLE=\"color: red; font-weight: bold; font-size"
. ": medium; text-align: center\">Category Updated."
. "</P>");
showCatsEDS($doctype);
} // END if
else
{
print("<P CLASS=\"errorMsg\"><SPAN STYLE=\"color: red\">"
. "ERROR:</SPAN> No Categories Were Updated.<BR>Please "
. "Retry.</P>");
showCatsEDS($doctype);
} // END else
} // END if
else
{
print("<P CLASS=\"errorMsg\"><SPAN STYLE=\"color: red\">"
. "ERROR:</SPAN> Unable To Update Category.<BR>Please Retry"
. ".</P>");
showCatsEDS($doctype);
} // END else
} // END elseif
else
{
showCatsEDS($doctype);
} // 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,$doctype);
if (!$auth[0])
outWarning($auth[1] . "<br><br>" . "You are not allowed to access WebSubmit Admin for this type of documents");
else
displayCategoriesList($doctype,$delCat,$addCatForm,$editCatForm,$editCatCommit,$addCatCommit);
/************************End of main script***************************/
</protect>
?>
Event Timeline
Log In to Comment