Author Topic: online users  (Read 18497 times)

Offline mortezaipo

  • Newbie
  • *
  • Posts: 7
online users
« 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.

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,876
    • SKaero - Custom Roundcube development
Re: online users
« Reply #1 on: February 12, 2013, 06:42:39 PM »
I don't currently know of any RoundCube plugin that does that.

Offline mortezaipo

  • Newbie
  • *
  • Posts: 7
Re: online users
« Reply #2 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.

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,876
    • SKaero - Custom Roundcube development
Re: online users
« Reply #3 on: February 13, 2013, 02:56:23 AM »
I'm not sure what you mean, you can read $_GET and $_POST in plugins.

Offline mortezaipo

  • Newbie
  • *
  • Posts: 7
Re: online users
« Reply #4 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){ ??

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,876
    • SKaero - Custom Roundcube development
Re: online users
« Reply #5 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

Offline bikram

  • Newbie
  • *
  • Posts: 5
Re: online users
« Reply #6 on: April 15, 2014, 03:44:22 AM »
try "node.js" for library for showing online users & chat options.

Offline skygge

  • Newbie
  • *
  • Posts: 6
Re: online users
« Reply #7 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!
« Last Edit: December 10, 2014, 11:37:59 AM by skygge »