Page MenuHomec4science

viewChecksEDS.php.wml
No OneTemporary

File Metadata

Created
Sat, Jun 29, 16:35

viewChecksEDS.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="Edit the <I><protect><?print $chname;?></protect></i> javascript checking function" \
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_listchecks"
<?
<protect>
## $Id$
## DO NOT EDIT THIS FILE! IT WAS AUTOMATICALLY GENERATED FROM CDSware WML SOURCES.
/********************Function Declarations****************************/
function errorOKbutton()
{
/*******************************************************************
This function has the simple task of creating an "OK" button,
which when pressed, sends the browser back to the
"allChecksEDS.php" page. It will only be displayed when there has
been some sort of error ocurrence.
Author: Nicholas Robinson
Email: Nicholas.Robinson@cern.ch
ca8nro@yahoo.co.uk
Created: 19/12/2000
Last Modified: 19/12/2000
*******************************************************************/
print("<TABLE ALIGN='center' CELLSPACING=0 CELLPADDING=0 BORDER=0>"
. "\n<FORM ACTION='allChecksEDS.php' METHOD='post'>\n<TR><TD ALIGN"
. "='center'>\n<INPUT TYPE='button' VALUE='OK' onClick=\"submit();"
. "\">\n</TD>\n</TR>\n</FORM>\n</TABLE>\n");
} // END function errorOKbutton()
//*************
function displayEDScheckDetsForm($chname)
{
/*****************************************************************
This function has the task of constructing the form that contains
the details of a given check that is to be viewed or editied. It
first conducts a query on the CHECK table to retrieve the details
of the check. If it can't, it displays the relevant error
messages. Otherwise, it displays all of the details of the check
in an HTML form. It also of course displays the buttons to
submit the form, or go back to another page.
Author: Nicholas Robinson
Email: Nicholas.Robinson@cern.ch
ca8nro@yahoo.co.uk
Created: 19/12/2000
Last Modified: 19/12/2000
*****************************************************************/
# Execute a query to retrieve the details of the given check...
$qRes = mysql_query("SELECT * FROM sbmCHECKS WHERE chname = "
. "'$chname'");
if($qRes)
{
# In this case, the query worked sans probleme
if(mysql_num_rows($qRes) < 1)
{
# Oh dear, the current check doesn't seem to exist.
print("<P CLASS=\"errorMsg\"><SPAN STYLE=\"color: red\">ERR"
. "OR:</SPAN> The $chname Checking Function Does Not Exist "
. "In " . DOCS_DATABASE . ".<BR>Inform System Administrator."
. "</P>\n");
# Display a button...
errorOKbutton();
# Now mail the admin to tell them this news.
$msgTxt = "An error has ocurred while attempting to retrieve "
. "the details of the $chname checking function from "
. DOCS_DATABASE . ". The query to select the details of this "
. "checking function returned no rows. There must have been "
. "a record for this checking function however, because the "
. "use must have clicked on a link for it to retrieve the "
. "details of it.\n\nThis suggests that there is a problem "
. "with concurrency. Perhaps another user deleted the check "
. "from " . DOCS_DATABASE . " just before the user who tried "
. "to view its details clicked on the link to it.\n\nEDS "
. "Administrator (";
$msgTxt .= makeDate();
$msgTxt .= ")";
# Now send the mail..
mail(ADMIN_EMAIL, "ERROR: Cannot Retrieve $chname Check "
. "Details", $msgTxt, "From: WebSubmit_Administrator");
} // END if
elseif(mysql_num_rows($qRes) > 1)
{
# Oh dear...several instances of the current check!
print("<P CLASS=\"errorMsg\"><SPAN STYLE=\"color: red\">ERR"
. "OR:</SPAN> Several Rows Have Been Retrieved For The "
. "<EM>$chname</EM> Checking Function.<BR>Inform System "
. "Administrator.</P>\n");
errorOKbutton();
# Now mail the admin to tell them this news.
$msgTxt = "An error has ocurred while attempting to retrieve "
. "the details of the $chname checking function from "
. DOCS_DATABASE . ". The query to select the details of this "
. "checking function returned several rows. The 'chname' "
. "field of the sbmCHECKS table should be unique, as it is used "
. "as the key of the table. This means that there should "
. "only ever be 1 row in the sbmCHECKS table for a given chname "
. "value.\n\nThis means that there must be key violations in "
. "the sbmCHECKS table, and this problem should be examined and "
. "corrected immediately.\n\nWebSubmit Administrator (";
$msgTxt .= makeDate();
$msgTxt .= ")";
# Now send the mail..
mail(ADMIN_EMAIL, "ERROR: sbmCHECKS Table Key Violation "
. "($chname)", $msgTxt, "From: WebSubmit_Administrator");
} // END elseif
else
{
# Perfect! Only one row for this check, as expected...
# Provide a quick description of the pages function...
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\">Below, is a"
. " table that allows you to view or edit the details of an "
. "EDS JavaScript checking function.<BR><BR>If you wish to "
. "edit the checking function, you can edit the details of "
. "the <EM>Check Description</EM> field, and then click on"
. " the \"SAVE CHANGES\" button.<BR>If you do not wish to "
. "make any changes to the checking function, simply click on"
. " the \"FINISHED\" button, which will return you to the "
. "page<BR>displaying a list of all checks.</P>\n</TD>\n</TR>"
. "\n</TABLE>\n");
# Make a horizontal rule to divide the page sections...
drawSeparator();
# Get a list of the fields in the sbmCHECKS table
$columns = mysql_list_fields(DOCS_DATABASE, "sbmCHECKS");
# Get the details of the current check to display
$dataRow = mysql_fetch_array($qRes);
# Now begin making the form...
print("<TABLE WIDTH='100%' ALIGN='center' BORDER=0 "
. "CELLSPACING=0 CELLPADDING=0>\n<FORM ACTION='viewChecksEDS"
. ".php' METHOD='post'>\n<INPUT TYPE='hidden' NAME='update"
. "Check' VALUE='true'>\n<TR>\n<TH BGCOLOR='#D3DCE3' ALIGN"
. "='right' WIDTH='20%'>Creation Date:&nbsp;</TH>\n<TD ALI"
. "GN='left' BGCOLOR='#FFFFCC' WIDTH='80%'><INPUT TYPE='"
. "readonly' NAME='cd' VALUE='". $dataRow["cd"] . "'></TD>\n"
. "<TR>\n<TH BGCOLOR='#D3DCE3' ALIGN='right' WIDTH='20%'>"
. "Modification Date:&nbsp;</TH>\n<TD ALIGN='left' BGCOLOR='"
. "#FFFFCC' WIDTH='80%'><INPUT TYPE='readonly' NAME='md' "
. "VALUE='" . $dataRow["md"] . "'></TD>\n</TR>\n<TR>\n<TH BG"
. "COLOR='#D3DCE3' ALIGN='right' WIDTH='20%'>Check Name:"
. "&nbsp;</TH>\n<TD ALIGN='left' WIDTH='80%' BGCOLOR='#FFFFC"
. "C'><INPUT TYPE='readonly' NAME='chname' VALUE='"
. $dataRow["chname"] . "'>\n</TD>\n</TR>\n<TR>\n<TH "
. "BGCOLOR='#87CEFA' ALIGN='right' WIDTH='20%'>Check "
. "Description:&nbsp;</TH>\n<TD ALIGN='left' BGCOLOR='#FFFFC"
. "C' WIDTH='80%'><TEXTAREA COLS=50 ROWS=20 NAME='chdesc'>"
. $dataRow["chdesc"] . "</TEXTAREA></TD>\n</TR>\n</TABLE>\n");
# Now make an other table to hold the various buttons...
print("<TABLE BORDER=0 CELLPADDING=2 CELLSPACING=2 ALIGN='"
. "center'>\n<TR>\n<TD ALIGN='right'><INPUT TYPE='button' "
. "VALUE='SAVE CHANGES' onClick=\"if(confirm('Are You Sure "
. "That You Wish To Alter This Checking Function Descriptio"
. "n?')) { submit(); }\"></TD>\n<TD ALIGN='center'><INPUT "
. "TYPE='button' "
. "VALUE='RESET' onClick=\"reset();\"></TD>\n</FORM>\n<FORM "
. "ACTION='allChecksEDS.php' METHOD='post'>\n<TD ALIGN='left"
. "'><INPUT TYPE='button' VALUE='CANCEL' onClick=\"submit();"
. "\"></TD>\n</TR>\n</TABLE>\n");
} // END else
} // END if
else
{
# In this case, the query to retrieve the details of the given
# check failed, so we can simply output an error message...
print("<P CLASS=\"errorMsg\"><SPAN STYLE=\"color: red\">ERROR:"
. "</SPAN> Could not query the <EM>sbmCHECKS</EM> table of "
. DOCS_DATABASE . ".<BR>Contact System Administrator.</P>\n");
# Add a button...
errorOKbutton();
} // END else
} // END function displayEDScheckDetsForm()
function displayPage()
{
global $updateCheck,$chdesc,$chname;
if($updateCheck)
{
# In this case, this call to the script is a call to commit
# updated details of the given check to the database.
# Get the date for the md field...
$modifiedDate = makeEDSmdDate();
# Make an update string...
$updStr = "UPDATE sbmCHECKS SET md = '$modifiedDate', chdesc = '"
. "$chdesc' WHERE chname = '$chname'";
# Now execute the update...
$updRes = mysql_query($updStr);
if($updRes)
{
# The query has worked...
if(mysql_affected_rows() == 1)
{
# In this case, the check has been updated, and we can
# simply let the user know of the update, inform the admin
# of it, and redisplay the check in the form.
print("<SCRIPT TYPE='text/javascript'>\nalert('The Check"
. "ing Function Has Been Updated.');\n</SCRIPT>\n");
$msgTxt = "The $chname checking function has been updated"
. " in " . DOCS_DATABASE . ".\n\nWebSubmit Administrator (";
$msgTxt .= makeDate();
$msgTxt .= ")";
# Now send the mail..
mail(ADMIN_EMAIL, "$chname Check Updated",
$msgTxt, "From: WebSubmit_Administrator");
# Now free the update query result...
mysql_free_result($updRes);
# Redisplay the form with the check in it
displayEDScheckDetsForm($chname);
} // END if
else
{
# The query didn't actually update anything. Hmm.
print("<SCRIPT TYPE='text/javascript'>alert('The Check Wa"
. "s Not Updated. It Is Possible That The Check Descript"
. "ion Was Not Changed.');\n</SCRIPT>\n");
displayEDScheckDetsForm($chname);
} // END else
} // END if
else
{
# In this case, the update has failed, so we can just inform
# the user of this, and redisplay the details of the check in
# the form (pre update - perhaps the user wrote weird stuff,
# or too much).
print("<SCRIPT TYPE='text/javascript'>\nalert('ERROR: It was "
. "not possible to update this check. The current saved vers"
. "ion of it has been redisplayed.\\nIt is possible that the "
. "values entered for the check were in some way invalid.\\n"
. "\\nPlease inform the system administrator if you think "
. "there is a problem.');\n</SCRIPT>\n");
# Now redisplay the check details in the form...
displayEDScheckDetsForm($chname);
} // END else
} // END if
else
{
# In this case, this is the first call to the script, and we must
# simply display the details of the given check in a form, ready
# for viewing or updating as appropriate.
# Display the interface...
displayEDScheckDetsForm($chname);
} // 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