Ejemplo n.º 1
0
 /**
  * Given a name check if it exists in the table
  * @param name    the unique key from the manifest
  * @param id      the id of the item you are comparing to
  * @return upgrade_history object if found, null otherwise
  */
 function checkForExisting($patch_to_check)
 {
     $uh = new UpgradeHistory();
     if ($patch_to_check != null) {
         if (empty($patch_to_check->id_name)) {
             $where = " WHERE name = '{$patch_to_check->name}' ";
         } else {
             $where = " WHERE id_name = '{$patch_to_check->id_name}' ";
         }
         if (!empty($patch_to_check->id)) {
             $where .= "  AND id != '{$patch_to_check->id}'  ";
         } else {
             $where .= "  AND id is not null  ";
         }
         $query = "SELECT id FROM " . $this->table_name . " " . $where;
         $result = $uh->db->query($query);
         if (empty($result)) {
             return null;
         }
         $row = $uh->db->fetchByAssoc($result);
         if (empty($row)) {
             return null;
         }
         if (!empty($row['id'])) {
             return $uh->retrieve($row['id']);
         }
     }
     return null;
 }
Ejemplo n.º 2
0
 public function run()
 {
     require_once 'ModuleInstall/PackageManager/PackageManager.php';
     $pm = new PackageManager();
     $packages = $pm->getinstalledPackages(array('module'));
     foreach ($packages as $pack) {
         if (strpos($pack['name'], 'SugarCRM Upgrader') !== false) {
             $uh = new UpgradeHistory();
             $uh->name = $pack['name'];
             $history = $uh->checkForExisting($uh);
             $this->filesToRemove[] = "custom/Extension/application/Ext/Include/{$history->id_name}.php";
             $history->delete();
             $this->fileToDelete($this->filesToRemove);
             $this->log("Useless files of {$pack['name']} v{$pack['version']} removed");
         }
     }
     foreach ($pm->getPackagesInStaging() as $pack) {
         if (strpos($pack['name'], 'SugarCRM Upgrader') !== false) {
             $file = UploadStream::getFSPath(hashToFile($pack['file']));
             $this->fileToDelete($file);
             foreach (array('manifest', 'icon') as $meta) {
                 $this->fileToDelete(pathinfo($file, PATHINFO_DIRNAME) . '/' . pathinfo($file, PATHINFO_FILENAME) . "-{$meta}.php");
             }
         }
     }
 }
Ejemplo n.º 3
0
 public function run()
 {
     // if error was encountered, script should have died before now
     $new_upgrade = new UpgradeHistory();
     $new_upgrade->filename = $this->context['zip'];
     if (!empty($this->context['zip_as_dir'])) {
         $new_upgrade->md5sum = trim(file_get_contents($this->context['zip'] . DIRECTORY_SEPARATOR . 'md5sum'));
     } else {
         if (file_exists($this->context['zip'])) {
             $new_upgrade->md5sum = md5_file($this->context['zip']);
         } else {
             // if file is not there, just md5 the filename
             $new_upgrade->md5sum = md5($this->context['zip']);
         }
     }
     $dup = $this->db->getOne("SELECT id FROM upgrade_history WHERE md5sum='{$new_upgrade->md5sum}'");
     if ($dup) {
         $this->error("Duplicate install for package, md5: {$new_upgrade->md5sum}");
         // Not failing it - by now there's no point, we're at the end anyway
         return;
     }
     $new_upgrade->name = pathinfo($this->context['zip'], PATHINFO_FILENAME);
     $new_upgrade->description = $this->manifest['description'];
     $new_upgrade->type = 'patch';
     $new_upgrade->version = $this->to_version;
     $new_upgrade->status = "installed";
     $new_upgrade->manifest = base64_encode(serialize($this->manifest));
     $new_upgrade->save();
 }
Ejemplo n.º 4
0
/**
 * Returns manifest patch from upgrade history of the given install file
 *
 * @param string $install_file
 * @return array
 */
