Page MenuHomec4science

veditFunDets.php.wml
No OneTemporary

File Metadata

Created
Wed, May 29, 15:56

veditFunDets.php.wml

## $Id$
## This file is part of the CERN Document Server Software (CDSware).
## Copyright (C) 2002 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="View <i><protect><?print $function;?></protect></i> function details" \
navtrail_previous_links="<a class=navtrail href=<WEBURL>/admin/<lang:star: index.*.html>><MSG_ADMIN_AREA></a> &gt; <a class=navtrail href=<WEBURL>/admin/websubmit/><MSG_ADMIN_SUBMIT></a>" \
navbar_name="admin" \
navbar_select="websubmit_listfunctions"
<?
<protect>
## $Id$
## DO NOT EDIT THIS FILE! IT WAS AUTOMATICALLY GENERATED FROM CDSware WML SOURCES.
function displayPage()
{
global $function,$deleteParam,$param,$updateFunDets,$description,$insertParam,$newParam,$theParam;
/******************************************************************
This script produces a page that is used for viewing or configuring
the details of a function in the WebSubmit database. When the page is
called for the first time, i.e. from the 'listFunctions.php' page,
it displays the name of the function, the description of the
function, any parameters that the function may have, and also offers
the ablility to add parameters to the function by presenting a drop
down selection list of tables in WebSubmit.
The page allows the user to alter the description of the function.
This can be done by typing into the description text field, and
clicking on the submit button. The page will then recursively call
itself, update this value in the sbmALLFUNCDESCR table of WebSubmit, and
then redisplay all of the functions details with the new description
The page also allows the user to add a parameter to the function.
In this case, the user must first of all select a table name from
the selection drop down list box. The page will then recursively
call itself again, but this time, also displaying a drop down select
list of fields in the table that the user selected. The user can
then select one of these fields, and click a submit button to add
the new parameter to the function. At this point, the page will
recursively call itself again, but this time adding the new
parameter to the function, and emailing the administrators to
inform them that this action has been carried out. The page will
then redirect to the 'funcUsage.php', which will display the usage
of the function, and the user will be informed that they must update
all of the actions and doctypes that use this function, as they will
need values inserting into the relevant tables for the new
parameter.
Author: Nicholas Robinson
Email: Nicholas.Robinson@cern.ch
******************************************************************/
if(isset($updateFunDets))
{
# If this variable is set, then this instance of the page is a
# call to update the value of the description field, and hence
# the update query must be carried out, and then all details of
# the function displayed once again...
# Free the $updateFunDets variable...
unset($updateFunDets);
# LOCK THE TABLES
if($lockRes = mysql_query("LOCK TABLES sbmALLFUNCDESCR WRITE"))
{
$updateDescRes = mysql_query("UPDATE sbmALLFUNCDESCR SET "
. "description = '$description' WHERE function = "
. "'$function'");
$unlockRes = mysql_query("UNLOCK TABLES");
if(!$updateDescRes)
{
# If this clause is reached, the script has been unable to
# update the value of description for some reason, and the
# user should be informed of this...
print("<SCRIPT TYPE='text/javascript'>alert('ERROR:\\n\\n"
. "Unable to update value of description for $function\\n"
. "function in sbmALLFUNCDESCR table.\\n\\n"
. "Please inform administrator.</SCRIPT>\n");
} // END if
} # END if
else
{
# Couldn't get lock - therefore no update allowed - tell user
print("<DIV STYLE='color: navy; font-weight: bold; "
. "text-align: center; font-size: large'><SPAN STYLE='color: "
. "red'>Error:</SPAN> Unable to update description.</DIV>\n"
. "<BR>\n");
} # END else
# Free up the space associated with the $updateDescRes query
# result...
mysql_free_result($updateDescRes);
# Redisplay the page...
makePageBody($function, "veditFunDets.php");
# Now, add a finish button that allows the user to leave the page
# and return to the 'listFunctions.php' page...
print("<TABLE ALIGN='center' BORDER=0 CELLPADDING=0 "
. "CELLSPACING=0>\n<TR>\n<TD ALIGN='center'>\n"
. "<FORM ACTION='listFunctions.php' METHOD='post'>\n"
. "<INPUT TYPE='button' VALUE='FINISHED' "
. "onClick=\"submit();\">\n"
. "</FORM>\n</TD>\n</TR>\n</TABLE>\n");
} // END if
elseif(isset($insertParam))
{
# If this variable is set, then this instance of the page is a
# call to add a new parameter to the function...
# LOCK THE TABLES
if($lockRes = mysql_query("LOCK TABLES sbmFUNDESC WRITE"))
{
if ($newParam != "")
$insertParamRes = mysql_query("INSERT INTO sbmFUNDESC
VALUES('$function', '$newParam')");
else
$insertParamRes = mysql_query("INSERT INTO sbmFUNDESC
VALUES('$function', '$theParam')");
$unlockRes = mysql_query("UNLOCK TABLES");
if($insertParamRes)
{
# Now that the parameter has been added, it is necessary to
# display an alert informing the user that the parameter
# has been added, but that they must also update all
# doctypes that use the function to have an actual value
# in the relevant table...
print("<SCRIPT TYPE='text/javascript'>alert('Parameter "
. "Added:"
. "\\n\\nThe $function function will now take a parameter"
. "\\nfrom the $theParam column of the $theTable table."
. "\\n\\nImportant:\\n\\nYour browser has now been "
. "redirected to a page displaying the\\ndocument types"
. " and the actions that this function is utilised in."
. "\\nIt is VERY important that you add a row into the\\n"
. "$theTable table for each of these document types, as"
. " the\\n$function function will now search for this row"
. " when it is called.');</SCRIPT>\n");
# Email the WebSubmit system administrator, and warn them that a
# function has been added to WebSubmit, and that they should
# ensure that all relevant tables have been updated...
# Get the date for the message...
$dateDets = getDate();
# Create the message text...
$messageText = "Please be advised that a parameter was "
. "added"
. " to the $function function on " . $dateDets['weekday']
. " " . $dateDets['mday'] . " " . $dateDets['month'] . " "
. $dateDets['year'] . ", at " . $dateDets['hours'] . ":"
. $dateDets['minutes'] . ".\n\n"
. "The function will search for the value of the new "
. "parameter in the $theParam column of the $theTable "
. "table.\n\nYou should ensure that all document types "
. "that"
. " use this function have a corresponding row in this "
. "table.\n\nInformation about the document types that "
. "utilise this function can be found under the 'WebSubmit "
. "Functions' section of the WebSubmit Administrator "
. "menu.\n\nWebSubmit Administrator.";
# Send the message...
mail(ADMIN_EMAIL, "Parameter Added To $function Function",
$messageText, "From: WebSubmit_Administrator");
# Make a form containing the function name for submitting
# to the 'funcUsage.php' script, so that it is able to
# display the usage of the function in question...
print("<FORM ACTION='funcUsage.php' METHOD='post' "
. "NAME='referForm'>\n<INPUT TYPE='hidden'"
. " NAME='function' VALUE='$function'>\n</FORM>\n");
# Now submit the form...
print("<SCRIPT TYPE='text/javascript'>\n"
. "setTimeout(\"document.referForm.submit();\", 0);\n"
. "</SCRIPT>\n");
} // END if
else
{
# If the insert query did not execute...
print("<SCRIPT TYPE='text/javascript'>alert('ERROR:\\n\\n"
. "It was not possible to add this parameter to the "
. "function.');</SCRIPT>\n");
# Just redisplay the page...
makePageBody($function, "veditFunDets.php");
# Now, add a finish button that allows the user to leave
# the pa'e and return to the 'listFunctions.php' page...
print("<TABLE ALIGN='center' BORDER=0 CELLPADDING=0 "
. "CELLSPACING=0>\n<TR>\n<TD ALIGN='center'>\n"
. "<FORM ACTION='listFunctions.php' METHOD='post'>\n"
. "<INPUT TYPE='button' VALUE='FINISHED' "
. "onClick=\"submit();\">\n"
. "</FORM>\n</TD>\n</TR>\n</TABLE>\n");
} // END else
} # END if
else
{
# Unable to get a lock. Don't commit at any costs!
print("<DIV STYLE='text-align: center; font-weight: bold; "
. "font-size: large; color: navy'><SPAN STYLE='color: red'>"
. "Error:</SPAN> Unable to insert parameter.</DIV>\n");
# Just redisplay the page...
makePageBody($function, "veditFunDets.php");
# Now, add a finish button that allows the user to leave
# the page and return to the 'listFunctions.php' page...
print("<TABLE ALIGN='center' BORDER=0 CELLPADDING=0 "
. "CELLSPACING=0>\n<TR>\n<TD ALIGN='center'>\n"
. "<FORM ACTION='listFunctions.php' METHOD='post'>\n"
. "<INPUT TYPE='button' VALUE='FINISHED' "
. "onClick=\"submit();\">\n"
. "</FORM>\n</TD>\n</TR>\n</TABLE>\n");
} # END else
} // END elseif
elseif(isset($deleteParam))
{
# This call to this script is a call to delete a given parameter
# from a function.
# LOCK THE TABLES
if($lockRes = mysql_query("LOCK TABLES sbmFUNDESC WRITE"))
{
$delRes = mysql_query("DELETE FROM sbmFUNDESC WHERE function = '"
. "$function' AND param = '$param'");
if($delRes)
{
# Query worked
if(mysql_affected_rows() < 1)
{
# Damn. We deleted no rows for some reason.
print("<SCRIPT TYPE='text/javascript'>\nalert('ERROR: "
. "Unable to delete requested parameter.\\nTry again "
. "or inform system administrator.');\n</SCRIPT>\n");
} // END if
else
{
# Woo Hoo! We deleted the parameter!
print("<SCRIPT TYPE='text/javascript'>\nalert('Parameter"
. " Deleted.\\n\\nWhen executed, the $function function"
. " will no longer search for the deleted "
. "parameter.');\n</SCRIPT>\n");
# Mail admin...
# Get the current date and time...
$dateDets = getdate();
$msgTxt = "A parameter has been deleted from the "
. "$function"
. " function in the " . DOCS_DATABASE . "database. This "
. "parameter was taken from the $param field of the "
. "$tablename Table. When the function is called by "
. "the WebSubmit system in the future, it will not search "
. "for this parameter.\n\nThis deletion was carried "
. "out on "
. $dateDets['weekday'] . " " . $dateDets['mday'] . " "
. $dateDets['month'] . " " . $dateDets['year']
. ", at " . $dateDets['hours'] . ":"
. $dateDets['minutes'] . ".\n\nWebSubmit Administrator.";
# Send the message...
mail(ADMIN_EMAIL, "Parameter Deleted From $function",
$msgTxt, "From: WebSubmit_Administrator");
} // END else
} // END if
else
{
# Damn. Query failed.
print("<SCRIPT TYPE='text/javascript'>\nalert('ERROR: "
. "Unable "
. "to delete requested parameter.\\nTry again or inform "
. "system administrator.');\n</SCRIPT>\n");
} // END else
} # END if
else
{
# Unable to get lock - don't allow deletion.
print("<DIV STYLE='text-align: center; font-weight: bold; "
. "font-size: large; color: navy'><SPAN STYLE='color: red'>"
. "Error:</SPAN> Unable to delete parameter.</DIV>\n");
} # END else
# Now redisplay the page...
makePageBody($function, "veditFunDets.php");
# Now, add a finish button that allows the user to leave the
# page and return to the 'listFunctions.php' page...
print("<TABLE ALIGN='center' BORDER=0 CELLPADDING=0 "
. "CELLSPACING=0>\n<TR>\n<TD ALIGN='center'>\n"
. "<FORM ACTION='listFunctions.php' METHOD='post'>\n"
. "<INPUT TYPE='button' VALUE='FINISHED' "
. "onClick=\"submit();\">\n"
. "</FORM>\n</TD>\n</TR>\n</TABLE>\n");
} // END elseif
else
{
if(isset($tableSelected))
{
# Make the page, including the table of parameters...
makePageBody($function, "veditFunDets.php",
$tableSelected, $theTable);
# Now, add a finish button that allows the user to leave the
# page and return to the 'listFunctions.php' page...
print("<TABLE ALIGN='center' BORDER=0 CELLPADDING=0 "
. "CELLSPACING=0>\n<TR>\n<TD ALIGN='center'>\n"
. "<FORM ACTION='listFunctions.php' METHOD='post'>\n"
. "<INPUT TYPE='button' VALUE='FINISHED' "
. "onClick=\"submit();\">\n"
. "</FORM>\n</TD>\n</TR>\n</TABLE>\n");
} // END if
else
{
# Make the page once more, as a first call to it...
makePageBody($function, "veditFunDets.php");
# Now, add a finish button that allows the user to leave the
# page and return to the 'listFunctions.php' page...
print("<TABLE ALIGN='center' BORDER=0 CELLPADDING=0 "
. "CELLSPACING=0>\n<TR>\n<TD ALIGN='center'>\n"
. "<FORM ACTION='listFunctions.php' METHOD='post'>\n"
. "<INPUT TYPE='button' VALUE='FINISHED' "
. "onClick=\"submit();\">\n"
. "</FORM>\n</TD>\n</TR>\n</TABLE>\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
displayPage();
/************************End of main script***************************/
</protect>
?>

Event Timeline