View Issue Details

IDProjectCategoryView StatusLast Update
0011682mantisbtotherpublic2010-09-03 09:38
Reporteruso Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status confirmedResolutionopen 
Product Version1.2.0 
Summary0011682: user_get_logged_in_user_ids always returns only one user
Description

user_get_logged_in_user_ids always returns only one user.

Two errors in one line, error 1 - a typo, error 2 - wrong parameter:
$result = db_query_bound( $query, array( $c_last_timestamp_threshold ), 1 );

should be:
$result = db_query_bound( $query, array( $t_last_timestamp_threshold ) );

Steps To Reproduce

Write something that uses user_get_logged_in_user_ids.

Here is a minimalistic plugin of mine:
<?php

[...]

require_once( 'core.php' );
$t_core_path = config_get( 'core_path' );
require_once( config_get( 'class_path' ) . 'MantisPlugin.class.php' );

class onlineUsersPlugin extends MantisPlugin
{
function register() {
$this->name = 'onlineUsers';
$this->description = 'Shows a list of online users at the bottom of the page.';

    $this->version      = '0.0.1';
    $this->requires     = array(
        'MantisCore' => '1.2.0'
    );

    $this->author       = 'Udo Sommer';
    $this->contact      = '';
    $this->url          = '';
}

function hooks() {
    $hooks = array(
            'EVENT_LAYOUT_CONTENT_END' => 'onlineUsers_injection'
            );
    return $hooks;
}

function onlineUsers_injection() 
{   
    $t_userids = user_get_logged_in_user_ids(5);
    echo <<<EOF



<hr size="1" />
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr valign="top">
<td>
Online:
</td>
</tr>
<tr valign="top">
<td>
<div align="left">
EOF;
foreach($t_userids as $t_userid)
{
echo '<a href="manage_user_edit_page.php?user_id=' . $t_userid . '">';
echo user_get_name( $t_userid );
echo '</a>';
if( $t_userid != $t_userids[count($t_userids)-1] )
{
echo ', ';
};
};
echo <<<EOF
</div>
</td>
</tr>
</table>
EOF;
}
}

Additional Information

Solution: patch user_api.php (See attached patch file)

TagsNo tags attached.
Attached Files
user_api.patch (844 bytes)   
--- core/user_api.php	Fri Mar 19 10:09:34 2010
+++ core/user_api.php	Fri Mar 19 10:09:35 2010
@@ -426,18 +426,19 @@
 	# Generate timestamp
 	$t_last_timestamp_threshold = mktime( date( 'H' ), date( 'i' ) - 1 * $t_session_duration_in_minutes, date( 's' ), date( 'm' ), date( 'd' ), date( 'Y' ) );
 	$t_user_table = db_get_table( 'mantis_user_table' );
-
+	
 	# Execute query
 	$query = 'SELECT id FROM ' . $t_user_table . ' WHERE last_visit > ' . db_param();
 	
-	$result = db_query_bound( $query, array( $c_last_timestamp_threshold ), 1 );
-
+	$result = db_query_bound( $query, array( $t_last_timestamp_threshold ) );
+	
 	# Get the list of connected users
 	$t_users_connected = array();
+
 	while( $row = db_fetch_array( $result ) ) {
 		$t_users_connected[] = $row['id'];
 	}
-
+	
 	return $t_users_connected;
 }
 
user_api.patch (844 bytes)   

Activities