function actionDelete(&$system, $args) { $object = new mObject($this->getNodeId($args)); if ($object->getNodeId() > 0) { if ($object->hasRight("write")) { $parent_id = getNode(GetParentPath($object->getPathInTree())); $object->deleteNode(); $system->addRedirect("exec=show&node_id=$parent_id"); } else $system->addAlert(ucf(i18n("not enough rights"))); } else $system->addAlert(ucf(i18n("the specified path is invalid"))); }
function exec($args, $stdin, &$stdout, &$stderr, &$system) { if (!empty($args)) { $path = $args; if ($path{0} != "/") $path = $_SESSION['murrix']['path']."/$path"; $node_id = getNode($path); if ($node_id <= 0) { $stderr = ucf(i18n("no such path")); return true; } else $object = new mObject($node_id); if (!(isAdmin() || $object->hasRight("write"))) { $stderr = ucf(i18n("not enough rights to delete")); return true; } clearNodeFileCache($object->getNodeId()); $object->deleteNode(); $stdout = ucf(i18n("deleted node successfully")); } else { $stdout = "Usage: odel [name]\n"; $stdout .= "Example: odel oldfolder"; } return true; }
function execute(&$system, $args) { if (isset($args['action'])) { $object = new mObject($args['parent_id']); if ($object->hasRight("write")) { if (count($args['node_ids']) == 0) { $system->addAlert(ucf(i18n("you must select at least one object"))); return; } if ($args['action'] == "delete") { foreach ($args['node_ids'] as $node_id) { $child = new mObject($node_id); $not_allowed_str = ""; if ($child->hasRight("write")) $child->deleteNode(); else $not_allowed_str .= $child->getPathInTree()."\n"; if (!empty($not_allowed_str)) $system->addAlert(ucf(i18n("you did not have enough rights to delete these nodes:"))."\n$not_allowed_str"); } clearNodeFileCache($object->getNodeId()); } else { if (isset($args['remote_node_id'])) $remote_node_id = $args['remote_node_id']; else $remote_node_id = getNode($args['path']); if ($remote_node_id > 0) { $remote = new mObject($remote_node_id); if ($remote->hasRight("write")) { switch ($args['action']) { case "move": foreach ($args['node_ids'] as $node_id) { $child = new mObject($node_id); $child->linkWithNode($remote_node_id, "sub"); $child->unlinkWithNode($object->getNodeId(), "sub", "bottom"); clearNodeFileCache($object->getNodeId()); clearNodeFileCache($child->getNodeId()); clearNodeFileCache($remote_node_id); } break; case "link": foreach ($args['node_ids'] as $node_id) { $child = new mObject($node_id); $child->linkWithNode($remote_node_id, "sub"); clearNodeFileCache($remote_node_id); clearNodeFileCache($child->getNodeId()); } break; } } else { $system->addAlert(ucf(i18n("you don't have enough rights on the target"))); return; } } else { $system->addAlert(ucf(i18n("the remote object you specified does not exist"))); return; } } } else { $system->addAlert(ucf(i18n("you don't have enough rights"))); return; } } $this->draw($system, $args); }