Getting social group icons on profile page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • unixman
    Senior Member
    • Jun 2001
    • 220
    • 5.2.x

    Getting social group icons on profile page

    Basically, I want to show the group icons for a user's groups on each user's profile page. Tried this, but it isn't returning any results, even though the user is actually a member of a few groups. If I remove the userid option, I get the full list of groups, so I know the API call itself it "working" per se.

    Am I missing the obvious here, or perhaps is there some other option that needs to be set for this API call to work? Thanks in advance!

    Code:
    {vb:set options.perpage, 9999}
    {vb:set options.page, 1}
    {vb:set options.userid, {vb:raw userInfo.userid}}
    {vb:rawdata nodes, socialgroup, getSGInfo, {vb:raw options}, {vb:raw page.routeInfo}}
    {vb:debugvardump nodes}
    Cheers.
    Last edited by unixman; Thu 1 Dec '16, 5:30am.
    Incursus: (latin: clash, collision/attack, raid, foray, invasion)
    We Create Thingz.
  • unixman
    Senior Member
    • Jun 2001
    • 220
    • 5.2.x

    #2
    Well, after doing some digging, it appears the "userid" option is only used to filter by the user who actually created the group, not who is a member of each group. Still digging for a way to do this.
    Incursus: (latin: clash, collision/attack, raid, foray, invasion)
    We Create Thingz.

    Comment

    • unixman
      Senior Member
      • Jun 2001
      • 220
      • 5.2.x

      #3
      I had an epiphany, and thought that the group membership data would be in $userInfo, but I don't see it there. I dug all through the database schema, and can't for the life of me figure out where the social group membership/subscription whatever are stored.
      Incursus: (latin: clash, collision/attack, raid, foray, invasion)
      We Create Thingz.

      Comment

      • unixman
        Senior Member
        • Jun 2001
        • 220
        • 5.2.x

        #4
        Tried this as well, but always returns nothing

        Code:
        {vb:set followList, {vb:data getFollowingParameters, {vb:raw userInfo.userid}}}
        Incursus: (latin: clash, collision/attack, raid, foray, invasion)
        We Create Thingz.

        Comment

        • unixman
          Senior Member
          • Jun 2001
          • 220
          • 5.2.x

          #5
          Okay, I think I found the table where the relationship is stored (groupintopic). Odd name, but that looks like the right table. Now I just need to find the right API call to get the data.
          Incursus: (latin: clash, collision/attack, raid, foray, invasion)
          We Create Thingz.

          Comment

          • unixman
            Senior Member
            • Jun 2001
            • 220
            • 5.2.x

            #6
            Ok, I realized i was using the wrong syntax for vb:data. Finally starting to make some headway!

            Code:
            {vb:data followList, user, getGroupInTopic, {vb:raw userInfo.userid}}
            Incursus: (latin: clash, collision/attack, raid, foray, invasion)
            We Create Thingz.

            Comment

            • unixman
              Senior Member
              • Jun 2001
              • 220
              • 5.2.x

              #7
              Yay! Finally figured out a much easier way to do this. Using the search API: For anyone looking to do something similar:

              Code:
              {vb:rawdata groupList, search, getInitialResults, '{"my_channels":{"type":"group"},"sort":{"title":"ASC"}}'}
              
              <vb:each from="groupList.results" key="index" value="group">
                <a href="{vb:url {vb:raw group.routeid}}"><img src="/filedata/fetch?type=icon&filedataid={vb:raw group.content.filedataid}" title="{vb:raw group.title}" /></a>
              </vb:each>
              Incursus: (latin: clash, collision/attack, raid, foray, invasion)
              We Create Thingz.

              Comment

              • unixman
                Senior Member
                • Jun 2001
                • 220
                • 5.2.x

                #8
                Crap. Never mind, that won't work. That always shows the groups of the current person who is logged in, not the groups of the person's profile page you are viewing. Dammit! lol. Tried to pass in a userid parameter, but that didn't work.
                Incursus: (latin: clash, collision/attack, raid, foray, invasion)
                We Create Thingz.

                Comment

                • In Omnibus
                  Senior Member
                  • Apr 2010
                  • 2310

                  #9
                  This might not be what you had in mind but it seems like making additional usergroups for each social group and then assigning a group avatar to each might be easier.

                  Comment


                  • unixman
                    unixman commented
                    Editing a comment
                    Thanks for the response! Unfortunately, that really won't work for me. We have literally hundreds of social groups. Each member can be in more than one, of course. I dread to see what the permissions page would look like if it had to load permissions for hundreds of usergroups hehe.
                • unixman
                  Senior Member
                  • Jun 2001
                  • 220
                  • 5.2.x

                  #10
                  Well, I've been digging and digging, and it is occurring to me that there really should be a proper API call to fetch the social groups of a user by userid. Perhaps a dev will chime in here. As it stands right now, I can get this far:

                  Code:
                  {vb:rawdata groupNodeIdList, follow, getFollowingParameters, {vb:raw $userInfo['userid']}}
                  
                  <vb:each from="groupNodes" key="index" value="group">
                      {vb:set groupNodeIdList.$group, group.nodeid}
                  </vb:each>
                  
                  {vb:rawdata groupNodes, node, getNodes, {vb:raw groupNodeIdList.member}}
                  And this does actually return the group info, but it doesn't have the filedataid in the result, which makes it impossible to retrieve the group icon for showing on the profile page
                  Incursus: (latin: clash, collision/attack, raid, foray, invasion)
                  We Create Thingz.

                  Comment

                  • Necrophyte
                    Member
                    • Oct 2014
                    • 58
                    • 5.2.x

                    #11
                    Why not write your own? Then just do a DB call and return the results. Example. I wanted to see all the moderators in each forum.
                    So I created this in the api/users.php
                    Code:
                        public function fetchModerators($channelid)
                        {
                            global $vbulletin;
                    
                            $result = $vbulletin->db->query("
                                SELECT moderator.*,
                                user.username, user.usergroupid, user.membergroupids
                                FROM " . TABLE_PREFIX . "moderator AS moderator
                                INNER JOIN " . TABLE_PREFIX . "user AS user USING(userid)
                                WHERE moderator.nodeid = ".$vbulletin->db->escape_string($channelid)."
                            ");
                    
                            while ($moderator = $result->fetch_assoc()){
                                $moderators[] = $moderator['userid'];
                            }
                            return $moderators;
                        }
                    The above returns all the moderator IDs of that forum(Channel)
                    Then in the template call: {vb:data moderators, user, fetchModerators, {vb:raw channelInfo.nodeid}}
                    {vb:raw moderators} will contain all the userids of all the moderators of that forum, and then you can list them out later.
                    You could do the same thing with the social groups, just change the query.

                    Hope that helps.

                    Comment

                    • unixman
                      Senior Member
                      • Jun 2001
                      • 220
                      • 5.2.x

                      #12
                      That's what I'm doing right now, but I hate changing core (especially the API).

                      Incursus: (latin: clash, collision/attack, raid, foray, invasion)
                      We Create Thingz.

                      Comment

                      • Necrophyte
                        Member
                        • Oct 2014
                        • 58
                        • 5.2.x

                        #13
                        What I do is put my name in a comment near the code I've changed.
                        Then when there is an update I can just search my name for all the changes and port them over quick.

                        Comment

                        • glennrocksvb
                          Former vBulletin Developer
                          • Mar 2011
                          • 3955
                          • 5.7.X

                          #14
                          You don't have to modify the core api files. You can create your own frontend controller in /includes/vb5/frontend/controller and call it from the template. Since it is a new file, you don't have to worry about losing it when you upgrade.

                          For example:

                          /includes/vb5/frontend/controller/customsocialgroup.php:
                          PHP Code:
                          <?php
                          class vB5_Frontend_Controller_CustomSocialGroup extends vB5_Frontend_Controller
                          {

                              public function 
                          __construct()
                              {
                                  
                          parent::__construct();
                              }

                              public static function 
                          getGroupInfo()
                              {
                                  global 
                          $vbulletin;
                                  
                          $result =  $vbulletin->db->query("SELECT xxxxxx FROM " TABLE_PREFIX "xxxxxx WHERE xxxxxxx");        
                                  
                          $row mysqli_fetch_array($resultMYSQL_ASSOC);        
                                  return 
                          $row;
                              }

                          }

                          Then in the template:

                          Code:
                          {vb:action groupInfo, CustomSocialGroup, getGroupInfo}
                          {vb:debugvardump groupInfo}
                          If you need to pass a parameter to the function:

                          Code:
                          {vb:action groupInfo, CustomSocialGroup, getGroupInfo, {vb:raw parameter}}
                          {vb:debugvardump groupInfo}
                          Obviously, you have to also modify the getGroupInfo function in the controller to accept parameters.

                          Flag Icon Postbit Insert GIPHY Impersonate User INITIALS AVATAR Better Name Card Quote Selected Text Collapsed PM Post Footer Translate Stop Links in Posts +MORE!

                          Comment

                          • unixman
                            Senior Member
                            • Jun 2001
                            • 220
                            • 5.2.x

                            #15
                            Excellent! I was hoping there was a way to do exactly that. I come from a Drupal background, and this makes things much easier!

                            Cheers.
                            Incursus: (latin: clash, collision/attack, raid, foray, invasion)
                            We Create Thingz.

                            Comment

                            widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                            Working...
                            😀
                            😂
                            🥰
                            😘
                            🤢
                            😎
                            😞
                            😡
                            👍
                            👎