Location: PHPKode > projects > Openelibrary > e-library/autoriedit.php
<?php 
session_start();
ob_start();
?>
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1 
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
?>
<?php
if (@phpversion() >= '5.0.0' && (!@ini_get('register_long_arrays') || @ini_get('register_long_arrays') == '0' || strtolower(@ini_get('register_long_arrays')) == 'off')) { // PHP5 with register_long_arrays off
	$HTTP_POST_VARS = &$_POST;
	$HTTP_GET_VARS = &$_GET;
	$HTTP_SERVER_VARS = &$_SERVER;
	$HTTP_COOKIE_VARS = &$_COOKIE;
	$HTTP_ENV_VARS = &$_ENV;
	$HTTP_POST_FILES = &$_FILES;
	if (isset($_SESSION)) $HTTP_SESSION_VARS = &$_SESSION;
}
?>
<?php include ("ewconfig.php") ?>
<?php include ("db.php") ?>
<?php include ("autoriinfo.php") ?>
<?php include ("advsecu.php") ?>
<?php include ("phpmkrfn.php") ?>
<?php include ("ewupload.php") ?>
<?php
	if (!IsLoggedIn() && (@$HTTP_COOKIE_VARS[ewCookieAutoLogin] == "autologin" && @$HTTP_COOKIE_VARS[ewCookiePassword] <> "")) {
		ob_end_clean();
		header("Location: login.php");
		exit();
	}
	LoadUserLevel();
	$ewCurSec = (IsLoggedIn())? CurrentUserLevelPriv("autori") : GetAnonymousPriv("autori");
	if (($ewCurSec & ewAllowEdit) <> ewAllowEdit) {
		ob_end_clean();
		header("Location: autorilist.php");
		exit();
	}
if (CurrentUserID() == "") {
	ob_end_clean();
	header("Location: login.php");
	exit();
}
?>
<?php
include('include/variables.php');

?>

<?php

// Load key from QueryString
$x_id_autore = @$HTTP_GET_VARS["id_autore"];

// Get action
$sAction = @$HTTP_POST_VARS["a_edit"];
if ($sAction == "") {
	$sAction = "I";	// Display record	
} else {

	// Get fields from form
	$x_id_autore = @$HTTP_POST_VARS["x_id_autore"];
	$x_title = @$HTTP_POST_VARS["x_title"];
	$x_subtitle = @$HTTP_POST_VARS["x_subtitle"];
	$x_title_en = @$HTTP_POST_VARS["x_title_en"];
	$x_subtitle_en = @$HTTP_POST_VARS["x_subtitle_en"];
	$x_Autore = @$HTTP_POST_VARS["x_Autore"];
	$x_id_tip_autore = @$HTTP_POST_VARS["x_id_tip_autore"];
	$x_id_autor_gender = @$HTTP_POST_VARS["x_id_autor_gender"];
	$x_abstract = @$HTTP_POST_VARS["x_abstract"];
	$x_id_thematic = @$HTTP_POST_VARS["x_id_thematic"];
	$x_semantic = @$HTTP_POST_VARS["x_semantic"];
	$x_anno_pub = @$HTTP_POST_VARS["x_anno_pub"];
	$x_id_place_city = @$HTTP_POST_VARS["x_id_place_city"];
	$x_Editorial_Publisher = @$HTTP_POST_VARS["x_Editorial_Publisher"];
	$x_id_language = @$HTTP_POST_VARS["x_id_language"];
	$x_id_version = @$HTTP_POST_VARS["x_id_version"];
	$x_id_tipo_testo = @$HTTP_POST_VARS["x_id_tipo_testo"];
$x_id_resource_format = @$HTTP_POST_VARS["x_id_resource_format"];

	$x_id_license = @$HTTP_POST_VARS["x_id_license"];
	$x_Extension = @$HTTP_POST_VARS["x_Extension"];
	$x_associated_image_Picture = @$HTTP_POST_VARS["x_associated_image_Picture"];
	$x_id_access = @$HTTP_POST_VARS["x_id_access"];
	$x_access_type_a = @$HTTP_POST_VARS["x_access_type_a"];
	$x_articolo = @$HTTP_POST_VARS["x_articolo"];
	$x_access_type_c = @$HTTP_POST_VARS["x_access_type_c"];
	$x_bib_reference = @$HTTP_POST_VARS["x_bib_reference"];
	$x_comments = @$HTTP_POST_VARS["x_comments"];
	$x_contact_e_mail = @$HTTP_POST_VARS["x_contact_e_mail"];
	$x_EmpoloyeeID = @$HTTP_POST_VARS["x_EmpoloyeeID"];
	$x_data_entrance = @$HTTP_POST_VARS["x_data_entrance"];
	$x_access_type_b = @$HTTP_POST_VARS["x_access_type_b"];
	$x_access_type_d = @$HTTP_POST_VARS["x_access_type_d"];
	$x_associated_image_Name = @$HTTP_POST_VARS["x_associated_image_Name"];
	$x_associated_image__Type = @$HTTP_POST_VARS["x_associated_image__Type"];
	$x_associated_image_Width = @$HTTP_POST_VARS["x_associated_image_Width"];
	$x_associated_image_Height = @$HTTP_POST_VARS["x_associated_image_Height"];
	$x_associated_image_Size = @$HTTP_POST_VARS["x_associated_image_Size"];
	$x_id_thematic_2 = @$HTTP_POST_VARS["x_id_thematic_2"];
	$x_id_thematic_3 = @$HTTP_POST_VARS["x_id_thematic_3"];
	$x_id_tipo_testo_2 = @$HTTP_POST_VARS["x_id_tipo_testo_2"];
	$x_id_thematic_4 = @$HTTP_POST_VARS["x_id_thematic_4"];
}
if (($x_id_autore == "") || ($x_id_autore == NULL)) {
	ob_end_clean();
	header("Location: autorilist.php");
	exit();
}
$conn = phpmkr_db_connect(HOST, USER, PASS, DB, PORT);
switch ($sAction) {
	case "I": // Display record
		if (!LoadData($conn)) { // Load record
			$HTTP_SESSION_VARS[ewSessionMessage] = "No records found";
			phpmkr_db_close($conn);
			ob_end_clean();
			header("Location: autorilist.php");
			exit();
		}
		break;
	case "U": // Update
		if (EditData($conn)) { // Update record
			$HTTP_SESSION_VARS[ewSessionMessage] = "Update Record Successful";
			phpmkr_db_close($conn);
			ob_end_clean();
			header("Location: autorilist.php");
			exit();
		}
		break;
}
?>
<?php include ("header.php") ?>
<script type="text/javascript">
<!--
EW_LookupFn = "ewlookup.php"; // ewlookup file name
EW_AddOptFn = "ewaddopt.php"; // ewaddopt.php file name
EW_MultiPagePage = "Page"; // multi-page Page Text
EW_MultiPageOf = "of"; // multi-page Of Text

//-->
</script>
<script type="text/javascript" src="ewp.js"></script>
<script type ="text/javascript" src="ewast.js"></script>
<script type="text/javascript">
<!--
EW_dateSep = "/"; // set date separator	

