%%comment-save-writer-scene%%
2002-12-27 15:11

%%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['comment'] || $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 Comments.",0);
	exit;
	}

// set flavor and name
$this->flavor= "Frame";
if (trim($this->name)=="") {
	// generate a unique name
	$this->name= date("Ymd").".".substr(uniqid(""),-4);
	}
berror("Comment Name is $this->name.",1);

//subscribe author automatically
//$this->p_subscriptionList= $sitemember->id;

// SCENE PROCESSING
$getobjects= $_POST['object'];
$newbody= "^^";
if (is_array($getobjects)) {
	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'];

berror("Saved comment $this->id which has parentobjtype=$this->parentobjtype and parentid=$this->parentid.",1);
$parent= $this->getParent();

$redirect="Location: $parent->baseUrl?frameid=$this->id";
if ($GLOBALS[debug]) {
 print "<b>Updated!</b><br><a href='$parent->baseUrl?frameid=$this->id'>Click here to continue.</a>";
 }
else {
 header($redirect); 
 exit;
 }


%%end of context%%
