Roundcube Community Forum

SVN Releases => Requests => Topic started by: mortezaipo on February 12, 2013, 01:01:41 PM

Title: online users
Post by: mortezaipo on February 12, 2013, 01:01:41 PM
Hi!
I wrote a simple code that can shows online users.
But I don't know exactly how to add it in roundcube plugins.

has roundcube this plugin that can shows who is online in my contact list?
I didn't find anything.

Thank you.
Title: Re: online users
Post by: SKaero on February 12, 2013, 06:42:39 PM
I don't currently know of any RoundCube plugin that does that.
Title: Re: online users
Post by: mortezaipo on February 13, 2013, 02:49:08 AM
So I made that plugin , but I don't know how can I check and control $_GET & $_POST in plugins.
I used Ajax for sending and receiving data.

Please guide me.

Thanks.
Title: Re: online users
Post by: SKaero on February 13, 2013, 02:56:23 AM
I'm not sure what you mean, you can read $_GET and $_POST in plugins.
Title: Re: online users
Post by: mortezaipo on February 13, 2013, 03:00:52 AM
I don't know exactly url addressing!

is this correct? $.get('?get_all_user_list',function(back){ ??
Title: Re: online users
Post by: SKaero on February 13, 2013, 06:06:23 AM
The url format is:
Code: [Select]
./?_task=<task>&_action=<action>

So for example:
Code: [Select]
./?_task=mail&_action=get_all_user_list
Title: Re: online users
Post by: bikram on April 15, 2014, 03:44:22 AM
try "node.js" for library for showing online users & chat options.
Title: Re: online users
Post by: skygge on December 10, 2014, 10:39:17 AM
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!