====== Creating a Module ====== **This is meant as an overview of module creation for VTiger as well as associated notes.** As we all know, the documentation of the VTiger vtlib module and it's associated API is not quite what it should be. This is NOT unusual in OSS based Projects and unfortunately is also doomed to remain so. Therefore it is left to us to make due and help each other. So if you find any information that is either incorrect or missing just let me know. PLEASE!!! ===== Basic outline ===== To create a module the following steps need to be taken. - create your vtlib.Test.Create.Module1.php file so that vtlib can create/install your module in the first place. - test install your module & modify your vtlib.Test.Create.Module1.php script until all is correct. - create your Manifest.xml from the working vtlib.Test.Create.Module1.php so that the module can be installed. - in the module/ directory is where you can do live testing and modifications until all is working. - create your module package ===== vtlib.Test.html ===== Why they didn't go into details here I have no idea. Anyway, vtlib.Test.html is a simple html file which calls your vtlib.Test.Create.Module1.php script which contains your actual vtlib install script for your module. Both files can be named anything you want and, in fact, you don't even really need vtlib.Test.html. A simple call to vtlib.Test.Create.Module1.php is more than sufficient to get your module installed. As an example the first vtlib.Test.html that I used (just found it on a rep somewhere on the net): vtlib Test Suite vtiger CRM

vtlib - vtiger development Library

===== vtlib.Test.Create.Module1.php ===== As an example I created the file vtlib.Install.Repository.php (same as vtlib.Test.Create.Module1.php). This file installs the Module and does not actually create anything. You upload your module in the modules directory (in my case modules/Repository) and you call up http://localhost/vtigercrm/vtlib.Install.Repository.php. if an error occurred during the install you will be informed. If all went well you can take the information in the PHP script to form your Manifest.xml file for your install package. As an example the beta version of my install script for the Repository Module: name = 'Repository'; $module->save(); // Initialize all the tables required $module->initTables(); // Add the basic module block $block1 = new Vtiger_Block(); $block1->label = 'LBL_REPOSITORY_INFORMATION'; $module->addBlock($block1); // Add custom block (required to support Custom Fields) $block2 = new Vtiger_Block(); $block2->label = 'LBL_CUSTOM_INFORMATION'; $module->addBlock($block2); /** Create required fields and add to the block */ $field1 = new Vtiger_Field(); $field1->name = 'RepositoryID'; $field1->label = 'Repository ID'; $field1->table = $module->basetable; $field1->column = 'repositoryid'; $field1->columntype = 'int(11)'; $field1->uitype = 1; $field1->typeofdata = 'I~M'; $field1->presence = 0; $field1->quickcreate = 1; $field1->masseditable = 0; $field1->displaytype= 2; $block1->addField($field1); /** Creates the field and adds to block */ // Set at-least one field to identifier of module record $module->setEntityIdentifier($field1); $field2 = new Vtiger_Field(); $field2->name = 'RepositoryName'; $field2->label = 'Repository Name'; $field2->table = $module->basetable; $field2->column = 'repositoryname'; $field2->columntype = 'VARCHAR(255)'; $field2->uitype = 2; $field2->typeofdata = 'V~M'; $field2->presence = 0; $field2->quickcreate = 1; $field2->masseditable = 0; $field2->displaytype= 1; $block1->addField($field2); $field3 = new Vtiger_Field(); $field3->name = 'RepositoryType'; $field3->label = 'Repository Type'; $field3->columntype = 'VARCHAR(10)'; $field3->uitype = 15; $field3->typeofdata = 'V~M'; $field3->presence = 0; $field3->quickcreate = 1; $field3->masseditable = 0; $field3->displaytype= 1; $field3->setPicklistValues( Array ('cvs', 'git', 'ssh+svn', 'svn') ); $block1->addField($field3); /** table, column, label, set to default values */ $field4 = new Vtiger_Field(); $field4->name = 'RepositoryHost'; $field4->label= 'Repository Host'; $field4->columntype = 'VARCHAR(255)'; $field4->uitype = 2; $field4->typeofdata = 'V~M'; $field4->presence = 0; $field4->quickcreate = 1; $field4->masseditable = 0; $field4->displaytype= 1; $block1->addField($field4); $field5 = new Vtiger_Field(); $field5->name = 'RepositoryPort'; $field5->label = 'Repository Port'; $field5->columntype = 'VARCHAR(6)'; $field5->uitype = 53; $field5->typeofdata = 'V~M'; $field5->presence = 0; $field5->quickcreate = 1; $field5->masseditable = 0; $field5->displaytype= 1; $block1->addField($field5); $field6 = new Vtiger_Field(); $field6->name = 'RepositoryUser'; $field6->label= 'Repository User'; $field6->columntype = 'VARCHAR(32)'; $field6->uitype = 2; $field6->typeofdata = 'V~M'; $field6->presence = 0; $field6->quickcreate = 1; $field6->masseditable = 0; $field6->displaytype= 1; $block1->addField($field6); $field7 = new Vtiger_Field(); $field7->name = 'RepositoryPass'; $field7->label= 'Repository Password'; $field7->columntype = 'VARCHAR(32)'; $field7->uitype = 2; $field7->typeofdata = 'V~M'; $field7->presence = 0; $field7->quickcreate = 1; $field7->masseditable = 0; $field7->displaytype= 1; $block1->addField($field7); $field8 = new Vtiger_Field(); $field8->name = 'RepositoryPath'; $field8->label= 'Repository Path'; $field8->columntype = 'VARCHAR(255)'; $field8->uitype = 2; $field8->typeofdata = 'V~M'; $field8->presence = 0; $field8->quickcreate = 1; $field8->masseditable = 0; $field8->displaytype= 1; $block1->addField($field8); /** END */ // Create default custom filter (mandatory) $filter1 = new Vtiger_Filter(); $filter1->name = 'All'; $filter1->isdefault = true; $module->addFilter($filter1); // Add fields to the filter created $filter1->addField($field1)->addField($field2, 1)->addField($field5, 2); /** Associate other modules to this module */ $module->setRelatedList(Vtiger_Module::getInstance('Project'), 'Project', Array('ADD','SELECT')); /** Set sharing access of this module */ $module->setDefaultSharing('Private'); /** Enable and Disable available tools */ $module->enableTools(Array('Import', 'Export')); $module->disableTools('Merge'); ?> ===== vtlib.delete.php ===== This file deinstalls (hopefully cleanly) your installed module. below you see as an example the code to deinstall the Repository module (as you can see it must also be in the base directory of your VTiger install): delete(); } ?> ===== vtlib.download.php ===== ===== My vtlib.installer.php ===== Seeing as how I will be doing a few different modules I thought it would be easier for me to adopt a naming convention for the installer files and an installer to control it all. I now name all my vtlib.Test.Create.Module1.php files vtlib.Control..php. This way the following script (vtlib.installer.php) can find them and offer them for installation, deinstallation and downloading (this is a beta release and I will be prettying it up a bit later when I get time): delete(); } exit; }elseif($action == "download" && $newmodule !== ""){ require_once('vtlib/Vtiger/Package.php'); require_once('vtlib/Vtiger/Module.php'); $package = new Vtiger_Package(); $package->export(Vtiger_Module::getInstance($newmodule), 'test/vtlib', $newmodule.'.zip', true); exit; }else{ if (!$module_files = safe_glob("vtlib.Control.*.php")) $module_files=false; //print_r($module_files); ?> vtlib Module Install Suite vtiger CRM

vtlib - vtiger development Library