Ejemplo n.º 1
0
	/**
	 * Function to get package of this instance
	 * @return <Vtiger_Package> package object
	 */
	public function getPackage() {
		$packageModel = new Vtiger_Package();
		$moduleName = $packageModel->getModuleNameFromZip(self::getUploadDirectory(). '/' .$this->getFileName());
		if ($moduleName) {
			return $packageModel;
		}
		return false;
	}
Ejemplo n.º 2
0
 public function importUserModuleStep2(Vtiger_Request $request)
 {
     $viewer = $this->getViewer($request);
     $uploadDir = Settings_ModuleManager_Module_Model::getUploadDirectory();
     $qualifiedModuleName = $request->getModule(false);
     $uploadFile = 'usermodule_' . time() . '.zip';
     $uploadFileName = "{$uploadDir}/{$uploadFile}";
     $error = '';
     checkFileAccess($uploadDir);
     if (!move_uploaded_file($_FILES['moduleZip']['tmp_name'], $uploadFileName)) {
         $error = 'LBL_ERROR_MOVE_UPLOADED_FILE';
     } else {
         $package = new Vtiger_Package();
         $importModuleName = $package->getModuleNameFromZip($uploadFileName);
         $importModuleDepVtVersion = $package->getDependentVtigerVersion();
         if ($importModuleName == null) {
             $error = $package->_errorText;
             checkFileAccessForDeletion($uploadFileName);
             unlink($uploadFileName);
         } else {
             // We need these information to push for Update if module is detected to be present.
             $moduleLicence = vtlib_purify($package->getLicense());
             $viewer->assign('MODULEIMPORT_FILE', $uploadFile);
             $viewer->assign('MODULEIMPORT_TYPE', $package->type());
             $viewer->assign('MODULEIMPORT_NAME', $importModuleName);
             $viewer->assign('MODULEIMPORT_PACKAGE', $package);
             $viewer->assign('MODULEIMPORT_DEP_VTVERSION', $importModuleDepVtVersion);
             $viewer->assign('MODULEIMPORT_LICENSE', $moduleLicence);
             $viewer->assign('MODULEIMPORT_PARAMETERS', $package->getParameters());
             if (!$package->isLanguageType() && !$package->isUpdateType() && !$package->isModuleBundle()) {
                 $moduleInstance = Vtiger_Module::getInstance($importModuleName);
                 $moduleimport_exists = $moduleInstance ? "true" : "false";
                 $moduleimport_dir_name = "modules/{$importModuleName}";
                 $moduleimport_dir_exists = is_dir($moduleimport_dir_name) ? "true" : "false";
                 $viewer->assign('MODULEIMPORT_EXISTS', $moduleimport_exists);
                 $viewer->assign('MODULEIMPORT_DIR', $moduleimport_dir_name);
                 $viewer->assign('MODULEIMPORT_DIR_EXISTS', $moduleimport_dir_exists);
             }
         }
     }
     $viewer->assign('MODULEIMPORT_ERROR', $error);
     $viewer->view('ImportUserModuleStep2.tpl', $qualifiedModuleName);
 }
Ejemplo n.º 3
0
function installOptionalModules($selected_modules)
{
    global $log;
    require_once 'vtlib/Vtiger/Package.php';
    require_once 'vtlib/Vtiger/Module.php';
    $selected_modules = split(":", $selected_modules);
    if ($handle = opendir('packages/5.1.0/optional')) {
        while (false !== ($file = readdir($handle))) {
            $filename_arr = explode(".", $file);
            $packagename = $filename_arr[0];
            if (!empty($packagename)) {
                $packagepath = "packages/5.1.0/optional/{$file}";
                $package = new Vtiger_Package();
                $module = $package->getModuleNameFromZip($packagepath);
                if ($module != null) {
                    $moduleInstance = Vtiger_Module::getInstance($module);
                    if (in_array($packagename, $selected_modules)) {
                        if ($moduleInstance) {
                            initUpdateVtlibModule($module, $packagepath);
                        } else {
                            installVtlibModule($packagename, $packagepath);
                        }
                    } elseif ($moduleInstance) {
                        initUpdateVtlibModule($module, $packagepath);
                        vtlib_toggleModuleAccess((string) $module, false);
                    }
                }
            }
        }
        closedir($handle);
    }
}
Ejemplo n.º 4
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;
     }
 }
