コード例 #1
0
ファイル: uw_utils.php プロジェクト: omusico/sugar_work
/**
 * gets valid patch file names that exist in upload/upgrade/patch/
 */
function getValidPatchName($returnFull = true)
{
    global $base_upgrade_dir;
    global $mod_strings;
    global $uh;
    global $sugar_version;
    global $sugar_config;
    $uh = new UpgradeHistory();
    list($base_upgrade_dir, $base_tmp_upgrade_dir) = getUWDirs();
    $return = array();
    // scan for new files (that are not installed)
    logThis('finding new files for upgrade');
    $upgrade_content = '';
    $upgrade_contents = findAllFiles($base_upgrade_dir, array(), false, 'zip');
    //other variations of zip file i.e. ZIP, zIp,zIP,Zip,ZIp,ZiP
    $ready = "<ul>\n";
    $ready .= "\n\t\t<table>\n\t\t\t<tr>\n\t\t\t\t<td></td>\n\t\t\t\t<td align=left>\n\t\t\t\t\t<b>{$mod_strings['LBL_ML_NAME']}</b>\n\t\t\t\t</td>\n\t\t\t\t<td align=left>\n\t\t\t\t\t<b>{$mod_strings['LBL_ML_TYPE']}</b>\n\t\t\t\t</td>\n\t\t\t\t<td align=left>\n\t\t\t\t\t<b>{$mod_strings['LBL_ML_VERSION']}</b>\n\t\t\t\t</td>\n\t\t\t\t<td align=left>\n\t\t\t\t\t<b>{$mod_strings['LBL_ML_PUBLISHED']}</b>\n\t\t\t\t</td>\n\t\t\t\t<td align=left>\n\t\t\t\t\t<b>{$mod_strings['LBL_ML_UNINSTALLABLE']}</b>\n\t\t\t\t</td>\n\t\t\t\t<td align=left>\n\t\t\t\t\t<b>{$mod_strings['LBL_ML_DESCRIPTION']}</b>\n\t\t\t\t</td>\n\t\t\t</tr>";
    $disabled = '';
    // assume old patches are there.
    $upgradeToVersion = array();
    // fill with valid patches - we will only use the latest qualified found patch
    // cn: bug 10609 - notices for uninitialized variables
    $icon = '';
    $name = '';
    $type = '';
    $version = '';
    $published_date = '';
    $uninstallable = '';
    $description = '';
    $disabled = '';
    foreach ($upgrade_contents as $upgrade_content) {
        if (!preg_match("#.*\\.zip\$#i", $upgrade_content)) {
            continue;
        }
        $the_base = basename($upgrade_content);
        $the_md5 = md5_file($upgrade_content);
        $md5_matches = $uh->findByMd5($the_md5);
        /* If a patch is in the /patch dir AND has no record in the upgrade_history table we assume that it's the one we want.
         * Edge-case: manual upgrade with a FTP of a patch; UH table has no entry for it.  Assume nothing. :( */
        if (0 == sizeof($md5_matches)) {
            $target_manifest = remove_file_extension($upgrade_content) . '-manifest.php';
            require_once $target_manifest;
            if (empty($manifest['version'])) {
                logThis("*** Potential error: patch found with no version [ {$upgrade_content} ]");
                continue;
            }
            if (!isset($manifest['type']) || $manifest['type'] != 'patch') {
                logThis("*** Potential error: patch found with either no 'type' or non-patch type [ {$upgrade_content} ]");
                continue;
            }
            $upgradeToVersion[$manifest['version']] = urlencode($upgrade_content);
            $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 = getUITextForType($manifest['type']);
            $manifest_type = $manifest['type'];
            if (empty($manifest['icon'])) {
                $icon = getImageForType($manifest['type']);
            } else {
                $path_parts = pathinfo($manifest['icon']);
                $icon = "<!--not_in_theme!--><img src=\"" . remove_file_extension($upgrade_content) . "-icon." . $path_parts['extension'] . "\">";
            }
        }
    }
    // cn: bug 10488 use the NEWEST upgrade/patch available when running upgrade wizard.
    ksort($upgradeToVersion);
    $upgradeToVersion = array_values($upgradeToVersion);
    $newest = array_pop($upgradeToVersion);
    $_SESSION['install_file'] = urldecode($newest);
    // in-case it was there from a prior.
    logThis("*** UW using [ {$_SESSION['install_file']} ] as source for patch files.");
    $cleanUpgradeContent = urlencode($_SESSION['install_file']);
    // cn: 10606 - cannot upload a patch file since this returned always.
    if (!empty($cleanUpgradeContent)) {
        $ready .= "<tr><td>{$icon}</td><td>{$name}</td><td>{$type}</td><td>{$version}</td><td>{$published_date}</td><td>{$uninstallable}</td><td>{$description}</td>\n";
        $ready .= <<<eoq
\t        <td>
\t\t\t\t<form action="index.php" method="post">
\t\t\t\t\t<input type="hidden" name="module" value="UpgradeWizard">
\t\t\t\t\t<input type="hidden" name="action" value="index">
\t\t\t\t\t<input type="hidden" name="step" value="{$_REQUEST['step']}">
\t\t\t\t\t<input type="hidden" name="run" value="delete">
\t        \t\t<input type=hidden name="install_file" value="{$cleanUpgradeContent}" />
\t        \t\t<input type=submit value="{$mod_strings['LBL_BUTTON_DELETE']}" />
\t\t\t\t</form>
\t\t\t</td></table>
eoq;
        $disabled = "DISABLED";
    }
    if (empty($cleanUpgradeContent)) {
        $ready .= "<tr><td colspan='7'><i>None</i></td>\n";
        $ready .= "</table>\n";
    }
    $ready .= "<br></ul>\n";
    $return['ready'] = $ready;
    $return['disabled'] = $disabled;
    if ($returnFull) {
        return $return;
    }
}
コード例 #2
0
     continue;
 }
 $upgrade_content = clean_path($upgrade_content);
 $the_base = basename($upgrade_content);
 $the_md5 = md5_file($upgrade_content);
 $md5_matches = $uh->findByMd5($the_md5);
 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 = getUITextForType($manifest['type']);
     $manifest_type = $manifest['type'];
     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 = getImageForType($manifest['type']);
     } else {
         $path_parts = pathinfo($manifest['icon']);
         $icon = "<img src=\"" . remove_file_extension($upgrade_content) . "-icon." . $path_parts['extension'] . "\">";
     }
     $upgrades_available++;
     print "<tr><td>{$icon}</td><td>{$name}</td><td>{$type}</td><td>{$version}</td><td>{$published_date}</td><td>{$uninstallable}</td><td>{$description}</td>\n";
