Subversion Repositories computer_asset_manager_v1

Rev

Rev 1 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

Modules Howto

Some basic guidelines on building modules for inclusion in CAMP.

By Convention:

Your module should have a single word name, that is consistently used throughout. It will be the directory name, and some flags in the program itself
Your module may add columns, or even whole tables into the database, but it must never alter existing columns
If you need a library of routines specialized to your module, use the name modulename.php
files with .html are parsed by php. The difference is convention alone: .html files are display, .php files are pure processing

Requirements:

Your module must reside a single directory tree under the modules subdirectory
All directories must have an index.html. This must conform to the standard page of CAMP
All files associated with your module must reside in the modules subdirectory
In all cases, insert the following statement into the database:
 insert into _system ( group_name,key_name,theValue,added_date) values ( 'Modules', 'modulename', 'modules/modulename/', now() );

If you alter the structure of the database at all (reports and menu options do not count), the following files must exist in your modules directory:
   database.php - Definition of the database structure in the format requried by admin edit
   backupDB.php - script that will store tables
   install.sql - Add all database changes
   uninstall.sql - Remove all database changes
   


If you have screens that are accessible from a menu, use the following for each menu item you want to create. A normal approach will be to have one "module menu item" with all submenus using it as the parent:
 /* primary module menu */
 insert into menu (parent_id,caption,url) values (null,'Module Caption','path to index.html');
 /* for submenus */
 insert into menu (parent_id,caption,url) select menu_id,'Caption','/modules/moduledir/html file' from menu where caption = 'Module Caption';

If you have reports, insert them as follows:
   insert into report ( name, query, parameters, screen_report ) values ('Report Name','Main Report Query','Parameters Definition', 1 or 0 );
If the last parameter is a 1, this report will be included in the main report when a user drills down to a particular machine from the main menu.

As an alternative (though it may be used with the reports), create a file with callable PHP routines, then add an entry in the _system table as follows:
insert into _system( group_name,key_name,theValue,added_date ) values ( 'device view', 'license', 'callable.php:view', now() );
The keys here 
   'device view' for group_name, which means this is a routine to be run during device view
   'license' for key_name, meaning this is provided by the license module
   'callable.php:view' - callable.php is included, then the view funciton is called
      all view functions are called with one parameter, an array, which contains the current client_id, device_id, site_id and the path to the module. All except the latter may be missing depending on the screen.




Other:

All screens must use the following structure:
   <?php 
      include_once( '../../header.php' ); 
      include_once( './sysinfo.php' ); /* optional local library
      INITIALIZATION SCRIPT
   ?>
   <?xml version="1.0" encoding="utf-8"?>
   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
   <html xmlns="http://www.w3.org/1999/xhtml">
   <head>
      <title>Computer Asset Management Program - MODULE NAME - PAGE NAME</title>
      <link rel="stylesheet" type="text/css" href="../../camp.css">
   </head>
   <body>
      <?php include_once('../../menu.php'); ?>
      <div id="content">
         CONTENT GOES HERE
      </div>
   </body>
   </html>