Joomla! Discussion Forums



It is currently Wed Nov 25, 2009 3:39 am (All times are UTC )

 




Post new topic Reply to topic  [ 29 posts ] 
Author Message
Posted: Mon Oct 30, 2006 10:09 pm 
Joomla! Fledgling
Joomla! Fledgling
Offline

Joined: Mon Oct 30, 2006 10:05 pm
Posts: 2
Hi,

I am pretty new to Joomla, but I am trying to get the current user name from Joomla for use within a PHP script using rd_addphp.

Is this possible??

TIA!!!
Matt


Top
  E-mail  
 
Posted: Sun Nov 05, 2006 2:46 pm 
Joomla! Enthusiast
Joomla! Enthusiast
Offline

Joined: Thu Jul 20, 2006 7:15 am
Posts: 148
Location: UK
You would need the following:

Code:
global $my;

echo "My username: ".$my->username."<br />";

echo "My name: ".$my->name."<br />";


Well, depending which one you want.

8)

_________________
Web Developer

www.obbec.com


Top
  E-mail  
 
Posted: Sun Nov 05, 2006 2:55 pm 
Joomla! Fledgling
Joomla! Fledgling
Offline

Joined: Mon Oct 30, 2006 10:05 pm
Posts: 2
Thanks bpatient!! It works a treat.


Top
  E-mail  
 
Posted: Tue Nov 07, 2006 8:42 am 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Wed Sep 13, 2006 9:50 am
Posts: 7
And If i want to know the passwd ?
how do i do ?


Top
   
 
Posted: Wed Nov 08, 2006 5:02 pm 
User avatar
Joomla! Virtuoso
Joomla! Virtuoso
Online

Joined: Sat Sep 24, 2005 11:01 pm
Posts: 4483
Location: Toronto, Canada
Can't really do that...  the password is not stored in the database, only an MD5 hashed version (I think that is what it is).  when the password is sent, it is hashed and then compared with the stored hash value.

Ian

_________________
Joomla! Leadership Team - Production Working Group
Joomla! Bug Squad Coordinator
Joomla! Developer Documentation Team
Please don't say something 'isn't working'. Explain what you tried, and what happened as a result.


Top
   
 
Posted: Thu Nov 09, 2006 2:51 am 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Wed Sep 13, 2006 9:50 am
Posts: 7
Thanks !
can we store it in the session ?
if enable, could you present detail it. please !


Top
   
 
Posted: Thu Nov 09, 2006 4:32 am 
User avatar
Joomla! Virtuoso
Joomla! Virtuoso
Online

Joined: Sat Sep 24, 2005 11:01 pm
Posts: 4483
Location: Toronto, Canada
I'm not sure exactly what you are asking?

Are you working on the backend or the frontend?

I'm not sure offhand if the hashed password is stored in the $my object.  You would have to try it.
HINT: you can see all the data in the $my object using print_r( $my );  If password is blank (which it may be), then you'll probably have to get it right from the database.  Otherwise, you can get it right from the $my object (and then there isn't a real need to store it in the session, is there?)

Variables can be stored and retrieved from the session using $mainframe->setUserState() and $mainframe->getUserState or $mainframe->getUserStateFromRequest().  See joomla.php for more info (see the mosMainframe class, the methods I just mentioned).  This file is in the includes directory.

The session is only active on the back end.  user state doesn't work on the front end.

Hope that helps,
Ian

_________________
Joomla! Leadership Team - Production Working Group
Joomla! Bug Squad Coordinator
Joomla! Developer Documentation Team
Please don't say something 'isn't working'. Explain what you tried, and what happened as a result.


Top
   
 
Posted: Fri Nov 10, 2006 2:10 am 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Wed Sep 13, 2006 9:50 am
Posts: 7
Thank a lot !


Top
   
 
Posted: Mon May 28, 2007 3:37 pm 
Joomla! Fledgling
Joomla! Fledgling
Offline

Joined: Mon May 28, 2007 2:12 pm
Posts: 4
But how do you get the username or session id from the front end?


Top
  E-mail  
 
Posted: Mon May 28, 2007 3:53 pm 
User avatar
Joomla! Virtuoso
Joomla! Virtuoso
Online

Joined: Sat Sep 24, 2005 11:01 pm
Posts: 4483
Location: Toronto, Canada
Read the thread again and you should find out how to get the username.

Why do you need the session ID?

Ian

_________________
Joomla! Leadership Team - Production Working Group
Joomla! Bug Squad Coordinator
Joomla! Developer Documentation Team
Please don't say something 'isn't working'. Explain what you tried, and what happened as a result.


