Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93548832
UDF_edit.shtml.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
Fri, Nov 29, 15:49
Size
6 KB
Mime Type
text/html
Expires
Sun, Dec 1, 15:49 (2 d)
Engine
blob
Format
Raw Data
Handle
22661736
Attached To
R3600 invenio-infoscience
UDF_edit.shtml.wml
View Options
<?
/*********************************************************************
This file is part of the CERN Document Server Software (CDSware).
Copyright (C) 2002 CERN.
1211 Geneva 23 - Switzerland
<cds.support@cern.ch>
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
*********************************************************************/
//==========================================================================
// File: UDF_edit.shtml (flexElink WI)
// Description: Allows to modify UDF data and updates the changes in the DB.
// POST parameters:
// fname --> (required) Name (id) of the UDF to be modified
// process -> (optional) When is set, the script updates the UDF data
// in the DB with the parameter values
// params -> (optional) Contains the UDF param list. UDF parameters are
// separated by using ","
// fname_orig -> (required if process is set) Original name of the UDF
// to be updated (the UDF name can be changed)
// doc ----> (optional) Description of the purpose of the UDF
// code ---> (optional) UDF's PHP code
// Notes: If the format is succesfully updated in the DB it closes the current
// browser and refreshes the opener one
// Requires: DB, ERROR, EXECUTOR
// Author: Hector.Sanchez@cern.ch
//==========================================================================
include("localconf.inc.shtml");
include(DB);
include(ERROR);
if( (!isset($fname)) or (trim($fname)=="") )
{
print "<b>Function name</b> hasn't been specified";
print "<hr>";
print "<a align=\"center\" href=\"JavaScript:window.close();\">[Close]</a>";
exit;
}
$db=mysql_connect( $DB_HOST, $DB_USER, $DB_PASSWD );
mysql_selectdb( $DB_DB );
$fname=trim(strtoupper($fname));
//-------DISPLAY
if(!isset($process))
{
$qry="select code, doc
from flxUDFS
where fname='$fname'";
$qh=mysql_query( $qry );
if(mysql_num_rows( $qh )<1)
{
print "<b>Function</b> not found";
print "<hr>";
print "<a align=\"center\" href=\"JavaScript:window.close();\">[Close]</a>";
exit;
}
$row=mysql_fetch_array($qh);
list($code, $doc)=$row;
$qry="select pname
from flxUDFPARAMS
where fname='$fname'
order by ord";
$qh=mysql_query($qry, $db);
$params="";
while($row=mysql_fetch_array($qh))
{
$params.=$row[0].",";
}
$params=substr($params, 0, strlen($params)-1);
?>
<form action="UDF_edit.shtml" method="POST">
<table width="100%" bgcolor="#808080">
<tr align="center">
<td colspan="2" bgcolor="#FFFFFFCC">
<font size="4">Editing udf <b>'<? echo $fname;?>'</b></font>
</td>
</tr>
<tr bgcolor="#FFFFFFFF">
<td width="50%"><b>Function Name</b> <input type="text" name="fname" value="<?echo $fname;?>"></td>
<td width="50%"><b>Params</b> <input type="text" name="params" size="60" value="<?echo $params;?>"></td>
</tr>
<tr bgcolor="#FFFFFFFF" align="center">
<td colspan="2">
<br><b>Documentation</b><br>
<textarea name="doc" cols="100" rows="5"><?echo $doc;?></textarea>
</td>
</tr>
<tr align="center" bgcolor="#FFFFFFFF">
<td colspan="2" >
<br><b>PHP Code</b><br>
<textarea name="code" cols="100" rows="15"><?echo $code;?></textarea><br><br>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="UPDATE" name="btnUpd">
<input type="submit" value="UPDATE&CLOSE" name="btnUpdClose">
</td>
</tr>
</table>
<input type="hidden" name="process" value="oo">
<input type="hidden" name="fname_orig" value="<?echo $fname;?>">
</form>
<?
}
else
{
if(!isset($fname_orig) || (trim($fname_orig)==""))
{
print "Original function name incorrect or not found<hr>
<a href=\"JavaScript:window.history.go(-1)\">[Go Back]</a>";
exit;
}
if( (!isset($code)) )
$code="";
if( (!isset($doc)) )
$doc="";
if( (!isset($params)) )
$params="";
if(!get_magic_quotes_gpc())
{
$doc=addslashes($doc);
$code=addslashes($code);
}
$qry="update flxUDFS
set fname='$fname',
code='$code',
doc='$doc'
where fname='$fname_orig'";
if(!mysql_query( $qry ))
{
print "Impossible to update udf '$fname_orig':<br> ".mysql_error();
print "<hr><a href=\"JavaScript:window.history.go(-1)\">[Go Back]</a>";
exit();
}
$qry="delete from flxUDFPARAMS where fname='$fname_orig'";
if(!mysql_query( $qry ))
{
print "Function was updated but couldn't update udf params:<br> ".mysql_error();
print "<hr><a href=\"JavaScript:window.history.go(-1)\">[Go Back]</a>";
exit();
}
$params=explode(",", $params);
$count=0;
foreach($params as $param)
{
$param=trim($param);
if($param=="") continue;
$qry="insert into flxUDFPARAMS(fname, pname, ord)
values('$fname', '$param', $count)";
if(!mysql_query( $qry ))
{
print "Function parameter '$param' couldn't be inserted:<br> ".mysql_error();
print "<hr><a href=\"JavaScript:window.history.go(-1)\">[Go Back]</a>";
exit();
}
$count++;
}
mysql_close( $db );
?>
<script language="JavaScript">
opener.location.reload(false);
<?
if(isset($btnUpd))
print "window.location=\"UDF_edit.shtml?fname=$fname\";";
else
print "window.close();";
?>
</script>
<?
}
?>
Event Timeline
Log In to Comment