Skip to content

Commit

Permalink
Merge pull request #130 from CON-In-A-Box/ARIC_modules_init
Browse files Browse the repository at this point in the history
Aric - Add facility for things out of modules to be loaded with every page
  • Loading branch information
tskeeley authored Apr 5, 2018
2 parents cc76031 + 64c02ed commit b2a9d37
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
15 changes: 15 additions & 0 deletions functions/functions.inc
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,21 @@ if (is_file($SITECONFIG)) {

// Include NeonCRM for DB calls via API
require_once(__DIR__."/neon.inc");

// Load the base of all active modules
$modules = scandir($MODULESDIR);
foreach ($modules as $key => $value) {
if (!in_array($value, array(".", ".."))) {
if (in_array($value, $DISABLEDMODULES)) {
continue;
}
if (is_dir($MODULESDIR.DIRECTORY_SEPARATOR.$value)) {
if (is_file($MODULESDIR.DIRECTORY_SEPARATOR.$value.DIRECTORY_SEPARATOR.'init.inc')) {
require_once($MODULESDIR.DIRECTORY_SEPARATOR.$value.DIRECTORY_SEPARATOR.'init.inc');
}
}
}
}
} else {
// Give a default config file
echo '
Expand Down
12 changes: 12 additions & 0 deletions modules/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Optional Modules

Here is where the core built-in CIAB modules live and are developed. The design goal is to have each module as independent as possible however it is understood that it there will likely be dependancies between modules. So it will have to be handled that if a given module is disabled the other modules continue to function.

A module is enabled by default and can be disabled in the `Configuration` table in backend database. The database can define a `DISABLEDMODULES` field where the value will be a comma separate list of modules that are disabled in this instance.

Within the module there are a few files of special importance. None of these file are required and only need to be present if the module need to have the behavior described.

* `init.inc`: This file will be loaded with every web page processed. Here you can define functions that are being 'exported', for lack of a better term.
* `pages/panes.inc`: This is loaded when the main page is loaded. It describes all the panes to be added to the main screen. If your module displays panes on the main screen you will want to add the full function name to the `$homepage_panes` array. It is generally recommend you use name spacing. So something like `registration\panes\badges` for the function `badges` in the namespace `registration\panes`
* `pages/menubar.inc`: This is the file loaded when the menubar is being constructed. Generally if you implement this you will be wanting to add something to `$admin_menus` as that is what is used to construct the menubar at the top of the pages. If you use this then you will also have to define the html templates that are loaded when this menu item is selected:
* `pages/pre.inc, pages/head.inc, pages/body.inc`: These are the HTML templates to generate the page that is loaded when the menu item is selected from the menubar. They are not required though if the `body.inc` file is missing then the user will get a blank page when they select the menu bar item.

0 comments on commit b2a9d37

Please sign in to comment.