//-->
</script>
<script type="text/javascript">
<!--
function EW_checkMyForm(EW_this) {
if (EW_this.x_title && !EW_hasValue(EW_this.x_title, "TEXT" )) {
	if (!EW_onError(EW_this, EW_this.x_title, "TEXT", "Please enter required field - Title (Language of the material)"))
		return false;
}
if (EW_this.x_Autore && !EW_hasValue(EW_this.x_Autore, "TEXT" )) {
	if (!EW_onError(EW_this, EW_this.x_Autore, "TEXT", "Please enter required field - Author(s)"))
		return false;
}
if (EW_this.x_id_tip_autore && !EW_hasValue(EW_this.x_id_tip_autore, "SELECT" )) {
	if (!EW_onError(EW_this, EW_this.x_id_tip_autore, "SELECT", "Please enter required field - Type of author"))
		return false;
}
if (EW_this.x_id_autor_gender && !EW_hasValue(EW_this.x_id_autor_gender, "SELECT" )) {
	if (!EW_onError(EW_this, EW_this.x_id_autor_gender, "SELECT", "Please enter required field - Gender author"))
		return false;
}
if (EW_this.x_abstract && !EW_hasValue(EW_this.x_abstract, "TEXTAREA" )) {
	if (!EW_onError(EW_this, EW_this.x_abstract, "TEXTAREA", "Please enter required field - Abstract"))
		return false;
}
if (EW_this.x_anno_pub && !EW_hasValue(EW_this.x_anno_pub, "TEXT" )) {
	if (!EW_onError(EW_this, EW_this.x_anno_pub, "TEXT", "Please enter required field - Year Publication"))
		return false;
}
if (EW_this.x_anno_pub && !EW_checkinteger(EW_this.x_anno_pub.value)) {
	if (!EW_onError(EW_this, EW_this.x_anno_pub, "TEXT", "Incorrect integer - Year Publication"))
		return false; 
}
if (EW_this.x_id_language && !EW_hasValue(EW_this.x_id_language, "SELECT" )) {
	if (!EW_onError(EW_this, EW_this.x_id_language, "SELECT", "Please enter required field - Language (s)"))
		return false;
}
if (EW_this.x_id_license && !EW_hasValue(EW_this.x_id_license, "SELECT" )) {
	if (!EW_onError(EW_this, EW_this.x_id_license, "SELECT", "Please enter required field - License"))
		return false;
}
if (EW_this.x_Extension && !EW_checkinteger(EW_this.x_Extension.value)) {
	if (!EW_onError(EW_this, EW_this.x_Extension, "TEXT", "Incorrect integer - Extension"))
		return false; 
}
if (EW_this.x_data_entrance && !EW_hasValue(EW_this.x_data_entrance, "TEXT" )) {
	if (!EW_onError(EW_this, EW_this.x_data_entrance, "TEXT", "Please enter required field - Data entrance"))
		return false;
}
if (EW_this.x_data_entrance && !EW_checkeurodate(EW_this.x_data_entrance.value)) {
	if (!EW_onError(EW_this, EW_this.x_data_entrance, "TEXT", "Incorrect date, format = dd/mm/yyyy - Data entrance"))
		return false; 
}
return true;
}

//-->
</script>
<script type="text/javascript">
<!--
	var EW_DHTMLEditors = [];

//-->
</script>
<link rel="stylesheet" type="text/css" media="all" href="calendar/calendar-win2k-1.css" title="win2k-1" />
<script type="text/javascript" src="calendar/calendar.js"></script>
<script type="text/javascript" src="calendar/lang/calendar-en.js"></script>
<script type="text/javascript" src="calendar/calendar-setup.js"></script>



<script type="text/javascript">
function biblio(){
//alert(document.fautoriadd.x_title.value);
<!--
var string="";
string += document.fautoriedit.x_Autore.value+". ";
string += document.fautoriedit.x_title.value+" [online]. ";
string += document.fautoriedit.x_anno_pub.value+". ";
string += " Available from: <http://www.openelibrary.info>.";

document.fautoriedit.x_bib_reference.value=string;
}
//-->
<!--
	var EW_DHTMLEditors = [];


function textCounter( field, countfield, maxlimit ) {
  if ( field.value.length > maxlimit )
  {
    field.value = field.value.substring( 0, maxlimit );
    alert( 'Textarea value can only be '+maxlimit+' characters in length.' );
    return false;
  }
  else
  {
    countfield.value = maxlimit - field.value.length;
  }
}


//-->
</script>


<? /**********************************************/ ?>
<div id="content">
	<div id="content2">
<? include('basketbox.php'); ?>
<? include('latestentries.php'); ?>
	</div>
	<div id="content1">
		<h1>Edit a resource</h1>
<form name="fautoriedit" id="fautoriedit" action="autoriedit.php" method="post" enctype="multipart/form-data" onSubmit="return EW_checkMyForm(this);">
	<h2><input type="hidden" id="x_id_autore" name="x_id_autore" value="<?php echo @$x_id_autore; ?>"><?php echo COPYINFO ?></h2>
	<input type="hidden" name="a_edit" value="U" />
	<input type="hidden" name="EW_Max_File_Size" value="1000000" />
<?php if (@$HTTP_SESSION_VARS[ewSessionMessage] <> "") { ?>
	<p><span class="ewmsg"><?php echo $HTTP_SESSION_VARS[ewSessionMessage]; ?></span></p>
<?php $HTTP_SESSION_VARS[ewSessionMessage] = ""; // Clear message
} ?>
	<input type="hidden" name="a_add" value="A" />
	<input type="hidden" name="EW_Max_File_Size" value="1000000" />
<?php if (@$HTTP_SESSION_VARS[ewSessionMessage] <> "") { ?>
	<p><span class="ewmsg"><?php echo $HTTP_SESSION_VARS[ewSessionMessage] ?></span></p>
<?php $HTTP_SESSION_VARS[ewSessionMessage] = ""; // Clear message 
} ?>
<table class="resource_description">
	<tr id="r_title">
		<th>
	<? echo TITLE_RES ?><span class="asterisk">&nbsp;*</span><br />
					<? echo TITLE_RES2 ?>
			
		</th>
		<td>



					<textarea  style="width: 100%;"  name="x_title" id="x_title" maxlength="250" rows=3 onchange="javascript:biblio();"
onkeypress="textCounter(this,this.form.counter,250);"  ><?php echo htmlspecialchars(@$x_title) ?></textarea><br />

<input name="counter" maxlength="3" size="3" value="255" type="text"> characters remaining
	


			<label for="x_id_language"><? echo LANGUAGE ?>:&nbsp;</label>
			<?php

$x_id_languageList = "<select id='x_id_language' name='x_id_language'>";
$x_id_languageList .= "<option value=''>Please Select</option>";
$sSqlWrk = "SELECT `id_language`, `language` FROM `language`";
$sSqlWrk .= " ORDER BY `language` Asc";
$rswrk = phpmkr_query($sSqlWrk,$conn) or die("Failed to execute query at line " . __LINE__ . ": " . phpmkr_error($conn) . '<br>SQL:' . $sSqlWrk);

if ($rswrk) {
	$rowcntwrk = 0;
	while ($datawrk = phpmkr_fetch_array($rswrk)) {
		$x_id_languageList .= "<option value=\"" . htmlspecialchars($datawrk[0]) . "\"";
		if ($datawrk["id_language"] == @$x_id_language) {
			$x_id_languageList .= " selected";
		}
		$x_id_languageList .= ">" . $datawrk["language"] . "</option>";
		$rowcntwrk++;
	}
}

@phpmkr_free_result($rswrk);

$x_id_languageList .= "</select>";
echo $x_id_languageList;

?>

&nbsp;<a href="javascript:void(0);" onclick="EW_ShowAddOption('x_id_language');">Add Language (s)</a>

<div id="ao_x_id_language" style="display: none;">

<input type="hidden" id="ltn_x_id_language" value="language">

<input type="hidden" id="lfn_x_id_language" value="id_language">

<input type="hidden" id="dfn_x_id_language" value="language">

<input type="hidden" id="lfm_x_id_language" value="Please enter required field - id language">

<input type="hidden" id="dfm_x_id_language" value="Please enter required field - language">

<input type="hidden" id="lfq_x_id_language" value="">

<input type="hidden" id="dfq_x_id_language" value="'">

<p><input type="text" id="df_x_id_language" size="30"> <input type="button" value="ADD" onClick="EW_PostNewOption('x_id_language')"><input type="button" value="CANCEL" onClick="EW_HideAddOption('x_id_language')">
</p>

</div>

			
		</td>
	</tr>
	<tr id="r_title_en">
		<th>
			<strong><? echo ENGTITLE ?></strong><span class="asterisk">&nbsp;*</span><br />
					<? echo TITLE_RES2 ?>
		</th>

		<td class="title_en">
			<span id="cb_x_title_en">




					<textarea  style="width: 100%;"  name="x_title_en" id="x_title_en" maxlength="250" rows=3 onchange="javascript:biblio();"
onkeypress="textCounter(this,this.form.counter2,250);"  ><?php echo htmlspecialchars(@$x_title_en) ?></textarea><br />

<input name="counter2" maxlength="3" size="3" value="255" type="text"> characters remaining


			</span>
		</td>
	</tr>
	<tr id="r_abstract">
		<th>
			<strong><? echo ABS ?></strong><span class="asterisk">&nbsp;*</span><br /><? echo ABS_TEXT ?>

		</th>
		<td>
<textarea cols="50" rows="5" id="x_abstract" name="x_abstract"><?php echo @$x_abstract; ?></textarea>

		</td>

	</tr>
	<tr id="r_Autore">
		<th><strong><? echo AUTS ?></strong><span class="asterisk">&nbsp;*</span></th>

		<td class="authors">
			<div id="cb_x_Autore" class="author person">
				<ul>
					<li>
					<!--
						<input type="text" name="fn_1" id="fn_1" size="20" maxlength="256" value="First name" class="fn" />,&nbsp;<input type="text" name="n_1" id="n_1" size="20" maxlength="256" value="Name" class="n" /><input type="submit" value="Delete this author" name="delete_author" />