function UW_get_patch_for_file($install_file)
{
    $history = new UpgradeHistory();
    $md5 = md5_file($install_file);
    $matches = $history->findByMd5($md5);
    $history = array_shift($matches);
    if ($history && $history->patch) {
        return unserialize(base64_decode($history->patch));
    }
    return array();
}
Ejemplo n.º 5
0
 public function testCheckForExistingSQL()
 {
     $patchToCheck = new stdClass();
     $patchToCheck->name = 'abc';
     $patchToCheck->id = '';
     $GLOBALS['db']->query("INSERT INTO upgrade_history (id, name, md5sum, date_entered) VALUES\n('444','abc','444','2008-12-20 08:08:20') ");
     $GLOBALS['db']->query("INSERT INTO upgrade_history (id, name, md5sum, date_entered) VALUES\n('555','abc','555','2008-12-20 08:08:20')");
     $uh = new UpgradeHistory();
     $return = $uh->checkForExisting($patchToCheck);
     $this->assertContains($return->id, array('444', '555'));
     $patchToCheck->id = '555';
     $return = $uh->checkForExisting($patchToCheck);
     $this->assertEquals($return->id, '444');
     $GLOBALS['db']->query("delete from upgrade_history where id='444'");
     $GLOBALS['db']->query("delete from upgrade_history where id='555'");
 }
Ejemplo n.º 6
0
 public function display()
 {
     global $sugar_flavor;
     global $current_user;
     $mod_strings = return_module_language($GLOBALS['current_language'], 'Home');
     $this->ss->assign('mod', $mod_strings);
     $this->ss->assign("sugarFlavor", $sugar_flavor);
     //check the upgrade history to see if this instance has been upgraded, if so then present the calendar url message
     //if no upgrade history exists then we can assume this is an install and we do not show the calendar message
     $uh = new UpgradeHistory();
     $upgrade = count($uh->getAll()) > 0 ? true : false;
     if ($upgrade) {
         //create the url with the user id and scrolltocal flag.  This will be passed into language string
         $urlForString = $mod_strings['LBL_TOUR_CALENDAR_URL_1'];
         $urlForString .= '<br><a href="index.php?module=Users&action=EditView&record=' . $current_user->id . '&scrollToCal=true" target="_blank">';
         $urlForString .= $mod_strings['LBL_TOUR_CALENDAR_URL_2'] . '</a>';
         $this->ss->assign('view_calendar_url', $urlForString);
     }
     $this->ss->display('modules/Home/tour.tpl');
 }
