protected function create($moduleInformation) { $moduleInformation['entityfieldname'] = strtolower($this->toAlphaNumeric($moduleInformation['entityfieldlabel'])); $module = new Vtiger_Module(); $module->name = $moduleInformation['name']; $module->parent=$moduleInformation['parent']; $module->save(); $module->initTables(); $block = new Vtiger_Block(); $block->label = 'LBL_'. strtoupper($module->name) . '_INFORMATION'; $module->addBlock($block); $blockcf = new Vtiger_Block(); $blockcf->label = 'LBL_CUSTOM_INFORMATION'; $module->addBlock($blockcf); $field1 = new Vtiger_Field(); $field1->name = $moduleInformation['entityfieldname']; $field1->label= $moduleInformation['entityfieldlabel']; $field1->uitype= 2; $field1->column = $field1->name; $field1->columntype = 'VARCHAR(255)'; $field1->typeofdata = 'V~M'; $block->addField($field1); $module->setEntityIdentifier($field1); /** Common fields that should be in every module, linked to vtiger CRM core table */ $field2 = new Vtiger_Field(); $field2->name = 'assigned_user_id'; $field2->label = 'Assigned To'; $field2->table = 'vtiger_crmentity'; $field2->column = 'smownerid'; $field2->uitype = 53; $field2->typeofdata = 'V~M'; $block->addField($field2); $field3 = new Vtiger_Field(); $field3->name = 'createdtime'; $field3->label= 'Created Time'; $field3->table = 'vtiger_crmentity'; $field3->column = 'createdtime'; $field3->uitype = 70; $field3->typeofdata = 'T~O'; $field3->displaytype= 2; $block->addField($field3); $field4 = new Vtiger_Field(); $field4->name = 'modifiedtime'; $field4->label= 'Modified Time'; $field4->table = 'vtiger_crmentity'; $field4->column = 'modifiedtime'; $field4->uitype = 70; $field4->typeofdata = 'T~O'; $field4->displaytype= 2; $block->addField($field4); // 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($field3, 2); // Set sharing access of this module $module->setDefaultSharing(); // Enable and Disable available tools $module->enableTools(Array('Import', 'Export', 'Merge')); // Initialize Webservice support $module->initWebservice(); // Create files $this->createFiles($module, $field1); }
/** * Import Module * @access private */ function import_Module() { $tabname = $this->_modulexml->name; $tablabel = $this->_modulexml->label; $tabversion = $this->_modulexml->version; $isextension = false; if (!empty($this->_modulexml->type)) { $type = strtolower($this->_modulexml->type); if ($type == 'extension' || $type == 'language') { $isextension = true; } } $vtigerMinVersion = $this->_modulexml->dependencies->vtiger_version; $vtigerMaxVersion = $this->_modulexml->dependencies->vtiger_max_version; $moduleInstance = new Vtiger_Module(); $moduleInstance->name = $tabname; $moduleInstance->label = $tablabel; $moduleInstance->isentitytype = $isextension != true; $moduleInstance->version = !$tabversion ? 0 : $tabversion; $moduleInstance->minversion = !$vtigerMinVersion ? false : $vtigerMinVersion; $moduleInstance->maxversion = !$vtigerMaxVersion ? false : $vtigerMaxVersion; if ($type != 'update') { $moduleInstance->save(); $moduleInstance->initWebservice(); $this->import_Tables($this->_modulexml); $this->import_Blocks($this->_modulexml, $moduleInstance); $this->import_CustomViews($this->_modulexml, $moduleInstance); $this->import_SharingAccess($this->_modulexml, $moduleInstance); $this->import_Events($this->_modulexml, $moduleInstance); $this->import_Actions($this->_modulexml, $moduleInstance); $this->import_RelatedLists($this->_modulexml, $moduleInstance); $this->import_CustomLinks($this->_modulexml, $moduleInstance); $this->import_CronTasks($this->_modulexml); Vtiger_Module::fireEvent($moduleInstance->name, Vtiger_Module::EVENT_MODULE_POSTINSTALL); } else { $this->import_update($this->_modulexml); } }
public static function createModule($moduleInformation) { $moduleInformation['entityfieldname'] = strtolower(self::toAlphaNumeric($moduleInformation['entityfieldname'])); $module = new Vtiger_Module(); $module->name = ucfirst($moduleInformation['module_name']); $module->label = $moduleInformation['module_label']; $module->type = $moduleInformation['entitytype']; $module->save(); $module->initTables(); $block = new Vtiger_Block(); $block->label = 'LBL_' . $module->name . '_INFORMATION'; $module->addBlock($block); $blockcf = new Vtiger_Block(); $blockcf->label = 'LBL_CUSTOM_INFORMATION'; $module->addBlock($blockcf); $field1 = new Vtiger_Field(); $field1->name = $moduleInformation['entityfieldname']; $field1->label = $moduleInformation['entityfieldlabel']; $field1->uitype = 2; $field1->column = $field1->name; $field1->columntype = 'VARCHAR(255)'; $field1->typeofdata = 'V~M'; $block->addField($field1); $module->setEntityIdentifier($field1); /** Common fields that should be in every module, linked to vtiger CRM core table */ $field2 = new Vtiger_Field(); $field2->name = 'number'; $field2->label = 'Numer'; $field2->column = 'number'; $field2->table = $module->basetable; $field2->uitype = 4; $field2->typeofdata = 'V~O'; $field2->columntype = 'varchar(32)'; $block->addField($field2); $field3 = new Vtiger_Field(); $field3->name = 'assigned_user_id'; $field3->label = 'Assigned To'; $field3->table = 'vtiger_crmentity'; $field3->column = 'smownerid'; $field3->uitype = 53; $field3->typeofdata = 'V~M'; $block->addField($field3); $field4 = new Vtiger_Field(); $field4->name = 'createdtime'; $field4->label = 'Created Time'; $field4->table = 'vtiger_crmentity'; $field4->column = 'createdtime'; $field4->uitype = 70; $field4->typeofdata = 'DT~O'; $field4->displaytype = 2; $block->addField($field4); $field5 = new Vtiger_Field(); $field5->name = 'modifiedtime'; $field5->label = 'Modified Time'; $field5->table = 'vtiger_crmentity'; $field5->column = 'modifiedtime'; $field5->uitype = 70; $field5->typeofdata = 'DT~O'; $field5->displaytype = 2; $block->addField($field5); // 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($field3, 2)->addField($field4, 2); // Set sharing access of this module $module->setDefaultSharing(); // Enable and Disable available tools $module->enableTools(array('Import', 'Export', 'Merge')); // Initialize Webservice support $module->initWebservice(); // Create files $module->createFiles($field1); $ModuleInstance = CRMEntity::getInstance($module->name); $ModuleInstance->setModuleSeqNumber('configure', $module->name, 'N', '1'); }