コード例 #3
0
            $md5_match->enabled = 1;
            $md5_match->save();
        }
        break;
}
// present list to user
?>
<form action="<?php 
print $form_action;
?>
" method="post">


<?php 
echo "<div>";
print getUITextForType($install_type) . " " . getUITextForMode($mode) . " " . $mod_strings['LBL_UW_SUCCESSFULLY'];
echo "<br>";
echo "<br>";
print "<input type=submit value=\"{$mod_strings['LBL_UW_BTN_BACK_TO_MOD_LOADER']}\" /><br>";
echo "</div>";
echo "<br>";
if (isset($lang_changed_string)) {
    print $lang_changed_string;
}
if ($install_type != "module") {
    if (sizeof($files_to_handle) > 0) {
        echo '<div style="text-align: left; cursor: hand; cursor: pointer; text-decoration: underline;" onclick=\'this.style.display="none"; toggleDisplay("more");\' id="all_text"><img src="' . SugarThemeRegistry::current()->getImageURL('advanced_search.gif') . '"> Show Details</div><div id=\'more\' style=\'display: none\'>
            <div style="text-align: left; cursor: hand; cursor: pointer; text-decoration: underline;" onclick=\'document.getElementById("all_text").style.display=""; toggleDisplay("more");\'><img name="options" src="' . SugarThemeRegistry::current()->getImageURL('basic_search.gif') . '"> Hide Details</div><br>';
        print "{$mod_strings['LBL_UW_FOLLOWING_FILES']} {$file_action}:<br>\n";
        print "<ul id=\"subMenu\">\n";
        foreach ($files_to_handle as $file_to_copy) {
コード例 #4
0
/**
 * gets valid patch file names that exist in upload/upgrade/patch/
 */
function getValidPatchName($returnFull = true)
{
    global $base_upgrade_dir;
    global $mod_strings;
    global $uh;
    $return = array();
    // scan for new files (that are not installed)
    logThis('finding new files for upgrade');
    $upgrade_content = '';
    $upgrade_contents = findAllFiles($base_upgrade_dir, array(), false);
    $upgrades_available = 0;
    $ready = "<ul>\n";
    $ready .= "\n\t\t<table>\n\t\t\t<tr>\n\t\t\t\t<th></th>\n\t\t\t\t<th align=left>\n\t\t\t\t\t{$mod_strings['LBL_ML_NAME']}\n\t\t\t\t</th>\n\t\t\t\t<th>\n\t\t\t\t\t{$mod_strings['LBL_ML_TYPE']}\n\t\t\t\t</th>\n\t\t\t\t<th>\n\t\t\t\t\t{$mod_strings['LBL_ML_VERSION']}\n\t\t\t\t</th>\n\t\t\t\t<th>\n\t\t\t\t\t{$mod_strings['LBL_ML_PUBLISHED']}\n\t\t\t\t</th>\n\t\t\t\t<th>\n\t\t\t\t\t{$mod_strings['LBL_ML_UNINSTALLABLE']}\n\t\t\t\t</th>\n\t\t\t\t<th>\n\t\t\t\t\t{$mod_strings['LBL_ML_DESCRIPTION']}\n\t\t\t\t</th>\n\t\t\t</tr>";
    $disabled = '';
    foreach ($upgrade_contents as $upgrade_content) {
        if (!preg_match("#.*\\.zip\$#i", $upgrade_content)) {
            continue;
        }
        $upgrade_content = clean_path($upgrade_content);
        $the_base = basename($upgrade_content);
        $the_md5 = md5_file($upgrade_content);
        $md5_matches = $uh->findByMd5($the_md5);
        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 = getUITextForType($manifest['type']);
            $manifest_type = $manifest['type'];
            if ($manifest_type != 'patch') {
                continue;
            }
            if (empty($manifest['icon'])) {
                $icon = getImageForType($manifest['type']);
            } else {
                $path_parts = pathinfo($manifest['icon']);
                $icon = "<img src=\"" . remove_file_extension($upgrade_content) . "-icon." . $path_parts['extension'] . "\">";
            }
            $upgrades_available++;
            if ($upgrades_available > 1) {
                logThis('ERROR: found more than 1 qualified upgrade file! Stopping upgrade.');
                $stop = true;
                // more than 1 upgrade?!?
            } else {
                logThis('found a valid upgrade file: ' . $upgrade_content);
                $_SESSION['install_file'] = $upgrade_content;
                // in-case it was there from a prior.
                $stop = false;
            }
            $ready .= "<tr><td>{$icon}</td><td>{$name}</td><td>{$type}</td><td>{$version}</td><td>{$published_date}</td><td>{$uninstallable}</td><td>{$description}</td>\n";
            $cleanUpgradeContent = urlencode($upgrade_content);
            $ready .= <<<eoq
\t            <td>
\t\t\t\t\t<form action="index.php" method="post">
\t\t\t\t\t\t<input type="hidden" name="module" value="UpgradeWizard">
\t\t\t\t\t\t<input type="hidden" name="action" value="index">
\t\t\t\t\t\t<input type="hidden" name="step" value="{$_REQUEST['step']}">
\t\t\t\t\t\t<input type="hidden" name="run" value="delete">
\t            \t\t<input type=hidden name="install_file" value="{$cleanUpgradeContent}" />
\t            \t\t<input type=submit value="{$mod_strings['LBL_BUTTON_DELETE']}" />
\t\t\t\t\t</form>
\t\t\t\t</td>
eoq;
            $disabled = "DISABLED";
        }
    }
    $ready .= "</table>\n";
    if ($upgrades_available == 0) {
        $ready .= "<i>None</i><br>\n";
    }
    $ready .= "</ul>\n";
    $return['ready'] = $ready;
    $return['disabled'] = $disabled;
    if ($returnFull) {
        return $return;
    }
}