if (isset($manifest['dependencies'])) {
    $dependencies = $manifest['dependencies'];
}
if (isset($manifest['remove_tables'])) {
    $remove_tables = $manifest['remove_tables'];
}
if ($remove_tables != 'prompt') {
    $hidden_fields .= "<input type=hidden name=\"remove_tables\" value='" . $remove_tables . "'>";
}
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":
 function getPackagesInStaging($view = 'module')
 {
     global $sugar_config;
     global $current_language;
     $uh = new UpgradeHistory();
     $base_upgrade_dir = "upload://upgrades";
     $base_tmp_upgrade_dir = sugar_cached("upgrades/temp");
     $uContent = findAllFiles($base_upgrade_dir, array(), false, 'zip');
     $upgrade_contents = array();
     $content_values = array_values($uContent);
     $alreadyProcessed = array();
     foreach ($content_values as $val) {
         if (empty($alreadyProcessed[$val])) {
             $upgrade_contents[] = $val;
             $alreadyProcessed[$val] = true;
         }
     }
     $upgrades_available = 0;
     $packages = array();
     $mod_strings = return_module_language($current_language, "Administration");
     foreach ($upgrade_contents as $upgrade_content) {
         if (!preg_match('#.*\\.zip$#', strtolower($upgrade_content)) || preg_match("#.*./zips/.*#", strtolower($upgrade_content))) {
             continue;
         }
         $the_base = basename($upgrade_content);
         $the_md5 = md5_file($upgrade_content);
         $md5_matches = $uh->findByMd5($the_md5);
         $file_install = $upgrade_content;
         if (empty($md5_matches)) {
             $target_manifest = remove_file_extension($upgrade_content) . '-manifest.php';
             require_once $target_manifest;
             $name = empty($manifest['name']) ? $upgrade_content : $manifest['name'];
             $version = empty($manifest['version']) ? '' : $manifest['version'];
             $published_date = empty($manifest['published_date']) ? '' : $manifest['published_date'];
             $icon = '';
             $description = empty($manifest['description']) ? 'None' : $manifest['description'];
             $uninstallable = empty($manifest['is_uninstallable']) ? 'No' : 'Yes';
             $type = $this->getUITextForType($manifest['type']);
             $manifest_type = $manifest['type'];
             $dependencies = array();
             if (isset($manifest['dependencies'])) {
                 $dependencies = $manifest['dependencies'];
             }
             //check dependencies first
             if (!empty($dependencies)) {
                 $uh = new UpgradeHistory();
                 $not_found = $uh->checkDependencies($dependencies);
                 if (!empty($not_found) && count($not_found) > 0) {
                     $file_install = 'errors_' . $mod_strings['ERR_UW_NO_DEPENDENCY'] . "[" . implode(',', $not_found) . "]";
                 }
             }
             if ($view == 'default' && $manifest_type != 'patch') {
                 continue;
             }
             if ($view == 'module' && $manifest_type != 'module' && $manifest_type != 'theme' && $manifest_type != 'langpack') {
                 continue;
             }
             if (empty($manifest['icon'])) {
                 $icon = $this->getImageForType($manifest['type']);
             } else {
                 $path_parts = pathinfo($manifest['icon']);
                 $icon = "<img src=\"" . remove_file_extension($upgrade_content) . "-icon." . $path_parts['extension'] . "\">";
             }
             $upgrades_available++;
             $packages[] = array('name' => $name, 'version' => $version, 'published_date' => $published_date, 'description' => $description, 'uninstallable' => $uninstallable, 'type' => $type, 'file' => fileToHash($upgrade_content), 'file_install' => fileToHash($upgrade_content));
         }
         //fi
     }
     //rof
     return $packages;
 }
