[checkmk-commits] Check_MK Git: check_mk: New sub-permissions for changing comment and contact while updating an event

git version control git at mathias-kettner.de
Wed Nov 7 10:31:26 CET 2012


Module: check_mk
Branch: master
Commit: 82e3eb1238123e2a8fd554ed917278ffe49da002
URL:    http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=82e3eb1238123e2a8fd554ed917278ffe49da002

Author: Mathias Kettner <mk at mathias-kettner.de>
Date:   Wed Nov  7 10:31:23 2012 +0100

New sub-permissions for changing comment and contact while updating an event

---

 ChangeLog                              |    1 +
 mkeventd/web/plugins/views/mkeventd.py |   34 +++++++++++++++++++++++++------
 2 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 21d4190..2d80ed1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -15,6 +15,7 @@
     * check_mkevents outputs last worst line in service output
     * Max. number of queued connections on status sockets is configurable now
     * check_mkevents: new option -a for ignoring acknowledged events
+    * New sub-permissions for changing comment and contact while updating an event
 
     Multisite:
     * Enable automation login with _username= and _secret=, while
diff --git a/mkeventd/web/plugins/views/mkeventd.py b/mkeventd/web/plugins/views/mkeventd.py
index c8c0873..7aa4cec 100644
--- a/mkeventd/web/plugins/views/mkeventd.py
+++ b/mkeventd/web/plugins/views/mkeventd.py
@@ -571,14 +571,28 @@ if mkeventd_enabled:
             _("Update an event"),
             _("Needed for acknowledging and changing the comment and contact of an event"),
             [ "user", "admin" ])
+
+    # Sub-Permissions for Changing Comment, Contact and Acknowledgement
+    config.declare_permission("mkeventd.update_comment",
+            _("Update an event: change comment"),
+            _("Needed for changing a comment when updating an event"),
+            [ "user", "admin" ])
+    config.declare_permission("mkeventd.update_contact",
+            _("Update an event: change contact"),
+            _("Needed for changing a contact when updating an event"),
+            [ "user", "admin" ])
     
     def render_mkeventd_update():
         html.write('<table border=0 cellspacing=3 cellpadding=0>')
-        html.write('<tr><td>%s</td><td>' % _("Change comment:"))
-        html.text_input('_mkeventd_comment', size=50)
-        html.write('</td></tr><tr><td>%s</td><td>' % _("Change contact:"))
-        html.text_input('_mkeventd_contact', size=50)
-        html.write('</td></tr><td></td><td>')
+        if config.may("mkeventd.update_comment"):
+            html.write('<tr><td>%s</td><td>' % _("Change comment:"))
+            html.text_input('_mkeventd_comment', size=50)
+            html.write('</td></tr>')
+        if config.may("mkeventd.update_contact"):
+            html.write('<tr><td>%s</td><td>' % _("Change contact:"))
+            html.text_input('_mkeventd_contact', size=50)
+            html.write('</td></tr>')
+        html.write('<td></td><td>')
         html.checkbox('_mkeventd_acknowledge', True, label=_("Set event to acknowledged"))
         html.write('</td></tr>')
         html.write('</table>')
@@ -586,8 +600,14 @@ if mkeventd_enabled:
     
     def command_mkeventd_update(cmdtag, spec, row):
         if html.var('_mkeventd_update'):
-            comment = html.var_utf8("_mkeventd_comment").strip().replace(";",",")
-            contact = html.var_utf8("_mkeventd_contact").strip().replace(":",",")
+            if config.may("mkeventd.update_comment"):
+                comment = html.var_utf8("_mkeventd_comment").strip().replace(";",",")
+            else:
+                comment = ""
+            if config.may("mkeventd.update_contact"):
+                contact = html.var_utf8("_mkeventd_contact").strip().replace(":",",")
+            else:
+                contact = ""
             ack = html.get_checkbox("_mkeventd_acknowledge")
             return "UPDATE;%s;%s;%s;%s;%s" % \
                 (row["event_id"], config.user_id, ack and 1 or 0, comment, contact), \



More information about the checkmk-commits mailing list