%%document-save-member-html%%
2002-11-10 

%%preprocess%%
// elevate member policy
berror("Current role is $sitemember->role",1);

// check somewhere if members are allowed to create before you do this.
if ($session->canSave['document'] || $session->canSave['all']) {
	if ($GLOBALS['sitemember']->role=="member") {
		$session->insertstatus= "posted";
		$session->insertpublic= 1;
		$session->publicwhere= "";
		$session->updatestatus= "posted";
		$session->updatepublic= "1";
		$session->updaterank= "100";
		$GLOBALS[session]= $session;
		}
	}
else {
	berror("Current policy does not allow you to save documents.",0);
	ext;
	}

if (trim($this->name)=="") {
	// generate a title-based unique name
	if (trim($this->title)=="") $this->name= date("Ymd").".".substr(uniqid(""),-4);
	else {
		$this->name= urlencode(strtolower(str_replace(" ","_",$this->title)));
		$this->name= preg_replace("/\%\d\d/","",$this->name);
		$this->name= substr($this->name,0,12)."_".substr(uniqid(""),-4);
		}
	}
berror("Document Name is $this->name.",1);

//subscribe author automatically
$this->p_subscriptionList= $sitemember->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);

%%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%%
// reset policy to normal levels.
$GLOBALS['session']->applyPolicy();

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


%%end of context%%
