NeoFW Modules

From NarcWiki

Jump to: navigation, search

This page contains a list of all NeoFW modules, along with their configuration directives.

Contents

The base Module

The base module is the first of two absolutely required modules. base provides some glue functions to the rest of the framework, and also contains some miscellaneous functions which haven't found their place yet.

Configuration variables

  • $config['prog']['sender'] -- (string) The default From: address of emails sent by the send_html_mail() function. It is only required if you're not going to pass a sender argument to the function.
  • $config['base']['ob'] -- (boolean) Whether to use output buffering in the application automatically or not. If true, will automatically call ob_start() during initialization.

Notes

  • See NeoFW base Functions for a list of all the functions provided by this module.
  • base is automatically included whenever NeoFW is in use. Disabling it in any way is unsupported.

The err Module

The err module provides error-reporting and handling functions, and a few logging functions that can be useful for debugging. Because it is used internally for these functions, it is the second of the two absolutely required modules.

Configuration variables

  • $config['err']['log'] -- (int, bitwise) One or more of the NEOFW_LOG_ family of constants, added together (or bitwise and-ed). Defines how logging is handled -- to console, to file, etc.. By default, it is NEOFW_LOG_CONSOLE_HTML (HTML-format logging lines are included in the output).
  • $config['err']['logfile'] -- (string) Path to the file used for logging, if logging to file is enabled. If a relative path, it will be relative to the script called via HTTP or command line. By default, uses "[NEOFW_PATH]/log/error.log". It is highly recommended to set this if you set $config['err']['log'] above.
  • $config['err']['debug'] -- (int, bitwise) One or more of the NEOFW_DEBUG_ family of constants, added together (or bitwise and-ed). Specifies the type of debug lines that will be logged automatically. Defaults to NEOFW_DEBUG_NONE, or no debug logging.
  • $config['err']['on_fatal_error'] -- (string, function($msg, $sys, $file, $line)) Specifies an (optional) function to be called in case of fatal error. The function must take four parameters, in order: error message, subsystem, file of error, and line of error. The latter two may be null in some cases.
  • $config['err']['with_error_location'] -- (boolean) Whether or not to include the error location (i.e. file and line) in the logging output when they are available.
  • $config['err']['css'] -- (string, hyperlink) Link to a CSS to be used for the default fatal error page (if you didn't set $config['err']['on_fatal_error'] above).

Notes

  • See NeoFW err Functions for a list of the functions provided by this module.
  • err is automatically included whenever NeoFW is in use. Disabling it is unsupported (but you can configure it not to log anything).

The db Module

db provides a single linking point to the db.* submodules.

Configuration variables

  • $config['db']['type'] -- (string) Name of the db.* submodule to include, without the db. prefix; if empty, db.inc is never included. Default: null (unset).

Notes

  • db and its submodules are non-standard, as NeoFW modules go, but this is because the functionality itself is unusual. db does not actually provide any functions itself, but instead includes one of the db.* submodules to make its functions available. These functions, however, are standardized across all the database handlers, and a list can be found at NeoFW db Functions.
  • The only database abstraction available at this point is for MySQL. This is expected to grow later to support a number of other databases, including at least one file-based database.


The db.null Module

db.null is a special debug/fallback database handler. It provides the known NeoFW db Functions, but their return value is unspecified. There is no database connection because there is no database.

Configuration variables

There is no configuration for the db.null module.

Notes

  • As stated above, the return values of the functions provided are unspecified, and may change at any time. The db.null module should never be used in a production environment for any purpose, it exists purely for debugging.
  • The sole guarantee is that db_connected() will always return false, thereby allowing you to test what happens when the back-end database of your website goes down.


The db.mysql Module

This section is a stub. It will be expanded upon later.


The db.mysqli Module

This section is a stub. It will be expanded upon later.


The priv Module

The priv module provides a reasonably complete set of functions that can be used to provide fine-grained access control to your application.

Configuration variables

  • $config['priv']['in_use'] -- (boolean) Whether to include the priv module or not. Defaults to null (unset), equivalent to false.
$config['priv']['list']['Write'] = 1;

$config['priv']['list']['Administer'] = 2;

An example of privileges
  • $config['priv']['list'] -- (array) An array mapping the privilege names used internally in the application to privilege IDs. An example is shown to the right, consisting of two privilege levels, "Write" and "Administer", given the IDs 1 and 2, respectively.

Notes

  • priv will automatically force the inclusion of the auth and prog modules by setting $config['auth']['in_use'] and $config['prog']['in_use'], due to a number of required functions from these modules. You may need to configure auth and prog as well if you're using priv.
  • The full listing of functions provided can be found at NeoFW priv Functions.
  • Be very careful when mapping privilege names to IDs! Duplicate privilege IDs may lead to unpredictable results when using the functions provided by this module.
  • The exotic nature of $config['priv']['list'] comes from a desire to avoid (potentially slow) SQL lookups of privilege IDs. A switch may be provided later to allow privileges to be stored in a database instead, allowing the DB to enforce the ID uniqueness requirement.

The auth Module

The auth module provides some authentication functions, allowing you to quickly provide user login, logout, and registration.

Configuration variables

  • $config['auth']['in_use'] -- (boolean) The master switch; controls whether the auth module should be included or not. Defaults to null (unset), equivalent to false, but may be overridden by other included modules.
  • $config['auth']['db'] -- (string) Name of the database containing the auth tables. Defaults to $config['db']['db'], but can and should be overridden in the case of multiple websites with a single user database.
  • $config['auth']['prefix'] -- (string) Prefix added to all authentication table names, in case of database sharing (some web hosts allow a single database per user; this allows the auth tables to stand out in the inevitable crowd).

Notes

  • Some special configuration needs to be done if auth is to be used in a single-login, multiple-website situation. In this case, NEOFW_LOGIN_URL must be set to a path which should contain login.php, register.php, and logout.php, which should perform the named functions respectively, and which should accept a returnto= parameter specifying a URL to redirect the user to after successful login/registration/logout. This implementation may change in the future and the instructions will be updated as needed.
  • Function list is at NeoFW auth Functions.
  • The various SQL queries used may be MySQL-specific; if so, a later version will include corrected versions that should work with all flavors of SQL supported by NeoFW.


See Also

This article is a stub. It will be expanded upon later.
Personal tools
Stuff