<?php

// +----------------------------------------------------------------------+
// | OpenConf                                                             |
// +----------------------------------------------------------------------+
// | Copyright (c) 2002-2008 Zakon Group LLC.  All Rights Reserved.       |
// +----------------------------------------------------------------------+
// | This source file is subject to the OpenConf License, available on    |
// | the OpenConf web site: www.OpenConf.com                              |
// +----------------------------------------------------------------------+

require_once "../include.php";

require_once OCC_COUNTRY_FILE;

if (OCC_CHAIR_PWD_TRUMPS && isset($_REQUEST['c']) && ($_REQUEST['c'] == 1)) {
	$hdrfn = 1;
	beginChairSession();
	$chair = TRUE;
} else {
	$hdrfn = 3;
	$chair = FALSE;
}

printHeader("Modifier une Soumission",$hdrfn);

// Edit still allowed?
if (! $chair && ! $OC_statusAR['OC_edit_open']) {
	print '
<b>La modification d\'une soumission n\'est plus possible.</b><p>
	';
	printFooter();
	exit;
}

// Get topics
$topq = "SELECT * FROM `" . OCC_TABLE_TOPIC . "`";
$topr = ocsql_query($topq) or err('unable to retrieve topics');
if (($tnum = mysql_num_rows($topr)) < 1) {
	warn('We are still waiting for the Program Chair to finalize the list of topics before opening up for submissions.  Please check back later.');
} else {
	$half = ceil($tnum / 2);
	$topicAR = array();
	while ($topl = mysql_fetch_assoc($topr)) {
		$topicAR[$topl['topicid']] = $topl['topicname'];
	}
}

// Get non-editable fields array
$nonEditFieldsAR = preg_split("/[\s,]+/", $OC_configAR['OC_subNonEditFields'], -1, PREG_SPLIT_NO_EMPTY);