Ejemplo n.º 7
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;
    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;
    }
}
Ejemplo n.º 8
0
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 .= "<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;
Ejemplo n.º 9
0
function get_required_upgrades($soapclient, $session)
{
    global $sugar_config, $sugar_version;
    require_once 'vendor/nusoap//nusoap.php';
    $errors = array();
    $upgrade_history = new UpgradeHistory();
    $upgrade_history->disable_row_level_security = true;
    $installeds = $upgrade_history->getAllOrderBy('date_entered ASC');
    $history = array();
    require_once 'soap/SoapError.php';
    $error = new SoapError();
    foreach ($installeds as $installed) {
        $history[] = array('id' => $installed->id, 'filename' => $installed->filename, 'md5' => $installed->md5sum, 'type' => $installed->type, 'status' => $installed->status, 'version' => $installed->version, 'date_entered' => $installed->date_entered, 'error' => $error->get_soap_array());
    }
    $result = $soapclient->call('get_required_upgrades', array('session' => $session, 'client_upgrade_history' => $history, 'client_version' => $sugar_version));
    $tempdir_parent = create_cache_directory("disc_client");
    $temp_dir = tempnam($tempdir_parent, "sug");
    sugar_mkdir($temp_dir, 0775);
    $upgrade_installed = false;
    if (empty($soapclient->error_str) && $result['error']['number'] == 0) {
        foreach ($result['upgrade_history_list'] as $upgrade) {
            $file_result = $soapclient->call('get_encoded_file', array('session' => $session, 'filename' => $upgrade['filename']));
            if (empty($soapclient->error_str) && $result['error']['number'] == 0) {
                if ($file_result['md5'] == $upgrade['md5']) {
                    $newfile = write_encoded_file($file_result, $temp_dir);
                    unzip($newfile, $temp_dir);
                    global $unzip_dir;
                    $unzip_dir = $temp_dir;
                    if (file_exists("{$temp_dir}/manifest.php")) {
                        require_once "{$temp_dir}/manifest.php";
                        global $manifest_arr;
                        $manifest_arr = $manifest;
                        if (!isset($manifest['offline_client_applicable']) || $manifest['offline_client_applicable'] == true || $manifest['offline_client_applicable'] == 'true') {
                            if (file_exists("{$temp_dir}/scripts/pre_install.php")) {
                                require_once "{$temp_dir}/scripts/pre_install.php";
                                pre_install();
                            }
                            if (isset($manifest['copy_files']['from_dir']) && $manifest['copy_files']['from_dir'] != "") {
                                $zip_from_dir = $manifest['copy_files']['from_dir'];
                            }
                            $source = "{$temp_dir}/{$zip_from_dir}";
                            $dest = getcwd();
                            copy_recursive($source, $dest);
                            if (file_exists("{$temp_dir}/scripts/post_install.php")) {
                                require_once "{$temp_dir}/scripts/post_install.php";
                                post_install();
                            }
                            //save newly installed upgrade
                            $new_upgrade = new UpgradeHistory();
                            $new_upgrade->filename = $upgrade['filename'];
                            $new_upgrade->md5sum = $upgrade['md5'];
                            $new_upgrade->type = $upgrade['type'];
                            $new_upgrade->version = $upgrade['version'];
                            $new_upgrade->status = "installed";
                            $new_upgrade->save();
                            $upgrade_installed = true;
                        }
                    }
                }
            }
        }
    }
    return $upgrade_installed;
}
Ejemplo n.º 10
0
    case "Disable":
        $file_action = "disabled";
        $uh = new UpgradeHistory();
        $the_md5 = md5_file($install_file);
        $md5_matches = $uh->findByMd5($the_md5);
        if (sizeof($md5_matches) == 0) {
            die("{$mod_strings['ERR_UW_NO_UPDATE_RECORD']} {$install_file}.");
        }
        foreach ($md5_matches as $md5_match) {
            $md5_match->enabled = 0;
            $md5_match->save();
        }
        break;
    case "Enable":
        $file_action = "enabled";
        $uh = new UpgradeHistory();
        $the_md5 = md5_file($install_file);
        $md5_matches = $uh->findByMd5($the_md5);
        if (sizeof($md5_matches) == 0) {
            die("{$mod_strings['ERR_UW_NO_UPDATE_RECORD']} {$install_file}.");
        }
        foreach ($md5_matches as $md5_match) {
            $md5_match->enabled = 1;
            $md5_match->save();
        }
        break;
}
// present list to user
?>
<form action="<?php 
print $form_action;
Ejemplo n.º 11
0
function get_required_upgrades($session, $client_upgrade_history, $client_version)
{
    // files might be big
    global $sugar_config;
    $error = new SoapError();
    if (!validate_authenticated($session)) {
        $error->set_error('invalid_login');
        return array('upgrade_history_list' => array(), 'error' => $error->get_soap_array());
    }
    global $current_user;
    $upgrade_history = new UpgradeHistory();
    $installeds = $upgrade_history->getAllOrderBy('date_entered ASC');
    $history = array();
    $client_ver = explode('.', $client_version);
    foreach ($installeds as $installed) {
        $installed_ver = explode('.', $installed->version);
        if (count($installed_ver) >= 3) {
            if (is_server_version_greater($client_ver, $installed_ver) == true) {
                $found = false;
                foreach ($client_upgrade_history as $client_history) {
                    if ($client_history['md5'] == $installed->md5sum) {
                        $found = true;
                        break;
                    }
                }
                if (!$found) {
                    //now check to be sure that this is available as an offline client upgrade
                    $manifest_file = getManifest($installed->filename);
                    if (is_file($manifest_file)) {
                        require_once $manifest_file;
                        if (!isset($manifest['offline_client_applicable']) || $manifest['offline_client_applicable'] == true || $manifest['offline_client_applicable'] == 'true') {
                            $history[] = array('id' => $installed->id, 'filename' => $installed->filename, 'md5' => $installed->md5sum, 'type' => $installed->type, 'status' => $installed->status, 'version' => $installed->version, 'date_entered' => $installed->date_entered, 'error' => $error->get_soap_array());
                        }
                    }
                }
            }
        }
    }
    return array('upgrade_history_list' => $history, 'error' => $error->get_soap_array());
}
Ejemplo n.º 12
0
/**
 * searches upgrade dir for lang pack files.
 *
 * @return string HTML of available lang packs
 */
