%%document-save-writer-scene%%
2002-12-22 11:46

%%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;
	}

// set flavor and name
$this->flavor= "Scene";
if (trim($this->name)=="") {
	// generate a unique name
	$this->name= date("Ymd").".".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);

// SCENE PROCESSING
$getobjects= $_POST['object'];
$newbody= "^^";
foreach ($getobjects AS $objnum=>$value) {
	$var= "object$objnum-";
	foreach ($_POST AS $key=>$postval) {
		if (substr($key,0,strlen($var))!=$var) continue;
		$newbody.= substr($key,strlen($var))."=".$postval."^";
		}
	$newbody.= "^";
	}
berror("newbody is $newbody",1);
$this->body= $newbody;


%%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();
$session= $GLOBALS['session'];

$this->getBaseUrl();
$redirect="Location: $this->baseUrl?method=view$session->cgi";
if ($_POST['submit']=="Create") $redirect.="#controls";
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%%
