Page 1 of 1

JOS_USERS [ Coding Help Please ]

Posted: Tue Oct 23, 2007 5:45 am
by AstroBoy
Hi,

First off I am using 1.0.12 currently.  I will upgrade to 1.5 when it is production stable.

Currently I need to access jos_users from the joomla database.  I know a little about programming suchs as sessions, which I thought might work, I have also looked at mainframe->getUser a little however I cannot seem to get this working.

I create my php file and load it into joomla using a wrapper.

How can I get the currently logged in users name, id, or email?  Anything would be good.  If the user it not registerd sent directly to registration form.  Initially I thought this would be easy using sessions however I guessed wrong.

Also I keep getting "Restricted Access"
defined( '_VALID_MOS' ) or die( 'Restricted access' );

So I can never tell if it is my code or something else causing the problems.

Please Help....
~Astro

Re: JOS_USERS [ Coding Help Please ]

Posted: Tue Oct 23, 2007 1:21 pm
by Opie
AstroBoy wrote:Also I keep getting "Restricted Access"
defined( '_VALID_MOS' ) or die( 'Restricted access' );
I would guess, since your code is not part of the system (i.e. a component, module, plugin/mambot) that you are not allowed to access the necessary functions.  Once the '_VALID_MOS' variable is defined, you could, theoretically, get access.

Re: JOS_USERS [ Coding Help Please ]

Posted: Tue Oct 23, 2007 6:58 pm
by AstroBoy
Hi Thanks,

I see there is also jos_session in the database which contains username and time.  Would it be possible to access sessions when a user is logged in?

Re: JOS_USERS [ Coding Help Please ]

Posted: Tue Oct 23, 2007 7:11 pm
by Opie
To be honest, I wouldn't know.  I have not checked it out.

Re: JOS_USERS [ Coding Help Please ]

Posted: Wed Oct 24, 2007 7:49 pm
by ianmac
AstroBoy wrote:Hi Thanks,

I see there is also jos_session in the database which contains username and time.  Would it be possible to access sessions when a user is logged in?


Instead of using the wrapper component, create a custom component.  Within that component, you can do:

global $my; inside your function and access the current user data.

Ian

Re: JOS_USERS [ Coding Help Please ]

Posted: Wed Oct 24, 2007 7:59 pm
by AstroBoy
Thanks for the info.  I guess I am stuck in the mud.

you say component?

I have a complete working php file which allows users to post jobs or resumes.  However I simply need to obtain the username from joomla and my system will do the rest.

I have (index.php) includes php/html/css
I have (jobs.php) post jobs php/html/css
I have (resumes.php) post resumes php/html/css

I thought by using a wrapper and creating my layout under the min width of my website I would be able to easily implement my currently designed system into joomla.

I have to create a component, which im not familary with, do i have to recode everything??

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Why is it not possible to get the username from sessions?

Also is it not possible to use #includes or globals in my current php files to make them work with joomla, allowing me to access $my = $mainframe->getUser();

~grant

Re: JOS_USERS [ Coding Help Please ]

Posted: Wed Oct 24, 2007 8:59 pm
by ianmac
AstroBoy wrote:Thanks for the info.  I guess I am stuck in the mud.

you say component?

I have a complete working php file which allows users to post jobs or resumes.  However I simply need to obtain the username from joomla and my system will do the rest.

I have (index.php) includes php/html/css
I have (jobs.php) post jobs php/html/css
I have (resumes.php) post resumes php/html/css

My recommendation would be to create a directory under components called com_resumesystem.  Inside that directory, create a file called resumesystem.php.

In that file, use a switch statement like:

$task = mosGetParam( 'task', '' );
switch( $task ) {
  case 'jobs':
        include( 'jobs.php' );
        break;
    case 'resumes':
        include( 'resumes.php' );
        break;
    default:
        include( 'index.php' );
        break;
}

Then in your existing PHP files, change your links to:  index.php?option=com_resumesystem&task={jobs|resumes}&...

substituing the task value as appropriate.


I thought by using a wrapper and creating my layout under the min width of my website I would be able to easily implement my currently designed system into joomla.

I have to create a component, which im not familary with, do i have to recode everything??

No, you don't have to recode everything.  See above.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Why is it not possible to get the username from sessions?
I'm sure it is possible...  I don't know how, so I suggested the way that I did know.


Also is it not possible to use #includes or globals in my current php files to make them work with joomla, allowing me to access $my = $mainframe->getUser();

includes perhaps, but you would basically be hand initializing the Joomla! framework and this, IMO, is a less trivial task and more prone to security problems.  Basically, you can do this, but IMO it is more difficult than making your existing script into a component.

Ian

Re: JOS_USERS [ Coding Help Please ]

Posted: Wed Oct 24, 2007 9:53 pm
by AstroBoy
Okay cool,

I understand what you said about com_resumesystem however Im still not sure how to actually use this..

Do I continue to use a wrapper and call the link you mentioned or another method?

index.php?option=com_resumesystem&task=resumes
index.php?option=com_resumesystem&task=jobs
index.php?option=com_resumesystem < this would be default ?

I will keep playing with this however it is somewhat frustrating.

~G