Page MenuHomec4science

referees.php.wml
No OneTemporary

File Metadata

Created
Mon, Jun 16, 01:05

referees.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="Referees 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" \
cdspageboxlefttopadd="<protect><?displayLoginMenu('submit');?></protect>"
<?
<protect>
## $Id$
## DO NOT EDIT THIS FILE! IT WAS AUTOMATICALLY GENERATED FROM CDSware WML SOURCES.
$idrule = getRuleID('referee');
/////////////////////////////////
// request for deleting a user //
/////////////////////////////////
if ($todo == "deleteuser")
{
mysql_query("
DELETE
FROM user_rule
WHERE id_user=$id and
id_rule=$idrule and
param1='$doctype' and
param2='$categ'");
}
////////////////////////////////
// request for adding user(s) //
////////////////////////////////
if ($todo == "adduser")
{
// For each id in the array
while ($addusersarray = each($addusers))
{
$addusersval = $addusersarray[1];
// First check whether this id is not already
// associated with this rule
$res = mysql_query("
SELECT id_user
FROM user_rule
WHERE id_rule=$idrule and
id_user=$addusersval and
param1='$doctype' and
param2='$param2'");
if (mysql_num_rows($res))
$warningText = "<font color=red>Sorry... This user is already a referee for this category.</font>";
else
{
// Actually add the user to the rule
$res = mysql_query("
INSERT
INTO user_rule(id_user,id_rule,param1,param2)
VALUES ('$addusersval','$idrule','$doctype','$param2')");
if (!$res)
$warningText = "<font color=red>".
"Sorry... ".
"This user cannot be a referee".
": ".mysql_error()."</font>";
}
}
}
function displayRefereesPage($doctype)
{
if ($doctype == "*")
$docname = "all catalogues";
else
{
$res = mysql_query("
SELECT *
FROM sbmDOCTYPE
WHERE sdocname='$doctype'");
$row = mysql_fetch_row($res);
$docname = $row[0];
}
print $warningText;
?>
<FORM ACTION='referees.php' METHOD='POST'>
<INPUT TYPE='hidden' NAME='todo' VALUE=''>
<INPUT TYPE='hidden' NAME='id' VALUE=''>
<INPUT TYPE='hidden' NAME='idrule' VALUE=''>
<?
print " <INPUT TYPE='hidden' NAME='doctype' VALUE='$doctype'>";
?>
<INPUT TYPE='hidden' NAME='categ' VALUE=''>
<!-- Role: referee -->
<TABLE><TR><TD valign=top>
<?
$usedids = array();
// call the function to display the table containing
// the list of associated emails
displayUserTable(getRuleID('referee'),"$doctype","%",$usedids);
?>
</TD>
<TD valign=top>
<?
// call the function to display the form allowing the
// manager to add new users
displayAddUser(getRuleID('referee'),"$doctype","%",$usedids);
?>
</TD></TR></TABLE>
<!-- End submissionuser rule -->
<SMALL>
<INPUT TYPE=submit VALUE='FINISHED' onclick="document.forms[1].action='documentEDS.php';document.forms[1].submit();">
</SMALL>
</FORM>
<?
}
function displayUserTable($idrule,$param1,$param2)
{
global $IMAGES;
// start displaying the table which will contain the list of
// email addresses.
print "<TABLE CELLSPACING=0 "
. "CELLPADDING=0 BORDER=0 bgcolor=#eeeeee>";
print "<TR><Td align=center colspan=2><small><b>Referees</b></small><hr></Td></TR>";
$res = mysql_query("
SELECT id_user,
param2
FROM user_rule
WHERE id_rule=$idrule and
param1='$param1'
ORDER BY param2");
if (mysql_num_rows($res) == 0)
print "<TR><TD align=center colspan=2><IMG SRC=\"$IMAGES/noway.gif\" height=16 width=16></TD></TR>";
$i = 0;
$currentcateg = "";
while ($row = mysql_fetch_row($res))
{
if (intval($i/2) == $i/2)
$bgcolor="#eeeeee";
else
$bgcolor="#dddddd";
if ($currentcateg != $row[1])
{
if ($row[1] != "*")
{
$res2 = mysql_query("
SELECT lname
FROM sbmCATEGORIES
WHERE sname='".$row[1]."' and
doctype='$param1'
");
$row2 = mysql_fetch_row($res2);
$categname = "Referee(s) for category: ".$row2[0];
}
else
$categname = "General Referee(s)";
print "<TR><TD colspan=2><small><b>$categname</b> </small></TD></TR>";
}
print "<TR bgcolor=$bgcolor>";
print "<TD align=right><small>";
$email = GetEmail($row[0]);
print $email;
print "</small></TD>";
print "<TD><a href=\"\" onClick=\"if (confirm('Are you sure you want to delete this referee?')){document.forms[1].todo.value='deleteuser';document.forms[1].id.value='".$row[0]."';document.forms[1].categ.value='".$row[1]."';document.forms[1].submit();return false;}else{return false;}\">";
print "<IMG SRC=\"$IMAGES/iconcross.gif\" border=0></a>";
print "</TD>";
print "</TR>";
$i++;
$currentcateg = $row[1];
}
// close table
print "</TABLE>";
}
function displayAddUser($idrule,$param1,$param2)
{
// start displaying the table which will contain the add
// form
print "<TABLE CELLSPACING=0 "
. "CELLPADDING=0 BORDER=0 BGCOLOR=#DDDDDD>";
print "<TR><TD><small>";
print "<CENTER><b>Add</b></CENTER>";
print "<hr>";
print "User:<br>";
$res = mysql_query("
SELECT id,
email
FROM user
WHERE email!=''
ORDER BY email");
if (mysql_num_rows($res) < 20)
$numrows = mysql_num_rows($res);
else
$numrows = 20;
print "<SELECT multiple name=addusers[] size=$numrows>";
while ($row = mysql_fetch_row($res))
{
print "<OPTION value=".$row[0].">".$row[1]."";
}
print "</SELECT><br>";
print "<SELECT name=param2>";
print "<OPTION value='*'>All categories";
$res = mysql_query("
SELECT lname,
sname
FROM sbmCATEGORIES
WHERE doctype='$param1'
ORDER BY lname");
while ($row = mysql_fetch_row($res))
{
print "<OPTION value=".$row[1].">".$row[0]."";
}
print "</SELECT><br>";
print "<INPUT type=button onClick=\"document.forms[1].todo.value='adduser';document.forms[1].submit();\" VALUE=\"ADD\">";
print "</small></TD></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,$doctype))
outWarning("You are not allowed to access WebSubmit Admin for this "
. "type of documents");
else
displayRefereesPage($doctype);
/************************End of main script***************************/
</protect>
?>

Event Timeline