1 |
rodolico |
1 |
Modules Howto
|
|
|
2 |
|
|
|
3 |
Some basic guidelines on building modules for inclusion in CAMP.
|
|
|
4 |
|
|
|
5 |
By Convention:
|
|
|
6 |
|
|
|
7 |
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
|
|
|
8 |
Your module may add columns, or even whole tables into the database, but it must never alter existing columns
|
|
|
9 |
If you need a library of routines specialized to your module, use the name modulename.php
|
|
|
10 |
files with .html are parsed by php. The difference is convention alone: .html files are display, .php files are pure processing
|
|
|
11 |
|
|
|
12 |
Requirements:
|
|
|
13 |
|
|
|
14 |
Your module must reside a single directory tree under the modules subdirectory
|
|
|
15 |
All directories must have an index.html. This must conform to the standard page of CAMP
|
|
|
16 |
All files associated with your module must reside in the modules subdirectory
|
|
|
17 |
In all cases, insert the following statement into the database:
|
|
|
18 |
insert into _system ( group_name,key_name,theValue,added_date) values ( 'Modules', 'modulename', 'modules/modulename/', now() );
|
|
|
19 |
|
|
|
20 |
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:
|
|
|
21 |
database.php - Definition of the database structure in the format requried by admin edit
|
|
|
22 |
backupDB.php - script that will store tables
|
|
|
23 |
install.sql - Add all database changes
|
|
|
24 |
uninstall.sql - Remove all database changes
|
|
|
25 |
|
|
|
26 |
|
|
|
27 |
|
|
|
28 |
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:
|
|
|
29 |
/* primary module menu */
|
|
|
30 |
insert into menu (parent_id,caption,url) values (null,'Module Caption','path to index.html');
|
|
|
31 |
/* for submenus */
|
|
|
32 |
insert into menu (parent_id,caption,url) select menu_id,'Caption','/modules/moduledir/html file' from menu where caption = 'Module Caption';
|
|
|
33 |
|
|
|
34 |
If you have reports, insert them as follows:
|
|
|
35 |
insert into report ( name, query, parameters, screen_report ) values ('Report Name','Main Report Query','Parameters Definition', 1 or 0 );
|
|
|
36 |
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.
|
|
|
37 |
|
49 |
rodolico |
38 |
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:
|
|
|
39 |
insert into _system( group_name,key_name,theValue,added_date ) values ( 'device view', 'license', 'callable.php:view', now() );
|
|
|
40 |
The keys here
|
|
|
41 |
'device view' for group_name, which means this is a routine to be run during device view
|
|
|
42 |
'license' for key_name, meaning this is provided by the license module
|
|
|
43 |
'callable.php:view' - callable.php is included, then the view funciton is called
|
|
|
44 |
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.
|
|
|
45 |
|
|
|
46 |
|
|
|
47 |
|
|
|
48 |
|
1 |
rodolico |
49 |
Other:
|
|
|
50 |
|
|
|
51 |
All screens must use the following structure:
|
|
|
52 |
<?php
|
|
|
53 |
include_once( '../../header.php' );
|
|
|
54 |
include_once( './sysinfo.php' ); /* optional local library
|
|
|
55 |
INITIALIZATION SCRIPT
|
|
|
56 |
?>
|
|
|
57 |
<?xml version="1.0" encoding="utf-8"?>
|
|
|
58 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
|
|
|
59 |
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
|
60 |
<head>
|
|
|
61 |
<title>Computer Asset Management Program - MODULE NAME - PAGE NAME</title>
|
|
|
62 |
<link rel="stylesheet" type="text/css" href="../../camp.css">
|
|
|
63 |
</head>
|
|
|
64 |
<body>
|
|
|
65 |
<?php include_once('../../menu.php'); ?>
|
|
|
66 |
<div id="content">
|
|
|
67 |
CONTENT GOES HERE
|
|
|
68 |
</div>
|
|
|
69 |
</body>
|
|
|
70 |
</html>
|