collapse

* User Info

 
 
Welcome, Guest. Please login or register.
Did you miss your activation email?

* Who's Online

  • Dot Guests: 78
  • Dot Hidden: 0
  • Dot Users: 1
  • Dot Users Online:

* Shoutbox

Refresh History
  • Shoutbox is not for support!
  • AngelinaBelle: For Documentation navigation, I really like to use the "<<" icon to turn that menu into a "navigation left panel", because I can read it better that way.
    April 21, 2014, 04:12:13 PM
  • oNLy1: Nakroma, please use the forum for support - ask all the questions (dumb or not) they will get answered
    April 18, 2014, 08:03:49 PM
  • Nakroma: i know this is just another question but im too dumb for it, where can I actualy get into the GENERAL SETTINGS page? im dumb sorry ;-;
    April 18, 2014, 04:27:39 PM
  • Nakroma: ahh okey, i get it. thanks
    April 18, 2014, 04:16:18 PM
  • [SiNaN]: Please don't get me wrong; I didn't mean that. You need to use the navigation menu right above the yellow Documentation bar you describe to navigate through different sections of documentation.
    April 18, 2014, 04:12:37 PM
  • Nakroma: okey I am dumb, could someone point out where at the top of the site it is? with a screenshot or something? if you mean the yellow Documention bar, thats not clickable for  me :|
    April 18, 2014, 03:57:34 PM
  • [SiNaN]: I wouldn't say it's hidden, lol. And it's extensive enough, thanks to Angelina.
    April 18, 2014, 02:28:55 PM
  • oNLy1: Documentation [link] (hidden at top of site)
    April 18, 2014, 12:48:01 PM
  • Nakroma: am I dumb or is there actually no tutorial? [link]
    April 18, 2014, 08:29:41 AM
  • AngelinaBelle: Welcome Gusto Prod.  Please visit [link] for info on creating an SMF forum
    April 17, 2014, 12:04:00 PM
  • GUSTO PROD: hi all give me creat new forum free
    April 16, 2014, 12:21:54 PM
  • AngelinaBelle: Hello w1ck3d! Welcome to Simple Portal. Unfortunately, there are not Russian speakers here very often.  Aplogies
    April 14, 2014, 07:49:26 AM
  • w1ck3d: тест
    April 14, 2014, 02:50:12 AM
  • Underdog: How to use Simple Portal for SMF: [link]
    April 02, 2014, 07:52:45 PM
  • Underdog: Thariq, please post questions in the forum. thank you.
    April 02, 2014, 07:51:40 PM
  • Thariq: how to create portal/site
    April 02, 2014, 06:30:42 AM
  • Ali çelen: forum nasıl oluştırıcam
    March 30, 2014, 10:59:08 PM
  • Ali çelen: sa
    March 30, 2014, 10:58:54 PM
  • AngelinaBelle: processor -- I think your customization will probably be just fine.
    February 14, 2014, 07:18:41 PM
  • AngelinaBelle: noumankhan: Welcome to SimplePortal.  Please read the documentation above. If you have questions about how to make a forum, please seek help at [link]
    February 14, 2014, 07:16:45 PM

* Team Blog

* Recent Posts

Re: SimplePortal article by Shayco
[Today at 12:40:04 PM]


Re: add font to type shoutbox by AngelinaBelle
[Today at 12:22:02 PM]


Re: Aeva Media Block by AngelinaBelle
[Today at 12:10:39 PM]


Re: SimplePortal article by andy
[Today at 11:14:23 AM]


Re: SimplePortal article by Shayco
[Today at 07:27:22 AM]

Join us on IRC! Come on in to #simpleportal on the irc.villageirc.net server.

Author Topic: Block Help - Second Staff Block  (Read 1214 times)

0 Members and 1 Guest are viewing this topic.

Offline Kapwn

  • Newbie
  • Posts: 4
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Block Help - Second Staff Block
« on: February 01, 2013, 08:42:38 PM »
Hello, I'm trying to make a second staff block that is separate from the original and will show other member groups. So far I've added other groups to the block by adding a permission, however the administrator group is still on the list because it has the permission as well, which is the problem. I'm hoping someone can remove administrators from the block while still showing membergroups with the permission.

