Roundcube Community Forum

 

online users

Started by mortezaipo, February 12, 2013, 01:01:41 PM

Previous topic - Next topic

mortezaipo

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.

SKaero

I don't currently know of any RoundCube plugin that does that.

mortezaipo

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.

SKaero

I'm not sure what you mean, you can read $_GET and $_POST in plugins.

mortezaipo

I don't know exactly url addressing!

is this correct? $.get('?get_all_user_list',function(back){ ??

SKaero

The url format is:

./?_task=<task>&_action=<action>


So for example:

./?_task=mail&_action=get_all_user_list

bikram

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

skygge

#7
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!