%%document-save-member-html%%
roots.encielo.org /recipients
2002-08-16 11:10:00

%%preprocess%%
/* old way:
$recipient= new Document;
$query= "SELECT obj.* FROM document AS obj WHERE obj.id='".$_GET['recipientid']."' AND obj.status!='deleted' ";
$recipient->selectObject($query);
$recipient->originalid= $recipient->id;
$recipient->id= "";
$recipient->name= "childof:$this->id:document:$recipient->originalid";
$recipient->parentid= $this->id;
$recipient->parentobjtype= "document";
$recipient->insertObject();
*/

// break out $this->p_recipientlist
$recipientarray= explode(" ",$this->p_recipientlist);
$found= 0;

// check if recipient is already here...
foreach ($recipientarray AS $key=>$value) {
    if ($value==$_GET['recipientid']) $found= 1;
    }

if (!$found) {
    // if not, add to the end of recipientlist
    $this->p_recipientlist= trim($this->p_recipientlist)." ".$_GET['recipientid'];

    // update the document
    $this->updateObject();
    }
else {
    berror("That recipient has already been suggested for this document.",0);
    }

%%header%%

%%css%%

%%template%%


%%listrow%%

%%nullobject%%

%%footer%%

%%postprocess%%
$this->getBaseURL();
$method="view";
$redirect="Location: $this->baseURL?method=$method"; 
if ($GLOBALS[debug]) {
 print "<b>Added</b><br><a href='$redirect'>Click here to continue.</a><hr>";
 }
else {
 header($redirect); 
 exit;
 }

%%end of context%%