-->
<input type="text" name="x_Autore" id="x_Autore" maxlength="100" value="<?php echo htmlspecialchars(@$x_Autore) ?>" onchange="javascript:biblio();">
<br />
						<label for="x_id_autor_gender"><? echo GENDER ?>:&nbsp;</label>
						<?php

$x_id_autor_genderList = "<select id='x_id_autor_gender' name='x_id_autor_gender'>";

$x_id_autor_genderList .= "<option value=''>Please Select</option>";

$sSqlWrk = "SELECT DISTINCT `id_gender`, `author_gender` FROM `author_gender`";

$sSqlWrk .= " ORDER BY `author_gender` Asc";

$rswrk = phpmkr_query($sSqlWrk,$conn) or die("Failed to execute query at line " . __LINE__ . ": " . phpmkr_error($conn) . '<br>SQL:' . $sSqlWrk);

if ($rswrk) {

	$rowcntwrk = 0;

	while ($datawrk = phpmkr_fetch_array($rswrk)) {

		$x_id_autor_genderList .= "<option value=\"" . htmlspecialchars($datawrk[0]) . "\"";

		if ($datawrk["id_gender"] == @$x_id_autor_gender) {

			$x_id_autor_genderList .= " selected";

		}

		$x_id_autor_genderList .= ">" . $datawrk["author_gender"] . "</option>";

		$rowcntwrk++;

	}

}

@phpmkr_free_result($rswrk);

$x_id_autor_genderList .= "</select>";

echo $x_id_autor_genderList;

?>
						


		<a href="javascript:void(0);" onclick="EW_ShowAddOption('x_id_autor_gender');"><? echo ADDGENDER ?></a>

		</span><span>

		<div id="ao_x_id_autor_gender" style="display: none;">
		<input type="hidden" id="ltn_x_id_autor_gender" value="author_gender">
		<input type="hidden" id="lfn_x_id_autor_gender" value="id_gender">
		<input type="hidden" id="dfn_x_id_autor_gender" value="author_gender">
		<input type="hidden" id="lfm_x_id_autor_gender" value="Please enter required field - id gender">
		<input type="hidden" id="dfm_x_id_autor_gender" value="Please enter required field - author gender">
		<input type="hidden" id="lfq_x_id_autor_gender" value="">
		<input type="hidden" id="dfq_x_id_autor_gender" value="'">
		<span id="add_gender_1">
<input type="text" id="df_x_id_autor_gender" size="30"><input type="button" value="ADD" onClick="EW_PostNewOption('x_id_autor_gender')"><input type="button" value="CANCEL" onClick="EW_HideAddOption('x_id_autor_gender')">

		</span>

		</div><br />

		<label for="x_id_tip_autore"><? echo TYPE ?>:&nbsp;</label>
		<?php

		$x_id_tip_autoreList = "<select id='x_id_tip_autore' name='x_id_tip_autore'>";
		$x_id_tip_autoreList .= "<option value=''>Please Select</option>";
		$sSqlWrk = "SELECT `id_tipo_autore`, `tipo_autore` FROM `tipo_autore`";
		$sSqlWrk .= " ORDER BY `tipo_autore` Asc";
		$rswrk = phpmkr_query($sSqlWrk,$conn) or die("Failed to execute query at line " . __LINE__ . ": " . phpmkr_error($conn) . '<br>SQL:' . $sSqlWrk);
		if ($rswrk) {
			$rowcntwrk = 0;
			while ($datawrk = phpmkr_fetch_array($rswrk)) {
				$x_id_tip_autoreList .= "<option value=\"" . htmlspecialchars($datawrk[0]) . "\"";
				if ($datawrk["id_tipo_autore"] == @$x_id_tip_autore) {
					$x_id_tip_autoreList .= " selected";
				}
				$x_id_tip_autoreList .= ">" . $datawrk["tipo_autore"] . "</option>";
				$rowcntwrk++;
			}
		}
		@phpmkr_free_result($rswrk);
		$x_id_tip_autoreList .= "</select>";
		echo $x_id_tip_autoreList;
		?>
		<a href="javascript:void(0);" onclick="EW_ShowAddOption('x_id_tip_autore');">Add Type of author</a>
				
			<div id="ao_x_id_tip_autore" style="display: none;">

			<input type="hidden" id="ltn_x_id_tip_autore" value="tipo_autore">

			<input type="hidden" id="lfn_x_id_tip_autore" value="id_tipo_autore">

			<input type="hidden" id="dfn_x_id_tip_autore" value="tipo_autore">

			<input type="hidden" id="lfm_x_id_tip_autore" value="Please enter required field - id tipo autore">

			<input type="hidden" id="dfm_x_id_tip_autore" value="Please enter required field - tipo autore">

			<input type="hidden" id="lfq_x_id_tip_autore" value="">

			<input type="hidden" id="dfq_x_id_tip_autore" value="'">

			<span id="add_author_type_1"><input type="text" id="df_x_id_tip_autore" size="30"><input type="button" value="ADD" onClick="EW_PostNewOption('x_id_tip_autore')"><input type="button" value="CANCEL" onClick="EW_HideAddOption('x_id_tip_autore')">
			</span>			
			</div>
			<br />
					<label for="x_id_autor_email">e-mail:&nbsp;</label><input type="text" name="x_contact_e_mail" id="x_contact_e_mail" size="40" maxlength="100" value="<?php echo htmlspecialchars(@$x_contact_e_mail) ?>">
					</li>

				</ul>
				<!-- <p><input type="submit" value="Add a new author" name="add_author" /></p> -->
			</div>
		</td>
	</tr>
	<tr id="r_anno_pub">

		<th><strong><? echo YEAROFPUB ?></strong><span class="asterisk">&nbsp;*</span></th>
		<td>
			<input type="text" name="x_anno_pub" id="x_anno_pub" size="4" value="<?php echo htmlspecialchars(@$x_anno_pub) ?>">
		</td>
	</tr>
	<tr id="r_id_license">
		<th><strong><? echo LICENZE ?></strong><span class="asterisk">&nbsp;*</span></th>

		<td>
			

<?php

$x_id_licenseList = "<select id='x_id_license' name='x_id_license'>";

$x_id_licenseList .= "<option value=''>Please Select</option>";

$sSqlWrk = "SELECT `id_license`, `type_license` FROM `type_license`";

$rswrk = phpmkr_query($sSqlWrk,$conn) or die("Failed to execute query at line " . __LINE__ . ": " . phpmkr_error($conn) . '<br>SQL:' . $sSqlWrk);

if ($rswrk) {

	$rowcntwrk = 0;

	while ($datawrk = phpmkr_fetch_array($rswrk)) {

		$x_id_licenseList .= "<option value=\"" . htmlspecialchars($datawrk[0]) . "\"";

		if ($datawrk["id_license"] == @$x_id_license) {

			$x_id_licenseList .= " selected";

		}

		$x_id_licenseList .= ">" . $datawrk["type_license"] . "</option>";

		$rowcntwrk++;

	}

}

@phpmkr_free_result($rswrk);

$x_id_licenseList .= "</select>";

echo $x_id_licenseList;

?>

&nbsp;<a href="javascript:void(0);" onclick="EW_ShowAddOption('x_id_license');"><? echo ADDLICENZE ?></a>

</span><span>

<div id="ao_x_id_license" style="display: none;">

<input type="hidden" id="ltn_x_id_license" value="type_license">
<input type="hidden" id="lfn_x_id_license" value="id_license">
<input type="hidden" id="dfn_x_id_license" value="type_license">
<input type="hidden" id="lfm_x_id_license" value="Please enter required field - id license">
<input type="hidden" id="dfm_x_id_license" value="Please enter required field - type license">
<input type="hidden" id="lfq_x_id_license" value="">
<input type="hidden" id="dfq_x_id_license" value="'">
<span id="add_license"><label for="new_license_title">License title:&nbsp;</label><input type="text" id="df_x_id_license" size="30"><input type="button" value="ADD" onClick="EW_PostNewOption('x_id_license')"><input type="button" value="CANCEL" onClick="EW_HideAddOption('x_id_license')">
</div></span>

