Posted by:.

6 replies on “Confluence trick: Put a button to create a Blog Entry

    1. Hi Patrick, yes you can use Javascript to query the REST API for the user groups and validate it.
      Example with JIRA REST to obtain the groups of the user:

      (function() {
      
      function getCurrentUserData()
      {
      var user;
           AJS.$.ajax({
              url: "/rest/api/2/myself",
              type: 'get',
              dataType: 'json',
              async: false,
              success: function(data) {
                  user = data.key;
              }
           });
           return user;
      }
      
      
      
      function getCurrentUserGroups()
      {
      var user;
           AJS.$.ajax({
              url: "/rest/api/2/myself?expand=groups",
              type: 'get',
              dataType: 'json',
              async: false,
              success: function(data) {
                  group = data.groups.items[0].name;
              }
           });
           return group;
      }
      
      
      alert("User:" + getCurrentUserData()+ " Group:"+ getCurrentUserGroups());
      
      
      })();
      

      you can see the Confluence REST options here:
      https://docs.atlassian.com/atlassian-confluence/REST/6.6.0/?_ga=2.201438101.509108005.1515055286-1667334152.1507881432

      The methods are these:

      Get user
      GET /rest/user
      Get anonymous
      GET /rest/user/anonymous
      Get current
      GET /rest/user/current
      Get groups
      GET /rest/user/memberof

      Regards

      Like

  1. Hi, what I meant was add restrictions to the blog inside that html macro. So somewhere in

    Create Blog

    add restrictions so that only a certain group can see the blog that will be created.

    Like

      1. Yes you can add the tag and insert the javascript code of my latest response. Then you must modify the code to obtain the REST data from Confluence and not for JIRA (but if you use SSO you can use the code as is and obtain the groups of the current user from the JIRA REST API).

        Regards

        Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s