Code: [Select]
        global $smcFunc, $sourcedir, $scripturl, $modSettings, $color_profile;

        $block_parameters = array(
                'lmod' => 'check',
        );

        if ($return_parameters)
                return $block_parameters;

        require_once($sourcedir . '/Subs-Members.php');

        if (empty($parameters['lmod']))
        {
                $request = $smcFunc['db_query']('', '
                        SELECT id_member
                        FROM {db_prefix}moderators AS mods',
                        array(
                        )
                );
                $local_mods = array();
                while ($row = $smcFunc['db_fetch_assoc']($request))
                        $local_mods[$row['id_member']] = $row['id_member'];
                $smcFunc['db_free_result']($request);

                if (count($local_mods) > 10)
                        $local_mods = array();
        }
        else
                $local_mods = array();

        $global_mods = membersAllowedTo('spstaff_perm');

        $all_staff = array_merge($local_mods, $global_mods);
        $all_staff = array_unique($all_staff);

        $request = $smcFunc['db_query']('', '
                SELECT
                                m.id_member, m.real_name, m.avatar, mg.group_name,
                                a.id_attach, a.attachment_type, a.filename
                FROM {db_prefix}members AS m
                                LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = m.id_member)
                                LEFT JOIN {db_prefix}membergroups AS mg ON (mg.id_group = CASE WHEN m.id_group = {int:reg_group_id} THEN m.id_post_group ELSE m.id_group END)
                WHERE m.id_member IN ({array_int:staff_list})',
                array(
                        'staff_list' => $all_staff,
                        'reg_group_id' => 0,
                )
        );
        $staff_list = array();
        $colorids = array();
        while ($row = $smcFunc['db_fetch_assoc']($request))
        {
                $colorids[$row['id_member']] = $row['id_member'];

                if ($modSettings['avatar_action_too_large'] == 'option_html_resize' || $modSettings['avatar_action_too_large'] == 'option_js_resize')
                {
                        $avatar_width = !empty($modSettings['avatar_max_width_external']) ? ' width="' . $modSettings['avatar_max_width_external'] . '"' : '';
                        $avatar_height = !empty($modSettings['avatar_max_height_external']) ? ' height="' . $modSettings['avatar_max_height_external'] . '"' : '';
                }
                else
                {
                        $avatar_width = '';
                        $avatar_height = '';
                }


                if (in_array($row['id_member'], $global_mods))
                        $row['type'] = 2;
                else
                        $row['type'] = 3;


                $staff_list[$row['type'] . '-' . $row['id_member']] = array(
                        'id' => $row['id_member'],
                        'name' => $row['real_name'],
                        'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>',
                        'group' => $row['group_name'],
                        'type' => $row['type'],
                        'avatar' => array(
                                'name' => $row['avatar'],
                                'image' => $row['avatar'] == '' ? ($row['id_attach'] > 0 ? '<img src="' . (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) . '" alt="" class="avatar" border="0" />' : '') : (stristr($row['avatar'], 'http://') ? '<img src="' . $row['avatar'] . '"' . $avatar_width . $avatar_height . ' alt="" class="avatar" border="0" />' : '<img src="' . $modSettings['avatar_url'] . '/' . htmlspecialchars($row['avatar']) . '" alt="" class="avatar" border="0" />'),
                                'href' => $row['avatar'] == '' ? ($row['id_attach'] > 0 ? (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) : '') : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar']),
                                'url' => $row['avatar'] == '' ? '' : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar'])
                        ),
                );
        }
        $smcFunc['db_free_result']($request);

        ksort($staff_list);
        $staff_count = count($staff_list);
        $count = 0;
        $icons = array(1 => 'admin', 'gmod', 'lmod');

        if (!empty($colorids) && sp_loadColors($colorids) !== false)
        {
                foreach ($staff_list as $k => $p)
                {
                        if (!empty($color_profile[$p['id']]['link']))
                                $staff_list[$k]['link'] = $color_profile[$p['id']]['link'];
                }
        }

        echo '
                                                                <table class="sp_fullwidth">';

        foreach ($staff_list as $staff)
                echo '
                                                                        <tr>
                                                                                <td class="sp_staff sp_center">', !empty($staff['avatar']['href']) ? '
                                                                                        <a href="' . $scripturl . '?action=profile;u=' . $staff['id'] . '"><img src="' . $staff['avatar']['href'] . '" alt="' . $staff['name'] . '" width="40" /></a>' : '', '
                                                                                </td>
                                                                                <td class="sp_staff_info', $staff_count != ++$count ? ' sp_staff_divider' : '', '">
                                                                                        ', sp_embed_image($icons[$staff['type']]), ' ', $staff['link'], '<br />
                                                                                        ', $staff['group'], '
                                                                                </td>
                                                                        </tr>';

        echo '
                                                                </table>';

