@verb #3135:"edit_verb" this none this rxdo #3135 @program #3135:"edit_verb" this none this "Copied from WWW-Exam (#84):edit_verb by Dax (#789) Aug 25 10:40:23 2002" caller == this || raise(E_PERM) player:isa($webber) || raise(E_PERM) player:tell($eval.antistealth) set_task_perms(player.user) {get, object} = args if (iobj && player.referer && $www:previous_object() != object && player.user != $no_one) "We have an unknown form refering a command to us with a user's perms..." $msg:mtell("www_error", "Warning! Previous page doesn't appear to be this one!") player:tell("For security reasons the command will not be executed. Refering page: [", player.referer, "]") iobj = {} endif suspend(0) url = tostr("/", toint(object)) vnum = $code_utils:find_verb_named(object, get) if (vnum == -1) if ($www:parse_POST("create")) "Verb doesn't exist, and we want to create it." add_verb(object, {player.user.wizard ? $hacker | player.user, "roxd", get}, {"this", "none", "this"}) player:tell("Verb created!
") "Keep going, and show the edit page." iobj = {} vnum = length(verbs(object)) else "Verb doesn't exist, offer to create it." player:tell("", object, " doesn't define this verb.
") if (host = object:has_verb(get)) host = host[1] player:tell("However, its ancestor ", host.name, " (", host, ") does. View/Edit ", host, ":", get, "
") endif if ($perm_utils:controls(player.user, object) || (object.w && player.user != $no_one)) player:tell("

") endif inherited = 0 for x in ({object, @object:ancestors()}) inherited = inherited + length(`verbs(x) ! E_PERM => {}') endfor return player:tell("See the list of ", `length(verbs(object)) ! E_PERM => "?"', " defined verbs and ", inherited, " inherited verbs on ", $su:nn(object), ".") endif endif code = 0 v_args = 0 info = `verb_info(object, vnum) ! E_PERM' if (info == E_PERM) $msg:mtell("www_error", "You do not have permission to view this verb.") return $www.exam:tell_verbs(object) endif hack = player.user.programmer && player.user != $no_one && (player.user:controls(info[1]) || index(info[2], "w")) if ($www:parse_POST("delete")) "Delete the verb, then show the list of verbs." if (`delete_verb(object, vnum) ! E_PERM' == E_PERM) $msg:mtell("www_error", "You do not have permission to delete this verb.") return $www.exam:tell_verbs(object) else player:tell("", object, ":", $html_utils:literal_text(get), " has been deleted!
") return $www.exam:tell_verbs(object) endif elseif (iobj) "Recompile the verb." if ($www:parse_POST("create")) $msg:mtell("www_error", "Verb already exists!") elseif (this.sharing_violations && $www:parse_POST("hash") && this:hash(tostr(object, ":", get)) != $www:parse_POST("hash")) $msg:mtell("www_error", "Sharing violation!") player:tell("While you were in the editor, somebody/something changed this verb. You have two choices: you can either lose your changes or you can lose the other person's changes.

") player:tell("

") player:tell($html_utils:input_hidden("hash", "")) for x in (iobj) if (x[1] != "hash") player:tell($html_utils:input_hidden(@x)) endif endfor player:tell("It might be wise to see what the verb looks like now and determine if you want to redo your changes on the new version, or come back here and the new version with your changes.
") player:tell("

How did this happen?

") return elseif (!$set_utils:includes($list_utils:slice(iobj), {"hash", "rename", "code", "arg1", "arg2", "arg3"})) $msg:mtell("www_error", "Invalid form elements.") player:tell("Verb was not compiled due to an error in the web interface. Tell a wizard.
") else name = $www:parse_POST("rename") code = $www:parse_POST("code") typeof(code) == $STR && (code = $string_utils:explode(code, "%0a")) code = {@code} v_args = {$www:parse_POST("arg1"), $www:parse_POST("arg2"), $www:parse_POST("arg3")} mods = ($www:parse_POST("r") ? "r" | "") + ($www:parse_POST("w") ? "w" | "") + ($www:parse_POST("o") ? "o" | "") + ($www:parse_POST("x") ? "x" | "") + ($www:parse_POST("d") ? "d" | "") if (player.user.wizard && $www:parse_POST("owner") && $www:parse_POST("owner") != $su:nn(info[1])) owner = $su:match_nn_object($www:parse_POST("owner"), #-1, player.user) valid(owner) || (owner = $su:match_player($www:parse_POST("owner"), player.user)) else owner = info[1] endif old_info = info info = {owner, mods, name} result = `set_verb_info(object, vnum, info) ! E_PERM, E_INVARG' if (result == E_PERM) $msg:mtell("www_error", "You do not have permission to modify this verb.") elseif (result == E_INVARG) if (valid(owner)) $msg:mtell("www_error", "Error, verb not compiled.")