Module: check_mk
Branch: master
Commit: f0ca2632f462bca74c89d62be4aeeee405742c58
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f0ca2632f462bc…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Jan 10 14:30:44 2013 +0100
Added user attributes for not seeing all objects
Not yet functional...
---
web/htdocs/wato.py | 23 ++++++++++++++---------
web/plugins/wato/user_attributes.py | 26 ++++++++++++++++++++++++++
2 files changed, 40 insertions(+), 9 deletions(-)
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 943922a..7e823c3 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -7519,11 +7519,14 @@ def delete_distributed_wato_file():
# | Mode for managing users and contacts. |
# '----------------------------------------------------------------------'
-def declare_user_attribute(name, vs, user_editable = True):
+def declare_user_attribute(name, vs, user_editable = True, permission = None):
userdb.user_attributes[name] = {
'valuespec': vs,
'user_editable': user_editable,
}
+ # Permission needed for editing this attribute
+ if permission:
+ userdb.user_attributes[name]["permission"] = permission
def load_notification_scripts_from(adir):
scripts = {}
@@ -8219,10 +8222,11 @@ def mode_edit_user(phase):
select_language(user.get('language', ''))
for name, attr in userdb.get_user_attributes():
if attr['user_editable']:
- vs = attr['valuespec']
- forms.section(vs.title())
- vs.render_input("ua_" + name, user.get(name, vs.default_value()))
- html.help(vs.help())
+ if not attr.get("permission") or
config.may(attr["permission"]):
+ vs = attr['valuespec']
+ forms.section(vs.title())
+ vs.render_input("ua_" + name, user.get(name,
vs.default_value()))
+ html.help(vs.help())
# TODO: Later we could add custom macros here, which
# then could be used for notifications. On the other hand,
@@ -10850,10 +10854,11 @@ def page_user_profile():
if config.may('general.edit_user_attributes'):
for name, attr in userdb.get_user_attributes():
if attr['user_editable']:
- vs = attr['valuespec']
- value = vs.from_html_vars('ua_' + name)
- vs.validate_value(value, "ua_" + name)
- users[config.user_id][name] = value
+ if not attr.get("permission") or
config.may(attr["permission"]):
+ vs = attr['valuespec']
+ value = vs.from_html_vars('ua_' + name)
+ vs.validate_value(value, "ua_" + name)
+ users[config.user_id][name] = value
# Change the password if requested
if config.may('general.change_password'):
diff --git a/web/plugins/wato/user_attributes.py b/web/plugins/wato/user_attributes.py
new file mode 100644
index 0000000..22ef473
--- /dev/null
+++ b/web/plugins/wato/user_attributes.py
@@ -0,0 +1,26 @@
+
+declare_user_attribute(
+ "force_authuser",
+ Checkbox(
+ title = _("Visibility of Hosts/Services"),
+ label = _("Only show hosts and services the user is a contact for"),
+ help = _("When this option is checked, then the status GUI will only "
+ "display hosts and services that the user is a contact for -
"
+ "even if he has the permission for seeing all objects."),
+ ),
+ permission = "general.see_all"
+)
+
+declare_user_attribute(
+ "force_authuser_webservice",
+ Checkbox(
+ title = _("Visibility of Hosts/Services (Webservice)"),
+ label = _("Export only hosts and services the user is a contact for"),
+ help = _("When this option is checked, then the Multisite webservice "
+ "will only export hosts and services that the user is a contact for
- "
+ "even if he has the permission for seeing all objects."),
+ ),
+ permission = "general.see_all"
+)
+
+