Actions

Developer Area/Pagetop Constants: Difference between revisions

From Mahara Wiki

< Developer Area
(Created page with "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…")
 
No edit summary
Line 2: Line 2:


'''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.
'''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 ===
=== INTERNAL ===
Line 14: Line 16:


  defined('INTERNAL') || die();
  defined('INTERNAL') || die();
== Access control ==
These constants control who can access the page. Also, setting any of them tells
=== ADMIN ===
=== INSTITUTIONALADMIN ===
=== STAFF ===
=== INSTITUTIONALSTAFF ===

Revision as of 10:33, 16 Ocak 2014

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. Also, setting any of them tells

ADMIN

INSTITUTIONALADMIN

STAFF

INSTITUTIONALSTAFF