Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID Sign In with Twitter
Support for Vanilla Forums Cloud product

In this Discussion

Follow Us


[Pockets Addon] Problem: Roles and Page settings broken?

edited February 2011 in Questions
This discussion is related to the Pockets addon.
@Todd

Pockets is a _really_ well designed plugin. Kudos. So I'm thinking that I'm probably just overlooking something here...

I have a pocket in the panel at given index 2. My Vanilla install is version 2.0.11.

Neither the Page settings nor the Roles conditions seem to work. Setting the Page to anything besides (All) makes the pocket disappear from all pages. And setting a role condition doesn't do anything at all: all roles seem to be able to see the pocket.

Any idea of what might be going on?

Comments

  • ToddTodd Chief Product Officer Vanilla Staff
    Hmm. I'll have to look into this.
  • Same behavior over here.
  • Experiencing the same thing as well, any quick workaround we can get at?
  • Anyone have any luck fixing this yet. Seems like a useful plugin otherwise.
  • @Todd Two comments from seven months ago re:looking into this... just wondering if it will ever get unbroken, or if we're out of luck with this essential plugin.
  • ToddTodd Chief Product Officer Vanilla Staff
    File a github issue and I won't forget about it again.
  • edited June 2011
    @Todd I don't want to be persnickety, but I haven't the faintest idea how to do that, nor do I see any info here on the actual support forums about it, other than a link on the addon page saying it is maintained on github.

    Are we to assume that the current version of this plugin (and others? which others? all the ones here?) is to be found on github, not on the Vanilla addons list here?

    Is there anywhere on this site where that is made clear? I can't find any reference to it in the doco.

    Also, I see at github that you (assuming you are tburry) made some change to class.pockets.plugin.php on May 7, 2011, but the addon itself here shows a last update date of November 2010. I'm not sure what we're meant to do with that -- is the November 2010 version here an old version, and we need to download the github version, or just the newer files from github, or...

    Again, I'm not trying to be difficult here, but the process is very unclear, at least to me.

    Further, why are some plugins on github? Are those ones written/maintained by the Vanilla devs? If so, same question as before: should we expect that the most current working versions can be found here in the actual Vanilla addons directory, given they are in some sense 'core' plugins maintained by the devs? Are versions at github not ready for primetime in some sense?

    I've been champing at the bit to get my busy community site from 1.1.10 to the 2.x branch for over a year now, but functionality (mostly achieved through some key plugins like nuggets/pockets) isn't quite there yet. I'd be happy to get involved in fixing code and submitting bugs if it will help things along, but I am honestly unclear on what the process is here (and I admit I am a bit bewildered by github).
  • edited June 2011
    Also, holy crap, I see there's a Whispers plugin at github! Sweet! This is one of the major core things I've been hoping for in 2.x (to prevent a user revolt at my site) -- has it been mentioned anywhere else?

    Is it ready for primetime? I'm going to go give it a go on my testbed...

    Edit: Bummer. I can't figure out how to make it do the Magic.
  • PS Using the version from github, and I can now save Pockets as intended -- active status is preserved.

    So hooray, and I guess I'll just try to remember to always check there too, if (an Approved?) plugin is not working...
  • lucluc ✭✭
    @stavthewonderchicken: For whispers, you will need to get 2.0.18 IIRC.
    That's why not of this was announced yet.
  • Just updated to 2.0.18b2, and tried enabling. I'm seeing the Whisper tickbox and am going to have a bash at testing it.

    After all this time I'm finally getting a little enthusiastic about moving off of 1.x...
  • hey there, i have updated the source code to 1.0.3b and i am still not able to limit a pocket to a specific role...

    i see that Stav says it is working...am i missing something here? is this fixed or not?

    thank you for your help.
  • hbfhbf wiki guy? MVP
    im seeing this behavior on my site. i have pockets set to only view for the guest role, but it shows for everyone.
  • Same problem, I believed, that 1.0.3b from Github will fix this problem, but didn't see any changes, still can't limit pocket to a specific role.

  • @Todd Hi, I'm just finishing customizing my new Vanilla based forum, and only thing that I need is to put some Js content on page, that should be displayed only for registered users. Pockets addon would be best option to do this, but in latest vanilla It doesen't work like it should, and as i see not only I have this problem - content is showed for all users, even if I restrict this in addon settings.

    I know, that You are probably very busy, and this addon isn't on Your top position to do, but I just only want to know what are the chances (in %) that You will fix this addon in the next ~30 days, beacause I don't know is it worth it to wait or better start create own simple addon to put this content in other way.

  • ToddTodd Chief Product Officer Vanilla Staff

    @stavthewonderchicken, all of our source code is maintained at github and so it will often be ahead of the stuff in the addons section.

    I will try to clear off the pockets issues this week. I don't think they are that difficult to fix.

    sahotataranMjDD
  • Same question as @hbf

  • @Todd -- Got a chance to look at this? Still stumped. Issue raised on Github in duplicate.

  • @leafmonster : Did you try the latest version of 'Pockets' available on GitHub? I am using it on my forum, and it's working like a charm.

  • @badlearner - Can You limit pocket display to a specific user group ? I was trying this latest version from GitHub, and I still didn't see any change.

  • @vaniller : Absolutely. Let me show you.

  • edited March 2012

    @vaniller : I'm on Vanilla 2.1a, and Pockets doesn't seem to be working, like you said. But when I tested it on Vanilla 2.0.18.3, it actually worked. So, I don't understand what could be wrong.

    This site (belongs to @aery ) http://forum.gtricks.com/ uses pockets, and it's working.

  • @badlearner @vaniller Thanks for the responses.

    I've upgraded to Vanilla 2.0.18.4 and Pockets 1.0.4 from Github... And the roles conditions still don't seem to do anything. Also the new mobile-only/no-mobile conditions don't seem to work either, in fact, the boxes don't stay checked when I save the pocket.

    What am I missing here?

  • edited March 2012

    I'm not much of a coder so I could be totally wrong, but attempting to read the code, it certainly looks to me like the Conditions feature isn't implemented. Specificially, the CanRender() function of the Pocket class which returns whether the pocket should show up or not, has no clause to to test for role or permission conditions. Nor can I find this tested for anywhere else in the Pockets codebase...

    I'd guess it's just one or two lines of code to add this... Anyone?

  • Same problem. Pockets show to all roles :(

  • So there is still no solution for this?

  • I hacked a fix for Pockets on the current stable release version of Vanilla 2.0.18.8 based on the downloadable version of the Pockets plugin (v1.0.1b) from Add-ons.

    The Github version requires the development version of Vanilla which I am not using (plus the latest code appears to simply comment out the Conditions section) - and I am way too new to the Vanilla code-base to start pushing updates to Github! ;-)

    This hack only considers Roles because I did not need to worry about Permissions - my (client's) use case is quite simple - I just want to show a payment form to users who are "Suspended" (which is a custom Role in my forum).

    I am attaching the updated zip file for the Pockets plugin with my mods.

    How it works: Essentially, what it does is add a "Conditions" var to the Pocket class which is populated on Load:

    public function Load($Data) { ... if ($Data['Condition']) $this->Condition = Gdn_Condition::FromString($Data['Condition']); }

    Then, in the main class' ProcessPockets function, the current user's role is extracted from GdnSession and added to Data which is passed to "CanRender".

    ... // Add current user roles to Data if (Gdn::Session()->IsValid()) { $userModel = new UserModel(); $roleData = $userModel->GetRoles( Gdn::Session()->User->UserID ); $roles=''; if( $roleData !== FALSE && $roleData->NumRows(DATASET_TYPE_ARRAY) > 0 ) { $roles = ConsolidateArrayValuesByKey( $roleData->Result(), 'Name' );

      $roleModel = new RoleModel();
      $allRoles = $roleModel->getArray();
    
      $idx = 0;
      $newRoles = array();
      $userRoles = array();
      foreach ($allRoles as $role) {
        if (in_array($role, $roles)) $userRoles[] = $idx;
        $newRoles[$idx++] = $role;
      }
    
      $Data['Roles'] = implode($userRoles, ',');
        }
      }
      ...
    

    CanRender compares the Pocket's condition with the user's role to determine if any of the user's roles match any of the condition roles. If they don't match, CanRender returns FALSE. public function CanRender($Data) { ... // Check to see if user role matches if ($this->Condition) { $foundMatch = FALSE; $userRole = explode(',',GetValue('Roles', $Data)); foreach($userRole as $myRole) { foreach($this->Condition as $condition) { if (('role' == $condition[0]) && ($condition[1] == $myRole)) { $foundMatch = TRUE; break; }
    } if ($foundMatch) break; } if (!$foundMatch) return FALSE; } ...

    Hope it saves you some time!

    Pockets.zip 57.9K
    hgtonight
Sign In or Register to comment.