Thanks.

Offline Wright

  • Hero Member
  • *****
  • Posts: 2045
  • Gender: Male
  • $("li.blurb").hide();
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: Block Help - Second Staff Block
« Reply #1 on: February 01, 2013, 09:17:28 PM »
In your code, can you find this:

Code: [Select]
$all_staff = array_unique($all_staff);
Then put this after it:

Code: [Select]
if ($context['user']['is_admin'])
{
    echo '<pre>';
    print_r($all_staff);
    echo '</pre>';
}

And then post what it shows?
Previously known as Leekoberries

Imagination rules the world.

Offline Kapwn

  • Newbie
  • Posts: 4
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: Block Help - Second Staff Block
« Reply #2 on: February 01, 2013, 09:33:30 PM »
Sorry, I'm new to this. Where is the echo that I should be posting? Also, I should have noted in the original topic that I'm doing this with a custom php block.

And is this how it's suppose to be added?
Code: [Select]
        $all_staff = array_unique($all_staff);
        if ($context['user']['is_admin'])
{
    echo '<pre>';
    print_r($all_staff);
    echo '</pre>';
}

Offline Wright

  • Hero Member
  • *****
  • Posts: 2045
  • Gender: Male
  • $("li.blurb").hide();
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: Block Help - Second Staff Block
« Reply #3 on: February 01, 2013, 09:40:06 PM »
It should appear in the block, if not look in the HTML source of the page.

Yes, the edit looks fine.
Previously known as Leekoberries

Imagination rules the world.

Offline Kapwn

  • Newbie
  • Posts: 4
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: Block Help - Second Staff Block
« Reply #4 on: February 01, 2013, 09:56:26 PM »
Sorry, I still do not know what I am looking for.

Offline Wright

  • Hero Member
  • *****
  • Posts: 2045
  • Gender: Male
  • $("li.blurb").hide();
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: Block Help - Second Staff Block
« Reply #5 on: February 01, 2013, 10:14:22 PM »
Create a new PHP block, as you are, and post the code with the edit I provided.

You should be presented with a large display of information that looks like

Array (
  [0] => stuff
  [1] => other stuff
)

This will help me identify what is being filled in that array at that given moment, letting me manipulate it afterwards to disclude the admin group.
Previously known as Leekoberries

Imagination rules the world.

Offline Kapwn

  • Newbie
  • Posts: 4
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: Block Help - Second Staff Block
« Reply #6 on: February 01, 2013, 10:31:36 PM »
Nothing appears on the block and I can't find anything in the HTML source page that looks like that.

Offline Underdog

  • Support
  • *
  • Posts: 721
  • Gender: Male
  • On Hiatus
    • Underdog-01 GitHub Repositories
  • SMF Version: 2.0.7
  • SP Version: 2.3.5
Re: Block Help - Second Staff Block
« Reply #7 on: February 02, 2013, 01:40:38 PM »

Kapwn,
  Imo your code needs a revamp but to do what you request requires just one simple bit of mysql logic to add. Try this please:
Code: [Select]
global $smcFunc, $sourcedir, $scripturl, $modSettings, $color_profile;

