%%folder-drop-editor-html%%
2002-07-16 21:17

%%preprocess%%
// find the object listed at $session->p_inventory[key]
$key= $GLOBALS['HTTP_GET_VARS']['key'];
berror("folder-drop-editor-html: dropping item $key from p_inventory ($session->p_inventory)",1);

if ($key!="" && trim($session->p_inventory)!="") {
	$inventoryArray= explode(" ", trim($session->p_inventory));
	$dropthis= $inventoryArray[$key];
	berror("folder-drop-editor-html: dropping this: $dropthis.",1);
	if ($dropthis) {
		$droparray= explode(":", $dropthis);
		$this->dropobjtype= $droparray[0];
		$this->dropid= $droparray[1];
		}
	else {
		berror("folder-drop-editor-html: invalid object at $key in session->inventory: ($inventoryArray[$key])",0);
		}
	}
else {
	berror("folder-drop-editor-html: either no key was indicated ($key) or no inventory to work on. ($session->p_inventory).",0);
	}
	
// move the object: 
// step 1, get the object:
$classname= ucfirst($this->dropobjtype);
$command= "\$dropped= new $classname;";
berror("folder-drop-editor-html: command= $command",1);
$void= eval("$command");

// step 2, move the object
$dropped->id= $this->dropid;
if (is_object($dropped)) berror("folder-drop-editor-html: dropped is $dropped->objtype with id#$dropped->id.",1);

$query= "SELECT obj.* FROM $this->dropobjtype AS obj WHERE id='$this->dropid' ";
$dropped->selectObject($query);
$dropped->applyPolicy();
$dropped->getBaseUrl();
berror("folder-drop-editor-html: found $dropped->title at $dropped->uri.",1);

if ($dropped->move($this)) {	
	// update session->p_inventory
	foreach ( $inventoryArray AS $ikey=>$value ) {
		if ($ikey==$key) continue;
		if ($newinventory) $newinventory= $newinventory." $value";
		else $newinventory= $value;
		}
	if ($newinventory) {
		$GLOBALS['session']->p_inventory= trim($newinventory);
		berror("folder-drop-editor-html: updated session inventory to $newinventory. (".$GLOBALS['session']->p_inventory.")",1);
		}
	else {
		$GLOBALS['session']->p_inventory=" ";
		berror("folder-drop-editor-html: unset session inventory. (".$GLOBALS['session']->p_inventory.")",1);
		}
	$GLOBALS['session']->updateObject();
	
	// show object
	$this->objecttag= bparsebml("Dropped [$this->dropobjtype:$this->dropid]");
	}
else {
	$this->objecttag= bparsebml("Unable to drop [$this->dropobjtype:$this->dropid]");
	}

%%header%%

%%css%%

%%template%%
$this->objecttag ($this->dropobjtype:$this->dropid) into $this->title folder.<br>
<a href="$this->baseUrl?method=view$session->cgi">Continue</a>...

%%listrow%%

%%nullobject%%

%%footer%%

%%postprocess%%

%%end of context%%