function getLangPacks($display_commit = true, $types = array('langpack'), $notice_text = '')
{
    global $mod_strings;
    global $next_step;
    global $base_upgrade_dir;
    if (empty($notice_text)) {
        $notice_text = $mod_strings['LBL_LANG_PACK_READY'];
    }
    $ret = "<tr><td colspan=7 align=left>{$notice_text}</td></tr>";
    //$ret .="<table width='100%' cellpadding='0' cellspacing='0' border='0'>";
    $ret .= "<tr>\n                <td width='20%' ><b>{$mod_strings['LBL_ML_NAME']}</b></td>\n                <td width='15%' ><b>{$mod_strings['LBL_ML_VERSION']}</b></td>\n                <td width='15%' ><b>{$mod_strings['LBL_ML_PUBLISHED']}</b></td>\n                <td width='15%' ><b>{$mod_strings['LBL_ML_UNINSTALLABLE']}</b></td>\n                <td width='20%' ><b>{$mod_strings['LBL_ML_DESCRIPTION']}</b></td>\n                <td width='7%' ></td>\n                <td width='1%' ></td>\n                <td width='7%' ></td>\n            </tr>\n";
    $files = array();
    // duh, new installs won't have the upgrade folders
    if (!is_dir($base_upgrade_dir)) {
        mkdir_recursive($base_upgrade_dir);
    }
    $subdirs = array('full', 'langpack', 'module', 'patch', 'theme', 'temp');
    foreach ($subdirs as $subdir) {
        mkdir_recursive("{$base_upgrade_dir}/{$subdir}");
    }
    $files = findAllFiles($base_upgrade_dir, $files);
    $hidden_input = '';
    unset($_SESSION['hidden_input']);
    foreach ($files as $file) {
        if (!preg_match("#.*\\.zip\$#", $file)) {
            continue;
        }
        // skip installed lang packs
        if (isset($_SESSION['INSTALLED_LANG_PACKS']) && in_array($file, $_SESSION['INSTALLED_LANG_PACKS'])) {
            continue;
        }
        // handle manifest.php
        $target_manifest = remove_file_extension($file) . '-manifest.php';
        $license_file = remove_file_extension($file) . '-license.txt';
        include $target_manifest;
        if (!empty($types)) {
            if (!in_array(strtolower($manifest['type']), $types)) {
                continue;
            }
        }
        $md5_matches = array();
        if ($manifest['type'] == 'module') {
            $uh = new UpgradeHistory();
            $upgrade_content = clean_path($file);
            $the_base = basename($upgrade_content);
            $the_md5 = md5_file($upgrade_content);
            $md5_matches = $uh->findByMd5($the_md5);
        }
        if ($manifest['type'] != 'module' || 0 == sizeof($md5_matches)) {
            $name = empty($manifest['name']) ? $file : $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';
            $manifest_type = $manifest['type'];
            $commitPackage = getPackButton('commit', $target_manifest, $file, $next_step);
            $deletePackage = getPackButton('remove', $target_manifest, $file, $next_step);
            //$ret .="<table width='100%' cellpadding='0' cellspacing='0' border='0'>";
            $ret .= "<tr>";
            $ret .= "<td width='20%' >" . $name . "</td>";
            $ret .= "<td width='15%' >" . $version . "</td>";
            $ret .= "<td width='15%' >" . $published_date . "</td>";
            $ret .= "<td width='15%' >" . $uninstallable . "</td>";
            $ret .= "<td width='20%' >" . $description . "</td>";
            if ($display_commit) {
                $ret .= "<td width='7%'>{$commitPackage}</td>";
            }
            $ret .= "<td width='1%'></td>";
            $ret .= "<td width='7%'>{$deletePackage}</td>";
            $ret .= "</td></tr>";
            $clean_field_name = "accept_lic_" . str_replace('.', '_', urlencode(basename($file)));
            if (is_file($license_file)) {
                //rrs
                $ret .= "<tr><td colspan=6>";
                $ret .= getLicenseDisplay('commit', $target_manifest, $file, $next_step, $license_file, $clean_field_name);
                $ret .= "</td></tr>";
                $hidden_input .= "<input type='hidden' name='{$clean_field_name}' id='{$clean_field_name}' value='no'>";
            } else {
                $hidden_input .= "<input type='hidden' name='{$clean_field_name}' id='{$clean_field_name}' value='yes'>";
            }
        }
        //fi
    }
    //rof
    $_SESSION['hidden_input'] = $hidden_input;
    if (count($files) > 0) {
        $ret .= "</tr><td colspan=7>";
        $ret .= "<form name='commit' action='install.php' method='POST'>\n                    <input type='hidden' name='current_step' value='{$next_step}'>\n                    <input type='hidden' name='goto' value='Re-check'>\n                    <input type='hidden' name='languagePackAction' value='commit'>\n                    <input type='hidden' name='install_type' value='custom'>\n                 </form>\n                ";
        $ret .= "</td></tr>";
    } else {
        $ret .= "</tr><td colspan=7><i>{$mod_strings['LBL_LANG_NO_PACKS']}</i></td></tr>";
    }
    return $ret;
}
 *
 * All copies of the Covered Code must include on each user interface screen:
 *    (i) the "Powered by SugarCRM" logo and
 *    (ii) the SugarCRM copyright notice
 * in the same form as they appear in the distribution.  See full license for
 * requirements.
 *
 * The Original Code is: SugarCRM Open Source
 * The Initial Developer of the Original Code is SugarCRM, Inc.
 * Portions created by SugarCRM are Copyright (C) 2004-2006 SugarCRM, Inc.;
 * All Rights Reserved.
 * Contributor(s): ______________________________________.
 */
