SVN Releases > Requests

online users

<< < (2/2)

SKaero:
The url format is:

--- Code: ---./?_task=<task>&_action=<action>

--- End code ---

So for example:

--- Code: ---./?_task=mail&_action=get_all_user_list

--- End code ---

bikram:
try "node.js" for library for showing online users & chat options.

skygge:
For v0.8.4 i did it like this:

program/include/rcube_user.php
modify function __construct:
####
    function __construct($id = null, $sql_arr = null)
    {
        $this->rc = rcmail::get_instance();
        $this->db = $this->rc->get_dbh();

        if ($id && !$sql_arr) {
            $sql_result = $this->db->query(
                "SELECT * FROM ".get_table_name('users')." WHERE user_id = ?", $id);
            $sql_arr = $this->db->fetch_assoc($sql_result);
            $sql_loggedusers_result = $this->db->query(
                "SELECT count(sess_id) as logged from session");
            $sql_loggedusers_arr = $this->db->fetch_assoc($sql_loggedusers_result);
        }
        if (!empty($sql_arr)) {
            $this->ID       = $sql_arr['user_id'];
            $this->data     = $sql_arr;
            $this->language = $sql_arr['language'];
            $this->loggedusers = $sql_loggedusers_arr['logged'];
        }
    }

####

program/include/rcube_template.php, add function current_users

    public function current_users()
    {
    $currentusers = $this->app->user->get_loggedusers();
    return 'Users online: ' . $currentusers;
    }


and modify function __construct (add  common UI object):

$this->add_handlers(array(
            'loginform'       => array($this, 'login_form'),
            'preloader'       => array($this, 'preloader'),
            'username'        => array($this, 'current_username'),
            'message'         => array($this, 'message_container'),
            'charsetselector' => array($this, 'charset_selector'),
            'aboutcontent'    => array($this, 'about_content'),
            'current_users'    => array($this, 'current_users'),
        ));


Then in template skins/larry/includes/header.php  add:

<div class="topleft">
                <roundcube:button name="about" type="link" label="about" class="about-link" onclick="UI.show_about(this);return false" />
                <roundcube:if condition="config:support_url" />
                <a href="<roundcube:var name='config:support_url' />" target="_blank" class="support-link" id="supportlink"><roundcube:label name="support" /></a>
                <roundcube:endif />
                <roundcube:object name="current_users" />
</div>

I know this is lame, but I'm not a programmer and this just works!
Regards!

Navigation

[0] Message Index

[*] Previous page

Go to full version