kaolak : documentation previous | next | table of contents 


3.5 Modules
Appart from kaolak core objects (MySqlDb, Kaolak, Node ; residing in /kaolak/inc/) all objects are included in modules.
Kaolak's base modules are the following :
Module Main object Sub objects
User User Session
Person
Company
City
State
Country
Branch Branch Lang
Document Document Mime_type
For module-specific information see section 4 Modules
Module structure
A module is a set of files residing under /kaolak/modules/module_name/

requirements
  • Must include a file named add-module.php runnable by superuser in supergui that registers module ie containing the following :
    require_once("$DOCUMENT_ROOT/kaolak/inc/node.php");
    
    $kaolak = new Kaolak;
    
    if (strcmp($SCRIPT_NAME,'/kaolak/gui/superadmin/add-module.php')) $kaolak->throwError('premission denied');
    
    $kaolak->addModule('module_name');
    
    $kaolak->addNodeType('module_name');
    
  • Must include Class file
  • Class name must be same as module with first letter uppercase
  • Must be subclass of Node
  • Must be instantiable in the following manner :
    $node     = new Node($nodeId);
    $nodeType = $node->getTypeName(1);
    
    require_once("$DOCUMENT_ROOT/kaolak/modules/$nodeType/$nodeType.php");
    
    $objClass = ucfirst($nodeType); // capitalize node type first letter to get class name
    $node     = new $objClass($nodeId);
    
  • If initialization code is to be run when module is attached to branch (eg creating user groups, directories), must include file branch-add.php containing the following :
    require_once("$DOCUMENT_ROOT/kaolak/inc/node.php");
    
    $kaolak = new Kaolak;
    
    if (strcmp($SCRIPT_NAME,'/kaolak/gui/superadmin/branch-info.php')) $kaolak->throwError('premission denied');
    




 previous | next | table of contents