Exemple #1
0
 /**
  * Check if vtiger CRM support Events
  */
 static function hasSupport()
 {
     if (self::$is_supported === '') {
         self::$is_supported = Vtiger_Utils::checkTable('vtiger_eventhandlers');
     }
     return self::$is_supported;
 }
 /**
  * Import Tables of the module
  * @access private
  */
 function import_Tables($modulenode)
 {
     if (empty($modulenode->tables) || empty($modulenode->tables->table)) {
         return;
     }
     $adb = PearDatabase::getInstance();
     $adb->query('SET FOREIGN_KEY_CHECKS = 0;');
     /**
      * Record the changes in schema file
      */
     if (file_exists("modules/{$modulenode->name}")) {
         $fileToOpen = "modules/{$modulenode->name}/schema.xml";
     } else {
         if (file_exists("modules/Settings/{$modulenode->name}")) {
             $fileToOpen = "modules/Settings/{$modulenode->name}/schema.xml";
         }
     }
     $schemafile = fopen($fileToOpen, 'w');
     if ($schemafile) {
         fwrite($schemafile, "<?xml version='1.0'?>\n");
         fwrite($schemafile, "<schema>\n");
         fwrite($schemafile, "\t<tables>\n");
     }
     // Import the table via queries
     foreach ($modulenode->tables->table as $tablenode) {
         $tablename = $tablenode->name;
         $tablesql = "{$tablenode->sql}";
         // Convert to string format
         // Save the information in the schema file.
         fwrite($schemafile, "\t\t<table>\n");
         fwrite($schemafile, "\t\t\t<name>{$tablename}</name>\n");
         fwrite($schemafile, "\t\t\t<sql><![CDATA[{$tablesql}]]></sql>\n");
         fwrite($schemafile, "\t\t</table>\n");
         // Avoid executing SQL that will DELETE or DROP table data
         if (Vtiger_Utils::IsCreateSql($tablesql)) {
             if (!Vtiger_Utils::checkTable($tablename)) {
                 self::log("SQL: {$tablesql} ... ", false);
                 Vtiger_Utils::ExecuteQuery($tablesql);
                 self::log("DONE");
             }
         } else {
             if (Vtiger_Utils::IsDestructiveSql($tablesql)) {
                 self::log("SQL: {$tablesql} ... SKIPPED");
             } else {
                 self::log("SQL: {$tablesql} ... ", false);
                 Vtiger_Utils::ExecuteQuery($tablesql);
                 self::log("DONE");
             }
         }
     }
     if ($schemafile) {
         fwrite($schemafile, "\t</tables>\n");
         fwrite($schemafile, "</schema>\n");
         fclose($schemafile);
     }
     $adb->query('SET FOREIGN_KEY_CHECKS = 1;');
 }
Exemple #3
0
 /**
  * Import Tables of the module
  * @access private
  */
 function import_Tables($modulenode)
 {
     if (empty($modulenode->tables) || empty($modulenode->tables->table)) {
         return;
     }
     /**
      * Record the changes in schema file
      */
     $schemafile = @fopen("modules/{$modulenode->name}/schema.xml", 'w');
     if ($schemafile) {
         fwrite($schemafile, "<?xml version='1.0'?>\n");
         fwrite($schemafile, "<schema>\n");
         fwrite($schemafile, "\t<tables>\n");
     }
     // Import the table via queries
     foreach ($modulenode->tables->table as $tablenode) {
         $tablename = $tablenode->name;
         $tablesql = "{$tablenode->sql}";
         // Convert to string format
         // Save the information in the schema file.
         if ($schemafile) {
             fwrite($schemafile, "\t\t<table>\n");
             fwrite($schemafile, "\t\t\t<name>{$tablename}</name>\n");
             fwrite($schemafile, "\t\t\t<sql><![CDATA[{$tablesql}]]></sql>\n");
             fwrite($schemafile, "\t\t</table>\n");
         }
         // Avoid executing SQL that will DELETE or DROP table data
         if (Vtiger_Utils::IsCreateSql($tablesql)) {
             if (!Vtiger_Utils::checkTable($tablename)) {
                 self::log("SQL: {$tablesql} ... ", false);
                 Vtiger_Utils::ExecuteQuery($tablesql);
                 self::log("DONE");
             }
         } else {
             if (Vtiger_Utils::IsDestructiveSql($tablesql)) {
                 self::log("SQL: {$tablesql} ... SKIPPED");
             } else {
                 self::log("SQL: {$tablesql} ... ", false);
                 Vtiger_Utils::ExecuteQuery($tablesql);
                 self::log("DONE");
             }
         }
     }
     if ($schemafile) {
         fwrite($schemafile, "\t</tables>\n");
         fwrite($schemafile, "</schema>\n");
         fclose($schemafile);
     }
 }
Exemple #4
0
 /**
  *
  * @param String $packagepath - path to the package file.
  * @return Array
  */
 static function getOptionalModuleDetails($package, $optionalModulesInfo)
 {
     global $optionalModuleStrings;
     $moduleUpdateVersion = $package->getVersion();
     $moduleForVtigerVersion = $package->getDependentVtigerVersion();
     $moduleMaxVtigerVersion = $package->getDependentMaxVtigerVersion();
     if ($package->isLanguageType()) {
         $type = 'language';
     } else {
         $type = 'module';
     }
     $moduleDetails = null;
     $moduleName = $package->getModuleName();
     if ($moduleName != null) {
         $moduleDetails = array();
         $moduleDetails['description'] = $optionalModuleStrings[$moduleName . '_description'];
         if (Vtiger_Version::check($moduleForVtigerVersion, '>=') && Vtiger_Version::check($moduleMaxVtigerVersion, '<')) {
             $moduleDetails['selected'] = true;
             $moduleDetails['enabled'] = true;
         } else {
             $moduleDetails['selected'] = false;
             $moduleDetails['enabled'] = false;
         }
         $migrationAction = 'install';
         if (!$package->isLanguageType()) {
             $moduleInstance = null;
             if (Vtiger_Utils::checkTable('vtiger_tab')) {
                 $moduleInstance = Vtiger_Module::getInstance($moduleName);
             }
             if ($moduleInstance) {
                 $migrationAction = 'update';
                 if (version_compare($moduleUpdateVersion, $moduleInstance->version, '>=')) {
                     $moduleDetails['enabled'] = false;
                 }
             }
         } else {
             if (Vtiger_Utils::CheckTable(Vtiger_Language::TABLENAME)) {
                 $languageList = array_keys(Vtiger_Language::getAll());
                 $prefix = $package->getPrefix();
                 if (in_array($prefix, $languageList)) {
                     $migrationAction = 'update';
                 }
             }
         }
         $optionalModulesInfo[$migrationAction][$type][$moduleName] = $moduleDetails;
     }
     return $optionalModulesInfo;
 }