示例#1
0
 public static function installSelectedOptionalModules($selected_modules, $source_directory = '', $destination_directory = '')
 {
     require_once 'vtlib/Vtiger/Package.php';
     require_once 'vtlib/Vtiger/Module.php';
     require_once 'include/utils/utils.php';
     $selected_modules = explode(":", $selected_modules);
     $languagePacks = array();
     if ($handle = opendir('packages/vtiger/optional')) {
         while (false !== ($file = readdir($handle))) {
             $filename_arr = explode(".", $file);
             if ($filename_arr[count($filename_arr) - 1] != 'zip') {
                 continue;
             }
             $packagename = $filename_arr[0];
             $packagepath = "packages/vtiger/optional/{$file}";
             $package = new Vtiger_Package();
             $module = $package->getModuleNameFromZip($packagepath);
             if (!empty($packagename) && in_array($module, $selected_modules)) {
                 if ($package->isLanguageType($packagepath)) {
                     $languagePacks[$module] = $packagepath;
                     continue;
                 }
                 if ($module != null) {
                     if ($package->isModuleBundle()) {
                         $unzip = new Vtiger_Unzip($packagepath);
                         $unzip->unzipAllEx($package->getTemporaryFilePath());
                         $moduleInfoList = $package->getAvailableModuleInfoFromModuleBundle();
                         foreach ($moduleInfoList as $moduleInfo) {
                             $moduleInfo = (array) $moduleInfo;
                             $packagepath = $package->getTemporaryFilePath($moduleInfo['filepath']);
                             $subModule = new Vtiger_Package();
                             $subModuleName = $subModule->getModuleNameFromZip($packagepath);
                             $moduleInstance = Vtiger_Module::getInstance($subModuleName);
                             if ($moduleInstance) {
                                 updateVtlibModule($subModuleName, $packagepath);
                             } else {
                                 installVtlibModule($subModuleName, $packagepath);
                             }
                         }
                     } else {
                         $moduleInstance = Vtiger_Module::getInstance($module);
                         if ($moduleInstance) {
                             updateVtlibModule($module, $packagepath);
                         } else {
                             installVtlibModule($module, $packagepath);
                         }
                     }
                 }
             }
         }
         closedir($handle);
     }
     foreach ($languagePacks as $module => $packagepath) {
         installVtlibModule($module, $packagepath);
         continue;
     }
 }