Top
   
 
Posted: Mon May 28, 2007 4:17 pm 
Joomla! Fledgling
Joomla! Fledgling
Offline

Joined: Mon May 28, 2007 2:12 pm
Posts: 4
The session id would make it possible to find the username and that;s the only thing i care for, that a user has succesfuly logged on. This username will then be the primary key for the database needed for a project.


Top
  E-mail  
 
Posted: Mon May 28, 2007 4:56 pm 
User avatar
Joomla! Virtuoso
Joomla! Virtuoso
Online

Joined: Sat Sep 24, 2005 11:01 pm
Posts: 4483
Location: Toronto, Canada
Then use the $my object.

If $my->id is 0, then no user is logged in.  Otherwise, the id is the user id of the currently logged in user.

$my->username will give you the username.

Sorry for the repetition here folks!
Ian

_________________
Joomla! Leadership Team - Production Working Group
Joomla! Bug Squad Coordinator
Joomla! Developer Documentation Team
Please don't say something 'isn't working'. Explain what you tried, and what happened as a result.


Top
   
 
Posted: Mon Jul 16, 2007 8:11 am 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Tue Apr 18, 2006 5:28 am
Posts: 13
bpatient wrote:
You would need the following:

Code:
global $my;

echo "My username: ".$my->username."<br />";

echo "My name: ".$my->name."<br />";


Well, depending which one you want.

8)


Can you please give me an example php page for grabbing the username?  I see the example above but it is not working for me.  my code is below:

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

global $my;

echo "My username: ".$my->username."
";

echo "My name: ".$my->name."
";

// Print an individual cookie
$cookie=  MD5( '64.merle.SuperAdministrator.1184563530' );
$name = $my->username;
echo $_COOKIE["devel.gardenfreshcorp.com"];
echo $HTTP_COOKIE_VARS["devel.gardenfreshcorp.com"];
echo $my->id;
echo $my->username;
echo $name;
echo $cookie;
echo "
";
echo $_USERNAME;
echo "
";
// Another way to debug/test is to view all cookies
print_r($_COOKIE);
?>


Top
   
 
Posted: Mon Jul 16, 2007 9:18 am 
User avatar
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Mon Mar 05, 2007 2:35 pm
Posts: 13
Location: Paris, France
Hello all,

Quote:
Can you please give me an example php page for grabbing the username?  I see the example above but it is not working for me.  my code is below:

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


I don't understand what you are trying to do... You want to use Joomla connected user info inside a non Joomla PHP page?

If your code is not in a joomla CMT (Component Miodule Template) that mean no user is currently connected...

If your code is in a Joomla CMT, then you does not need to call Joomla core files (configuration.php and joomla.php), because this is your CMT witch is call inside Joomla (and not the inverse)...

You can find $my object exemple in the mod_login.php module...

_________________
Christophe


Top
   
 
Posted: Tue Jul 17, 2007 9:35 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Tue Apr 18, 2006 5:28 am
Posts: 13
Thanks for the reply.  I actually got it working.  I am using Flex 2 for a project to graph financial data.  Within the flash file, i am calling a php page to ascertain who is logged into joomla (our intranet) and that determines who has permission to do certain things with the data in flex.

I added the following to the templates/ja_altair/index.php and login.php(custom login page i made) and i am able to grab the username into flex:

$name = "$my->username";
setcookie("name",$name);
?>

I can then call the cookie named "name" to return the currently logged in user.  I know its not the proper way to do it,  but since joomla is so confusing with the session_id stuff and i read literally dozens upon dozens of posts all over the web of people wanting to do the same thing with no success, i had to do it this way.

Unless anyone can tell me an easier way, this will have to do.  I recently purchased a support suite called: "kayako" for $500.00 only to find out that it is not "integrated" with joomla as they claim.  It merely uses the same username/password as joomla requiring you to login twice.  Once for joomla and a second time for the support suite.  Since this is ridiculous, I wrote code within the joomla login to create the session and cookie for Kayako so that you are logged in from joomla into kayako without having to login in twice.  Would have been much easier if joomla's session login was explained somewhere so that normal people could figure it out.  I can assure you I am of above average intelligence but I could not make heads or tails of the joomla login.

Thanks for your timely reply.  Anyone heard of anyone making a module for Kayako and joomla integration?  Lots of people looking for this from the posts i read FYI.

Merle
IT Manager,
Souplantation


Top
   
 
Posted: Sat Sep 29, 2007 5:42 pm 
User avatar
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Sat Sep 29, 2007 3:31 pm
Posts: 11
If you use Joomla 1.0.12 or above use the loginShare, details in Kayako SupportSuite Manual