// Is this a post?
if (isset($_POST['submit'])) {
	// Check for paper ID & password
	if (! isset($_POST['pid']) || 
		! preg_match("/^\d+$/", $_POST['pid']) ||
		(! $chair && (! isset($_POST['pwd']) || empty($_POST['pwd'])))
	) {
		warn('Veuillez revenir en arrière et vérifier le numéro d\'identification et le mot de passe, s.v.p.');
		printFooter();
		exit;
	}

	if ($chair) { // display back links
		print '<p style="text-align: center"><a href="../chair/show_paper.php?pid=' . $_POST['pid'] . '">Voir cette soumission</a> | <a href="../chair/list_papers.php">Voir toutes les soumissions</a></p>';
	} else { // check pwd
		$pq = "SELECT password FROM " . OCC_TABLE_PAPER . " WHERE paperid='".$_POST['pid']."'";
		$pr = ocsql_query($pq) or err("Unable to retrieve submission ".mysql_errno());
		if (mysql_num_rows($pr) != 1) { err("Unable to find submission id ".$_POST['pid']); }
		$pl = mysql_fetch_array($pr);
		if ((hashPassword($_POST['pwd'], $pl['password']) != $pl['password']) && (md5($_POST['pwd']) != $pl['password']) && (!OCC_CHAIR_PWD_TRUMPS || (hashPassword($_POST['pwd'], $OC_configAR['OC_chair_pwd']) != $OC_configAR['OC_chair_pwd'])) && (!defined('OCC_SUPERCHAIR_PASSWORD') || (hashPassword($_POST['pwd'], OCC_SUPERCHAIR_PASSWORD) != OCC_SUPERCHAIR_PASSWORD))) {
			warn('Le mot de passe n\'est pas valide pour la soumission n° ' . safeHTMLstr($_POST['pid']));
			printFooter();
			exit;
		}
	}

	// Check whether we're submitting changes
	if ($_POST['submit'] == "Enregistrer les modifications") {
		if ($chair && !validToken('chair')) {
			warn('Invalid submission');
		}
      	$err = '';
		// Check title
		if (($chair || $OC_statusAR['OC_submissions_open'] || !in_array('title', $nonEditFieldsAR)) && !preg_match("/\w+/",$_POST['title'])) {
			$err .= "<li>Enter a submission title</li>";
		}
		// Check that we have a valid contact author & email
		if (!preg_match("/^[1-5]$/",$_POST['contact'])) {
			$err .= "<li>Contact author invalid</li>";
		} else {
	        $contactemail = $_POST['email'.$_POST['contact']];
			if (!preg_match("/\w/",$_POST['name_last'.$_POST['contact']]) || !preg_match("/\w/",$_POST['name_first'.$_POST['contact']])) {
				$err .= "<li>Fill in both the first &amp; last name of the contact author</li>";
			}
			if (!validEmail($contactemail)) {
				$err .= "<li>Contact author email does not seem valid</li>";
			}
		}
		// Check author countries
		for ($c=1; $c<=4; $c++) {
			if ((!isset($_POST['country'.$c]) || empty($_POST['country'.$c])) && isset($_POST['isocountry'.$c]) && !empty($_POST['isocountry'.$c])) {
				$isoUpper = oc_strtoupper($_POST['isocountry'.$c]);
				if (!in_array($isoUpper, array_keys($OC_countryAR))) {
					$err .= "<li>Auteur n°" . $c . " (2-letter) ISO country code is not valid</li>";
				} else {
					$_POST['country'.$c] = $OC_countryAR[$isoUpper];
				}
			}
		}
		// Check that we have alternate contact info for contact author
		if (!validEmail($_POST['contactaltemail']) && !preg_match("/\d/",$_POST['contactphone'])) {
			$err .= "<li>Enter a valid alternate email or phone number for contact author</li>";
		}
		// Check student
		if (!preg_match("/^[FT]$/", $_POST['student'])) {
			$err .= "<li>Student selection invalid</li>";
		}
		// Check topics
		if (($chair || $OC_statusAR['OC_submissions_open'] || !in_array('topics', $nonEditFieldsAR)) && empty($_POST['topic'])) {
			$err .= "<li>Select at least one topic area</li>";
		}

		if (oc_hookSet('author-edit-validate')) {
			foreach ($GLOBALS['OC_hooksAR']['author-edit-validate'] as $hook) {
				require_once $hook;
			}
		}
		
		// Check password
		if ($_POST['password1'] != $_POST['password2']) {
			$err .= "<li>Passwords entered do not match</li>";
		}

		// errors?
		if ($err) {
	        print '<p><span class="warn">Please go back and check the following:<ul>' . $err . '</ul></span><p />';
		} else { // process edits
			$q = "UPDATE " . OCC_TABLE_PAPER . " SET ";
			if (!empty($_POST['password1'])) {
				$q .= "password='" . hashPassword(stripslashes($_POST['password1'])) . "',";
			}
			if ($chair || $OC_statusAR['OC_submissions_open'] || !in_array('title', $nonEditFieldsAR)) {
				$q .= "title='" . safeSQLstr($_POST['title'])."',";
			}
			if ($chair || $OC_statusAR['OC_submissions_open'] || !in_array('student', $nonEditFieldsAR)) {
				$q .= "student='" . $_POST['student'] . "',";
			}
			$q .= "contactid='" . $_POST['contact'] . "',".
				   "contactemail='" . safeSQLstr(oc_strtolower($_POST['contactaltemail'])) . "',".
				   "contactphone='" . safeSQLstr($_POST['contactphone']) . "',".
				   "lastupdate='" . date("Y-m-d") . "',".
				   "otherauthors='" . safeSQLstr($_POST['otherauthors']) . "',".
				   "keywords='" . safeSQLstr($_POST['keywords']) . "',".
				   "comments='" . safeSQLstr($_POST['comments']) . "',".
				   "abstract='" . safeSQLstr($_POST['abstract']) . "'".
				   " WHERE paperid='" . $_POST['pid'] . "'";
			$r = ocsql_query($q) or err("unable to update submission ".mysql_errno());

			$q = "DELETE FROM " . OCC_TABLE_AUTHOR . " WHERE paperid='" . $_POST['pid'] . "'";
			$r = ocsql_query($q) or err("Unable to update authors (2) - ".mysql_errno());
			for ($i=1;$i<=5;$i++) {
				if (!empty($_POST["name_last$i"])) {
					$q = "INSERT INTO " . OCC_TABLE_AUTHOR . " (paperid,position,name_last,name_first,organization,country,email) VALUES (".
							"'" . $_POST['pid'] . "',".
							"'$i',".
							"'" . safeSQLstr($_POST["name_last$i"]) . "',".
							"'" . safeSQLstr($_POST["name_first$i"]) . "',".
							"'" . safeSQLstr($_POST["org$i"]) . "',".
							"'" . safeSQLstr($_POST["country$i"]) . "',".
							"'" . safeSQLstr($_POST["email$i"]) . "'".
							")";
					$r = ocsql_query($q) or err("unable to update authors or topics".mysql_errno());
	  			}
			}
	
			if ($chair || $OC_statusAR['OC_submissions_open'] || !in_array('topics', $nonEditFieldsAR)) {
				$q = "DELETE FROM " . OCC_TABLE_PAPERTOPIC . " WHERE paperid='".$_POST['pid']."'";
				$r = ocsql_query($q) or err("unable to update topics");
				foreach ($_POST['topic'] as $t) {
  					if (is_numeric($t)) {
						$q = "INSERT INTO " . OCC_TABLE_PAPERTOPIC . " (paperid,topicid) VALUES (" . $_POST['pid'] . ",$t)";
						$r = ocsql_query($q) or err("unable to update topic ".mysql_errno());
					}
					else { err("invalid submission topic - ..$t.."); }
				}
			}

			if (oc_hookSet('author-edit-save')) {
				foreach ($GLOBALS['OC_hooksAR']['author-edit-save'] as $hook) {
					require_once $hook;
				}
			}

			$confirmmsg = '
Soumission n. ' . $_POST['pid'] . '

Titre : '.stripslashes($_POST['title']).'
';
			if (($OC_configAR['OC_trackStudent'] == 1) && ($chair || $OC_statusAR['OC_submissions_open'] || !in_array('student', $nonEditFieldsAR))) {
				$confirmmsg .= 'Student: ' . $_POST['student'];
			}
			for ($i=1;$i<=5;$i++) {
				$confirmmsg .= '
Auteur ' . $i;
			if ($i == $_POST['contact']) { $confirmmsg .= " (CONTACT AUTHOR)"; }
  			$confirmmsg .= '
  Nom: ' . stripslashes($_POST["name_first$i"] . " " . $_POST["name_last$i"]) . '
  Org: ' . stripslashes($_POST["org$i"]) . '
  Pays: ' . $_POST["country$i"] . '
  Courriel:' . $_POST["email$i"];
			}
			$confirmmsg .= '
Autres Auteurs: ' . stripslashes($_POST['otherauthors']) . '
Contact Alt Courriel: ' . $_POST['contactaltemail'] . '
Contact Tel: ' . $_POST['contactphone'] . '
Mots clefs: ' . stripslashes($_POST['keywords']) . '
Résumé : ' . stripslashes($_POST['abstract']) . '
Commentaires : ' . stripslashes($_POST['comments']) . '
';

			if (oc_hookSet('author-edit-confirm')) {
				foreach ($GLOBALS['OC_hooksAR']['author-edit-confirm'] as $hook) {
					require_once $hook;
				}
			}

			//confirm it
			print '<p><b>The submission has been updated.	Below is the information submitted.</b></p><pre>' . safeHTMLstr($confirmmsg) . '</pre>';
			if (! $chair) {
				print '<p>A copy has also been emailed to the contact author.  If you notice any problems or do <b>not</b> receive the email within 24 hours, please contact the <a href="mailto:' . $OC_configAR['OC_pcemail'] . '?subject=submission edit problem - ' . $_POST['pid'] . '">Program Chair</a>.</b></p>';
				sendEmail($contactemail, "Mise-à-jour soumission n. " . $_POST['pid'], $confirmmsg, $OC_configAR['OC_notifyAuthorEdit']);
 			}
  		} // else no $err

		printFooter();
		exit;
	} // if Submit Changes
	// Check whether we're retrieving a submission and if so, display filled out form
	elseif ($_POST['submit'] == "Modifier la soumission") {
		// get paper info
		$eq = "SELECT * FROM " . OCC_TABLE_PAPER . " WHERE paperid='".$_POST['pid']."'";
		$er = ocsql_query($eq) or err("Unable to retrieve submission info - ".mysql_errno());
		$el = mysql_fetch_array($er) or err("Unable to retrieve submission data - ".mysql_errno());
		// get paper authors
		$aq = "SELECT * FROM " . OCC_TABLE_AUTHOR . " WHERE paperid='".$_POST['pid']."'";
		$ar = ocsql_query($aq) or err("Unable to retrieve author info - ".mysql_errno());
		while ($al = mysql_fetch_array($ar)) {
			$authorar[$al['position']]['name_last'] = $al['name_last'];
			$authorar[$al['position']]['name_first'] = $al['name_first'];
			$authorar[$al['position']]['organization'] = $al['organization'];
			$authorar[$al['position']]['country'] = $al['country'];
			$authorar[$al['position']]['email'] = $al['email'];
		}
		// get paper topics
		$ptq = "SELECT * FROM `" . OCC_TABLE_PAPERTOPIC . "` WHERE paperid='" . $_POST['pid'] . "'";
		$ptr = ocsql_query($ptq) or err("Unable to retrieve topic info - " . mysql_errno());
		$papertopicar = array();
		while ($ptl = mysql_fetch_array($ptr)) {
			$papertopicar[] = $ptl['topicid'];
		}

		print '
<form method="post" action="'.$_SERVER['PHP_SELF'].'">
<input type="hidden" name="pid" value="'.$_POST['pid'].'">
';
		if ($chair) {
			print '
<input type="hidden" name="c" value="1">
<input type="hidden" name="token" value="' . $_SESSION[OCC_SESSION_VAR_NAME]['chairtoken'] . '" />
';
		}
		print '
<table border=0 cellspacing=1 cellpadding=5 bgcolor="#dddddd">
<tr><td colspan=3 class="cat">Information Générale</td></tr>
<tr><td class="item">Soumission&nbsp;n°</td><td colspan=2>'.$el['paperid'].'</td></tr>
<tr>
<td class="item"><label for="form_title">Titre :</label></td>
<td colspan=2>';

		if ($chair || $OC_statusAR['OC_submissions_open'] || !in_array('title', $nonEditFieldsAR)) {
			print '<input name="title" id="form_title" size="75" maxlength="250" value="'.safeHTMLstr($el['title']).'">';
		} else {
			print safeHTMLstr($el['title']);
	        print '<input type="hidden" name="title" id="form_title" value="'.safeHTMLstr($el['title']).'">';
		}

		print "</td></tr>\n";

		if ($OC_configAR['OC_trackStudent'] == 1) {
			print '
<tr>
<td class="item" valign="top">Student?</td>
<td colspan=2>';

			if ($chair || $OC_statusAR['OC_submissions_open'] || !in_array('student', $nonEditFieldsAR)) {
				$studoptions = '<input name="student" id="form_studentYes" type="radio" value="T"><label for="form_studentYes">Yes</label> &nbsp; &nbsp;  <input name="student" id="form_studentNo" type="radio" value="F"><label for="form_studentNo">No</label>';
				if ($el['student'] == "T") {
					print preg_replace("/(value=\"T\")/", "$1 checked", $studoptions);
				} else {
					print preg_replace("/(value=\"F\")/", "$1 checked", $studoptions);
				}
				print '
  <br>
  <span class="note">' . $OC_configAR['OC_studentNote'] . '</span>
			';
			} else {
			if ($el['student'] == "T") { print 'Yes'; } else { print 'No'; }
				print '<input type="hidden" name="student" value="F">';
			}
			print '
</td>
</tr>
			';
		} else { // not tracking students
			print '<input type="hidden" name="student" value="F">';
		}

		if (oc_hookSet('author-edit-general')) {
			foreach ($GLOBALS['OC_hooksAR']['author-edit-general'] as $hook) {
				require_once $hook;
			}
		}

		print '
<tr><td colspan=3 class="sep">&nbsp;<br>&nbsp;</td></tr>

<tr><td colspan=3 class="cat">Information sur l\'auteur / les auteurs</td></tr>
';

		$colar = array(1,3,5);
		for ($i=1;$i<=5;$i++) {
			if (in_array($i,$colar)) { $it = "item2"; } else { $it = "item"; }
	 		print '
<tr><td class="' . $it . '" rowspan=4>Auteur n°' . $i . '</td>
<td class="' . $it . '">Nom:</td>
<td class="' . $it . '">';
			if ($i==1) {
				print '
	<table border=0 cellspacing=0 cellpadding=0>
	<tr><td>
	<input size=33 name="name_first' . $i . '" id="form_name_first' . $i . '" value="'.safeHTMLstr($authorar[$i]['name_first']).'" maxlength=60><br /><span class="note"><label for="form_name_first' . $i . '">Prénom</label></span>
	</td><td><nobr> &nbsp; &nbsp; </nobr></td><td>
	<input size=33 name="name_last' . $i . '" id="form_name_last' . $i . '" value="'.safeHTMLstr($authorar[$i]['name_last']).'" maxlength=40><br /><span class="note"><label for="form_name_last' . $i . '">Nom de famille</label></span>
	</td></tr>
	</table>';
			} else {
				print '
<input size=33 name="name_first' . $i . '" value="' . safeHTMLstr(varValue('name_first', $authorar[$i])) . '" maxlength=60> &nbsp; &nbsp; <input size=33 name="name_last' . $i . '" value="' . safeHTMLstr(varValue('name_last', $authorar[$i])) . '" maxlength=40>';
			}
	
			print '
</td>
</tr>
<tr>
<td class="' . $it . '"><label for="form_org' . $i . '">Organisation:</label></td>
<td class="' . $it . '"><input name="org' . $i . '" id="form_org' . $i . '" size=75 maxlength=255 value="' . safeHTMLstr(varValue('organization', $authorar[$i])) . '">';

			if ($i==1) {
				print "<br><span class=\"note\">NOTE: Organization should be your company, university, or similar. Please do not use your department or division, unless it is part of your organization's name such as Interior Department.</span>";
			}
			print '</td>
</tr>
<tr>
<td class="' . $it . '" valign="top"><label for="form_country' . $i . '">Pays :</label></td>
<td class="' . $it . '"><input name="isocountry' . $i . '" id="form_country' . $i . '" size="2" title="ISO 2-letter country code" /> <select name="country' . $i . '"><option></option>' . generateSelectOptions($OC_countryAR, varValue('country', $authorar[$i]), FALSE) . '</select>';
			if ($i == 1) {
				print '<br /><span class="note">Enter the 2-letter ISO country code above or select country name from drop-down menu.</span>';
			}
			print '</td>
</tr>
<tr>
<td class="' . $it . '"><label for="form_email' . $i . '">Courriel :</label></td>
<td class="' . $it . '"><input name="email' . $i . '" id="form_email' . $i . '" size=75 maxlength=100 value="' . safeHTMLstr(varValue('email', $authorar[$i])) . '"></td>
</tr>
';
		} // foreach author

		print '
<tr>
<td class="item" valign="top"><label for="form_otherauthors">Auteurs<br />Supplémentaires :</label></td>
<td colspan=2>
<span class="note">If you have more than 5 authors, please enter the additional information here:</span><br>
<textarea rows=4 cols=70 name="otherauthors" id="form_otherauthors">' . safeHTMLstr($el['otherauthors']) . '</textarea></td>
</tr>
';


if (oc_hookSet('author-edit-authors')) {
	foreach ($GLOBALS['OC_hooksAR']['author-edit-authors'] as $hook) {
		require_once $hook;
	}
}


print '
<tr><td colspan=3 class="sep">&nbsp;<br>&nbsp;</td></tr>

<tr><td colspan=3 class="cat">Auteur de contact</td></tr>
<tr><td colspan=3><span class="note">
The contact author is the person responsible for correspondence with the program chair. We ask for additional information for the contact author, so that we can ensure timely communication and make the program accurate. We will only contact authors other than the contact author if we are unable to reach the contact author (e.g., because of a bad email address). Please notify us of any changes in names, affiliations, etc. in the contact author\'s information
<p>
Note: If you have more than one email address, please put the second address under "Alternate Email". We will only use that address if there is a problem with the primary email.
</span></td></tr>
<tr>
<td class="item"><label for="form_contact">Auteur de contact :</label></td>
<td colspan=2><select name="contact" id="form_contact">
';

		$contactoptions = '<option value="1">Auteur 1</option><option value="2">Auteur 2</option><option value="3">Auteur 3</option><option value="4">Auteur 4</option><option value="5">Auteur 5</option>';
		$cid=$el['contactid'];
		if (is_numeric($cid)) {
			print preg_replace("/(value=\"$cid\")/", "$1 selected", $contactoptions);
		} else {
			print $contactoptions;
		}

		print '
</select></td>
</tr>
<tr>
<td class="item"><label for="form_contactaltemail">Courriel de secours :</label></td>
<td colspan=2><input name="contactaltemail" id="form_contactaltemail" size=50 maxlength=100 value="' . safeHTMLstr($el["contactemail"]) . '"></td>
</tr>
<tr>
<td class="item"><label for="form_contactphone">Téléphone :</label></td>
<td colspan=2><input name="contactphone" id="form_contactphone" size=50 maxlength=30 value="'. safeHTMLstr($el["contactphone"]) .'"></td>
</tr>
';


if (oc_hookSet('author-edit-contact')) {
	foreach ($GLOBALS['OC_hooksAR']['author-edit-contact'] as $hook) {
		require_once $hook;
	}
}


print '
<tr><td colspan=3 class="sep">&nbsp;<br>&nbsp;</td></tr>

<tr><td colspan=3 class="cat">Thèmes</td></tr>
';

		if ($chair || $OC_statusAR['OC_submissions_open'] || !in_array('topics', $nonEditFieldsAR)) {
			print '
<tr><td colspan=3><span class="note">
To help match submissions to reviewers and sessions, please select ';

if ($OC_configAR['OC_multipleSubmissionTopics']) {
	print 'one or more area(s)';
} else {
	print 'one area';
}

print ' most applicable to your submission:
</td></tr>
<tr><td colspan=3>
  <table border=0 cellspacing=0 cellpadding=0><tr><td valign="top">
';

			$i=1;
			if ($OC_configAR['OC_multipleSubmissionTopics']) {
				$type = 'checkbox';
			} else {
				$type = 'radio';
			}
			foreach ($topicAR as $tid => $topic) {
				print '<label><input type="' . $type . '" name="topic[]" value="' . $tid . '"';
				if (isset($papertopicar) && in_array($tid, $papertopicar)) { print " checked"; }
				print ' />' . safeHTMLstr($topic) . '</label>';
				if (($OC_configAR['OC_topicColumns'] == 2) && ($i++ == $half)) {
	  				print "</td><td><nobr> &nbsp; &nbsp; &nbsp; &nbsp; </nobr></td><td valign=\"top\">";
		  		}
				else { print "<br />\n"; }
			}

			print '
  </td></tr></table>
';
		} else {
			print "<tr><td colspan=3><ul>\n";
			$q = "SELECT topicname FROM " . OCC_TABLE_TOPIC . ", " . OCC_TABLE_PAPERTOPIC . " WHERE " . OCC_TABLE_PAPERTOPIC . ".paperid='".$_POST['pid']."' AND " . OCC_TABLE_PAPERTOPIC . ".topicid=" . OCC_TABLE_TOPIC . ".topicid";
			$r = ocsql_query($q) or err("unable to retrieve topic names");
			while ($l=mysql_fetch_array($r)) {
				print "<li>" . safeHTMLstr($l['topicname']) . "</li>\n";
			}
			print "</ul></td></tr>\n";
		}
		print '
</td></tr>
';


if (oc_hookSet('author-edit-topics')) {
	foreach ($GLOBALS['OC_hooksAR']['author-edit-topics'] as $hook) {
		require_once $hook;
	}
}


print '
<tr><td colspan=3 class="sep">&nbsp;<br>&nbsp;</td></tr>

<tr><td colspan=3 class="cat">Contenu</td></tr>

<tr>
<td class="item"><label for="form_keywords">Mots-clefs :</label></td>
<td colspan=2><input name="keywords" id="form_keywords" size="75" maxlength="250" value="' . safeHTMLstr($el["keywords"]) . '"></td>
</tr>

<tr>
<td class="item" valign="top"><label for="form_abstract">Résumé :</label></td>
<td colspan=2><textarea name="abstract" id="form_abstract" rows=6 cols=70>' . safeHTMLstr($el["abstract"]) . '</textarea></td>
</tr>
';


if (oc_hookSet('author-edit-content')) {
	foreach ($GLOBALS['OC_hooksAR']['author-edit-content'] as $hook) {
		require_once $hook;
	}
}


print '
<tr><td colspan=3 class="sep">&nbsp;<br>&nbsp;</td></tr>

<tr><td colspan=3 class="cat">Changer le mot de passe</td></tr>

<tr><td colspan=3><span class="note">
Leave these fields blank if you do not want to change your password
</span></td></tr>

<tr>
<td class="item"><label for="form_password1">Mot de passe :</label></td>
<td colspan=2><input type="password" name="password1" id="form_password1" size="20" maxlength="30"></td>
</tr>

<tr>
<td class="item"><label for="form_password2">Confirmation :</label></td>
<td colspan=2><input type="password" name="password2" id="form_password2" size="20" maxlength="30"></td>
</tr>

<tr><td colspan=3 class="sep">&nbsp;<br>&nbsp;</td></tr>

<tr><td colspan=3 class="cat">Commentaires / Comments</td></tr>

<tr><td colspan=3><span class="note">(optionnel / optional)</td></tr>

<td valign="top" class="item"><label for="form_comments"></label><br /><span class="note"></span></td>
<td colspan=2><textarea name="comments" id="form_comments" cols=70 rows=4>'.safeHTMLstr($el["comments"]).'</textarea></td>
</tr>
';


if (oc_hookSet('author-edit-comments')) {
	foreach ($GLOBALS['OC_hooksAR']['author-edit-comments'] as $hook) {
		require_once $hook;
	}
}


print '
<tr><td colspan=3 class="sep">&nbsp;<br>&nbsp;</td></tr>

<tr><td colspan=3 valign="top" class="cat">Soumission</td></tr>
';

if (! $chair) {
	print '
<tr>
<td colspan=3>
<span class="note">
Please enter your current password and click on the <i>Enregistrer les modifications</i> button.
</span>
</td></tr>
<tr><td class="item"><label for="form_pwd">Mot&nbsp;de&nbsp;passe&nbsp;actuel:</label></td>
<td colspan=2><input type="password" name="pwd" id="form_pwd" size=20 maxlength=250></td></tr>
';
}

print '
<tr><td colspan="3">
<input type="submit" name="submit" value="Enregistrer les modifications"></td>
</td></tr>
</table>
</form>
';

		printFooter();
		exit;
	} // elseif Edit Submission
} // if Submission

// display login form by default
print '
<center>
<form method="post" action="' . $_SERVER['PHP_SELF'] . '">
<table border=0 cellspacing=0 cellpadding=5>
<tr><td><b>Soumission n°</b></td><td><input name="pid" size="5" tabindex="1"> ( <a href="email_papers.php">forgot ID?</a> )</td></tr>
<tr><td><b>Mot de passe :</b></td><td><input name="pwd" type="password" tabindex="2" size="20" maxlength="255"> ( <a href="reset.php">forgot password?</a> )</td></tr>
</td></tr></table>
<p>
<input type="submit" name="submit" value="Modifier la soumission" tabindex="3">
</form>
</center>
<p>
<script language="javascript">
<!--
document.forms[0].elements[0].focus();
// -->
</script>

';

printFooter();

exit;

?>
