Zikula: A Flexible Open Source Content Management System
home | forum | contact us

Dizkus

Bottom
API for showing a users group
  • Posted: 14.04.2005, 09:52
     
    MACscr
    rank:
    Professional Professional
    registered:
     December 1969
    Status:
    offline
    last visit:
    10.01.08
    Posts:
    1631
    To much code to currently do this, hope its available in .8 and just as easy to show a users group as it is his/her ID
  • Posted: 14.04.2005, 11:47
     
    Simon
    rank:
    Steering Committee Steering Committee
    registered:
     December 2002
    Status:
    offline
    last visit:
    28.11.08
    Posts:
    13417
    Mark's comment here tells you the functionality will be in .8:

    http://forums.postnuke.com/index.php?name=PNphpBB2&file=viewtopic&t=39347

    --
    Regards,
    Simon

    itbegins.co.uk - Zikula Consulting

    Please read the Support Guide
  • Posted: 14.04.2005, 12:55
     
    rank:
    Moderator Moderator
    registered:
     March 2002
    Status:
    offline
    last visit:
    26.08.08
    Posts:
    7720
    In fact I said it's in .760. The groups module is API compliant so exposes a number of module API's for querying and manipulating groups.

    -Mark
  • Posted: 14.04.2005, 18:40
     
    MACscr
    rank:
    Professional Professional
    registered:
     December 1969
    Status:
    offline
    last visit:
    10.01.08
    Posts:
    1631
    Ah, sry i missed that post, thats great. So i should be able to show the users group by just echoing something like this?


    Code

    $usersgroups = pnModAPIFunc('groups', 'user', 'getusergroups', array('uid' => $userid));
    echo $usersgroups;
  • Posted: 14.04.2005, 19:34
     
    Simon
    rank:
    Steering Committee Steering Committee
    registered:
     December 2002
    Status:
    offline
    last visit:
    28.11.08
    Posts:
    13417

    Quote

    In fact I said it's in .760


    oops ;)

    Presumably the function returns an array of group ids rather than group names - so you couldnt echo it out.

    --
    Regards,
    Simon

    itbegins.co.uk - Zikula Consulting

    Please read the Support Guide
  • Posted: 14.04.2005, 19:39
     
    rank:
    Moderator Moderator
    registered:
     March 2002
    Status:
    offline
    last visit:
    26.08.08
    Posts:
    7720
    To output a debug message where the result will be an array use print_r or var_dump.

    -Mark
  • Posted: 14.04.2005, 22:09
     
    MACscr
    rank:
    Professional Professional
    registered:
     December 1969
    Status:
    offline
    last visit:
    10.01.08
    Posts:
    1631
    Would be nice to know how to use it in templates too.

    For example, I would like to be able to show what groups the user is in in the member list, or using advprofile and its templates.

    How would i do it to show their group name instead of just their group ID, without doing an "if" statement, etc.
  • Posted: 14.04.2005, 22:13
     
    Simon
    rank:
    Steering Committee Steering Committee
    registered:
     December 2002
    Status:
    offline
    last visit:
    28.11.08
    Posts:
    13417
    Groups_userapi_get()

    Returns an array of group name, id and member ids - if you want to find the groups of lots of users you might be better off doing it through that API...

    --
    Regards,
    Simon

    itbegins.co.uk - Zikula Consulting

    Please read the Support Guide
  • Posted: 14.04.2005, 22:16
     
    MACscr
    rank:
    Professional Professional
    registered:
     December 1969
    Status:
    offline
    last visit:
    10.01.08
    Posts:
    1631
    what if its just for that specific user. Sry, just trying to get some better examples as thats how I learn best. Partial code doesnt help me to much, and as its looking, it doesnt look like its really that much easier than it was before.
  • Posted: 14.04.2005, 23:18
     
    Lobos
    rank:
    Professional Professional
    registered:
     December 2002
    Status:
    offline
    last visit:
    24.08.08
    Posts:
    1588
    I'm guessing that you would set the $userid variable for this - ie $userid = 10; (put this before the function) you would then display the groups with a and array loop I suppose...put this after the fucntion call: print_r($usersgroups); you will then see output of what the function is returning.

    -Lobos

    --
    -Lobos
    Professional PHP Framework Services: Concept, Development and Deployment
  • Posted: 14.04.2005, 23:25
     
    Chestnut
    rank:
    Steering Committee Steering Committee
    registered:
     August 2002
    Status:
    offline
    last visit:
    03.03.08
    Posts:
    1221
    The advProfile plugin would probably be something like this on a pn0.760 install...

    Code

    <?php

    function advProfile_userapi_usergroups($args)
    {

        extract($args);
        unset($args);

        if (!isset($uid)) {
            return false;
        }

        if (!pnModAPILoad('Groups', 'user')) {
            return false;
        }

        $usergroups = array();
       
        $usergroups = pnModAPIFunc('Groups',
                                   'user',
                                   'getusergroups',
                                   array('uid' => $uid));
                                   
        return $usergroups;

    }

    ?>


    The template, something like this :

    Code

    <!--[section name="usergroups" loop=$usergroups]-->
      <!--[$usergroups[usergroups].name]--><br />
    <!--[/section]-->


    This is done reallllly fast and I don't have time to check it......... I'm REAAAALLLY LATE....

    Cya ! :wink:

    --
    Chestnut !
    Support via Private message won't be answered...
    http://dev.pnconcept.com
    http://www.postnuke-france.org
  • Posted: 15.04.2005, 00:28
     
    MACscr
    rank:
    Professional Professional
    registered:
     December 1969
    Status:
    offline
    last visit:
    10.01.08
    Posts:
    1631
    Thanks Chestnut, thats exactly the type of example i was looking for. I will definately try it out when i get home. Would it be possible to use that same type of logic in any module?
  • Posted: 15.04.2005, 09:46
     
    MACscr
    rank:
    Professional Professional
    registered:
     December 1969
    Status:
    offline
    last visit:
    10.01.08
    Posts:
    1631
    Doh, doesnt work. I added the function to the pnuserapi.php file and then the template code to user_main.tpl, still no luck
  • Posted: 15.04.2005, 13:10
     
    Chestnut
    rank:
    Steering Committee Steering Committee
    registered:
     August 2002
    Status:
    offline
    last visit:
    03.03.08
    Posts:
    1221
    The Plugin way......

    usergroups.php

    advProfile_plugin_usergroups.tpl

    And in the main tpl :

    Code

    <!--[$plugins.usergroups]-->


    Still untested and not much time to test anything until later though...

    --
    Chestnut !
    Support via Private message won't be answered...
    http://dev.pnconcept.com
    http://www.postnuke-france.org
  • Posted: 15.04.2005, 19:09
     
    MACscr
    rank:
    Professional Professional
    registered:
     December 1969
    Status:
    offline
    last visit:
    10.01.08
    Posts:
    1631
    sweet, that one worked. Thanks!

Extensions Moderation

Main Menu

Extensions Database

Documentation

Development

Login

Donate to Zikula