After 1.0.13 see http://forum.joomla.org/index.php/topic,217746.0.html


Top
   
 
Posted: Sun Dec 09, 2007 11:49 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Sun Dec 09, 2007 9:57 pm
Posts: 6
does anyone know how the "session_id" in the jos_session table is generated?

is it

md5(something + something else)?


Top
  E-mail  
 
Posted: Wed Dec 12, 2007 1:24 am 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Sun Dec 09, 2007 9:57 pm
Posts: 6
Ok, there IS a way...,

and its not made to be handled in a very simple manner at the present moment, and still NEEDS to be documented (the whole topic with username, authentication, session_id business - cannot find the documentation anywhere as of this moment :( ).

Concerning the cases outside of joomla (otherwise try the solutions above), there are no straightforward solutions, please email me mike.vasiljevs@gmail.com if you still have a problem

you might need to either modify joomla.php or create a bunch of fake classes etc in your external code just to trick joomla for some of the variables it expects to be available...

also my other post in http://forum.joomla.org/index.php/topic,242580.0.html
..on how to get 'session_id' and then simply SELECT the username from the jos_session table.
8)


mattp wrote:
I am pretty new to Joomla, but I am trying to get the current user name from Joomla for use within a PHP script using rd_addphp.

Is this possible??



Last edited by sonicth on Wed Dec 12, 2007 1:29 am, edited 1 time in total.

Top
  E-mail  
 
Posted: Mon Mar 17, 2008 11:05 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Wed Jul 04, 2007 2:56 pm
Posts: 24
mreine wrote:
Unless anyone can tell me an easier way, this will have to do.  I recently purchased a support suite called: "kayako" for $500.00 only to find out that it is not "integrated" with joomla as they claim.  It merely uses the same username/password as joomla requiring you to login twice.  Once for joomla and a second time for the support suite.  Since this is ridiculous, I wrote code within the joomla login to create the session and cookie for Kayako so that you are logged in from joomla into kayako without having to login in twice.  Would have been much easier if joomla's session login was explained somewhere so that normal people could figure it out.  I can assure you I am of above average intelligence but I could not make heads or tails of the joomla login.


Merle, did you manage to work out how to do this? It would be really great if this was workin


Top
   
 
Posted: Sat Mar 22, 2008 1:30 am 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Wed Jul 04, 2007 2:56 pm
Posts: 24
Any update? have anyone got Kayako working with Joomla?

If any developer out there is interesting in developing this then contact me as I would be willing to pay....


Top
   
 
Posted: Sat Mar 22, 2008 6:34 am 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Tue Apr 18, 2006 5:28 am
Posts: 13
Hello,

The following person/people report to have it working and I have emailed them as to the cost but no response yet. If you contact them and get any pricing, let me know and I will do the same.

http://forums.kayako.com/f78/joomla-kay ... tor-13692/


Top
   
 
Posted: Sat Mar 22, 2008 11:23 am 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Wed Jul 04, 2007 2:56 pm
Posts: 24
mreine wrote:
Hello,

The following person/people report to have it working and I have emailed them as to the cost but no response yet. If you contact them and get any pricing, let me know and I will do the same.

http://forums.kayako.com/f78/joomla-kay ... tor-13692/


I contacted them an purchased the autologin but it works using an Joomla wrapper... This isn't want I wanted as running any page in a wrapper isn't ideal. Still looking for a real module which allows Kayako and Joomla to share information.


Top
   
 
Posted: Tue Apr 01, 2008 8:45 pm 
User avatar
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Sat Sep 29, 2007 3:31 pm
Posts: 11
top_cat wrote:
mreine wrote:
Hello,

The following person/people report to have it working and I have emailed them as to the cost but no response yet. If you contact them and get any pricing, let me know and I will do the same.

http://forums.kayako.com/f78/joomla-kay ... tor-13692/


I contacted them an purchased the autologin but it works using an Joomla wrapper... This isn't want I wanted as running any page in a wrapper isn't ideal. Still looking for a real module which allows Kayako and Joomla to share information.


Top
   
 
Posted: Tue Apr 01, 2008 8:48 pm 
User avatar
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Sat Sep 29, 2007 3:31 pm
Posts: 11
top_cat wrote:
mreine wrote:
Hello,

The following person/people report to have it working and I have emailed them as to the cost but no response yet. If you contact them and get any pricing, let me know and I will do the same.

http://forums.kayako.com/f78/joomla-kay ... tor-13692/



