Announcement

Collapse
No announcement yet.

Hide code content from guests

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Hide code content from guests

    Hey, I was using the vb 5.6.0 release thread, but I guess it's better to use a own thread for the sake of clean diskussions


    I was using this template modification to hide [code] content from guests:
    https://www.vbulletin.org/forum/showthread.php?p=2602245


    unfortunately it is suddenly not working anymore with 5.6.0 (didnt do any changes, just the update).
    Can anybody help me to modify the code in a way, so that it is working again?


    I was using this code before:


    Code:
    <vb:if condition="$vboptions['codemaxlines']">
        {vb:set verticalPadding, 12}
        {vb:set horizScrollbarAllowance, 20}
        {vb:set blockCssHeight, {vb:math {vb:raw blockheight} * {vb:stylevar  bbcode_code_line_height} + {vb:raw verticalPadding} + {vb:raw  horizScrollbarAllowance}}}
    </vb:if>
    <div class="bbcode_container">
        <div class="bbcode_description">{vb:rawphrase code}:</div>
    <vb:if condition="is_member_of($user, 2, 3, 6)">
        <pre class="bbcode_code"<vb:if  condition="$vboptions['codemaxlines']"> style="height:{vb:raw  blockCssHeight};"</vb:if>>{vb:raw code}</pre>
    <vb:else />
        {vb:rawphrase hide_code}
    </vb:if>
    </div>

    The problem seems to be a trouble with the group parts. When I enter the group for guests, it shows the content to everybody (of course). If I enter the groups for registered users, admins and mods, it is hidden from everybody.


    Would appreciate any help!

  • #2
    Unforunately the coder of this is not answering anymore on vbulletin.org

    Comment


    • #3
      I got an interesting answer von vb.org (https://www.vbulletin.org/forum/show....php?p=2602297)



      Originally posted by shka
      I dont know if it is an error or a feature. Add debugvardump (! in test environment)

      Code:
      <vb:if condition="$vboptions['codemaxlines']">
          {vb:set verticalPadding, 12}
          {vb:set horizScrollbarAllowance, 20}
          {vb:set blockCssHeight, {vb:math {vb:raw blockheight} * {vb:stylevar  bbcode_code_line_height} + {vb:raw verticalPadding} + {vb:raw  horizScrollbarAllowance}}}
      </vb:if>
      <div class="bbcode_container">
          <div class="bbcode_description">{vb:rawphrase code}:</div>
      {vb:debugvardump $user}
      <vb:if condition="is_member_of($user, 2, 3, 6)">
          <pre class="bbcode_code"<vb:if  condition="$vboptions['codemaxlines']"> style="height:{vb:raw  blockCssHeight};"</vb:if>>{vb:raw code}</pre>
      <vb:else />
          {vb:rawphrase hide_code}
      </vb:if>
      </div>
      Test in 5.5.3:
      You get the vardump of the current logged in user (and also null info of not logged in) - and only then your bbcode_code makes sense

      Test in fresh 5.6.0 with first post by admin and answer by registered user
      In all situations (admin logged in, reg user logged in, no one logged in) I see in first post "admin-user-object" and in second post "reg-user-object".

      So error in 5.6.0 or you have to use another object.

      Comment


      • #4
        So I guess something has changed in 5.6.0?

        Comment


        • #5
          Something changes in every version. I suspect that passing $user was considered a security risk somewhere in the hundreds of changes made between 5.5.3 and 5.6.0. Probably in 5.5.4 and 5.5.5 when we had a published security exploit and we had to tighten security on the template/module system to fix it.

          Unfortunately, I don't know what object can be passed to handle the permission check that you want at this time. You will most likely need to make an API call in the template to get the data you need in order to check their permissions.
          Translations provided by Google.

          Wayne Luke
          The Rabid Badger - a vBulletin Cloud demonstration site.
          vBulletin 5 API - Full / Mobile
          Vote for your favorite feature requests and the bugs you want to see fixed.

          Comment


          • #6
            I did the Update from 5.5.6 to 5.6.0, so the security fix was before.
            Sorry for the stress, it's just that hiding code is vital for my forum I am willing to give a donation for any solution

            Comment


            • #7
              Finally found out with the help of a User from vbulletin.org (many thanks to shka!) that this is realted to how vbulletin is suddenly caching.

              When I add the code I wrote above and I clear the cache, it works.

              But now it depends which user hits the page first after clearing the cache, because this user sets the rights for all groups.

              So, following procedure:


              Clear Cache
              First hit on page is a Guest: All links are hidden in the forum for all users

              Clear Cache
              First hit on page is a User: All links are visible in the forum for all users


              Somehow funny and even more no idea how to make it work again
              Just sharing the info.

              Comment


              • #8
                It seems like you're over-complicating this. Wouldn't it be easier to just hide all BBCode for all Guests?

                Comment


                • zweeper
                  zweeper commented
                  Editing a comment
                  Is there a standard way to do that in vbulletin 5?

              • #9
                Originally posted by In Omnibus View Post
                It seems like you're over-complicating this. Wouldn't it be easier to just hide all BBCode for all Guests?
                Ahm yes, but how?

                Comment


                • #10
                  Originally posted by zweeper View Post

                  Ahm yes, but how?
                  Have you tried removing the show conditional? It's probably unnecessary. It shows to all User Groups by default so you probably only need the hide conditional.

                  Code:
                  <vb:if condition="is_member_of($user, 1)"> {vb:rawphrase hide_code} </vb:if>
                  I'm not where I can test this which is why I haven't responded sooner

                  Comment


                  • #11
                    Caching should have this conditional built in. That is the entire point of using vBulletin markup. This seems to be an unseen complication because it wouldn't be tested. I suggest creating a bug report for this issue.

                    Ideally, this would be handled by a channel permission but that is a more involved fix.
                    Translations provided by Google.

                    Wayne Luke
                    The Rabid Badger - a vBulletin Cloud demonstration site.
                    vBulletin 5 API - Full / Mobile
                    Vote for your favorite feature requests and the bugs you want to see fixed.

                    Comment


                    • #12
                      Yes, I can confirm it now. Caching is the issue.

                      Comment


                      • #13
                        Request created, please vote if you like it!

                        https://tracker.vbulletin.com/vbulle...sues/VBV-20123

                        Comment


                        • #14
                          Just found out that this is similar to this one: https://tracker.vbulletin.com/vbulle...sues/VBV-15379

                          Comment

                          widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                          Working...
                          X