Ejemplo n.º 5
0
$smarty->assign("THEME", $theme);
$smarty->assign("IMAGE_PATH", "themes/{$theme}/images/");
global $modulemanager_uploaddir;
// Defined in modules/Settings/ModuleManager.php
if ($module_import_step == 'Step2') {
    if (!is_dir($modulemanager_uploaddir)) {
        mkdir($modulemanager_uploaddir);
    }
    $uploadfile = "usermodule_" . time() . ".zip";
    $uploadfilename = "{$modulemanager_uploaddir}/{$uploadfile}";
    checkFileAccess($modulemanager_uploaddir);
    if (!move_uploaded_file($_FILES['module_zipfile']['tmp_name'], $uploadfilename)) {
        $smarty->assign("MODULEIMPORT_FAILED", "true");
    } else {
        $package = new Vtiger_Package();
        $moduleimport_name = $package->getModuleNameFromZip($uploadfilename);
        if ($moduleimport_name == null) {
            $smarty->assign("MODULEIMPORT_FAILED", "true");
            $smarty->assign("MODULEIMPORT_FILE_INVALID", "true");
        } else {
            if (!$package->isLanguageType()) {
                $moduleInstance = Vtiger_Module::getInstance($moduleimport_name);
                $moduleimport_exists = $moduleInstance ? "true" : "false";
                $moduleimport_dir_name = "modules/{$moduleimport_name}";
                $moduleimport_dir_exists = is_dir($moduleimport_dir_name) ? "true" : "false";
                $smarty->assign("MODULEIMPORT_EXISTS", $moduleimport_exists);
                $smarty->assign("MODULEIMPORT_DIR", $moduleimport_dir_name);
                $smarty->assign("MODULEIMPORT_DIR_EXISTS", $moduleimport_dir_exists);
            }
            $moduleimport_dep_vtversion = $package->getDependentVtigerVersion();
            $moduleimport_license = $package->getLicense();
Ejemplo n.º 6
0
     $entryName = $za->getNameIndex($i);
     $firstSlash = strpos($entryName, '/');
     if ($entryName === 'manifest.xml' || $entryName === './manifest.xml' || $firstSlash === false) {
         $za->unchangeAll();
         break;
     }
     $newEntryName = substr($entryName, $firstSlash + 1);
     if ($newEntryName !== false) {
         $za->renameIndex($i, $newEntryName);
     } else {
         $za->deleteIndex($i);
     }
 }
 $za->close();
 $package = new Vtiger_Package();
 $moduleupdate_name = $package->getModuleNameFromZip($uploadfilename);
 if ($moduleupdate_name == null) {
     $smarty->assign("MODULEUPDATE_FAILED", "true");
     $smarty->assign("MODULEUPDATE_FILE_INVALID", "true");
 } else {
     if (!$package->isLanguageType() && $moduleupdate_name != $target_modulename) {
         $smarty->assign("MODULEUPDATE_FAILED", "true");
         $smarty->assign("MODULEUPDATE_NAME_MISMATCH", "true");
     } else {
         if ($package->isLanguageType() && trim($package->xpath_value('prefix')) != $target_modulename) {
             $smarty->assign("MODULEUPDATE_FAILED", "true");
             $smarty->assign("MODULEUPDATE_NAME_MISMATCH", "true");
         } else {
             $moduleupdate_dep_vtversion = $package->getDependentVtigerVersion();
             $moduleupdate_license = $package->getLicense();
             $moduleupdate_version = $package->getVersion();
Ejemplo n.º 7
0
	public function handle() {
		if ($this->interactive) {
			echo "------------------------------------ >>> UPDATE MODULE <<< ---\n";
			do {
				$path = $this->prompt("Enter package path: ", self::PROMPT_PATH);
				if (file_exists($path)) {
					break;
				}
				echo "ERROR: " . $path . " - file not found, try another.\n";
			} while (true);
		} else {
			$path = array_shift($this->arguments);
		}
		
		if (file_exists($path)) {
			$package = new Vtiger_Package();
			$module  = $package->getModuleNameFromZip($path);
			
			$moduleInstance = Vtiger_Module::getInstance($module);
			if (!$moduleInstance) {
				echo "ERROR: Module $module not found!\n";
			} else {
				echo "Updating ...";
				$package->update($moduleInstance, $path);
				echo "DONE.\n";
			}			
			
		} else {
			throw new Exception("Package file $path not found.");
		}
		
		echo "----------------------------------\n\n";
	}
Ejemplo n.º 8
0
 /**
  * Function installs all the available modules
  */
 public static function installModules()
 {
     require_once 'vtlib/Vtiger/Package.php';
     require_once 'vtlib/Vtiger/Module.php';
     require_once 'include/utils/utils.php';
     $moduleFolders = array('packages/vtiger/mandatory', 'packages/vtiger/optional');
     foreach ($moduleFolders as $moduleFolder) {
         if ($handle = opendir($moduleFolder)) {
             while (false !== ($file = readdir($handle))) {
                 $packageNameParts = explode(".", $file);
                 if ($packageNameParts[count($packageNameParts) - 1] != 'zip') {
                     continue;
                 }
                 array_pop($packageNameParts);
                 $packageName = implode("", $packageNameParts);
                 if (!empty($packageName)) {
                     $packagepath = "{$moduleFolder}/{$file}";
                     $package = new Vtiger_Package();
                     $module = $package->getModuleNameFromZip($packagepath);
                     if ($module != null) {
                         $moduleInstance = Vtiger_Module::getInstance($module);
                         if ($moduleInstance) {
                             updateVtlibModule($module, $packagepath);
                         } else {
                             installVtlibModule($module, $packagepath);
                         }
                     }
                 }
             }
             closedir($handle);
         }
     }
 }