%%sitemember-newpassword-admin-html%%
$Date: 2003/03/07 20:40:53 $

%%preprocess%%
if ($session->request->connection!="https") {
 $newlocation= "https://".$session->request->sitename."$_SERVER[SCRIPT_NAME]/".$session->request->path."?".$session->request->cgi;
 header("Location: $newlocation");
 exit;
 }

$postvars= $_POST;
if ($postvars[email]!="") {
	$valid= 1;
    $session->updatestatus= "";
    $GLOBALS[session]= $session;

	$email= addslashes($postvars[email]);
	$id= addslashes($postvars[id]);
	berror("sitemember-newpassword called on member #$id with email=$email.",1);

	if ($email=="" ) {
		$GLOBALS['session']->alert= "Email was blank!";
		$valid= 0;
		}

	// create a temporary member object for comparison
	$temp= new Member;

	// lookup email in member table
	$query= "SELECT * FROM member WHERE email='$email' AND id!='$id' AND status!='deleted' ";
	$temp->selectObject($query);

	if ($temp->id!="") {
		$GLOBALS['session']->alert= "Another membership already exists with that email address ($temp->email).";
		$valid= 0;
		}

	// no duplicate, so update the member
	$temp->id= $postvars[id];
	$temp->email= $postvars[email];
	if ($postvars[newpassword]!="") $temp->password= bpassword($postvars[newpassword]);
	if ($postvars[hint]!="") $temp->hint= $postvars[hint];
	//$temp->flavor= $current->flavor;
	//$temp->status= $current->status;


    if ($valid) {
		$temp->updateObject('$Id: sitemember-newpassword-admin-html,v 1.4 2003/03/07 20:40:53 csnyder Exp $');
		$newlocation= "$_SERVER[SCRIPT_NAME]/".$session->request->path."?method=view$session->cgi";
		//header("Location: $newlocation");
		print "Successfully updated. <a href='$newlocation'>Please click here</a> to continue.";
		exit;
		}
    }

//look up the member's email?
$query= "SELECT obj.email FROM member AS obj WHERE obj.id='$this->memberid' ";
$member= new Member;
$member->selectObject($query);
$this->email= $member->email;

%%header%%


%%css%%


%%template%%
<form method='post' action='$this->idurl?method=newpassword' class='.form'>
<input type=hidden name=id value='$this->memberid'>
<table width='400' border='0' cellspacing='0' cellpadding='5' align='center'>
<tr>
<td colspan=2><b>Change email address and/or password:</b></td>
</tr>
<tr> <td colspan=2><b>This will affect $this->name's registration ($this->email) at all berylium sites on this server.</b></td>
</tr>
<tr> <td colspan=2><b>$session->alert</b></td>
</tr>
<tr> <td align='right' valign='top'>email:</td>
<td valign='top'> <input type='text' name='email' size='42' maxlength='255' value="$this->email">
</td>
</tr>
<tr> <td align='right' valign='top'>new password:</td>
<td valign='top'> <input type='text' name='newpassword' size='42' maxlength='255' value="">
</td>
</tr>
<tr> <td align='right' valign='top'>new password&nbsp;hint:</td>
<td valign='top'> <input type='text' name='hint' size='42' maxlength='255' value="">
<br>
This hint should remind you of your password. Passwords are encrypted 
        and can't be included in a reminder email.</td>
</tr>
<tr> <td>&nbsp;</td>
<td> <input type='submit' name='Submit' value='update' class='buttonstyle'>
</td>
</tr>
</table>
</form>


%%listrow%%


%%nullobject%%


%%footer%%


%%postprocess%%


%%end of context%%
