Joomla! Discussion Forums



It is currently Tue Nov 24, 2009 7:07 am (All times are UTC )

 




Post new topic Reply to topic  [ 14 posts ] 
Author Message
Posted: Wed Jul 05, 2006 3:41 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Tue Jul 04, 2006 12:59 am
Posts: 12
hello,
  i'm doing  little investigation on why jd_wordpress and joomla aren't playing nice together.  It seems as though I can't get the username and ID from joomla.

using joomla 1.0.10
here's the relevant code:

if (!defined('ABSPATH')) {
define( '_VALID_MOS', 1 );

include_once( '../../../globals.php' );
require_once( '../../../configuration.php' );
require_once( '../../../includes/joomla.php' );

global $mosConfig_absolute_path, $mosConfig_live_site, $database;

$mainframe = new mosMainFrame( $database, isset($option), '.' );
$mainframe->initSession();
        $my = $mainframe->getUser();

the above looks like it should work, but whenever i echo $my->Id; i get zero (0).  However, I know the ID of the logged in user is 62 (i'm logging in as admin).

  any ideas on why this isn't working?

i've also posted about this on the wordpress support forums (for reference).
http://wordpress.org/support/topic/7833 ... ost-405510

A million thanks.  Right now i rigged wp with the id of the admin user in order to be able to use it.  Any help would be appreciated.


Top
  E-mail  
 
Posted: Wed Jul 05, 2006 3:45 pm 
User avatar
Joomla! Master
Joomla! Master
Offline

Joined: Thu Aug 18, 2005 8:55 pm
Posts: 12895
Location: Nijmegen, The Netherlands
buffnerd wrote:
any ideas on why this isn't working?


Yes, you need to put $my in the global statement...

global $mosConfig_absolute_path, $mosConfig_live_site, $database, $my;
$userid = $my->id;

_________________
Kind Regards,
Peter Martin, Global Moderator - Community & Leadership Team
www.db8.nl - Joomla specialist, Nijmegen, Nederland
Joomla 1.5 Quick Reference Guide: www.db8.nl/en/downloads/misc-downloads/ ... glish.html


Top
   
 
Posted: Wed Jul 05, 2006 4:12 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Tue Jul 04, 2006 12:59 am
Posts: 12
tried that.  i'm still getting the same issue.


Top
  E-mail  
 
Posted: Wed Jul 05, 2006 4:15 pm 
User avatar
Joomla! Master
Joomla! Master
Offline

Joined: Thu Aug 18, 2005 8:55 pm
Posts: 12895
Location: Nijmegen, The Netherlands
Did you put the code in a Joomla module/component or in jd_wordpress?
What I wrote only works in Joomla...

_________________
Kind Regards,
Peter Martin, Global Moderator - Community & Leadership Team
www.db8.nl - Joomla specialist, Nijmegen, Nederland
Joomla 1.5 Quick Reference Guide: www.db8.nl/en/downloads/misc-downloads/ ... glish.html


Top
   
 
Posted: Wed Jul 05, 2006 4:16 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Tue Jul 04, 2006 12:59 am
Posts: 12
ah, i put it in the jd_wordprss admin.php.  I should put it in the file you mentioned?

let me try that.


Top
  E-mail  
 
Posted: Wed Jul 05, 2006 4:20 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Tue Jul 04, 2006 12:59 am
Posts: 12
here's what i did.

i put my in the global line of the admin.php file in components/com_jd-wp/wp-admin.

should i be doing something different?  I know this is a noob question, i'm a bit new to joomla


Top
  E-mail  
 
Posted: Wed Jul 05, 2006 4:23 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Tue Jul 04, 2006 12:59 am
Posts: 12
pe7er wrote:
Did you put the code in a Joomla module/component or in jd_wordpress?


do you mean i need to edit the mod_components.php file? in administrator/modules?


Top
  E-mail  
 
Posted: Wed Jul 05, 2006 4:28 pm 
User avatar
Joomla! Master
Joomla! Master
Offline

Joined: Thu Aug 18, 2005 8:55 pm
Posts: 12895
Location: Nijmegen, The Netherlands
I meant: when I write a module or component for Joomla, the method I wrote about works to get the id of the registered user that is logged in.

Did you take a look at http://extensions.joomla.org/component/ ... /cat_id,0/ for any jd_wordpress components/modules that function from within Joomla?
(I don't know jd_wordpress, but maybe you can use the extensions, or take a look at them how they work).

_________________
Kind Regards,
Peter Martin, Global Moderator - Community & Leadership Team
www.db8.nl - Joomla specialist, Nijmegen, Nederland
Joomla 1.5 Quick Reference Guide: www.db8.nl/en/downloads/misc-downloads/ ... glish.html


Top
   
 
Posted: Wed Jul 05, 2006 4:36 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Tue Jul 04, 2006 12:59 am
Posts: 12
you're right, it should work.  I wonder why i'm always getting zero for the ID though.  It just doesn't make sense.

by the way, i'm using predator's jd_wordpress not the extension you mentioned (it is designed to share the joomla user DB).  Either way, it's strange that i can't get the id of the currently logged in user.  Any ideas ?


Top
  E-mail  
 
Posted: Wed Jul 05, 2006 7:56 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Tue Jul 04, 2006 12:59 am
Posts: 12
is it possible the initSession(); below is creating an entirely new session?  Do you have some sample code of how to get the current user? 
do you just globalize the $my and the just get the id using $my->id ?

Thanks


if (!defined('ABSPATH')) {
define( '_VALID_MOS', 1 );

include_once( '../../../globals.php' );
require_once( '../../../configuration.php' );
require_once( '../../../includes/joomla.php' );

global $mosConfig_absolute_path, $mosConfig_live_site, $database, $my;

$mainframe = new mosMainFrame( $database, isset($option), '.' );
$mainframe->initSession();
    $my = $mainframe->getUser();


Top
  E-mail  
 
 Post subject: still working on this
Posted: Wed Jul 05, 2006 10:29 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Tue Jul 04, 2006 12:59 am
Posts: 12
i've been on this all day and nothing so far. it's almost as if the session is being rest.  $my is just plain old empty.

any thoughts by anyone ??


Top
  E-mail  
 
Posted: Thu Jul 06, 2006 5:47 am 
User avatar
Joomla! Master
Joomla! Master
Offline

Joined: Thu Aug 18, 2005 8:55 pm
Posts: 12895
Location: Nijmegen, The Netherlands
You could insert some code to return the values of your variables.

global $mosConfig_absolute_path, $mosConfig_live_site, $database, $my;
print"
";
print_r([color=red]$array_variable_you_want_to_echo_to_screen);
print"
";
die($query);
[/color]$mainframe = new mosMainFrame( $database, isset($option), '.' );

and then instead of $array_variable_you_want_to_echo_to_screen, use $mosConfig_absolute_path, $mosConfig_live_site, $database and $my to show if those contain any values.

_________________
Kind Regards,
Peter Martin, Global Moderator - Community & Leadership Team
www.db8.nl - Joomla specialist, Nijmegen, Nederland
Joomla 1.5 Quick Reference Guide: www.db8.nl/en/downloads/misc-downloads/ ... glish.html


Top
   
 
Posted: Thu Jul 06, 2006 10:53 am 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Tue Jul 04, 2006 12:59 am
Posts: 12
thanks for staying with me on this.  I finally figued out the problem.  the issue was with $mosConfig_live_site
it was set to buffnerd.com not http://www.buffnerd.com. 

Now i have no idea why it solved the problem, but once i changed it the problem was fixed.  It took me a while of echoing variables, but finally i got it.

i wonder why that would have caused the problem though (not being an expert on joomla, but having worked with sessions in other languages) it would seem that even if the live site variable was wrong the session should still have been found.  I mean if i store a session for apple and i look for apple it should still be stored under the correct name.

well, all is well now.  thanks again!


Top
  E-mail  
 
Posted: Thu Jul 06, 2006 11:04 am 
User avatar
Joomla! Master
Joomla! Master
Offline

Joined: Thu Aug 18, 2005 8:55 pm
Posts: 12895
Location: Nijmegen, The Netherlands
Good to see that you've solved your problem!
Interesting question!
A search on this forum for "mosConfig_live_site session" returned some message that shows the code:
session_name( md5( $mosConfig_live_site ) );

Which indicates that the session name is related to (an MD5 Hashed) $mosConfig_live_site.

_________________
Kind Regards,
Peter Martin, Global Moderator - Community & Leadership Team
www.db8.nl - Joomla specialist, Nijmegen, Nederland
Joomla 1.5 Quick Reference Guide: www.db8.nl/en/downloads/misc-downloads/ ... glish.html


Top
   
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

Quick reply

 



Who is online

Users browsing this forum: No registered users and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group