"; $install_type = getInstallType( $install_file ); $version = ""; $previous_version = ""; $show_files = true; $zip_from_dir = "."; $zip_to_dir = "."; $zip_force_copy = array(); $license_file = $unzip_dir.'/LICENSE.txt'; $readme_file = $unzip_dir.'/README.txt'; $require_license = false; $found_readme = false; $author = ''; $name = ''; $description = ''; $is_uninstallable = true; $id_name = ''; $dependencies = array(); $remove_tables = 'true'; unzip( $install_file, $unzip_dir ); if($install_type == 'module' && $mode != 'Uninstall'){ if(file_exists($license_file)){ $require_license = true; } } //Scan the unzip dir for unsafe files if(!empty($GLOBALS['sugar_config']['moduleInstaller']['packageScan']) && $install_type != 'patch'){ require_once('ModuleInstall/ModuleScanner.php'); $ms = new ModuleScanner(); $ms->scanPackage($unzip_dir); if($ms->hasIssues()){ $ms->displayIssues(); sugar_cleanup(true); } } // assumption -- already validated manifest.php at time of upload require_once( "$unzip_dir/manifest.php" ); if( isset( $manifest['copy_files']['from_dir'] ) && $manifest['copy_files']['from_dir'] != "" ){ $zip_from_dir = $manifest['copy_files']['from_dir']; } if( isset( $manifest['copy_files']['to_dir'] ) && $manifest['copy_files']['to_dir'] != "" ){ $zip_to_dir = $manifest['copy_files']['to_dir']; } if( isset( $manifest['copy_files']['force_copy'] ) && $manifest['copy_files']['force_copy'] != "" ){ $zip_force_copy = $manifest['copy_files']['force_copy']; } if( isset( $manifest['version'] ) ){ $version = $manifest['version']; } if( isset( $manifest['author'] ) ){ $author = $manifest['author']; } if( isset( $manifest['name'] ) ){ $name = $manifest['name']; } if( isset( $manifest['description'] ) ){ $description = $manifest['description']; } if( isset( $manifest['is_uninstallable'] ) ){ $is_uninstallable = $manifest['is_uninstallable']; } if(isset($installdefs) && isset( $installdefs['id'] ) ){ $id_name = $installdefs['id']; } if( isset( $manifest['dependencies']) ){ $dependencies = $manifest['dependencies']; } if( isset( $manifest['remove_tables']) ){ $remove_tables = $manifest['remove_tables']; } if($remove_tables != 'prompt'){ $hidden_fields .= ""; } if(file_exists($readme_file) || !empty($manifest['readme'])){ $found_readme = true; } $uh = new UpgradeHistory(); //check dependencies first if(!empty($dependencies)){ $not_found = $uh->checkDependencies($dependencies); if(!empty($not_found) && count($not_found) > 0){ die( $mod_strings['ERR_UW_NO_DEPENDENCY']."[".implode(',', $not_found)."]"); }//fi } switch( $install_type ){ case "full": case "patch": if( !is_writable( "config.php" ) ){ die( $mod_strings['ERR_UW_CONFIG'] ); } break; case "theme": break; case "langpack": // find name of language pack: find single file in include/language/xx_xx.lang.php $d = dir( "$unzip_dir/$zip_from_dir/include/language" ); while( $f = $d->read() ){ if( $f == "." || $f == ".." ){ continue; } else if( preg_match("/(.*)\.lang\.php\$/", $f, $match) ){ $new_lang_name = $match[1]; } } if( $new_lang_name == "" ){ die( $mod_strings['ERR_UW_NO_LANGPACK'].$install_file ); } $hidden_fields .= ""; $new_lang_desc = getLanguagePackName( "$unzip_dir/$zip_from_dir/include/language/$new_lang_name.lang.php" ); if( $new_lang_desc == "" ){ die( $mod_strings['ERR_UW_NO_LANG_DESC_1']."include/language/$new_lang_name.lang.php".$mod_strings['ERR_UW_NO_LANG_DESC_2']."$install_file." ); } $hidden_fields .= ""; if( !is_writable( "config.php" ) ){ die( $mod_strings['ERR_UW_CONFIG'] ); } break; case "module": $previous_install = array(); if(!empty($id_name) & !empty($version)) $previous_install = $uh->determineIfUpgrade($id_name, $version); $previous_version = (empty($previous_install['version'])) ? '' : $previous_install['version']; $previous_id = (empty($previous_install['id'])) ? '' : $previous_install['id']; $show_files = false; //rrs pull out unique_key $hidden_fields .= ""; $hidden_fields .= ""; $hidden_fields .= ""; $hidden_fields .= ""; $hidden_fields .= ""; $hidden_fields .= ""; $hidden_fields .= ""; break; default: die( $mod_strings['ERR_UW_WRONG_TYPE'].$install_type ); } $new_files = findAllFilesRelative( "$unzip_dir/$zip_from_dir", array() ); $hidden_fields .= ""; $serial_manifest = array(); $serial_manifest['manifest'] = (isset($manifest) ? $manifest : ''); $serial_manifest['installdefs'] = (isset($installdefs) ? $installdefs : ''); $serial_manifest['upgrade_manifest'] = (isset($upgrade_manifest) ? $upgrade_manifest : ''); $hidden_fields .= ""; // present list to user ?>
" name="files" method="post" onSubmit="return validateForm();"> '.$mod_strings['LBL_UW_CHECK_ALL']; foreach($new_studio_mod_files as $the_file) { $new_file = clean_path( "$zip_to_dir/$the_file" ); print( "
  • " . $new_file . "
  • "); $count++; } } echo '
    '; if($require_license){ $contents = sugar_file_get_contents($license_file); $readme_contents = ''; if($found_readme){ if(file_exists($readme_file) && filesize($readme_file) > 0){ $readme_contents = file_get_contents($readme_file); }elseif(!empty($manifest['readme'])){ $readme_contents = $manifest['readme']; } } $license_final =<<
     
    {$mod_strings['LBL_MODULE_LICENSE']}
    {$mod_strings['LBL_ACCEPT']}  {$mod_strings['LBL_DENY']}
    eoq2; echo $license_final; echo "
    "; } switch( $mode ){ case "Install": if( $install_type == "langpack") { print( $mod_strings['LBL_UW_LANGPACK_READY'] ); echo '

    '; } break; case "Uninstall": if( $install_type == "langpack" ){ print( $mod_strings['LBL_UW_LANGPACK_READY_UNISTALL'] ); echo '

    '; } else if($install_type != "module"){ print( $mod_strings['LBL_UW_FILES_REMOVED'] ); } break; case "Disable": if( $install_type == "langpack" ){ print( $mod_strings['LBL_UW_LANGPACK_READY_DISABLE'] ); echo '

    '; } break; case "Enable": if( $install_type == "langpack" ){ print( $mod_strings['LBL_UW_LANGPACK_READY_ENABLE'] ); echo '

    '; } break; } ?>
    "); print ("".$mod_strings['ML_LBL_REMOVE_TABLES']." "); print ("".$mod_strings['ML_LBL_DO_NOT_REMOVE_TABLES']."
    "); } $count = 0; if( $show_files == true ){ $count = 0; $new_studio_mod_files = array(); $new_sugar_mod_files = array(); $cache_html_files = findAllFilesRelative( sugar_cached("layout"), array()); foreach($new_files as $the_file) { if(substr(strtolower($the_file), -5, 5) == '.html' && in_array($the_file, $cache_html_files)) array_push($new_studio_mod_files, $the_file); else array_push($new_sugar_mod_files, $the_file); } echo ''; global $theme; echo '

    '; echo '
    '.SugarThemeRegistry::current()->getImage('advanced_search', '', null, null, ".gif", $mod_strings['LBL_ADVANCED_SEARCH']).$mod_strings['LBL_UW_SHOW_DETAILS'].'
    ' .SugarThemeRegistry::current()->getImage('basic_search', '', null, null, ".gif", $mod_strings['LBL_BASIC_SEARCH']).$mod_strings['LBL_UW_HIDE_DETAILS'].'

    '; echo ' '.$mod_strings['LBL_UW_CHECK_ALL']; echo '
      '; foreach( $new_sugar_mod_files as $the_file ){ $highlight_start = ""; $highlight_end = ""; $checked = ""; $disabled = ""; $unzip_file = "$unzip_dir/$zip_from_dir/$the_file"; $new_file = clean_path( "$zip_to_dir/$the_file" ); $forced_copy = false; if( $mode == "Install" ){ $checked = "checked"; foreach( $zip_force_copy as $pattern ){ if( preg_match("#" . $pattern . "#", $unzip_file) ){ $disabled = "disabled=\"true\""; $forced_copy = true; } } if( !$forced_copy && is_file( $new_file ) && (md5_file( $unzip_file ) == md5_file( $new_file )) ){ $disabled = "disabled=\"true\""; //$checked = ""; } if( $checked != "" && $disabled != "" ){ // need to put a hidden field print( "\n" ); } print( "
    • " . $highlight_start . $new_file . $highlight_end ); if( $checked == "" && $disabled != "" ){ // need to explain this file hasn't changed print( " (no changes)" ); } print( "
      \n" ); } else if( $mode == "Uninstall" && file_exists( $new_file ) ){ if( md5_file( $unzip_file ) == md5_file( $new_file ) ){ $checked = "checked=\"true\""; } else{ $highlight_start = ""; $highlight_end = ""; } print( "
    • " . $highlight_start . $new_file . $highlight_end . "
      \n" ); } $count++; } print( "
    \n" ); } // echo '
    '; if($mode == "Disable" || $mode == "Enable"){ //check to see if any files have been modified $modified_files = getDiffFiles($unzip_dir, $install_file, ($mode == 'Enable'), $previous_version); if(count($modified_files) > 0){ //we need to tell the user that some files have been modified since they last did an install echo ''; print(''.$mod_strings['ML_LBL_OVERWRITE_FILES'].''); print('
    '); print("{$mod_strings['LBL_OVERWRITE_FILES']} "); print("{$mod_strings['LBL_DO_OVERWRITE_FILES']}"); print("
    "); print(''); }else{ echo ''; } }else{ echo ''; } echo ''; $fileHash = fileToHash($install_file ); ?> info( "Upgrade Wizard patches" ); ?>