Exemplo n.º 3
0
 function getPackagesInStaging($view = 'module')
 {
     global $sugar_config;
     global $current_language;
     $uh = new UpgradeHistory();
     $base_upgrade_dir = $sugar_config['upload_dir'] . "/upgrades";
     $base_tmp_upgrade_dir = "{$base_upgrade_dir}/temp";
     $uContent = findAllFiles("{$base_upgrade_dir}", array(), false, 'zip', $base_tmp_upgrade_dir);
     //other variations of zip file i.e. ZIP, zIp,zIP,Zip,ZIp,ZiP
     $extns = array('ZIP', 'ZIp', 'ZiP', 'Zip', 'zIP', 'zIp', 'ziP');
     foreach ($extns as $extn) {
         $uContent = array_merge($uContent, findAllFiles("{$base_upgrade_dir}", array(), false, $extn, $base_tmp_upgrade_dir));
     }
     $upgrade_contents = array();
     $content_values = array_values($uContent);
     $alreadyProcessed = array();
     foreach ($content_values as $val) {
         if (empty($alreadyProcessed[$val])) {
             $upgrade_contents[] = $val;
             $alreadyProcessed["{$val}"] = true;
         }
     }
     $upgrades_available = 0;
     $packages = array();
     $mod_strings = return_module_language($current_language, "Administration");
     foreach ($upgrade_contents as $upgrade_content) {
         if (!preg_match("#.*\\.zip\$#", strtolower($upgrade_content)) || preg_match("#.*./zips/.*#", strtolower($upgrade_content))) {
             continue;
         }
         $upgrade_content = clean_path($upgrade_content);
         // Bug 22285 - fix for UNC paths
         if (substr($upgrade_content, 0, 2) == '\\\\') {
             $upgrade_content = '\\\\' . $upgrade_content;
         }
         $the_base = basename($upgrade_content);
         $the_md5 = md5_file($upgrade_content);
         $md5_matches = $uh->findByMd5($the_md5);
         $file_install = $upgrade_content;
         if (0 == sizeof($md5_matches)) {
             $target_manifest = remove_file_extension($upgrade_content) . '-manifest.php';
             require_once $target_manifest;
             $name = empty($manifest['name']) ? $upgrade_content : $manifest['name'];
             $version = empty($manifest['version']) ? '' : $manifest['version'];
             $published_date = empty($manifest['published_date']) ? '' : $manifest['published_date'];
             $icon = '';
             $description = empty($manifest['description']) ? 'None' : $manifest['description'];
             $uninstallable = empty($manifest['is_uninstallable']) ? 'No' : 'Yes';
             $type = $this->getUITextForType($manifest['type']);
             $manifest_type = $manifest['type'];
             $dependencies = array();
             if (isset($manifest['dependencies'])) {
                 $dependencies = $manifest['dependencies'];
             }
             //check dependencies first
             if (!empty($dependencies)) {
                 $uh = new UpgradeHistory();
                 $not_found = $uh->checkDependencies($dependencies);
                 if (!empty($not_found) && count($not_found) > 0) {
                     $file_install = 'errors_' . $mod_strings['ERR_UW_NO_DEPENDENCY'] . "[" . implode(',', $not_found) . "]";
                 }
                 //fi
             }
             if ($view == 'default' && $manifest_type != 'patch') {
                 continue;
             }
             if ($view == 'module' && $manifest_type != 'module' && $manifest_type != 'theme' && $manifest_type != 'langpack') {
                 continue;
             }
             if (empty($manifest['icon'])) {
                 $icon = $this->getImageForType($manifest['type']);
             } else {
                 $path_parts = pathinfo($manifest['icon']);
                 $icon = "<img src=\"" . remove_file_extension($upgrade_content) . "-icon." . $path_parts['extension'] . "\">";
             }
             $upgrades_available++;
             // uploaded file in cache/upload
             $fileS = explode('/', $upgrade_content);
             $c = count($fileS);
             $fileName = isset($fileS[$c - 1]) && !empty($fileS[$c - 1]) ? $fileS[$c - 1] : $fileS[$c - 2];
             $upload_file = $sugar_config['upload_dir'] . $fileName;
             $upgrade_content = urlencode($upgrade_content);
             $upload_content = urlencode($upload_file);
             $packages[] = array('name' => $name, 'version' => $version, 'published_date' => $published_date, 'description' => $description, 'uninstallable' => $uninstallable, 'type' => $type, 'file_install' => fileToHash($file_install), 'file' => fileToHash($upgrade_content), 'upload_file' => $upload_content);
         }
         //fi
     }
     //rof
     return $packages;
 }