Where are the global variables?

Where are the global variables?

by Kent Tan -
Number of replies: 2

sorry, but i am really a newbie to this moodle thing. in fact, i am a newbie to php.

i'm trying to create another type of users (corporate) besides admin, creators, teachers and students.

i tried to trace back the include files but i just couldnt find where $teachers, $USER are declared.

can someone tell me how and where these variables are declared?

many thanks.

Average of ratings: -
In reply to Kent Tan

Re: Where are the global variables?

by Shane Elliott -
Picture of Core developers Picture of Plugin developers
There is a plan for flexible user roles to be implemented in a later version of moodle

1. USER is the only user related global variable and is loaded from the session (or created) in /lib/setup.php. The USER variable is populated with the current user's information when they log in (/login/index.php) by calling the function authenticate_user_login() (in /lib/moodlelib.php)
2. admins have an entry in the user_admin table
3. creators have an entry in the user_coursecreators table
4. teachers have an entry in the user_teachers table (with appropriate course id)
5. students have an entry in the user_students table (with appropriate course id)

There are functions (eg isadmin(), iscreator() ... ) which check for entries of the current user's id in the appropriate database table.

Depending on what your coporate role needs to do you may just want to add another database table (eg user_corporate) and then check for a user's id in the table before they are allowed to do a particular task.

HTH
In reply to Shane Elliott

Re: Where are the global variables?

by Kent Tan -

thanks!

gotta start figuring out if i should add corporate as a user or create a seperate table altogether.