<?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";

printHeader("Email Username",1);

if (! $OC_configAR['OC_chairUsernameForgot']) {
	print '<p class="err" style="text-align: center">Functionality disabled</p>';
}
elseif (isset($_POST['submit']) && ($_POST['submit'] == "Email Username")) {
	// Check for valid submission
	if (!validToken('chair')) {
		warn('Invalid submission');
	}

	$msg = '
The Chair username for accessing the ' . $OC_configAR['OC_confName'] . ' OpenConf system is:

	' . $OC_configAR['OC_chair_uname'] . '
';
	if (sendEmail($OC_configAR['OC_pcemail'], "Chair username", $msg)) {
		print '<p class="note2" align="center">The Chair username has been emailed to the Chair\'s address<p /><p align="center"><a href="signin.php">Proceed to sign in</a></p>';
	} else {
		err('Unable to send email');
	}
} else {
	print '
<center>
<p class="note2">Click the button below to email the username to the Chair\'s address</p>
<form method="post" action="' . $_SERVER['PHP_SELF'] . '">
<input type="hidden" name="token" value="' . $_SESSION[OCC_SESSION_VAR_NAME]['chairtoken'] . '" />
<input type="submit" name="submit" value="Email Username">
</form>
<p>
';
}

print "</center>\n";

printFooter();

?>
