示例#1
0
 /**
  * Create this module instance
  * @access private
  */
 function __create()
 {
     global $adb;
     self::log("Creating Module {$this->name} ... STARTED");
     $this->id = $this->__getUniqueId();
     if (!$this->tabsequence) {
         $this->tabsequence = $this->__getNextSequence();
     }
     if (!$this->label) {
         $this->label = $this->name;
     }
     $customized = 1;
     // To indicate this is a Custom Module
     $this->__handleVtigerCoreSchemaChanges();
     $adb->pquery("INSERT INTO vtiger_tab (tabid,name,presence,tabsequence,tablabel,modifiedby,\n\t\t\tmodifiedtime,customized,ownedby,version,parent) VALUES (?,?,?,?,?,?,?,?,?,?,?)", array($this->id, $this->name, $this->presence, -1, $this->label, NULL, NULL, $customized, $this->ownedby, $this->version, $this->parent));
     $useisentitytype = $this->isentitytype ? 1 : 0;
     $adb->pquery('UPDATE vtiger_tab set isentitytype=? WHERE tabid=?', array($useisentitytype, $this->id));
     if (!Vtiger_Utils::CheckTable('vtiger_tab_info')) {
         Vtiger_Utils::CreateTable('vtiger_tab_info', '(tabid INT, prefname VARCHAR(256), prefvalue VARCHAR(256), FOREIGN KEY fk_1_vtiger_tab_info(tabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE ON UPDATE CASCADE)', true);
     }
     if ($this->minversion) {
         $tabResult = $adb->pquery("SELECT 1 FROM vtiger_tab_info WHERE tabid=? AND prefname='vtiger_min_version'", array($this->id));
         if ($adb->num_rows($tabResult) > 0) {
             $adb->pquery("UPDATE vtiger_tab_info SET prefvalue=? WHERE tabid=? AND prefname='vtiger_min_version'", array($this->minversion, $this->id));
         } else {
             $adb->pquery('INSERT INTO vtiger_tab_info(tabid, prefname, prefvalue) VALUES (?,?,?)', array($this->id, 'vtiger_min_version', $this->minversion));
         }
     }
     if ($this->maxversion) {
         $tabResult = $adb->pquery("SELECT 1 FROM vtiger_tab_info WHERE tabid=? AND prefname='vtiger_max_version'", array($this->id));
         if ($adb->num_rows($tabResult) > 0) {
             $adb->pquery("UPDATE vtiger_tab_info SET prefvalue=? WHERE tabid=? AND prefname='vtiger_max_version'", array($this->maxversion, $this->id));
         } else {
             $adb->pquery('INSERT INTO vtiger_tab_info(tabid, prefname, prefvalue) VALUES (?,?,?)', array($this->id, 'vtiger_max_version', $this->maxversion));
         }
     }
     Vtiger_Profile::initForModule($this);
     self::syncfile();
     if ($this->isentitytype) {
         Vtiger_Access::initSharing($this);
     }
     $moduleInstance = Vtiger_Module::getInstance($this->name);
     $parentTab = $this->parent;
     if (!empty($parentTab)) {
         $menuInstance = Vtiger_Menu::getInstance($parentTab);
         $menuInstance->addModule($moduleInstance);
     }
     self::log("Creating Module {$this->name} ... DONE");
 }
示例#2
0
 /**
  * Export Module Handler
  * @access private
  */
 function export_Module($moduleInstance)
 {
     global $adb;
     $moduleid = $moduleInstance->id;
     $sqlresult = $adb->query("SELECT * FROM vtiger_parenttabrel WHERE tabid = {$moduleid}");
     $parenttabid = $adb->query_result($sqlresult, 0, 'parenttabid');
     $menu = Vtiger_Menu::getInstance($parenttabid);
     $parent_name = $menu->label;
     $sqlresult = $adb->query("SELECT * FROM vtiger_tab WHERE tabid = {$moduleid}");
     $tabresultrow = $adb->fetch_array($sqlresult);
     $tabname = $tabresultrow['name'];
     $tablabel = $tabresultrow['tablabel'];
     $tabversion = isset($tabresultrow['version']) ? $tabresultrow['version'] : false;
     $this->openNode('module');
     $this->outputNode(date('Y-m-d H:i:s'), 'exporttime');
     $this->outputNode($tabname, 'name');
     $this->outputNode($tablabel, 'label');
     $this->outputNode($parent_name, 'parent');
     if (!$moduleInstance->isentitytype) {
         $this->outputNode('extension', 'type');
     }
     if ($tabversion) {
         $this->outputNode($tabversion, 'version');
     }
     // Export dependency information
     $this->export_Dependencies($moduleInstance);
     // Export module tables
     $this->export_Tables($moduleInstance);
     // Export module blocks
     $this->export_Blocks($moduleInstance);
     // Export module filters
     $this->export_CustomViews($moduleInstance);
     // Export Sharing Access
     $this->export_SharingAccess($moduleInstance);
     // Export Events
     $this->export_Events($moduleInstance);
     // Export Actions
     $this->export_Actions($moduleInstance);
     // Export Related Lists
     $this->export_RelatedLists($moduleInstance);
     // Export Custom Links
     $this->export_CustomLinks($moduleInstance);
     $this->closeNode('module');
 }
