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); }
function execute(&$system, $args) { if (isset($args['action'])) { if ($args['action'] == "deletelink") { $object = new mObject($args['node_id']); /*$links = $object->getLinks(); if ($object->getNumLinksSubBottom() <= 1 && ($link['type'] == "sub" && $link['direction'] == "bottom")) $response->addAlert(ucf(i18n("unable to delete last link"))); else*/ if ($object->hasRight("write")) { $object->unlinkWithNode($args['remote_id'], $args['type'], $args['direction']); clearNodeFileCache($object->getNodeId()); clearNodeFileCache($args['remote_id']); $_SESSION['murrix']['path'] = $object->getPathInTree(); $system->triggerEventIntern("newlocation", $args); } else $system->addAlert(ucf(i18n("you don't have enough rights to delete this link"))); return; } else if ($args['action'] == "newlink") { $object = new mObject($args['node_id']); if ($object->hasRight("write")) { 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")) { if (!$object->linkWithNode($remote_node_id, $args['type'])) { $system->addAlert(ucf(i18n($object->error))); return; } clearNodeFileCache($object->getNodeId()); clearNodeFileCache($remote_node_id); } else { $system->addAlert(ucf(i18n("you don't have enough rights on the remote object to create this link"))); 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 to create a link"))); return; } $args['message'] = ucf(i18n("created new link successfully")); $_SESSION['murrix']['path'] = $object->getPathInTree(); $system->triggerEventIntern("newlocation", $args); return; } } $this->draw($system, $args); }
function exec($args, $stdin, &$stdout, &$stderr, &$system) { if (!empty($args)) { $args_split = splitArgs($args); if (count($args_split) >= 2) { $source = $args_split[0]; $target = $args_split[1]; if ($source{0} != "/") $source = $_SESSION['murrix']['path']."/$source"; $source_node_id = getNode($source); if ($source_node_id <= 0) { $stderr = ucf(i18n("no such path")).": $source"; return true; } else $source = new mObject($source_node_id); if (!(isAdmin() || $source->hasRight("write"))) { $stderr = ucf(i18n("not enough rights on source")); return true; } if ($target{0} != "/") $target = $_SESSION['murrix']['path']."/$target"; $target_node_id = getNode($target); if ($target_node_id <= 0) { $stderr = ucf(i18n("no such path")).": $target"; return true; } else $target = new mObject($target_node_id); if (!(isAdmin() || $target->hasRight("write"))) { $stderr = ucf(i18n("not enough rights on target")); return true; } $parent_node_id = getNode($_SESSION['murrix']['path']); $source->linkWithNode($target->getNodeId(), "sub"); $source->unlinkWithNode($parent_node_id, "sub", "bottom"); clearNodeFileCache($source->getNodeId()); clearNodeFileCache($target->getNodeId()); clearNodeFileCache(getNode($_SESSION['murrix']['path'])); $stdout = ucf(i18n("moved node successfully")); } } else { $stdout = "Usage: omove [sourcepath] [targetpath]\n"; $stdout .= "Example: omove \"/root/home\" \"/root/public\""; } return true; }