'', 'label' => __('Workspace'), ], [ 'link' => '', 'label' => __('Users connected'), ], ] ); $check_profile = db_get_row('tusuario_perfil', 'id_usuario', $config['id_user'], 'id_up'); if ($check_profile === false && !users_is_admin()) { return ui_print_error_message( __('This user does not have any associated profile'), '', false ); } // Get groups user has permission. $group_um = users_get_groups_UM($config['id_user']); // Is admin or has group permissions all. $groups = implode(',', array_keys($group_um, 1)); // Get user conected last 5 minutes.Show only those on which the user has permission. switch ($config['dbtype']) { case 'mysql': if (users_is_admin()) { $sql = sprintf( 'SELECT tusuario.id_user, tusuario.last_connect FROM tusuario WHERE last_connect > (UNIX_TIMESTAMP(NOW()) - '.SECONDS_5MINUTES.') GROUP BY tusuario.id_user ORDER BY last_connect DESC' ); } else { $sql = sprintf( 'SELECT tusuario.id_user, tusuario.last_connect FROM tusuario INNER JOIN tusuario_perfil ON tusuario_perfil.id_usuario = tusuario.id_user AND tusuario_perfil.id_grupo IN (%s) WHERE last_connect > (UNIX_TIMESTAMP(NOW()) - '.SECONDS_5MINUTES.') GROUP BY tusuario.id_user ORDER BY last_connect DESC', $groups ); } break; case 'postgresql': if (users_is_admin()) { $sql = sprintf( "SELECT tusuario.id_user, tusuario.last_connect FROM tusuario WHERE last_connect > (ceil(date_part('epoch', CURRENT_TIMESTAMP)) - ".SECONDS_5MINUTES.') GROUP BY tusuario.id_user ORDER BY last_connect DESC' ); } else { $sql = sprintf( "SELECT tusuario.id_user, tusuario.last_connect FROM tusuario INNER JOIN tusuario_perfil ON tusuario_perfil.id_usuario = tusuario.id_user AND tusuario_perfil.id_grupo IN (%s) WHERE last_connect > (ceil(date_part('epoch', CURRENT_TIMESTAMP)) - ".SECONDS_5MINUTES.') GROUP BY tusuario.id_user ORDER BY last_connect DESC', $groups ); } break; case 'oracle': if (users_is_admin()) { $sql = sprintf( "SELECT tusuario.id_user, tusuario.last_connect FROM tusuario WHERE last_connect > (ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (".SECONDS_1DAY.')) - '.SECONDS_5MINUTES.') GROUP BY tusuario.id_user ORDER BY last_connect DESC' ); } else { $sql = sprintf( "SELECT tusuario.id_user, tusuario.last_connect FROM tusuario INNER JOIN tusuario_perfil ON tusuario_perfil.id_usuario = tusuario.id_user AND tusuario_perfil.id_grupo IN (%s) WHERE last_connect > (ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (".SECONDS_1DAY.')) - '.SECONDS_5MINUTES.') GROUP BY tusuario.id_user ORDER BY last_connect DESC', $groups ); } break; default: // Nothing to do. break; } $rows = db_get_all_rows_sql($sql); if (empty($rows)) { $rows = []; echo "