Page MenuHomec4science

funcUsage.php.wml
No OneTemporary

File Metadata

Created
Mon, Nov 4, 03:14

funcUsage.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="Where the <i><protect><?print $function;?></protect></i> function is used" \
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" \
cdspageboxlefttopadd="<protect><?displayLoginMenu('submit');?></protect>"
<?
<protect>
## $Id$
## DO NOT EDIT THIS FILE! IT WAS AUTOMATICALLY GENERATED FROM CDSware WML SOURCES.
/******************************************************************
This script has been written so that a user can view the usage of a
particular function throughout the MESS system. The script is
passed the variable $function from the calling page (which is
listFunctions.php). The script runs a series of queries,
retrieving all doctypes in the MESS database, then retrieving all
actions for each of these queries, then retrieving all functions
that match with the function name stored in $function, for each of
these actions. This means that a form of hierarchical list can be
built showing on which actions on which doctypes the function being
examined is used.
Author: Nicholas Robinson
Email: Nicholas.Robinson@cern.ch
Created: 21/09/2000
Last Modified: 22/03/2001
******************************************************************/
/**********************Function Declarations***********************/
function killThisScript()
{
/***************************************************************
This is just a simple function to stop the processing of this
script. It will be called whenever a fatal query error occurs.
Author: Nicholas Robinson
Email: Nicholas.Robinson@cern.ch
Created: 21/09/2000
Last Modified: 05/02/2001
***************************************************************/
# Stop processing this script...
die("</TD></TR></TABLE><STRONG STYLE='text-align: center; color: "
. "red>Report Processing Terminated. <A HREF='index.php'>Main "
. "Page.</A></STRONG></TD>\n</TR>\n</TABLE>\n</BODY>\n"
. "</HTML>\n");
} // END function killThisPage()
//***************
function makeFuncUsageList($doctypesQuery, $function)
{
/*******************************************************************
This function takes 2 parameters. The first is a query result
set that points to all of the doctypes in the sbmDOCTYPE table, and
the second is a function name (the one whose usage is to be
examined). The function loops through every doctype in the
result set, and for each one, it executes a query finding all of
the actions on that doctype. For each of these actions, it then
executes a query to see if the function we are examining is used
by that action on that doctype. If it is, it is displayed in a
bullet pointed list. The action on the doctype that the function
is used in is the text that is actually displayed, and it is
displayed as a link to the func.php page, where the parameters
for that function can be displayed.
Author: Nicholas Robinson
Email: Nicholas.Robinson@cern.ch
Created: 25/09/2000
Last Modified: 22/03/2001
*******************************************************************/
if($doctypesQuery) # If the query to get all doctypes was successful
{
# Open an invisible table that will contain the bullet list of
# doctypes and actions in which the function is utilised.
print("<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 "
. "ALIGN='center'>\n<TR><TD>");
# A flag is needed to determine whether or not a doctype has been
# printed on screen (as all actions are indented from this. The
# flag is first set to 0, as no doctype has been displayed at
# first...
$headerDrawn = 0;
# For each document type returned by the query (each doctype in
# the MESS database...
while(list($doctypeItem, $doctypeName) =
mysql_fetch_row($doctypesQuery))
{
# Execute a query to retrieve the actions belonging to this
# particular document type...
# Lock the sbmIMPLEMENT table.
$lockRes = mysql_query("LOCK TABLES sbmIMPLEMENT READ");
$actionsQuery = mysql_query("SELECT actname FROM sbmIMPLEMENT
WHERE docname = '$doctypeItem'");
if($lockRes)
{
# Unlock the table...
$unlockRes = mysql_query("UNLOCK TABLES");
} # END if
# If this actions query was executed successfully...
if($actionsQuery)
{
# For each action of the current document type...
while(list($actItem) = mysql_fetch_row($actionsQuery))
{
# Execute a query to retrieve all of the entries for the
# function being tested for, as part of the current
# action on the current document type...
$string = "SELECT function FROM sbmFUNCTIONS WHERE "
. "doctype = '$doctypeItem' AND function = '$function' and action='${actItem}'";
# Lock the current table as READ.
$lockStr = "LOCK TABLES sbmFUNCTIONS READ";
$lockRes = mysql_query($lockStr);
$functionsQuery = mysql_query($string);
if($lockRes)
{
# Release the locks...
$unlockRes = mysql_query("UNLOCK TABLES");
unset($lockStr);
} # END if
if($functionsQuery) # If the query executed successfully
{
# If rows were returned by the query (i.e. if the
# current action on the current doctype includes the
# function being tested for...
if(mysql_num_rows($functionsQuery) > 0)
{
# If the headerDrawn flag is not set (i.e. the
# doctype bullet point has not yet been displayed
# on the screen...
if(!$headerDrawn)
{
# Write the document type on the screen, and
# then open another HTML unordered list to
# contain action titles...
print("<UL TYPE='disc'>\n<LI><STRONG>"
. "<SMALL>$doctypeName</S"
. "MALL></STRONG></LI>\n"
. "\t<UL TYPE='square'>\n");
# Set the header flag to indicate that the
# doctype title has now been written on the
# screen...
$headerDrawn = 1;
} // END if
# Display the action name as part of the inner
# list...
print("<A HREF='func.php?functionName=$function"
. "&doctype=$doctypeItem&action=$actItem"
. "&returnTo=funcUsage.php'>"
. "<LI>$actItem</LI></A>\n");
} // END if
} // END if
else
{
/**************************************************
This error condition will be reached if for some
reason the query to retrieve functions for the
current action of the current doctype, from the
functions table has failed to execute. This
condition should never really be reached, but it
is my suggestion that if it has, it could be
because field names have been changed in the
functions table, or, more likely, because the
current action is an action that has been created
whereby a corresponding table in the MESS database
has not been created. (All actions must have a
corresponding functions table in MESS.
**************************************************/
# Make a query string to contain the error message to
# be displayed in the alert box...
$funcAlertString = "ERROR:\\n\\n"
. "Unable To Query The functions Table.\\n\\nIt"
. "is possible that field names in this table have"
. " been changed since this\\napplication was "
. "developed."
. "\\n\\nIt is also possible however, that "
. "the MESS action ($actItem) being queried for "
. "functions\\ndoes not have a corresponding "
. "functions table in the MESS database.\\n\\n"
. "All actions in MESS must have corresponding"
. " functions tables.";
# Display the error in an alert box...
print("<SCRIPT TYPE='text/javascript'>alert('"
. "$funcAlertString');</SCRIPT>");
/*********
It would be possible to terminate this script at
this point, but given that it may only be one
functions table that is unqueryable, processing
shall not be terminated, but left to display
other potential results
*********/
} // END else
} // END while
if($headerDrawn)
{
# Reset the headerDrawn flag so that the next document
# type can be tested appropriately...
$headerDrawn = 0;
print("</UL>\n</UL>\n");
} // END if
} // END if
else
{
# This error condition will be reached if for some reason
# the query to select actions belonging to a given doctype
# from the sbmIMPLEMENT table has failed. It should not
# ever really occurr, but it is my suggestion that if it
# has occurred, it is possible that field names in the
# table have been changed, or the sbmIMPLEMENT table name
# has been changed.
# Make an error query string...
$actErrorString = "Error:\\n\\nUnable to query the "
. "sbmIMPLEMENT table.\\n\\nIt is possible that the "
. "names"
. " of the fields in the sbmIMPLEMENT table\\nhave "
. "been changed since the MESS Administrator "
. "application was developed.\\n\\nContact the system"
. " administrator about this problem.";
print("<SCRIPT TYPE='text/javascript'>alert('"
. "$actErrorString');</SCRIPT>\n");
# Terminate the processing of the script...
killThisScript();
} // END else
} // END while
print("</TD>\n</TR>\n</TABLE>\n");
} // END if
else
{
# This error condition will be reached if for some reason the
# query to select doctypes from the sbmDOCTYPE table has failed. It
# should not occur, but is my suggestion that if it has, it is
# possible that field names in the sbmDOCTYPE table have changed, or
# the tablename has changed.
# Make an error query string...
$docErrorString = "ERROR\\n\\nUnable to query the sbmDOCTYPE "
. "table.\\n\\n"
. "It is possible that the names of the fields in the TEST\\n"
. "table have been changed since the MESS Administrator "
. "application was developed.\\n\\nContact the system "
. "administrator about this problem.";
# Output the error in a JavaScript aler box...
print("<SCRIPT TYPE='text/javascript'>alert('$docErrorString');"
. "</SCRIPT>\n");
# Terminate the processing of this script, as nothing further can
# be done if this query has failed...
killThisScript();
} // END else
} // END function makeFuncUsageList($doctypesQuery)
function displayPage()
{
global $function;
#######LOCKS#######
# Place a READ lock on the sbmDOCTYPE table
if($lockRes = mysql_query("LOCK TABLES sbmDOCTYPE READ"))
{
# We must execute a query to return a list of all document types in
# the MESS system. This can be obtained by querying the TEST
# table...
$doctypesQuery = mysql_query("SELECT sdocname, ldocname FROM sbmDOCTYPE ORDER
BY sdocname");
# We must unlock our table...
$unlockRes = mysql_query("UNLOCK TABLES");
# Make the list of doctypes and their actions that the function
# being examined is used in...
makeFuncUsageList($doctypesQuery, $function);
} # END if
else
{
# Could not get a lock...
print("<DIV STYLE='text-align: center; font-weight: bold; "
. "font-size: large; color: navy'>\n<SPAN STYLE='color: red'>"
. "Error:</SPAN> Unable to retrieve information.</DIV>\n".mysql_error()."<BR>\n");
} # END else
# Make a button to go back to the calling page...
print("<TABLE ALIGN='center' BORDER=0 CELLSPACING=0 CELLPADDING=0>\n"
. "<TR><FORM ACTION='listFunctions.php' METHOD='post'>\n<TD>"
. "<INPUT TYPE='button' VALUE='FINISHED' onClick=\"submit()\">"
. "</TD>\n</TR></TABLE>");
}
/**********************Start of main script***************************/
# Connect to the MySQL server
serverConnect(MYSQLDOCMACHINE, MYSQLDOCUSERID, MYSQLDOCPASSWORD);
# Select the CDS Search database...
dbSelect(DOCS_DATABASE);
if (!canUseWebSubmitAdmin($uid))
outWarning("You are not allowed to access WebSubmit Admin");
else
displayPage();
/************************End of main script***************************/
</protect>
?>

Event Timeline