Page MenuHomec4science

pageDetsEDS.php.wml
No OneTemporary

File Metadata

Created
Sat, Sep 21, 12:33

pageDetsEDS.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 Submission Page <protect><?print "$pageNumber of $subname"?></protect>" \
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.
function makeSubmPgePrev($res, $pageNumber)
{
/******************************************************************
This function has the task of creating and displaying the table
that contains a preview of the elements that make up a submission
page. The function is passed a result pointer that points to a
given submission pages contents. For each row of this pointer
(which indicates a given element that appears on the relevant
page), this function retrieves the configuration information for
this element from the sbmFIELDDESC table, and uses this information
to display the element.
******************************************************************/
# Open an outer table, in which another table will be placed. The
# inner table will contain the preview of the appearance of the page
# with its current elements can be shown...
print("<P STYLE=\"color: navy; font-size: large; text-align: "
. "left\">Page Preview\n<br>&nbsp;");
print("<TABLE WIDTH='100%' ALIGN='center' BORDER=1 CELLSPACING=0 "
. "CELLPADDING=0 BGCOLOR='papayawhip'>\n<TR><TD ALIGN='center'>\n");
# Open the inner table, and a dummy form so that the input elements
# can be shown
print("<TABLE ALIGN='center' BORDER=0 CELLPADDING=0 "
. "CELLSPACING=0>\n<FORM NAME='Dummy'>\n");
if(mysql_num_rows($res) < 1)
{
# This submission page is empty. Just place a nice RED text
# message in the table to let the user know this.
print("<TR>\n<TD ALIGN='center'>\n<P STYLE=\"font-size: large;"
. " color: red; text-align: center\">[Page Has No Elements]"
. "</P>\n</TD>\n</TR>\n");
} // END if
else
{
# In this case, the page has elements to display...
# Open the current row and cell of the table
print("<TR>\n<TD ALIGN='left'>\n");
while($anItem = mysql_fetch_array($res))
{
# For each row (which is an item), determine the properties
# that should be used to display the item by querying the
# sbmFIELDDESC table for data regarding it...
$configRes = mysql_query("SELECT * FROM sbmFIELDDESC WHERE name"
. " = '" . $anItem["fidesc"] . "'");
if($configRes)
{
$numItemConfigs = mysql_num_rows($configRes);
$anItemsProperties = mysql_fetch_array($configRes);
# Display the text that will accompany the image...
print($anItem["fitext"] . "&nbsp;");
if($anItemsProperties["type"] == "T")
{
# Our item is an HTML textarea input type.
# Display it...
print("<TEXTAREA NAME=\"" . $anItem["fidesc"] . "\""
. "ROWS=" . $anItemsProperties["rows"] . " COLS="
. $anItemsProperties["cols"] . ">"
. $anItemsProperties["val"] . "</TEXTAREA>");
} // END if
elseif($anItemsProperties["type"] == "I")
{
# Our item is a text input type.
# Display it...
print("<INPUT TYPE=\"text\" NAME=\"" . $anItem["fidesc"]
. "\" SIZE=" . $anItemsProperties["size"] . " VALUE=\""
. $anItemsProperties["val"] . "\">");
} // END elseif
elseif($anItemsProperties["type"] == "H")
{
# Our item is a hidden input field.
print("<INPUT TYPE=\"hidden\" NAME=\""
. $anItem["fidesc"] . "\" VALUE=\""
. $anItemsProperties["val"] . "\">");
} // END elseif
elseif($anItemsProperties["type"] == "F")
{
# Our item is a file input type.
# Display it
print("<INPUT TYPE=\"file\" NAME=\"" . $anItem["fidesc"]
. "\" SIZE=" . $anItemsProperties["size"]
. ">");
} // END elseif
elseif($anItemsProperties["type"] == "D")
{
# Our item is some other form of input (e.g. a select
# list, or a radio button, etc). Basically, it has a
# description in the database, which is to be used.
print($anItemsProperties["fidesc"]);
} // END elseif
elseif($anItemsProperties["type"] == "S")
{
# Our item is some other form of input (e.g. a select
# list, or a radio button, etc). Basically, it has a
# description in the database, which is to be used.
print($anItemsProperties["fidesc"]);
} // END elseif
elseif($anItemsProperties["type"] == "R")
{
# Our item is some other form of input (e.g. a select
# list, or a radio button, etc). Basically, it has a
# description in the database, which is to be used.
print("<SPAN STYLE=\"color: red; font-size: medium; "
. "text-align: left\">[Response Input Type: evaluate only at runtime]"
. "</SPAN>\n");
} // END elseif
else
{
# Oh dear! This is a field type that we don't recognise
print("<SPAN STYLE=\"color: red; font-size: medium; "
. "text-align: left\">[Unrecognised Input Type]"
. "</SPAN>\n");
} // END else
# If the number of rows returned by the query of the
# sbmFIELDDESC table was greater than 1, we can display a
# small GREEN message so that the user to be aware of this
# error
if($numItemConfigs > 1)
{
print("&nbsp;&nbsp;&nbsp;&nbsp;More than one row of "
. "configuration information retrieved. Using first.");
} // END if
} // END if
else
{
# Oh dear! We couldn't query the sbmFIELDDESC table. Better
# give the user an error message, which will sit in the
# place of the expected element...
print("<SPAN STYLE=\"color: red; text-align: left; "
. "font-size: medium\">ERROR: Unable to Execute A Query on"
. " the sbmFIELDDESC Table for this Element.</SPAN>\n");
} // END else
} // END while
# We can now close the current row, as we are finished with it
print("</TD>\n</TR>\n");
} // END else
# Close the form and the inner table...
print("</FORM></TABLE>\n");
# Now close the page preview table...
print("</TD>\n</TR>\n</TABLE>\n");
} // END function makeSubmPgePrev($res)
//*****************
function buildPgeElemntTbl($res, $subname, $pageNumber, $nPgs,
$doctype)
{
/******************************************************************
This function has the task of making the second section of the
page to display the details of a given submission page. The
section created by this function, displays a table of elements
that make up the submission page. Using the tables created by
this function, the user can move individual elements to different
positions on the page, delete elements from the submission page,
click buttons to add new elements to the page, click buttons to
edit the details of individual elements, etc.
The function is passed several parameters, many of which are used
for making the various forms located within the table that the
function creates. The first parameter is the "$res" parameter.
This is a result pointer that contains a reference to several
rows relating to the current page of the current submission.
Each row effectively references an element of the page. The
function is also passed the $link variable, the $subname value
(which is the unique identifier for a submission), the
$pageNumber value (which is the number of the page of the
submission that the given element appears on), the $nPgs value
(which is the number of pages that make up the given submission),
and the $doctype variable (which is the document type that the
submission belongs to).
******************************************************************/
global $IMAGES;
print("<P STYLE=\"color: navy; font-size: large; text-align: "
. "left\">Elements on this Page\n");
# Now that we have displayed the "preview page", we need to reset
# the query result set that held the details of each page element
# on the given page back to the first row, so that we can loop
# throught it again in order to display the configuration of the
# elements on the page.
mysql_data_seek($res, 0);
# Okay, $res is now pointing at the first result, so we can begin
# making a table of details for each of the elements...
# Get a list of all fields in the sbmFIELD table...
$fieldCols = mysql_list_fields(DOCS_DATABASE, "sbmFIELD");
# Get the number of fields in the sbmFIELD table...
$noFields = mysql_num_rows($fieldCols);
# Get the number of elements on the page...
$noElements = mysql_num_rows($res);
# we want to output the fields of the result set in a certain
# order. To do this, we don't want to have to write the code many
# times. This means that we can simply make an array, whereby each
# cell has an index number (corresponding to a certain field of the
# result set), and loop through the cells of this array (0 to
# whatever). Using the integer value contained within each cell of
# the array, we can display that row in the order we want to.
$colOrder = array(2, 3, 1, 4, 5, 6, 7, 8, 9);
# Make another array, that contains the names to be given to each
# column in the table. This array corresponds with the above
# indexes one.
$colNames = array("Item No", "Name", "Page No", "Element Label",
"Level", "Short Desc", "Check", "Creation Date",
"Modification Date");
# get the size of the array, to determine where to end our loop
$noCols2show = count($colOrder);
print("<TABLE WIDTH='100%' ALIGN='center' BORDER=1 CELLSPACING=0 "
. "CELLPADDING=0>\n<TR BGCOLOR='#CCDDFF'>\n");
# Now, display the titles for the table...
for($count = 0; $count < $noCols2show; $count++)
{
if($count == 1)
{
# If we have displayed the first field, we must now include
# another field for some arrow buttons to be placed in...
print("<TH>&nbsp;</TH>\n");
} // END if
print("<TH>" . $colNames[$count] . "</TH>\n");
} // END for
# Now make two more cells (the last 2 columns), for the edit button
# an the delete button (1 column for edit, 1 for delete)
print("<TH>&nbsp;</TH>\n<TH>&nbsp;</TH>\n</TR>\n");
# Set a row counter....
$aCounter = 0;
# Now, put all of the query dynaset rows into an array...
while($element = mysql_fetch_array($res))
{
$allElements[$aCounter] = $element;
$aCounter++;
} // END while
# Now fill in the table with the details of each element...
for($i = 0; $i < $noElements; $i++)
{
print("<TR BGCOLOR='#FFFFCC'>\n");
for($count = 0; $count < $noCols2show; $count++)
{
if($count == 0)
{
# In this place, we want to put a select list containing
# the numbers of each page element. These numbers
# determine the order on the page in which the elements
# appear. The number that the element is currently
# desegnated will be "checked", but the numbers of the
# other elements are also available for selection. If the
# user selects another number, the element is moved into
# that position, and the element that was in this position
# is moved down a place, as are the others below it.
print("<FORM ACTION='pageDetsEDS.php' METHOD='post'>\n"
. "<TD ALIGN='center'><INPUT TYPE='hidden' NAME='"
. "moveDigital' VALUE='true'><INPUT TYPE='hidden' NAME='"
. "subname' VALUE='$subname'><INPUT TYPE='hidden' NAME='"
. "pageNumber' VALUE='$pageNumber'><INPUT TYPE='hidden' "
. "NAME='currFieldnb' VALUE='"
. ($i+1) . "'><INPUT TYPE='hidden'"
. " NAME='fidesc' VALUE='" . $allElements[$i][$colOrder[1]]
. "'><INPUT TYPE='hidden' NAME='maxRowNo' VALUE='"
. "$noElements'><INPUT TYPE='hidden' NAME='nPgs' VALUE='"
. "$nPgs'><INPUT TYPE='hidden' NAME='doctype' VALUE='"
. "$doctype'><SELECT NAME='elementPos' onChange=\""
. "if(this.options[this.selectedIndex].value != "
. ($i+1) . ") { submit(); }\">");
for($index = 1; $index <= $noElements; $index++)
{
print("<OPTION VALUE='$index'");
if($i+1 == $index)
{
print(" SELECTED");
} // END if
print(">$index</OPTION>\n");
} // END for
print("</SELECT>\n</TD>\n</FORM>");
} // END if
elseif($count == 1)
{
# Add the "up" arrow element...
print("<TD ALIGN='center'><TABLE WIDTH='100%' BORDER=0 "
. "CELLPADDING=0 CELLSPACING=0><TR>"
. "<FORM ACTION='pageDetsEDS.php' METHOD='post'>"
. "<INPUT TYPE='hidden' NAME='moveUp' VALUE='true'>"
. "<INPUT TYPE='hidden' NAME='subname' VALUE='$subname'>"
. "<INPUT TYPE='hidden' NAME='pageNumber' VALUE="
. "'$pageNumber'><INPUT TYPE='hidden' NAME='currFieldnb' "
. "VALUE='" . $allElements[$i][$colOrder[0]] . "'><INPUT"
. " TYPE='hidden' NAME='fidesc' VALUE='"
. $allElements[$i][$colOrder[1]] . "'>"
. "<INPUT TYPE='hidden' NAME='nPgs' VALUE='$nPgs'>"
. "<INPUT TYPE='hidden' NAME='doctype' VALUE='$doctype'>");
if($i == 0)
{
# In this case, this is the first element on the page
print("<TD ALIGN='center'><IMG SRC='".$IMAGES."/up.gif' "
. "BORDER=0 WIDTH=11 HEIGHT=15 ALT='Element Already "
. "First On Page!'>");
} // END if
else
{
print("<INPUT TYPE='hidden' NAME='previousfiDesc' VALUE"
. "='" . $allElements[$i - 1][$colOrder[1]] . "'>"
. "<INPUT TYPE='hidden' NAME='previousFieldnb' VALUE='"
. $allElements[$i - 1][$colOrder[0]] . "'><TD ALIGN='"
. "center'><INPUT TYPE='image' SRC='".$IMAGES
. "/up.gif' BORDER=0 WIDTH=11 HEIGHT=15>");
} // END else
# Now, we can add the "down" arrow element...
print("</TD></FORM></TR>"
. "<FORM ACTION='pageDetsEDS.php' METHOD='post'>"
. "<INPUT TYPE='hidden' NAME='moveDown' VALUE='true'>"
. "<INPUT TYPE='hidden' NAME='subname' VALUE='$subname'>"
. "<INPUT TYPE='hidden' NAME='pageNumber' VALUE="
. "'$pageNumber'><INPUT TYPE='hidden' NAME='currFieldnb' "
. "VALUE='" . $allElements[$i][$colOrder[0]] . "'><INPUT"
. " TYPE='hidden' NAME='fidesc' VALUE='"
. $allElements[$i][$colOrder[1]] . "'>"
. "<INPUT TYPE='hidden' NAME='nPgs' VALUE='$nPgs'>"
. "<INPUT TYPE='hidden' NAME='doctype' VALUE='$doctype'>");
if($i == ($noElements - 1))
{
# In this case, this is the last element on the page
print("<TD ALIGN='center'><IMG SRC='".$IMAGES."/down.gif'"
. "BORDER=0 WIDTH=11 HEIGHT=15 ALT='Element Is Already "
. "Last On Page!'>");
} // END if
else
{
print("<INPUT TYPE='hidden' NAME='nextfiDesc' VALUE"
. "='" . $allElements[$i + 1][$colOrder[1]] . "'>"
. "<INPUT TYPE='hidden' NAME='nextFieldnb' VALUE='"
. $allElements[$i + 1][$colOrder[0]] . "'><TD ALIGN='"
. "center'><INPUT TYPE='image' SRC='".$IMAGES
. "/down.gif' BORDER=0 WIDTH=11 HEIGHT=15>");
} // END else
print("</TD></FORM></TR></TABLE></TD>");
# Now, we want to make this field a link to the page
# allowing the editing of these dets...
print("<TD ALIGN='center'>\n<A HREF='"
. "elementConfigDetsEDS.php?"
. "name=" . ereg_replace("'", "&#39;",
htmlspecialchars($allElements[$i][$colOrder[$count]]))
. "&subname=$subname&pageNumber=$pageNumber&nPgs=$nPgs&"
. "doctype=$doctype&caller=pageDetsEDS.php'>"
. ereg_replace("'", "&#39;",
htmlspecialchars($allElements[$i][$colOrder[$count]]))
. "</A>&nbsp;</TD>");
} // END elseif
else
{
# Print the relevant element of the result set...
print("<TD ALIGN='center'>\n"
. ereg_replace("'", "&#39;",
htmlspecialchars($allElements[$i][$colOrder[$count]]))
. "&nbsp;</TD>\n");
} // END else
} // END for
# Now that we have output all of our actual data, we can output
# a form, and an image button in the 2nd last column, which will
# allow the user to edit the given page elements details...
print("<FORM ACTION='editPageElementEDS.php' METHOD='post'>\n"
. "<INPUT TYPE='hidden' NAME='fidesc' VALUE='"
. $allElements[$i][$colOrder[1]] . "'><INPUT TYPE='hidden' "
. "NAME='fieldnb' VALUE='" . $allElements[$i][$colOrder[0]]
. "'><INPUT TYPE='hidden' NAME='pageNumber' VALUE='$pageNumber'>"
. "<INPUT TYPE='hidden' NAME='subname' VALUE='$subname'>"
. "<INPUT TYPE='hidden' NAME='nPgs' VALUE='$nPgs'>"
. "<INPUT TYPE='hidden' NAME='doctype' VALUE='$doctype'>"
. "<TD ALIGN='center' VALIGN='middle'>\n<INPUT TYPE='image' "
. "SRC='".$IMAGES."/edit1.gif' BORDER=0 onClick=\"submit();\""
. " ALIGN='center'></TD>\n</FORM>\n");
# Now that we have output the "edit details" button, we can make
# one last column that, when clicked, allows us to delete an
# element from the current page.
print("<FORM ACTION='pageDetsEDS.php' METHOD='post' onSubmit=\""
. "if(confirm('The " . $allElements[$i][$colOrder[1]]
. " Element Will Be Permenantly Deleted From This Page.\\n"
. "Are You Sure You Wish To Continue?')) { return true; } else {"
. " return false; }\">\n<INPUT "
. "TYPE='hidden' NAME='deleteElement' VALUE='true'><INPUT TYPE"
. "='hidden' NAME='subname' VALUE='$subname'><INPUT TYPE='hidden"
. "' NAME='pageNumber' VALUE='$pageNumber'><INPUT TYPE='hidden' "
. "NAME='currFieldnb' VALUE='" . $allElements[$i][$colOrder[0]]
. "'><INPUT TYPE='hidden' NAME='fidesc' VALUE='"
. $allElements[$i][$colOrder[1]] . "'><INPUT TYPE='hidden' "
. "NAME='maxRowNo' VALUE='$noElements'><INPUT TYPE='hidden' "
. "NAME='nPgs' VALUE='$nPgs'><INPUT TYPE='hidden' NAME='doctype'"
. " VALUE='$doctype'><TD ALIGN='center' VALIGN='middle'>\n<INPUT"
. " TYPE='image' SRC='".$IMAGES."/answer_bad.gif' BORDER=0 ALIGN='"
. "center' WIDTH=14 HEIGHT=14></TD>"
. "\n</FORM>\n");
# Now we can close the current row of the table
print("</TR>\n");
} // END for
# Now, close up the table...
print("</TABLE>\n");
# Now that the table of elements has been displayed, provide a
# button, which when clicked, will allow the user to add an element
# to the current page of the submission.
print("<FORM ACTION='addElement2PageEDS.php' METHOD='post'>"
. "<INPUT TYPE='hidden' NAME='doctype' VALUE='$doctype'>\n"
. "<INPUT TYPE='hidden' NAME='subname' VALUE='$subname'>\n"
. "<INPUT TYPE='hidden' NAME='nPgs' VALUE='$nPgs'>\n"
. "<INPUT TYPE='hidden' NAME='pageNumber' VALUE='$pageNumber'>\n"
. "<INPUT TYPE='hidden' NAME='noElements' VALUE='$noElements'>\n"
. "<TABLE WIDTH='100%' ALIGN='center' CELLSPACING=0 CELLPADDING=0 "
. "BORDER=0>\n<TR>\n<TD ALIGN='center'>\n<INPUT TYPE='button' "
. "VALUE='ADD ELEMENT TO PAGE' onClick=\"submit();\">\n</TD>\n</TR>"
. "\n</TABLE>\n</FORM>\n");
# Make a horizontal rule to divide the page sections...
drawSeparator();
# Now that we have displayed all of the details of the elements, it
# is possible to display a series of links to the other pages of the
# given submission...
print("<TABLE BORDER=0 ALIGN='center' WIDTH='100%' CELLSPACING=0"
. " CELLPADDING=0>\n<TR>\n<TD ALIGN='center'>\n");
# Now, display links to all of the other pages...
for($c = 1; $c <= $nPgs; $c++)
{
if($c == $pageNumber)
{
# Just display the name of the current page...
print("<SMALL>[$subname Page $c]&nbsp;</SMALL>");
} // END if
else
{
# Display an actual link to the page details...
print("[<A HREF='pageDetsEDS.php?subname=$subname"
. "&pageNumber=$c&nPgs=$nPgs&doctype=$doctype'>$subname Page"
. " $c</A>]&nbsp;\n");
} // END else
} // END for
# Now close the table and be done with it...
print("\n</TD>\n</TR>\n</TABLE>\n");
# Make a horizontal rule to divide the page sections...
drawSeparator();
# Now simply display a finish button, which when clicked, will
# return the user to the "viewEditSubmissionEDS.php" page.
print("<FORM ACTION='viewEditSubmissionEDS.php' METHOD='post'>"
. "\n<INPUT TYPE='hidden' NAME='doctype' VALUE='$doctype'>\n"
. "<INPUT TYPE='hidden' NAME='subname' VALUE='$subname'>\n"
. "<TABLE ALIGN='center' CELLSPACING=0 CELLPADDING=0 BORDER=0 "
. "WIDTH='100%'>\n<TR><TD ALIGN='center'>\n<INPUT TYPE='button' "
. "VALUE='FINISHED' onClick=\"submit();\">\n</TD>\n</TR>\n</TABLE>"
. "\n</FORM>\n");
} // END function buildPgeElemntTbl()
//**************
function constructSubmPge($subname, $pageNumber, $nPgs,
$doctype)
{
/*******************************************************************
This function has the task of producing the interface for the
"pageDetsEDS.php" page. The function conducts a query to get a
list of all of the elements that appear on the given page of the
given submission type (whose details we are to display). If the
query to retrieve a list of elements was executed without error,
it calls the relevant functions to display the different sections
of the page. Otherwise, it displays a relevant error message on
the screen.
The function is passsed several arguments. It is passed the
$link variable, the $subname value (which is the unique
identifier for a submission), the $pageNumber value (which is the
number of the page of the submission that the given element
appears on), the $nPgs value (which is the number of pages that
make up the given submission), and the $doctype variable (which
is the document type that the submission belongs to).
*******************************************************************/
# 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\">This page allows you to view and modify page"
. " $pageNumber of the <EM>$subname</EM> submission.<BR><BR>The "
. "page is composed of 2 main sections:<BR><OL STYLE=\"text-align: "
. "left\"><LI>The preview section. This allows you to obtain a "
. "preview of the shape and form that the page will take with the "
. "current elements and configuration.</LI>\n<LI>\nThe elements "
. "section. This section allows you to view, modify or add "
. "elements to the page. You can also alter the order of "
. "appearance that elements take on the submission page.</LI>\n"
. "</OL>\n</P>\n</TD>\n</TR>\n</TABLE>\n");
drawSeparator();
$res = mysql_query("SELECT * FROM sbmFIELD WHERE subname = '$subname'"
. " AND pagenb = $pageNumber ORDER BY fieldnb");
if(res)
{
makeSubmPgePrev($res, $pageNumber);
# Now that we have produced a nice preview of the current page of
# the submission, it is possible to actually give the details of
# each element.
drawSeparator();
buildPgeElemntTbl($res, $subname, $pageNumber, $nPgs,
$doctype);
} // END if
else
{
# Oh dear, our query failed for one reason or another. We must
# now display an error message...
print("<P CLASS='errorMsg'><SPAN STYLE=\"color: red\">ERROR:"
. "</SPAN> Unable to retrieve details of the elements for "
. "<EM>page $pageNumber</EM> of the <EM>$subname</EM> submission"
. " type.<BR>Please inform the system administrator.</P>\n");
} // END else
} // END function constructSubmPge()
//***********
function moveElementUp($previousFieldnb, $subname, $pageNumber,
$fidesc, $currFieldnb, $previousfiDesc, $doctype)
{
/******************************************************************
The task of this function is to process the situation whereby a
user has opted to move an element of a given submission page up
the page by using the "up" arrow button. This function basically
swaps the positions of the element to move, and the element above
it.
The function is passed several parameters. These are the
$previousFieldnb value, the $subname value, the $pageNumber
value, the $fidesc value, the $currFieldnb value, the $link
pointer, the $nPgs value, the $doctype value, and the
$previousfiDesc value.
******************************************************************/
# Get the current date so that an elements modification date can be
# updated when we move it around the page in its order
# Get the data, so that it can be committed for the modification
# date field (md)...
$modifiedDate = makeEDSmdDate();
# make a query string to alter the elements position.
$queryStringA = "UPDATE sbmFIELD SET fieldnb = '$previousFieldnb', "
. "md = '$modifiedDate' WHERE subname = '$subname' AND pagenb = "
. "'$pageNumber' AND fidesc = '$fidesc' AND fieldnb = "
. "'$currFieldnb'";
# Now make a query string to alter the position of the element above
# the element that we are moving, to that of the element that we are
# moving...
$queryStringB = "UPDATE sbmFIELD SET fieldnb = '$currFieldnb', "
. "md = '$modifiedDate' WHERE subname = '$subname' AND pagenb = "
. "'$pageNumber' AND fidesc = '$previousfiDesc' AND fieldnb = "
. "'$previousFieldnb'";
# Execute the query A
$queryResultA = mysql_query($queryStringA);
if($queryResultA)
{
# If the first query has been successful, execute the 2nd
$queryResultB = mysql_query($queryStringB);
if($queryResultB)
{
# In this case, both queries have executed successfully.
mysql_free_result($queryResultA);
mysql_free_result($queryResultB);
# we must update the "modified date" field in the sbmIMPLEMENT
# table, to reflect the fact that certain changes have been
# made to the given submission, even if they are just moving
# elements around the page.
$mdResult = mysql_query("UPDATE sbmIMPLEMENT SET md = "
. "'$modifiedDate' WHERE subname = '$subname'");
if($mdResult)
{
mysql_free_result($mdResult);
} // END if
else
{
# The update the date query has failed for some reason
print("<SCRIPT LANGUAGE=\"JavaScript\">alert('Error: "
. "Couldn't update the md in sbmIMPLEMENT!');</SCRIPT>\n");
} // END else
# We must also modify the md field of the doctype record to
# which this submission belongs
updateEDSDOCTYPEmd($doctype, $modifiedDate);
# Now, we can send a quick email to the administrator, saying
# that the given submission has been modified.
$msgTxt = "An update has been carried out on the $subname "
. "submission type in the " . DOCS_DATABASE
. " database. An element was moved to another position "
. "on page $pageNumber.\n\nWebSubmit Administrator (";
$msgTxt .= makeDate();
$msgTxt .= ")";
# Now send the mail..
mail(ADMIN_EMAIL, "$subname Submission Type Updated", $msgTxt,
"From: WebSubmit_Administrator");
} // END if
else
{
# In this case, the 2nd query has failed for some reason
print("<SCRIPT LANGUAGE=\"JavaScript\">alert('Error: "
. "Couldn't move an element! (qstringb)');</SCRIPT>\n");
} // END else ($queryStringB)
} // END if
else
{
# The query string A has failed for some reason!
print("<SCRIPT LANGUAGE=\"JavaScript\">alert('Error: "
. "Couldn't move an element (qstringA)');</SCRIPT>\n");
} // END else ($queryResA)
} // END function moveElementUp()
//************
function moveElementDown($nextFieldnb, $subname, $pageNumber, $fidesc,
$currFieldnb, $nextfiDesc, $doctype)
{
/******************************************************************
This function has the task of handling the moving of an element
of a submission page down by one place on the page. This
basically means that it swaps the places of a given element with
the element below it. It then sends the relevant mails to let
the administrators know that this has been done.
The function is passed several paramaters. These are the
$nextFieldnb value, the $subname value, the $pageNumber value,
the $fidesc value, the $currFieldnb value and the $nextfiDesc
value. These are all needed for the execution of the queries to
move the elements.
******************************************************************/
# Get the current date so that an elements modification date can be
# updated when we move it around the page in its order
# Get the data, so that it can be committed for the modification
# date field (md)...
$modifiedDate = makeEDSmdDate();
# make a query string to alter the elements position.
$queryStringA = "UPDATE sbmFIELD SET fieldnb = '$nextFieldnb', "
. "md = '$modifiedDate' WHERE subname = '$subname' AND pagenb = "
. "'$pageNumber' AND fidesc = '$fidesc' AND fieldnb = "
. "'$currFieldnb'";
# Now make a query string to alter the position of the element above
# the element that we are moving, to that of the element that we are
# moving...
$queryStringB = "UPDATE sbmFIELD SET fieldnb = '$currFieldnb', "
. "md = '$modifiedDate' WHERE subname = '$subname' AND pagenb = "
. "'$pageNumber' AND fidesc = '$nextfiDesc' AND fieldnb = "
. "'$nextFieldnb'";
# Execute the query A
$queryResultA = mysql_query($queryStringA);
if($queryResultA)
{
# If the first query has been successful, execute the 2nd
$queryResultB = mysql_query($queryStringB);
if($queryResultB)
{
# In this case, both queries have executed successfully.
# Free the 2 update query results..
mysql_free_result($queryResultA);
mysql_free_result($queryResultB);
# we must update the "modified date" field in the sbmIMPLEMENT
# table, to reflect the fact that certain changes have been
# made to the given submission, even if they are just moving
# elements around the page.
$mdResult = mysql_query("UPDATE sbmIMPLEMENT SET md = "
. "'$modifiedDate' WHERE subname = '$subname'");
if($mdResult)
{
# Free the result left by this update
mysql_free_result($mdResult);
} // END if
else
{
# The update the date query has failed for some reason
print("<SCRIPT LANGUAGE=\"JavaScript\">alert('Error: "
. "Couldn't update the md in sbmIMPLEMENT!');</SCRIPT>\n");
} // END else
# Now update the modified date field for the actual doctype
# record that this submission belongs to
updateEDSDOCTYPEmd($doctype, $modifiedDate);
# Now, we can send a quick email to the administrator, saying
# that the given submission has been modified.
$msgTxt = "An update has been carried out on the $subname "
. "submission type in the " . DOCS_DATABASE
. " database. An element was moved to another position "
. "on page $pageNumber.\n\nWebSubmit Administrator (";
$msgTxt .= makeDate();
$msgTxt .= ")";
# Now send the mail..
mail(ADMIN_EMAIL, "$subname Submission Type Updated", $msgTxt,
"From: WebSubmit_Administrator");
} // END if
else
{
# In this case, the 2nd query has failed for some reason
print("<SCRIPT LANGUAGE=\"JavaScript\">alert('Error: "
. "Couldn't move an element! (qstringb)');</SCRIPT>\n");
} // END else ($queryStringB)
} // END if
else
{
# The query string A has failed for some reason!
print("<SCRIPT LANGUAGE=\"JavaScript\">alert('Error: "
. "Couldn't move an element (qstringA)');</SCRIPT>\n");
} // END else ($queryResA)
} // END function moveElementDown()
//************
function moveElementDigital($subname, $pageNumber, $currFieldnb,
$fidesc, $elementPos, $doctype)
{
/******************************************************************
This function has the task of moving an element of the current
submission page to another position on the page. The movement is
done digitally (i.e. the user selects the position to move the
element to from a select list, and the element appears to slot
right into the position). This function has the job of
re-numbering all of the elements that are affected by this move
(as some other elements may need to be moved up or down to fit
into the place of the moved function. It then moves the element
that is to be moved into the target position.
The function also updates the relevant modified dates for the
moved elements, and the submission type itsself. It also emails
the administrators to let them know of the elements movement.
The function is passed several parameters. These are the
$subname value, the $pageNumber value, the $currFieldnb value,
the $fidesc value, the $maxRowNo value, the $nPgs value, the
$doctype value and the $elementPos value.
******************************************************************/
$modifiedDate = makeEDSmdDate();
# Now get a list of all of the elements on the page
$qResult = mysql_query("SELECT * FROM sbmFIELD WHERE subname = "
. "'$subname' AND pagenb = $pageNumber ORDER BY fieldnb");
# Now, put all of the query dynaset rows into an array...
$idx = 1;
$currentPos = 1;
while($anElement = mysql_fetch_row($qResult))
{
if ($idx == $elementPos && $currFieldnb > $elementPos)
$currentPos++;
if ($idx == $currFieldnb)
$currentPos--;
if ($idx != $currFieldnb)
mysql_query("
UPDATE sbmFIELD
SET fieldnb='$currentPos',
md='$modifiedDate'
WHERE subname='$subname' and
pagenb='$pageNumber' and
fieldnb='".$anElement[2]."' and
fidesc='".$anElement[3]."'");
else
mysql_query("
UPDATE sbmFIELD
SET fieldnb='$elementPos',
md='$modifiedDate'
WHERE subname='$subname' and
pagenb='$pageNumber' and
fieldnb='".$anElement[2]."' and
fidesc='".$anElement[3]."'");
if ($idx == $elementPos && $currFieldnb < $elementPos)
$currentPos++;
$idx++;
$currentPos++;
} // END while
} // END function moveElementDigital()
//*************
function deletePageElement($subname, $pageNumber, $currFieldnb,
$fidesc, $doctype)
{
/******************************************************************
This function has the task of deleting a given element from a
given submission page. When this element is deleted, it is often
necessary to renumber certain other elements on the same page
(those that appeared below the deleted element), as there will be
a gap where the element was removed from. This function deals
with this task when it is necessary. The function also emails
the administrators to let them know that the element has been
deleted from the given page.
The function is passed several parameters. These are the
$subname value, the $pageNumber value, the $currFieldnb value and
the $fidesc value.
******************************************************************/
$dateDets = getdate();
# Now put the date into a variable in a nice MySQL friendly format
$modifiedDate = $dateDets['year'] . "-" . $dateDets['mon'] . "-"
. $dateDets['mday'];
# Now get a list of all of the elements on the page
$qResult = mysql_query("SELECT * FROM sbmFIELD WHERE subname = "
. "'$subname' AND pagenb = $pageNumber ORDER BY fieldnb");
# Now, put all of the query dynaset rows into an array...
$idx = 0;
$numRows = mysql_num_rows($qResult);
while($anElement = mysql_fetch_array($qResult))
{
$elementList[$idx] = $anElement;
$idx++;
} // END while
if($currFieldnb < $numRows)
{
for($k = $currFieldnb; $k < $numRows; $k++)
{
# Make a query string to deal with moving each element
# below the element to move (up until the position to move
# to) up one place in the page elements order.
$moveStr = "UPDATE sbmFIELD SET fieldnb = '"
. ($elementList[$k][2] - 1) . "', md = '$modifiedDate' "
. "WHERE subname = '$subname' AND pagenb = '$pageNumber' "
. "AND fieldnb = '" . $elementList[$k][2] . "'";
# Execute the query to remove the element
$moveRes = mysql_query($moveStr);
if($moveRes)
{
mysql_free_result($moveRes);
} // END if
else
{
# Query hasn't worked
print("<SCRIPT TYPE='text/javascript'>alert('Error: "
. "Couldn't move an element!');</SCRIPT>\n");
}// END else
} // END for
# Make the query string to remove the element
$finalDelStr = "DELETE FROM sbmFIELD WHERE subname = '$subname' "
. "AND pagenb ='$pageNumber' AND fieldnb = '$currFieldnb' "
. "AND fidesc = '$fidesc'";
# Execute the query to remove the element
$finalDelRes = mysql_query($finalDelStr);
if($finalDelRes)
{
# Free the result pointer left by this deletion
mysql_free_result($finalDelRes);
# Now, we can send a quick email to the administrator, saying
# that the given submission has been modified.
$msgTxt = "An update has been carried out on the $subname "
. "submission type in the " . DOCS_DATABASE
. " database. An element was deleted from page $pageNumber"
. ".\n\nWebSubmit Administrator (";
$msgTxt .= makeDate();
$msgTxt .= ")";
# Now send the mail..
mail(ADMIN_EMAIL, "$subname Submission Type Updated", $msgTxt,
"From: WebSubmit_Administrator");
} // END if
else
{
# Query hasn't worked
print("<SCRIPT TYPE='text/javascript'>alert('Error: "
. "Couldn't delete an element!');</SCRIPT>\n");
}// END else
} // END if
else
{
# In this case, the item to be deleted must be the last in the
# list, so we don't need to move any elements around, just delete
# the it.
# Make the query string to remove the element
$finalDelStr = "DELETE FROM sbmFIELD WHERE subname = '$subname' "
. "AND pagenb ='$pageNumber' AND fieldnb = '$currFieldnb' "
. "AND fidesc = '$fidesc'";
$finalDelRes = mysql_query($finalDelStr);
if($finalDelRes)
{
mysql_free_result($finalDelRes);
# Now, we can send a quick email to the administrator, saying
# that the given submission has been modified.
$msgTxt = "An update has been carried out on the $subname "
. "submission type in the " . DOCS_DATABASE
. " database. An element was deleted from page $pageNumber"
. ".\n\nWebSubmit Administrator (";
$msgTxt .= makeDate();
$msgTxt .= ")";
mail(ADMIN_EMAIL, "$subname Submission Type Updated", $msgTxt,
"From: WebSubmit_Administrator");
} // END if
else
{
# Query hasn't worked
print("<SCRIPT LANGUAGE=\"JavaScript\">alert('Error: "
. "Couldn't delete an element!');</SCRIPT>\n");
}// END else
} // END else
# we must update the "modified date" field in the sbmIMPLEMENT
# table, to reflect the fact that certain changes have been
# made to the given submission, even if they are just moving
# elements around the page.
$mdResult = mysql_query("UPDATE sbmIMPLEMENT SET md = "
. "'$modifiedDate' WHERE subname = '$subname'");
if($mdResult)
{
# Free the result left by this update
mysql_free_result($mdResult);
} // END if
else
{
# The update the date query has failed for some reason
print("<SCRIPT LANGUAGE=\"JavaScript\">alert('Error: "
. "Couldn't update the md in sbmIMPLEMENT!');</SCRIPT>\n");
} // END else
# Update the doctype modification date
updateEDSDOCTYPEmd($doctype, $modifiedDate);
} // END function deletePageElement()
function displayPage()
{
global $moveUp,$x,$y,$previousFieldnb,$subname,$pageNumber,$fidesc,$currFieldnb,$previousfiDesc,$doctype,$nPgs,$moveDown,$moveDigital,$elementPos,$deleteElement;
# Conduct a test to see what kind of call to this page this actually
# is, and then take the appropriate action based upon this
# outcome...
if(isset($moveUp))
{
# If the $up variable is set, it means that the user has pressed
# the up arrow button to move an element up in the order in which
# it is placed on the page...
unset($x);
unset($y);
unset($moveUp);
# Process the element movement...
moveElementUp($previousFieldnb, $subname, $pageNumber, $fidesc,
$currFieldnb, $previousfiDesc, $doctype);
# Redisplay the page...
constructSubmPge($subname, $pageNumber, $nPgs, $doctype);
} // END if
elseif(isset($moveDown))
{
# If this variable is set, it means that the user has pressed the
# down arrow button to move an element down in the order in which
# it is located on the page.
unset($x);
unset($y);
unset($moveDown);
# Process the element movement...
moveElementDown($nextFieldnb, $subname, $pageNumber, $fidesc,
$currFieldnb, $nextfiDesc, $doctype);
# Redisplay the page...
constructSubmPge($subname, $pageNumber, $nPgs, $doctype);
} // END elseif
elseif(isset($moveDigital))
{
/***************************************************************
In this case, the user has opted to move an element to another
position by selecting the position to move it to from the
select list (the item is then moved directly to this position
in the page element order, hence the reason for calling this a
digital move). When this move is accomplished, the other
elements cascade down/up to fill the vacant position left by
the element to be moved.
***************************************************************/
unset($moveDigital);
# Process the element movement
moveElementDigital($subname, $pageNumber, $currFieldnb, $fidesc,
$elementPos, $doctype);
# Redisplay the page...
constructSubmPge($subname, $pageNumber, $nPgs, $doctype);
} // END elseif
elseif(isset($deleteElement))
{
# In this case, the user has opted to delete a given element from
# the page. This means that we must delete the element, and then
# reorder the item numbers of all of the other items in order to
# fill the gap left by this element. We also need to alter the
# modified date of the given submission.
unset($deleteElement);
# Process the element deletion...
deletePageElement($subname, $pageNumber, $currFieldnb, $fidesc,
$doctype);
# Redisplay the page...
constructSubmPge($subname, $pageNumber, $nPgs, $doctype);
} // END elseif
else
{
# In this case, it is the first call to the page (a
# non-self-referential call), and we just need to display the
# details of the submission page...
constructSubmPge($subname, $pageNumber, $nPgs, $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
displayPage();
/************************End of main script***************************/
</protect>
?>

Event Timeline