I contacted them an purchased the autologin but it works using an Joomla wrapper... This isn't want I wanted as running any page in a wrapper isn't ideal. Still looking for a real module which allows Kayako and Joomla to share information.


Top
   
 
Posted: Tue Apr 01, 2008 8:56 pm 
User avatar
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Sat Sep 29, 2007 3:31 pm
Posts: 11
About the last posts... (error quotes)

Hello men, i try to contact many developers to create a Joomla - Kayako Support Suite Bridge with no wrapper. If you can post your "autologin" with wrapper you can help!

If you paid for it and not have iterest in share you can port a url example. it very helpfull for the planning process.

Tks


Top
   
 
Posted: Wed Apr 02, 2008 4:08 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Tue Apr 18, 2006 5:28 am
Posts: 13
Latest conversation with kayako:

Hi,
>> When are you going to support joomla? And I don't mean your half baked joomla shared login that you have now. I mean a single signon with joomla when logged into joomla, it is logged into kayako? Hundreds of people are asking for it and i would think your company would want to appease its users.

I will forward this to the developers and if anything like this comes up, we will release it in News section and announcements in forums at http://forums.kayako.com Any inconvenience is deeply regretted.

Let us know if there is anything else we can assist you with.

Regards,

Varun Sharma


Top
   
 
Posted: Sun Apr 06, 2008 7:44 pm 
User avatar
Joomla! Guru
Joomla! Guru
Offline

Joined: Wed Jul 04, 2007 4:54 am
Posts: 828
Location: Kuala Lumpur, Malaysia
could this be the reason for lack of response ?
it does not look like open source to me.

from Kayako site.
License Options
--------------------------------------------------------------------------------

There are four license options for you to choose from when purchasing SupportSuite, eSupport or LiveResponse. Licenses are on a per-installation basis - you are granted one installation for each license purchased. Additional licenses are available at a reduced cost, provided they are used by the same license holder (person, company or otherwise).

For yearly and monthly leased licenses, support and upgrades are available for as long as you hold the license for. For an owned license (a lifetime license), you will receive support and upgrades for 6 months. After this period (if you wish to continue receiving support and have access to new versions of the software) you will need to purchase another 6 months of support and upgrades. There is no obligation to renew and you will still be able to download the last version available to you.

Owned Yearly Leased Monthly Leased Monthly Hosted
Source code 98% Fully encrypted
Support 6 months Provided for as long as the license is held
Upgrades 6 months Provided for as long as the license is held
Hosted Your own web host or server Hosted for you
Seats Unlimited seats (staff) and users (clients)


Top
  E-mail  
 
Posted: Tue Aug 11, 2009 7:26 pm 
Joomla! Fledgling
Joomla! Fledgling
Offline

Joined: Tue Aug 11, 2009 7:09 pm
Posts: 3
Hello , I tried

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

global $my;

echo "My username: ".$my->username."
";

echo "My name: ".$my->name."
";


but it shows me "Restricted access" error , even if I'm logged
Thanks


Top
  E-mail  
 
Posted: Sat Aug 29, 2009 8:10 pm 
Joomla! Fledgling
Joomla! Fledgling
Offline

Joined: Sat Aug 29, 2009 7:47 pm
Posts: 1
I hope it's appropriate to post here - but I have a similar situation and it is not working. I'm a real noob to Joomla, and getting the user name is a snap as are most things compared to figuring out how to be Joomla friendly. I'm a seasoned Perl, C/C++, MySQL web developer, but I am lost. So let me explain what I want to do and maybe you can give me some guidance.

On the main "page" of the site I want to have a link which will call a script (probably PHP since Joomla seems to prefer it). The script will access a mysql database and display some data in a table. Very simple to do in html and perl or php. However, I *need* the user name from Joomla in order to get the data which is user specific. I created a module which is running but does not work properly - but at least I know it runs. The problem is that it executes when the user logs on to the site. It's supposed to be run only by registered users - obviously after they have had a chance to login - and only if they want it. So the module should open a new window with the table data in it.

I have tried 2 approaches: one is simply a extension module and added an html link - from which I cannot extract the username using the $my... apparently $my is not accessible to a pure php script.

Tthe other attempt uses a Section/category - Similar to the "hello World" example in the "Professional Joomla" book by Dan Rahmel - but it executes when the main page is loaded - I need it to be selected manually.

So in essence I need to know:

How do I put a user selectable "link" to my module on the main page?


Top
  E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 29 posts ] 

Quick reply

 



Who is online

Users browsing this forum: No registered users and 8 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