[xwiki-devs] tree view macro stops working after changing XWikiGlobalRights
Hello. I'm trying to grant page delete right for all registered users.I'm doing it by running this code in onEvent method of my ApplicationReadyEventListenerif (contextProvider != null) { XWikiContext context = contextProvider.get(); if (context != null) { XWiki xwiki = context.getWiki(); DocumentReference dr = new DocumentReference("xwiki", "XWiki", "XWikiPreferences"); XWikiDocument doc = xwiki.getDocument(dr, context); BaseObject bo = doc.getObject("XWiki.XWikiGlobalRights", true, context); bo.set("groups", "XWiki.XWikiAllGroup", context); bo.set("levels", "view,comment,edit,script,delete", context); bo.set("users", "", context); bo.set("allow", 1, context); xwiki.saveDocument(doc, context); }}It does the job, but causes a new issue. Tree view on my page stops working showing infinite loading whentrying to expand a node. The browser developer tools shows me this exception: https://gist.github.com/edvorg/acff4a58342edfa3485791a7ba57e172 <https://gist.github.com/edvorg/acff4a58342edfa3485791a7ba57e172> -- View this message in context: http://xwiki.475771.n2.nabble.com/tree-view-macro-stops-working-after-changi... Sent from the XWiki- Dev mailing list archive at Nabble.com.
Hi Edvorg, the error message means some pages (probably either XWiki/.ocumentTree or XWiki.DocumentTreeMacros) has lost their "programming rights", because they have been edited by a user without programming rights. One option is that you have denied the "Admin" user the programming rights via your listener, by editing the first "XWiki.XWikiGlobalRights" object in the preferences, and that previously gave programming rights to the "XWiki.XWikiAdminGroup" . You should be able to check this by viewing the XWiki.XWikiPreferences page in the object editor and inspect its XWiki.XWikiGlobalRights" object. To avoid this, your code should loop over all "XWiki.XWikiGlobalRights" of the preferences page, and modify the one which has a value for "groups" as "XWiki.XWikiAllGroup" and a "allow" == 1, possibly creating such an object if it does not exist Hope this helps Clemens P.S.: the code in your mail looks somewhat unformatted. Maybe you send it as HTML mail? The mailinglist software only delivers plain text mail, so it might be better to only send plain text mails, too Edvorg wrote:
Hello. I'm trying to grant page delete right for all registered users.I'm doing it by running this code in onEvent method of my ApplicationReadyEventListenerif (contextProvider != null) { XWikiContext context = contextProvider.get(); if (context != null) { XWiki xwiki = context.getWiki(); DocumentReference dr = new DocumentReference("xwiki", "XWiki", "XWikiPreferences"); XWikiDocument doc = xwiki.getDocument(dr, context); BaseObject bo = doc.getObject("XWiki.XWikiGlobalRights", true, context); bo.set("groups", "XWiki.XWikiAllGroup", context); bo.set("levels", "view,comment,edit,script,delete", context); bo.set("users", "", context); bo.set("allow", 1, context); xwiki.saveDocument(doc, context); }}It does the job, but causes a new issue. Tree view on my page stops working showing infinite loading whentrying to expand a node. The browser developer tools shows me this exception: https://gist.github.com/edvorg/acff4a58342edfa3485791a7ba57e172 <https://gist.github.com/edvorg/acff4a58342edfa3485791a7ba57e172>
-- View this message in context: http://xwiki.475771.n2.nabble.com/tree-view-macro-stops-working-after-changi... Sent from the XWiki- Dev mailing list archive at Nabble.com. _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
I'm sorry, my bad. I didn't know it doesn't support html. Thank you for you response. I will check it out as soon as possible. 2016年7月5日(火) 19:56 Clemens Klein-Robbenhaar [via XWiki] < [email protected]>:
Hi Edvorg,
the error message means some pages (probably either XWiki/.ocumentTree or XWiki.DocumentTreeMacros) has lost their "programming rights", because they have been edited by a user without programming rights.
One option is that you have denied the "Admin" user the programming rights via your listener, by editing the first "XWiki.XWikiGlobalRights" object in the preferences, and that previously gave programming rights to the "XWiki.XWikiAdminGroup" .
You should be able to check this by viewing the XWiki.XWikiPreferences page in the object editor and inspect its XWiki.XWikiGlobalRights" object.
To avoid this, your code should loop over all "XWiki.XWikiGlobalRights" of the preferences page, and modify the one which has a value for "groups" as "XWiki.XWikiAllGroup" and a "allow" == 1, possibly creating such an object if it does not exist
Hope this helps Clemens
P.S.: the code in your mail looks somewhat unformatted. Maybe you send it as HTML mail? The mailinglist software only delivers plain text mail, so it might be better to only send plain text mails, too
Edvorg wrote:
Hello. I'm trying to grant page delete right for all registered users.I'm doing it by running this code in onEvent method of my ApplicationReadyEventListenerif (contextProvider != null) { XWikiContext context = contextProvider.get(); if (context != null) { XWiki xwiki = context.getWiki(); DocumentReference dr = new DocumentReference("xwiki", "XWiki", "XWikiPreferences"); XWikiDocument doc = xwiki.getDocument(dr, context); BaseObject bo = doc.getObject("XWiki.XWikiGlobalRights", true, context); bo.set("groups", "XWiki.XWikiAllGroup", context); bo.set("levels", "view,comment,edit,script,delete", context); bo.set("users", "", context); bo.set("allow", 1, context); xwiki.saveDocument(doc, context); }}It does the job, but causes a new issue. Tree view on my page stops working showing infinite loading whentrying to expand a node. The browser developer tools shows me this exception: https://gist.github.com/edvorg/acff4a58342edfa3485791a7ba57e172 <https://gist.github.com/edvorg/acff4a58342edfa3485791a7ba57e172>
-- View this message in context: http://xwiki.475771.n2.nabble.com/tree-view-macro-stops-working-after-changi... Sent from the XWiki- Dev mailing list archive at Nabble.com. _______________________________________________ devs mailing list [hidden email] <http:///user/SendEmail.jtp?type=node&node=7600232&i=0> http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________ devs mailing list [hidden email] <http:///user/SendEmail.jtp?type=node&node=7600232&i=1> http://lists.xwiki.org/mailman/listinfo/devs
------------------------------ If you reply to this email, your message will be added to the discussion below:
http://xwiki.475771.n2.nabble.com/tree-view-macro-stops-working-after-changi... To unsubscribe from tree view macro stops working after changing XWikiGlobalRights, click here <http://xwiki.475771.n2.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=7600229&code=ZWR2b3JnQGdtYWlsLmNvbXw3NjAwMjI5fC0xNzE2MjAxNjAy> . NAML <http://xwiki.475771.n2.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
-- View this message in context: http://xwiki.475771.n2.nabble.com/tree-view-macro-stops-working-after-changi... Sent from the XWiki- Dev mailing list archive at Nabble.com.
Finally got a chance to check your solution and it works nicely. The call we were using is deprecated, btw. Iteration over objects and modifying the right one helped. Thank you, Clemens. Edward. -- View this message in context: http://xwiki.475771.n2.nabble.com/tree-view-macro-stops-working-after-changi... Sent from the XWiki- Dev mailing list archive at Nabble.com.
participants (2)
-
Clemens Klein-Robbenhaar -
edvorg