示例#3
0
 /**
  * Import Module
  * @access private
  */
 function import_Module()
 {
     $tabname = $this->_modulexml->name;
     $tablabel = $this->_modulexml->label;
     $parenttab = (string) $this->_modulexml->parent;
     $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->parent = $parenttab;
     $moduleInstance->isentitytype = $isextension != true;
     $moduleInstance->version = !$tabversion ? 0 : $tabversion;
     $moduleInstance->minversion = !$vtigerMinVersion ? false : $vtigerMinVersion;
     $moduleInstance->maxversion = !$vtigerMaxVersion ? false : $vtigerMaxVersion;
     $moduleInstance->save();
     if (!empty($parenttab)) {
         $menuInstance = Vtiger_Menu::getInstance($parenttab);
         $menuInstance->addModule($moduleInstance);
     }
     $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);
     $moduleInstance->initWebservice();
 }
include_once 'vtlib/Vtiger/Module.php';
$Vtiger_Utils_Log = true;
$MODULENAME = 'Tarifas';
$TABLENAME = 'vtiger_tarifas';
// $moduleInstance = Vtiger_Module::getInstance($MODULENAME);
// if ($moduleInstance || file_exists('modules/'.$MODULENAME)) {
//         echo "Module already present - choose a different name.";
// } else {
/////////////////////////INICIO MODULO///////////////////////////
$moduleInstance = new Vtiger_Module();
$moduleInstance->name = $MODULENAME;
$moduleInstance->parent = 'Sales';
$moduleInstance->save();
// Schema Setup
$moduleInstance->initTables();
$menuInstance = Vtiger_Menu::getInstance('Sales');
$menuInstance->addModule($moduleInstance);
/////////////////////////FIN MODULO///////////////////////////
/////////////////////////INICIO BLOQUE///////////////////////////
// Field Setup
$blockInstance = new Vtiger_Block();
$blockInstance->label = 'LBL_TARIFAS_INFORMATION';
$moduleInstance->addBlock($blockInstance);
$blockInstance2 = new Vtiger_Block();
$blockInstance2->label = 'LBL_CUSTOM_INFORMATION';
$moduleInstance->addBlock($blockInstance2);
/////////////////////////FIN BLOQUE///////////////////////////
/////////////////////////INICIO CAMPOS///////////////////////////
$fieldInstance1 = new Vtiger_Field();
$fieldInstance1->name = 'codigo';
$fieldInstance1->label = 'Codigo';
$menuInstance->updateMenu($moduleInstance);
//Fin Instanciacion del modulo Cuentas en el Parent Tab de Agencia
//Inicio Instanciacion del modulo Tipos de Comisiones en el Parent Tab de Agencia
$moduleInstance = Vtiger_Module::getInstance('RegistroDeVentas');
$moduleInstance->parent = 'Agencia';
$moduleInstance->save();
$menuInstance = Vtiger_Menu::getInstance('Agencia');
$menuInstance->updateMenu($moduleInstance);
//Fin Instanciacion del modulo Tipos de Comisiones en el Parent Tab de Agencia
//Inicio Instanciacion del modulo Comisiones Agencia en el Parent Tab de Agencia
$moduleInstance = Vtiger_Module::getInstance('RegistroDePagos');
$moduleInstance->parent = 'Agencia';
$moduleInstance->save();
$menuInstance = Vtiger_Menu::getInstance('Agencia');
$menuInstance->updateMenu($moduleInstance);
//Fin Instanciacion del modulo Comisiones Agencia en el Parent Tab de Agencia
//Inicio Instanciacion del modulo Tarifas en el Parent Tab de Agencia
$moduleInstance = Vtiger_Module::getInstance('VentaDeProductos');
$moduleInstance->parent = 'Agencia';
$moduleInstance->save();
$menuInstance = Vtiger_Menu::getInstance('Agencia');
$menuInstance->updateMenu($moduleInstance);
//Fin Instanciacion del modulo Tarifas en el Parent Tab de Agencia
//Inicio Instanciacion del modulo Tarifas en el Parent Tab de Agencia
$moduleInstance = Vtiger_Module::getInstance('Envios');
$moduleInstance->parent = 'Agencia';
$moduleInstance->save();
$menuInstance = Vtiger_Menu::getInstance('Agencia');
$menuInstance->updateMenu($moduleInstance);
//Fin Instanciacion del modulo Tarifas en el Parent Tab de Agencia
echo "OK\n";
示例#6
0
chdir('..');
$Vtiger_Utils_Log = true;
include_once 'vtlib/Vtiger/Menu.php';
include_once 'vtlib/Vtiger/Module.php';
include_once 'modules/PickList/DependentPickListUtils.php';
include_once 'include/utils/CommonUtils.php';
$module_name = 'Sample';
$table_name = 'vtiger_sample';
$main_name = "titlename";
$main_id = "sampleid";
//module作成
$module = new Vtiger_Module();
$module->name = $module_name;
$module->save();
$module->initTables($table_name, $main_id);
$menu = Vtiger_Menu::getInstance('Tools');
$menu->addModule($module);
// block作成
$blockInstance = new Vtiger_Block();
$blockInstance->label = 'LBL_SAMPLE_INFORMATION';
$module->addBlock($blockInstance);
// field作成
$field = new Vtiger_Field();
$field->name = 'TitleName';
$field->table = 'vtiger_sample';
$field->column = 'titlename';
$field->columntype = 'VARCHAR(255)';
$field->uitype = 1;
$field->typeofdata = 'V~M';
$blockInstance->addField($field);
$filter_field1 = $field;
include_once 'vtlib/Vtiger/Menu.php';
include_once 'vtlib/Vtiger/Module.php';
// Create module instance and save it first
$module = new Vtiger_Module();
$module->name = 'Deliverynote';
$module->save();
// Initialize all the tables required
$module->initTables();
/**
 * Creates the following table:
 * vtiger_deliverynote  (deliverynoteid INTEGER)
 * vtiger_deliverynotecf(deliverynoteid INTEGER PRIMARY KEY)
 * vtiger_deliverynotegrouprel((deliverynoteid INTEGER PRIMARY KEY, groupname VARCHAR(100))
 */
