Make desc/set abide by edit/control locks

This commit is contained in:
Griatch 2018-03-01 20:23:18 +01:00
parent 5b96b09bca
commit aa9663024c

View file

@ -568,6 +568,9 @@ class CmdDesc(COMMAND_DEFAULT_CLASS):
if not obj: if not obj:
return return
if not (obj.access(self.caller, 'control') or obj.access(self.caller, 'edit')):
self.caller.msg("You don't have permission to edit the description of %s." % obj.key)
self.caller.db.evmenu_target = obj self.caller.db.evmenu_target = obj
# launch the editor # launch the editor
EvEditor(self.caller, loadfunc=_desc_load, savefunc=_desc_save, EvEditor(self.caller, loadfunc=_desc_load, savefunc=_desc_save,
@ -597,7 +600,7 @@ class CmdDesc(COMMAND_DEFAULT_CLASS):
if not obj: if not obj:
return return
desc = self.args desc = self.args
if obj.access(caller, "edit"): if (obj.access(self.caller, 'control') or obj.access(self.caller, 'edit')):
obj.db.desc = desc obj.db.desc = desc
caller.msg("The description was set on %s." % obj.get_display_name(caller)) caller.msg("The description was set on %s." % obj.get_display_name(caller))
else: else:
@ -1581,6 +1584,10 @@ class CmdSetAttribute(ObjManipCommand):
result = [] result = []
if "edit" in self.switches: if "edit" in self.switches:
# edit in the line editor # edit in the line editor
if not (obj.access(self.caller, 'control') or obj.access(self.caller, 'edit')):
caller.msg("You don't have permission to edit %s." % obj.key)
return
if len(attrs) > 1: if len(attrs) > 1:
caller.msg("The Line editor can only be applied " caller.msg("The Line editor can only be applied "
"to one attribute at a time.") "to one attribute at a time.")
@ -1601,12 +1608,18 @@ class CmdSetAttribute(ObjManipCommand):
return return
else: else:
# deleting the attribute(s) # deleting the attribute(s)
if not (obj.access(self.caller, 'control') or obj.access(self.caller, 'edit')):
caller.msg("You don't have permission to edit %s." % obj.key)
return
for attr in attrs: for attr in attrs:
if not self.check_attr(obj, attr): if not self.check_attr(obj, attr):
continue continue
result.append(self.rm_attr(obj, attr)) result.append(self.rm_attr(obj, attr))
else: else:
# setting attribute(s). Make sure to convert to real Python type before saving. # setting attribute(s). Make sure to convert to real Python type before saving.
if not (obj.access(self.caller, 'control') or obj.access(self.caller, 'edit')):
caller.msg("You don't have permission to edit %s." % obj.key)
return
for attr in attrs: for attr in attrs:
if not self.check_attr(obj, attr): if not self.check_attr(obj, attr):
continue continue