Page MenuHomec4science

func.php.wml
No OneTemporary

File Metadata

Created
Sat, Jun 29, 17:27

func.php.wml

## $Id$
## This file is part of the CERN Document Server Software (CDSware).
## Copyright (C) 2002, 2003, 2004, 2005 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="List of parameters of function <I><protect><?print $functionName;?></protect></i> for the <I><protect><?print $doctype;?></protect></i> document type" \
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"
<?
<protect>
## $Id$
## DO NOT EDIT THIS FILE! IT WAS AUTOMATICALLY GENERATED FROM CDSware WML SOURCES.
/*********************Function Declarations**************************/
function displayReturnButton($buttonText, $returnTo, $doctype,
$functionName, $action)
{
/****************************************************************
This function simply outputs a simple button in a table, which is
centered on the page. When the button is clicked, it calls the
script previous to func.php, which is actionFunctions.php
Author: Nicholas Robinson
Email: Nicholas.Robinson@cern.ch
Created: 24/08/2000
Last Modified: 05/02/2001
****************************************************************/
# Display the button...
print("<BR><TABLE BORDER=0 CELLSPACING=0 ALIGN='center'><TR>");
print("<FORM ACTION='$returnTo' METHOD='post'><TD>\n");
if($returnTo == "funcUsage.php")
{
print("<INPUT TYPE='hidden' NAME='function' "
. "VALUE='$functionName'>");
} // END if
else
{
print("<INPUT TYPE='hidden' NAME='doctype' VALUE='$doctype'>");
print("<INPUT TYPE='hidden' NAME='action' VALUE='$action'>");
} // END else
print("<INPUT TYPE='button' VALUE='$buttonText' onClick=\"");
print("submit()\"></TD></FORM></TR></TABLE>\n");
} // END function displayReturnButton()
//*********************
function makeFuncParamsTableBody($queryResult, $columns, $functionName,
$returnTo, $doctype, $action)
{
/*****************************************************************
This function serves the purpose of creating the main body of the
table of parameters for a given function as part of a given
action performed upon a given doctype. The function does not
actually open or close the table itself, merely build the body
of the table (the data rows). Yhe function is passed the
$queryResult parameter, which is used to get the data for each
row of the table. It is also passed the $columns parameter,
which is used to determine how many columns there are in the
table. It is also passed the $functionName, $doctype and $action
parameters, which are all used in building the hyperlink that
can be clicked on for viewing the value of a given parameter.
Author: Nicholas Robinson
Email: Nicholas.Robinson@cern.ch
Created: 24/08/2000
Last Modified: 08/02/2001
*****************************************************************/
global $HTDOCSDIR,$IMAGES;
while($rowData = mysql_fetch_array($queryResult))
{ # While there are rows of the query dynaset to read...
print("<TR BGCOLOR='#FFFFCC'>\n");
for($colIndex = 0; $colIndex < mysql_num_fields($columns);
$colIndex++)
{ # For each column, display its value...
print("<TD ALIGN='center'>&nbsp;");
print(htmlspecialchars($rowData[$colIndex]));
print("</TD>\n");
} // End FOR
print("<TD ALIGN='center'>&nbsp;");
# Execute a select query that will select the value of the
# current rows parameter from the relevant table...
$querStr = "SELECT value FROM sbmPARAMETERS WHERE doctype = '$doctype' and name='" . $rowData['param'] . "'";
# Place a READ lock on the given table...
$lockStr = "LOCK TABLES sbmPARAMETERS READ";
$lockRes = mysql_query($lockStr);
# Execute the SELECT query...
$querRes = mysql_query($querStr);
# Remove the table lock...
if($lockRes)
{
$unlockRes = mysql_query("UNLOCK TABLES");
} # END if
unset($lockStr);
if($querRes)
{
if(mysql_num_rows($querRes) == 1)
{
# Great, we can display our parameter. We must however
# test to see if the current function is the
# "Make_Weblib_Record" function. If it is, it means that
# we must link to the file that is this functions
# parameter. We must allow it to be edited by providing a
# link to it.
# Get the parameters value...
list($value) = mysql_fetch_row($querRes);
if(($functionName == "Make_Weblib_Record") ||
($functionName == "Make_Modify_Record"))
{
# Ok, it is the "Make_Weblib_Record"
# or"Make_Modify_Record" function, so link to the text
# file editor script...
print("<A TITLE='EDIT THE FILE' HREF='editRecordFile"
. ".php?file=$HTDOCSDIR/submit/bibconvert/config/" . ltrim(ereg_replace("'", "&#39;",
htmlspecialchars($value))) . "&amp;doctype="
. ereg_replace("'", "&#39;",
htmlspecialchars($doctype)) . "&amp;function"
. "Name=" . ereg_replace("'", "&#39;",
htmlspecialchars($functionName)) . "&amp;"
. "action=" . ereg_replace("'", "&#39;",
htmlspecialchars($action)) . "&amp;returnTo="
. ereg_replace("'", "&#39;",
htmlspecialchars($returnTo)) . "'>"
. ereg_replace("'", "&#39;",
htmlspecialchars($value)) . "</A>\n");
} // END if
else
{
# Okay, it's not the "Make_Weblib_Record" or
# "Make_Modify_Record" function, so just display the
# value as a standard text field.
print(htmlspecialchars($value));
} // END else
} // END if
elseif(mysql_num_rows($querRes) > 1)
{
/**************
If this condition has been reached, it means that
more than 1 row has been returned by this query. This
means that there are DB consistency errors, as there
should never be more than 1 row for a parameters value
for a given doctype.
**************/
# Mail the administrator to inform them of the error that
# has ocurred...
$errMailTxt = "An error has occurred when attempting to "
. "obtain a parameter value for the " . $rowData['param']
. "parameter of the $functionName function. The data was"
. "selected from the parameters table"
. " for the $doctype document type.\n\nPlease look "
. "into this problem, as it suggests that there are "
. "multiple values for this parameter, which breaks DB"
. "consistency.\n\n"
. "This error occurred on " . $dateDets['weekday'] . " "
. $dateDets['mday'] . " " . $dateDets['month'] . " "
. $dateDets['year'] . ", at " . $dateDets['hours'] . ":"
. $dateDets['minutes'] . ".";
mail(ADMIN_EMAIL, "Error: Multiple Values For A Parameter",
$errMailTxt, "From: WebSubmit_Administrator");
# Inform the user of this error using a javascript alert..
print("<SCRIPT TYPE='text/javascript'>alert('Error:\\n\\n"
. "Too many rows returned when selecting "
. $rowData['param']
. " parameter\\nfrom the parameters"
. " table for $doctype document type');</SCRIPT>");
} // END elseif
else
{
# In this case, no rows have been returned (i.e. there is
# no value in the DB for the parameter on this doctype, so
# a little warning will be displayed in the value cell!
print("<IMG SRC='".$IMAGES."/noway.gif' ALT='No value"
. " stored in the " . $rowData['param'] . " column of"
. " the parameters table for the "
. "$doctype document type.' BORDER=0 WIDTH=14 "
. "HEIGHT=14>\n");
} // END else
} // END if
else
{
/**************************
If this condition has been reached, it means that the query
has failed to execute for some reason.
**************************/
print("<SCRIPT TYPE='text/javascript'>alert('Error:\\t\\t"
. "Unable to select " . $rowData['param']
. " parameter from parameters "
. " table for $doctype document type');</SCRIPT>");
} // END else
# Close the value table data cell...
print("</TD>\n");
# Now display an icon to allow the user to edit the value of the
# parameter. This will require a form with invisible inputs in
# order to pass the relevant parameters to the parameterUpdate
# script...
print("<FORM ACTION='parameterUpdate.php' METHOD='post'>\n"
. "<INPUT TYPE='hidden' NAME='param' VALUE='"
. ereg_replace("'", "&#39;",
htmlspecialchars($rowData['param']))
. "'>\n<INPUT TYPE='hidden' NAME='functionName' VALUE='"
. ereg_replace("'", "&#39;", htmlspecialchars($functionName))
. "'>\n<INPUT TYPE='hidden' NAME='doctype' VALUE='"
. ereg_replace("'", "&#39;", htmlspecialchars($doctype))
. "'>\n<INPUT TYPE='hidden' NAME='action' VALUE='"
. ereg_replace("'", "&#39;", htmlspecialchars($action))
. "'>\n"
. "<INPUT TYPE='hidden' NAME='returnTo' VALUE='$returnTo'>\n"
. "<TD><INPUT TYPE='image' SRC='".$IMAGES."/edit1.gif' "
. "WIDTH=20 HEIGHT=20 BORDER=0 ALT='Edit Parameter Value' "
. "onClick=\"submit();\"></TD>\n</FORM>\n");
# Close up the table row...
print("</TR>\n");
} // End while
} // END function makeFuncParamsTableBody()
//*******************
function processQuery($queryResult, $doctype, $action, $functionName,
$returnTo)
{
/*****************************************************************
This function is passed a queryResult from the main function of
func.php. The query was a select query to get all rows from the
sbmFUNDESC table for a given function (i.e. all of that functions
parameters). This function tests to see if rows were returned by
this query, and if there were rows returned, a table containing
the details of the parameters is created and output on the fly.
If no rows were returned by the query however, a relevant
informative message is displayed on the screen instead of the
table.
Author: Nicholas Robinson
Email: Nicholas.Robinson@cern.ch
Created: 24/08/2000
Last Modified: 06/02/2001
*****************************************************************/
$numRows = mysql_num_rows($queryResult);
if($numRows > 0)
{
# Get information about the sbmFUNDESC table. This will be used to
# display the column headers in the table of info about the
# chosen function.
$columns = mysql_list_fields(DOCS_DATABASE, "sbmFUNDESC");
# Now, we can create a table to hold the function info. First,
# we will put the column headings in it...
print("<TABLE BORDER=1 CELLSPACING=0 ALIGN='center'>\n");
print("<TR BGCOLOR='#CCDDFF'>\n");
makeTableHeaderRow($columns, 0);
# Add another column for the value of the parameter...
print("<TH>&nbsp;value&nbsp;</TH>\n");
# Add another column for the edit parameter value icon to be put
# in...
print("<TH>&nbsp;</TH>\n</TR>\n");
# Now that the column headers have been displayed for the
# function information table, we can create the rest of the
# table, with the actual information about the function in it.
makeFuncParamsTableBody($queryResult, $columns, $functionName,
$returnTo, $doctype, $action);
# Close the table, as it is now complete...
print("</TABLE>\n");
} // End if
else # If there are no parameters to display...
{
print("<P><H4 STYLE=\"color: red; text-align: center\">The "
. "$functionName function has no parameters to display.</H4>"
. "\n</P>\n");
} // End else
} // END function processQuery()
function displayPage()
{
global $functionName,$doctype,$action,$returnTo;
# Decode the $functionName parameter from url encoding...
$functionName = urldecode($functionName);
# Execute a query on the sbmFUNDESC table, retrieving data about the
# function whose name was passed as an argument to the script.
# The function data really just gives details of the parameters
# that the function takes, and the table that these parameters
# can be found in. The output is sorted in ascending order of
# parameters.
# Lock the sbmFUNDESC table as READ
if($lockRes = mysql_query("LOCK TABLES sbmFUNDESC READ"))
{
$queryResult = mysql_query("SELECT * FROM sbmFUNDESC WHERE
function = '$functionName' ORDER BY param");
$unlockRes = mysql_query("UNLOCK TABLES");
# Test the query result, and take the appropriate action...
processQuery($queryResult, $doctype, $action, $functionName,
$returnTo);
# Display a 'finished' button...
displayReturnButton("FINISHED", $returnTo, $doctype,
$functionName, $action);
} # END if
else
{
# Unable to lock sbmFUNDESC table. Unsafe to read from it, so
# don't.
print("<DIV STYLE='text-align: center; color: navy; font-weight:"
. " bold; font-size: large'><SPAN STYLE='color: red'>Error:"
. "</SPAN> Unable to lock sbmFUNDESC table.</DIV>\n<BR>\n");
# Display a 'OK' button...
displayReturnButton("OK", $returnTo, $doctype,
$functionName, $action);
} # 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