<br />
		<!--	<span id="add_license"><label for="new_license_title">License title:&nbsp;</label><input name="new_license_title" id="new_license_title" type="text" maxlenght="25" size="20" value="" />&nbsp;<label for="new_license_uri">License uri:&nbsp;</label><input name="new_license_uri" id="new_license_uri" type="text" maxlenght="25" size="20" value="http://" />&nbsp;<input type="submit" value="Add" name="add_license	" /></span> -->
		</td>
	</tr>
</table>
<h2><? echo RESOURCEDESC ?></h2>
<table class="resource_description">
	<tr id="r_Editorial_Publisher">
		<th><strong><? echo EDITORIAL ?></strong></th>
		<td>
			<input type="text" name="x_Editorial_Publisher" id="x_Editorial_Publisher" size="30" maxlength="100" value="<?php echo htmlspecialchars(@$x_Editorial_Publisher) ?>">
		</td>
	</tr>
	<tr id="r_id_place_city">
		<th>
			<strong><? echo PLACE ?></strong>
		</th>
		<td>
			<span id="cb_x_id_place_city">

<?php

$x_id_place_cityList = "<select id='x_id_place_city' name='x_id_place_city'>";
$x_id_place_cityList .= "<option value=''>Please Select</option>";
$sSqlWrk = "SELECT `id_place`, `CITY_NAME`, `ADMIN_NAME` FROM `place`";
$sSqlWrk .= " ORDER BY `CITY_NAME` Asc";
$rswrk = phpmkr_query($sSqlWrk,$conn) or die("Failed to execute query at line " . __LINE__ . ": " . phpmkr_error($conn) . '<br>SQL:' . $sSqlWrk);
if ($rswrk) {
	$rowcntwrk = 0;
	while ($datawrk = phpmkr_fetch_array($rswrk)) {
		$x_id_place_cityList .= "<option value=\"" . htmlspecialchars($datawrk[0]) . "\"";
		if ($datawrk["id_place"] == @$x_id_place_city) {
			$x_id_place_cityList .= " selected";
		}
		$x_id_place_cityList .= ">" . $datawrk["CITY_NAME"] . ValueSeparator($rowcntwrk) . $datawrk["ADMIN_NAME"] . "</option>";
		$rowcntwrk++;
	}
}
@phpmkr_free_result($rswrk);
$x_id_place_cityList .= "</select>";
echo $x_id_place_cityList;
?>

&nbsp;<a href="javascript:void(0);" onclick="EW_ShowAddOption('x_id_place_city');"><? echo ADDPLACE ?></a>

</span><span>

<div id="ao_x_id_place_city" style="display: none;">

<input type="hidden" id="ltn_x_id_place_city" value="place">
<input type="hidden" id="lfn_x_id_place_city" value="id_place">
<input type="hidden" id="dfn_x_id_place_city" value="CITY_NAME">
<input type="hidden" id="df2n_x_id_place_city" value="ADMIN_NAME">
<input type="hidden" id="lfm_x_id_place_city" value="Please enter required field - id place">
<input type="hidden" id="dfm_x_id_place_city" value="Please enter required field - CITY NAME">
<input type="hidden" id="df2m_x_id_place_city" value="Please enter required field - ADMIN NAME">
<input type="hidden" id="lfq_x_id_place_city" value="">
<input type="hidden" id="dfq_x_id_place_city" value="'">
<input type="hidden" id="df2q_x_id_place_city" value="'">
<table class="ewAddOption">
<tr><td><span><? echo CITYNAME ?></span></td><td><input type="text" id="df_x_id_place_city" size="30"></td></tr>

<tr><td><span><? echo ADMINNAME ?></span></td><td><input type="text" id="df2_x_id_place_city" size="30"></td></tr>

<tr><td colspan="2" align="right"><input type="button" value="ADD" onClick="EW_PostNewOption('x_id_place_city')"><input type="button" value="CANCEL" onClick="EW_HideAddOption('x_id_place_city')"></td></tr>

</table>

</div>

</span>
</div>

		</td>

	</tr>
	<tr id="r_id_categories">
		<th>
			<strong><? echo THEMATIC ?></strong><br />
<? echo MAX4OPT ?>
		</th>
		<td>
			

<?php

$x_id_thematicList = "<select id='x_id_thematic' name='x_id_thematic[]' size=6 multiple>";

$sSqlWrk = "SELECT `id_thematic`, `thematic` FROM `thematic`";

$sSqlWrk .= " ORDER BY `thematic` Asc";

$rswrk = phpmkr_query($sSqlWrk,$conn) or die("Failed to execute query at line " . __LINE__ . ": " . phpmkr_error($conn) . '<br>SQL:' . $sSqlWrk);

if ($rswrk) {

	$rowcntwrk = 0;

	while ($datawrk = phpmkr_fetch_array($rswrk)) {

		$ar_x_id_thematic= explode(",", @$x_id_thematic);

		$x_id_thematicList .= "<option value=\"" . htmlspecialchars($datawrk[0]) . "\"";

		foreach ($ar_x_id_thematic as $cnt_x_id_thematic) {

			if ($datawrk["id_thematic"] == trim($cnt_x_id_thematic)) {

				$x_id_thematicList .= " selected";

				break;

			}

		}

		$x_id_thematicList .= ">" . $datawrk["thematic"] . "</option>";

		$rowcntwrk++;

	}

}

@phpmkr_free_result($rswrk);

$x_id_thematicList .= "</select>";

echo $x_id_thematicList;

?>

&nbsp;<a href="javascript:void(0);" onclick="EW_ShowAddOption('x_id_thematic');"><? echo ADDTHEMATIC ?></a>

</span><span>

<div id="ao_x_id_thematic" style="display: none;">

<input type="hidden" id="ltn_x_id_thematic" value="thematic">
<input type="hidden" id="lfn_x_id_thematic" value="id_thematic">
<input type="hidden" id="dfn_x_id_thematic" value="thematic">
<input type="hidden" id="lfm_x_id_thematic" value="Please enter required field - id thematic">
<input type="hidden" id="dfm_x_id_thematic" value="Please enter required field - thematic">
<input type="hidden" id="lfq_x_id_thematic" value="">
<input type="hidden" id="dfq_x_id_thematic" value="'">
  <input type="text" id="df_x_id_thematic" size="30" maxlength="100">
<input type="button" value="ADD" onClick="EW_PostNewOption('x_id_thematic')"><input type="button" value="CANCEL" onClick="EW_HideAddOption('x_id_thematic')">
</div>

</span>


		</td>
	</tr>
	<tr id="r_tags">
		<th>
			<strong>Tags</strong><br />
<? echo TAGSTEXT ?>
		</th>

		<td>
			<textarea cols="50" rows="5" id="x_semantic" name="x_semantic"><?php echo @$x_semantic; ?></textarea>
		</td>
	</tr>
	<tr id="r_id_version">
		<th><strong><? echo VERSION ?></strong></th>
		<td>

<?php

$x_id_versionList = "<select id='x_id_version' name='x_id_version'>";
$x_id_versionList .= "<option value=''>Please Select</option>";
$sSqlWrk = "SELECT `id_version_id`, `version` FROM `version`";
$sSqlWrk .= " ORDER BY `id_version_id` Asc";
$rswrk = phpmkr_query($sSqlWrk,$conn) or die("Failed to execute query at line " . __LINE__ . ": " . phpmkr_error($conn) . '<br>SQL:' . $sSqlWrk);
if ($rswrk) {
	$rowcntwrk = 0;
	while ($datawrk = phpmkr_fetch_array($rswrk)) {
		$x_id_versionList .= "<option value=\"" . htmlspecialchars($datawrk[0]) . "\"";
		if ($datawrk["id_version_id"] == @$x_id_version) {
			$x_id_versionList .= " selected";
		}
		$x_id_versionList .= ">" . $datawrk["version"] . "</option>";
		$rowcntwrk++;
	}
}
@phpmkr_free_result($rswrk);
$x_id_versionList .= "</select>";
echo $x_id_versionList;

?>

		</td>
	</tr>
<tr id="r_id_resource_format">
<th><strong><? echo FORMAT ?></strong> <? echo OFRES ?></th>
		<td>
			<select id='x_id_resource_format' name='x_id_resource_format' >
<?
$sSqlWrk = "SELECT * FROM format WHERE 1";
$rswrk = phpmkr_query($sSqlWrk,$conn) or die("Failed to execute query at line " . __LINE__ . ": " . phpmkr_error($conn) . '<br>SQL:' . $sSqlWrk);
echo '<option value="0">Choose a format</option>';
if ($rswrk) {
	while ($datawrk = phpmkr_fetch_array($rswrk)) {

echo '<option value="'.$datawrk["id_format"].'" ';
if ($datawrk["id_format"] == @$x_id_resource_format) {
	echo " selected";
}

echo '>'.$datawrk["format"].'</option>';
	}
}
?>


			</select>

		<td>
	<tr>
	<tr id="r_id_tipo_testo">
		<th>
			<strong><? echo TYPE ?></strong> <? echo OFRES ?>. <br />
		<? echo DESCTYPE ?>	

