[Elgg 1.8-1.12 & 2.X: Users Online] v1.8.0

Release Notes

  • Initial release.
  • I like the plugin but is there a simple one that will just place a green dot on online members?

  • @Ratime1 I guess you are looking for something like this: http://community.elgg.org/plugins/859908/1.0/online-user-status-elgg-18x. The "Users Online" plugin here has a slightly different purpose though. With the "green dot" you only see if someone is online if you happen to be on a page where this member's avatar is displayed. So, it's difficult to know who exactly is online right now. Therefore, the "Users Online" lists all members who are currently active in one place (without the need to go to the Online Members tab either).

  • @Team Webgalli: well you beat me. :-)

  • @emmanuel: I've just added a screenshot.
     

  • Hi iionly!
    How to make plugin, which will show the users- online separately for each group.

  • To list the group members who are currently online in the sidebar on group pages you could change users_online/views/default/users_online/sidebar.php to

    <?php
    /**
     * Users Online
     *
     * Show users who are currently logged in the sidebar
     * with blue border around users' avatars who are friends of logged in user
     *
     * @package users_online
     * @author iionly
     * @copyright iionly 2014
     * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
     * @website https://github.com/iionly
     * @email iionly@gmx.de
     */

    // limit number of users to be displayed
    $limit = elgg_get_plugin_setting('user_listing_limit', 'users_online');
    if (!$limit) {
        $limit = 20;
    }

    // Get the page owner entity
    $page_owner = elgg_get_page_owner_entity();

    if (elgg_instanceof($page_owner, 'group')) {

        $db_prefix = elgg_get_config('dbprefix');
        $time = time() - 300;
        $users_online = elgg_get_entities_from_relationship(array(
            'type' => 'user',
            'relationship' => 'member',
            'relationship_guid' => $page_owner->getGUID(),
            'inverse_relationship' => true,
            'limit' => $limit,
            'joins' => array("join {$db_prefix}users_entity u on e.guid = u.guid"),
            'wheres' => array("u.last_action >= {$time}"),
            'order_by' => "u.last_action desc",
        ));
        $title = elgg_echo('Group members online');
    } else {
        // active users within the last 5 minutes
        $users_online = find_active_users(300, $limit);

        $title = elgg_echo('users_online:online');
    }

    if ($users_online) {
        foreach($users_online as $user) {
            $spacer_url = elgg_get_site_url() . '_graphics/spacer.gif';
            $name = htmlspecialchars($user->name, ENT_QUOTES, 'UTF-8', false);
            $username = $user->username;
            $icon_url = elgg_format_url($user->getIconURL('tiny'));
            $icon = elgg_view('output/img', array(
                'src' => $spacer_url,
                'alt' => $name,
                'title' => $name,
                'class' => '',
                'style' => "background: url($icon_url) no-repeat;",
            ));
            if ($user->isFriend()) {
                $class = "usersonlinefriendicon";
            } else {
                $class = "usersonlineicon";
            }

            $body .= "<div class='elgg-avatar elgg-avatar-tiny'>";
            $body .= elgg_view('output/url', array(
                'href' => $user->getURL(),
                'text' => $icon,
                'is_trusted' => true,
                'class' => "elgg-avatar elgg-avatar-tiny $class",
            ));
            $body .= elgg_view_icon('hover-menu');
            $body .= elgg_view_menu('user_hover', array('entity' => $user, 'username' => $username, 'name' => $name));
            $body .= "</div>";
        }
    } else {
        $body = '<p>' . elgg_echo('users_online:noonline') . '</p>';
    }

    echo elgg_view_module('aside', $title, $body);

    For listing them on top of the page users_online.php would have to be modified likewise.

Stats

  • Category: Misc
  • License: GNU General Public License (GPL) version 2
  • Updated: 2019-2-24
  • Downloads: 3499
  • Recommendations: 15

Other Projects

View iionly's plugins