Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F80393420
editCatalogues.php.wml
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Aug 31, 12:14
Size
14 KB
Mime Type
text/x-c
Expires
Mon, Sep 2, 12:14 (2 d)
Engine
blob
Format
Raw Data
Handle
20354275
Attached To
R3600 invenio-infoscience
editCatalogues.php.wml
View Options
## $Id$
## This file is part of CDS Invenio.
## Copyright (C) 2002, 2003, 2004, 2005, 2006 CERN.
##
## CDS Invenio 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.
##
## CDS Invenio 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 CDS Invenio; 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="Organise webSubmit main page" \
navtrail_previous_links="<a class=navtrail href=<WEBURL>/admin/<lang:star: index.*.html>>_(Admin Area)_</a> > <a class=navtrail href=<WEBURL>/admin/websubmit/>_(WebSubmit Administration)_</a>" \
navbar_name="admin" \
navbar_select="websubmit_organise"
<?
<protect>
## $Id$
## DO NOT EDIT THIS FILE! IT WAS AUTOMATICALLY GENERATED FROM CDS Invenio WML SOURCES.
function makeCataloguesTable()
{
global $catalogues;
$queryResult = mysql_query("SELECT id_son FROM sbmCOLLECTION_sbmCOLLECTION "
. "where id_father=0 ORDER BY catalogue_order");
if($queryResult)
{
# Query has executed successfully, so we can proceed to display all
# catalogues in the EDS system...
if (mysql_num_rows($queryResult) == 0)
print "<h3>No catalogues yet...</h3>\n";
else
print "<UL>\n";
while ($row = mysql_fetch_array($queryResult))
{
array_push($catalogues,$row[id_son]);
displayCatalogueBranch($row[id_son],1);
}
if (mysql_num_rows($queryResult) != 0)
print "</UL>\n";
} // END if
else
{
# In this case, the query failed, so we can terminate the scripts
# running, and terminate the WebSubmit Administrator session, as no
# further actions can be carried out...
print("<H3>Error: Unable to retrieve data from the catalogues table."
. "</H3>\n");
} // END else
}
function displayCatalogueBranch($id_father,$level)
{
global $catalogues,$IMAGES;
$res = mysql_query("SELECT name,id FROM sbmCOLLECTION WHERE id=$id_father");
$row = mysql_fetch_row($res);
if ($level == 1)
print "<LI><font size=\"+1\"><strong>"
. $row[0]."</strong></font>\n";
elseif ($level == 2)
print "<LI>". $row[0]."\n";
elseif ($level > 2)
print "<LI>". $row[0]."\n";
print "<A HREF=\"editCatalogues.php?upCatalogue=yes&id=" .$row[1]. "\">"
. "<IMG SRC=\"".$IMAGES."/up.gif\" width=14 height=14 border=0 HSPACE=0 VSPACE=0 alt=up></A>\n";
print "<A HREF=\"editCatalogues.php?downCatalogue=yes&id=" .$row[1]. "\">"
. "<IMG SRC=\"".$IMAGES."/down.gif\" width=14 height=14 border=0 HSPACE=0 VSPACE=0 alt=down></A>\n";
print "<A HREF=\"editCatalogues.php?deleteCatalogue=yes&id=" .$row[1]
. "\" onClick=\"if (!confirm('Are you sure you want to delete this catalogue? "
. "All sub-catalogues will be deleted as well!')) {return false} \">"
. "<IMG SRC=\"".$IMAGES."/iconcross.gif\" border=0 HSPACE=0 VSPACE=0></A>\n";
// display the son document types
$res1 = mysql_query("SELECT id_son from sbmCOLLECTION_sbmDOCTYPE WHERE id_father=$id_father ORDER BY catalogue_order");
$res2 = mysql_query("SELECT id_son FROM sbmCOLLECTION_sbmCOLLECTION WHERE id_father=$id_father ORDER BY catalogue_order");
if (mysql_num_rows($res1) != 0 || mysql_num_rows($res2) != 0)
print "<UL>\n";
if (mysql_num_rows($res1) != 0)
while ($row = mysql_fetch_array($res1))
displayDoctypeBranch($row[id_son],$id_father);
// display the son catalogues
while ($row = mysql_fetch_array($res2))
{
array_push($catalogues,$row[id_son]);
displayCatalogueBranch($row[id_son],$level+1);
}
if (mysql_num_rows($res1) != 0 || mysql_num_rows($res2) != 0)
print "</UL>\n";
}
function displayDoctypeBranch($doctype,$id_father)
{
global $catalogues,$IMAGES;
$res = mysql_query("SELECT ldocname,sdocname FROM sbmDOCTYPE WHERE sdocname='$doctype'");
$row = mysql_fetch_row($res);
print "<LI><small>"
. "<a href=\"documentEDS.php?doctype=$doctype\">"
. $row[0]."</a></small>\n";
print "<A HREF=\"editCatalogues.php?upDoctype=yes&id=".$row[1]."&id_father=$id_father\">"
. "<IMG SRC=\"".$IMAGES."/up.gif\" width=14 height=14 border=0 HSPACE=0 VSPACE=0 alt=up></A>\n";
print "<A HREF=\"editCatalogues.php?downDoctype=yes&id=" .$row[1]. "&id_father=$id_father\">"
. "<IMG SRC=\"".$IMAGES."/down.gif\" width=14 height=14 border=0 HSPACE=0 VSPACE=0 alt=down></A>\n";
print "<A HREF=\"editCatalogues.php?deleteDoctype=yes&id=" .$doctype. "&id_father=$id_father"
. "\" onClick=\"if (!confirm('Are you sure you want to delete this document type? "
. "')) {return false} \">"
. "<IMG SRC=\"".$IMAGES."/iconcross.gif\" border=0 HSPACE=0 VSPACE=0></A>\n";
}
function deleteBranch($id)
{
// First delete the attached doctypes
$res = mysql_query("DELETE FROM sbmCOLLECTION_sbmDOCTYPE WHERE id_father=$id");
// Then the sub-catalogues
$res = mysql_query("SELECT id_son FROM sbmCOLLECTION_sbmCOLLECTION WHERE id_father=$id");
while ($row = mysql_fetch_row($res))
deleteBranch($row[0]);
// Then the catalogue itself
$res = mysql_query("DELETE FROM sbmCOLLECTION_sbmCOLLECTION WHERE id_son=$id");
$res2 = mysql_query("DELETE FROM sbmCOLLECTION WHERE id=$id");
if (!res || !$res2)
print "<h3><font color=red>WARNING:</font> Could not delete catalogue(<EM>".mysql_error()."</EM>)</h3>";
}
function deleteDoctype($id,$id_father)
{
$res = mysql_query("DELETE FROM sbmCOLLECTION_sbmDOCTYPE WHERE id_son='$id' and id_father='$id_father'");
if (!$res)
print "<h3><font color=red>WARNING:</font> Could not delete doctype(<EM>".mysql_error()."</EM>)</h3>";
}
function makeAddCatalogueInterface()
{
global $catalogues;
print "<SMALL>\n";
print("<H2>Add a Catalogue</H2>\n");
print("<br>");
print "<FORM>";
print "<INPUT type=hidden name=addCatalogue value=yes>\n";
print "Catalogue name:<br><INPUT size=50 name=catalogue_name>\n<br>";
print "Attached to: <SELECT name=attached>\n";
print "<OPTION value=\"0\"> top level\n";
reset($catalogues);
while (list($number,$value) = each($catalogues))
{
$res = mysql_query("SELECT name FROM sbmCOLLECTION WHERE id=$value");
$row = mysql_fetch_row($res);
print "<OPTION value=\"$value\">".$row[0]."\n";
}
print "</SELECT><br><br>\n";
print "<CENTER><INPUT type=button value=\"ADD\" onclick=\"submit();\">\n";
print " \n";
print "</CENTER></FORM>\n";
print "</SMALL>\n";
}
function makeAddDoctypeInterface()
{
global $catalogues;
print "<SMALL>\n";
print("<H2>Add a Document Type</H2>\n");
print("<br>");
print "<FORM>";
print "<INPUT type=hidden name=addDoctype value=yes>\n";
print "Document type name: <SELECT multiple name=doctype[] size=5>\n";
$res = mysql_query("SELECT sdocname,ldocname from sbmDOCTYPE order by ldocname");
while ($row = mysql_fetch_array($res))
print "<OPTION value=\"".$row[sdocname]."\">".$row[ldocname];
print "</SELECT>\n<br>";
print "Attached to: <SELECT name=attached>\n";
reset($catalogues);
while (list($number,$value) = each($catalogues))
{
$res = mysql_query("SELECT name FROM sbmCOLLECTION WHERE id=$value");
$row = mysql_fetch_row($res);
print "<OPTION value=\"$value\">".$row[0]."\n";
}
print "</SELECT><br><br>\n";
print "<CENTER><INPUT type=button value=\"ADD\" onclick=\"submit();\">\n";
print " \n";
print "</CENTER></FORM>\n";
print "</SMALL>\n";
}
function upCatalogue($id)
{
// Get father id
$res = mysql_query("SELECT id_father,catalogue_order FROM sbmCOLLECTION_sbmCOLLECTION WHERE id_son='$id'");
$row = mysql_fetch_row($res);
$id_father = $row[0];
$order = $row[1];
// Get smallest number before this one
$res = mysql_query("SELECT MAX(catalogue_order) FROM sbmCOLLECTION_sbmCOLLECTION WHERE id_father='$id_father' and catalogue_order < $order");
if (mysql_num_rows($res) != 0)
{
$row = mysql_fetch_row($res);
$neworder = $row[0];
mysql_query("UPDATE sbmCOLLECTION_sbmCOLLECTION SET catalogue_order='$order' WHERE id_father='$id_father' and catalogue_order='$neworder'");
mysql_query("UPDATE sbmCOLLECTION_sbmCOLLECTION SET catalogue_order='$neworder' where id_son='$id'");
}
}
function downCatalogue($id)
{
// Get father id
$res = mysql_query("SELECT id_father,catalogue_order FROM sbmCOLLECTION_sbmCOLLECTION WHERE id_son='$id'");
$row = mysql_fetch_row($res);
$id_father = $row[0];
$order = $row[1];
// Get smallest number after this one
$res = mysql_query("SELECT MIN(catalogue_order) FROM sbmCOLLECTION_sbmCOLLECTION WHERE id_father='$id_father' and catalogue_order > $order");
if (mysql_num_rows($res) != 0)
{
$row = mysql_fetch_row($res);
$neworder = $row[0];
mysql_query("UPDATE sbmCOLLECTION_sbmCOLLECTION SET catalogue_order='$order' WHERE id_father='$id_father' and catalogue_order='$neworder'");
mysql_query("UPDATE sbmCOLLECTION_sbmCOLLECTION SET catalogue_order='$neworder' where id_son='$id'");
}
}
function upDoctype($id,$id_father)
{
// Get current order
$res = mysql_query("SELECT catalogue_order FROM sbmCOLLECTION_sbmDOCTYPE WHERE id_son='$id' and id_father='$id_father'");
$row = mysql_fetch_row($res);
$order = $row[0];
// Get smallest number before this one
$res = mysql_query("SELECT MAX(catalogue_order) FROM sbmCOLLECTION_sbmDOCTYPE WHERE id_father='$id_father' and catalogue_order < $order");
if (mysql_num_rows($res) != 0)
{
$row = mysql_fetch_row($res);
$neworder = $row[0];
mysql_query("UPDATE sbmCOLLECTION_sbmDOCTYPE SET catalogue_order='$order' WHERE id_father='$id_father' and catalogue_order='$neworder'");
mysql_query("UPDATE sbmCOLLECTION_sbmDOCTYPE SET catalogue_order='$neworder' where id_son='$id'");
}
}
function downDoctype($id,$id_father)
{
// Get current order
$res = mysql_query("SELECT catalogue_order FROM sbmCOLLECTION_sbmDOCTYPE WHERE id_son='$id' and id_father='$id_father'");
$row = mysql_fetch_row($res);
$order = $row[0];
// Get smallest number after this one
$res = mysql_query("SELECT MIN(catalogue_order) FROM sbmCOLLECTION_sbmDOCTYPE WHERE id_father='$id_father' and catalogue_order > $order");
if (mysql_num_rows($res) != 0)
{
$row = mysql_fetch_row($res);
$neworder = $row[0];
mysql_query("UPDATE sbmCOLLECTION_sbmDOCTYPE SET catalogue_order='$order' WHERE id_father='$id_father' and catalogue_order='$neworder'");
mysql_query("UPDATE sbmCOLLECTION_sbmDOCTYPE SET catalogue_order='$neworder' where id_son='$id'");
}
}
/**********************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
{
if ($addCatalogue == "yes")
{
$res = mysql_query("INSERT INTO sbmCOLLECTION (name) VALUES ('$catalogue_name')");
if ($res)
{
$newid = mysql_insert_id();
$res = mysql_query("SELECT MAX(catalogue_order) FROM sbmCOLLECTION_sbmCOLLECTION where id_father='$attached'");
if (mysql_num_rows($res) != 0)
{
$row = mysql_fetch_row($res);
$order = $row[0] + 1;
}
else
$order = 1;
$res = mysql_query("INSERT INTO sbmCOLLECTION_sbmCOLLECTION (id_father,id_son,catalogue_order) VALUES ($attached,$newid,$order)");
}
else
print "<h3><font color=red>WARNING:</font> Could not insert new catalogue(<EM>".mysql_error()."</EM>)</h3>";
}
if ($addDoctype == "yes")
{
while ($currentdoc = current($doctype))
{
$res = mysql_query("SELECT MAX(catalogue_order) FROM sbmCOLLECTION_sbmDOCTYPE where id_father='$attached'");
if (mysql_num_rows($res) != 0)
{
$row = mysql_fetch_row($res);
$order = $row[0] + 1;
}
else
$order = 1;
$res = mysql_query("INSERT INTO sbmCOLLECTION_sbmDOCTYPE (id_father,id_son,catalogue_order) VALUES ('$attached','$currentdoc','$order')");
if (!$res)
print "<h3><font color=red>WARNING:</font> Could not insert new doctype(<EM>".mysql_error()."</EM>)</h3>";
next($doctype);
}
}
if ($deleteCatalogue == "yes")
deleteBranch($id);
if ($deleteDoctype == "yes")
deleteDoctype($id,$id_father);
if ($upCatalogue == "yes")
upCatalogue($id);
if ($downCatalogue == "yes")
downCatalogue($id);
if ($upDoctype == "yes")
upDoctype($id,$id_father);
if ($downDoctype == "yes")
downDoctype($id,$id_father);
# Now, display a quick set of page instructions for the user..
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\">This page is "
. "used for defining the catalogues which will appear on"
. " the CDS Submit main page.<br>These catalogues are not necessarily "
. "the same as those defined in the search interface (CDS Search)."
. "</P>\n</TD>\n</TR>\n</TABLE>\n");
print("<br><br>");
# Initialise catalogues array
$catalogues = array();
print "<table width=\"100%\" border=0>\n";
print "<tr><td valign=top>\n";
makeCataloguesTable();
print "</td><td valign=top>\n";
print "<table width=\"100%\" border=0 bgcolor=lightblue cellspacing=20>\n";
print "<tr><td valign=top>\n";
makeAddCatalogueInterface();
print "</td></tr><tr><td valign=top>\n";
makeAddDoctypeInterface();
print "</td></tr></table>\n";
print "</td></tr></table>\n";
print "<hr>\n";
print "<FORM action=index.php>";
print "<CENTER><INPUT type=button value=\"FINISHED\" onClick=\"document.location='index.php';\">\n";
print "</CENTER></FORM>\n";
}
/************************End of main script***************************/
</protect>
?>
Event Timeline
Log In to Comment