</th>
		<td>
			
<?php

$x_id_tipo_testoList = "<select id='x_id_tipo_testo' name='x_id_tipo_testo[]' size=6 multiple>";

$sSqlWrk = "SELECT `id_tipologia_testo`, `tipologia_testo` FROM `tipo_testo`";

$sSqlWrk .= " ORDER BY `tipologia_testo` Asc";

$rswrk = phpmkr_query($sSqlWrk,$conn) or die("Failed to execute query at line " . __LINE__ . ": " . phpmkr_error($conn) . '<br>SQL:' . $sSqlWrk);

if ($rswrk) {

	$rowcntwrk = 0;

	while ($datawrk = phpmkr_fetch_array($rswrk)) {

		$ar_x_id_tipo_testo= explode(",", @$x_id_tipo_testo);
		$x_id_tipo_testoList .= "<option value=\"" . htmlspecialchars($datawrk[0]) . "\"";
		foreach ($ar_x_id_tipo_testo as $cnt_x_id_tipo_testo) {
			if ($datawrk["id_tipologia_testo"] == trim($cnt_x_id_tipo_testo)) {
				$x_id_tipo_testoList .= " selected";
				break;
			}
		}
		$x_id_tipo_testoList .= ">" . $datawrk["tipologia_testo"] . "</option>";
		$rowcntwrk++;
	}
}
@phpmkr_free_result($rswrk);
$x_id_tipo_testoList .= "</select>";
echo $x_id_tipo_testoList;
?>

&nbsp;<a href="javascript:void(0);" onclick="EW_ShowAddOption('x_id_tipo_testo');"><? echo ADDTYPE ?></a>

</span><span>

<div id="ao_x_id_tipo_testo" style="display: none;">

<input type="hidden" id="ltn_x_id_tipo_testo" value="tipo_testo">

<input type="hidden" id="lfn_x_id_tipo_testo" value="id_tipologia_testo">
<input type="hidden" id="dfn_x_id_tipo_testo" value="tipologia_testo">
<input type="hidden" id="lfm_x_id_tipo_testo" value="Please enter required field - id tipologia testo">
<input type="hidden" id="dfm_x_id_tipo_testo" value="Please enter required field - tipologia testo">
<input type="hidden" id="lfq_x_id_tipo_testo" value="">
<input type="hidden" id="dfq_x_id_tipo_testo" value="'">
<span id="add_resource_type"><label for="new_resource_type">Resource type:&nbsp;</label>
<input type="text" id="df_x_id_tipo_testo" size="30" maxlength="50">
<input type="button" value="ADD" onClick="EW_PostNewOption('x_id_tipo_testo')"><input type="button" value="CANCEL" onClick="EW_HideAddOption('x_id_tipo_testo')"></span>
</div>

			
		<td>
	</tr>

	<tr id="r_Extension">
		<th>
				<strong><? echo EXTEN ?></strong><br />
				<? echo NUMOP ?>

		</th>
		<td>
			<input type="text" name="x_Extension" id="x_Extension" size="3" value="<?php echo htmlspecialchars(@$x_Extension) ?>">
		</td>
	</tr>

	<tr id="r_associated_image_Picture">
		<th>
			<strong>Thumbnail</strong><br />
<? echo ASSIMG ?>
		</th>
		<td>
		<?php if (($x_associated_image_Picture != NULL) && $x_associated_image_Picture <> "") {  ?>

<input type="radio" name="a_x_associated_image_Picture" value="1" checked>Keep&nbsp;

<input type="radio" name="a_x_associated_image_Picture" value="2">Remove&nbsp;
<input type="radio" name="a_x_associated_image_Picture" value="3">Replace<br>
<?php } else {?>
<input type="hidden" name="a_x_associated_image_Picture" value="3">
<?php } ?>

<input type="hidden" name="w_x_associated_image_Picture"><input type="hidden" name="h_x_associated_image_Picture">

<input type="file" id="x_associated_image_Picture" name="x_associated_image_Picture" size="30" onChange="if (this.form.a_x_associated_image_Picture[2]) this.form.a_x_associated_image_Picture[2].checked=true;EW_getimagesize(this, this.form.w_x_associated_image_Picture, this.form.h_x_associated_image_Picture);">
		</td>

	</tr>
	<tr id="r_id_access">
		<th><strong><? echo ACCESSTYPE ?></strong></th>
		<td>
			<?php

$x_id_accessList = "<select id='x_id_access' name='x_id_access'>";

$x_id_accessList .= "<option value=''>Please Select</option>";

$sSqlWrk = "SELECT `id_access`, `access` FROM `access`";

$sSqlWrk .= " ORDER BY `access` Asc";

$rswrk = phpmkr_query($sSqlWrk,$conn) or die("Failed to execute query at line " . __LINE__ . ": " . phpmkr_error($conn) . '<br>SQL:' . $sSqlWrk);

if ($rswrk) {

	$rowcntwrk = 0;

	while ($datawrk = phpmkr_fetch_array($rswrk)) {

		$x_id_accessList .= "<option value=\"" . htmlspecialchars($datawrk[0]) . "\"";

		if ($datawrk["id_access"] == @$x_id_access) {

			$x_id_accessList .= " selected";

		}

		$x_id_accessList .= ">" . $datawrk["access"] . "</option>";

		$rowcntwrk++;

	}

}

@phpmkr_free_result($rswrk);

$x_id_accessList .= "</select>";

echo $x_id_accessList;

?>
		</td>
	</tr>
	<tr id="r_access_type_a">
		<th>
			<strong><? echo EFORMAT ?></strong><br />
			<? echo PASTETEXT ?>

</th>

		<td>
			
<textarea cols="100" rows="5" id="x_access_type_a" name="x_access_type_a"><?php echo @$x_access_type_a; ?></textarea>
		</td>
	</tr>
	<tr id="r_articolo">
		<th>
			<strong><? echo FILEUPLOAD ?></strong>. <br />
			<? echo UPLOADTEXT ?>. <br />
			Examples: correct - <code>activistresearchbonet.txt</code> or <code>activist_research_bonet.pdf</code>; wrong - <code>Activist Research Bonet.doc</code>
</th>
		
		<td>


<?php if (($x_articolo != NULL) && $x_articolo <> "") {  ?>

<input type="radio" name="a_x_articolo" value="1" checked>Keep&nbsp;
<input type="radio" name="a_x_articolo" value="2">Remove&nbsp;
<input type="radio" name="a_x_articolo" value="3">Replace<br>
<?php } else {?>
<input type="hidden" name="a_x_articolo" value="3">
<?php } ?>
<input type="file" id="x_articolo" name="x_articolo" size="30" onChange="if (this.form.a_x_articolo[2]) this.form.a_x_articolo[2].checked=true;">	
</td>
	</tr>

	<tr id="r_access_type_c">
		<th>
			<strong><? echo EXTLINK?></strong><br />
			Paste the url without <code>http://</code>

		</th>
		<td>
			<input type="text" name="x_access_type_c" id="x_access_type_c" size="50" maxlength="100" value="<?php echo htmlspecialchars(@$x_access_type_c) ?>">
		</td>
	</tr>

	<tr id="r_bib_reference">
		<th><strong><? echo BIBREF ?></strong></th>
		<td class="ewTableAltRow">
			<textarea cols="100" rows="4" id="x_bib_reference" name="x_bib_reference"><?php echo @$x_bib_reference; ?></textarea>
		</td>
	</tr>
	<tr id="r_comments">
		<th><strong><? echo COMMENTS ?></strong></th>

		<td>
			<textarea cols="100" rows="4" id="x_comments" name="x_comments"><?php echo @$x_comments; ?></textarea>
		</td>
	</tr>
	<tr id="r_data_entrance">
		<th><strong><? echo PUBINEL ?></strong></th>
		<td>
			by "<?php if (CurrentUserID() == -1) { // System admin ?>
