%%sitemember-save-member-html%%
progmin : / (context #112)
2002-06-11 21:48:36

%%preprocess%%

if ($this->id=="") {
	// creating a new sitemember, might need to create a new member, too...
	if ($sitemember->role!="admin" && $this->role!="member" && $this->memberid!=$sitemember->memberid ) {
		berror("Sorry, you do not have permission to save an editor-type sitemember. Please contact the site admin.",0);
		exit;
		}
		
	// use email to look up member record
	$member= new Member;
	$query= "SELECT obj.id, obj.email FROM member AS obj WHERE obj.email='$this->email' AND obj.status='posted' ";
	$member->selectObject($query);
	
	//if not found, create a new member with email, password, and sitememberid=$sitemember->id
	if ($member->id=="") {
		// from session->membercreate...
		$member->email= $this->email;
		$member->password= bpassword($this->password);
		$member->hint= "Please get your password from $sitemember->name.";
		$member->flavor= "created";
		$member->status= "posted";
		$member->sitememberid= $sitemember->id;
		$member->insertObject();
			
		// it's probably okay, just this once, to send a clear password?
		$message="A membership has been created for you at $site->name by $sitemember->name.
	
	To access the site, go to http://$site->name/berylium/?method=login and use:
	 email: $member->email
	 password: $this->password
	
	If you have received this email in error, please forward it in full to $GLOBALS[adminemail].";
		bmail($this->email, "Your new membership at $site->name.", $message);
		}
	
	$this->memberid= $member->id;
	}


%%header%%





%%css%%





%%template%%
<table width='90%' border='0' cellspacing='20' cellpadding='5' align='center'>
<tr> <td> <p><b>UPDATED! $this->objtype object id#$this->id ($this->name):</b></p>
<p>$this->propertiesList</p>
<p><a href='$session->refreshURL'>refresh</a> | <a href='$this->baseURL?method=edit$session->cgi'>edit</a> | <a href='$this->baseURL?method=create$session->cgi'>create new</a> | <a href='$this->baseURL?method=addchild$session->cgi'>add child</a> | <a href='#top'>top</a></p>
</td>
</tr>
</table>







%%listrow%%





%%nullobject%%





%%footer%%





%%postprocess%%
$this->getBaseURL();
if ($this->submit=="save") $method="edit";
else $method="view";
$redirect="Location: ".$this->idUrl."?method=$method".$session->cgi; 
if ($GLOBALS[debug]) {
 print "<b>Updated!</b><br><a href='$this->idUrl?method=view$session->cgi'>Click here to continue.</a>";
 }
else {
 header($redirect); 
 exit;
 }





%%end of context%%
