</> Developers Guide to Funraisin

Admin Modules

The Funraisin admin consists of different modules that can be enabled / disabled on a site by site basis. Each module provides certain administrative access to a specific part of the site e.g. Events or User Accounts

Anatomy of a Module

All Funraisin modules reside in a modules directory which sits in the site's document root e.g.  /var/www/vhosts/domain.com/application/modules/module-name and each module itself consists of directory containing a minum of 3 files

This is the view file which is used to render any html required by the module.

The controller file used to process any data and load the above view

Controls the module navigation options

As well as being stored on the server a module also exists in the database in the table "CMS_modules" which allows for account types to be assigned access to specific modules.

Module URL Structure

The url for each module will be https://www.domain.com/management/module-name and this wil load the above files automatically.

If you require addtional files you can just use include("file.php") or require "file.php" within your main controller and as long as they are in the same directory as the controller, they will be loaded into memory.

There are also a few additional url based helpers to make it easier to manage.

To allow you to manage specific records you can use module-name?ID=some-number and the ID will then be available as a global variable using $GLOBALS["CMSid"];

To help cater for different actions e.g. saving vs editing you can use https://www.domain.com/management/module-name/$task/$subtask with $task and $subtask being entirely optional.

$task if provided will become available as a global variable using $GLOBALS["CMStask"]

$subtask if provided will become available using $GLOBALS["subtask"]

The Controller

The module controller is loaded first and this is the file that does all the hard work such as connecting to the database and processing any data.

The first part of the controller should always be to test if the logged in Admin user is permitted to access the module and this can be done via the following code

$ModID=MySQLResult("SELECT mod_id FROM CMS_modules WHERE mod_short_name='".$GLOBALS["CMSmod"]."'","mod_id");
if(!in_array($ModID,$Access)) {

Once we know the admin user is permitted to access the module you can then use the $GLOBAL variable "CMStask" to control your actions like below

switch($GLOBALS["CMStask"]) {
    case "save":
    //database query to process $_POST data

    // function to load default view

The View

The view file is simply a standard PHP file however for the purpose of clean code it's best to keep the HTML rendering separate from the PHP processing as per any good MVC platform.

HTML rendering is handled via PHP functions which are called from the Controller, so for the above example the view file would contain a function such as


Function DisplayDashboard() {