@verb #310:"tell_audit" this none this rxdo #789
@program #310:"tell_audit" this none this
player:isa($webber) || E_PERM
set_task_perms(player.user)
{who, columns, ?sort = ""} = args
"Columns is a list of some or all of these strings:"
good = this.audit_columns
if (!`objects = who.owned_objects ! E_PROPNF')
return player:tell("", who.name, " doesn't own anything.")
endif
if (bad = $set_utils:difference(columns, good))
player:tell("Invalid column types: ", $su:english_list(bad), "
")
endif
columns = $set_utils:intersection(columns, good)
if (sort && !(sort in good))
player:tell("Invalid sort type: ", sort, "
")
sort = ""
elseif (sort && !(sort in columns))
player:tell("Sort type (", sort, ") isn't one of the columns. Table won't be sorted.
")
sort = ""
endif
info = keys = {}
for object in (objects)
line = {}
for column in (columns)
$command_utils:suspend_if_needed()
if (column == "#")
text = tostr(object)
sort == "#" && (key = object)
elseif (column == "Name")
text = $www:link(object, object.name || "unnamed")
sort == "Name" && (key = object.name)
elseif (column == "Parent")
text = tostr(parent(object))
sort == "Parent" && (key = parent(object))
elseif (column == "Location")
text = tostr(object.location)
sort == "Location" && (key = object.location)
elseif (column == "RWF")
text = (object.r ? "R" | "") + (object.w ? "W" | "") + (object.f ? "F" | "")
text = text || " "
sort == "RWF" && (key = text)
elseif (column == ". / : / !")
text = `tostr("", length(properties(object)), "/", length(verbs(object)), "/", length(object:filelist()), "") ! E_PERM => "E_PERM"'
text = text || " "
sort == ". / : / !" && (key = `length(properties(object)) + length(verbs(object)) + length(object:filelist()) ! E_PERM => 0')
elseif (column == "$Type")
text = `$find_reference_in_ancestry(object) ! ANY => "???"'
sort == "$Type" && (key = text)
elseif (column == "Expires")
if (`object:_get_petrified() ! E_PROPNF => 1')
text = "petrified"
sort == "Expires" && (key = $maxint - 1)
elseif (object:_get_solidified())
text = "solidified"
sort == "Expires" && (key = $maxint - 2)
elseif ($object_utils:isa(object, $player))
text = ""
sort == "Expires" && (key = $maxint)
elseif (object:is_expired())
text = "expired"
sort == "Expires" && (key = $minint)
else
text = $string_utils:from_seconds(object.best_before - time())
sort == "Expires" && (key = object.best_before)
endif
elseif (column == "Disk")
if (`object:_get_subsidised() ! E_PROPNF => 0')
text = "subsidised"
sort == "Disk" && (key = $maxint)
else
text = tostr(object:_obj_disk_size() || "")
sort == "Disk" && (key = object:_obj_disk_size())
endif
elseif (column == "Bytes")
text = tostr(object:object_bytes())
sort == "Bytes" && (key = object:object_bytes())
elseif (column == "Kids")
kids = children(object)
if (kids)
text = tostr("", length(kids), length(kids) == 1 ? " kid" | " kids", "")
else
text = " "
endif
sort == "Kids" && (key = length(kids))
elseif (column == "Setup")
text = tostr("Setup")
sort == "Setup" && (key = object)
elseif (column == "Recycle")
text = is_player(object) ? "" | tostr("Recycle")
sort == "Recycle" && (key = is_player(object) ? #-1 | object)
else
raise(E_INVARG, "Unknown column type.", column)
endif
line = {@line, text}
endfor
$command_utils:suspend_if_needed()
info = {@info, line}
sort && (keys = {@keys, key})
endfor
if (!$tcm && sort)
info = $list_utils:sort_suspended(info, keys)
endif
player:TellColumns(3, $list_utils:make(length(columns), 1), columns, @info)
"Last modified by Dax (#789) on Tue May 3 14:09:31 2005 MDT."
.