%%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. Be sure to update your password and create a hint when you log in.";
		$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 https://$site->name/berylium/?method=login and use:
	 email: $member->email
	 password: $this->password

	You may update your password after you have logged in, using this link:
	https://$site->name/berylium/?method=updatemember
	
	If you have received this email in error, please forward it in full to $GLOBALS[adminemail].";
		if ($_POST['sendinvite']==1) bmail($this->email, "Your new membership at $site->name.", $message);
		}
	
	$this->memberid= $member->id;
	}

// generate automagic keywords for searching later...
$ignorewords= " the , of , and , a , to , in , is , you , that , it , he , she , for , was , on , are , as , with , his , her , they , at , be , this , from , i , have , or , by , one , had , not , but , all , were , there , can , an , your , which , their , said , if , do , so , these , has , than , did , those , 1 , 2 , 3 , 4 , 5 , 6 ";
$igwordsarray= explode(",", $ignorewords);
$ignorepunctuation= ".,?,!,:,;,[,]";
$igpuncarray= explode(",", $ignorepunctuation);
$igpuncarray[]= ",";
$this->keywords= str_replace($igwordsarray, " ", str_replace($igpuncarray, " ", strtolower($this->description)));
$this->keywords= str_replace("  ", " ", $this->keywords);

// put name into keywords, too.
$this->keywords= $this->name." ".$this->keywords;

%%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->idUrl?method=edit$session->cgi'>edit</a> | <a href='$this->idUrl?method=create$session->cgi'>create new</a> | <a href='$this->idUrl?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%%
