CodeIgniter Forums
Joomla woes - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Joomla woes (/showthread.php?tid=19824)

Pages: 1 2


Joomla woes - El Forum - 06-19-2009

[eluser]jwindhorst[/eluser]
Hi all, it's been a while since I've posted but this ones a good one.

Our company has decide to use Joomla for their CMS and CI for the application. Now however, they want us to come up with a way for our application login to work on both domains. application.com and cms.application.com. So fine, our sessions are stored in the DB so we can use the end users IP to locate their session record regardless of the domain, but I cannot find where Joomla checks for a user and creates it.

I'm thinking it's hidden under a meatball in the nonsensical spaghetti mess of code Joomla uses. Anyone have any ideas where this might be? Or a better way to accomplish the same goal? We're using the new release of Joomla, 1.5.whatever.

Thanks


Joomla woes - El Forum - 06-19-2009

[eluser]Dam1an[/eluser]
After a little bit of digging around (only a minute or two thanks to eclipse being abe to jump around and make better sense of the structure then me)
You want the onAuthencate function found in /plugins/authentication/joompla.php (line 55)

That calls an encryption function call getCryptedPassword which is in /libraries/joomla.user/helper.php (line 106)

If you just include that function and call it, you should be OK

Edit: that was Joomla 1.5.11, so line numbers might be slightly differant if you don't have the latest stable version


Joomla woes - El Forum - 06-19-2009

[eluser]jwindhorst[/eluser]
Actually I believe the onAuthenticate is the function that gets called when the user attempts a login to a joomla site. I'm trying to hook into the point before that where joomla decides if you currently logged in or not. Once joomla says "I appears this person is not logged in", I could then run a second check on the CI DB to see if they are logged in there.

In otherwords, I'm not looking to run the joomla authentication from the CI DB, instead trying to sort of HiJack (for lack of a better word) the CI Session from the DB, and use those credentials on the joomla site so that the end user "Admin" would only have to log in to one site.

Thanks for the quick response though, it is appreciated.


Joomla woes - El Forum - 06-19-2009

[eluser]Dam1an[/eluser]
Oh right, sorry, I misunderstood it (rereading it, I obviously didn't read it properly the first time ad just dived straight into Joomla)

I'll have a look what I can dig out and get back to you


Joomla woes - El Forum - 06-19-2009

[eluser]Jon Hack[/eluser]
Hi, although I don't have a direct answer for you, the following might help you in the right direction.

The Joomla API reference for the user functions is found here
http://api.joomla.org/Joomla-Framework/User/JUser.html

I'd also add that the changes you're looking at will require modifying the core of Joomla, which is not recommended so proceed at your own risk.

Another thought though is that you may be able to find a freelancer somewhere who knows his way around the Joomla code who can put that together for you.

Cheers


Joomla woes - El Forum - 06-19-2009

[eluser]jwindhorst[/eluser]
thanks JonHack, I realize that it means changing their core files, but currently it's a pretty vanilla install. If I break it too badly we could likely start over. That being said, I'm merely wanting to inject an extra database check as an interupt to whatever they are already doing. If they are saying if $user then getUser($user->id) -- I would like too be able to say, if $user || $otheruser ... etc.

The fix should be easy since we have mapped the joomla user id's into our primary database, I simple cannot find where they are making the "isLoggedIn" determination.


Joomla woes - El Forum - 06-19-2009

[eluser]Dam1an[/eluser]
ok, I think i got it this time, but first, I'll give you a quick tour of how to get there so you understand the flow

1) index.php:56 - branch off to do authorization
2) $mainframe that it does the branch from is actually a JSite object, found in /includes/application.php
3) application.php: 195 - The authorize function
Here you can see the part of the if/else where it would redirect to login, if you just put your hook in there

Hope this helps Smile


Joomla woes - El Forum - 06-19-2009

[eluser]jwindhorst[/eluser]
Yea, I was looking at that earlier. I feel like whatever $itemid is doing is determining things. I almost feel like we need to hook prior to that function being called and that was where I got lost.

I was able to get it to partially work by adding the hook to libraries/joomla/factory.php line 157. At the very beginning of the getUser function. however, it seems to get the user object, but the application still thinks were not logged in. Like it will say "Hi jwindhorst" and offer me the login form.

Furthermore, going to domain.com/administrator with this 1/2 user causes severe breakage.

Thanks again for helping out though.


Joomla woes - El Forum - 06-19-2009

[eluser]jwindhorst[/eluser]
Maybe it would help if I posted the code I added to the beginning of the getUser function:

Code:
$ci_link=mysql_connect($params_to_ci_db);
mysql_select_db('database_name');

$uip=$_SERVER['REMOTE_ADDR'];
$cross_over_query = "SELECT user_data FROM ci_sessions WHERE ip_address='$uip'";
$cross_over_results = mysql_query($cross_over_query);

while($cross_over_row= mysql_fetch_object($cross_over_results))
{
    $user_data=unserialize($cross_over_row->user_data);
    $user_id=$user_data['cms_id'];  // assume this is our joomla user id.
}
if(is_numeric($user_id))
    $id=$user_id;

// THE NEXT LINE IS
jimport('joomla.user.user); // UNCHANGED AS IS THE REST OF THE FUNCTION

So, essentially I was trying to provide the $id if it was missing, but something that happens earlier in the app is being skipped.


Joomla woes - El Forum - 06-19-2009

[eluser]Developer13[/eluser]
*Looks around*

Aren't these the CodeIgniter forums?