Method code for $db<$root>.perms()

[Turn off line numbering]
  1: arg what, @args;
  2: var flag;
  3: 
  4: if (!args)
  5:     args = ['writer];
  6: if (type(args[1]) == 'symbol) {
  7:     switch (args[1]) {
  8:         case 'system:
  9:             if (!$sys.is_system(what))
 10:                 throw(~perm, "Permission Denied: " + what + " is not of the system.", what);
 11:         case 'manager:
 12:             if (.manager() != what && !$sys.is_system(what))
 13:                 throw(~perm, "Permission Denied: " + what + " is not the manager.", what);
 14:         case 'trusts:
 15:             if (!.trusts(what))
 16:                 throw(~perm, "Permission Denied: " + what + " is not a trustee.", what);
 17:         case 'command:
 18:             if (what != $user && what != $body)
 19:                 throw(~perm, what + " is not a valid command invoking object.");
 20:         default:
 21:             if (!.is_writable_by(what))
 22:                 throw(~perm, "Permission Denied: " + what + " is not a writer.", what);
 23:     }
 24: } else if (type(what) == 'objnum) {
 25:     if (!(what in args))
 26:         throw(~perm, what + " is not one of: " + args.mmap('namef, 'ref).to_english(), what);
 27: }

// Created as a part of ColdCore, see: @help Credit

Tlon