<?php
$x_EmpoloyeeIDList = "<select id='x_EmpoloyeeID' name='x_EmpoloyeeID'>";
$x_EmpoloyeeIDList .= "<option value=''>Please Select</option>";
$sSqlWrk = "SELECT `EMPLOYEEID`, `FIRSTNAME`, `LASTNAME` FROM `utenti`";
$rswrk = phpmkr_query($sSqlWrk,$conn) or die("Failed to execute query at line " . __LINE__ . ": " . phpmkr_error($conn) . '<br>SQL:' . $sSqlWrk);
if ($rswrk) {
	$rowcntwrk = 0;
	while ($datawrk = phpmkr_fetch_array($rswrk)) {
		$x_EmpoloyeeIDList .= "<option value=\"" . htmlspecialchars($datawrk[0]) . "\"";
		if ($datawrk["EMPLOYEEID"] == @$x_EmpoloyeeID) {
			$x_EmpoloyeeIDList .= " selected";
		}
		$x_EmpoloyeeIDList .= ">" . $datawrk["FIRSTNAME"] . ValueSeparator($rowcntwrk) . $datawrk["LASTNAME"] . "</option>";
		$rowcntwrk++;
	}
}
@phpmkr_free_result($rswrk);
$x_EmpoloyeeIDList .= "</select>";
echo $x_EmpoloyeeIDList;
?>
<?php } else { // Non system admin ?>
<?php $x_EmpoloyeeID = stripslashes($HTTP_SESSION_VARS["web_biblio_6_2_custom_status_UserID"]); ?>
<?php
if (($x_EmpoloyeeID != NULL) && ($x_EmpoloyeeID <> "")) {
	$sSqlWrk = "SELECT `FIRSTNAME`, `LASTNAME` FROM `utenti`";
	$sTmp = $x_EmpoloyeeID;
	$sTmp = addslashes($sTmp);
	$sSqlWrk .= " WHERE `EMPLOYEEID` = " . $sTmp . "";
	$rswrk = phpmkr_query($sSqlWrk,$conn) or die("Failed to execute query at line " . __LINE__ . ": " . phpmkr_error($conn) . '<br>SQL:' . $sSqlWrk);
	if ($rswrk && $rowwrk = phpmkr_fetch_array($rswrk)) {
		$sTmp = $rowwrk["FIRSTNAME"];
		$sTmp .= ValueSeparator(0) . $rowwrk["LASTNAME"];
	}
	@phpmkr_free_result($rswrk);
} else {
	$sTmp = "";
}
$ox_EmpoloyeeID = $x_EmpoloyeeID; // Backup original value
$x_EmpoloyeeID = $sTmp;
?>
<?php echo $x_EmpoloyeeID; ?>
<?php $x_EmpoloyeeID = $ox_EmpoloyeeID; // Restore original value ?>
<input type="hidden" id="x_EmpoloyeeID" name="x_EmpoloyeeID" value="<?php echo $x_EmpoloyeeID; ?>">
<?php } ?>" on 

<?php echo FormatDateTime(@$x_data_entrance,7); ?>





		</td>
	</tr>
</table>
<p>
<input type="hidden" name="x_data_entrance" id="x_data_entrance" value="<?php 
if($x_data_entrance !="")
echo FormatDateTime(@$x_data_entrance,7);
else
 echo date("d/m/Y");;
 ?>">
<input type="submit" name="btnAction" id="btnAction" value="Save">
</p>
		</form>
	</div><!-- End content1 -->
</div><!-- End content2 -->



<? /**********************************************/
//	<input type="submit" name="btnAction" id="btnAction" value="EDIT">
 ?>



<?php include ("footer.php") ?>
<?php
phpmkr_db_close($conn);
?>
<?php

//-------------------------------------------------------------------------------
// Function LoadData
// - Variables setup: field variables

function LoadData($conn)
{
	global $HTTP_SESSION_VARS;
	global $x_id_autore;
	$sFilter = ewSqlKeyWhere;
	if (!is_numeric($x_id_autore)) return false;
	$x_id_autore =  (get_magic_quotes_gpc()) ? stripslashes($x_id_autore) : $x_id_autore;
	$sFilter = str_replace("@id_autore", AdjustSql($x_id_autore), $sFilter); // Replace key value
	if ((CurrentUserID() <> "-1") && (CurrentUserID() <> "")) {
	$sFilter .= " AND " . str_replace("#UserID", AdjustSql(CurrentuserID()), ewSqlUserIDFilter);
	}
	$sSql = ewBuildSql(ewSqlSelect, ewSqlWhere, ewSqlGroupBy, ewSqlHaving, ewSqlOrderBy, $sFilter, "");
	$rs = phpmkr_query($sSql,$conn) or die("Failed to execute query at line " . __LINE__ . ": " . phpmkr_error($conn) . '<br>SQL: ' . $sSql);
	if (phpmkr_num_rows($rs) == 0) {
		$bLoadData = false;
	} else {
		$bLoadData = true;
		$row = phpmkr_fetch_array($rs);

		// Get the field contents
		$GLOBALS["x_id_autore"] = $row["id_autore"];
		$GLOBALS["x_title"] = $row["title"];
		$GLOBALS["x_subtitle"] = $row["subtitle"];
		$GLOBALS["x_title_en"] = $row["title_en"];
		$GLOBALS["x_subtitle_en"] = $row["subtitle_en"];
		$GLOBALS["x_Autore"] = $row["Autore"];
		$GLOBALS["x_id_tip_autore"] = $row["id_tip_autore"];
		$GLOBALS["x_id_autor_gender"] = $row["id_autor_gender"];
		$GLOBALS["x_abstract"] = $row["abstract"];
		$GLOBALS["x_id_thematic"] = $row["id_thematic"];
		$GLOBALS["x_semantic"] = $row["semantic"];
		$GLOBALS["x_anno_pub"] = $row["anno_pub"];
		$GLOBALS["x_id_place_city"] = $row["id_place_city"];
		$GLOBALS["x_Editorial_Publisher"] = $row["Editorial_Publisher"];
		$GLOBALS["x_id_language"] = $row["id_language"];
		$GLOBALS["x_id_version"] = $row["id_version"];

		$GLOBALS["x_id_resource_format"] = $row["id_format"];
		$GLOBALS["x_id_tipo_testo"] = $row["id_tipo_testo"];
		$GLOBALS["x_id_license"] = $row["id_license"];
		$GLOBALS["x_Extension"] = $row["Extension"];
		$GLOBALS["x_associated_image_Picture"] = $row["associated_image_Picture"];

		// Get BLOB field width and height
		$GLOBALS["wd_x_associated_image_Picture"] = $row["associated_image_Width"];
		$GLOBALS["ht_x_associated_image_Picture"] = $row["associated_image_Height"];
		$GLOBALS["x_id_access"] = $row["id_access"];
		$GLOBALS["x_access_type_a"] = $row["access_type_a"];
		$GLOBALS["x_articolo"] = $row["articolo"];
		$GLOBALS["x_access_type_c"] = $row["access_type_c"];
		$GLOBALS["x_bib_reference"] = $row["bib_reference"];
		$GLOBALS["x_comments"] = $row["comments"];
		$GLOBALS["x_contact_e_mail"] = $row["contact_e_mail"];
		$GLOBALS["x_EmpoloyeeID"] = $row["EmpoloyeeID"];
		$GLOBALS["x_data_entrance"] = $row["data_entrance"];
		$GLOBALS["x_access_type_b"] = $row["access_type_b"];
		$GLOBALS["x_access_type_d"] = $row["access_type_d"];
		$GLOBALS["x_associated_image_Name"] = $row["associated_image_Name"];
		$GLOBALS["x_associated_image__Type"] = $row["associated_image__Type"];
		$GLOBALS["x_associated_image_Width"] = $row["associated_image_Width"];
		$GLOBALS["x_associated_image_Height"] = $row["associated_image_Height"];
		$GLOBALS["x_associated_image_Size"] = $row["associated_image_Size"];
		$GLOBALS["x_id_thematic_2"] = $row["id_thematic_2"];
		$GLOBALS["x_id_thematic_3"] = $row["id_thematic_3"];
		$GLOBALS["x_id_tipo_testo_2"] = $row["id_tipo_testo_2"];
		$GLOBALS["x_id_thematic_4"] = $row["id_thematic_4"];
	}
	phpmkr_free_result($rs);
	return $bLoadData;
}
?>
<?php

//-------------------------------------------------------------------------------
// Function EditData
// - Variables used: field variables

