Forum Discussion

fuenteso's avatar
fuenteso
Leader
8 years ago

Is thread/board/category Read Only?

Hi,

 

Is there a way to know if a category/board/thread is read only using lithium contexual objects? I want to disable the "Post new message" on threads or boards marked as Read Only

 

Thanks!

  • fuenteso - There aren't any context objects, however, you can check the read-only categories/ boards using this API -

     

    http://community.lithium.com/community-name/restapi/vc/boards/id/[id]/settings/name/config.read_only

     

    I hope this helps. 

  • fuenteso - There aren't any context objects, however, you can check the read-only categories/ boards using this API -

     

    http://community.lithium.com/community-name/restapi/vc/boards/id/[id]/settings/name/config.read_only

     

    I hope this helps. 

  • ClaudiusH's avatar
    ClaudiusH
    Khoros Alumni (Retired)

    Keep in mind that on topic level it gets a bit more complicated as there are multiple permissions and the topic level "Block new replies" can come into effect. Also you don't necessarily need to use the API thanks to the coreNode context object's 'permissions.hasPermission("permission_identifier")' method.

     

    1. To check if new replies are blocked (== "Topic closed"):
      <#assign message = rest("/messages/id/${env.context.message.uniqueId}").message />
      <#assign readOnly = message.read_only?boolean />
    2. To check if user is allowed to create messages:
      <#if coreNode.permissions.hasPermission("create_message") >
    3. To check if user is allowed to create new topics (likely to be used on board and category):
      <#if coreNode.permissions.hasPermission("create_thread") >
    • fuenteso's avatar
      fuenteso
      Leader

      Thanks ClaudiusH, I tried with the permissions but it looks like it checks if the user has permission to create a post on a board, it ignores if the board is ready only :(

       

      I ended up using a combination of both answers. First checking if the board is read only, and then checking if the user has access to post to read only boards. I wanted to hide a custom post button from read only boards for users who didn't have the permission.

       

      Thank you both!

       

      • ClaudiusH's avatar
        ClaudiusH
        Khoros Alumni (Retired)

        You are completely right: You have to use a combination of both node permissions and topic status if you want to capture all variations.