× R0.22 and earlier: No Longer Supported

numbers as user names don't work with Joomdle

11 years 9 months ago
Omar Troncoso
Posts: 6
More
Topic Author
numbers as user names don't work with Joomdle #1
Hello,
I installed Joomdle without problems. Then I created some trial users (user1, user2, etc.) and tried the Joomla Moodle integration. It worked fine and I decided to used with for a course I have in Moodle.
So I add the new users in Joomla as registrered users. I used the ID number (8 digits) as user names. But the integration failed because when the users logged in (in the Joomla web page) they were redirected to Moodle (they were supposed to stay in the Joomla page and see the available courses in Moodle).
I couldn't understand why the trial accounts worked fine and the real accounts didn't.
Well, I changed the user names of the real accounts so they were "u"+"ID number" (ei they were a character and a number combination). I was surprised because that chage made the difference and all the students were able to login and the integration worked fine.
I am trying to understand why the integration didn't work when the accounts had ID numbers as user names. Was it because a Moodle restriction to usernames? Can not Joomdle handle numbers as user names?

Please Log in or Create an account to join the conversation.

11 years 9 months ago
Antonio Durán
Posts: 7331
More
numbers as user names don't work with Joomdle #2
Hi. I don't know what the problem is. I don't there is anything in Joomdlde code preventing those usernames.
I will investigate more and report back.

On test: did you try to manually create a normal account like that in Moodle to know if works?

Please Log in or Create an account to join the conversation.

11 years 9 months ago
Omar Troncoso
Posts: 6
More
Topic Author
numbers as user names don't work with Joomdle #3
Hi Antonio,
I created an account manually in Moodle to see if that works and there wer no problem.

Regards,

Omar

Please Log in or Create an account to join the conversation.

11 years 9 months ago
Antonio Durán
Posts: 7331
More
numbers as user names don't work with Joomdle #4
Hi. I have been investigating, and it turns out the problem is with Joomla, and not Moodle.

There is function in Joomla that returns user details. This function can take a number or a string as an argument, and depending on the type it looks for username or ID.
So, what was happening is that your users were searched for as if they were IDs instead of usernames.

I made a small change in Joomdle to avoid this behaviour. It will be included in next release.
In the meantime, you can do the change yourself in current version, as it is very small.

File: plugins/xmlrpc/joomdle.php
At the start, add:

jimport('joomla.user.helper');

Change getUserInfo() and logout() function by this one:

function getUserInfo($username)
{
$id = JUserHelper::getUserId($username);
$user =& JFactory::getUser($id);
$user_info = $user->name;
$user_info = $user->email;

return $user_info;
}

function logout($username)
{
global $mainframe;

$id = JUserHelper::getUserId($username);
$error = $mainframe->logout($id, array ( 'clientid' => array (0)));

return;
}


As you see, what I do is just force a search by username and then pass always the id, so the problem does not happen.

Please test to see if everything work as expected.

Regards,
Antonio

Please Log in or Create an account to join the conversation.

11 years 9 months ago
Omar Troncoso
Posts: 6
More
Topic Author
numbers as user names don't work with Joomdle #5
Ok. I'll try it this week end. I'll let you know if it work. Thanks

Please Log in or Create an account to join the conversation.

11 years 9 months ago 11 years 9 months ago by Omar Troncoso.
Omar Troncoso
Posts: 6
More
Topic Author
numbers as user names don't work with Joomdle #6
Antonio,
I tried to make the changes as instructed but I coudn't find the logout function in my joomdle.php file.

Attached you can find my joomdle.php file:

<?php
/**
* @version $Id
* @package Joomla
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport( 'joomla.plugin.plugin' );

class plgXMLRPCJoomdle extends JPlugin
{
function plgXMLRPCJoomdle(&$subject, $config)
{
parent::__construct($subject, $config);
$this->loadLanguage( '', JPATH_ADMINISTRATOR );
}

/**
* @return array An array of associative arrays defining the available methods
*/
function onGetWebServices()
{
global $xmlrpcI4, $xmlrpcInt, $xmlrpcBoolean, $xmlrpcDouble, $xmlrpcString, $xmlrpcDateTime, $xmlrpcBase64, $xmlrpcArray, $xmlrpcStruct, $xmlrpcValue;

return array
(
'joomdle.confirmJoomlaSession' => array(
'function' => 'plgXMLRPCJoomdleServices::confirmJoomlaSession',
'docstring' => JText::_('Confirms that a user is logged in Joomla'),
'signature' => array(array ($xmlrpcBoolean,$xmlrpcString, $xmlrpcString))
),
'joomdle.getUserInfo' => array(
'function' => 'plgXMLRPCJoomdleServices::getUserInfo',
'docstring' => JText::_('Returns user information'),
'signature' => array(array ($xmlrpcArray,$xmlrpcString))
)
);
}
}

class plgXMLRPCJoomdleServices
{
/**
* Remote session check
*
* @param string Username
* @param string Session ID
* @return boolean Wheter the user can log in Results
* @since 1.5
*/

function confirmJoomlaSession($username, $token)
{
global $mainframe, $xmlrpcerruser, $xmlrpcI4, $xmlrpcInt, $xmlrpcBoolean, $xmlrpcDouble, $xmlrpcString, $xmlrpcDateTime, $xmlrpcBase64, $xmlrpcArray, $xmlrpcStruct, $xmlrpcValue;

$user =& JFactory::getUser($username);

$query = 'SELECT session_id' .
' FROM #__session' .
" WHERE username = '$username' and md5(session_id) = '$token'";
$db = &JFactory::getDBO();
$db->setQuery( $query );
$sessions = $db->loadObjectList();

if (count ($sessions))
$r = true;
else $r = false;
return new xmlrpcresp(new xmlrpcval( $r, $xmlrpcBoolean));
}

function getUserInfo($username)
{
$user =& JFactory::getUser($username);
$user_info = $user->name;
$user_info = $user->email;

return $user_info;
}
}

Please Log in or Create an account to join the conversation.

11 years 9 months ago
Antonio Durán
Posts: 7331
More
numbers as user names don't work with Joomdle #7
It seems that you are running joomdle 0.21 instead of the latest 0.22, right?

Please Log in or Create an account to join the conversation.

11 years 8 months ago
Omar Troncoso
Posts: 6
More
Topic Author
numbers as user names don't work with Joomdle #8
Hi,
I uninstalled the old version and then I installed the latest 0.22 version. I see that the logout function do a great job. However, I made the changes to the jommdle.php file but I still have the same problem.
Regards,
Omar

Please Log in or Create an account to join the conversation.

11 years 8 months ago
Antonio Durán
Posts: 7331
More
numbers as user names don't work with Joomdle #9
Hi. It is strange, it is working Ok for me with those changes applied :(

Maybe I a missing something. I think the best is that you wait for 0.23, which should be available this week, and has this bug fixed.

Please Log in or Create an account to join the conversation.

11 years 8 months ago
Omar Troncoso
Posts: 6
More
Topic Author
numbers as user names don't work with Joomdle #10
Hi Antonio,
I have installed the latest version of Joomdle (0.23a) and now I can use numbers as usernames. That's ok.
However, there is a little bug. Whenever I use numbers as username the users that log out from Moodle don't log out from Joomla. I've tried it several times.
When the username is formed by letters or letters and numbers the logout function works fine (loging out from Moodles forces the loging out from Joomla). When the username is formed only by numbers, the user have to log out from Moodle and, then, again from Joomla.

Regards,

Omar

Please Log in or Create an account to join the conversation.