Jump to content

Recommended Posts

Posted

Ok... I'm working on an external script. I need to display my user groups along with their names, which I have seen isdone in places such as the advanced search page. But I don't seem to be able to get this working- whenever I'm trying to output the group names, it's returning what looks like MD5 hashes which change on each page load. For example:

6efe1e7a1c78652b76c5ae3be94f2441
c3ff10a9a6cfec708bc6abbcce6cba94
9ae79d66153d33e93498247b0e55ea90

OR:

2d893a957ef41a6f29eaac3944277d42
a257a8f400105af97e1412a642011c28
1f2b589f7e76427d0f3552ff45c54031

The following code is what I'm using. The result below that is what I'm getting when I print_r() the $group variable.

<?php

require 'init.php';
\IPS\Dispatcher\External::i();

$groups = \IPS\Member\Group::groups(TRUE, FALSE, FALSE);
foreach ($groups as $group)
{
    print_r($group);
    //echo $group->get_name().'<br>';
}
IPS\Member\Group Object
(
    [_data:protected] => Array
        (
            [g_id] => 4
            [g_view_board] => 1
            [g_mem_info] => 1
            [g_use_search] => 1
            [g_edit_profile] => 1
            [g_edit_posts] => 1
            [g_delete_own_posts] => 1
            [g_use_pm] => 1
            [g_append_edit] => 1
            [g_access_offline] => 1
            [g_avoid_q] => 1
            [g_avoid_flood] => 1
            [g_icon] => monthly_2020_06/admin.png.a9e087291c4fe72c681322d378b57531.png
            [g_attach_max] => 500000
            [prefix] => <span style='color:#ff0000'>
            [suffix] => </span>
            [g_max_messages] => -1
            [g_max_mass_pm] => -1
            [g_search_flood] => 0
            [g_edit_cutoff] => 5
            [g_photo_max_vars] => 500:170:170
            [g_dohtml] => 0
            [g_bypass_badwords] => 1
            [g_can_msg_attach] => 1
            [g_attach_per_post] => 50000
            [g_dname_changes] => -1
            [g_dname_date] => 0
            [g_mod_preview] => 0
            [g_rep_max_positive] => 100
            [g_rep_max_negative] => 100
            [g_signature_limits] => 0:::::
            [g_hide_online_list] => 0
            [g_bitoptions] => 26148875
            [g_pm_perday] => -1
            [g_mod_post_unit] => 5
            [g_ppd_limit] => 500
            [g_ppd_unit] => 5
            [g_displayname_unit] => 0
            [g_sig_unit] => 5
            [g_pm_flood_mins] => -1
            [g_max_bgimg_upload] => -1
            [g_post_polls] => 1
            [g_vote_polls] => 1
            [g_topic_rate_setting] => 0
            [g_bitoptions2] => 24
            [g_upload_animated_photos] => 1
            [g_view_displaynamehistory] => 1
            [g_hide_own_posts] => 1
            [g_lock_unlock_own] => 1
            [g_can_report] => 1
            [g_create_clubs] => public,open,closed,private
            [g_club_allowed_nodes] => *
            [g_promote_exclude] => 1
            [g_close_polls] => 0
            [g_club_limit] => 
            [g_pmviewer_protectedgroup] => 0
            [g_pmviewer_viewhidden] => 0
            [g_pmviewer_hideunhide] => 0
            [g_pmviewer_managemembers] => 0
            [g_pmviewer_editposts] => 0
        )

    [_new:protected] => 
    [changed] => Array
        (
        )

    [skipCloneDuplication] => 
)

Does anyone know what's going wrong here? I genuinely have no idea why text is being replaced by these hashes.

Posted
<?php

require 'init.php';
\IPS\Dispatcher\External::i();

$groups = \IPS\Member\Group::groups(TRUE, FALSE, FALSE);
foreach ($groups as $group)
{
    print \IPS\Member::loggedIn()->language()->get( "core_group_{$group->g_id}" ).'<br>';
}

 

Things stored in the language system (such as group names, because they can be translated into each language) will return a hash when you initially access them typically, and then a special routine runs when we go to print out the output that replaces all the hashes in one go. This saves resources with regards to language replacements. You can call the get() method against the language to return the language string right away, however.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...