$block_parameters = array('lmod' => 'check');
if ($return_parameters)
return $block_parameters;

require_once($sourcedir . '/Subs-Members.php');

if (empty($parameters['lmod']))
{
$request = $smcFunc['db_query']('', 'SELECT id_member FROM {db_prefix}moderators AS mods');
$local_mods = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
$local_mods[$row['id_member']] = $row['id_member'];

$smcFunc['db_free_result']($request);

if (count($local_mods) > 10)
$local_mods = array();
}
else
$local_mods = array();

$global_mods = membersAllowedTo('spstaff_perm');
$all_staff = array_unique(array_merge($local_mods, $global_mods));
$request = $smcFunc['db_query']('', 'SELECT m.id_member, m.real_name, m.avatar, mg.group_name, a.id_attach, a.attachment_type, a.filename
FROM {db_prefix}members AS m
LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = m.id_member)
LEFT JOIN {db_prefix}membergroups AS mg ON (mg.id_group = CASE WHEN m.id_group = {int:reg_group_id}
THEN m.id_post_group ELSE m.id_group END)
WHERE m.id_member IN ({array_int:staff_list})
AND mg.id_group != 1', array('staff_list' => $all_staff, 'reg_group_id' => 0)
    );
$staff_list = array();
$colorids = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
$colorids[$row['id_member']] = $row['id_member'];

if ($modSettings['avatar_action_too_large'] == 'option_html_resize' || $modSettings['avatar_action_too_large'] == 'option_js_resize')
{
$avatar_width = !empty($modSettings['avatar_max_width_external']) ? ' width="' . $modSettings['avatar_max_width_external'] . '"' : '';
$avatar_height = !empty($modSettings['avatar_max_height_external']) ? ' height="' . $modSettings['avatar_max_height_external'] . '"' : '';
}
else
{
$avatar_width = false;
$avatar_height = false;
}

if (in_array($row['id_member'], $global_mods))
$row['type'] = 2;
else
$row['type'] = 3;

$staff_list[$row['type'] . '-' . $row['id_member']] = array(
'id' => $row['id_member'],
                        'name' => $row['real_name'],
                        'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>',
'group' => $row['group_name'],
'type' => $row['type'],
'avatar' => array(
'name' => $row['avatar'],
'image' => $row['avatar'] == '' ? ($row['id_attach'] > 0 ? '<img src="' . (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) . '" alt="" class="avatar" border="0" />' : '') : (stristr($row['avatar'], 'http://') ? '<img src="' . $row['avatar'] . '"' . $avatar_width . $avatar_height . ' alt="" class="avatar" border="0" />' : '<img src="' . $modSettings['avatar_url'] . '/' . htmlspecialchars($row['avatar']) . '" alt="" class="avatar" border="0" />'),
'href' => $row['avatar'] == '' ? ($row['id_attach'] > 0 ? (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) : '') : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar']),
'url' => $row['avatar'] == '' ? '' : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar']))
                );
}

$smcFunc['db_free_result']($request);

ksort($staff_list);
$staff_count = count($staff_list);
$count = 0;
$icons = array(1 => 'admin', 'gmod', 'lmod');

if (!empty($colorids) && sp_loadColors($colorids) !== false)
{
foreach ($staff_list as $k => $p)
{
if (!empty($color_profile[$p['id']]['link']))
$staff_list[$k]['link'] = $color_profile[$p['id']]['link'];
}
}

echo '
<table class="sp_fullwidth">';

foreach ($staff_list as $staff)
echo '
<tr>
<td class="sp_staff sp_center">', !empty($staff['avatar']['href']) ? '
        <a href="' . $scripturl . '?action=profile;u=' . $staff['id'] . '">
<img src="' . $staff['avatar']['href'] . '" alt="' . $staff['name'] . '" width="40" /></a>' : '', '
</td>
<td class="sp_staff_info', $staff_count != ++$count ? ' sp_staff_divider' : '', '">
', sp_embed_image($icons[$staff['type']]), ' ', $staff['link'], '<br />
', $staff['group'], '
</td>
</tr>';

echo '
</table>';