function EditData($conn)
{
	global $HTTP_SESSION_VARS;
	global $HTTP_POST_VARS;
	global $HTTP_POST_FILES;
	global $HTTP_ENV_VARS;
	global $x_id_autore;
	$sFilter = ewSqlKeyWhere;
	if (!is_numeric($x_id_autore)) return false;
	$sTmp =  (get_magic_quotes_gpc()) ? stripslashes($x_id_autore) : $x_id_autore;
	$sFilter = str_replace("@id_autore", AdjustSql($sTmp), $sFilter); // Replace key value
	if ((CurrentUserID() <> "-1") && (CurrentUserID() <> "")) { // Non system admin
	$sFilter .= " AND " . str_replace("#UserID", AdjustSql(CurrentUserID()), ewSqlUserIDFilter);
	}
	$sSql = ewBuildSql(ewSqlSelect, ewSqlWhere, ewSqlGroupBy, ewSqlHaving, ewSqlOrderBy, $sFilter, "");
	$rs = phpmkr_query($sSql,$conn) or die("Failed to execute query at line " . __LINE__ . ": " . phpmkr_error($conn) . '<br>SQL: ' . $sSql);

	// Get old recordset
	$oldrs = phpmkr_fetch_array($rs);
	if (phpmkr_num_rows($rs) == 0) {
		return false; // Update Failed
	} else {

		// Check file size
		$EW_MaxFileSize = @$HTTP_POST_VARS["EW_Max_File_Size"];
		$x_id_autore = @$HTTP_POST_VARS["x_id_autore"];
		$x_title = @$HTTP_POST_VARS["x_title"];
		$x_title_en = @$HTTP_POST_VARS["x_title_en"];
		$x_Autore = @$HTTP_POST_VARS["x_Autore"];
		$x_id_tip_autore = @$HTTP_POST_VARS["x_id_tip_autore"];
		$x_id_autor_gender = @$HTTP_POST_VARS["x_id_autor_gender"];
		$x_abstract = @$HTTP_POST_VARS["x_abstract"];
		$x_id_thematic = @$HTTP_POST_VARS["x_id_thematic"];
		$x_semantic = @$HTTP_POST_VARS["x_semantic"];
		$x_anno_pub = @$HTTP_POST_VARS["x_anno_pub"];
		$x_id_place_city = @$HTTP_POST_VARS["x_id_place_city"];
		$x_Editorial_Publisher = @$HTTP_POST_VARS["x_Editorial_Publisher"];
		$x_id_language = @$HTTP_POST_VARS["x_id_language"];
		$x_id_version = @$HTTP_POST_VARS["x_id_version"];
		$x_id_tipo_testo = @$HTTP_POST_VARS["x_id_tipo_testo"];
$x_id_resource_format = @$HTTP_POST_VARS["x_id_resource_format"];

		$x_id_license = @$HTTP_POST_VARS["x_id_license"];
		$x_Extension = @$HTTP_POST_VARS["x_Extension"];

		// Check the file size
		if (!empty($HTTP_POST_FILES["x_associated_image_Picture"]["size"])) {
			if (!empty($EW_MaxFileSize) && $HTTP_POST_FILES["x_associated_image_Picture"]["size"] > $EW_MaxFileSize) {
				die(str_replace("%s", $EW_MaxFileSize, "Max. file size (%s bytes) exceeded."));
			}
		}
		$fn_x_associated_image_Picture = @$HTTP_POST_FILES["x_associated_image_Picture"]["name"];

		// Check the file type
		if (!empty($fn_x_associated_image_Picture)) {
			if (!ewUploadAllowedFileExt($fn_x_associated_image_Picture)) {
				die("File type is not allowed.");
			}
		}
		$ct_x_associated_image_Picture = @$HTTP_POST_VARS["x_associated_image_Picture"];
		$x_associated_image_Picture = @$HTTP_POST_VARS[ "x_associated_image_Picture"];
		$wd_x_associated_image_Picture = @$HTTP_POST_VARS["wd_x_associated_image_Picture"];
		$ht_x_associated_image_Picture = @$HTTP_POST_VARS["ht_x_associated_image_Picture"];
		$a_x_associated_image_Picture =  @$HTTP_POST_VARS["a_x_associated_image_Picture"];
		$x_id_access = @$HTTP_POST_VARS["x_id_access"];
		$x_access_type_a = @$HTTP_POST_VARS["x_access_type_a"];

		// Check the file size
		if (!empty($HTTP_POST_FILES["x_articolo"]["size"])) {
			if (!empty($EW_MaxFileSize) && $HTTP_POST_FILES["x_articolo"]["size"] > $EW_MaxFileSize) {
				die(str_replace("%s", $EW_MaxFileSize, "Max. file size (%s bytes) exceeded."));
			}
		}
		$fn_x_articolo = @$HTTP_POST_FILES["x_articolo"]["name"];

		// Check the file type
		if (!empty($fn_x_articolo)) {
			if (!ewUploadAllowedFileExt($fn_x_articolo)) {
				die("File type is not allowed.");
			}
		}
		$ct_x_articolo = @$HTTP_POST_VARS["x_articolo"];
		$x_articolo = @$HTTP_POST_VARS[ "x_articolo"];
		$wd_x_articolo = @$HTTP_POST_VARS["wd_x_articolo"];
		$ht_x_articolo = @$HTTP_POST_VARS["ht_x_articolo"];
		$a_x_articolo =  @$HTTP_POST_VARS["a_x_articolo"];
		$x_access_type_c = @$HTTP_POST_VARS["x_access_type_c"];
		$x_bib_reference = @$HTTP_POST_VARS["x_bib_reference"];
		$x_comments = @$HTTP_POST_VARS["x_comments"];
		$x_contact_e_mail = @$HTTP_POST_VARS["x_contact_e_mail"];
		$x_EmpoloyeeID = @$HTTP_POST_VARS["x_EmpoloyeeID"];
		$x_data_entrance = @$HTTP_POST_VARS["x_data_entrance"];
		$theValue = (!get_magic_quotes_gpc()) ? addslashes($GLOBALS["x_title"]) : $GLOBALS["x_title"]; 
		$theValue = ($theValue != "") ? " '" . $theValue . "'" : "NULL";
		$fieldList["`title`"] = $theValue;
		$theValue = (!get_magic_quotes_gpc()) ? addslashes($GLOBALS["x_title_en"]) : $GLOBALS["x_title_en"]; 
		$theValue = ($theValue != "") ? " '" . $theValue . "'" : "NULL";
		$fieldList["`title_en`"] = $theValue;
		$theValue = (!get_magic_quotes_gpc()) ? 
addslashes($GLOBALS["x_Autore"]) : $GLOBALS["x_Autore"]; 
		$theValue = ($theValue != "") ? " '" . $theValue . "'" : "NULL";
		$fieldList["`Autore`"] = $theValue;
		$theValue = ($GLOBALS["x_id_tip_autore"] != "") ? intval($GLOBALS["x_id_tip_autore"]) : "NULL";
		$fieldList["`id_tip_autore`"] = $theValue;
		$theValue = ($GLOBALS["x_id_autor_gender"] != "") ? intval($GLOBALS["x_id_autor_gender"]) : "NULL";
		$fieldList["`id_autor_gender`"] = $theValue;
		$theValue = (!get_magic_quotes_gpc()) ? addslashes($GLOBALS["x_abstract"]) : $GLOBALS["x_abstract"]; 
		$theValue = ($theValue != "") ? " '" . $theValue . "'" : "NULL";
		$fieldList["`abstract`"] = $theValue;
		$theValue = ($GLOBALS["x_id_thematic"] != "") ? implode(",", $GLOBALS["x_id_thematic"]) : "";
		$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
		$theValue = ($theValue != "") ? " '" . $theValue . "'" : "NULL";
		$fieldList["`id_thematic`"] = $theValue;
		$theValue = (!get_magic_quotes_gpc()) ? addslashes($GLOBALS["x_semantic"]) : $GLOBALS["x_semantic"]; 
		$theValue = ($theValue != "") ? " '" . $theValue . "'" : "NULL";
		$fieldList["`semantic`"] = $theValue;
		$theValue = ($GLOBALS["x_anno_pub"] != "") ? intval($GLOBALS["x_anno_pub"]) : "NULL";
		$fieldList["`anno_pub`"] = $theValue;
		$theValue = ($GLOBALS["x_id_place_city"] != "") ? intval($GLOBALS["x_id_place_city"]) : "NULL";
		$fieldList["`id_place_city`"] = $theValue;
		$theValue = (!get_magic_quotes_gpc()) ? addslashes($GLOBALS["x_Editorial_Publisher"]) : $GLOBALS["x_Editorial_Publisher"]; 
		$theValue = ($theValue != "") ? " '" . $theValue . "'" : "NULL";
		$fieldList["`Editorial_Publisher`"] = $theValue;
		$theValue = ($GLOBALS["x_id_language"] != "") ? intval($GLOBALS["x_id_language"]) : "NULL";
		$fieldList["`id_language`"] = $theValue;
		$theValue = ($GLOBALS["x_id_version"] != "") ? intval($GLOBALS["x_id_version"]) : "NULL";
		$fieldList["`id_version`"] = $theValue;
		

$theValue = ($GLOBALS["x_id_resource_format"] != "") ? intval($GLOBALS["x_id_resource_format"]) : "NULL";
		$fieldList["`id_format`"] = $theValue;


		$theValue = ($GLOBALS["x_id_tipo_testo"] != "") ? implode(",", $GLOBALS["x_id_tipo_testo"]) : "";
		$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
		$theValue = ($theValue != "") ? " '" . $theValue . "'" : "NULL";
		$fieldList["`id_tipo_testo`"] = $theValue;
		$theValue = ($GLOBALS["x_id_license"] != "") ? intval($GLOBALS["x_id_license"]) : "NULL";
		$fieldList["`id_license`"] = $theValue;
		$theValue = ($GLOBALS["x_Extension"] != "") ? intval($GLOBALS["x_Extension"]) : "NULL";
		$fieldList["`Extension`"] = $theValue;
		if ($a_x_associated_image_Picture == "2") { // Remove
			$fieldList["`associated_image_Picture`"] = "NULL";
			$fieldList["`associated_image_Size`"] = "NULL";
			$fieldList["`associated_image_Width`"] = "NULL";
			$fieldList["`associated_image_Height`"] = "NULL";
			$fieldList["`associated_image__Type`"] = "NULL";
			$fieldList["`associated_image_Name`"] = "NULL";
		} else if ($a_x_associated_image_Picture == "3") { // Update
			if ($HTTP_POST_FILES["x_associated_image_Picture"]["tmp_name"] != "none" && $HTTP_POST_FILES["x_associated_image_Picture"]["tmp_name"] != "") {
				$destfile = $HTTP_POST_FILES["x_associated_image_Picture"]["tmp_name"];
				$fileHandle = fopen($HTTP_POST_FILES["x_associated_image_Picture"]["tmp_name"], "r");
				$fileContent = fread($fileHandle, $HTTP_POST_FILES["x_associated_image_Picture"]["size"]);
				$theValue = addslashes($fileContent);
				$theValue = " '" . $theValue . "'";
				$fieldList["`associated_image_Picture`"] = $theValue;
				$theName = $HTTP_POST_FILES["x_associated_image_Picture"]["name"];

				// File type
				$fieldList["`associated_image__Type`"] = " '" . $HTTP_POST_FILES["x_associated_image_Picture"]["type"] . "'";

				// File name
				$theName = (!get_magic_quotes_gpc()) ? addslashes($theName) : $theName;
				$fieldList["`associated_image_Name`"] = " '" . $theName . "'";

				//File Size
				$fieldList["`associated_image_Size`"] = $HTTP_POST_FILES["x_associated_image_Picture"]["size"];

				// Image height and width
				$theSize = getimagesize($destfile);									
				$fieldList["`associated_image_Width`"] = ((is_numeric($theSize[0])) ? $theSize[0] : "NULL");
				$fieldList["`associated_image_Height`"] = ((is_numeric($theSize[1])) ? $theSize[1] : "NULL");
				@unlink($HTTP_POST_FILES["x_associated_image_Picture"]["tmp_name"]);
			}
		}
		$theValue = ($GLOBALS["x_id_access"] != "") ? intval($GLOBALS["x_id_access"]) : "NULL";
		$fieldList["`id_access`"] = $theValue;
		$theValue = (!get_magic_quotes_gpc()) ? addslashes($GLOBALS["x_access_type_a"]) : $GLOBALS["x_access_type_a"]; 
		$theValue = ($theValue != "") ? " '" . $theValue . "'" : "NULL";
		$fieldList["`access_type_a`"] = $theValue;
		if ($a_x_articolo == "2") { // Remove
			$fieldList["`articolo`"] = "NULL";
		} else if ($a_x_articolo == "3") { // Update
			if ($HTTP_POST_FILES["x_articolo"]["tmp_name"] != "none" && $HTTP_POST_FILES["x_articolo"]["tmp_name"] != "") {
				$sTmpFolder = ewUploadPathEx(true, EW_UploadDestPath);


//prendo l'ultimo id inserito
/*
$miniquery="SELECT id_autore as maxid FROM autori WHERE 1 ORDER BY id_autore DESC";
$minires=mysql_query($miniquery);
$minirow=mysql_fetch_array($minires);
$lastid=$minirow['maxid'];
$newid=$lastid+1;
*/
$newid=$x_id_autore;
//echo $sTmpFolder.$newid;
//exit;
if(!ewCreateFolder($sTmpFolder.$newid))
	echo "ERRORE";

				$theName = ewUploadFileNameEx($sTmpFolder, $HTTP_POST_FILES["x_articolo"]["name"]);
				$destfile = $sTmpFolder .$newid."/".$theName;
						if (!copy($HTTP_POST_FILES["x_articolo"]["tmp_name"], $destfile)) // Move file to destination path
							die("" . $destfile);

				// File name
				$theName = (!get_magic_quotes_gpc()) ? addslashes($theName) : $theName;
				$fieldList["`articolo`"] = " '" .$newid."/". $theName . "'";
				@unlink($HTTP_POST_FILES["x_articolo"]["tmp_name"]);
			}
		}
		$theValue = (!get_magic_quotes_gpc()) ? addslashes($GLOBALS["x_access_type_c"]) : $GLOBALS["x_access_type_c"]; 
		$theValue = ($theValue != "") ? " '" . $theValue . "'" : "NULL";
		$fieldList["`access_type_c`"] = $theValue;
		$theValue = (!get_magic_quotes_gpc()) ? addslashes($GLOBALS["x_bib_reference"]) : $GLOBALS["x_bib_reference"]; 
		$theValue = ($theValue != "") ? " '" . $theValue . "'" : "NULL";
		$fieldList["`bib_reference`"] = $theValue;
		$theValue = (!get_magic_quotes_gpc()) ? addslashes($GLOBALS["x_comments"]) : $GLOBALS["x_comments"]; 
		$theValue = ($theValue != "") ? " '" . $theValue . "'" : "NULL";
		$fieldList["`comments`"] = $theValue;
		$theValue = (!get_magic_quotes_gpc()) ? addslashes($GLOBALS["x_contact_e_mail"]) : $GLOBALS["x_contact_e_mail"]; 
		$theValue = ($theValue != "") ? " '" . $theValue . "'" : "NULL";
		$fieldList["`contact_e_mail`"] = $theValue;
		$theValue = ($GLOBALS["x_EmpoloyeeID"] != "") ? intval($GLOBALS["x_EmpoloyeeID"]) : "NULL";
		$fieldList["`EmpoloyeeID`"] = $theValue;
		$theValue = ($GLOBALS["x_data_entrance"] != "") ? " '" . ConvertDateToMysqlFormat($GLOBALS["x_data_entrance"]) . "'" : "Null";
		$fieldList["`data_entrance`"] = $theValue;

		// Update
		$sSql = "UPDATE `autori` SET ";
		foreach ($fieldList as $key=>$temp) {
			$sSql .= "$key = $temp, ";
		}
		if (substr($sSql, -2) == ", ") {
			$sSql = substr($sSql, 0, strlen($sSql)-2);
		}
		$sSql .= " WHERE " . $sFilter;

		// Updating event
		if (Recordset_Updating($fieldList, $oldrs)) {
			phpmkr_query($sSql,$conn) or die("Failed to execute query at line " . __LINE__ . ": " . phpmkr_error($conn) . '<br>SQL: ' . $sSql);
			$result = (phpmkr_affected_rows($conn) >= 0);

			// Updated event
			if ($result) Recordset_Updated($fieldList, $oldrs);
		} else {
			$result = false; // Update Failed
		}
	}
	return $result;
}

// Updating Event
function Recordset_Updating($newrs, $oldrs)
{

	// Enter your customized codes here
	return true;
}

// Updated event
function Recordset_Updated($newrs, $oldrs)
{
	global $HTTP_SESSION_VARS;
	global $HTTP_POST_VARS;
	global $HTTP_POST_FILES;
	global $HTTP_ENV_VARS;
	$table = "autori";
}
?>
Return current item: Openelibrary