/** * Look for a dam:trash, and move element inside. create dam:trash at root if not found * @param {Integer} $id of the node to recycle * @return {Boolean} true on success, false otherwise */ static function recycle($id) { $trashcan = model::searchKey('id', 'dam:trash'); $trashcan = $trashcan[0]; if (!$trashcan) { $trashcan = model::create(array('#parent' => '0', 'id' => 'dam:trash', 'name' => 'dam:trash', 'type' => 'folder')); } return model::move($id, $trashcan); }
header('HTTP/1.1: 400 Bad Request'); exit; } // Here we implemented the children method to return indexes for performance, keeping the backward compatibility if (arg("int") === '1') { echo json_encode(model::children(arg('id'))); } else { echo json_encode(model_json::multi(model::children(arg('id')))); } break; case "move": if (is_null(arg('id')) || is_null(arg('target'))) { header("HTTP/1.1: 400 Bad Request"); echo "Bad command"; exit; } if (!model::move(arg("id"), arg("target"))) { header("HTTP/1.1: 409 Conflict"); echo "move Error, please change your values"; exit; } break; default: header('HTTP/1.1: 400 Bad Request'); exit; } // switch / case $nolog = array('read', 'ancestors', 'children', 'links', 'stats', 'types', 'tags', 'search'); if (!in_array(arg('cmd'), $nolog)) { damas_service::log_event(); }