Developer Area/Pagetop Constants
From Mahara Wiki
< Developer Area
Mahara uses a diverse range of PHP constants defined at the beginning of the script, to define the script's behavior or provide metadata. This page attempts to be a comprehensive list of these constants and what they do.
Note: By all means make use of the existing set of page-top constants, but please avoid creating new ones whenever possible. They're a form of global variable, and as such they bring all the associated problems with them. They also tend not to be well-documented, because there's no central place in the code where they have to be used.
General purpose
INTERNAL
This backwards-named constant tells Mahara that it's okay to access this page externally.
Every Mahara script that is meant to be addressed directly by a web browser (or other HTTP client) should define it as its very first PHP statement, even before including init.php.
define('INTERNAL', 1);
Conversely, every "library" script which is not meant to be addressed directly by a web browser, should begin with this:
defined('INTERNAL') || die();
Access control
These constants control who can access the page. If any of them is set, the logged-in user will be checked for appropriate access control in the auth_setup() method called by init.php. If they lack appropriate credentials, they'll see a warning message.
Note that you can only set one of these values on any page. If more than one is defined, only the most restrictive one will have effect and the others will be ignored. (See the auth_check_admin_section() method for the actual implementatoin.)
Setting any of these constants also tells the Mahara main_nav() method that you are in Mahara's "admin section", and it will then show you the appropriate admin menu depending on whether you are a site admin, site staff, institution admin, or institution staff. It also sets a smarty flag with the same name as the constant, which can be used to style the admin section differently than normal pages.
ADMIN
define('ADMIN', 1);
Indicates that this page should only be accessible to Site Administrators.
STAFF
define('STAFF', 1);
Indicates that this page should only be accessible to Site Staff (and Site Admins).
INSTITUTIONALADMIN
define('INSTITUTIONALADMIN', 1);
Indicates that this page should only be accessible to Institution Admins (and Site Admins).
INSTITUTIONALSTAFF
define('INSTITUTIONALSTAFF', 1);
Indicates that this page should be accessible to Institution Staff (and Site Admins, Site Staff, and Institutional Admins).