Page MenuHomec4science

documentEDS.php.wml
No OneTemporary

File Metadata

Created
Sat, Nov 9, 14:30

documentEDS.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="Details 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> &gt; <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 CDS Invenio WML SOURCES.
</protect>
/*********************Function Descriptions***************************/
function displayDocsAndSubs($doctype)
{
/******************************************************************
This function is used to pruduce the entire page. It effectively
performs the queries that retrieve data about the doctype & its
submissions, and then produces the tables that contain this
information.
Author: Nicholas Robinson
Email: Nicholas.Robinson@cern.ch
ca8nro@yahoo.co.uk
Last Modified: 25/01/2001
******************************************************************/
global $URLPATH,$IMAGES;
$queryResult = mysql_query("SELECT * FROM sbmDOCTYPE WHERE sdocname ="
. " '$doctype'");
if($queryResult)
{
# test for multiple or no rows returned
if(mysql_num_rows($queryResult) > 1)
{
# If this clause is reached, too many rows have been returned
# by the query. There should only be 1 row returned. -> We
# must inform the user of this error, and email the
# administrator about it.
print('<H3>ERROR: Too many rows have been returned for the '
. $doctype . ' document type from the DOCTYPE table</H3>');
} // END if
elseif(mysql_num_rows($queryResult) < 1)
{
# In this case, no rows have been returned, which means we
# must have a data consistency error going on.
print('<H3>ERROR: No data has been returned from the DOCTYPE'
. ' table for the '.$doctype.' document type</H3>');
} // END elseif
else
{
# In this case, 1 row has been returned, which is perfect!
# Get a list of all fields in the DOCTYPE table...
$doctypeColumns = mysql_list_fields(DOCS_DATABASE, "sbmDOCTYPE");
# Open a table to hold the data...
print('<TABLE ALIGN=center BORDER=1 CELLSPACING=0 '
. 'CELLPADDING=0 WIDTH=85%>');
# Now make the table/form that will be used to contain all
# data about the document type...
$numTblFlds = mysql_num_fields($doctypeColumns);
$dataRow = mysql_fetch_array($queryResult);
for($indx = 0; $indx < $numTblFlds; $indx++)
{
# First, display the field name (but give each field a
# meaningful name)...
print('<TR><TH BGCOLOR=#CCDDFF ALIGN=right '
. 'WIDTH=30%>');
# Get the name of the current field...
$fName = mysql_field_name($doctypeColumns, $indx);
if($fName == "ldocname")
{
print("Document Type Description");
} // END if
elseif($fName == "sdocname")
{
print("Document Type ID");
} // END elseif
elseif($fName == "cd")
{
print("Creation Date");
} // END elseif
elseif($fName == "md")
{
print("Modification Date");
} // END elseif
else
{
print("$fName");
} // END else
print(":&nbsp;</TH>");
# Now display the data in a table field...
print('<TD BGCOLOR=#FFFFCC ALIGN=left>');
# If it is the description field, display it as html - otherwise just
# display the field normally..
if(mysql_field_name($doctypeColumns, $indx) == "description")
{
print("$dataRow[$indx]");
} // END if
else
{
print(ereg_replace("'", "&#39;",
htmlspecialchars($dataRow[$indx])));
} // END else
print("&nbsp;</TD></TR>");
} // END for
# Now close the doctype table...
print("</TABLE>");
# Now offer a button to edit the document types details..
print('<FORM ACTION="editDoctypeEDS.php" METHOD=post>'
. '<TABLE BORDER=0 ALIGN=center CELLSPACING=4 CELLPADDING=0 '
. '><TR>'
. '<INPUT TYPE=hidden NAME=doctype VALUE='.$doctype.'>'
. '<TD>'
. '<INPUT TYPE=button VALUE="EDIT DOCUMENT TYPE DETAILS"'
. ' onClick="submit();"></TD></FORM>');
# Now we can display a button on which the user can click
# in order to display the CATEGORIES relating to this
# doctype
print('<FORM ACTION="doctypeCategoriesEDS.php" METHOD="'
. 'post"'
. '><INPUT TYPE=hidden NAME=doctype VALUE='.$doctype
. '><TD ALIGN=center'
. '><INPUT TYPE=button VALUE="VIEW CATEGORIES" onClick'
. '="submit();"></TD></FORM>');
print('<FORM ACTION="referees.py" METHOD="'
. 'post"'
. '><INPUT TYPE=hidden NAME=doctype VALUE='.$doctype
. '><TD ALIGN=center'
. '><INPUT TYPE=button VALUE="SIMPLE APPROVAL REFEREES" onClick'
. '="submit();"></TD></TR></TABLE></FORM>');
# Make a horizontal rule to divide the page sections...
drawSeparator();
####################
# Now, we can display each of the actions (submissions) for
# the current doctype...
$actionsQuery = mysql_query("SELECT * FROM sbmIMPLEMENT WHERE "
. "docname = '$doctype' ORDER BY actname");
if($actionsQuery)
{
# In this case, the query executed without error.
# Display a title for this new page section...
print('<P STYLE="font-size: large; color: navy; '
. 'text-align: left">Implemented actions for the '
. '<EM>'.$doctype.'</EM> document type:</P>');
# Now that the section heading has been displayed, the
# table of actions can be displayed on-screen..
if(mysql_num_rows($actionsQuery) != 0)
{
# List columns in the IMPLEMENT TABLE
$implCols = mysql_list_fields(DOCS_DATABASE, "sbmIMPLEMENT");
# Get the number of fields in the IMPLEMENT table...
$imlNoFields = mysql_num_fields($implCols);
# Display the actions for the current doctype in a
# table..
print('<TABLE ALIGN=center WIDTH=90% BORDER=1 '
. 'CELLPADDING=0 CELLSPACING=0><TR '
. 'BGCOLOR=#CCDDFF>');
for($cnt = 1; $cnt < $imlNoFields; $cnt++)
{
# Don't display the subname column..
if(mysql_field_name($implCols, $cnt) != "subname")
{
# Get the current field name...
$curfName = mysql_field_name($implCols, $cnt);
print("<TH>");
# Rename the columns..
if($curfName == "displayed")
{
print("On Submission<BR>Page");
} // END if
elseif($curfName == "actname")
{
print("Action<BR>Name");
} // END elseif
elseif($curfName == "nbpg")
{
print("No.<BR>Pages");
} // END elseif
elseif($curfName == "cd")
{
print("Creation<BR>Date");
} // END elseif
elseif($curfName == "md")
{
print("Modification<BR>Date");
} // END elseif
elseif($curfName == "buttonorder")
{
print("Button<BR>Order");
} // END elseif
elseif($curfName == "statustext")
{
print("Status<BR>Text");
} // END elseif
else
{
print("$curfName");
} // END else
print("</TH>");
} // END if
} // END for
# Make 1 more column the subname column (it is 3rd in the
# IMPLEMENT table)
print("<TH>Edit<br>Submission<br>Pages</TH>");
# Make 1 more column for editing functions
print("<TH>Edit<br>Functions</TH>");
# Make 1 more column for editing the submission item
print("<TH>Edit<br>Submission</TH>");
# Now make 1 more column (in which the delete button
# will be placed)...
print("<TH>Delete<br>Submission</TH>");
# Now the header row can be closed..
print("</TR>");
# Display the table to hold the action data - links 'n'
# all
while($actDataRow = mysql_fetch_array($actionsQuery))
{
print('<TR BGCOLOR=#FFFFCC>');
for($count = 1; $count < $imlNoFields; $count++)
{
# Don't display the subname column..
if(mysql_field_name($implCols, $count) !=
"subname")
{
print('<TD ALIGN=center>');
if(mysql_field_name($implCols, $count) ==
"actname")
{
# Make a link to the page to view details of
# an action
print('<A HREF="viewActionEDS.php?actname='
. ereg_replace("'", "&#39;",
htmlspecialchars($actDataRow[$count]))
. '&caller=documentEDS.php&doctype='
. $doctype.'">'
. ereg_replace("'", "&#39;",
htmlspecialchars($actDataRow[$count]))
. '</A>');
} // END if
else
{
print(ereg_replace("'", "&#39;",
htmlspecialchars($actDataRow[$count])));
} // END else
print("&nbsp;</TD>");
} // END if
} // END for
# column to edit pages...
print('<TD ALIGN=center><A HREF=viewEditSub'
. 'missionEDS.php?subname='
. $actDataRow["subname"] . '&doctype='.$doctype.'>'
. '<IMG SRC="'.$IMAGES.'/edit1.gif" border=0>'
. '</A></TD>');
# column to edit functions...
print('<TD ALIGN=center><A HREF=action'
. 'Functions.php?action='
. $actDataRow["actname"] . '&doctype='.$doctype.'>'
. '<IMG SRC="'.$IMAGES.'/edit1.gif" border=0>'
. '</A></TD>');
# column to edit the submission...
print('<TD ALIGN=center><A HREF=edit'
. 'ActionDets.php?actname='
. $actDataRow["actname"] . '&doctype='.$doctype.'>'
. '<IMG SRC="'.$IMAGES.'/edit1.gif" border=0>'
. '</A></TD>');
# Now, insert the button for deleting a submission
print('<FORM ACTION=documentEDS.php METHOD=post '
. 'onSubmit="if(confirm(\'Really delete this '
. 'submission, its pages and all of their '
. 'elements?\')) { return true; } else { return '
. 'false; }"><INPUT TYPE=hidden NAME=subname'
. ' VALUE="' . $actDataRow["subname"]
. '"><INPUT TYPE=hidden NAME=doctype VALUE="'
. $doctype.'"><INPUT TYPE=hidden NAME=deleteSub'
. ' VALUE=true><TD ALIGN=center VALIGN="'
. 'middle"><INPUT TYPE=image SRC="'.$IMAGES.'/answer'
. '_bad.gif" WIDTH=14 HEIGHT=14 BORDER=0 ALT="Delet'
. 'e Submission" onClick="submit();"></TD>'
. '</FORM>');
print("</TR>");
} // END while
# Close up the table of submissions...
print("</TABLE>");
} // END if
else
{
# In this case, the current doctype has no actions..
print('<H3 STYLE="color: green">The <EM>$doctype</EM>'
. ' document type currently has no submissions.'
. '</H3>');
} // END else
# Now that the submissions for the current doctype have
# been displayed (or not), we can add a botton to allow the
# addition of new submissions to that doctype..
print('<FORM ACTION="newSubmissionEDS.php" METHOD=post>'
. '<INPUT TYPE=hidden NAME=doctype VALUE='.$doctype.'>'
. '<TABLE ALIGN=center WIDTH=100% CELLSPACING=0 '
. 'CELLPADDING=0 BORDER=0><TR><TD ALIGN=center>'
. '<INPUT TYPE=button VALUE="ADD A NEW ACTION" '
. 'onClick="submit();"></TD></TR></TABLE>'
. '</FORM>');
# Now, we can display a "FINISHED" button..
print('<FORM ACTION="index.php" METHOD=post><TABLE'
. ' BORDER=0 ALIGN=center WIDTH=100% CELLSPACING=0'
. ' CELLPADDING=0><TR><TD ALIGN=center><INPUT '
. 'TYPE=button VALUE=FINISHED onClick="submit();"'
. '></TD></TR></TABLE></FORM>');
} // END if
else
{
# In this case, there was an error while trying to get the
# actions for the given doctype from IMPLEMENT
print('<H2 STYLE="text-align: center; color: navy">'
. '<SPAN STYLE="color: red">ERROR:</SPAN> Unable to '
. 'retrieve data for the <EM>'.$doctype.'</EM> document type'
. ' from the <EM>IMPLEMENT</EM> table.<BR>Please inform '
. 'the system administrator.</H2>');
} // END else
} // END else
} // END if($queryResult)
else
{
# In this case, it was not possible to query the DOCTYPE table.
# This means that there is no point in continuing with the
# displaying of other data, so an error message can be output,
# and we can terminate processing
print('<H2 STYLE="text-align: center; color: navy"><SPAN '
. 'STYLE="color: red">ERROR:</SPAN> Unable to retrieve data '
. 'from the <EM>DOCTYPE</EM> table.<BR>Please inform the system'
. ' administrator.</H2>');
} // END else
} // END function displayDocsAndSubs($doctype)
//************
function killSub($subname)
{
/*******************************************************************
This function simply removes the row for the submission whose
name is passed to it from the actual IMPLEMENT table.
Author: Nicholas Robinson
Email: Nicholas.Robinson@cern.ch
ca8nro@yahoo.co.uk
Created: 25/01/2001
Last Modified: 25/01/2001
*******************************************************************/
# Delete the entry for the doctype from the IMPLEMENT table...
$subDelRes = mysql_query("DELETE FROM sbmIMPLEMENT WHERE subname = '"
. "$subname'");
if($subDelRes)
{
# Get the number of rows deleted..
$noRowsDel = mysql_affected_rows();
if($noRowsDel == 1)
{
mysql_free_result($subDelRes);
print('<SCRIPT TYPE="text/javascript">alert("'.$subname
. ' submission deleted.");</SCRIPT>');
$msgTxt = "The $subname submission has been deleted "
. "WebSubmit Administrator(" . makeDate()
. ")";
mail(ADMIN_EMAIL, "$subname Submission Deleted", $msgTxt,
"From: WebSubmit_Administrator");
} // END if
elseif($noRowsDel < 1)
{
# Couldn't delete the submission.
mysql_free_result($subDelRes);
print('<SCRIPT TYPE="text/javascript">alert("Unable to '
. 'delete submission. Please retry.");</SCRIPT>');
} // END elseif
else
{
# Multiple rows deleted
mysql_free_result($subDelRes);
print('<SCRIPT TYPE="text/javascript">alert("'.$subname
. ' submission deleted.HOWEVER, '.$noRowsDel
. ' submission records were deleted from database. It is '
. 'possible that there were many records for the same '
. 'submission, which would break consistency rules.'
. 'They have now however, been removed.");</SCRIPT>');
$msgTxt = "The $subname submission has been deleted "
. ". However, $noRowsDel rows were "
. "deleted from IMPLEMENT for this submission. It is "
. "possible that for some reason, there were several "
. "rows for the same submission in this table."
. "WebSubmit Administrator(" . makeDate() . ")";
mail(ADMIN_EMAIL, "ERROR: Several Records Deleted "
. "For $subname Submission", $msgTxt,
"From: WebSubmit_Administrator");
} // END else
} // END if
else
{
print('<SCRIPT TYPE="text/javascript">alert("Unable to delete'
. ' $subname.Please Retry.");</SCRIPT>');
} // END else
} // END function killSub($subname)
//************
function deleteAsubmission($subname, $doctype)
{
/*******************************************************************
This function has the purpose of deleting a submission and any
elements that it may have, from an EDS document type. If the
deletion is successful, the user & administrator will be informed
of this fact. If there are any serious problems with the
deletion, the user & admin will also be informed.
It is worth noting that this deletion process will not remove the
"SUBMISSION_NAME.php" file from the access/protection directory
that is used for the various security by the Apache webserver.
This is because my supervisor informed me that doing this would
be unnecessessary.
Author: Nicholas Robinson
Email: Nicholas.Robinson@cern.ch
ca8nro@yahoo.co.uk
Created: 25/01/2001
Last Modified: 25/01/2001
*******************************************************************/
# retrieve action name
$res = mysql_query("SELECT actname from sbmIMPLEMENT where subname='$subname'");
$row = mysql_fetch_array($res);
$action = $row['actname'];
# delete functions
$res = mysql_query("DELETE FROM sbmFUNCTIONS where doctype='$doctype' and action='$action'");
# First, execute a query to see how many elements there are for the
# current submission
$noElesRes = mysql_query("SELECT * FROM sbmFIELD WHERE subname = '"
. "$subname'");
if($noElesRes)
{
# Good, query success
$noEles = mysql_num_rows($noElesRes);
# Free up the $noElesRes result set to quicken the pace
mysql_free_result($noElesRes);
# Delete all elements for the current doctype submission
$eleDelRes = mysql_query("DELETE FROM sbmFIELD WHERE subname = '"
. "$subname'");
if($eleDelRes)
{
# Get the date for the created date & modification date
$theDate = makeEDSmdDate();
if(mysql_affected_rows() == $noEles)
{
mysql_free_result($eleDelRes);
# Update the md field for our doctype
updateEDSDOCTYPEmd($doctype, $theDate);
# Now carry on with the deletion of the submission
killSub($subname);
} // END if
elseif(mysql_affected_rows() > $noEles)
{
# Too many rows deleted - error
print('<SCRIPT TYPE="text/javascript">alert("ERROR: '
. 'When the page elements of the '.$subname.' submission '
. 'were deleted,' . mysql_affected_rows()
. ' elements were deleted, when there were only '.$noEles
. ' elements to delete.The deletion of the '
. 'submission was however, continued.");</SCRIPT>');
$msgTxt = "An error ocurred when the page elements of the"
. "$subname submission were deleted. A total of "
. mysql_affected_rows() . " page elements were "
. "deleted when there were only $noEles page elements to "
. "delete. Despite this fact, the deletion process was "
. "continued, as there is no way to counteract this fact,"
. " or determine which extra elements were deleted."
. "WebSubmit Administrator(" . makeDate() . ")";
mail(ADMIN_EMAIL, "ERROR: Too Many Elements Deleted "
. "During $subname Submission Deletion", $msgTxt,
"From: WebSubmit_Administrator");
mysql_free_result($eleDelRes);
# Update the md field for our doctype
updateEDSDOCTYPEmd($doctype, $theDate);
# Now carry on with the deletion of the submission
killSub($subname);
} // END elseif
else
{
# Too few elements deleted - error
mysql_free_result($eleDelRes);
# Update the md field for our doctype
updateEDSDOCTYPEmd($doctype, $theDate);
print('<SCRIPT TYPE="text/javascript">alert("ERROR: '
. 'When deleting the elements for the '.$subname
. ' submission, not all elements were deleted. The '
. 'submission itself has therefore been left un-dele'
. 'ted, and should be deleted again.");</SCRIPT>');
} // END else
} // END if
else
{
# could not delete
print('<SCRIPT TYPE="text/javascript">alert("Unable To '
. 'Perform Delete. Please Retry.");</SCRIPT>');
} // END else
} // END if
else
{
print('<SCRIPT TYPE="text/javascript">alert("Unable To Perfor'
. 'm Deletion - Could Not Retrieve Details Of Submissions '
. 'Page Elements.Please Retry.");</SCRIPT>');
} // END else
} // END function deleteAsubmission($subname, $doctype)
/**********************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
{
if(isset($deleteSub))
{
unset($deleteSub);
# Delete submission
deleteAsubmission($subname, $doctype);
# Redisplay the page
displayDocsAndSubs($doctype);
} // END if
else
{
# display page
displayDocsAndSubs($doctype);
} // END else
}
/************************End of main script***************************/
?>

Event Timeline