// Add the module to the Menu (entry point from UI)
$menu = Vtiger_Menu::getInstance('Inventory');
$menu->addModule($module);
// Add the basic module block
$block1 = new Vtiger_Block();
$block1->label = 'LBL_DELIVERY_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 = 'deliverynotename';
$field1->label = 'Delivery Order';
$field1->table = $module->basetable;
$field1->column = 'deliverynotename';
$menuInstance->updateMenu($moduleInstance);
//Fin Instanciacion del modulo Cuentas en el Parent Tab de Satelites
//Inicio Instanciacion del modulo Terminales en el Parent Tab de Satelites
$moduleInstance = Vtiger_Module::getInstance('Terminales');
$moduleInstance->parent = 'Satelites';
$moduleInstance->save();
$menuInstance = Vtiger_Menu::getInstance('Satelites');
$menuInstance->updateMenu($moduleInstance);
//Fin Instanciacion del modulo Terminales en el Parent Tab de Satelites
//Inicio Instanciacion del modulo Tipos de Comisiones en el Parent Tab de Satelites
$moduleInstance = Vtiger_Module::getInstance('TiposdeComisiones');
$moduleInstance->parent = 'Satelites';
$moduleInstance->save();
$menuInstance = Vtiger_Menu::getInstance('Satelites');
$menuInstance->updateMenu($moduleInstance);
//Fin Instanciacion del modulo Tipos de Comisiones en el Parent Tab de Satelites
//Inicio Instanciacion del modulo Comisiones Satelites en el Parent Tab de Satelites
$moduleInstance = Vtiger_Module::getInstance('ComisionSatelites');
$moduleInstance->parent = 'Satelites';
$moduleInstance->save();
$menuInstance = Vtiger_Menu::getInstance('Satelites');
$menuInstance->updateMenu($moduleInstance);
//Fin Instanciacion del modulo Comisiones Satelites en el Parent Tab de Satelites
//Inicio Instanciacion del modulo Tarifas en el Parent Tab de Satelites
$moduleInstance = Vtiger_Module::getInstance('Tarifas');
$moduleInstance->parent = 'Satelites';
$moduleInstance->save();
$menuInstance = Vtiger_Menu::getInstance('Satelites');
$menuInstance->updateMenu($moduleInstance);
//Fin Instanciacion del modulo Tarifas en el Parent Tab de Satelites
echo "OK\n";