require_once 'modules/Administration/UpgradeWizardCommon.php';
global $mod_strings;
$uh = new UpgradeHistory();
function unlinkTempFiles()
{
    global $sugar_config;
    @unlink($_FILES['upgrade_zip']['tmp_name']);
    @unlink(getcwd() . '/' . $sugar_config['upload_dir'] . $_FILES['upgrade_zip']['name']);
}
// make sure dirs exist
foreach ($subdirs as $subdir) {
    mkdir_recursive("{$base_upgrade_dir}/{$subdir}");
}
// get labels and text that are specific to either Module Loader or Upgrade Wizard
if ($view == "module") {
    $uploaddLabel = $mod_strings['LBL_UW_UPLOAD_MODULE'];
    $descItemsQueued = $mod_strings['LBL_UW_DESC_MODULES_QUEUED'];
    $descItemsInstalled = $mod_strings['LBL_UW_DESC_MODULES_INSTALLED'];
Ejemplo n.º 14
0
function get_unique_system_id($session, $unique_key, $system_name = '', $install_method = 'web')
{
    global $beanList, $beanFiles, $current_user, $server;
    $error = new SoapError();
    if (!empty($server->requestHeaders)) {
        $header = explode('=', $server->requestHeaders);
        $uh = new UpgradeHistory();
        if (count($header) == 2 && $uh->is_right_version_greater(explode('.', '5.0.0'), explode('.', $header[1]))) {
            $output_list = array();
            if (!validate_authenticated($session)) {
                $error->set_error('invalid_login');
                return array('id' => '', 'error' => $error->get_soap_array());
            }
            $system = new System();
            if ($system->canAddNewOfflineClient()) {
                $system->system_key = $unique_key;
                $system->user_id = $current_user->id;
                $system->system_name = $system_name;
                $system->install_method = $install_method;
                $system->last_connect_date = TimeDate::getInstance()->nowDb();
                $system_id = $system->retrieveNextKey();
                if ($system_id == -1) {
                    $error->set_error('client_deactivated');
                }
            } else {
                $system_id = -1;
                $error->set_error('cannot_add_client');
            }
        } else {
            $system_id = -1;
            $error->set_error('upgrade_client');
        }
    } else {
        $system_id = -1;
        $error->set_error('upgrade_client');
    }
    return array('id' => $system_id, 'error' => $error->get_soap_array());
}
/**
 * creates UpgradeHistory entries
 * @param mode string Install or Uninstall
 */
function updateUpgradeHistory()
{
    if (isset($_SESSION['INSTALLED_LANG_PACKS']) && count($_SESSION['INSTALLED_LANG_PACKS']) > 0) {
        foreach ($_SESSION['INSTALLED_LANG_PACKS'] as $k => $zipFile) {
            $new_upgrade = new UpgradeHistory();
            $new_upgrade->filename = $zipFile;
            $new_upgrade->md5sum = md5_file($zipFile);
            $new_upgrade->type = 'langpack';
            $new_upgrade->version = $_SESSION['INSTALLED_LANG_PACKS_VERSION'][$k];
            $new_upgrade->status = "installed";
            $new_upgrade->save();
        }
    }
}
Ejemplo n.º 16
0
 function getinstalledPackages($types = array('module', 'langpack'))
 {
     global $sugar_config;
     $installeds = $this->getInstalled($types);
     $packages = array();
     $upgrades_installed = 0;
     $uh = new UpgradeHistory();
     $base_upgrade_dir = sugar_cached("/upgrades");
     $base_tmp_upgrade_dir = "{$base_upgrade_dir}/temp";
     foreach ($installeds as $installed) {
         $populate = false;
         $filename = from_html($installed->filename);
         $date_entered = $installed->date_entered;
         $type = $installed->type;
         $version = $installed->version;
         $uninstallable = false;
         $link = "";
         $description = $installed->description;
         $name = $installed->name;
         $enabled = true;
         $enabled_string = 'ENABLED';
         //if the name is empty then we should try to pull from manifest and populate upgrade_history_table
         if (empty($name)) {
             $populate = true;
         }
         $upgrades_installed++;
         switch ($type) {
             case "theme":
             case "langpack":
             case "module":
             case "patch":
                 if ($populate) {
                     $manifest_file = $this->extractManifest($filename, $base_tmp_upgrade_dir);
                     require_once $manifest_file;
                     $GLOBALS['log']->info("Filling in upgrade_history table");
                     $populate = false;
                     if (isset($manifest['name'])) {
                         $name = $manifest['name'];
                         $installed->name = $name;
                     }
                     if (isset($manifest['description'])) {
                         $description = $manifest['description'];
                         $installed->description = $description;
                     }
                     if (isset($installdefs) && isset($installdefs['id'])) {
                         $id_name = $installdefs['id'];
                         $installed->id_name = $id_name;
                     }
                     $serial_manifest = array();
                     $serial_manifest['manifest'] = isset($manifest) ? $manifest : '';
                     $serial_manifest['installdefs'] = isset($installdefs) ? $installdefs : '';
                     $serial_manifest['upgrade_manifest'] = isset($upgrade_manifest) ? $upgrade_manifest : '';
                     $installed->manifest = base64_encode(serialize($serial_manifest));
                     $installed->save();
                 } else {
                     $serial_manifest = unserialize(base64_decode($installed->manifest));
                     $manifest = $serial_manifest['manifest'];
                 }
                 if (($upgrades_installed == 0 || $uh->UninstallAvailable($installeds, $installed)) && is_file($filename) && !empty($manifest['is_uninstallable'])) {
                     $uninstallable = true;
                 }
                 $enabled = $installed->enabled;
                 if (!$enabled) {
                     $enabled_string = 'DISABLED';
                 }
                 $file_uninstall = $filename;
                 if (!$uninstallable) {
                     $file_uninstall = 'UNINSTALLABLE';
                     $enabled_string = 'UNINSTALLABLE';
                 } else {
                     $file_uninstall = fileToHash($file_uninstall);
                 }
                 $packages[] = array('name' => $name, 'version' => $version, 'type' => $type, 'published_date' => $date_entered, 'description' => $description, 'uninstallable' => $uninstallable, 'file_install' => $file_uninstall, 'file' => fileToHash($filename), 'enabled' => $enabled_string);
                 break;
             default:
                 break;
         }
     }
     //rof
     return $packages;
 }
Ejemplo n.º 17
0
 function buildInstallGrid($view)
 {
     $uh = new UpgradeHistory();
     $installeds = $uh->getAll();
     $upgrades_installed = 0;
     $installed_objects = array();
     foreach ($installeds as $installed) {
         $filename = from_html($installed->filename);
         $date_entered = $installed->date_entered;
         $type = $installed->type;
         $version = $installed->version;
         $upgrades_installed++;
         $link = "";
         switch ($type) {
             case "theme":
             case "langpack":
             case "module":
             case "patch":
                 $manifest_file = extractManifest($filename);
                 require_once $manifest_file;
                 $name = empty($manifest['name']) ? $filename : $manifest['name'];
                 $description = empty($manifest['description']) ? $mod_strings['LBL_UW_NONE'] : $manifest['description'];
                 if (($upgrades_installed == 0 || $uh->UninstallAvailable($installeds, $installed)) && is_file($filename) && !empty($manifest['is_uninstallable'])) {
                     $link = urlencode($filename);
                 } else {
                     $link = 'false';
                 }
                 break;
             default:
                 break;
         }
         if ($view == 'default' && $type != 'patch') {
             continue;
         }
         if ($view == 'module' && $type != 'module' && $type != 'theme' && $type != 'langpack') {
             continue;
         }
         $target_manifest = remove_file_extension($filename) . "-manifest.php";
         require_once "{$target_manifest}";
         if (isset($manifest['icon']) && $manifest['icon'] != "") {
             $manifest_copy_files_to_dir = isset($manifest['copy_files']['to_dir']) ? clean_path($manifest['copy_files']['to_dir']) : "";
             $manifest_copy_files_from_dir = isset($manifest['copy_files']['from_dir']) ? clean_path($manifest['copy_files']['from_dir']) : "";
             $manifest_icon = clean_path($manifest['icon']);
             $icon = "<img src=\"" . $manifest_copy_files_to_dir . ($manifest_copy_files_from_dir != "" ? substr($manifest_icon, strlen($manifest_copy_files_from_dir) + 1) : $manifest_icon) . "\">";
         } else {
             $icon = getImageForType($manifest['type']);
         }
         $installed_objects[] = array('icon' => $icon, 'name' => $name, 'type' => $type, 'version' => $version, 'date_entered' => $date_entered, 'description' => $description, 'file' => $link);
         //print( "<form action=\"" . $form_action . "_prepare\" method=\"post\">\n" );
         //print( "<tr><td>$icon</td><td>$name</td><td>$type</td><td>$version</td><td>$date_entered</td><td>$description</td><td>$link</td></tr>\n" );
         //print( "</form>\n" );
     }
 }
Ejemplo n.º 18
0
$uwMain = '';
$steps = array();
$step = 0;
$showNext = '';
$showCancel = '';
$showBack = '';
$showRecheck = '';
$stepNext = '';
$stepCancel = '';
$stepBack = '';
$stepRecheck = '';
////	END SYSTEM PREP
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
////	LOGIC
$uh = new UpgradeHistory();
$smarty = new Sugar_Smarty();
// this flag set in pre_install.php->UWUpgrade();
if (isset($_SESSION['UpgradedUpgradeWizard']) && $_SESSION['UpgradedUpgradeWizard'] == true) {
    // coming from 4.2.x or 4.0.1x
    $steps = array('files' => array('start', 'systemCheck', 'preflight', 'commit', 'end', 'cancel'), 'desc' => array($mod_strings['LBL_UW_TITLE_START'], $mod_strings['LBL_UW_TITLE_SYSTEM_CHECK'], $mod_strings['LBL_UW_TITLE_PREFLIGHT'], $mod_strings['LBL_UW_TITLE_COMMIT'], $mod_strings['LBL_UW_TITLE_END'], $mod_strings['LBL_UW_TITLE_CANCEL']));
} else {
    // 4.5.0+
    $steps = array('files' => array('start', 'systemCheck', 'upload', 'preflight', 'commit', 'end', 'cancel'), 'desc' => array($mod_strings['LBL_UW_TITLE_START'], $mod_strings['LBL_UW_TITLE_SYSTEM_CHECK'], $mod_strings['LBL_UW_TITLE_UPLOAD'], $mod_strings['LBL_UW_TITLE_PREFLIGHT'], $mod_strings['LBL_UW_TITLE_COMMIT'], $mod_strings['LBL_UW_TITLE_END'], $mod_strings['LBL_UW_TITLE_CANCEL']));
}
if (isset($_REQUEST['step'])) {
    if ($_REQUEST['step'] == -1) {
        $_REQUEST['step'] = count($steps['files']) - 1;
    } elseif ($_REQUEST['step'] >= count($steps['files'])) {
        $_REQUEST['step'] = 0;
    }
Ejemplo n.º 19
0
     }
     if (!write_array_to_file("sugar_config", $sugar_config, "config.php")) {
         logThis('*** ERROR: could not write config.php! - upgrade will fail!', $path);
         $errors[] = 'Could not write config.php!';
     }
     logThis('post_install() done.', $path);
 }
 ///////////////////////////////////////////////////////////////////////////////
 ////	REGISTER UPGRADE
 if (empty($errors)) {
     logThis('Registering upgrade with UpgradeHistory', $path);
     if (!didThisStepRunBefore('commit', 'upgradeHistory')) {
         set_upgrade_progress('commit', 'in_progress', 'upgradeHistory', 'in_progress');
         $file_action = "copied";
         // if error was encountered, script should have died before now
         $new_upgrade = new UpgradeHistory();
         $new_upgrade->filename = $install_file;
         $new_upgrade->md5sum = md5_file($install_file);
         $new_upgrade->name = $zip_from_dir;
         $new_upgrade->description = $manifest['description'];
         $new_upgrade->type = 'patch';
         $new_upgrade->version = $sugar_version;
         $new_upgrade->status = "installed";
         $new_upgrade->manifest = !empty($_SESSION['install_manifest']) ? $_SESSION['install_manifest'] : '';
         if ($new_upgrade->description == null) {
             $new_upgrade->description = "Silent Upgrade was used to upgrade the instance";
         } else {
             $new_upgrade->description = $new_upgrade->description . " Silent Upgrade was used to upgrade the instance.";
         }
         $new_upgrade->save();
         set_upgrade_progress('commit', 'in_progress', 'upgradeHistory', 'done');
 */
/**
 * @package reg_invoices
 * @author Rodrigo Saiz Camarero <*****@*****.**>
 */
require_once 'modules/Administration/UpgradeHistory.php';
$admin_option_defs = array();
// Invoice options
$admin_option_defs[] = array('Administration', 'LBL_FACT_CONFIG', 'LBL_FACT_CONFIG_DESC', './index.php?module=Configurator&action=reg_invoices_Config');
// Dependencies checker
$admin_option_defs[] = array('Administration', 'LBL_FACT_CHECK', 'LBL_FACT_CHECK_DESC', './index.php?module=Administration&action=reg_invoices_Check');
/*
 * Add administration options to page
 * Supports:
 */
$US = new UpgradeHistory();
/*
 * Prepare for < 5.5
 */
$minimal = explode(".", "5.5.0");
$current = explode(".", $GLOBALS['sugar_version']);
if (!$US->is_right_version_greater($minimal, $current, true)) {
    foreach ($admin_option_defs as $key => $val) {
        //Add $image_path
        $admin_option_defs[$key][0] = $image_path . $admin_option_defs[$key][0];
    }
}
$minimal = explode(".", "5.2.0");
$current = explode(".", $GLOBALS['sugar_version']);
// 5.2 and later
if ($US->is_right_version_greater($minimal, $current, true)) {