<?php
if(!defined('PSA_PATH')) define('PSA_PATH',dirname(__FILE__).'/..');
if(isset($_POST['PSA_submit'])){
if(!$PSA_SYS->username_valid(trim($_POST['PSA_id']))){
// invalid username
$PSA_SYS->error();
}else if(!$PSA_SYS->password_valid(trim($_POST['PSA_pass']))){
// invalid pass
$PSA_SYS->error();
}else{
// OK to add user
// take care of expiration date stuff first
if(isset($_POST['PSA_emonth']) && $_POST['PSA_emonth']>0){
// expiration date was sent, assemble pieces for a midnight expiration
$_POST['PSA_expiration']=$_POST['PSA_eyear'].'-'.$_POST['PSA_emonth'].'-'.$_POST['PSA_eday'].' 00:00:00';
}
$result=$PSA_SYS->user_add($_POST);
if(!$result){
$PSA_SYS->error();
}else{
if(isset($_POST['PSA_active']) && $PSA_SYS->is_admin($_SESSION['PSA_psaun']))
$PSA_SYS->user_activate($_POST['PSA_id']);
else if($PSA_SYS->is_admin($_SESSION['PSA_psaun']))
$PSA_SYS->user_activate($_POST['PSA_id'],0);
unset($_POST);
include PSA_PATH.'/include/users.php';
}
}
}else{
?>
<h2><?php echo _("Create New User") ?></h2>
<p><a href="<?php echo $_SERVER['PHP_SELF'] ?>?psaSec=users" title="<?php echo _("Back") ?>"><?php echo _("Back") ?></a></p>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>?psaSec=user_add">
<fieldset>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<th><?php echo _("Name") ?><p>(<?php echo _("Last, First, MI") ?>)</p></th>
<td valign="top">
<input type="text" name="PSA_lname" size="25" <?php if(isset($_POST['PSA_lname'])) echo 'value="',$_POST['PSA_lname'],'"'; ?> />
<input type="text" name="PSA_fname" size="20" <?php if(isset($_POST['PSA_fname'])) echo 'value="',$_POST['PSA_fname'],'"'; ?> />
<input type="text" name="PSA_mname" size="2" <?php if(isset($_POST['PSA_mname'])) echo 'value="',$_POST['PSA_mname'],'"'; ?> />
</td>
</tr>
<tr>
<th><?php echo _("E-Mail") ?></th>
<td>
<input type="text" name="PSA_email" size="35" <?php if(isset($_POST['PSA_email'])) echo 'value="',$_POST['PSA_email'],'"'; ?> />
</td>
</tr>
<tr>
<th><?php echo _("Phone") ?></th>
<td>
<input type="text" name="PSA_phone" size="20" <?php if(isset($_POST['PSA_phone'])) echo 'value="',$_POST['PSA_phone'],'"'; ?> />
</td>
</tr>
<tr>
<th><?php echo _("Username") ?></th>
<td>
<input type="text" name="PSA_id" size="20" <?php if(isset($_POST['PSA_id'])) echo 'value="',$_POST['PSA_id'],'"'; ?> />
</td>
</tr>
<tr>
<th><?php echo _("Password") ?></th>
<td>
<input type="password" name="PSA_pass" size="20" />
</td>
</tr>
<tr>
<th><?php echo _("Verify") ?></th>
<td valign="top">
<input type="password" name="PSA_pass2" size="20" />
</td>
</tr>
<tr>
<th valign="top"><?php echo _("Account Expiration") ?><p>(<?php echo _("Leave month blank for no expiration") ?>)</p></th>
<td valign="top">
<?php include PSA_PATH.'/include/expdate.form.php'; ?><br />
</tr>
<tr>
<td colspan="2">
<?php echo _("Use the fields below to set your password reset challenge. Your answer is CASE SENSITIVE.") ?>
</td>
</tr>
<tr>
<th><?php echo _("Challenge Question") ?></th>
<td>
<input type="text" name="PSA_question" size="35" />
</td>
</tr>
<tr>
<th><?php echo _("Challenge Answer") ?></th>
<td>
<input type="text" name="PSA_answer" size="20" />
</td>
</tr>
<tr>
<th valign="top"><?php echo _("Profile") ?></th>
<td valign="top">
<?php
$profiles=$PSA_SYS->get_profiles();
while(list($gid,$name)=@each($profiles)){
echo ' <input type="checkbox" name="PSA_gids[]" value="',$gid,'" />',$name,'<br />',"\n";
}
?>
</td>
</tr>
<tr>
<td colspan="2">
<input type="checkbox" name="PSA_active" value="1" />
<b><?php echo _("Account Active") ?></b>
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" name="PSA_submit" value="<?php echo _("Add User") ?>" />
</td>
</tr>
</table>
</fieldset>
</form>
<?php
}
?>