collapse

* User Info

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

* Who's Online

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

* Shoutbox

Refresh History
  • Shoutbox is not for support!
  • Burke Knight: LOL!
    Yesterday at 03:35:00 pm
  • andy: Shoutbox IS for support... moral support  ;D
    Yesterday at 11:18:48 am
  • {OCS}MasterSeal: THANKS AGAIN FOR SP!
    June 22, 2015, 09:47:08 am
  • angeljs: Thanks :)
    June 20, 2015, 08:28:30 am
  • ♦ Ninja ZX-10RR ♦: Unfortunately I am only a Support Apprentice and I don't have access to it, so I cannot approve it. But I will let my Support coach know ;)
    June 19, 2015, 06:30:47 pm
  • angeljs: Yes. that was it. I managed to edit the post, but now can't make any more new ones as it's back in the moderation queue again! :(
    June 19, 2015, 05:06:05 pm
  • ♦ Ninja ZX-10RR ♦: There should be...? Maybe the post is waiting for approval, don't know.
    June 18, 2015, 03:26:04 pm
  • angeljs: Ok, thanks. I just need to know how to edit my posts as I can't find any edit button
    June 18, 2015, 03:13:00 pm
  • ♦ Ninja ZX-10RR ♦: Newbies cannot post in some sections due to antispam I think, especially if they post links. Feel free to open a topic somewhere, a mod will move it :)
    June 18, 2015, 02:53:02 pm
  • angeljs: I know the shoutbox isn't for support, but I can't post in the support forums! Where can I find help with this website?
    June 18, 2015, 10:36:07 am
  • Jazzpa: Thank you Chen!
    June 12, 2015, 08:31:09 am
  • Chen Zhen: Your thread has been approved and a solution posted.
    June 11, 2015, 11:05:45 pm
  • Jazzpa: How long does it take approve a thread/question over here?
    June 11, 2015, 12:25:01 pm
  • {OCS}MasterSeal: AGAIN. I'm here to spam...errr I mean THANK YOU FOR SP!!!
    May 29, 2015, 02:57:41 am
  • ♦ Ninja ZX-10RR ♦: Cool! Glad that you enjoy SimplePortal! :)
    May 02, 2015, 01:12:20 pm
  • iain sherriff: first SP portal installafter trying most of the others...flawless :)
    May 02, 2015, 09:17:00 am
  • streetfire: hi guys!
    April 30, 2015, 06:59:50 pm
  • empire: good luck with your friends and relatives of his father had to get to work
    April 30, 2015, 09:30:53 am
  • Rupurudu!: :)
    April 28, 2015, 08:27:16 pm
  • empire: when I say bob bob it means bob bob
    April 27, 2015, 10:30:46 am

* Recent Posts

Re: Is this possible with SP? by ♦ Ninja ZX-10RR ♦
[Today at 02:06:19 pm]


Is this possible with SP? by 420connect
[Today at 01:49:31 pm]


Re: kayan resimler bloğu by streetfire
[Today at 06:53:53 am]


Re: Shoutbox refreshing error by andy
[Yesterday at 09:04:16 pm]


Re: Shoutbox refreshing error by Burke Knight
[Yesterday at 03:31:38 pm]

NEED HELP? If you're looking for support with Simple Portal, look no further than the Support Board!

Author Topic: Additional details to custom php block (borrowed from Staff block)  (Read 1514 times)

0 Members and 1 Guest are viewing this topic.

Offline Albertm

  • Newbie
  • Posts: 4
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Hi guys,

I copied the code in the sp_staff function in the file listed under Sources/PortalBlocks.php, and used it for a custom php block.  So far, it works the same as just using the Staff block normally, but I want to list an extra detail for each member listed.

I created a custom profile field in SMF, called "aboutUser" detailing a little about the staff members.  Something of interest for others to read if they wish to find out more.  However, I'm not sure how to pull that information or where to put it for it to show up in the custom php block I created.

So far the code I have is just what I pulled from the function sp_staff, without the input parameters:
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('moderate_board', 0);
        $admins = membersAllowedTo('admin_forum');

        $all_staff = array_merge($local_mods, $global_mods, $admins);
        $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'], $admins))
                        $row['type'] = 1;
                elseif (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>';
« Last Edit: October 28, 2012, 02:58:33 pm by Albertm »

Offline Albertm

  • Newbie
  • Posts: 4
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: Additional details to custom php block (borrowed from Staff block)
« Reply #1 on: November 14, 2012, 01:48:20 pm »
Any help would be greatly appreciated.  Please :)