Add php files

This commit is contained in:
2025-05-12 15:44:39 +00:00
parent c951760058
commit 82d5804ac4
9534 changed files with 2638137 additions and 0 deletions

51
modules/UpgradeWizard/Menu.php Executable file
View File

@@ -0,0 +1,51 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*********************************************************************************
* Description:
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights
* Reserved. Contributor(s): ______________________________________..
* *******************************************************************************/
global $current_language;
global $mod_strings;
// grab Adminstration strings too
$admin_mod_strings = return_module_language($current_language, 'Administration');
$mod_strings = sugarArrayMerge($admin_mod_strings, $mod_strings);
include("modules/Administration/Menu.php");
?>

View File

@@ -0,0 +1,96 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*********************************************************************************
* Description: Defines the English language pack for the base application.
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
* All Rights Reserved.
* Contributor(s): ______________________________________..
********************************************************************************/
require_once('modules/UpgradeWizard/SugarMerge/EditViewMerge.php');
/**
* This class extends the EditViewMerge - since the meta data is relatively the same the only thing that needs to be changed is the parameter for viewdefs
*
*/
class DetailViewMerge extends EditViewMerge{
/**
* Enter the name of the parameter used in the $varName for example in editviewdefs and detailviewdefs it is 'EditView' and 'DetailView' respectively - $viewdefs['EditView']
*
* @var STRING
*/
protected $viewDefs = 'DetailView';
/**
* Determines if getFields should analyze panels to determine if it is a MultiPanel
*
* @var BOOLEAN
*/
protected $scanForMultiPanel = true; /**
* Parses out the fields for each files meta data and then calls on mergeFields and setPanels
*
*/
protected function mergeMetaData(){
$this->originalFields = $this->getFields($this->originalData[$this->module][$this->viewDefs][$this->panelName]);
$this->originalPanelIds = $this->getPanelIds($this->originalData[$this->module][$this->viewDefs][$this->panelName]);
$this->customFields = $this->getFields($this->customData[$this->module][$this->viewDefs][$this->panelName]);
//Special handling to rename certain variables for DetailViews
$rename_fields = array();
foreach($this->customFields as $field_id=>$field){
//Check to see if we need to rename the field for special cases
if(!empty($this->fieldConversionMapping[$this->module][$field_id])) {
$rename_fields[$field_id] = $this->fieldConversionMapping[$this->module][$field['data']['name']];
$this->customFields[$field_id]['data']['name'] = $this->fieldConversionMapping[$this->module][$field['data']['name']];
}
}
foreach($rename_fields as $original_index=>$new_index) {
$this->customFields[$new_index] = $this->customFields[$original_index];
unset($this->customFields[$original_index]);
}
$this->customPanelIds = $this->getPanelIds($this->customData[$this->module][$this->viewDefs][$this->panelName]);
$this->newFields = $this->getFields($this->newData[$this->module][$this->viewDefs][$this->panelName]);
//echo var_export($this->newFields, true);
$this->newPanelIds = $this->getPanelIds($this->newData[$this->module][$this->viewDefs][$this->panelName]);
$this->mergeFields();
$this->mergeTemplateMeta();
$this->setPanels();
}
}
?>

View File

@@ -0,0 +1,751 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*********************************************************************************
* Description: Defines the English language pack for the base application.
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
* All Rights Reserved.
* Contributor(s): ______________________________________..
********************************************************************************/
/**
* This is the base class that all other SugarMerge objects extend
*
*/
class EditViewMerge{
/**
* The variable name that is used with the file for example in editviewdefs and detailviewdefs it is $viewdefs
*
* @var STRING
*/
protected $varName = 'viewdefs';
/**
* Enter the name of the parameter used in the $varName for example in editviewdefs and detailviewdefs it is 'EditView' and 'DetailView' respectively - $viewdefs['EditView']
*
* @var STRING
*/
protected $viewDefs = 'EditView';
/**
* this will store the meta data for the original file
*
* @var ARRAY
*/
protected $originalData = array();
/**
* this will store the meta data for the new file
*
* @var ARRAY
*/
protected $newData = array();
/**
* this will store the meta data for the custom file
*
* @var ARRAY
*/
protected $customData = array();
/**
* this will store an associative array contianing all the fields that are used in the original meta data file
*
* @var ARRAY
*/
protected $originalFields = array();
/**
* this will store an associative array contianing all the fields that are used in the new meta data file
*
* @var ARRAY
*/
protected $newFields = array();
/**
* this will store an associative array contianing all the fields that are used in the custom meta data file
*
* @var ARRAY
*/
protected $customFields = array();
/**
* this will store an associative array contianing all the merged fields
*
* @var ARRAY
*/
protected $mergedFields = array();
/**
* the name of the module to be merged
*
* @var STRING
*/
protected $module = 'module';
/**
* the max number of columns for this view
*
* @var INT
*/
protected $maxCols = 2;
/**
* If we should use the best match algorithim
*
* @var BOOLEAN
*/
protected $bestMatch = true;
/**
* The default panel we place the fields in if we aren't using the best match algorithim
*
* @var STRING
*/
protected $defaultPanel = 'default';
/**
* The name of the panels section in the meta data
*
* @var STRING
*/
protected $panelName = 'panels';
/**
* The name of the templateMeta data secion in the meta data
*/
protected $templateMetaName = 'templateMeta';
/**
* The file pointer to log to if set to NULL it will use the GLOBALS['log'] if available and log to debug
*
* @var FILEPOINTER
*/
protected $fp = NULL;
/**
* Determines if getFields should analyze panels to determine if it is a MultiPanel
*
* @var unknown_type
*/
protected $scanForMultiPanel = true;
/**
* If true then it works as though it's a multipanel
*
* @var BOOLEAN
*/
protected $isMultiPanel = true;
/**
* The ids of the panels found in custom metadata fuke
*
*/
protected $customPanelIds = array();
/**
* The ids of the panels found in original metadata fuke
*
*/
protected $originalPanelIds = array();
/**
* The ids of the panels found in original metadata fuke
*
*/
protected $newPanelIds = array();
/**
* Special case conversion
*
*/
protected $fieldConversionMapping = array(
'Campaigns' => array('created_by_name'=>'date_entered', 'modified_by_name'=>'date_modified'),
'Cases' => array('created_by_name'=>'date_entered', 'modified_by_name'=>'date_modified'),
'Contracts' => array('created_by_name'=>'date_entered', 'modified_by_name'=>'date_modified'),
'Leads' => array('created_by'=>'date_entered'),
'Meetings' => array('created_by_name'=>'date_entered', 'modified_by_name'=>'date_modified'),
'ProspectLists' => array('created_by_name'=>'date_entered', 'modified_by_name'=>'date_modified'),
'Prospects' => array('created_by_name'=>'date_entered', 'modified_by_name'=>'date_modified'),
'Tasks' => array('created_by_name'=>'date_entered', 'modified_by_name'=>'date_modified'),
);
/**
* Clears out the values of the arrays so that the same object can be utilized
*
*/
protected function clear(){
unset($this->newData);
$this->newData = array();
unset($this->customData);
$this->customData = array();
unset($this->originalData);
$this->originalData = array();
unset($this->newFields);
$this->newFields = array();
unset($this->customFields);
$this->customFields = array();
unset($this->originalFields);
$this->originalFields = array();
unset($this->mergedFields);
$this->mergedFields = array();
unset($this->mergeData);
$this->mergeData = array();
$this->defaultPanel = 'default';
}
/**
* Allows the user to choose to use the best match algorithim or not
*
* @param BOOLEAN $on
*/
public function setBestMatch($on=true){
$this->bestMatch = $on;
}
/**
* Allows users to set the name to use as the default panel in the meta data
*
* @param STRING $name - name of the default panel
*/
public function setDefaultPanel($name = 'default'){
$this->defaultPanel = $name;
}
/**
* Allows the user to set a filepointer that is already open to log to
*
* @param FILEPOINTER $fp
*/
public function setLogFilePointer($fp){
$this->fp = $fp;
}
/**
* opens the file with the 'a' parameter and use it to log messages to
*
* @param STRING $file - path to file we wish to log to
*/
public function setLogFile($file){
$this->fp = fopen($file, 'a');
}
/**
*
*/
/**
* returns true if $val1 and $val2 match otherwise it returns false
*
* @param MULTI $val1 - a value to compare to val2
* @param MULTI $val2 - a value to compare to val1
* @return BOOLEAN - if $val1 and $val2 match
*/
protected function areMatchingValues($val1, $val2){
if(!is_array($val1)){
//if val2 is an array and val1 isn't then it isn't a match
if(is_array($val2)){
return false;
}
//otherwise both are not arrays so we can return a comparison between them
return $val1 == $val2;
}else{
//if val1 is an array and val2 isn't then it isn't a match
if(!is_array($val2)){
return false;
}
}
foreach($val1 as $k=>$v){
if(!isset($val2[$k]))return false;
if(!$this->areMatchingValues($val1[$k], $val2[$k])){
return false;
}
unset($val2[$k]);
unset($val1[$k]);
}
//this implies that there are still values left so the two must not match since we unset any matching values
if(!empty($val2)){
return false;
}
return true;
}
/**
* Recursiveley merges two arrays
*
* @param ARRAY $gimp - if keys match this arrays values are overriden
* @param ARRAY $dom - if keys match this arrays values will override the others
* @return ARRAY $merged - the merges array
*/
function arrayMerge($gimp, $dom) {
if(is_array($gimp) && is_array($dom)) {
foreach($dom as $domKey => $domVal) {
if(isset($gimp[$domKey])) {
if(is_array($domVal)) {
$gimp[$domKey] = $this->arrayMerge($gimp[$domKey], $dom[$domKey]);
} else {
$gimp[$domKey] = $domVal;
}
} else {
$gimp[$domKey] = $domVal;
}
}
}
return $gimp;
}
/**
* Merges the meta data of a single field
*
* @param ARRAY $orig - the original meta-data for this field
* @param ARRAY $new - the new meta-data for this field
* @param ARRAY $custom - the custom meta-data for this field
* @return ARRAY $merged - the merged meta-data
*/
protected function mergeField($orig, $new, $custom){
$orig_custom = $this->areMatchingValues($orig, $custom);
$new_custom = $this->areMatchingValues($new, $custom);
// if both are true then there is nothing to merge since all three fields match
if(!($orig_custom && $new_custom)){
$this->log('merging field');
$this->log('original meta-data');
$this->log($orig);
$this->log('new meta-data');
$this->log($new);
$this->log('custom meta-data');
$this->log($custom);
$this->log('merged meta-data');
$log = true;
}else{
return $new;
}
//if orignal and custom match always take the new value or if new and custom match
if($orig_custom || $new_custom){
$this->log($new);
return $new;
}
//if original and new match always take the custom
if($this->areMatchingValues($orig, $new)){
$this->log($custom);
return $custom;
}
if(is_array($custom)) {
//if both new and custom are arrays then at this point new != custom and orig != custom and orig != new so let's merge the custom and the new and return that
if(is_array($new)){
$new = $this->arrayMerge($custom, $new);
$this->log($new);
return $new;
}else{
//otherwise we know that new is not an array and custom has been 'customized' so let's keep those customizations.
$this->log($custom);
return $custom;
}
}
//default to returning the New version of the field
$this->log($new);
return $new;
}
/**
* Merges the fields together and stores them in $this->mergedFields
*
*/
protected function mergeFields() {
foreach($this->customFields as $field=>$data) {
//if we have this field in both the new fields and the original fields - it has existed since the last install/upgrade
if(isset($this->newFields[$field]) && isset($this->originalFields[$field])){
//if both the custom field and the original match then we take the location of the custom field since it hasn't moved
$loc = $this->customFields[$field]['loc'];
$loc['source'] = 'custom';
$do_merge = true;
//Address fields present a special problem...
if(preg_match('/(alt_|primary_|billing_|shipping_)address_street/i', $field, $matches)) {
$prefix = $matches[1];
$city = $prefix . 'address_city';
$postal_code = $prefix . 'address_postalcode';
$state = $prefix . 'address_state';
$country = $prefix . 'address_country';
if(isset($this->customFields[$city]) ||
isset($this->customFields[$postal_code]) ||
isset($this->customFields[$state]) ||
isset($this->customFields[$country])) {
$do_merge = false;
$this->mergedFields[$field] = array(
'data'=>$this->customFields[$field]['data'],
'loc'=>$loc);
}
}
if($do_merge) {
//but we still merge the meta data of the three
$this->mergedFields[$field] = array(
'data'=>$this->mergeField($this->originalFields[$field]['data'], $this->newFields[$field]['data'], $this->customFields[$field]['data']),
'loc'=>$loc);
}
//if it's not set in the new fields then it was a custom field or an original field so we take the custom fields data and set the location source to custom
} else if(!isset($this->newFields[$field])){
$this->mergedFields[$field] = $data;
$this->mergedFields[$field]['loc']['source'] = 'custom';
} else {
//otherwise the field is in both new and custom but not in the orignal so we merge the new and custom data together and take the location from the custom
$this->mergedFields[$field] = array(
'data'=>$this->mergeField('', $this->newFields[$field]['data'], $this->customFields[$field]['data']),
'loc'=>$this->customFields[$field]['loc']);
$this->mergedFields[$field]['loc']['source'] = 'custom';
//echo var_export($this->mergedFields[$field], true);
}
//then we clear out the field from
unset($this->originalFields[$field]);
unset($this->customFields[$field]);
unset($this->newFields[$field]);
}
/**
* These are fields that were removed by the customer
*/
foreach($this->originalFields as $field=>$data){
unset($this->originalFields[$field]);
unset($this->newFields[$field]);
}
/**
* These are fields that were added by sugar
*/
$new_field_panel = $this->defaultPanel;
foreach($this->customPanelIds as $custom_panel_ids=>$panels) {
$new_field_panel = $custom_panel_ids;
}
foreach($this->newFields as $field=>$data){
$data['loc']['source']= 'new';
$data['loc']['panel'] = $new_field_panel;
$this->mergedFields[$field] = array(
'data'=>$data['data'],
'loc'=>$data['loc']);
unset($this->newFields[$field]);
}
}
/**
* Walks through the merged fields and places them in the appropriate place based on their location parameter as well as the choosen algorithim
*
* @return ARRAY $panels - the new panels section for the merged file
*/
protected function buildPanels(){
$panels = array();
$panel_keys = array_keys($this->customPanelIds);
$this->defaultPanel = end($panel_keys);
foreach($this->mergedFields as $field_id=>$field){
//If this field is in a panel not defined in the custom layout, set it to default panel
if(!isset($this->customPanelIds[$field['loc']['panel']])) {
$field['loc']['panel'] = $this->defaultPanel;
}
if($field['loc']['source'] == 'new') {
if($this->bestMatch){
//for best match as long as the column is filled let's keep walking down till we can fill it
$row = end(array_keys($this->customData[$this->module][$this->viewDefs][$this->panelName][$field['loc']['panel']]));
$col = 0;
while(!empty($panels[$field['loc']['panel']][$row][$col])){
$col++;
if($col == 2) {
$row++;
$col = 0;
}
}
//row should be at a point that there is no field in this location
$panels[$field['loc']['panel']][$row][$col] = $field['data'];
}else{
//so for not best match we place it in the default panel at the first available column for the row
$row = 0;
while(!empty($panels[$this->defaultPanel][$row][$field['loc']['col']])){
$row++;
}
$panels[$field['loc']['panel']][$row][$field['loc']['col']] = $field['data'];
}
} else {
$panels[$field['loc']['panel']][$field['loc']['row']][$field['loc']['col']] = $field['data'];
}
}
foreach($panels as $k=>$panel){
foreach($panel as $r=>$row){
ksort($panels[$k][$r]);
}
ksort($panels[$k]);
}
return $panels;
}
/**
* Merge the templateMeta entry for the view defs. Also assume that any changes made in the custom files should
* have precedence since they must be changed manually, even over new files that may be provided in the upgarde
* patch.
*
*/
protected function mergeTemplateMeta()
{
if( isset($this->customData[$this->module][$this->viewDefs][$this->templateMetaName]) )
$this->newData[$this->module][$this->viewDefs][$this->templateMetaName] = $this->customData[$this->module][$this->viewDefs][$this->templateMetaName];
}
/**
* Sets the panel section for the meta-data after it has been merged
*
*/
protected function setPanels(){
$this->newData[$this->module][$this->viewDefs][$this->panelName] = $this->buildPanels();
/*
if(!$this->isMultiPanel) {
$this->newData[$this->module][$this->viewDefs][$this->panelName] = $this->newData[$this->module][$this->viewDefs][$this->panelName][$this->defaultPanel];
}
*/
}
/**
* Parses out the fields for each files meta data and then calls on mergeFields and setPanels
*
*/
protected function mergeMetaData(){
$this->originalFields = $this->getFields($this->originalData[$this->module][$this->viewDefs][$this->panelName]);
$this->originalPanelIds = $this->getPanelIds($this->originalData[$this->module][$this->viewDefs][$this->panelName]);
$this->customFields = $this->getFields($this->customData[$this->module][$this->viewDefs][$this->panelName]);
$this->customPanelIds = $this->getPanelIds($this->customData[$this->module][$this->viewDefs][$this->panelName]);
$this->newFields = $this->getFields($this->newData[$this->module][$this->viewDefs][$this->panelName]);
//echo var_export($this->newFields, true);
$this->newPanelIds = $this->getPanelIds($this->newData[$this->module][$this->viewDefs][$this->panelName]);
$this->mergeFields();
$this->mergeTemplateMeta();
$this->setPanels();
}
/**
* This takes in a list of panels and returns an associative array of field names to the meta-data of the field as well as the locations of that field
*
* @param ARRAY $panels - this is the 'panel' section of the meta-data
* @return ARRAY $fields - an associate array of fields and their meta-data as well as their location
*/
protected function getFields(&$panels){
$fields = array();
$blanks = 0;
$setDefaultPanel = false;
if(count($panels) == 1) {
$arrayKeys = array_keys($panels);
if(!empty($arrayKeys[0])) {
$this->defaultPanel = $arrayKeys[0];
$panels = $panels[$arrayKeys[0]];
} else {
$panels = $panels[''];
}
$setDefaultPanel = true;
}
if($this->scanForMultiPanel){
require_once('include/SugarFields/Parsers/MetaParser.php');
if($setDefaultPanel || !MetaParser::hasMultiplePanels($panels)) {
$panels = array($this->defaultPanel=>$panels);
$this->isMultiPanel = false;
}
}
//echo "---------------------------------------------------------\n";
//echo var_export($panels, true);
foreach($panels as $panel_id=>$panel){
foreach($panel as $row_id=>$rows){
foreach($rows as $col_id=>$col){
if(empty($col)) {
$field_name = 'BLANK_' . $blanks;
$blanks++;
} else {
$field_name = is_array($col) && isset($col['name']) ? $col['name'] : $col;
if(is_array($col)){
if(!empty($col['name'])) {
$field_name = $col['name'];
}
}else{
$field_name = $col;
}
}
if(is_string($field_name)) {
$fields[$field_name] = array('data'=>$col, 'loc'=>array('panel'=>"{$panel_id}", 'row'=>"{$row_id}", 'col'=>"{$col_id}"));
}
}
}
}
//echo "---------------------------------------------------------\n";
//echo var_export($fields, true);
return $fields;
}
/**
* getPanelIds
*
*/
protected function getPanelIds($panels){
$panel_ids = array();
$setDefaultPanel = false;
if(count($panels) == 1) {
$arrayKeys = array_keys($panels);
if(!empty($arrayKeys[0])) {
$this->defaulPanel = $arrayKeys[0];
$panels = $panels[$arrayKeys[0]];
} else {
$panels = $panels[''];
}
$setDefaultPanel = true;
}
if($this->scanForMultiPanel){
require_once('include/SugarFields/Parsers/MetaParser.php');
if($setDefaultPanel || !MetaParser::hasMultiplePanels($panels)) {
$panels = array($this->defaultPanel=>$panels);
$this->isMultiPanel = false;
}
}
foreach($panels as $panel_id=>$panel){
$panel_ids[$panel_id] = $panel_id;
}
return $panel_ids;
}
/**
* Loads the meta data of the original, new, and custom file into the variables originalData, newData, and customData respectively
*
* @param STRING $module - name of the module's files that are to be merged
* @param STRING $original_file - path to the file that originally shipped with sugar
* @param STRING $new_file - path to the new file that is shipping with the patch
* @param STRING $custom_file - path to the custom file
*/
protected function loadData($module, $original_file, $new_file, $custom_file){
$this->module = $module;
$varnmame = $this->varName;
require($original_file);
$this->originalData = $$varnmame;
require($new_file);
$this->newData = $$varnmame;
if(file_exists($custom_file)){
require($custom_file);
$this->customData = $$varnmame;
}else{
$this->customData = $this->originalData;
}
}
/**
* This will save the merged data to a file
*
* @param STRING $to - path of the file to save it to
* @return BOOLEAN - success or failure of the save
*/
public function save($to){
return write_array_to_file("viewdefs['$this->module']['$this->viewDefs']", $this->newData[$this->module][$this->viewDefs], $to);
}
/**
* This will return the meta data of the merged file
*
* @return ARRAY - the meta data of the merged file
*/
public function getData(){
return $this->newData;
}
/**
* public function that will merge meta data from an original sugar file that shipped with the product, a customized file, and a new file shipped with an upgrade
*
* @param STRING $module - name of the module's files that are to be merged
* @param STRING $original_file - path to the file that originally shipped with sugar
* @param STRING $new_file - path to the new file that is shipping with the patch
* @param STRING $custom_file - path to the custom file
* @param BOOLEAN $save - boolean on if it should save the results to the custom file or not
* @return BOOLEAN - if the merged file was saved if false is passed in for the save parameter it always returns true
*/
public function merge($module, $original_file, $new_file, $custom_file=false, $save=true){
$this->clear();
$this->log("\n\n". 'Starting a merge in ' . get_class($this));
$this->log('merging the following files');
$this->log('original file:' . $original_file);
$this->log('new file:' . $new_file);
$this->log('custom file:' . $custom_file);
if(empty($custom_file) && $save){
return true;
}else{
$this->loadData($module, $original_file, $new_file, $custom_file);
$this->mergeMetaData();
if($save && !empty($this->newData) && !empty($custom_file)){
//backup the file
copy($custom_file, $custom_file . '.suback.php');
return $this->save($custom_file);
}
}
if(!$save)return true;
return false;
}
/**
* Logs the given message if the message is not a string it will export it first. If $this->fp is NULL then it will try to log to the $GLOBALS['log'] if it is available
*
* @param MULTI $message
*/
protected function log($message){
if(!is_string($message)){
$message = var_export($message, true);
}
if(!empty($this->fp)){
fwrite($this->fp, $message. "\n");
}else{
if(!empty($GLOBALS['log'])){
$GLOBALS['log']->debug($message . "\n");
}
}
}
}
?>

View File

@@ -0,0 +1,254 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*********************************************************************************
* Description: Defines the English language pack for the base application.
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
* All Rights Reserved.
* Contributor(s): ______________________________________..
********************************************************************************/
require_once('modules/UpgradeWizard/SugarMerge/EditViewMerge.php');
/**
* This class is used to merge list view meta data. It subclasses EditView merge and transforms listview meta data into EditView meta data for the merge and then transforms it back into list view meta data
*
*/
class ListViewMerge extends EditViewMerge{
protected $varName = 'listViewDefs';
protected $viewDefs = 'ListView';
/**
* Loads the meta data of the original, new, and custom file into the variables originalData, newData, and customData respectively it then transforms them into a structure that EditView Merge would understand
*
* @param STRING $module - name of the module's files that are to be merged
* @param STRING $original_file - path to the file that originally shipped with sugar
* @param STRING $new_file - path to the new file that is shipping with the patch
* @param STRING $custom_file - path to the custom file
*/
protected function loadData($module, $original_file, $new_file, $custom_file){
parent::loadData($module, $original_file, $new_file, $custom_file);
$this->originalData = array($module=>array( $this->viewDefs=>array($this->panelName=>array('DEFAULT'=>$this->originalData[$module]))));
$this->customData = array($module=>array( $this->viewDefs=>array($this->panelName=>array('DEFAULT'=>$this->customData[$module]))));
$this->newData = array($module=>array( $this->viewDefs=>array($this->panelName=>array('DEFAULT'=>$this->newData[$module]))));
}
/**
* This takes in a list of panels and returns an associative array of field names to the meta-data of the field as well as the locations of that field
* Since ListViews don't have the concept of rows and columns it takes the panel and the row to be the field name
* @param ARRAY $panels - this is the 'panel' section of the meta-data for list views all the meta data is one panel since it is just a list of fields
* @return ARRAY $fields - an associate array of fields and their meta-data as well as their location
*/
protected function getFields(&$panels, $multiple = true){
$fields = array();
$blanks = 0;
if(!$multiple)$panels = array($panels);
foreach($panels as $panel_id=>$panel){
foreach($panel as $col_id=>$col){
$field_name = $col_id;
$fields[$field_name. $panel_id] = array('data'=>$col, 'loc'=>array('row'=>$col_id, 'panel'=>$col_id));
}
}
return $fields;
}
/**
* This builds the array of fields from the merged fields in the appropriate order
* when building the panels for a list view the most important thing is order
* so we ensure the fields that came from the custom file keep
* their order then we add any new fields at the end
*
* @return ARRAY
*/
protected function buildPanels() {
$panels = array();
//first only deal with ones that have their location coming from the custom source
foreach($this->mergedFields as $id =>$field){
if($field['loc']['source'] == 'custom'){
$panels[$field['loc']['panel']] = $field['data'];
unset($this->mergedFields[$id]);
}
}
//now deal with the rest
foreach($this->mergedFields as $id =>$field){
//Set the default attribute to false for all the rest of these fields since they're not from custom source
$field['data']['default'] = false;
$panels[$field['loc']['panel']] = $field['data'];
}
return $panels;
}
/**
* Since all the meta-data is just a list of fields the panel section should be all the meta data
*
*/
protected function setPanels(){
$this->newData = $this->buildPanels();
}
/**
* This will save the merged data to a file
*
* @param STRING $to - path of the file to save it to
* @return BOOLEAN - success or failure of the save
*/
public function save($to){
return write_array_to_file("$this->varName['$this->module']", $this->newData, $to);
}
/**
* Merges the fields together and stores them in $this->mergedFields
*
*/
protected function mergeFields() {
foreach($this->customFields as $field=>$data){
//if we have this field in both the new fields and the original fields - it has existed since the last install/upgrade
if(isset($this->newFields[$field]) && isset($this->originalFields[$field])){
//if both the custom field and the original match then we take the location of the custom field since it hasn't moved
$loc = $this->customFields[$field]['loc'];
$loc['source'] = 'custom';
//echo var_export($loc, true);
//but we still merge the meta data of the three
$this->mergedFields[$field] = array(
'data'=>$this->mergeField($this->originalFields[$field]['data'], $this->newFields[$field]['data'], $this->customFields[$field]['data']),
'loc'=>$loc);
//if it's not set in the new fields then it was a custom field or an original field so we take the custom fields data and set the location source to custom
} else if(!isset($this->newFields[$field])){
$this->mergedFields[$field] = $data;
$this->mergedFields[$field]['loc']['source'] = 'custom';
} else {
//otherwise the field is in both new and custom but not in the orignal so we merge the new and custom data together and take the location from the custom
$this->mergedFields[$field] = array(
'data'=>$this->mergeField('', $this->newFields[$field]['data'], $this->customFields[$field]['data']),
'loc'=>$this->customFields[$field]['loc']);
$this->mergedFields[$field]['loc']['source'] = 'custom';
//echo var_export($this->mergedFields[$field], true);
}
//then we clear out the field from
unset($this->originalFields[$field]);
unset($this->customFields[$field]);
unset($this->newFields[$field]);
}
/**
* These are fields that were removed by the customer
*/
foreach($this->originalFields as $field=>$data){
unset($this->originalFields[$field]);
unset($this->newFields[$field]);
}
foreach($this->newFields as $field=>$data){
$data['loc']['source']= 'new';
$this->mergedFields[$field] = array(
'data'=>$data['data'],
'loc'=>$data['loc']);
unset($this->newFields[$field]);
}
}
/**
* Merges the meta data of a single field
*
* @param ARRAY $orig - the original meta-data for this field
* @param ARRAY $new - the new meta-data for this field
* @param ARRAY $custom - the custom meta-data for this field
* @return ARRAY $merged - the merged meta-data
*/
protected function mergeField($orig, $new, $custom){
$orig_custom = $this->areMatchingValues($orig, $custom);
$new_custom = $this->areMatchingValues($new, $custom);
// if both are true then there is nothing to merge since all three fields match
if(!($orig_custom && $new_custom)){
$this->log('merging field');
$this->log('original meta-data');
$this->log($orig);
$this->log('new meta-data');
$this->log($new);
$this->log('custom meta-data');
$this->log($custom);
$this->log('merged meta-data');
$log = true;
}else{
return $new;
}
//if orignal and custom match always take the new value or if new and custom match
if($orig_custom || $new_custom){
$this->log($new);
$new['default'] = isset($custom['default']) ? $custom['default'] : false;
return $new;
}
//if original and new match always take the custom
if($this->areMatchingValues($orig, $new)){
$this->log($custom);
return $custom;
}
if(is_array($custom)) {
//if both new and custom are arrays then at this point new != custom and orig != custom and orig != new so let's merge the custom and the new and return that
if(is_array($new)){
$new = $this->arrayMerge($custom, $new);
$this->log($new);
$new['default'] = $custom['default'];
return $new;
}else{
//otherwise we know that new is not an array and custom has been 'customized' so let's keep those customizations.
$this->log($custom);
return $custom;
}
}
//default to returning the New version of the field
$new['default'] = isset($custom['default']) ? $custom['default'] : false;
return $new;
}
}
?>

View File

@@ -0,0 +1,53 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*********************************************************************************
* Description: Defines the English language pack for the base application.
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
* All Rights Reserved.
* Contributor(s): ______________________________________..
********************************************************************************/
require_once('modules/UpgradeWizard/SugarMerge/EditViewMerge.php');
/**
* This class extends the EditViewMerge - since the meta data is relatively the same the only thing that needs to be changed is the parameter for viewdefs
*
*/
class QuickCreateMerge extends EditViewMerge{
protected $viewDefs = 'QuickCreate';
}
?>

View File

@@ -0,0 +1,178 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*********************************************************************************
* Description: Defines the English language pack for the base application.
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
* All Rights Reserved.
* Contributor(s): ______________________________________..
********************************************************************************/
require_once('modules/UpgradeWizard/SugarMerge/ListViewMerge.php');
/**
* SearchMerge is a class for merging search meta data together. This search meta-data has a listing of fields similar to ListViews
*
*/
class SearchMerge extends ListViewMerge{
protected $varName = 'searchdefs';
protected $viewDefs = 'Search';
protected $panelName = 'layout';
/**
* Loads the meta data of the original, new, and custom file into the variables originalData, newData, and customData respectively it then transforms them into a structure that EditView Merge would understand
*
* @param STRING $module - name of the module's files that are to be merged
* @param STRING $original_file - path to the file that originally shipped with sugar
* @param STRING $new_file - path to the new file that is shipping with the patch
* @param STRING $custom_file - path to the custom file
*/
protected function loadData($module, $original_file, $new_file, $custom_file){
EditViewMerge::loadData($module, $original_file, $new_file, $custom_file);
$this->originalData = array($module=>array( $this->viewDefs=>$this->originalData[$module]));
$this->customData = array($module=>array( $this->viewDefs=>$this->customData[$module]));
$this->newData = array($module=>array( $this->viewDefs=>$this->newData[$module]));
}
/**
* This takes in a list of panels and returns an associative array of field names to the meta-data of the field as well as the locations of that field
* Since searchdefs have the concept of basic and advanced those act as panels for merging
* @param ARRAY $panels - this is the 'panel' section of the meta-data for list views all the meta data is one panel since it is just a list of fields
* @return ARRAY $fields - an associate array of fields and their meta-data as well as their location
*/
protected function getFields(&$panels, $multiple = true){
$fields = array();
if(!$multiple)$panels = array($panels);
foreach($panels as $panel_id=>$panel){
foreach($panel as $col_id=>$col){
if(is_array($col)){
$field_name = $col['name'];
}else{
$field_name = $col;
}
$fields[$field_name . $panel_id] = array('data'=>$col, 'loc'=>array('row'=>$col_id, 'panel'=>$panel_id));
}
}
return $fields;
}
/**
* This builds the array of fields from the merged fields in the right order
* when building the panels for a list view the most important thing is order
* so we ensure the fields that came from the custom file keep
* their order then we add any new fields at the end
*
* @return ARRAY
*/
protected function buildPanels(){
$panels = array();
//first only deal with ones that have their location coming from the custom source
foreach($this->mergedFields as $id =>$field){
if($field['loc']['source'] == 'custom'){
$panels[$field['loc']['panel']][] = $field['data'];
unset($this->mergedFields[$id]);
}
}
//now deal with the rest
/*
foreach($this->mergedFields as $id =>$field){
$field['data']['default'] = false;
$panels[$field['loc']['panel']][] = $field['data'];
}
*/
return $panels;
}
/**
* Sets the panel section for the meta-data after it has been merged
*
*/
protected function setPanels(){
$this->newData[$this->module][$this->viewDefs][$this->panelName] = $this->buildPanels();
$this->newData[$this->module] = $this->newData[$this->module][$this->viewDefs];
}
public function save($to){
return write_array_to_file("$this->varName['$this->module']", $this->newData[$this->module], $to);
}
/**
* public function that will merge meta data from an original sugar file that shipped with the product, a customized file, and a new file shipped with an upgrade
*
* @param STRING $module - name of the module's files that are to be merged
* @param STRING $original_file - path to the file that originally shipped with sugar
* @param STRING $new_file - path to the new file that is shipping with the patch
* @param STRING $custom_file - path to the custom file
* @param BOOLEAN $save - boolean on if it should save the results to the custom file or not
* @return BOOLEAN - if the merged file was saved if false is passed in for the save parameter it always returns true
*/
public function merge($module, $original_file, $new_file, $custom_file=false, $save=true){
//Bug 37207
if($module == 'Connectors') {
return false;
}
$this->clear();
$this->log("\n\n". 'Starting a merge in ' . get_class($this));
$this->log('merging the following files');
$this->log('original file:' . $original_file);
$this->log('new file:' . $new_file);
$this->log('custom file:' . $custom_file);
if(empty($custom_file) && $save){
return true;
}else{
$this->loadData($module, $original_file, $new_file, $custom_file);
if(!isset($this->originalData[$module])) {
return false;
}
$this->mergeMetaData();
if($save && !empty($this->newData) && !empty($custom_file)){
//backup the file
copy($custom_file, $custom_file . '.suback.php');
return $this->save($custom_file);
}
}
if(!$save)return true;
return false;
}
}
?>

View File

@@ -0,0 +1,90 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*********************************************************************************
* Description: Defines the English language pack for the base application.
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
* All Rights Reserved.
* Contributor(s): ______________________________________..
********************************************************************************/
require_once('modules/UpgradeWizard/SugarMerge/ListViewMerge.php');
/**
* SubpanelMerge is a class for merging subpanel meta data together. This subpanel meta-data is a mix of the layouts seen in listviews and editviews
*
*/
class SubpanelMerge extends ListViewMerge{
protected $varName = 'subpanel_layout';
protected $viewDefs = 'SubPanel';
/**
* Loads the meta data of the original, new, and custom file into the variables originalData, newData, and customData respectively it then transforms them into a structure that EditView Merge would understand
*
* @param STRING $module - name of the module's files that are to be merged
* @param STRING $original_file - path to the file that originally shipped with sugar
* @param STRING $new_file - path to the new file that is shipping with the patch
* @param STRING $custom_file - path to the custom file
*/
protected function loadData($module, $original_file, $new_file, $custom_file){
parent::loadData($module, $original_file, $new_file, $custom_file);
$this->originalData = array($module=>array( $this->viewDefs=>array($this->panelName=>array('DEFAULT'=>$this->originalData[$module]['list_fields']))));
$this->customData = array($module=>array( $this->viewDefs=>array($this->panelName=>array('DEFAULT'=>$this->customData[$module]['list_fields']))));
$this->mergeData = $this->newData;
$this->newData = array($module=>array( $this->viewDefs=>array($this->panelName=>array('DEFAULT'=>$this->newData[$module]['list_fields']))));
}
/**
* We take mergeData which is a copy of the new meta data prior to merging and set it's list_fields variable to the merged panels
*
*/
protected function setPanels(){
$this->mergeData['list_fields'] = $this->buildPanels();
}
/**
* This will save the merged data to a file
*
* @param STRING $to - path of the file to save it to
* @return BOOLEAN - success or failure of the save
*/
public function save($to){
return write_array_to_file("$this->varName", $this->newData, $to);
}
}
?>

View File

@@ -0,0 +1,197 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*********************************************************************************
* Description: Defines the English language pack for the base application.
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
* All Rights Reserved.
* Contributor(s): ______________________________________..
********************************************************************************/
require_once('modules/UpgradeWizard/SugarMerge/EditViewMerge.php');
require_once('modules/UpgradeWizard/SugarMerge/DetailViewMerge.php');
require_once('modules/UpgradeWizard/SugarMerge/SearchMerge.php');
require_once('modules/UpgradeWizard/SugarMerge/ListViewMerge.php');
require_once('modules/UpgradeWizard/SugarMerge/QuickCreateMerge.php');
/**
* SugarMerge wraps around all the merge functionality of Sugar given a module name and the path to an unzipped patch
*
*/
class SugarMerge {
private $mergeMapping = array();
private $new_path = '';
private $custom_path = 'custom';
private $original_path = '';
private $merged = array();
private $fp = NULL;
function SugarMerge($new_path='', $original_path='', $custom_path='custom') {
$this->new_path = empty($new_path) || preg_match('/[\/]$/', $new_path) ? $new_path : $new_path . '/';
$this->original_path = empty($original_path) || preg_match('/[\/]$/', $original_path) ? $original_path : $original_path . '/';
$this->custom_path = empty($custom_path) || preg_match('/[\/]$/', $custom_path) ? $custom_path : $custom_path . '/';
$this->mergeMapping = array(
'editviewdefs.php'=> new EditViewMerge(),
'detailviewdefs.php'=>new DetailViewMerge(),
'listviewdefs.php'=>new ListViewMerge(),
'searchdefs.php'=>new SearchMerge(),
'quickcreatedefs.php'=>new QuickCreateMerge(),
);
}
function setLogFilePointer($fp){
$this->fp = $fp;
}
/**
* This will run through all the modules that may need merging and determine if there is anything to merge
* if $merge is set to true it will perform the merge
* if $merge and $save are set to true it will perform the merge and save the results in the custom directory
*
* @param BOOLEAN $merge - do we wish to perform the merge if false it will just return a list of files that can be merged
* @param BOOLEAN $save - do we wish to save the merged files to true - $merge must be true for this to apply - otherwise it will simulate merging so you can view the log files of the merge
* @return ARRAY - an associative array of module names to files that were either merged or have the potential to be merged depeneding if $merge and $save are set to true
*/
function mergeAll($merge=true, $save=true){
$this->merged = array();
$searchDirectory = $this->custom_path;
if(!preg_match('/[\/]modules$/si', $searchDirectory)) {
$searchDirectory .= preg_match('/[\/]$/', $this->custom_path) ? 'modules' : '/modules';
}
if(file_exists($searchDirectory)){
$dir = dir($searchDirectory);
while($e = $dir->read()){
if(substr($e , 0, 1) != '.') {
if(is_dir("{$searchDirectory}/{$e}/metadata")){
$this->merged[$e] = $this->mergeModule($e, $merge, $save );
}
}
}
}
return $this->merged;
}
/**
* This will merge any files that need merging for a given module
* if $merge is set to true it will perform the merge
* if $merge and $save are set to true it will perform the merge and save the results in the custom directory
*
* @param STRING $module - the name of the module to merge files for
* @param BOOLEAN $merge - do we wish to perform the merge if false it will just return a list of files that can be merged
* @param BOOLEAN $save - do we wish to save the merged files to true - $merge must be true for this to apply - otherwise it will simulate merging so you can view the log files of the merge
* @return ARRAY - an associative array of files that were either merged or have the potential to be merged depeneding if $merge and $save are set to true
*/
function mergeModule($module, $merge = true, $save=true){
$merged = array();
$path = $this->original_path . 'modules/' . $module . '/metadata/';
$custom_path = $this->custom_path . 'modules/' . $module . '/metadata/';
$new_path = $this->new_path . 'modules/' . $module . '/metadata/';
foreach($this->mergeMapping as $file=>&$object){
if(file_exists("{$custom_path}{$file}") && file_exists("{$new_path}{$file}")){
if($merge){
$merged[$file] = $this->mergeFile($module, $file, $save);
}else{
$merged[$file] = true;
}
}
}
return $merged;
}
/**
* This function will merge a single file for a module
*
* @param STRING $module - name of the module
* @param STRING $file - name of the file
* @param STRING $save - should the merged file be saved to the custom directory
* @return BOOLEAN - success or failure of the merge
*/
function mergeFile($module, $file, $save=true){
$path = $this->original_path . 'modules/' . $module . '/metadata/';
$custom_path = $this->custom_path . 'modules/' . $module . '/metadata/';
$new_path = $this->new_path . 'modules/' . $module . '/metadata/';
if($this->fp) $this->mergeMapping[$file]->setLogFilePointer($this->fp);
if(isset($this->mergeMapping[$file]) && file_exists("{$path}{$file}") && file_exists("{$custom_path}{$file}") && file_exists("{$new_path}{$file}")){
return $this->mergeMapping[$file]->merge($module, "{$path}{$file}", "{$new_path}{$file}", "{$custom_path}{$file}", $save);
}
return false;
}
/**
* Return the custom modules path
*
* @return STRING directory where custom module files are located
*/
function getCustomPath() {
return $this->custom_path;
}
/**
* Return the new upgrade modules path
*
* @return STRING directory where new module files are located
*/
function getNewPath() {
return $this->new_path;
}
/**
* Return the original modules path
*
* @return STRING directory where new module files are located
*/
function getOriginalPath() {
return $this->original_path;
}
}
?>

View File

@@ -0,0 +1,86 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
//Request object must have these property values:
// Module: module name, this module should have a file called TreeData.php
// Function: name of the function to be called in TreeData.php, the function will be called statically.
// PARAM prefixed properties: array of these property/values will be passed to the function as parameter.
require_once('include/JSON.php');
require_once('include/upload_file.php');
//require_once('modules/UpgradeWizard/uw_utils.php');
$json = getJSONobj();
$file_name = $json->decode(html_entity_decode($_REQUEST['file_name']));
if(isset($file_name['jsonObject']) && $file_name['jsonObject'] != null){
$file_name = $file_name['jsonObject'];
}
$filesize = '';
if(file_exists($file_name)){
//$fh = fopen($file_name, 'r');
//$license_contents = fread($fh, filesize($file_name));
//fclose($fh);
$filesize =filesize($file_name);
}
$response = '';
//$GLOBALS['log']->fatal('file name '.$file_name);
//$GLOBALS['log']->fatal('file size loaded '.filesize($file_name));
//if($filesize > ini_get("upload_max_filesize"))
//$GLOBALS['log']->fatal($filesize);
//$GLOBALS['log']->fatal(substr(ini_get("upload_max_filesize"), 0, strlen( ini_get("upload_max_filesize")) - 1));
//get the file size defined in php.ini
//$uploadSizeIni = substr(ini_get("upload_max_filesize"), 0, strlen( ini_get("upload_max_filesize")) - 1);
//$GLOBALS['log']->fatal('Upload php setting Size '.return_bytes(ini_get("upload_max_filesize")));
if($filesize != null){
if(($filesize > return_bytes(ini_get("upload_max_filesize"))) || ($filesize > return_bytes(ini_get("post_max_size")))){
$response=$filesize;
//$response= "<script>alert('File size is bigger than the max_upload-size setting in php.ini. Upgrade attempt will fail. Increase the upload_max_size in php.ini to greater than ')</script>";
}
}
if (!empty($response)) {
echo $response;
}
sugar_cleanup();
exit();
?>

View File

@@ -0,0 +1,94 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*********************************************************************************
* Description:
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights
* Reserved. Contributor(s): ______________________________________..
* *******************************************************************************/
logThis('[At cancel.php]');
logThis('cleaning up files and session. goodbye.');
//Check the current step.
if(isset($_SESSION['install_file']) && file_exists(isset($_SESSION['install_file']))){
@unlink(isset($_SESSION['install_file']));
}
unlinkTempFiles();
unlinkUploadFiles();
resetUwSession();
$uwMain =<<<eoq
<table cellpadding="3" cellspacing="0" border="0">
<tr>
<th align="left">
{$mod_strings['LBL_UW_TITLE_CANCEL']}
</th>
</tr>
<tr>
<td align="left">
<p>
{$mod_strings['LBL_UW_CANCEL_DESC']}
</p>
</td>
</tr>
<tr>
<th align="left">
<input title = "{$mod_strings['LBL_BUTTON_DONE']}"
class = "button"
onclick = "window.location.href ='{$sugar_config['site_url']}/index.php?module=UpgradeWizard&action=index';"
type = "submit"
value = " {$mod_strings['LBL_BUTTON_DONE']} "
id = "done_button" >
</th>
</tr>
</table>
eoq;
$showBack = false;
$showCancel = false;
$showRecheck = false;
$showNext = false;
$stepBack = $_REQUEST['step'] - 1;
$stepNext = $_REQUEST['step'] + 1;
$stepCancel = -1;
$stepRecheck = $_REQUEST['step'];
?>

659
modules/UpgradeWizard/commit.php Executable file
View File

@@ -0,0 +1,659 @@
<?php
if(!defined('sugarEntry') || !sugarEntry)
die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*********************************************************************************
* Description:
* Portions created by SugarCRM are Copyright(C) SugarCRM, Inc. All Rights
* Reserved. Contributor(s): ______________________________________..
* *******************************************************************************/
require_once('include/SugarLogger/SugarLogger.php');
$trackerManager = TrackerManager::getInstance();
$trackerManager->pause();
$trackerManager->unsetMonitors();
$_SESSION['upgrade_complete'] = '';
$_REQUEST['upgradeWizard'] = true;
logThis('[At commit.php]');
$stop = true; // flag to show "next"
//refreshing mod_strings
global $mod_strings;
$curr_lang = 'en_us';
if(isset($GLOBALS['current_language']) && ($GLOBALS['current_language'] != null)){
$curr_lang = $GLOBALS['current_language'];
}
return_module_language($curr_lang, 'UpgradeWizard');
$standardErrorLevel = error_reporting();
logThis("Setting error_reporting() to E_ERROR while running upgrade");
error_reporting(E_ERROR);
set_time_limit(0);
/*
* [unzip_dir] => /Users/curisu/www/head/cache/upload//upgrades/temp/QSugp3
* [zip_from_dir] => SugarEnt-Upgrade-4.0.1-to-4.2.1
* rest_dir: /Users/curisu/www/head/cache/upload/SugarEnt-Upgrade-4.0.1-to-4.2.1-restore
*/
// flag upgradeSql script run method
$_SESSION['schema_change'] = $_REQUEST['schema_change'];
if(didThisStepRunBefore('commit')){
$_SESSION['committed'] = true;
}
else{
set_upgrade_progress('commit','in_progress','commit','in_progress');
}
//Initialize session errors array
if(!isset($_SESSION['sqlSkippedQueries']) && !is_array($_SESSION['sqlSkippedQueries'])){
$_SESSION['sqlSkippedQueries'] = array();
}
// prevent "REFRESH" double commits
if(!isset($_SESSION['committed'])) {
//$_SESSION['committed'] = true; // flag to prevent refresh double-commit
//set the flag at the end though
unset($_SESSION['rebuild_relationships']);
unset($_SESSION['rebuild_extensions']);
//put checks for follwing files
if(!isset($_SESSION['unzip_dir']) || empty($_SESSION['unzip_dir'])) {
logThis('unzipping files in upgrade archive...');
$errors = array();
$base_upgrade_dir = $sugar_config['upload_dir'] . "/upgrades";
$base_tmp_upgrade_dir = "$base_upgrade_dir/temp";
$unzip_dir = '';
//also come up with mechanism to read from upgrade-progress file
if(!isset($_SESSION['install_file']) || empty($_SESSION['install_file']) || !is_file($_SESSION['install_file'])) {
if (file_exists(clean_path($base_tmp_upgrade_dir)) && $handle = opendir(clean_path($base_tmp_upgrade_dir))) {
while (false !== ($file = readdir($handle))) {
if($file !="." && $file !="..") {
//echo $base_tmp_upgrade_dir."/".$file.'</br>';
if(is_file($base_tmp_upgrade_dir."/".$file."/manifest.php")){
require_once($base_tmp_upgrade_dir."/".$file."/manifest.php");
$package_name= $manifest['copy_files']['from_dir'];
//echo file_exists($base_tmp_upgrade_dir."/".$file."/".$package_name).'</br>';
if(file_exists($base_tmp_upgrade_dir."/".$file."/".$package_name) && file_exists($base_tmp_upgrade_dir."/".$file."/scripts") && file_exists($base_tmp_upgrade_dir."/".$file."/manifest.php")){
//echo 'Yeah this the directory '. $base_tmp_upgrade_dir."/".$file;
$unzip_dir = $base_tmp_upgrade_dir."/".$file;
if(file_exists($sugar_config['upload_dir'].'/upgrades/patch/'.$package_name.'.zip')){
$_SESSION['install_file'] = $sugar_config['upload_dir'].'/upgrades/patch/'.$package_name.'.zip';
break;
}
}
}
}
}
}
}
if(!isset($_SESSION['install_file']) || empty($_SESSION['install_file'])){
unlinkTempFiles();
resetUwSession();
echo 'Upload File not found so redirecting to Upgrade Start ';
$redirect_new_wizard = $sugar_config['site_url' ].'/index.php?module=UpgradeWizard&action=index';
echo '<form name="redirect" action="' .$redirect_new_wizard. '" method="POST">';
$upgrade_directories_not_found =<<<eoq
<table cellpadding="3" cellspacing="0" border="0">
<tr>
<th colspan="2" align="left">
<span class='error'><b>'Upload file missing or has been deleted. Refresh the page to go back to UpgradeWizard start'</b></span>
</th>
</tr>
</table>
eoq;
$uwMain = $upgrade_directories_not_found;
return '';
}
$install_file = urldecode( $_SESSION['install_file'] );
$show_files = true;
if(empty($unzip_dir)){
$unzip_dir = mk_temp_dir( $base_tmp_upgrade_dir );
}
$zip_from_dir = ".";
$zip_to_dir = ".";
$zip_force_copy = array();
if(!$unzip_dir){
logThis('Could not create a temporary directory using mk_temp_dir( $base_tmp_upgrade_dir )');
die($mod_strings['ERR_UW_NO_CREATE_TMP_DIR']);
}
//double check whether unzipped .
if(file_exists($unzip_dir ."/scripts") && file_exists($unzip_dir."/manifest.php")){
//already unzipped
}
else{
unzip( $install_file, $unzip_dir );
}
// 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( !is_writable( "config.php" ) ){
return $mod_strings['ERR_UW_CONFIG'];
}
$_SESSION['unzip_dir'] = clean_path($unzip_dir);
$_SESSION['zip_from_dir'] = clean_path($zip_from_dir);
logThis('unzip done.');
} else {
$unzip_dir = $_SESSION['unzip_dir'];
$zip_from_dir = $_SESSION['zip_from_dir'];
}
//check if $_SESSION['unzip_dir'] and $_SESSION['zip_from_dir'] exist
if(!isset($_SESSION['unzip_dir']) || !file_exists($_SESSION['unzip_dir'])
|| !isset($_SESSION['install_file']) || empty($_SESSION['install_file']) || !file_exists($_SESSION['install_file'])){
//redirect to start
unlinkTempFiles();
resetUwSession();
echo 'Upload File not found so redirecting to Upgrade Start ';
$redirect_new_wizard = $sugar_config['site_url' ].'/index.php?module=UpgradeWizard&action=index';
echo '<form name="redirect" action="' .$redirect_new_wizard. '" method="POST">';
$upgrade_directories_not_found =<<<eoq
<table cellpadding="3" cellspacing="0" border="0">
<tr>
<th colspan="2" align="left">
<span class='error'><b>'Upload file missing or has been deleted. Refresh the page to go back to UpgradeWizard start'</b></span>
</th>
</tr>
</table>
eoq;
$uwMain = $upgrade_directories_not_found;
return '';
}
$install_file = urldecode($_SESSION['install_file']);
$file_action = "";
$uh_status = "";
$errors = array();
$out = '';
$backupFilesExist = false;
$rest_dir = clean_path(remove_file_extension($install_file) . "-restore");
///////////////////////////////////////////////////////////////////////////////
//// MAKE BACKUPS OF TARGET FILES
if(!didThisStepRunBefore('commit','commitMakeBackupFiles')){
set_upgrade_progress('commit','in_progress','commitMakeBackupFiles','in_progress');
$errors = commitMakeBackupFiles($rest_dir, $install_file, $unzip_dir, $zip_from_dir, array());
set_upgrade_progress('commit','in_progress','commitMakeBackupFiles','done');
}
//// END MAKE BACKUPS OF TARGET FILES
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//// HANDLE PREINSTALL SCRIPTS
if(empty($errors)) {
$file = "$unzip_dir/" . constant('SUGARCRM_PRE_INSTALL_FILE');
if(is_file($file)) {
$out .= "{$mod_strings['LBL_UW_INCLUDING']}: {$file} <br>\n";
include($file);
logThis('Running pre_install()...');
if(!didThisStepRunBefore('commit','pre_install')){
set_upgrade_progress('commit','in_progress','pre_install','in_progress');
pre_install();
set_upgrade_progress('commit','in_progress','pre_install','done');
}
logThis('pre_install() done.');
}
}
//// HANDLE PREINSTALL SCRIPTS
///////////////////////////////////////////////////////////////////////////////
//Clean smarty from cache
if(is_dir($GLOBALS['sugar_config']['cache_dir'].'smarty')){
$allModFiles = array();
$allModFiles = findAllFiles($GLOBALS['sugar_config']['cache_dir'].'smarty',$allModFiles);
foreach($allModFiles as $file){
//$file_md5_ref = str_replace(clean_path(getcwd()),'',$file);
if(file_exists($file)){
unlink($file);
}
}
}
//Also add the three-way merge here. The idea is after the 451 html files have
//been converted run the 3-way merge. If 500 then just run the 3-way merge
$ce_to_pro_ent = isset($manifest['name']) && ($manifest['name'] == 'SugarCE to SugarPro' || $manifest['name'] == 'SugarCE to SugarEnt');
if(file_exists('modules/UpgradeWizard/SugarMerge/SugarMerge.php')){
require_once('modules/UpgradeWizard/SugarMerge/SugarMerge.php');
if(isset($_SESSION['unzip_dir']) && isset($_SESSION['zip_from_dir'])){
$merger = new SugarMerge($_SESSION['unzip_dir'].'/'.$_SESSION['zip_from_dir']);
$merger->mergeAll();
}
}
//COPY ALL FILES FROM UPLOADED UPGRADE PACKAGE
if(!didThisStepRunBefore('commit','commitCopyNewFiles')){
set_upgrade_progress('commit','in_progress','commitCopyNewFiles','in_progress');
$split = commitCopyNewFiles($unzip_dir, $zip_from_dir);
$copiedFiles = $split['copiedFiles'];
$skippedFiles = $split['skippedFiles'];
set_upgrade_progress('commit','in_progress','commitCopyNewFiles','done');
}
//END COPY NEW FILES INTO TARGET INSTANCE
///////////////////////////////////////////////////////////////////////////////
//// HANDLE POSTINSTALL SCRIPTS
logThis('Starting post_install()...');
if (!function_exists("inDeveloperMode")) {
//this function was introduced from tokyo in the file include/utils.php, so when upgrading from 5.1x and 5.2x we should declare the this function
function inDeveloperMode()
{
return isset($GLOBALS['sugar_config']['developerMode']) && $GLOBALS['sugar_config']['developerMode'];
}
}
if(empty($errors)) {
if(!didThisStepRunBefore('commit','post_install')){
$file = "$unzip_dir/" . constant('SUGARCRM_POST_INSTALL_FILE');
if(is_file($file)) {
//set_upgrade_progress('commit','in_progress','post_install','in_progress');
$progArray['post_install']='in_progress';
post_install_progress($progArray,'set');
include($file);
post_install();
//set process to done
$progArray['post_install']='done';
//set_upgrade_progress('commit','in_progress','post_install','done');
post_install_progress($progArray,'set');
}
}
require("sugar_version.php");
if($_SESSION['current_db_version'] != $_SESSION['target_db_version']){
logThis('Performing UWrebuild()...');
UWrebuild();
global $sugar_version;
$origVersion = substr(preg_replace("/[^0-9]/", "", $_SESSION['current_db_version']),0,3);
if($origVersion < '600') {
_logThis('Check to hide iFrames and Feeds modules', $path);
hide_iframes_and_feeds_modules();
}
logThis('UWrebuild() done.');
}
//set the logger before rebuilding config
if(!isset($sugar_config['logger'])){
$sugar_config['logger'] =array (
'level'=>'fatal',
'file' =>
array (
'ext' => '.log',
'name' => 'sugarcrm',
'dateFormat' => '%c',
'maxSize' => '10MB',
'maxLogs' => 10,
'suffix' => '%m_%Y',
),
);
}
// Set the default max tabs to 7
$sugar_config['default_max_tabs'] = '7';
if(!rebuildConfigFile($sugar_config, $sugar_version)) {
logThis('*** ERROR: could not write config.php! - upgrade will fail!');
$errors[] = $mod_strings['ERR_UW_CONFIG_WRITE'];
}
}
logThis('post_install() done.');
//// END POSTINSTALL SCRIPTS
///////////////////////////////////////////////////////////////////////////////
if($_SESSION['current_db_version'] == $_SESSION['target_db_version']){
$_SESSION['license_seats_needed'] = '';
//Clean modules from cache
if(is_dir($GLOBALS['sugar_config']['cache_dir'].'modules')){
$allModFiles = array();
$allModFiles = findAllFiles($GLOBALS['sugar_config']['cache_dir'].'modules',$allModFiles);
foreach($allModFiles as $file){
//$file_md5_ref = str_replace(clean_path(getcwd()),'',$file);
if(file_exists($file)){
unlink($file);
}
}
}
//Clean jsLanguage from cache
if(is_dir($GLOBALS['sugar_config']['cache_dir'].'jsLanguage')){
$allModFiles = array();
$allModFiles = findAllFiles($GLOBALS['sugar_config']['cache_dir'].'jsLanguage',$allModFiles);
foreach($allModFiles as $file){
//$file_md5_ref = str_replace(clean_path(getcwd()),'',$file);
if(file_exists($file)){
unlink($file);
}
}
}
}
//cleanup cache modules
if(substr($sugar_version,0,1) == 5){
//Clean modules from cache
if(is_dir($GLOBALS['sugar_config']['cache_dir'].'modules')){
$allModFiles = array();
$allModFiles = findAllFiles($GLOBALS['sugar_config']['cache_dir'].'modules',$allModFiles);
foreach($allModFiles as $file){
//$file_md5_ref = str_replace(clean_path(getcwd()),'',$file);
if(file_exists($file)){
unlink($file);
}
}
}
}
//Look for chance folder and delete it if found. Bug 23595
if(function_exists('deleteChance')){
@deleteChance();
}
//also add the cache cleaning here.
if(function_exists('deleteCache')){
@deleteCache();
}
//add tabs
$from_dir = clean_path(remove_file_extension($install_file) . "-restore");
addNewSystemTabsFromUpgrade($from_dir);
//run fix on dropdown lists that may have been incorrectly named
//fix_dropdown_list();
///////////////////////////////////////////////////////////////////////////////
//// REGISTER UPGRADE
logThis('Registering upgrade with UpgradeHistory');
if(!didThisStepRunBefore('commit','upgradeHistory')){
set_upgrade_progress('commit','in_progress','upgradeHistory','in_progress');
if(empty($errors)) {
$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->type = 'patch';
$new_upgrade->version = $sugar_version;
$new_upgrade->status = "installed";
$new_upgrade->manifest =(!empty($_SESSION['install_manifest']) ? $_SESSION['install_manifest'] : '');
$new_upgrade->save();
}
set_upgrade_progress('commit','in_progress','upgradeHistory','done');
}
//// REGISTER UPGRADE
///////////////////////////////////////////////////////////////////////////////
}else{
$backupFilesExist = false;
$copiedFiles = array();
$skippedFiles = array();
}
// flag to prvent double-commits via refresh
$_SESSION['committed'] = true;
///////////////////////////////////////////////////////////////////////////////
//// FINISH AND OUTPUT
if(empty($errors)) {
$stop = false;
}
$backupDesc = '';
if($backupFilesExist) {
$backupDesc .= "<b>{$mod_strings['LBL_UW_BACKUP_FILES_EXIST_TITLE']}</b><br />";
$backupDesc .= $mod_strings['LBL_UW_BACKUP_FILES_EXIST'] . ': ' . $rest_dir;
}
$customized_mods_Desc = '';
$old_schema= '';
$old_schema_opt = '';
$skipped_queries = '';
if($_SESSION['current_db_version'] != $_SESSION['target_db_version']){
global $sugar_version;
$origVersion = substr(preg_replace("/[^0-9]/", "", $_SESSION['current_db_version']),0,3);
$destVersion = substr(preg_replace("/[^0-9]/", "", $_SESSION['target_db_version']),0,3);
//old schema to be dropped
$old_schema_contents = '';
if(file_exists($_SESSION['unzip_dir'].'/scripts/drop_'.$origVersion.'_schema_after_upgrade_'.$destVersion.'.php')){
require_once($_SESSION['unzip_dir'].'/scripts/drop_'.$origVersion.'_schema_after_upgrade_'.$destVersion.'.php');
ob_start();
$old_schema_contents=@drop_preUpgardeSchema(true);
ob_end_clean();
}
if($old_schema_contents != null && strlen($old_schema_contents) >0){
$old_schema = "<p><a href='javascript:void(0); toggleNwFiles(\"old_schemashow\");'>{$mod_strings['LBL_UW_SHOW_OLD_SCHEMA_TO_DROP']}</a>";
$old_schema .= "<div id='old_schemashow' style='display:none;'>";
$old_schema .= "<textarea readonly cols='80' rows='10'>{$old_schema_contents}</textarea>";
$old_schema .= "</div></p>";
$old_schema_opt="<b>{$mod_strings['LBL_UW_DROP_SCHEMA_METHOD']}</b>
<select name=\"schema_drop\" id=\"select_schema_drop\" onchange=\"checkSchemaDropStatus();\">
<option value=\"manual\">{$mod_strings['LBL_UW_DROP_SCHEMA_MANUAL']}</option>
<option value=\"sugar\">{$mod_strings['LBL_UW_DROP_SCHEMA_UPGRADE_WIZARD']}</option>
</select>
";
}
//also add the cache cleaning here.
if(function_exists('deleteCache')){
@deleteCache();
}
}
$copiedDesc = '';
if(count($copiedFiles) > 0) {
$copiedDesc .= "<b>{$mod_strings['LBL_UW_COPIED_FILES_TITLE']}</b><br />";
$copiedDesc .= "<a href='javascript:void(0); toggleNwFiles(\"copiedFiles\");'>{$mod_strings['LBL_UW_SHOW']}</a>";
$copiedDesc .= "<div id='copiedFiles' style='display:none;'>";
foreach($copiedFiles as $file) {
$copiedDesc .= $file . "<br />";
}
$copiedDesc .= "</div>";
}
$skippedDesc = '';
if(count($skippedFiles) > 0) {
$skippedDesc .= "<b>{$mod_strings['LBL_UW_SKIPPED_FILES_TITLE']}</b><br />";
$skippedDesc .= "<a href='javascript:void(0); toggleNwFiles(\"skippedFiles\");'>{$mod_strings['LBL_UW_SHOW']}</a>";
$skippedDesc .= "<div id='skippedFiles' style='display:none;'>";
foreach($skippedFiles as $file) {
$skippedDesc .= $file . "<br />";
}
$skippedDesc .= "</div>";
}
$rebuildResult = "<b>{$mod_strings['LBL_UW_REBUILD_TITLE']}</b><br />";
$rebuildResult .= "<a href='javascript:void(0); toggleRebuild();'>{$mod_strings['LBL_UW_SHOW']}</a> <div id='rebuildResult'></div>";
$rebuildResult = '';
//moving unlink files to last
//unlinkTempFiles();
$skipped_queries_Desc='';
if(isset($_SESSION['sqlSkippedQueries']) && $_SESSION['sqlSkippedQueries'] != null && is_array($_SESSION['sqlSkippedQueries']) && sizeof($_SESSION['sqlSkippedQueries'])>0){
$skipped_queries_Desc .= "<b>{$mod_strings['LBL_UW_SKIPPED_QUERIES_ALREADY_EXIST']}</b><br />";
$skipped_queries_Desc .= "<a href='javascript:void(0); toggleNwFiles(\"skippedQueries\");'>{$mod_strings['LBL_UW_SHOW']}</a>";
$skipped_queries_Desc .= "<div id='skippedQueries' style='display:none;'>";
if($_SESSION['sqlSkippedQueries'] != null){
$skipped_queries_Desc .= $mod_strings['LBL_UW_SKIPPED_QUERIES_ALREADY_EXIST']. "<br />";
foreach($_SESSION['sqlSkippedQueries'] as $skippedQ) {
$skipped_queries_Desc .= $skippedQ . "<br />";
}
}
}
$delete_chance='';
if(isset($_SESSION['chance']) && $_SESSION['chance'] != null){
$delete_chance .= "<b>Remove the folder: {$_SESSION['chance']}</b><br />";
}
if(empty($mod_strings['LBL_UPGRADE_TAKES_TIME_HAVE_PATIENCE'])){
$mod_strings['LBL_UPGRADE_TAKES_TIME_HAVE_PATIENCE'] = 'Upgrade may take some time';
}
///////////////////////////////////////////////////////////////////////////////
//// HANDLE REMINDERS
commitHandleReminders($skippedFiles);
//// HANDLE REMINDERS
///////////////////////////////////////////////////////////////////////////////
logThis("Resetting error_reporting() to system level.");
error_reporting($standardErrorLevel);
///////////////////////////////////////////////////////////////////////////////
//// OUTPUT
$uwMain =<<<eoq
<script type="text/javascript" language="javascript">
function toggleRebuild() {
var target = document.getElementById('rebuildResult');
if(target.innerHTML == '') {
target.innerHTML = rebuildResult; // found in UWrebuild()
} else {
target.innerHTML = '';
}
}
</script>
<table cellpadding="3" cellspacing="0" border="0">
<tr>
<th align="left">
{$mod_strings['LBL_UW_TITLE_COMMIT']}
</th>
</tr>
<tr>
<td align="left">
<p>
{$delete_chance}
</p>
<p>
{$backupDesc}
</p>
<p>
{$customized_mods_Desc}
</p>
<p>
{$copiedDesc}
</p>
<p>
{$skippedDesc}
</p>
<p>
{$skipped_queries_Desc}
</p>
<p>
{$rebuildResult}
</p>
</td>
</tr>
<tr><td>
<p>
{$old_schema}
</p>
</td></tr>
<tr><td>
{$old_schema_opt}
</td></tr>
</table>
<div id="upgradeDiv" style="display:none">
<table cellspacing="0" cellpadding="0" border="0">
<tr><td>
<p><img src='modules/UpgradeWizard/processing.gif'> <br>{$mod_strings['LBL_UPGRADE_TAKES_TIME_HAVE_PATIENCE']}</p>
</td></tr>
</table>
</div>
<script>
function checkSchemaDropStatus() {
if(document.getElementById('select_schema_drop') != null){
var schemaSelect = document.getElementById('select_schema_drop');
var schemaDropMethod = document.getElementById('schema_drop');
if(schemaSelect.options[schemaSelect.selectedIndex].value == 'manual') {
schemaDropMethod.value = 'manual';
} else {
schemaDropMethod.value = 'sugar';
}
}
}
checkSchemaDropStatus();
</script>
eoq;
//set the upgrade progress status.
set_upgrade_progress('commit','done','commit','done');
$showBack = false;
$showCancel = false;
$showRecheck = false;
$showNext =($stop) ? false : true;
$stepBack = $_REQUEST['step'] - 1;
$stepNext = $_REQUEST['step'] + 1;
$stepCancel = -1;
$stepRecheck = $_REQUEST['step'];
$_SESSION['step'][$steps['files'][$_REQUEST['step']]] =($stop) ? 'failed' : 'success';
// clear out the theme cache
// clear out the theme cache
if(!class_exists('SugarThemeRegistry')){
require_once('include/SugarTheme/SugarTheme.php');
}
SugarThemeRegistry::buildRegistry();
SugarThemeRegistry::clearAllCaches();
// re-minify the JS source files
$_REQUEST['root_directory'] = getcwd();
$_REQUEST['js_rebuild_concat'] = 'rebuild';
require_once('jssource/minify.php');

View File

@@ -0,0 +1,81 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*********************************************************************************
* Description:
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights
* Reserved. Contributor(s): ______________________________________..
* *******************************************************************************/
if(ob_get_level() < 1)
ob_start();
ob_implicit_flush(1);
if(!function_exists('getFilesForPermsCheck')) {
require_once('modules/UpgradeWizard/uw_utils.php');
}
if(!isset($sugar_config) || empty($sugar_config)) {
}
// persistence
$persistence = getPersistence();
switch($_REQUEST['commitStep']) {
case 'run_sql':
ob_end_flush();
logThis('commitJson->runSql() called.');
$persistence = commitAjaxRunSql($persistence);
break;
case 'get_errors':
logThis('commitJson->getErrors() called.');
commitAjaxGetSqlErrors($persistence);
break;
case 'post_install':
logThis('commitJson->postInstall() called.');
commitAjaxPostInstall($persistence);
break;
case 'final_touches':
logThis('commitJson->finalTouches() called.');
$persistence = commitAjaxFinalTouches($persistence);
break;
}
savePersistence($persistence);
?>

View File

@@ -0,0 +1,95 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
//Request object must have these property values:
// Module: module name, this module should have a file called TreeData.php
// Function: name of the function to be called in TreeData.php, the function will be called statically.
// PARAM prefixed properties: array of these property/values will be passed to the function as parameter.
require_once('include/JSON.php');
//require_once('modules/UpgradeWizard/uw_utils.php');
$json = getJSONobj();
//Clean modules from cache
if(is_dir($GLOBALS['sugar_config']['cache_dir'].'modules')){
$allModFiles = array();
$allModFiles = findAllFiles($GLOBALS['sugar_config']['cache_dir'].'modules',$allModFiles);
foreach($allModFiles as $file){
if(file_exists($file)){
unlink($file);
}
}
}
//Clean jsLanguage from cache
if(is_dir($GLOBALS['sugar_config']['cache_dir'].'jsLanguage')){
$allModFiles = array();
$allModFiles = findAllFiles($GLOBALS['sugar_config']['cache_dir'].'jsLanguage',$allModFiles);
foreach($allModFiles as $file){
if(file_exists($file)){
unlink($file);
}
}
}
//Clean smarty from cache
if(is_dir($GLOBALS['sugar_config']['cache_dir'].'smarty')){
$allModFiles = array();
$allModFiles = findAllFiles($GLOBALS['sugar_config']['cache_dir'].'smarty',$allModFiles);
foreach($allModFiles as $file){
if(file_exists($file)){
unlink($file);
}
}
}
$response = '';
//$GLOBALS['log']->fatal('file name '.$file_name);
//$GLOBALS['log']->fatal('file size loaded '.filesize($file_name));
/*
if($allModFiles != null){
foreach($allModFiles as $f){
$GLOBALS['log']->fatal('file name '.$f);
$response .= $f;
}
}
*/
if (!empty($response)) {
echo $response;
}
sugar_cleanup();
exit();
?>

312
modules/UpgradeWizard/end.php Executable file
View File

@@ -0,0 +1,312 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*********************************************************************************
* Description:
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights
* Reserved. Contributor(s): ______________________________________..
* *******************************************************************************/
logThis('[At end.php]');
global $unzip_dir;
global $path;
global $sugar_config;
if($unzip_dir == null ) {
$unzip_dir = $_SESSION['unzip_dir'];
}
//First repair the databse to ensure it is up to date with the new vardefs/tabledefs
logThis('About to repair the database.', $path);
//Use Repair and rebuild to update the database.
global $dictionary, $beanFiles;
require_once("modules/Administration/QuickRepairAndRebuild.php");
$rac = new RepairAndClear();
$rac->clearVardefs();
$rac->rebuildExtensions();
$repairedTables = array();
foreach ($beanFiles as $bean => $file) {
if(file_exists($file)){
require_once ($file);
unset($GLOBALS['dictionary'][$bean]);
$focus = new $bean ();
if (($focus instanceOf SugarBean) && !isset($repairedTables[$focus->table_name])) {
$sql = $db->repairTable($focus, true);
logThis('Running sql:' . $sql, $path);
$repairedTables[$focus->table_name] = true;
}
}
}
$olddictionary = $dictionary;
unset ($dictionary);
include ('modules/TableDictionary.php');
foreach ($dictionary as $meta) {
$tablename = $meta['table'];
if (isset($repairedTables[$tablename])) continue;
$fielddefs = $meta['fields'];
$indices = $meta['indices'];
$sql = $GLOBALS['db']->repairTableParams($tablename, $fielddefs, $indices, true);
logThis('Running sql:' . $sql, $path);
$repairedTables[$tablename] = true;
}
$dictionary = $olddictionary;
logThis('database repaired', $path);
$ce_to_pro_ent = isset($_SESSION['upgrade_from_flavor']) && ($_SESSION['upgrade_from_flavor'] == 'SugarCE to SugarPro' || $_SESSION['upgrade_from_flavor'] == 'SugarCE to SugarEnt');
if(isset($_SESSION['current_db_version']) && $_SESSION['current_db_version'] < '550')
{
include("install/seed_data/Advanced_Password_SeedData.php");
}
if(isset($_SESSION['current_db_version']) && $_SESSION['current_db_version'] < '550' && $sugar_config['dbconfig']['db_type'] == 'mssql' && !is_freetds())
{
convertImageToText('import_maps', 'content');
convertImageToText('import_maps', 'default_values');
}
logThis(" Start Rebuilding the config file again", $path);
//check and set the logger before rebuilding config
if(!isset($sugar_config['logger'])){
$sugar_config['logger'] =array (
'level'=>'fatal',
'file' =>
array (
'ext' => '.log',
'name' => 'sugarcrm',
'dateFormat' => '%c',
'maxSize' => '10MB',
'maxLogs' => 10,
'suffix' => '%m_%Y',
),
);
}
if(!rebuildConfigFile($sugar_config, $sugar_version)) {
logThis('*** WARNING: could not write config.php!', $path);
}
logThis(" Finish Rebuilding the config file again", $path);
set_upgrade_progress('end','in_progress');
if(isset($_SESSION['current_db_version']) && isset($_SESSION['target_db_version'])){
if($_SESSION['current_db_version'] != $_SESSION['target_db_version']){
logThis("Upgrading multienum data", $path);
require_once("$unzip_dir/scripts/upgrade_multienum_data.php");
upgrade_multienum_data();
}
//keeping separate. making easily visible and readable
if($_SESSION['current_db_version'] == $_SESSION['target_db_version']){
$_REQUEST['upgradeWizard'] = true;
ob_start();
include('modules/ACL/install_actions.php');
include_once('include/Smarty/internals/core.write_file.php');
ob_end_clean();
$db =& DBManagerFactory::getInstance();
if($ce_to_pro_ent){
//Also set license information
$admin = new Administration();
$category = 'license';
$value = '0';
$admin->saveSetting($category, 'users', $value);
$key = array('num_lic_oc','key','expire_date');
$value = '';
foreach($key as $k){
$admin->saveSetting($category, $k, $value);
}
}
}
}
// Mark the instance as having gone thru the admin wizard
$admin = new Administration();
$admin->saveSetting('system','adminwizard',1);
/////////////////////////Old Logger settings///////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
if(file_exists('modules/Configurator/Configurator.php')){
require_once('include/utils/array_utils.php');
require_once('modules/Configurator/Configurator.php');
$Configurator = new Configurator();
$Configurator->parseLoggerSettings();
}
//unset the logger previously instantiated
if(file_exists('include/SugarLogger/LoggerManager.php')){
unset($GLOBALS['log']);
$GLOBALS['log'] = LoggerManager::getLogger('SugarCRM');
}
require_once('modules/Administration/upgrade_custom_relationships.php');
upgrade_custom_relationships();
//Update the license
logThis('Start Updating the license ', $path);
ob_start();
check_now(get_sugarbeat());
ob_end_clean();
logThis('End Updating the license ', $path);
set_upgrade_progress('end','done');
logThis('Cleaning up the session. Goodbye.');
unlinkTempFiles();
logThis('Cleaning up the session. Goodbye.');
resetUwSession();
// flag to say upgrade has completed
$_SESSION['upgrade_complete'] = true;
//add the clean vardefs here
if(!class_exists('VardefManager')){
}
VardefManager::clearVardef();
require_once('include/TemplateHandler/TemplateHandler.php');
TemplateHandler::clearAll();
//also add the cache cleaning here.
if(function_exists('deleteCache')){
deleteCache();
}
global $mod_strings;
global $current_language;
if(!isset($current_language) || ($current_language == null)){
$current_language = 'en_us';
}
if(isset($GLOBALS['current_language']) && ($GLOBALS['current_language'] != null)){
$current_language = $GLOBALS['current_language'];
}
$mod_strings = return_module_language($current_language, 'UpgradeWizard');
$stop = false;
$httpHost = $_SERVER['HTTP_HOST']; // cn: 8472 - HTTP_HOST includes port in some cases
if($colon = strpos($httpHost, ':')) {
$httpHost = substr($httpHost, 0, $colon);
}
$parsedSiteUrl = parse_url($sugar_config['site_url']);
$host = ($parsedSiteUrl['host'] != $httpHost) ? $httpHost : $parsedSiteUrl['host'];
// aw: 9747 - use SERVER_PORT for users who don't plug in the site_url at install correctly
if ($_SERVER['SERVER_PORT'] != 80){
$port = ":".$_SERVER['SERVER_PORT'];
}
else if (isset($parsedSiteUrl['port']) && $parsedSiteUrl['port'] != 80){
$port = ":".$parsedSiteUrl['port'];
}
else{
$port = '';
}
$path = $parsedSiteUrl['path'];
$cleanUrl = "{$parsedSiteUrl['scheme']}://{$host}{$port}{$path}/index.php";
$uwMain =<<<eoq
<table cellpadding="3" cellspacing="0" border="0">
<tr>
<th align="left">
{$mod_strings['LBL_UW_TITLE_END']}
</th>
</tr>
<tr>
<td align="left">
<p>
{$mod_strings['LBL_UW_END_DESC']}
</p>
<p>
{$mod_strings['LBL_UW_END_DESC2']}
</p>
</td>
</tr>
<tr>
<td align="left">
<p>
<b class="error">{$mod_strings['LBL_UW_END_LOGOUT']}</b>
</p>
<p>
<a href="index.php?module=Users&action=Logout">{$mod_strings['LBL_UW_END_LOGOUT2']}</a>
</p>
</td>
</tr>
<tr>
<td align="left">
<input type="button" value="{$mod_strings['LBL_BUTTON_DONE']}" onclick="deleteCacheAjax();window.location.href='$cleanUrl?module=Home&action=About'">
</td>
</tr>
</table>
<script>
function deleteCacheAjax(){
//AJAX call for checking the file size and comparing with php.ini settings.
var callback = {
success:function(r) {
//alert(r.responseText);
}
}
postData = '&module=UpgradeWizard&action=deleteCache&to_pdf=1';
YAHOO.util.Connect.asyncRequest('POST', 'index.php', callback, postData);
}
</script>
eoq;
$showBack = false;
$showCancel = false;
$showRecheck = false;
$showNext = false;
$stepBack = 0;
$stepNext = 0;
$stepCancel = 0;
$stepRecheck = 0;
$_SESSION['step'][$steps['files'][$_REQUEST['step']]] = ($stop) ? 'failed' : 'success';
?>

484
modules/UpgradeWizard/index.php Executable file
View File

@@ -0,0 +1,484 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*********************************************************************************
* Description:
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights
* Reserved. Contributor(s): ______________________________________..
* *******************************************************************************/
if(!is_admin($current_user)) {
sugar_die($app_strings['ERR_NOT_ADMIN']);
}
require_once('include/utils/db_utils.php');
require_once('include/utils/zip_utils.php');
require_once('modules/UpgradeWizard/uw_utils.php');
require_once('modules/Administration/UpgradeHistory.php');
if(!isset($locale) || empty($locale)) {
$locale = new Localization();
}
global $sugar_config;
global $sugar_flavor;
///////////////////////////////////////////////////////////////////////////////
//// SYSTEM PREP
$base_upgrade_dir = getcwd().'/'.$sugar_config['upload_dir'] . "upgrades";
$base_tmp_upgrade_dir = "$base_upgrade_dir/temp";
$subdirs = array('full', 'langpack', 'module', 'patch', 'theme', 'temp');
global $sugar_flavor;
prepSystemForUpgrade();
$uwMain = '';
$steps = array();
$step = 0;
$showNext = '';
$showCancel = '';
$showBack = '';
$showRecheck = '';
$stepNext = '';
$stepCancel = '';
$stepBack = '';
$stepRecheck = '';
$disableNextForLicense='';
if(!isset($_SESSION['step']) || !is_array($_SESSION['step'])){
$_SESSION['step'] = array();
}
//// END SYSTEM PREP
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//// LOGIC
$uh = new UpgradeHistory();
$smarty = new Sugar_Smarty();
set_upgrade_vars();
//Initialize the session variables. If upgrade_progress.php is already created
//look for session vars there and restore them
initialize_session_vars();
$deletedPackage =false;
$cancelUpgrade = false;
$backOrRecheckUpgrade = false;
// this flag set in pre_install.php->UWUpgrade();
//ADDING A SESSION VARIBALE FOR KEEPING TRACK OF TOTAL UPGRADE TIME.
if(!isset($_SESSION['totalUpgradeTime'])){
$_SESSION['totalUpgradeTime'] = 0;
}
if(!isset($mod_strings['LBL_UW_ACCEPT_THE_LICENSE']) || $mod_strings['LBL_UW_ACCEPT_THE_LICENSE'] == null){
$mod_strings['LBL_UW_ACCEPT_THE_LICENSE'] = 'Accept License';
}
if(!isset($mod_strings['LBL_UW_CONVERT_THE_LICENSE']) || $mod_strings['LBL_UW_CONVERT_THE_LICENSE'] == null){
$mod_strings['LBL_UW_CONVERT_THE_LICENSE'] = 'Convert License';
}
$license_title = $mod_strings['LBL_UW_ACCEPT_THE_LICENSE'];
if((isset($sugar_flavor) && $sugar_flavor != null) && ($sugar_flavor=='OS' || $sugar_flavor=='CE')){
$license_title = $mod_strings['LBL_UW_CONVERT_THE_LICENSE'];
}
if(isset($_REQUEST['delete_package']) && $_REQUEST['delete_package'] == 'true') {
logThis('running delete old package');
$error = '';
if(!isset($_REQUEST['install_file']) || ($_REQUEST['install_file'] == "")) {
logThis('ERROR: trying to delete non-existent file: ['.$_REQUEST['install_file'].']');
$error .= $mod_strings['ERR_UW_NO_FILE_UPLOADED'].'<br>';
}
// delete file in upgrades/patch
$delete_me = urldecode( $_REQUEST['install_file'] );
if(is_file($delete_me) && !@unlink($delete_me)) {
logThis('ERROR: could not delete: '.$delete_me);
$error .= $mod_strings['ERR_UW_FILE_NOT_DELETED'].$delete_me.'<br>';
}
// delete back up instance
$delete_dir = clean_path(remove_file_extension(urldecode($_REQUEST['install_file'])) . "-restore");
if(is_dir($delete_dir) && !@rmdir_recursive($delete_dir)) {
logThis('ERROR: could not delete: '.$delete_dir);
$error .= $mod_strings['ERR_UW_FILE_NOT_DELETED'].$delete_dir.'<br>';
}
// delete file in cache/upload
$fileS = explode('/', $delete_me);
$c = count($fileS);
$fileName = (isset($fileS[$c-1]) && !empty($fileS[$c-1])) ? $fileS[$c-1] : $fileS[$c-2];
$deleteUpload = getcwd().'/'.$sugar_config['upload_dir'].$fileName;
logThis('Trying to delete '.$deleteUpload);
if(is_file($deleteUpload) && !@unlink($deleteUpload)) {
logThis('ERROR: could not delete: ['.$deleteUpload.']');
$error .= $mod_strings['ERR_UW_FILE_NOT_DELETED'].$sugar_config['upload_dir'].$fileName;
}
if(!empty($error)) {
$out = "<b><span class='error'>{$error}</span></b><br />";
$smarty->assign('frozen', $out);
}
}
//redirect to the new upgradewizard
if(isset($_SESSION['Upgraded451Wizard']) && $_SESSION['Upgraded451Wizard']==true){
if(!isset($_SESSION['Initial_451to500_Step'])){
//redirect to the new upgradewizard
$redirect_new_wizard = $sugar_config['site_url' ].'/index.php?module=UpgradeWizard&action=index';
//'<form name="redirect" action="' .$redirect_new_wizard. '" >';
//echo "<meta http-equiv='refresh' content='0; url={$redirect_new_wizard}'>";
$_SESSION['Initial_451to500_Step'] = true;
//unset($_SESSION['step']);
$_REQUEST['step'] = 0;
}
$steps = array(
'files' => array(
'license_fiveO',
'preflight',
'commit',
'end',
'cancel',
),
'desc' => array (
$license_title,
$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{
if(isset($_SESSION['UpgradedUpgradeWizard']) && $_SESSION['UpgradedUpgradeWizard'] == true) {
// Upgrading from 5.0 upwards and upload already performed.
$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{
// Upgrading from 5.0 upwards and upload not performed yet.
$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_UPLOAD_UPGRADE'],
$mod_strings['LBL_UW_TITLE_PREFLIGHT'],
$mod_strings['LBL_UW_TITLE_COMMIT'],
$mod_strings['LBL_UW_TITLE_END'],
$mod_strings['LBL_UW_TITLE_CANCEL'],
),
);
}
}
$upgradeStepFile = '';
if(isset($_REQUEST['step']) && $_REQUEST['step'] !=null){
if($_REQUEST['step'] == -1) {
$_REQUEST['step'] = count($steps['files']) - 1;
} elseif($_REQUEST['step'] >= count($steps['files'])) {
$_REQUEST['step'] = 0;
}
$upgradeStepFile = $steps['files'][$_REQUEST['step']];
} else {
//check if upgrade was run before. If so then resume from there
$previouUpgradeRun = get_upgrade_progress();
if($previouUpgradeRun != null){
//echo 'Previous run '.$previouUpgradeRun.'</br>';
$upgradeStepFile = $previouUpgradeRun;
//reset REQUEST
for($i=0;$i<sizeof($steps['files']);$i++){
if($steps['files'][$i]== $previouUpgradeRun){
$_REQUEST['step']=$i;
break;
}
}
}
else{
// first time through - kill off old sessions
unset($_SESSION['step']);
$_REQUEST['step'] = 0;
$upgradeStepFile = $steps['files'][$_REQUEST['step']];
}
}
if($upgradeStepFile == 'license_fiveO'){
$disableNextForLicense = 'disabled = "disabled"';
}
if($upgradeStepFile == 'end'){
//if(isset($_SESSION['current_db_version']) && substr($_SESSION['current_db_version'],0,1) == 4){
ob_start();
include('modules/ACL/install_actions.php');
include('modules/Administration/RebuildRelationship.php');
//also add the cache cleaning here.
if(function_exists('deleteCache')){
deleteCache();
}
ob_end_clean();
if(isset($_SESSION['current_db_version']) && substr($_SESSION['current_db_version'],0,1) == 4){
//Remove footer from themes except default, love and link themes
logThis('Start removing footer.php file from themes...');
$deleteNot =array('themes/default/footer.php','themes/Love/footer.php','themes/Links/footer.php');
removeFileFromPath('footer.php','themes', $deleteNot);
logThis('End removing footer.php file from themes...');
}
//}
}
require('modules/UpgradeWizard/'.$upgradeStepFile.'.php');
//// END LOGIC
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//// UPGRADE HISTORY
// display installed pieces and versions
$installeds = $uh->getAll();
$upgrades_installed = 0;
$uwHistory = $mod_strings['LBL_UW_DESC_MODULES_INSTALLED']."<br>\n";
$uwHistory .= "<ul>\n";
$uwHistory .= "<table>\n";
$uwHistory .= <<<eoq
<tr>
<th></th>
<th align=left>
{$mod_strings['LBL_ML_NAME']}
</th>
<th align=left>
{$mod_strings['LBL_ML_TYPE']}
</th>
<th align=left>
{$mod_strings['LBL_ML_VERSION']}
</th>
<th align=left>
{$mod_strings['LBL_ML_INSTALLED']}
</th>
<th>
{$mod_strings['LBL_ML_DESCRIPTION']}
</th>
<th>
{$mod_strings['LBL_ML_ACTION']}
</th>
</tr>
eoq;
foreach($installeds as $installed) {
$form_action = '';
$filename = from_html($installed->filename);
$date_entered = $installed->date_entered;
$type = $installed->type;
//rrs only display patches here
if($type == 'patch'){
$version = $installed->version;
$upgrades_installed++;
$link = is_file($filename)? ' <input type="hidden" name="module" value="UpgradeWizard">
<input type="hidden" name="action" value="index">
<input type="hidden" name="step" value="'.$_REQUEST['step'].'">
<input type="hidden" name="delete_package" value="true">
<input type=hidden name="install_file" value="'.$filename.'" />
<input type=submit value="'.$mod_strings['LBL_BUTTON_DELETE'].'" />':'';
$view = 'default';
$target_manifest = remove_file_extension( $filename ) . "-manifest.php";
// cn: bug 9174 - cleared out upgrade dirs, or corrupt entries in upgrade_history give us bad file paths
if(is_file($target_manifest)) {
require_once( "$target_manifest" );
$name = empty($manifest['name']) ? $filename : $manifest['name'];
$description = empty($manifest['description']) ? $mod_strings['LBL_UW_NONE'] : $manifest['description'];
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'] );
}
$uwHistory .= "<form action=\"index.php\" method=\"post\">\n".
"<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".
"</form>\n";
}
}
}
if($upgrades_installed == 0) {
$uwHistory .= "<td colspan='6'>";
$uwHistory .= $mod_strings['LBL_UW_NO_INSTALLED_UPGRADES'];
$uwHistory .= "</td></tr>";
}
$uwHistory .= "</table>\n";
$uwHistory .= "</ul>\n";
//// END UPGRADE HISTORY
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//// PAGE OUTPUT
if($upgradeStepFile=='preflight' || $upgradeStepFile=='commit' || $upgradeStepFile=='end'){
$UW_510RC_PACKAGE_MESSAGE=<<<eoq
<table cellpadding="3" cellspacing="0" border="0">
<tr>
<th colspan="2" align="center">
<h1><span class='error'><b>We do not recommended upgrading your production system to 5.1.0 RC. We recommend upgrading a development system for testing purposes.</b></span></h1>
</th>
</tr>
</table>
eoq;
}
$js=<<<eoq
<script type="text/javascript" language="Javascript">
function toggleNwFiles(target) {
var div = document.getElementById(target);
if(div.style.display == "none") {
div.style.display = "";
} else {
div.style.display = "none";
}
}
function handlePreflight(step) {
if(step == 'preflight') {
if(document.getElementById('select_schema_change') != null){
document.getElementById('schema').value = document.getElementById('select_schema_change').value;
}
if(document.getElementById('diffs') != null) {
/* preset the hidden var for defaults */
checkSqlStatus(false);
theForm = document.getElementById('diffs');
var serial = '';
for(i=0; i<theForm.elements.length; i++) {
if(theForm.elements[i].type == 'checkbox' && theForm.elements[i].checked == false) {
// we only want "DON'T OVERWRITE" files
if(serial != '') {
serial += "::";
}
serial += theForm.elements[i].value;
}
} document.getElementById('overwrite_files_serial').value = serial;
if(document.getElementById('addTask').checked == true) {
document.getElementById('addTaskReminder').value = 'remind';
}
if(document.getElementById('addEmail').checked == true) {
document.getElementById('addEmailReminder').value = 'remind';
}
}
}
return;
}
</script>
eoq;
$smarty->assign('UW_MAIN', $uwMain);
$smarty->assign('UW_JS', $js);
$smarty->assign('CHECKLIST', getChecklist($steps, $step));
$smarty->assign('UW_TITLE', get_module_title($mod_strings['LBL_UW_TITLE'], $mod_strings['LBL_UW_TITLE'].": ".$steps['desc'][$_REQUEST['step']], true));
$smarty->assign('MOD', $mod_strings);
$smarty->assign('APP', $app_strings);
$smarty->assign('GRIDLINE', $current_user->getPreference('gridline'));
$smarty->assign('showNext', $showNext);
$smarty->assign('showCancel', $showCancel);
$smarty->assign('showBack', $showBack);
$smarty->assign('showRecheck', $showRecheck);
$smarty->assign('STEP_NEXT', $stepNext);
$smarty->assign('STEP_CANCEL', $stepCancel);
$smarty->assign('STEP_BACK', $stepBack);
$smarty->assign('STEP_RECHECK', $stepRecheck);
$smarty->assign('step', $steps['files'][$_REQUEST['step']]);
$smarty->assign('UW_HISTORY', $uwHistory);
$smarty->assign('disableNextForLicense',$disableNextForLicense);
if(isset($stop) && $stop == true) {
$frozen = (isset($frozen)) ? "<br />".$frozen : '';
$smarty->assign('frozen', $mod_strings['LBL_UW_FROZEN'].$frozen);
}
if ($sugar_config['sugar_version'] < '5.5') {
$smarty->assign('includeContainerCSS', true);
} else {
$smarty->assign('includeContainerCSS', false);
} // else
$smarty->display('modules/UpgradeWizard/uw_main.tpl');
//// END PAGE OUTPUT
///////////////////////////////////////////////////////////////////////////////
?>

View File

@@ -0,0 +1,277 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*********************************************************************************
* Description:
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights
* Reserved. Contributor(s): ______________________________________..
* *******************************************************************************/
$mod_strings = array(
'DESC_MODULES_INSTALLED' => 'The following modules have been installed:',
'DESC_MODULES_QUEUED' => 'The following modules are ready to be installed:',
'ERR_UW_CANNOT_DETERMINE_GROUP' => 'Cannot determine Group',
'ERR_UW_CANNOT_DETERMINE_USER' => 'Cannot determine Owner',
'ERR_UW_CONFIG_WRITE' => 'Error updating config.php with new version information.',
'ERR_UW_CONFIG' => 'Please make your config.php file writable and reload this page.',
'ERR_UW_DIR_NOT_WRITABLE' => 'Directory not writable',
'ERR_UW_FILE_NOT_COPIED' => 'File not copied',
'ERR_UW_FILE_NOT_DELETED' => 'Problem removing package ',
'ERR_UW_FILE_NOT_READABLE' => 'File could not be read.',
'ERR_UW_FILE_NOT_WRITABLE' => 'File cannot be moved or written to',
'ERR_UW_FLAVOR_2' => 'Upgrade Flavor: ',
'ERR_UW_FLAVOR' => 'SugarCRM System Flavor: ',
'ERR_UW_LOG_FILE_UNWRITABLE' => './upgradeWizard.log could not be created/written to. Please fix permissions on your SugarCRM directory.',
'ERR_UW_MBSTRING_FUNC_OVERLOAD' => 'mbstring.func_overload set to a value higher than 1. Please change this in your php.ini and restart the web server.',
'ERR_UW_MYSQL_VERSION' => 'SugarCRM requires MySQL version 4.1.2 or newer. Found: ',
'ERR_UW_NO_FILE_UPLOADED' => 'Please specify a file and try again!',
'ERR_UW_NO_FILES' => 'An error occurred, no files were found to check.',
'ERR_UW_NO_MANIFEST' => 'The zip file is missing a manifest.php file. Cannot proceed.',
'ERR_UW_NO_VIEW' => 'Invalid view specified.',
'ERR_UW_NO_VIEW2' => 'View not defined. Please go to the Administration home to navigate to this page.',
'ERR_UW_NOT_VALID_UPLOAD' => 'Not valid upload.',
'ERR_UW_NO_CREATE_TMP_DIR' => 'Could not create the temp directory. Check file permissions.',
'ERR_UW_ONLY_PATCHES' => 'You can only upload patches on this page.',
'ERR_UW_PREFLIGHT_ERRORS' => 'Errors Found During Preflight Check',
'ERR_UW_UPLOAD_ERR' => 'There was an error uploading the file, please try again!<br>\n',
'ERR_UW_VERSION' => 'SugarCRM System Version: ',
'ERR_UW_WRONG_TYPE' => 'This page is not for running ',
'ERR_UW_PHP_FILE_ERRORS' => array(
1 => 'The uploaded file exceeds the upload_max_filesize directive in php.ini.',
2 => 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.',
3 => 'The uploaded file was only partially uploaded.',
4 => 'No file was uploaded.',
5 => 'Unknown error.',
6 => 'Missing a temporary folder.',
7 => 'Failed to write file to disk.',
8 => 'File upload stopped by extension.',
),
'LBL_BUTTON_BACK' => 'Back',
'LBL_BUTTON_CANCEL' => 'Cancel',
'LBL_BUTTON_DELETE' => 'Delete Package',
'LBL_BUTTON_DONE' => 'Done',
'LBL_BUTTON_INSTALL' => 'Preflight Upgrade',
'LBL_BUTTON_NEXT' => 'Next',
'LBL_BUTTON_RECHECK' => 'Recheck',
'LBL_UPLOAD_UPGRADE' => 'Upload an upgrade ',
'LBL_UPLOAD_FILE_NOT_FOUND' => 'Upload file not found',
'LBL_UW_BACKUP_FILES_EXIST_TITLE' => 'File Backup',
'LBL_UW_BACKUP_FILES_EXIST' => 'Backed-up files from this upgrade can be found in',
'LBL_UW_BACKUP' => 'File BACKUP',
'LBL_UW_CANCEL_DESC' => 'Upgrade Wizard has been cancelled. All temporary files and the uploaded zip file have been deleted.<br><br>Press "Done" to restart the Upgrade Wizard.',
'LBL_UW_CHARSET_SCHEMA_CHANGE' => 'Character Set Schema Changes',
'LBL_UW_CHECK_ALL' => 'Check All',
'LBL_UW_CHECKLIST' => 'Upgrade Steps',
'LBL_UW_COMMIT_ADD_TASK_DESC_1' => "Backups of Overwritten Files are in the following directory: \n",
'LBL_UW_COMMIT_ADD_TASK_DESC_2' => "Manually merge the following files:\n",
'LBL_UW_COMMIT_ADD_TASK_NAME' => 'Upgrade Process: Manually Merge Files',
'LBL_UW_COMMIT_ADD_TASK_OVERVIEW' => 'Please use whichever diff method is most familiar to you to merge these files. Until this is complete, your SugarCRM installation will be in an uncertain state, and the upgrade incomplete.',
'LBL_UW_COMPLETE' => 'Complete',
'LBL_UW_CONTINUE_CONFIRMATION' => 'This new version of Sugar contains new license agreement. Would you like to continue?',
'LBL_UW_COMPLIANCE_ALL_OK' => 'All system settings requirements satisfied',
'LBL_UW_COMPLIANCE_CALLTIME' => 'PHP Setting: Call Time Pass By Reference',
'LBL_UW_COMPLIANCE_CURL' => 'cURL Module',
'LBL_UW_COMPLIANCE_IMAP' => 'IMAP Module',
'LBL_UW_COMPLIANCE_MBSTRING' => 'MBStrings Module',
'LBL_UW_COMPLIANCE_MBSTRING_FUNC_OVERLOAD' => 'MBStrings mbstring.func_overload Parameter',
'LBL_UW_COMPLIANCE_MEMORY' => 'PHP Setting: Memory Limit',
'LBL_UW_COMPLIANCE_MSSQL_MAGIC_QUOTES' => 'MS SQL Server & PHP Magic Quotes GPC',
'LBL_UW_COMPLIANCE_MYSQL' => 'Minimum MySQL Version',
'LBL_UW_COMPLIANCE_PHP_INI' => 'Location of php.ini',
'LBL_UW_COMPLIANCE_PHP_VERSION' => 'Minimum PHP Version',
'LBL_UW_COMPLIANCE_SAFEMODE' => 'PHP Setting: Safe Mode',
'LBL_UW_COMPLIANCE_TITLE' => 'Server Settings Check',
'LBL_UW_COMPLIANCE_TITLE2' => 'Detected Settings',
'LBL_UW_COMPLIANCE_XML' => 'XML Parsing',
'LBL_UW_COPIED_FILES_TITLE' => 'Files Copied Successfully',
'LBL_UW_CUSTOM_TABLE_SCHEMA_CHANGE' => 'Custom Table Schema Changes',
'LBL_UW_DB_CHOICE1' => 'Upgrade Wizard Runs SQL',
'LBL_UW_DB_CHOICE2' => 'Manual SQL Queries',
'LBL_UW_DB_INSERT_FAILED' => 'INSERT failed - compared results differ',
'LBL_UW_DB_ISSUES_PERMS' => 'Database Privileges',
'LBL_UW_DB_ISSUES' => 'Database Issues',
'LBL_UW_DB_METHOD' => 'Database Update Method',
'LBL_UW_DB_NO_ADD_COLUMN' => 'ALTER TABLE [table] ADD COLUMN [column]',
'LBL_UW_DB_NO_CHANGE_COLUMN' => 'ALTER TABLE [table] CHANGE COLUMN [column]',
'LBL_UW_DB_NO_CREATE' => 'CREATE TABLE [table]',
'LBL_UW_DB_NO_DELETE' => 'DELETE FROM [table]',
'LBL_UW_DB_NO_DROP_COLUMN' => 'ALTER TABLE [table] DROP COLUMN [column]',
'LBL_UW_DB_NO_DROP_TABLE' => 'DROP TABLE [table]',
'LBL_UW_DB_NO_ERRORS' => 'All Privileges Available',
'LBL_UW_DB_NO_INSERT' => 'INSERT INTO [table]',
'LBL_UW_DB_NO_SELECT' => 'SELECT [x] FROM [table]',
'LBL_UW_DB_NO_UPDATE' => 'UPDATE [table]',
'LBL_UW_DB_PERMS' => 'Necessary Privilege',
'LBL_UW_DESC_MODULES_INSTALLED' => 'The following upgrades have been installed:',
'LBL_UW_END_DESC' => 'Congratulations, your system is now upgraded.',
'LBL_UW_END_DESC2' => 'If you have chosen to manually run any steps such as file merges or SQL queries, please do this now. Your system will be in an unstable state until those steps are completed.',
'LBL_UW_END_LOGOUT' => 'Please log out of your account if you plan on upgrading further than this patch/upgrade level.',
'LBL_UW_END_LOGOUT2' => 'Logout',
'LBL_UW_REPAIR_INDEX' => 'For database performance improvements, please run the <a href="index.php?module=Administration&action=RepairIndex" target="_blank">Repair Index</a> script.',
'LBL_UW_FILE_DELETED' => " has been removed.<br>",
'LBL_UW_FILE_GROUP' => 'Group',
'LBL_UW_FILE_ISSUES_PERMS' => 'File Permissions',
'LBL_UW_FILE_ISSUES' => 'File Issues',
'LBL_UW_FILE_NEEDS_DIFF' => 'File Requires Manual Diff',
'LBL_UW_FILE_NO_ERRORS' => '<b>All Files Writable</b>',
'LBL_UW_FILE_OWNER' => 'Owner',
'LBL_UW_FILE_PERMS' => 'Permissions',
'LBL_UW_FILE_UPLOADED' => ' has been uploaded',
'LBL_UW_FILE' => 'File Name',
'LBL_UW_FILES_QUEUED' => 'The following upgrades are ready to be installed:',
'LBL_UW_FILES_REMOVED' => "The following files will be removed from the system:<br>\n",
'LBL_UW_FROZEN' => 'Required steps must be completed before continuing.',
'LBL_UW_HIDE_DETAILS' => 'Hide Details',
'LBL_UW_IN_PROGRESS' => 'In Progress',
'LBL_UW_INCLUDING' => 'Including',
'LBL_UW_INCOMPLETE' => 'Incomplete',
'LBL_UW_INSTALL' => 'File INSTALL',
'LBL_UW_MANUAL_MERGE' => 'File Merge',
'LBL_UW_MODULE_READY_UNINSTALL' => "Module is ready to be uninstalled. Click \"Commit\" to proceed with uninstallation.<br>\n",
'LBL_UW_MODULE_READY' => "Module is ready to be installed. Click \"Commit\" to proceed with installation.",
'LBL_UW_NO_INSTALLED_UPGRADES' => 'No recorded Upgrades detected.',
'LBL_UW_NONE' => 'None',
'LBL_UW_NOT_AVAILABLE' => 'Not available',
'LBL_UW_OVERWRITE_DESC' => "All changed files will be overwritten, including any code customizations and template changes you have made. Are you sure you want to proceed?",
'LBL_UW_OVERWRITE_FILES_CHOICE1' => 'Overwrite All Files',
'LBL_UW_OVERWRITE_FILES_CHOICE2' => 'Manual Merge - Preserve All',
'LBL_UW_OVERWRITE_FILES' => 'Merge Method',
'LBL_UW_PATCH_READY' => 'The patch is ready to proceed. Click the "Commit" button below to complete the upgrade process.',
'LBL_UW_PATCH_READY2' => '<h2>Notice: Customized Layouts Found</h2><br />The following file(s) have new fields or modified screen layouts applied via the Studio. The patch you are about to install also contains changes to the file(s). For <u>each file</u> you may:<br><ul><li>[<b>Default</b>] Retain your version by leaving the checkbox blank. The patch modifications will be ignored.</li>or<li>Accept the updated files by selecting the checkbox. Your layouts will need to be re-applied via Studio.</li></ul>',
'LBL_UW_PREFLIGHT_ADD_TASK' => 'Create Task Item for Manual Merge?',
'LBL_UW_PREFLIGHT_COMPLETE' => 'Preflight Check',
'LBL_UW_PREFLIGHT_DIFF' => 'Differentiated ',
'LBL_UW_PREFLIGHT_EMAIL_REMINDER' => 'Email Yourself a Reminder for Manual Merge?',
'LBL_UW_PREFLIGHT_FILES_DESC' => 'The files listed below have been modified. Uncheck items that require a manual merge. <i>Any detected layout changes are automatically unchecked; checkmark any that should be overwritten.',
'LBL_UW_PREFLIGHT_NO_DIFFS' => 'No Manual File Merge Required.',
'LBL_UW_PREFLIGHT_NOT_NEEDED' => 'Not needed.',
'LBL_UW_PREFLIGHT_PRESERVE_FILES' => 'Auto-preserved Files:',
'LBL_UW_PREFLIGHT_TESTS_PASSED' => 'All Preflight tests passed. Press "Next" to commit these changes.',
'LBL_UW_PREFLIGHT_TOGGLE_ALL' => 'Toggle All Files',
'LBL_UW_REBUILD_TITLE' => 'Rebuild Result',
'LBL_UW_SCHEMA_CHANGE' => 'Schema Changes',
'LBL_UW_SHOW_COMPLIANCE' => 'Show Detected Settings',
'LBL_UW_SHOW_DB_PERMS' => 'Show Missing Database Permissions',
'LBL_UW_SHOW_DETAILS' => 'Show Details',
'LBL_UW_SHOW_DIFFS' => 'Show Files Requiring Manual Merge',
'LBL_UW_SHOW_NW_FILES' => 'Show Files with Bad Permissions',
'LBL_UW_SHOW_SCHEMA' => 'Show Schema Change Script',
'LBL_UW_SHOW_SQL_ERRORS' => 'Show Bad Queries',
'LBL_UW_SHOW' => 'Show',
'LBL_UW_SKIPPED_FILES_TITLE' => 'Skipped Files',
'LBL_UW_SKIPPING_FILE_OVERWRITE' => 'Skipping File Overwrites - Manual Merge Selected.',
'LBL_UW_SQL_RUN' => 'Check when SQL has been manually run',
'LBL_UW_START_DESC' => 'Welcome to the SugarCRM Upgrade Wizard. This wizard is designed to assist administrators when upgrading their SugarCRM instances. Please follow the instructions carefully.',
'LBL_UW_START_DESC2' => 'We highly recommend that you perform the upgrade on a cloned instance of your production server first. Please backup the database and the system files (all of the files in the SugarCRM folder) before performing this operation.',
'LBL_UW_START_UPGRADED_UW_DESC' => 'The new Upgrade Wizard will now resume the upgrade process. Please continue your upgrade.',
'LBL_UW_START_UPGRADED_UW_TITLE' => 'Welcome to the new Upgrade Wizard',
'LBL_UW_SYSTEM_CHECK_CHECKING' => 'Now checking, please wait. This could take up to 30 seconds.',
'LBL_UW_SYSTEM_CHECK_FILE_CHECK_START' => 'Finding all pertinent files to check.',
'LBL_UW_SYSTEM_CHECK_FILES' => 'Files',
'LBL_UW_SYSTEM_CHECK_FOUND' => 'Found',
'LBL_UW_TITLE_CANCEL' => 'Cancel',
'LBL_UW_TITLE_COMMIT' => 'Commit Upgrade',
'LBL_UW_TITLE_END' => 'Debrief',
'LBL_UW_TITLE_PREFLIGHT' => 'Preflight Check',
'LBL_UW_TITLE_START' => 'Start',
'LBL_UW_TITLE_SYSTEM_CHECK' => 'System Checks',
'LBL_UW_TITLE_UPLOAD' => 'Upload Upgrade',
'LBL_UW_TITLE' => 'Upgrade Wizard',
'LBL_UW_UNINSTALL' => 'Uninstall',
//500 upgrade labels
'LBL_UW_ACCEPT_THE_LICENSE' => 'Accept License',
'LBL_UW_CONVERT_THE_LICENSE' => 'Convert License',
'LBL_UW_CUSTOMIZED_OR_UPGRADED_MODULES' => 'Upgraded/Customized Modules',
'LBL_UW_FOLLOWING_MODULES_CUSTOMIZED' => 'The following modules are detected as customized and preserved',
'LBL_UW_FOLLOWING_MODULES_UPGRADED' => 'The following modules are detected as Studio-customized and have been upgraded',
'LBL_UW_SUGAR_COMMUNITY_EDITION_LICENSE' => 'The Sugar Community Edition 5.0 uses GNU Affero General Public License version 3. This upgrade will convert your existing license to the new license displayed below.',
'LBL_START_UPGRADE_IN_PROGRESS' => 'Start in progress',
'LBL_SYSTEM_CHECKS_IN_PROGRESS' => 'System Checks in progress',
'LBL_LICENSE_CHECK_IN_PROGRESS' => 'License Check in progress',
'LBL_PREFLIGHT_CHECK_IN_PROGRESS' => 'Preflight Check in progress',
'LBL_COMMIT_UPGRADE_IN_PROGRESS' => 'Commit Upgrade in progress',
'LBL_UPGRADE_SUMMARY_IN_PROGRESS' => 'Upgrade Summary in progress',
'LBL_UPGRADE_IN_PROGRESS' => 'in progress ',
'LBL_UPGRADE_TIME_ELAPSED' => 'Time elapsed',
'LBL_UPGRADE_CANCEL_IN_PROGRESS' => 'Upgrade Cancel and Cleanup in progress',
'LBL_UPGRADE_TAKES_TIME_HAVE_PATIENCE' => 'Upgrade may take some time',
'LBL_UPLOADE_UPGRADE_IN_PROGRESS' => 'Upload checks in progress',
'LBL_UPLOADING_UPGRADE_PACKAGE' => 'Uploading upgrade package... ',
'LBL_UW_DORP_THE_OLD_SCHMEA' => 'Would you like Sugar to drop the depricated 451 Schema ?',
'LBL_UW_DROP_SCHEMA_UPGRADE_WIZARD' => 'Upgrade Wizard Drops old 451 schema',
'LBL_UW_DROP_SCHEMA_MANUAL' => 'Manual Drop Schema Post Upgrade',
'LBL_UW_DROP_SCHEMA_METHOD' => 'Old Schema Drop Method',
'LBL_UW_SHOW_OLD_SCHEMA_TO_DROP' => 'Show Old Schema that could be dropped',
'LBL_UW_SKIPPED_QUERIES_ALREADY_EXIST' => 'Skipped Queries',
'LBL_INCOMPATIBLE_PHP_VERSION' => 'Php version 5 or above is required.',
'ERR_CHECKSYS_PHP_INVALID_VER' => 'Your version of PHP is not supported by Sugar. You will need to install a version that is compatible with the Sugar application. Please consult the Compatibility Matrix in the Release Notes for supported PHP Versions. Your version is ',
'LBL_BACKWARD_COMPATIBILITY_ON' => 'Php Backward Compatibility mode is turned on. Set zend.ze1_compatibility_mode to Off for proceeding further',
//including some strings from moduleinstall that are used in Upgrade
'LBL_ML_ACTION' => 'Action',
'LBL_ML_CANCEL' => 'Cancel',
'LBL_ML_COMMIT'=>'Commit',
'LBL_ML_DESCRIPTION' => 'Description',
'LBL_ML_INSTALLED' => 'Date Installed',
'LBL_ML_NAME' => 'Name',
'LBL_ML_PUBLISHED' => 'Date Published',
'LBL_ML_TYPE' => 'Type',
'LBL_ML_UNINSTALLABLE' => 'Uninstallable',
'LBL_ML_VERSION' => 'Version',
'LBL_ML_INSTALL'=>'Install',
//adding the string used in tracker. copying from homepage
'LBL_HOME_PAGE_4_NAME' => 'Tracker',
'LBL_CURRENT_PHP_VERSION' => '(Your current php version is ',
'LBL_RECOMMENDED_PHP_VERSION' => '. Recommended php version is 5.2.1 or above)',
'LBL_MODULE_NAME' => 'UpgradeWizard',
);
?>

View File

@@ -0,0 +1,278 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* The contents of this file are subject to the SugarCRM Professional End User
* License Agreement ("License") which can be viewed at
* http://www.sugarcrm.com/crm/products/sugar-professional-eula.html
* By installing or using this file, You have unconditionally agreed to the
* terms and conditions of the License, and You may not use this file except in
* compliance with the License. Under the terms of the license, You shall not,
* among other things: 1) sublicense, resell, rent, lease, redistribute, assign
* or otherwise transfer Your rights to the Software, and 2) use the Software
* for timesharing or service bureau purposes such as hosting the Software for
* commercial gain and/or for the benefit of a third party. Use of the Software
* may be subject to applicable fees and any use of the Software without first
* paying applicable fees is strictly prohibited. You do not have the right to
* remove SugarCRM copyrights from the source code or user interface.
*
* 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.
*
* Your Warranty, Limitations of liability and Indemnity are expressly stated
* in the License. Please refer to the License for the specific language
* governing these rights and limitations under the License. Portions created
* by SugarCRM are Copyright (C) 2004-2006 SugarCRM, Inc.; All Rights Reserved.
********************************************************************************/
/*********************************************************************************
* $Id: en_us.lang.php,v 1.6 2006/07/13 01:36:00 chris Exp $
* Description:
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights
* Reserved. Contributor(s): ______________________________________..
* *******************************************************************************/
/*********************************************************************************
* pl_pl.lang.php,v for SugarCRM 4.5-->>
* Translator: Krzysztof Morawski
* All Rights Reserved.
* Any bugs report welcome: krzysiek<at>mojsklepik<dot>net
* Contributor(s): ______________________________________..
********************************************************************************/
$mod_strings = array(
'DESC_MODULES_INSTALLED' => 'Następujący moduł został zainstalowany:',
'DESC_MODULES_QUEUED' => 'Następujące moduły są przygotowane do Instalacji:',
'ERR_UW_CANNOT_DETERMINE_GROUP' => 'Nie można określić grupy',
'ERR_UW_CANNOT_DETERMINE_USER' => 'NIe można określić właściciela',
'ERR_UW_CONFIG_WRITE' => 'Błąd uaktualnienia informacji o nowej wersji w pliku config.php.',
'ERR_UW_CONFIG' => 'Uczyń plik config.php zapisywalnym i załaduj ponownie tę stronę.',
'ERR_UW_DIR_NOT_WRITABLE' => 'Niezapisywalny katalog',
'ERR_UW_FILE_NOT_COPIED' => 'Plik nie został skopiowany',
'ERR_UW_FILE_NOT_DELETED' => 'Problem z usunięciem pakietu ',
'ERR_UW_FILE_NOT_READABLE'=> 'Plik nie może być odczytany.',
'ERR_UW_FILE_NOT_WRITABLE' => 'Plik nie może zostać przesunięty, ani nadpisany',
'ERR_UW_FLAVOR_2' => 'Ulepsz system: ',
'ERR_UW_FLAVOR' => 'SugarCRM system: ',
'ERR_UW_LOG_FILE_UNWRITABLE' => 'Plik ./upgradeWizard.log nie mógł być stworzony/zapisany. Popraw uprawnienia w Twoim katalogu SugarCRM.',
'ERR_UW_MBSTRING_FUNC_OVERLOAD' => 'Funkcja mbstring.func_overload ma ustawioną wartość na więcej niż 1. Zmień ją w twoim php.ini i przeładuj server.',
'ERR_UW_MYSQL_VERSION' => 'SugarCRM wymaga wersji MySQL 4.1.2 lub wyższej. Znaleziono: ',
'ERR_UW_NO_FILE_UPLOADED' => 'Podaj nazwę pliku i spróbuj ponownie!<br>\n',
'ERR_UW_NO_FILES' => 'Wykryto błąd. Nie znaleziono plików do sprawdzenia.',
'ERR_UW_NO_MANIFEST' => 'Archiwum zip nie zawiera pliku manifest.php. Nie można kontynuować',
'ERR_UW_NO_VIEW' => 'Określono nieprawidłowo widok.',
'ERR_UW_NO_VIEW2'=> 'Widok nie został zdefiniowany. Idź do głównej strony panelu administracyjnego aby przejśc do tej strony.',
'ERR_UW_NOT_VALID_UPLOAD'=> 'Nieprawidłowy plik do załadownia.',
'ERR_UW_NO_CREATE_TMP_DIR' => 'Nie moge utworzyć katalogu tymczasowego. Sprawdź prawa do plików.',
'ERR_UW_ONLY_PATCHES' => 'Tylko na tej stronie możesz załadować poprawki.',
'ERR_UW_PREFLIGHT_ERRORS' => 'Znaleziono błędy podzczas wstępnej instalacji',
'ERR_UW_UPLOAD_ERR' => 'Wystąpił problem podczas załadowania pliku. Spróbuj jeszcze raz!<br>\n',
'ERR_UW_VERSION' => 'Wersja systemu SugarCRM: ',
'ERR_UW_WRONG_TYPE'=> 'Ta strona nie może być wyświetlona ',
'ERR_UW_PHP_FILE_ERRORS'=> array(
1 => 'Ładowane pliki przekraczają dopuszczalną wielkość, określoną w dyrektywie upload_max_filesize w pliku php.ini.',
2 => 'Ładowane pliki przekraczają dopuszczalną wielkość, określoną w dyrektywie MAX_FILE_SIZE, określoną w formularzu HTML.',
3 => 'Pliki zostały załadowane częściowo.',
4 => 'Zadne pliki nie zostały załadowane.',
5 => 'Nieznany błąd.',
6 => 'Brak foldera tymczasowego.',
7 => 'Nie można zapisać pliku na dysku.',
8 => 'Ładowanie pliku zatrzymane z podowu rozszerzenia.',
),
'LBL_BUTTON_BACK'=> 'Powrót',
'LBL_BUTTON_CANCEL'=> 'Skasuj',
'LBL_BUTTON_DELETE'=> 'Usuń pakiet',
'LBL_BUTTON_DONE'=> 'Zrobione',
'LBL_BUTTON_INSTALL'=> 'Wstępna instalacja',
'LBL_BUTTON_NEXT'=> 'Dalej',
'LBL_BUTTON_RECHECK'=> 'Sprawdź ponownie',
'LBL_UPLOAD_UPGRADE'=> 'Załaduj poprawkę: ',
'LBL_UPLOAD_FILE_NOT_FOUND'=> 'Nie znaleziono pliku aktualizacji',
'LBL_UW_BACKUP_FILES_EXIST_TITLE'=> 'Kopia zapasowa pliku',
'LBL_UW_BACKUP_FILES_EXIST' => 'Pliki określające z tego ulepszenia znajdują się w ',
'LBL_UW_BACKUP'=> 'Kopia zapasowa pliku',
'LBL_UW_CANCEL_DESC'=> 'Kreator ulepszeń został zatrzymany. Wszystkie pliki tymczasowe i załadowanie archiwa zip zostały usunięte.<br><br>Naciśnij Zrobione, aby wznowić działanie kreaotra.',
'LBL_UW_CHARSET_SCHEMA_CHANGE'=> 'Zmiany schematu kodowania znaków',
'LBL_UW_CHECK_ALL'=> 'Sprawdź wszystko',
'LBL_UW_CHECKLIST'=> 'Kroki podczas ulepszania',
'LBL_UW_COMMIT_ADD_TASK_DESC_1'=> 'Kopia bezpieczeństwa nadpisanych plików znajdują sie w następującym katalogu: \n',
'LBL_UW_COMMIT_ADD_TASK_DESC_2' => 'Połącz ręcznie następujące pliki:\n',
'LBL_UW_COMMIT_ADD_TASK_NAME' => 'Proces Ulepszania: Połączenie ręczne plików',
'LBL_UW_COMMIT_ADD_TASK_OVERVIEW'=> 'Użyj najlepszej dla siebie metody porównania plików podczas scalania. Do czasu zakończenia procesu ulepszania Twoja instalacja jest niestabilna.',
'LBL_UW_COMPLETE'=> 'Zakończono',
'LBL_UW_CONTINUE_CONFIRMATION' => 'Nowa wersja Sugar zawiera nową umowę licencyjną. Czy chcesz kontynuować?',
'LBL_UW_COMPLIANCE_ALL_OK'=> 'Wszystkie wymagane ustawienia systemowe są właściwe',
'LBL_UW_COMPLIANCE_CALLTIME' => 'Ustawienia PHP: Wywołanie poszczególnych funkcji',
'LBL_UW_COMPLIANCE_CURL'=> 'Moduł cURL',
'LBL_UW_COMPLIANCE_IMAP'=> 'Moduł IMAP',
'LBL_UW_COMPLIANCE_MBSTRING'=> 'Moduł MBStrings',
'LBL_UW_COMPLIANCE_MBSTRING_FUNC_OVERLOAD' => 'Parametr MBStrings mbstring.func_overload',
'LBL_UW_COMPLIANCE_MEMORY'=> 'Ustawienie PHP: Limit pamięci',
'LBL_UW_COMPLIANCE_MSSQL_MAGIC_QUOTES' => 'Serwer MS SQL i PHP Magic Quotes GPC',
'LBL_UW_COMPLIANCE_MYSQL'=> 'Minimalna wersja MySQL',
'LBL_UW_COMPLIANCE_PHP_INI'=> 'Położenie pliku php.ini',
'LBL_UW_COMPLIANCE_PHP_VERSION'=> 'Minimalna wersja PHP ',
'LBL_UW_COMPLIANCE_SAFEMODE'=> 'Ustawienie PHP: Tryb bezpieczny',
'LBL_UW_COMPLIANCE_TITLE' => 'Sprawdzenie ustawień serwera',
'LBL_UW_COMPLIANCE_TITLE2'=> 'Wykryte ustawienia',
'LBL_UW_COMPLIANCE_XML'=> 'Parser XML',
'LBL_UW_COPIED_FILES_TITLE'=> 'Pliki zostały skopiowane pomyślnie',
'LBL_UW_CUSTOM_TABLE_SCHEMA_CHANGE'=> 'Zmiany dostosowywanych schematów tabeli',
'LBL_UW_DB_CHOICE1'=> 'Kreator aktualizacji skryptem SQL',
'LBL_UW_DB_CHOICE2'=> 'Ręczne zapytania SQL',
'LBL_UW_DB_INSERT_FAILED' => 'INSERT nie powiódł się - rezultat porównania rózni się',
'LBL_UW_DB_ISSUES_PERMS'=> 'Brak uprawnień',
'LBL_UW_DB_ISSUES'=> 'Wersja bazy',
'LBL_UW_DB_METHOD'=> 'Metoda aktualizacji bazy',
'LBL_UW_DB_NO_ADD_COLUMN' => 'ALTER TABLE [tabela] ADD COLUMN [kolumna]',
'LBL_UW_DB_NO_CHANGE_COLUMN' => 'ALTER TABLE [tabela] CHANGE COLUMN [kolumna]',
'LBL_UW_DB_NO_CREATE'=> 'CREATE TABLE [tabela]',
'LBL_UW_DB_NO_DELETE'=> 'DELETE FROM [tabela]',
'LBL_UW_DB_NO_DROP_COLUMN' => 'ALTER TABLE [tabela] DROP COLUMN [kolumna]',
'LBL_UW_DB_NO_DROP_TABLE'=> 'DROP TABLE [tabela]',
'LBL_UW_DB_NO_ERRORS'=> 'Nie stwierdzono braku uprawnień',
'LBL_UW_DB_NO_INSERT'=> 'INSERT INTO [tabela]',
'LBL_UW_DB_NO_SELECT'=> 'SELECT [x] FROM [tabela]',
'LBL_UW_DB_NO_UPDATE'=> 'UPDATE [tabela]',
'LBL_UW_DB_PERMS'=> 'Niezbędne uprawnienia',
'LBL_UW_DESC_MODULES_INSTALLED' => 'Następujące ulepszenia zostały zainstalowane:',
'LBL_UW_END_DESC' => 'Gratulacje, Twój system jest teraz ulepszony.',
'LBL_UW_END_DESC2'=> 'Jeżeli zdecydowałeś o ręcznym wykonaniu kroków, takich jak łączenie plików, lub zapytania SQL, zrób to teraz. Twój system będzie niestabilny, dopóki nie wykonasz tych kroków.',
'LBL_UW_END_LOGOUT'=> 'Proszę się wylogować, jeżeli planujesz przejść dalej w procesie ulepszania.',
'LBL_UW_END_LOGOUT2'=> 'Wyloguj',
'LBL_UW_REPAIR_INDEX'=> 'W celu zwiększenia wydajności bazy, wykonaj skrypt <a href="index.php?module=Administration&action=RepairIndex" target="_blank">Repair Index</a>',
'LBL_UW_FILE_DELETED'=> ' został usunięty.<br>',
'LBL_UW_FILE_GROUP'=> 'Grupa',
'LBL_UW_FILE_ISSUES_PERMS'=> 'Prawa dostępu dla pliku',
'LBL_UW_FILE_ISSUES'=> 'Wersja Pliku',
'LBL_UW_FILE_NEEDS_DIFF'=> 'Plik wymaga ręcznego porównania',
'LBL_UW_FILE_NO_ERRORS'=> 'Wszystkie zapisywalne pliki',
'LBL_UW_FILE_OWNER'=> 'Właściciel',
'LBL_UW_FILE_PERMS'=> 'Prawa dostępu',
'LBL_UW_FILE_UPLOADED'=> ' został załadowany',
'LBL_UW_FILE'=> 'Nazwa pliku',
'LBL_UW_FILES_QUEUED' => 'Następujące ulepszenia są przygotowane do instalacji',
'LBL_UW_FILES_REMOVED'=> 'Następujące pliki zostaną usunięte z systemu:<br>\n',
'LBL_UW_FROZEN'=> 'Wymagane kroki muszą być zakończone, przed kontynuacją.',
'LBL_UW_HIDE_DETAILS'=> 'Ukryj szczegóły',
'LBL_UW_IN_PROGRESS'=> 'W trakcie',
'LBL_UW_INCLUDING'=> 'Zawiera',
'LBL_UW_INCOMPLETE'=> 'Niekompletny',
'LBL_UW_INSTALL'=> 'Plik INSTALL',
'LBL_UW_MANUAL_MERGE'=> 'Ręczne scalanie',
'LBL_UW_MODULE_READY_UNINSTALL'=> "Moduł gotowy do odinstlowania. Kliknij \"Wykonaj\" aby kontynuować deinstalację.<br>\n",
'LBL_UW_MODULE_READY'=> 'Moduł jest gotowy do instalacji. Kliknij <b>Wykonaj</b> aby kontynuować instalację.',
'LBL_UW_NO_INSTALLED_UPGRADES'=> 'Nie wykryto zapisanych ulepszeń.',
'LBL_UW_NONE'=> 'Nic',
'LBL_UW_NOT_AVAILABLE'=> 'Niedostępne',
'LBL_UW_OVERWRITE_DESC'=> 'Wszystkie zmieniane pliki zostaną nadpisane, łącznie ze zmianami w kodzie i wzorcami stworzonymi przez Ciebie. Czy na pewno chcesz kontynuować?',
'LBL_UW_OVERWRITE_FILES_CHOICE1'=> 'Nadpisz wszystkie pliki',
'LBL_UW_OVERWRITE_FILES_CHOICE2'=> 'Ręczne łączenie - zachowaj wszystko',
'LBL_UW_OVERWRITE_FILES'=> 'Metoda łączenia',
'LBL_UW_PATCH_READY'=> 'Poprawka jest gotowa do instalacji. Kliknij klawisz <b>Wykonaj</b> poniżej, aby kontynuować proces instalacji',
'LBL_UW_PATCH_READY2'=> '<h2>Uwaga: Znaleziono własne formaty wyglądu</h2><br>Następujące pliki zawierają nowe pola, lub modyfikacje wygladu, wykonanego przez moduł Studio. Poprawka, która chcesz zainstalować, również zawiera takie modyfikacje Dla <u>każdego pliku </u> możesz:<br><ul><li>[<b>Domyślnie</b>] Zachować swoje wersje, pozostawiając puste pole wyboru. Zmiany zawarte w poprawce zostaną zignorowane. </li>lub<li>Zatwierdzić zmiany z plików poprawki przez zaznaczenie pola wyboru. Wtedy Twoje zmiany będą wymagały ponownego załadowania porzez moduł Studio.</li></ul>',
'LBL_UW_PREFLIGHT_ADD_TASK' => 'Utworzyć zadanie dla łączenia ręcznego?',
'LBL_UW_PREFLIGHT_COMPLETE'=> 'Wstepne sprawdzanie zakończone',
'LBL_UW_PREFLIGHT_DIFF'=> 'Różniące się ',
'LBL_UW_PREFLIGHT_EMAIL_REMINDER'=> 'Czy wysłać wiadomość email, przypominającą o ręcznym scaleniu?',
'LBL_UW_PREFLIGHT_FILES_DESC'=> 'Pliki wyminenione poniżej zostały zmodfikowane. Odznacz elementy, które wymagają ręcznego scalenia. <i>Wszystkie wykryte zmiany wyglądu zostaną automatycznie odznaczone; wszystkie zaznaczone zostaną nadpisane.',
'LBL_UW_PREFLIGHT_NO_DIFFS'=> 'Nie jest wymagane żadne ręczne scalanie.',
'LBL_UW_PREFLIGHT_NOT_NEEDED'=> 'Nie wymagane.',
'LBL_UW_PREFLIGHT_PRESERVE_FILES'=> 'Automatycznie zabezpieczone Pliki:',
'LBL_UW_PREFLIGHT_TESTS_PASSED'=> 'Wszystkie testy wstępnego sprawdzania zostały wykonane poprawnie. Naciśnij dalej, aby zatwierdzić te zmiany.',
'LBL_UW_PREFLIGHT_TOGGLE_ALL'=> 'Zaznacz wszystkie pliki',
'LBL_UW_REBUILD_TITLE'=> 'Przebuduj rezultaty',
'LBL_UW_SCHEMA_CHANGE'=> 'Schemat zmian',
'LBL_UW_SHOW_COMPLIANCE'=> 'Pokaż wykryte ustawienia',
'LBL_UW_SHOW_DB_PERMS' => 'Pokaż brakujące prawa dostępu do bazy',
'LBL_UW_SHOW_DETAILS'=> 'Pokaż szczegóły',
'LBL_UW_SHOW_DIFFS'=> 'Pokaż pliki wymagające ręcznego scalenia',
'LBL_UW_SHOW_NW_FILES'=> 'Pokaż pliki z niewłaściwymi prawami dostępu',
'LBL_UW_SHOW_SCHEMA'=> 'Pokaż skrypt zmian',
'LBL_UW_SHOW_SQL_ERRORS'=> 'Pokaż złe zapytania',
'LBL_UW_SHOW'=> 'Pokaż',
'LBL_UW_SKIPPED_FILES_TITLE'=> 'pominięte pliki',
'LBL_UW_SKIPPING_FILE_OVERWRITE'=> 'Przeskakuje krok nadpisywania plików - Wybrano ręczne scalanie.',
'LBL_UW_SQL_RUN' => 'Sprawdź kiedy SQL był uruchomiony ręcznie',
'LBL_UW_START_DESC'=> 'Witamy w kreatorze instalacyjnym SugarCRM. Ten kreator jest zaprojektowany, aby asystować admninistratorom podczas ulepszania ich wersji SugarCRM. Proszę wykonywać uważnie podane instrukcje.',
'LBL_UW_START_DESC2'=> 'Zdecydowanie polecamy wykonanie ulepszania na kopii Twojego serwera produkcyjnego. Wykonaj kopię bezpieczeństwa plików systemu (wszystkich, które znajdują sie w Twoim folderze z SugarCRM). Przed przeprowadzeniem tej operacji - zapobieganie jest zawsze lepsze, niż leczenie',
'LBL_UW_START_UPGRADED_UW_DESC'=> 'Nowy kreator ulepszeń podsumuje teraz proces ulepszania. Kontynuuj.',
'LBL_UW_START_UPGRADED_UW_TITLE'=> 'Witamy w nowym kreatorze ulepszeń',
'LBL_UW_SYSTEM_CHECK_CHECKING'=> 'Sprawdzam. Proszę czekać. Może to trwać do 30 sekund.',
'LBL_UW_SYSTEM_CHECK_FILE_CHECK_START'=> 'Znajdywanie wszystkich plików spełniających warunki.',
'LBL_UW_SYSTEM_CHECK_FILES'=> 'Plików',
'LBL_UW_SYSTEM_CHECK_FOUND'=> 'Znaleziono',
'LBL_UW_HIDE_DETAILS'=> 'Ukryj szczegóły',
'LBL_UW_TITLE_END'=> 'Sprawozdanie',
'LBL_UW_TITLE_CANCEL' => 'Kasuj',
'LBL_UW_TITLE_COMMIT' => 'Wykonaj ulepszenie',
'LBL_UW_TITLE_END' => 'Debrief',
'LBL_UW_TITLE_PREFLIGHT' => 'Sprawdzanie wstępne',
'LBL_UW_TITLE_START' => 'Start',
'LBL_UW_TITLE_SYSTEM_CHECK' => 'Sprawdzanie systemu',
'LBL_UW_TITLE_UPLOAD' => 'Załaduj Ulepszenie',
'LBL_UW_TITLE' => 'Kreator instalacji',
'LBL_UW_UNINSTALL' => 'Odinstaluj',
//500 upgrade labels
'LBL_UW_ACCEPT_THE_LICENSE' => 'Zaakceptuj licencję',
'LBL_UW_CONVERT_THE_LICENSE' => 'Konwertuj Licencję',
'LBL_UW_CUSTOMIZED_OR_UPGRADED_MODULES' => 'Ulepszone/dostosowywane moduły',
'LBL_UW_FOLLOWING_MODULES_CUSTOMIZED' => 'Następujące moduły wykryto jako dostosowywane i zabezpieczone',
'LBL_UW_FOLLOWING_MODULES_UPGRADED' => 'Następujące moduły są dostosowywane przez Studio i zostały ulepszone.',
'LBL_UW_SUGAR_COMMUNITY_EDITION_LICENSE' => 'Sugar Community Edition 5.0 jest wydana na licencji GNU General Public License Version 3. To uaktualnienie przekształci Twoją istniejąca licencję. Warunki nowej licencji zostały opisane poniżej.',
'LBL_START_UPGRADE_IN_PROGRESS' => 'Rozpoczęto',
'LBL_SYSTEM_CHECKS_IN_PROGRESS' => 'Sprawdzanie systemu w toku',
'LBL_LICENSE_CHECK_IN_PROGRESS' => 'Sprawdzanie licencji w toku',
'LBL_PREFLIGHT_CHECK_IN_PROGRESS' => 'Testowanie wstępnej instalacji w toku',
'LBL_COMMIT_UPGRADE_IN_PROGRESS' => 'Trwa wykonywanie ulepszeń',
'LBL_UPGRADE_SUMMARY_IN_PROGRESS' => 'Tworzone jest podsumowanie ulepszenia',
'LBL_UPGRADE_IN_PROGRESS' => 'w toku ',
'LBL_UPGRADE_TIME_ELAPSED' => 'Czas, który pozsotał',
'LBL_UPGRADE_CANCEL_IN_PROGRESS' => 'Ulepszenie zatrzymane. Trwa czyszczenie',
'LBL_UPGRADE_TAKES_TIME_HAVE_PATIENCE' => 'Ulepszanie może zająć trochę czasu',
'LBL_UPLOADE_UPGRADE_IN_PROGRESS' => 'Testowanie połączenia',
'LBL_UPLOADING_UPGRADE_PACKAGE' => 'Trwa pobieranie poprawek... ',
'LBL_UW_DORP_THE_OLD_SCHMEA' => 'Czy chcesz, aby Sugar pominął nieaktualne schematy z v. 451?',
'LBL_UW_DROP_SCHEMA_UPGRADE_WIZARD' => 'Kreator ulepszeń pomija stare schematy z v. 451',
'LBL_UW_DROP_SCHEMA_MANUAL' => 'Ręczne usunięcie starych schematów po instalacji',
'LBL_UW_DROP_SCHEMA_METHOD' => 'Metoda usunięcia starych schematów',
'LBL_UW_SHOW_OLD_SCHEMA_TO_DROP' => 'Pokaż stare schematy, które mogą zostać usunięte',
'LBL_UW_FILES_REMOVED' => ' Zaznaczone pliki zostały usunięte.',
'LBL_UW_SKIPPED_QUERIES_ALREADY_EXIST' => 'Pominięte zapytania',
'LBL_INCOMPATIBLE_PHP_VERSION' => 'Jest wymagana co najmniej wersja php 5.0.',
'ERR_CHECKSYS_PHP_INVALID_VER' => 'Ta wersja PHP nie jest wspierana przez Sugar. Należy zainstalować wersję kompatybilną z Sugar. Proszę sprawdzić w informacji dołaczonej do bieżacego wydania jaka wersja PHP jest wymagana . Twoja wersja to ',
'LBL_BACKWARD_COMPATIBILITY_ON' => 'Tryb wstecznej kompatybilności php jest włączony. Ustaw dyrektywę "zend.ze1_compatibility_mode" na "Off", aby kontynuować.',
//including some strings from moduleinstall that are used in Upgrade
'LBL_ML_ACTION' => 'Akcja',
'LBL_ML_CANCEL' => 'Skasuj',
'LBL_ML_COMMIT'=>'Wykonaj',
'LBL_ML_DESCRIPTION' => 'Opis',
'LBL_ML_INSTALLED' => 'Data instalacji',
'LBL_ML_NAME' => 'Nazwa',
'LBL_ML_PUBLISHED' => 'Data publikacji',
'LBL_ML_TYPE' => 'Typ',
'LBL_ML_UNINSTALLABLE' => 'Nieodinstalowywalny',
'LBL_ML_VERSION' => 'Wersja',
'LBL_ML_INSTALL'=>'Zainstaluj',
//adding the string used in tracker. copying from homepage
'LBL_HOME_PAGE_4_NAME' => 'Śledzenie',
'LBL_CURRENT_PHP_VERSION' => '(Obecnie używana wersja PHP to',
'LBL_RECOMMENDED_PHP_VERSION' => '. zalecana wersja php to 5.2.1 lub wyższa)',
);
?>

View File

@@ -0,0 +1,101 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
//Request object must have these property values:
// Module: module name, this module should have a file called TreeData.php
// Function: name of the function to be called in TreeData.php, the function will be called statically.
// PARAM prefixed properties: array of these property/values will be passed to the function as parameter.
require_once('include/JSON.php');
require_once('include/entryPoint.php');
require_once('include/upload_file.php');
require_once('include/ytree/Tree.php');
require_once('include/ytree/Node.php');
require_once('modules/KBTags/TreeData.php');
$json = getJSONobj();
$selectedTable = $json->decode(html_entity_decode($_REQUEST['selectedTable']));
if(isset($tagArticleIds['jsonObject']) && $tagArticleIds['jsonObject'] != null){
$selectedTable = $selectedTable['jsonObject'];
}
$GLOBALS['log']->fatal('************ comes here *********');
//$GLOBALS['log']->fatal($_REQUEST['selectedTable']);
function tableColumns($table_name){
$GLOBALS['log']->fatal('********TABLE PASSED******* '.$table_name);
global $sugar_config;
global $setup_db_database_name;
global $setup_db_host_name;
global $setup_db_host_instance;
global $setup_db_admin_user_name;
global $setup_db_admin_password;
//$db = &DBManagerFactory::getInstance('information_schema');
$db_name= $sugar_config['dbconfig']['db_name'];
$setup_db_host_name = $sugar_config['dbconfig']['db_host_name'];
$setup_db_admin_user_name = $sugar_config['dbconfig']['db_user_name'];
$setup_db_host_instance = $sugar_config['dbconfig']['db_host_instance'];
$setup_db_admin_password = $sugar_config['dbconfig']['db_password'];
$link = @mysql_connect($setup_db_host_name, $setup_db_admin_user_name, $setup_db_admin_password);
mysql_select_db('information_schema');
$qu="SELECT column_name FROM information_schema.columns WHERE table_schema = '".$db_name."' AND table_name = '".$table_name."'";
$ct =$GLOBALS['db']->query($qu,$link);
//$cols= '';
$colsDrop = array();
while($row = $GLOBALS['db']->fetchByAssoc($ct)){
$colsDrop[] =$row['column_name'];
}
return $colsDrop;
}
$colsDrop = tableColumns($_REQUEST['selectedTable']);
if($colsDrop != null){
$colsDropDown = "<option value=".$_REQUEST['selectedTable']." Columns>".$_REQUEST['selectedTable']." Columns</option>";
foreach($colsDrop as $col){
$colsDropDown .="<option value={$col}>{$col}</option>";
}
}
//$response = "<script>document.getElementById('select_column').innerHTML=$colsDropDown</script>";
$response = $colsDropDown;
if (!empty($response)) {
echo $response;
}
sugar_cleanup();
exit();
?>

View File

@@ -0,0 +1,498 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*********************************************************************************
* Description:
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights
* Reserved. Contributor(s): ______________________________________..
* *******************************************************************************/
// LEGACY for old versions - emulating upload.php
// aw: make this better for later versions.
//refreshing mod_strings
global $mod_strings;
$curr_lang = 'en_us';
if(isset($GLOBALS['current_language']) && ($GLOBALS['current_language'] != null)){
$curr_lang = $GLOBALS['current_language'];
}
$mod_strings = return_module_language($curr_lang, 'UpgradeWizard',true);
function check_php($sys_php_version = '')
{
$min_considered_php_version = '5.2.1';
$supported_php_versions = array (
'5.2.1', '5.2.2', '5.2.3', '5.2.4', '5.2.5', '5.2.6', '5.2.8', '5.3.0'
);
//Find out what Database the system is using.
global $sugar_config;
$dbType = '';
if (isset ($sugar_config['dbconfig']) && isset ($sugar_config['dbconfig']['db_type'])) {
$dbType = $sugar_config['dbconfig']['db_type'];
}
// invalid versions above the $min_considered_php_version,
// should be mutually exclusive with $supported_php_versions
// SugarCRM prohibits install on PHP 5.2.x on all platforms
$invalid_php_versions = array('5.2.7');
// default unsupported
$retval = 0;
// versions below $min_considered_php_version are invalid
if(1 == version_compare($sys_php_version, $min_considered_php_version, '<')) {
$retval = -1;
}
// supported version check overrides default unsupported
foreach($supported_php_versions as $ver) {
if(1 == version_compare($sys_php_version, $ver, 'eq') || strpos($sys_php_version,$ver) !== false) {
$retval = 1;
break;
}
}
// invalid version check overrides default unsupported
foreach($invalid_php_versions as $ver) {
if(1 == version_compare($sys_php_version, $ver, 'eq') || strpos($sys_php_version,$ver) !== false) {
$retval = -1;
break;
}
}
//allow a redhat distro to install, regardless of version. We are assuming the redhat naming convention is followed
//and the php version contains 'rh' characters
if(strpos($sys_php_version, 'rh') !== false) {
$retval = 1;
}
return $retval;
}
$curr_lang = 'en_us';
if(isset($GLOBALS['current_language']) && ($GLOBALS['current_language'] != null)){
$curr_lang = $GLOBALS['current_language'];
}
return_module_language($curr_lang, 'UpgradeWizard');
logThis('at preflight.php');
//set the upgrade progress status.
set_upgrade_progress('preflight','in_progress');
$php_warnings = '';
if (version_compare(phpversion(),'5.2.0') >=0) {
$stop = true; // flag to show "next"
if(isset($_SESSION['files'])) {
unset($_SESSION['files']);
}
$errors = preflightCheck();
$php_version = constant('PHP_VERSION');
if(check_php($php_version) == -1)
{
$phpVersion = "<b><span class=stop>{$mod_strings['ERR_CHECKSYS_PHP_INVALID_VER']} {$php_version} </span></b>";
$error_txt = '<span class="error">'.$phpVersion.'</span>';
if(count($errors) == 0)
$errors[] = '';
$errors[] = $error_txt;
logThis($error_txt);
}
$diffs = '';
$schema = '';
$anyScriptChanges = '';
$db =& DBManagerFactory::getInstance();
//Quickcreatedefs on the basis of editviewdefs
if(substr($sugar_version,0,1) >= 5){
updateQuickCreateDefs();
}
if((count($errors) == 1)) { // only diffs
logThis('file preflight check passed successfully.');
$stop = false;
$out = $mod_strings['LBL_UW_PREFLIGHT_TESTS_PASSED'];
$stop = false;
$disableEmail = (empty($current_user->email1)) ? 'DISABLED' : 'CHECKED';
if(count($errors['manual']) > 0) {
$preserveFiles = array();
$diffs =<<<eoq
<script type="text/javascript" language="Javascript">
function preflightToggleAll(cb) {
var checkAll = false;
var form = document.getElementById('diffs');
if(cb.checked == true) {
checkAll = true;
}
for(i=0; i<form.elements.length; i++) {
if(form.elements[i].type == 'checkbox') {
form.elements[i].checked = checkAll;
}
}
return;
}
</script>
<table cellpadding='0' cellspacing='0' border='0'>
<tr>
<td valign='top'>
<input type='checkbox' name='addTask' id='addTask' CHECKED>
</td>
<td valign='top'>
{$mod_strings['LBL_UW_PREFLIGHT_ADD_TASK']}
</td>
</tr>
<tr>
<td valign='top'>
<input type='checkbox' name='addEmail' id='addEmail' $disableEmail>
</td>
<td valign='top'>
{$mod_strings['LBL_UW_PREFLIGHT_EMAIL_REMINDER']}
</td>
</tr>
</table>
<form name='diffs' id='diffs'>
<p><a href='javascript:void(0); toggleNwFiles("diffsHide");'>{$mod_strings['LBL_UW_SHOW_DIFFS']}</a></p>
<div id='diffsHide' style='display:none'>
<table cellpadding='0' cellspacing='0' border='0'>
<tr>
<td valign='top' colspan='2'>
{$mod_strings['LBL_UW_PREFLIGHT_FILES_DESC']}
<br />&nbsp;
</td>
</tr>
<tr>
<td valign='top' colspan='2'>
<input type='checkbox' onchange='preflightToggleAll(this);'>&nbsp;<i><b>{$mod_strings['LBL_UW_PREFLIGHT_TOGGLE_ALL']}</b></i>
<br />&nbsp;
</td>
</tr>
eoq;
foreach($errors['manual'] as $diff) {
$diff = clean_path($diff);
$_SESSION['files']['manual'][] = $diff;
$checked = (isAutoOverwriteFile($diff)) ? 'CHECKED' : '';
if(empty($checked)) {
$preserveFiles[] = $diff;
}
$diffs .= "<tr><td valign='top'>";
$diffs .= "<input type='checkbox' name='diff_files[]' value='{$diff}' $checked>";
$diffs .= "</td><td valign='top'>";
$diffs .= str_replace(getcwd(), '.', $diff);
$diffs .= "</td></tr>";
}
$diffs .= "</table>";
$diffs .= "</div></p>";
$diffs .= "</form>";
// list preserved files (templates, etc.)
$preserve = '';
foreach($preserveFiles as $pf) {
if(empty($preserve)) {
$preserve .= "<table cellpadding='0' cellspacing='0' border='0'><tr><td><b>";
$preserve .= $mod_strings['LBL_UW_PREFLIGHT_PRESERVE_FILES'];
$preserve .= "</b></td></tr>";
}
$preserve .= "<tr><td valign='top'><i>".str_replace(getcwd(), '.', $pf)."</i></td></tr>";
}
if(!empty($preserve)) {
$preserve .= '</table><br>';
}
$diffs = $preserve.$diffs;
} else { // NO FILE DIFFS REQUIRED
$diffs = $mod_strings['LBL_UW_PREFLIGHT_NO_DIFFS'];
}
} else {
logThis('*** ERROR: found too many preflight errors - displaying errors and stopping execution.');
$out = "<b>{$mod_strings['ERR_UW_PREFLIGHT_ERRORS']}:</b><hr />";
$out .= "<span class='error'>";
foreach($errors as $error) {
if(is_array($error)) { // manual diff files
continue;
} else {
$out .= "{$error}<br />";
}
}
$out .= "</span><br />";
}
$diffs ='';
///////////////////////////////////////////////////////////////////////////////
//// SCHEMA SCRIPT HANDLING
logThis('starting schema preflight check...');
//Check the current and target versions and store them in session variables
if(!isset($sugar_db_version) || empty($sugar_db_version)) {
include('./sugar_version.php');
}
if(!isset($manifest['version']) || empty($manifest['version'])) {
include($_SESSION['unzip_dir'].'/manifest.php');
}
$current_version = substr(preg_replace("#[^0-9]#", "", $sugar_db_version),0,3);
$targetVersion = substr(preg_replace("#[^0-9]#", "", $manifest['version']),0,3);
//save the versions as session variables
$_SESSION['current_db_version'] = $current_version;
$_SESSION['target_db_version'] = $targetVersion;
$_SESSION['upgrade_from_flavor'] = $manifest['name'];
// aw: BUG 10161: check flavor conversion sql files
$sqlFile = ''; // cn: bug
if($current_version == $targetVersion) {
if(preg_match('/(.*?)([^0])$/', $current_version, $matches))
{
$current_version = $matches[1].'0';
}
switch($manifest['name']){
case 'SugarCE to SugarPro':
$sqlFile = $current_version.'_ce_to_pro_'.$db->dbType;
break;
case 'SugarCE to SugarEnt':
$sqlFile = $current_version.'_ce_to_ent_'.$db->dbType;
break;
case 'SugarPro to SugarEnt':
$sqlFile = $current_version.'_pro_to_ent_'.$db->dbType;
break;
default:
break;
}
} else {
$sqlFile = $current_version.'_to_'.$targetVersion.'_'.$db->dbType;
}
$newTables = array();
if($db->dbType == 'oci8') {
} else {
$sqlScript = $_SESSION['unzip_dir'].'/scripts/'.$sqlFile.'.sql';
}
logThis('looking for schema script at: '.$sqlScript);
if(is_file($sqlScript)) {
logThis('found schema upgrade script: '.$sqlScript);
logThis('schema preflight using MySQL');
if(function_exists('sugar_fopen')){
$fp = sugar_fopen($sqlScript, 'r');
}
else{
$fp = fopen($sqlScript, 'r');
}
$contents = fread($fp, filesize($sqlScript));
$anyScriptChanges =$contents;
// remove __uw_temp tables
//testCleanUp($db->dbType);
fclose($fp);
$customTables = getCustomTables($db->dbType);
if ( !empty($customTables) ) {
$_SESSION['alterCustomTableQueries'] = alterCustomTables($db->dbType, $customTables);
} else {
$_SESSION['alterCustomTableQueries'] = false;
}
$schema = "<p><a href='javascript:void(0); toggleNwFiles(\"schemashow\");'>{$mod_strings['LBL_UW_SHOW_SCHEMA']}</a>";
$schema .= "<div id='schemashow' style='display:none;'>";
$schema .= "<textarea readonly cols='80' rows='10'>{$contents}</textarea>";
$schema .= "</div></p>";
if(!empty($sqlErrors)) {
$stop = true;
$out = "<b class='error'>{$mod_strings['ERR_UW_PREFLIGHT_ERRORS']}:</b> ";
$out .= "<a href='javascript:void(0);toggleNwFiles(\"sqlErrors\");'>{$mod_strings['LBL_UW_SHOW_SQL_ERRORS']}</a><div id='sqlErrors' style='display:none'>";
foreach($sqlErrors as $sqlError) {
$out .= "<br><span class='error'>{$sqlError}</span>";
}
$out .= "</div><hr />";
}
} else {
$customTableSchema = '';
logThis('no schema script found - all schema preflight skipped');
}
logThis('schema preflight done.');
//// END SCHEMA SCRIPT HANDLING
///////////////////////////////////////////////////////////////////////////////
//php 521 suggestion
$php_521 = '';
if(version_compare(phpversion(),'5.2.1') < 0){
$php_521=$mod_strings['LBL_CURRENT_PHP_VERSION'].phpversion().$mod_strings['LBL_RECOMMENDED_PHP_VERSION'];
}
if(empty($mod_strings['LBL_UPGRADE_TAKES_TIME_HAVE_PATIENCE'])){
$mod_strings['LBL_UPGRADE_TAKES_TIME_HAVE_PATIENCE'] = 'Upgrade may take some time';
}
$style_for_out = empty($out)?'style=\'display:none\'':'';
$style_for_dif = empty($diffs)?'style=\'display:none\'':'';
$style_for_schemaChange = empty($schema)?'style=\'display:none\'':'';
$final =<<<eoq
<table cellpadding="3" cellspacing="0" border="0">
<tr>
<th colspan="2" align="left">
<b>{$mod_strings['LBL_UW_PREFLIGHT_COMPLETE']}<i>{$php_521}</i></b><hr />
</th>
</tr>
<tr {$style_for_out}>
<td colspan="2" align="left" valign="top">
{$out}
</td>
</tr>
<tr {$style_for_dif}>
<td align="left" valign="top">
<b>{$mod_strings['LBL_UW_MANUAL_MERGE']}</b>
</td>
<td align="left" valign="top">
{$diffs}
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr {$style_for_schemaChange}>
<td align="left" valign="top">
<b>{$mod_strings['LBL_UW_SCHEMA_CHANGE']}</b>
</td>
<td align="left" valign="top">
{$schema}
</td>
</tr>
<tr {$style_for_schemaChange}>
<td>
</td>
<td valign="top">
<div>
<b>{$mod_strings['LBL_UW_DB_METHOD']}</b><br />
<select name="schema_change" id="select_schema_change" onchange="checkSqlStatus(false);">
<option value="sugar">{$mod_strings['LBL_UW_DB_CHOICE1']}</option>
<option value="manual">{$mod_strings['LBL_UW_DB_CHOICE2']}</option>
</select>
</div>
<div id='show_sql_run' style='display:none'>
<input type='checkbox' name='sql_run' id='sql_run' onmousedown='checkSqlStatus(true);'> {$mod_strings['LBL_UW_SQL_RUN']}
</div>
</td>
</tr>
</table>
eoq;
$form5 =<<<eoq5
<br>
<div id="upgradeDiv" style="display:none">
<table cellspacing="0" cellpadding="0" border="0">
<tr><td>
<p><img src='modules/UpgradeWizard/processing.gif'> <br>{$mod_strings['LBL_UPGRADE_TAKES_TIME_HAVE_PATIENCE']}</p>
</td></tr>
</table>
</div>
eoq5;
$uwMain = $final.$form5;
//set the upgrade progress status.
set_upgrade_progress('preflight','done');
}
else{
$stop = true;
if(empty($mod_strings['LBL_INCOMPATIBLE_PHP_VERSION'])){
$mod_strings['LBL_INCOMPATIBLE_PHP_VERSION'] = 'Php version 5.2.1 or above is required.';
}
$php_verison_warning =<<<eoq
<table cellpadding="3" cellspacing="0" border="0">
<tr>
<th colspan="2" align="left">
<span class='error'><b>{$mod_strings['LBL_INCOMPATIBLE_PHP_VERSION']}</b></span>
</th>
</tr>
</table>
eoq;
$php_warnings = $php_verison_warning;
}
//Add the backward compatibility check as well.
//Php Backward compatibility checks
if(ini_get("zend.ze1_compatibility_mode")) {
$stop = true;
if(empty($mod_strings['LBL_BACKWARD_COMPATIBILITY_ON'])){
$mod_strings['LBL_BACKWARD_COMPATIBILITY_ON'] = 'Php Backward Compatibility mode is turned on. Set zend.ze1_compatibility_mode to Off for proceeding further';
}
$php_compatibility_warning =<<<eoq
<table cellpadding="3" cellspacing="0" border="0">
<tr>
<th colspan="2" align="left">
<span class='error'><b>{$mod_strings['LBL_BACKWARD_COMPATIBILITY_ON']}</b></span>
</th>
</tr>
</table>
eoq;
$php_warnings .= $php_compatibility_warning;
}
if($php_warnings != null){
$uwMain = $php_warnings;
}
$showBack = false;
$showCancel = true;
$showRecheck = true;
$showNext = ($stop) ? false : true;
$stepBack = $_REQUEST['step'] - 1;
$stepNext = $_REQUEST['step'] + 1;
$stepCancel = -1;
$stepRecheck = $_REQUEST['step'];
$_SESSION['step'][$steps['files'][$_REQUEST['step']]] = ($stop) ? 'failed' : 'success';
?>

View File

@@ -0,0 +1,89 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*********************************************************************************
* Description:
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights
* Reserved. Contributor(s): ______________________________________..
* *******************************************************************************/
if(ob_get_level() < 1)
ob_start();
ob_implicit_flush(1);
// load the generated persistence file if found
$persistence = array();
if(file_exists(getcwd().'/modules/UpgradeWizard/_persistence.php')) {
require_once(getcwd().'/modules/UpgradeWizard/_persistence.php');
}
if(!function_exists('getFilesForPermsCheck')) {
require_once('modules/UpgradeWizard/uw_utils.php');
}
if(!isset($sugar_config) || empty($sugar_config)) {
}
if(!function_exists('unzip')) {
require_once('include/utils/zip_utils.php');
}
switch($_REQUEST['preflightStep']) {
case 'find_upgrade_files':
logThis('preflightJson finding upgrade files');
ob_end_flush();
$persistence['upgrade_files'] = preflightCheckJsonFindUpgradeFiles();
break;
case 'diff_upgrade_files':
logThis('preflightJson diffing upgrade files');
ob_end_flush();
$persistence = preflightCheckJsonDiffFiles();
break;
case 'get_diff_results':
logThis('preflightJson getting diff results for display');
ob_end_flush();
$persistence = preflightCheckJsonGetDiff();
break;
case 'get_diff_errors':
logThis('preflightJson getting diff errors (if any)');
preflightCheckJsonGetDiffErrors();
break;
}
write_array_to_file('persistence', $persistence, 'modules/UpgradeWizard/_persistence.php');
?>

View File

@@ -0,0 +1,96 @@
<?php
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
function build_argument_string($arguments=array()) {
if(!is_array($arguments)) {
return '';
}
$argument_string = '';
$count = 0;
foreach($arguments as $arg) {
if($count != 0) {
$argument_string .= ' ' . escapeshellarg($arg);
}
$count++;
}
return $argument_string;
}
$php_path = '';
$run_dce_upgrade = false;
if(isset($argv[3]) && is_dir($argv[3]) && file_exists($argv[3]."/ini_setup.php")) {
//this is a dce call, set the dce flag
chdir($argv[3]);
$run_dce_upgrade = true;
//set the php path if found
if(is_file($argv[7].'dce_config.php')){
include($argv[7].'dce_config.php');
$php_path = $dce_config['client_php_path'].'/';
}
}
$php_file = $argv[0];
$p_info = pathinfo($php_file);
$php_dir = (isset($p_info['dirname']) && $p_info['dirname'] != '.') ? $p_info['dirname'] . '/' : '';
$step1 = $php_path."php -f {$php_dir}silentUpgrade_step1.php " . build_argument_string($argv);
passthru($step1, $output);
$has_error = $output == 0 ? false : true;
if(!$has_error) {
if($run_dce_upgrade) {
$step2 = $php_path."php -f {$php_dir}silentUpgrade_dce_step1.php " . build_argument_string($argv);
passthru($step2, $output);
} else {
$step2 = "php -f {$php_dir}silentUpgrade_step2.php " . build_argument_string($argv);
passthru($step2, $output);
}
}
if($run_dce_upgrade) {
$has_error = $output == 0 ? false : true;
if(!$has_error) {
$step3 = $php_path."php -f {$php_dir}silentUpgrade_dce_step2.php " . build_argument_string($argv);
passthru($step3, $output);
}
}
if($output != 0) {
echo "*************** silentupgrade failed ***************\n";
}
?>

View File

@@ -0,0 +1,645 @@
<?php
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
//////////////////////////////////////////////////////////////////////////////////////////
//// This is a stand alone file that can be run from the command prompt for upgrading a
//// Sugar Instance. Three parameters are required to be defined in order to execute this file.
//// php.exe -f silentUpgrade.php [Path to Upgrade Package zip] [Path to Log file] [Path to Instance]
//// See below the Usage for more details.
/////////////////////////////////////////////////////////////////////////////////////////
ini_set('memory_limit',-1);
///////////////////////////////////////////////////////////////////////////////
//// UTILITIES THAT MUST BE LOCAL :(
function prepSystemForUpgradeSilent() {
global $subdirs;
global $cwd;
global $sugar_config;
// make sure dirs exist
foreach($subdirs as $subdir) {
if(!is_dir(clean_path("{$cwd}/{$sugar_config['upload_dir']}upgrades/{$subdir}"))) {
mkdir_recursive(clean_path("{$cwd}/{$sugar_config['upload_dir']}upgrades/{$subdir}"));
}
}
}
//local function for clearing cache
function clearCacheSU($thedir, $extension) {
if ($current = @opendir($thedir)) {
while (false !== ($children = readdir($current))) {
if ($children != "." && $children != "..") {
if (is_dir($thedir . "/" . $children)) {
clearCacheSU($thedir . "/" . $children, $extension);
}
elseif (is_file($thedir . "/" . $children) && substr_count($children, $extension)) {
unlink($thedir . "/" . $children);
}
}
}
}
}
//Bug 24890, 24892. default_permissions not written to config.php. Following function checks and if
//no found then adds default_permissions to the config file.
function checkConfigForPermissions(){
if(file_exists(getcwd().'/config.php')){
require(getcwd().'/config.php');
}
global $sugar_config;
if(!isset($sugar_config['default_permissions'])){
$sugar_config['default_permissions'] = array (
'dir_mode' => 02770,
'file_mode' => 0660,
'user' => '',
'group' => '',
);
ksort($sugar_config);
if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
//writing to the file
}
}
}
function checkLoggerSettings(){
if(file_exists(getcwd().'/config.php')){
require(getcwd().'/config.php');
}
global $sugar_config;
if(!isset($sugar_config['logger'])){
$sugar_config['logger'] =array (
'level'=>'fatal',
'file' =>
array (
'ext' => '.log',
'name' => 'sugarcrm',
'dateFormat' => '%c',
'maxSize' => '10MB',
'maxLogs' => 10,
'suffix' => '%m_%Y',
),
);
ksort($sugar_config);
if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
//writing to the file
}
}
}
function checkResourceSettings(){
if(file_exists(getcwd().'/config.php')){
require(getcwd().'/config.php');
}
global $sugar_config;
if(!isset($sugar_config['resource_management'])){
$sugar_config['resource_management'] =
array (
'special_query_limit' => 50000,
'special_query_modules' =>
array (
0 => 'Reports',
1 => 'Export',
2 => 'Import',
3 => 'Administration',
4 => 'Sync',
),
'default_limit' => 1000,
);
ksort($sugar_config);
if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
//writing to the file
}
}
}
//rebuild all relationships...
function rebuildRelations($pre_path = ''){
$_REQUEST['silent'] = true;
include($pre_path.'modules/Administration/RebuildRelationship.php');
$_REQUEST['upgradeWizard'] = true;
include($pre_path.'modules/ACL/install_actions.php');
}
function createMissingRels(){
$relForObjects = array('leads'=>'Leads','campaigns'=>'Campaigns','prospects'=>'Prospects');
foreach($relForObjects as $relObjName=>$relModName){
//assigned_user
$guid = create_guid();
$query = "SELECT id FROM relationships WHERE relationship_name = '{$relObjName}_assigned_user'";
$result= $GLOBALS['db']->query($query, true);
$a = null;
$a = $GLOBALS['db']->fetchByAssoc($result);
if($GLOBALS['db']->checkError()){
//log this
}
if(!isset($a['id']) && empty($a['id']) ){
$qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted)
VALUES ('{$guid}', '{$relObjName}_assigned_user','Users','users','id','{$relModName}','{$relObjName}','assigned_user_id',NULL,NULL,NULL,'one-to-many',NULL,NULL,'0','0')";
$GLOBALS['db']->query($qRel);
if($GLOBALS['db']->checkError()){
//log this
}
}
//modified_user
$guid = create_guid();
$query = "SELECT id FROM relationships WHERE relationship_name = '{$relObjName}_modified_user'";
$result= $GLOBALS['db']->query($query, true);
if($GLOBALS['db']->checkError()){
//log this
}
$a = null;
$a = $GLOBALS['db']->fetchByAssoc($result);
if(!isset($a['id']) && empty($a['id']) ){
$qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted)
VALUES ('{$guid}', '{$relObjName}_modified_user','Users','users','id','{$relModName}','{$relObjName}','modified_user_id',NULL,NULL,NULL,'one-to-many',NULL,NULL,'0','0')";
$GLOBALS['db']->query($qRel);
if($GLOBALS['db']->checkError()){
//log this
}
}
//created_by
$guid = create_guid();
$query = "SELECT id FROM relationships WHERE relationship_name = '{$relObjName}_created_by'";
$result= $GLOBALS['db']->query($query, true);
$a = null;
$a = $GLOBALS['db']->fetchByAssoc($result);
if(!isset($a['id']) && empty($a['id']) ){
$qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted)
VALUES ('{$guid}', '{$relObjName}_created_by','Users','users','id','{$relModName}','{$relObjName}','created_by',NULL,NULL,NULL,'one-to-many',NULL,NULL,'0','0')";
$GLOBALS['db']->query($qRel);
if($GLOBALS['db']->checkError()){
//log this
}
}
}
//Also add tracker perf relationship
}
/**
* This function will merge password default settings into config file
* @param $sugar_config
* @param $sugar_version
* @return bool true if successful
*/
function merge_passwordsetting($sugar_config, $sugar_version) {
$passwordsetting_defaults = array(
'passwordsetting' => array (
'SystemGeneratedPasswordON' => '',
'generatepasswordtmpl' => '',
'lostpasswordtmpl' => '',
'forgotpasswordON' => false,
'linkexpiration' => '1',
'linkexpirationtime' => '30',
'linkexpirationtype' => '1',
'systexpiration' => '0',
'systexpirationtime' => '',
'systexpirationtype' => '0',
'systexpirationlogin' => '',
) ,
);
$sugar_config = sugarArrayMerge($passwordsetting_defaults, $sugar_config );
// need to override version with default no matter what
$sugar_config['sugar_version'] = $sugar_version;
ksort( $sugar_config );
if( write_array_to_file( "sugar_config", $sugar_config, "config.php" ) ){
return true;
}
else {
return false;
}
}
function addDefaultModuleRoles($defaultRoles = array()) {
foreach($defaultRoles as $roleName=>$role){
foreach($role as $category=>$actions){
foreach($actions as $name=>$access_override){
$query = "SELECT * FROM acl_actions WHERE name='$name' AND category = '$category' AND acltype='$roleName' AND deleted=0 ";
$result = $GLOBALS['db']->query($query);
//only add if an action with that name and category don't exist
$row=$GLOBALS['db']->fetchByAssoc($result);
if ($row == null) {
$guid = create_guid();
$currdate = gmdate($GLOBALS['timedate']->get_db_date_time_format());
$query= "INSERT INTO acl_actions (id,date_entered,date_modified,modified_user_id,name,category,acltype,aclaccess,deleted ) VALUES ('$guid','$currdate','$currdate','1','$name','$category','$roleName','$access_override','0')";
$GLOBALS['db']->query($query);
if($GLOBALS['db']->checkError()){
//log this
}
}
}
}
}
}
function verifyArguments($argv,$usage_dce,$usage_regular){
$upgradeType = '';
$cwd = getcwd(); // default to current, assumed to be in a valid SugarCRM root dir.
if(isset($argv[3])) {
if(is_dir($argv[3])) {
$cwd = $argv[3];
chdir($cwd);
} else {
echo "*******************************************************************************\n";
echo "*** ERROR: 3rd parameter must be a valid directory. Tried to cd to [ {$argv[3]} ].\n";
exit(1);
}
}
//check if this is an instance
if(is_file("{$cwd}/ini_setup.php")){
// this is an instance
$upgradeType = constant('DCE_INSTANCE');
//now that this is dce instance we want to make sure that there are
// 7 arguments
if(count($argv) < 7) {
echo "*******************************************************************************\n";
echo "*** ERROR: Missing required parameters. Received ".count($argv)." argument(s), require 7.\n";
echo $usage_dce;
echo "FAILURE\n";
exit(1);
}
// this is an instance
if(!is_dir($argv[1])) { // valid directory . template path?
echo "*******************************************************************************\n";
echo "*** ERROR: First argument must be a full path to the template. Got [ {$argv[1]} ].\n";
echo $usage_dce;
echo "FAILURE\n";
exit(1);
}
}
else if(is_file("{$cwd}/include/entryPoint.php")) {
//this should be a regular sugar install
$upgradeType = constant('SUGARCRM_INSTALL');
//check if this is a valid zip file
if(!is_file($argv[1])) { // valid zip?
echo "*******************************************************************************\n";
echo "*** ERROR: First argument must be a full path to the patch file. Got [ {$argv[1]} ].\n";
echo $usage_regular;
echo "FAILURE\n";
exit(1);
}
if(count($argv) < 5) {
echo "*******************************************************************************\n";
echo "*** ERROR: Missing required parameters. Received ".count($argv)." argument(s), require 5.\n";
echo $usage_regular;
echo "FAILURE\n";
exit(1);
}
}
else {
//this should be a regular sugar install
echo "*******************************************************************************\n";
echo "*** ERROR: Tried to execute in a non-SugarCRM root directory.\n";
exit(1);
}
if(isset($argv[7]) && file_exists($argv[7].'SugarTemplateUtilties.php')){
require_once($argv[7].'SugarTemplateUtilties.php');
}
return $upgradeType;
}
function upgradeDCEFiles($argv,$instanceUpgradePath){
//copy and update following files from upgrade package
$upgradeTheseFiles = array('cron.php','download.php','index.php','install.php','soap.php','sugar_version.php','vcal_server.php');
foreach($upgradeTheseFiles as $file){
$srcFile = clean_path("{$instanceUpgradePath}/$file");
$destFile = clean_path("{$argv[3]}/$file");
if(file_exists($srcFile)){
if(!is_dir(dirname($destFile))) {
mkdir_recursive(dirname($destFile)); // make sure the directory exists
}
copy_recursive($srcFile,$destFile);
$_GET['TEMPLATE_PATH'] = $destFile;
$_GET['CONVERT_FILE_ONLY'] = true;
if(!class_exists('TemplateConverter')){
include($argv[7].'templateConverter.php');
}else{
TemplateConverter::convertFile($_GET['TEMPLATE_PATH']);
}
}
}
}
function threeWayMerge(){
//using threeway merge apis
}
//// END UTILITIES THAT MUST BE LOCAL :(
///////////////////////////////////////////////////////////////////////////////
// only run from command line
if(isset($_SERVER['HTTP_USER_AGENT'])) {
fwrite(STDERR,'This utility may only be run from the command line or command prompt.');
exit(1);
}
//Clean_string cleans out any file passed in as a parameter
$_SERVER['PHP_SELF'] = 'silentUpgrade.php';
///////////////////////////////////////////////////////////////////////////////
//// USAGE
$usage_dce =<<<eoq1
Usage: php.exe -f silentUpgrade.php [upgradeZipFile] [logFile] [pathToSugarInstance]
On Command Prompt Change directory to where silentUpgrade.php resides. Then type path to
php.exe followed by -f silentUpgrade.php and the arguments.
Example:
[path-to-PHP/]php.exe -f silentUpgrade.php [path-to-upgrade-package/]SugarEnt-Upgrade-4.5.1-to-5.0.0b.zip [path-to-log-file/]silentupgrade.log [path-to-sugar-instance/]Sugar451e
[Old Template path] [skipdbupgrade] [exitOrContinue]
Arguments:
New Template Path or Upgrade Package : Upgrade package name. Template2 (upgrade to)location.
silentupgrade.log : Silent Upgarde log file.
Sugar451e/DCE : Sugar or DCE Instance instance being upgraded.
Old Template path : Template1 (upgrade from) Instance is being upgraded.
skipDBupgrade : If set to Yes then silentupgrade will only upgrade files. Default is No.
exitOnConflicts : If set to No and conflicts are found then Upgrade continues. Default Yes.
pathToDCEClient : This is path to to DCEClient directory
eoq1;
$usage_regular =<<<eoq2
Usage: php.exe -f silentUpgrade.php [upgradeZipFile] [logFile] [pathToSugarInstance] [admin-user]
On Command Prompt Change directory to where silentUpgrade.php resides. Then type path to
php.exe followed by -f silentUpgrade.php and the arguments.
Example:
[path-to-PHP/]php.exe -f silentUpgrade.php [path-to-upgrade-package/]SugarEnt-Upgrade-5.2.0-to-5.5.0.zip [path-to-log-file/]silentupgrade.log [path-to-sugar-instance/] admin
Arguments:
upgradeZipFile : Upgrade package file.
logFile : Silent Upgarde log file.
pathToSugarInstance : Sugar Instance instance being upgraded.
admin-user : admin user performing the upgrade
eoq2;
//// END USAGE
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//// STANDARD REQUIRED SUGAR INCLUDES AND PRESETS
if(!defined('sugarEntry')) define('sugarEntry', true);
$_SESSION = array();
$_SESSION['schema_change'] = 'sugar'; // we force-run all SQL
$_SESSION['silent_upgrade'] = true;
$_SESSION['step'] = 'silent'; // flag to NOT try redirect to 4.5.x upgrade wizard
$_REQUEST = array();
$_REQUEST['addTaskReminder'] = 'remind';
define('SUGARCRM_INSTALL', 'SugarCRM_Install');
define('DCE_INSTANCE', 'DCE_Instance');
global $cwd;
$cwd = getcwd(); // default to current, assumed to be in a valid SugarCRM root dir.
$upgradeType = verifyArguments($argv,$usage_dce,$usage_regular);
///////////////////////////////////////////////////////////////////////////////
////// Verify that all the arguments are appropriately placed////////////////
///////////////////////////////////////////////////////////////////////////////
//// PREP LOCALLY USED PASSED-IN VARS & CONSTANTS
//$GLOBALS['log'] = LoggerManager::getLogger('SugarCRM');
//require_once('/var/www/html/eddy/sugarnode/SugarTemplateUtilities.php');
$path = $argv[2]; // custom log file, if blank will use ./upgradeWizard.log
//$db = &DBManagerFactory::getInstance(); //<---------
//$UWstrings = return_module_language('en_us', 'UpgradeWizard');
//$adminStrings = return_module_language('en_us', 'Administration');
//$mod_strings = array_merge($adminStrings, $UWstrings);
$subdirs = array('full', 'langpack', 'module', 'patch', 'theme', 'temp');
//$_REQUEST['zip_from_dir'] = $zip_from_dir;
define('SUGARCRM_PRE_INSTALL_FILE', 'scripts/pre_install.php');
define('SUGARCRM_POST_INSTALL_FILE', 'scripts/post_install.php');
define('SUGARCRM_PRE_UNINSTALL_FILE', 'scripts/pre_uninstall.php');
define('SUGARCRM_POST_UNINSTALL_FILE', 'scripts/post_uninstall.php');
echo "\n";
echo "********************************************************************\n";
echo "***************This Upgrade process may take sometime***************\n";
echo "********************************************************************\n";
echo "\n";
global $sugar_config;
$isDCEInstance = false;
$errors = array();
if($upgradeType == constant('DCE_INSTANCE')){
//$instanceUpgradePath = "{$argv[1]}/DCEUpgrade/{$zip_from_dir}";
//$instanceUpgradePath = "{$argv[1]}";
include ("ini_setup.php");
//get new template path for use in later processing
$dceupgrade_pos = strpos($argv[1], '/DCEUpgrade');
$newtemplate_path = substr($argv[1], 0, $dceupgrade_pos);
require("{$argv[4]}/sugar_version.php");
global $sugar_version;
//load up entrypoint from original template
require_once("{$argv[4]}/include/entryPoint.php");
require_once("{$argv[4]}/include/utils/zip_utils.php");
require_once("{$argv[4]}/modules/Administration/UpgradeHistory.php");
// We need to run the silent upgrade as the admin user,
global $current_user;
$current_user = new User();
$current_user->retrieve('1');
//This is DCE instance
global $sugar_config;
global $sugar_version;
// require_once("{$cwd}/sugar_version.php"); //provides instance version, flavor etc..
//provides instance version, flavor etc..
$isDCEInstance = true;
prepSystemForUpgradeSilent();
/////retrieve admin user
$configOptions = $sugar_config['dbconfig'];
$GLOBALS['log'] = LoggerManager::getLogger('SugarCRM');
$db = &DBManagerFactory::getInstance();
///////////////////////////////////////////////////////////////////////////////
//// MAKE SURE PATCH IS COMPATIBLE
if(is_file("{$argv[1]}/manifest.php")) {
// provides $manifest array
include("{$argv[1]}/manifest.php");
}
//If Instance then the files will be accessed from Template/DCEUpgrade folder
$zip_from_dir = '';
if( isset( $manifest['copy_files']['from_dir'] ) && $manifest['copy_files']['from_dir'] != "" ){
$zip_from_dir = $manifest['copy_files']['from_dir'];
}
$instanceUpgradePath = "{$argv[1]}/{$zip_from_dir}";
global $instancePath;
$instancePath = $instanceUpgradePath;
$_SESSION['instancePath'] = $instancePath;
if(file_exists("{$instanceUpgradePath}/modules/UpgradeWizard/uw_utils.php")){
require_once("{$instanceUpgradePath}/modules/UpgradeWizard/uw_utils.php");
}
else{
require_once("{$argv[4]}/modules/UpgradeWizard/uw_utils.php");
}
if(function_exists('set_upgrade_vars')){
set_upgrade_vars();
}
if(is_file("$argv[1]/manifest.php")) {
// provides $manifest array
//include("$instanceUpgradePath/manifest.php");
if(!isset($manifest)) {
fwrite(STDERR,"\nThe patch did not contain a proper manifest.php file. Cannot continue.\n\n");
exit(1);
} else {
$error = validate_manifest($manifest);
if(!empty($error)) {
$error = strip_tags(br2nl($error));
fwrite(STDERR,"\n{$error}\n\nFAILURE\n");
exit(1);
}
}
} else {
fwrite(STDERR,"\nThe patch did not contain a proper manifest.php file. Cannot continue.\n\n");
exit(1);
}
$ce_to_pro_ent = isset($manifest['name']) && ($manifest['name'] == 'SugarCE to SugarPro' || $manifest['name'] == 'SugarCE to SugarEnt');
$_SESSION['upgrade_from_flavor'] = $manifest['name'];
//get the latest uw_utils.php
// require_once("{$instanceUpgradePath}/modules/UpgradeWizard/uw_utils.php");
logThis("*** SILENT DCE UPGRADE INITIATED.", $path);
logThis("*** UpgradeWizard Upgraded ", $path);
$_SESSION['sugar_version_file'] = '';
$srcFile = clean_path("{$instanceUpgradePath}/sugar_version.php");
if(file_exists($srcFile)) {
logThis('Save the version file in session variable', $path);
$_SESSION['sugar_version_file'] = $srcFile;
}
//check exit on conflicts
$exitOnConflict = 'yes'; //default
if($argv[5] != null && !empty($argv[5])){
if(strtolower($argv[5]) == 'no'){
$exitOnConflict = 'no'; //override
}
}
if($exitOnConflict == 'yes'){
$customFiles = array();
$customFiles = findAllFiles(clean_path("{$argv[3]}/custom"), $customFiles);
if($customFiles != null){
logThis("*** **************************** ****", $path);
logThis("*** START LOGGING CUSTOM FILES ****", $path);
$existsCustomFile = false;
foreach($customFiles as $file) {
$srcFile = clean_path($file);
//$targetFile = clean_path(getcwd() . '/' . $srcFile);
if (strpos($srcFile,".svn") !== false) {
//do nothing
}
else{
$existsCustomFile = true;
//log the custom file in
logThis($file, $path);
}
}
logThis("*** END LOGGING CUSTOM FILES ****", $path);
logThis("*** **************************** ****", $path);
if($existsCustomFile){
echo 'Stop and Exit Upgrade. There are customized files. Take a look in the upgrade log';
logThis("Stop and Exit Upgrade. There are customized files. Take a look in the upgrade log", $path);
exit(1);
}
else{
upgradeDCEFiles($argv,$instanceUpgradePath);
}
}
else{
//copy and update following files from upgrade package
upgradeDCEFiles($argv,$instanceUpgradePath);
}
}
else{
//copy and update following files from upgrade package
upgradeDCEFiles($argv,$instanceUpgradePath);
}
global $unzip_dir;
$unzip_dir = $argv[1];
$_SESSION['unzip_dir'] = $unzip_dir;
global $path;
$path = $argv[2];
} //END OF BIG if block
///////////////////////////////////////////////////////////////////////////////
//// RECORD ERRORS
$phpErrors = ob_get_contents();
ob_end_clean();
logThis("**** Potential PHP generated error messages: {$phpErrors}", $path);
if(count($errors) > 0) {
foreach($errors as $error) {
logThis("****** SilentUpgrade ERROR: {$error}", $path);
}
echo "FAILED\n";
}
?>

View File

@@ -0,0 +1,865 @@
<?php
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
//////////////////////////////////////////////////////////////////////////////////////////
//// This is a stand alone file that can be run from the command prompt for upgrading a
//// Sugar Instance. Three parameters are required to be defined in order to execute this file.
//// php.exe -f silentUpgrade.php [Path to Upgrade Package zip] [Path to Log file] [Path to Instance]
//// See below the Usage for more details.
/////////////////////////////////////////////////////////////////////////////////////////
ini_set('memory_limit',-1);
///////////////////////////////////////////////////////////////////////////////
//// UTILITIES THAT MUST BE LOCAL :(
//local function for clearing cache
function clearCacheSU($thedir, $extension) {
if ($current = @opendir($thedir)) {
while (false !== ($children = readdir($current))) {
if ($children != "." && $children != "..") {
if (is_dir($thedir . "/" . $children)) {
clearCacheSU($thedir . "/" . $children, $extension);
}
elseif (is_file($thedir . "/" . $children) && substr_count($children, $extension)) {
unlink($thedir . "/" . $children);
}
}
}
}
}
//Bug 24890, 24892. default_permissions not written to config.php. Following function checks and if
//no found then adds default_permissions to the config file.
function checkConfigForPermissions(){
if(file_exists(getcwd().'/config.php')){
require(getcwd().'/config.php');
}
global $sugar_config;
if(!isset($sugar_config['default_permissions'])){
$sugar_config['default_permissions'] = array (
'dir_mode' => 02770,
'file_mode' => 0660,
'user' => '',
'group' => '',
);
ksort($sugar_config);
if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
//writing to the file
}
}
}
function checkLoggerSettings(){
if(file_exists(getcwd().'/config.php')){
require(getcwd().'/config.php');
}
global $sugar_config;
if(!isset($sugar_config['logger'])){
$sugar_config['logger'] =array (
'level'=>'fatal',
'file' =>
array (
'ext' => '.log',
'name' => 'sugarcrm',
'dateFormat' => '%c',
'maxSize' => '10MB',
'maxLogs' => 10,
'suffix' => '%m_%Y',
),
);
ksort($sugar_config);
if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
//writing to the file
}
}
}
function checkResourceSettings(){
if(file_exists(getcwd().'/config.php')){
require(getcwd().'/config.php');
}
global $sugar_config;
if(!isset($sugar_config['resource_management'])){
$sugar_config['resource_management'] =
array (
'special_query_limit' => 50000,
'special_query_modules' =>
array (
0 => 'Reports',
1 => 'Export',
2 => 'Import',
3 => 'Administration',
4 => 'Sync',
),
'default_limit' => 1000,
);
ksort($sugar_config);
if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
//writing to the file
}
}
}
function createMissingRels(){
$relForObjects = array('leads'=>'Leads','campaigns'=>'Campaigns','prospects'=>'Prospects');
foreach($relForObjects as $relObjName=>$relModName){
//assigned_user
$guid = create_guid();
$query = "SELECT id FROM relationships WHERE relationship_name = '{$relObjName}_assigned_user'";
$result= $GLOBALS['db']->query($query, true);
$a = null;
$a = $GLOBALS['db']->fetchByAssoc($result);
if($GLOBALS['db']->checkError()){
//log this
}
if(!isset($a['id']) && empty($a['id']) ){
$qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted)
VALUES ('{$guid}', '{$relObjName}_assigned_user','Users','users','id','{$relModName}','{$relObjName}','assigned_user_id',NULL,NULL,NULL,'one-to-many',NULL,NULL,'0','0')";
$GLOBALS['db']->query($qRel);
if($GLOBALS['db']->checkError()){
//log this
}
}
//modified_user
$guid = create_guid();
$query = "SELECT id FROM relationships WHERE relationship_name = '{$relObjName}_modified_user'";
$result= $GLOBALS['db']->query($query, true);
if($GLOBALS['db']->checkError()){
//log this
}
$a = null;
$a = $GLOBALS['db']->fetchByAssoc($result);
if(!isset($a['id']) && empty($a['id']) ){
$qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted)
VALUES ('{$guid}', '{$relObjName}_modified_user','Users','users','id','{$relModName}','{$relObjName}','modified_user_id',NULL,NULL,NULL,'one-to-many',NULL,NULL,'0','0')";
$GLOBALS['db']->query($qRel);
if($GLOBALS['db']->checkError()){
//log this
}
}
//created_by
$guid = create_guid();
$query = "SELECT id FROM relationships WHERE relationship_name = '{$relObjName}_created_by'";
$result= $GLOBALS['db']->query($query, true);
$a = null;
$a = $GLOBALS['db']->fetchByAssoc($result);
if(!isset($a['id']) && empty($a['id']) ){
$qRel = "INSERT INTO relationships (id,relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, relationship_role_column, relationship_role_column_value, reverse, deleted)
VALUES ('{$guid}', '{$relObjName}_created_by','Users','users','id','{$relModName}','{$relObjName}','created_by',NULL,NULL,NULL,'one-to-many',NULL,NULL,'0','0')";
$GLOBALS['db']->query($qRel);
if($GLOBALS['db']->checkError()){
//log this
}
}
}
//Also add tracker perf relationship
}
/**
* This function will merge password default settings into config file
* @param $sugar_config
* @param $sugar_version
* @return bool true if successful
*/
function merge_passwordsetting($sugar_config, $sugar_version) {
$passwordsetting_defaults = array(
'passwordsetting' => array (
'SystemGeneratedPasswordON' => '',
'generatepasswordtmpl' => '',
'lostpasswordtmpl' => '',
'forgotpasswordON' => false,
'linkexpiration' => '1',
'linkexpirationtime' => '30',
'linkexpirationtype' => '1',
'systexpiration' => '0',
'systexpirationtime' => '',
'systexpirationtype' => '0',
'systexpirationlogin' => '',
) ,
);
$sugar_config = sugarArrayMerge($passwordsetting_defaults, $sugar_config );
// need to override version with default no matter what
$sugar_config['sugar_version'] = $sugar_version;
ksort( $sugar_config );
if( write_array_to_file( "sugar_config", $sugar_config, "config.php" ) ){
return true;
}
else {
return false;
}
}
function addDefaultModuleRoles($defaultRoles = array()) {
foreach($defaultRoles as $roleName=>$role){
foreach($role as $category=>$actions){
foreach($actions as $name=>$access_override){
$query = "SELECT * FROM acl_actions WHERE name='$name' AND category = '$category' AND acltype='$roleName' AND deleted=0 ";
$result = $GLOBALS['db']->query($query);
//only add if an action with that name and category don't exist
$row=$GLOBALS['db']->fetchByAssoc($result);
if ($row == null) {
$guid = create_guid();
$currdate = gmdate($GLOBALS['timedate']->get_db_date_time_format());
$query= "INSERT INTO acl_actions (id,date_entered,date_modified,modified_user_id,name,category,acltype,aclaccess,deleted ) VALUES ('$guid','$currdate','$currdate','1','$name','$category','$roleName','$access_override','0')";
$GLOBALS['db']->query($query);
if($GLOBALS['db']->checkError()){
//log this
}
}
}
}
}
}
function verifyArguments($argv,$usage_dce,$usage_regular){
$upgradeType = '';
$cwd = getcwd(); // default to current, assumed to be in a valid SugarCRM root dir.
if(isset($argv[3])) {
if(is_dir($argv[3])) {
$cwd = $argv[3];
chdir($cwd);
} else {
echo "*******************************************************************************\n";
echo "*** ERROR: 3rd parameter must be a valid directory. Tried to cd to [ {$argv[3]} ].\n";
exit(1);;
}
}
//check if this is an instance
if(is_file("{$cwd}/ini_setup.php")){
// this is an instance
$upgradeType = constant('DCE_INSTANCE');
//now that this is dce instance we want to make sure that there are
// 7 arguments
if(count($argv) < 7) {
echo "*******************************************************************************\n";
echo "*** ERROR: Missing required parameters. Received ".count($argv)." argument(s), require 7.\n";
echo $usage_dce;
echo "FAILURE\n";
exit(1);;
}
// this is an instance
if(!is_dir($argv[1])) { // valid directory . template path?
echo "*******************************************************************************\n";
echo "*** ERROR: First argument must be a full path to the template. Got [ {$argv[1]} ].\n";
echo $usage_dce;
echo "FAILURE\n";
exit(1);;
}
}
else if(is_file("{$cwd}/include/entryPoint.php")) {
//this should be a regular sugar install
$upgradeType = constant('SUGARCRM_INSTALL');
//check if this is a valid zip file
if(!is_file($argv[1])) { // valid zip?
echo "*******************************************************************************\n";
echo "*** ERROR: First argument must be a full path to the patch file. Got [ {$argv[1]} ].\n";
echo $usage_regular;
echo "FAILURE\n";
exit(1);;
}
if(count($argv) < 5) {
echo "*******************************************************************************\n";
echo "*** ERROR: Missing required parameters. Received ".count($argv)." argument(s), require 5.\n";
echo $usage_regular;
echo "FAILURE\n";
exit(1);;
}
}
else {
//this should be a regular sugar install
echo "*******************************************************************************\n";
echo "*** ERROR: Tried to execute in a non-SugarCRM root directory.\n";
exit(1);;
}
if(isset($argv[7]) && file_exists($argv[7].'SugarTemplateUtilties.php')){
require_once($argv[7].'SugarTemplateUtilties.php');
}
return $upgradeType;
}
function upgradeDCEFiles($argv,$instanceUpgradePath){
//copy and update following files from upgrade package
$upgradeTheseFiles = array('cron.php','download.php','index.php','install.php','soap.php','sugar_version.php','vcal_server.php');
foreach($upgradeTheseFiles as $file){
$srcFile = clean_path("{$instanceUpgradePath}/$file");
$destFile = clean_path("{$argv[3]}/$file");
if(file_exists($srcFile)){
if(!is_dir(dirname($destFile))) {
mkdir_recursive(dirname($destFile)); // make sure the directory exists
}
copy_recursive($srcFile,$destFile);
$_GET['TEMPLATE_PATH'] = $destFile;
$_GET['CONVERT_FILE_ONLY'] = true;
if(!class_exists('TemplateConverter')){
include($argv[7].'templateConverter.php');
}else{
TemplateConverter::convertFile($_GET['TEMPLATE_PATH']);
}
}
}
}
function threeWayMerge(){
//using threeway merge apis
}
//// END UTILITIES THAT MUST BE LOCAL :(
///////////////////////////////////////////////////////////////////////////////
// only run from command line
if(isset($_SERVER['HTTP_USER_AGENT'])) {
fwrite(STDERR, 'This utility may only be run from the command line or command prompt.');
exit(1);
}
//Clean_string cleans out any file passed in as a parameter
$_SERVER['PHP_SELF'] = 'silentUpgrade.php';
///////////////////////////////////////////////////////////////////////////////
//// USAGE
$usage_dce =<<<eoq1
Usage: php.exe -f silentUpgrade.php [upgradeZipFile] [logFile] [pathToSugarInstance]
On Command Prompt Change directory to where silentUpgrade.php resides. Then type path to
php.exe followed by -f silentUpgrade.php and the arguments.
Example:
[path-to-PHP/]php.exe -f silentUpgrade.php [path-to-upgrade-package/]SugarEnt-Upgrade-4.5.1-to-5.0.0b.zip [path-to-log-file/]silentupgrade.log [path-to-sugar-instance/]Sugar451e
[Old Template path] [skipdbupgrade] [exitOrContinue]
Arguments:
New Template Path or Upgrade Package : Upgrade package name. Template2 (upgrade to)location.
silentupgrade.log : Silent Upgarde log file.
Sugar451e/DCE : Sugar or DCE Instance instance being upgraded.
Old Template path : Template1 (upgrade from) Instance is being upgraded.
skipDBupgrade : If set to Yes then silentupgrade will only upgrade files. Default is No.
exitOnConflicts : If set to No and conflicts are found then Upgrade continues. Default Yes.
pathToDCEClient : This is path to to DCEClient directory
eoq1;
$usage_regular =<<<eoq2
Usage: php.exe -f silentUpgrade.php [upgradeZipFile] [logFile] [pathToSugarInstance] [admin-user]
On Command Prompt Change directory to where silentUpgrade.php resides. Then type path to
php.exe followed by -f silentUpgrade.php and the arguments.
Example:
[path-to-PHP/]php.exe -f silentUpgrade.php [path-to-upgrade-package/]SugarEnt-Upgrade-5.2.0-to-5.5.0.zip [path-to-log-file/]silentupgrade.log [path-to-sugar-instance/] admin
Arguments:
upgradeZipFile : Upgrade package file.
logFile : Silent Upgarde log file.
pathToSugarInstance : Sugar Instance instance being upgraded.
admin-user : admin user performing the upgrade
eoq2;
//// END USAGE
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//// STANDARD REQUIRED SUGAR INCLUDES AND PRESETS
if(!defined('sugarEntry')) define('sugarEntry', true);
$_SESSION = array();
$_SESSION['schema_change'] = 'sugar'; // we force-run all SQL
$_SESSION['silent_upgrade'] = true;
$_SESSION['step'] = 'silent'; // flag to NOT try redirect to 4.5.x upgrade wizard
$_REQUEST = array();
$_REQUEST['addTaskReminder'] = 'remind';
define('SUGARCRM_INSTALL', 'SugarCRM_Install');
define('DCE_INSTANCE', 'DCE_Instance');
global $cwd;
$cwd = getcwd(); // default to current, assumed to be in a valid SugarCRM root dir.
$upgradeType = verifyArguments($argv,$usage_dce,$usage_regular);
///////////////////////////////////////////////////////////////////////////////
////// Verify that all the arguments are appropriately placed////////////////
///////////////////////////////////////////////////////////////////////////////
//// PREP LOCALLY USED PASSED-IN VARS & CONSTANTS
//$GLOBALS['log'] = LoggerManager::getLogger('SugarCRM');
//require_once('/var/www/html/eddy/sugarnode/SugarTemplateUtilities.php');
$path = $argv[2]; // custom log file, if blank will use ./upgradeWizard.log
//$db = &DBManagerFactory::getInstance(); //<---------
//$UWstrings = return_module_language('en_us', 'UpgradeWizard');
//$adminStrings = return_module_language('en_us', 'Administration');
//$mod_strings = array_merge($adminStrings, $UWstrings);
$subdirs = array('full', 'langpack', 'module', 'patch', 'theme', 'temp');
//$_REQUEST['zip_from_dir'] = $zip_from_dir;
define('SUGARCRM_PRE_INSTALL_FILE', 'scripts/pre_install.php');
define('SUGARCRM_POST_INSTALL_FILE', 'scripts/post_install.php');
define('SUGARCRM_PRE_UNINSTALL_FILE', 'scripts/pre_uninstall.php');
define('SUGARCRM_POST_UNINSTALL_FILE', 'scripts/post_uninstall.php');
echo "\n";
echo "********************************************************************\n";
echo "***************This Upgrade process may take sometime***************\n";
echo "********************************************************************\n";
echo "\n";
global $sugar_config;
$isDCEInstance = false;
$errors = array();
if($upgradeType == constant('DCE_INSTANCE')){
//$instanceUpgradePath = "{$argv[1]}/DCEUpgrade/{$zip_from_dir}";
//$instanceUpgradePath = "{$argv[1]}";
include ("ini_setup.php");
//get new template path for use in later processing
$dceupgrade_pos = strpos($argv[1], '/DCEUpgrade');
$newtemplate_path = substr($argv[1], 0, $dceupgrade_pos);
require("{$argv[4]}/sugar_version.php");
global $sugar_version;
/*
//require classes if they do not exist, as these were not in pre 550 entrypoint.php and need to be loaded first
if(!class_exists('VardefManager')){
require_once("{$newtemplate_path}/include/SugarObjects/VardefManager.php");
}
if (!class_exists('Sugar_Smarty')){
require_once("{$newtemplate_path}/include/Sugar_Smarty.php");
}
if (!class_exists('LanguageManager')){
require_once("{$newtemplate_path}/include/SugarObjects/LanguageManager.php");
}
*/
//load up entrypoint from original template
require_once("{$argv[4]}/include/entryPoint.php");
require_once("{$newtemplate_path}/include/utils/zip_utils.php");
require_once("{$newtemplate_path}/modules/Administration/UpgradeHistory.php");
// We need to run the silent upgrade as the admin user
require_once("{$newtemplate_path}/modules/Users/User.php");
global $current_user;
$current_user = new User();
$current_user->retrieve('1');
//This is DCE instance
global $sugar_config;
global $sugar_version;
// require_once("{$cwd}/sugar_version.php"); //provides instance version, flavor etc..
//provides instance version, flavor etc..
$isDCEInstance = true;
$configOptions = $sugar_config['dbconfig'];
$GLOBALS['log'] = LoggerManager::getLogger('SugarCRM');
$db = &DBManagerFactory::getInstance();
///////////////////////////////////////////////////////////////////////////////
//// MAKE SURE PATCH IS COMPATIBLE
if(is_file("{$argv[1]}/manifest.php")) {
// provides $manifest array
include("{$argv[1]}/manifest.php");
}
//If Instance then the files will be accessed from Template/DCEUpgrade folder
$zip_from_dir = '';
if( isset( $manifest['copy_files']['from_dir'] ) && $manifest['copy_files']['from_dir'] != "" ){
$zip_from_dir = $manifest['copy_files']['from_dir'];
}
$instanceUpgradePath = "{$argv[1]}/{$zip_from_dir}";
$_SESSION['sugar_version_file'] = '';
$srcFile = clean_path("{$instanceUpgradePath}/sugar_version.php");
if(file_exists($srcFile)) {
$_SESSION['sugar_version_file'] = $srcFile;
}
global $instancePath;
$instancePath = $instanceUpgradePath;
$_SESSION['instancePath'] = $instancePath;
if(file_exists("{$instanceUpgradePath}/modules/UpgradeWizard/uw_utils.php")){
require_once("{$instanceUpgradePath}/modules/UpgradeWizard/uw_utils.php");
} else{
require_once("{$newtemplate_path}/modules/UpgradeWizard/uw_utils.php");
}
$ce_to_pro_ent = isset($manifest['name']) && ($manifest['name'] == 'SugarCE to SugarPro' || $manifest['name'] == 'SugarCE to SugarEnt');
$_SESSION['upgrade_from_flavor'] = $manifest['name'];
//check for db upgrade
//check exit on conflicts
$skipDBUpgrade = 'no'; //default
if($argv[6] != null && !empty($argv[6])){
if(strtolower($argv[6]) == 'yes'){
$skipDBUpgrade = 'yes'; //override
}
}
global $unzip_dir;
$unzip_dir = $argv[1];
$_SESSION['unzip_dir'] = $unzip_dir;
global $path;
$path = $argv[2];
if($skipDBUpgrade == 'no'){
//upgrade the db
///////////////////////////////////////////////////////////////////////////////
//// HANDLE PREINSTALL SCRIPTS
$file = "{$argv[1]}/".constant('SUGARCRM_PRE_INSTALL_FILE');
if(is_file($file)) {
include($file);
logThis('Running pre_install()...', $path);
pre_install();
logThis('pre_install() done.', $path);
}
//run the 3-way merge
if(file_exists($newtemplate_path.'/modules/UpgradeWizard/SugarMerge/SugarMerge.php')){
logThis('Running 3 way merge()...', $path);
require_once($newtemplate_path.'/modules/UpgradeWizard/SugarMerge/SugarMerge.php');
$merger = new SugarMerge($instanceUpgradePath, $argv[4].'/', $argv[3].'/custom');
$merger->mergeAll();
logThis('Finished 3 way merge()...', $path);
}
logThis('Starting post_install()...', $path);
$file = "{$argv[1]}/".constant('SUGARCRM_POST_INSTALL_FILE');
if(is_file($file)) {
include($file);
post_install();
}
logThis('post_install() done.', $path);
///////////////////////////////////////////////////////////////////////////////
//clean vardefs
logThis('Performing UWrebuild()...', $path);
UWrebuild();
logThis('UWrebuild() done.', $path);
logThis('begin check default permissions .', $path);
checkConfigForPermissions();
logThis('end check default permissions .', $path);
logThis('begin check logger settings .', $path);
checkLoggerSettings();
logThis('end check logger settings .', $path);
logThis('Set default_max_tabs to 7', $path);
$sugar_config['default_max_tabs'] = '7';
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!';
}
//check to see if there are any new files that need to be added to systems tab
//retrieve old modules list
logThis('check to see if new modules exist',$path);
$oldModuleList = array();
$newModuleList = array();
include($argv[4].'/include/modules.php');
$oldModuleList = $moduleList;
include($newtemplate_path.'/include/modules.php');
$newModuleList = $moduleList;
/// RELOAD NEW DEFINITIONS
global $ACLActions, $beanList, $beanFiles;
include($newtemplate_path.'/modules/ACLActions/actiondefs.php');
//First repair the databse to ensure it is up to date with the new vardefs/tabledefs
logThis('About to repair the database.', $path);
//Use Repair and rebuild to update the database.
global $dictionary;
require_once($newtemplate_path.'/modules/Administration/QuickRepairAndRebuild.php');
$rac = new RepairAndClear();
$rac->clearVardefs();
$rac->rebuildExtensions();
$repairedTables = array();
//Force vardefs to be reloaded
$GLOBALS['reload_vardefs'] = true;
foreach ($beanFiles as $bean => $file) {
if(file_exists($newtemplate_path . '/' . $file) && $bean != 'UpgradeHistory'){
unset($GLOBALS['dictionary'][$bean]);
require_once($newtemplate_path . '/' . $file);
$focus = new $bean ();
if(empty($focus->table_name) || isset($repairedTables[$focus->table_name])) {
continue;
}
if (($focus instanceOf SugarBean)) {
$sql = $db->repairTable($focus, true);
if(!empty($sql)) {
logThis($sql, $path);
$repairedTables[$focus->table_name] = true;
}
}
}
}
unset ($dictionary);
include ($newtemplate_path.'/modules/TableDictionary.php');
foreach ($dictionary as $meta) {
$tablename = $meta['table'];
if(isset($repairedTables[$tablename])) {
continue;
}
$fielddefs = $meta['fields'];
$indices = $meta['indices'];
$sql = $GLOBALS['db']->repairTableParams($tablename, $fielddefs, $indices, true);
if(!empty($sql)) {
logThis($sql, $path);
$repairedTables[$tablename] = true;
}
}
logThis('database repaired', $path);
//include tab controller
require_once($newtemplate_path.'/modules/MySettings/TabController.php');
$newTB = new TabController();
//make sure new modules list has a key we can reference directly
$newModuleList = $newTB->get_key_array($newModuleList);
$oldModuleList = $newTB->get_key_array($oldModuleList);
//iterate through list and remove commonalities to get new modules
foreach ($newModuleList as $remove_mod){
if(in_array($remove_mod, $oldModuleList)){
unset($newModuleList[$remove_mod]);
}
}
//new modules list now has left over modules which are new to this install, so lets add them to the system tabs
logThis('new modules to add are '.var_export($newModuleList,true),$path);
//grab the existing system tabs
$tabs = $newTB->get_system_tabs();
//add the new tabs to the array
foreach($newModuleList as $nm ){
$tabs[$nm] = $nm;
}
//now assign the modules to system tabs
$newTB->set_system_tabs($tabs);
logThis('module tabs updated',$path);
if($ce_to_pro_ent){
//add the global team if it does not exist
$globalteam = new Team();
$globalteam->retrieve('1');
include($newtemplate_path.'/modules/Administration/language/en_us.lang.php');
if(isset($globalteam->name)){
echo 'Global '.$mod_strings['LBL_UPGRADE_TEAM_EXISTS'].'<br>';
logThis(" Finish Building private teams", $path);
}else{
$globalteam->create_team("Global", $mod_strings['LBL_GLOBAL_TEAM_DESC'], $globalteam->global_team);
}
//build private teams
logThis(" Start Building private teams", $path);
upgradeModulesForTeam();
logThis(" Finish Building private teams", $path);
//build team sets
logThis(" Start Building the team_set and team_sets_teams", $path);
upgradeModulesForTeamsets();
logThis(" Finish Building the team_set and team_sets_teams", $path);
//upgrade teams
if(file_exists($newtemplate_path.'/modules/Administration/upgradeTeams.php')) {
logThis(" Start {$newtemplate_path}/modules/Administration/upgradeTeams.php", $path);
include($newtemplate_path.'/modules/Administration/upgradeTeams.php');
logThis(" Finish {$newtemplate_path}/modules/Administration/upgradeTeams.php", $path);
//update the users records to have default team
logThis('running query to populate default_team on users table',$path);
$GLOBALS['db']->query("update users set default_team = (select teams.id from teams where teams.name = concat('(',users.user_name, ')') or team.associated_user_id = users.id)");
}
//run upgrade script for dashlets to include sales/marketing
if(function_exists('upgradeDashletsForSalesAndMarketing')){
logThis('calling upgradeDashlets script',$path);
upgradeDashletsForSalesAndMarketing();
}
}
require("sugar_version.php");
require('config.php');
global $sugar_config;
require("{$instanceUpgradePath}/sugar_version.php");
if(!rebuildConfigFile($sugar_config, $sugar_version)) {
logThis('*** ERROR: could not write config.php! - upgrade will fail!', $path);
$errors[] = 'Could not write config.php!';
}
checkConfigForPermissions();
// clear out the theme cache
if(!class_exists('SugarThemeRegistry')){
require_once($newtemplate_path . '/include/SugarTheme/SugarTheme.php');
}
SugarThemeRegistry::buildRegistry();
SugarThemeRegistry::clearAllCaches();
// re-minify the JS source files
$_REQUEST['root_directory'] = getcwd();
$_REQUEST['js_rebuild_concat'] = 'rebuild';
require_once($newtemplate_path . '/jssource/minify.php');
//as last step, rebuild the language files and rebuild relationships
/*
if(file_exists($newtemplate_path.'/modules/Administration/RebuildJSLang.php')) {
logThis("begin rebuilding js language files. via ".$newtemplate_path.'/modules/Administration/RebuildJSLang.php', $path);
include($newtemplate_path.'/modules/Administration/RebuildJSLang.php');
rebuildRelations($newtemplate_path.'/');
}
*/
}
} //END OF BIG if block
//Also set the tracker settings if flavor conversion ce->pro or ce->ent
if(isset($_SESSION['current_db_version']) && isset($_SESSION['target_db_version'])){
if($_SESSION['current_db_version'] == $_SESSION['target_db_version']){
$_REQUEST['upgradeWizard'] = true;
ob_start();
include('include/Smarty/internals/core.write_file.php');
ob_end_clean();
$db =& DBManagerFactory::getInstance();
if($ce_to_pro_ent){
//Also set license information
$admin = new Administration();
$category = 'license';
$value = 0;
$admin->saveSetting($category, 'users', $value);
$key = array('num_lic_oc','key','expire_date');
$value = '';
foreach($key as $k){
$admin->saveSetting($category, $k, $value);
}
}
}
}
set_upgrade_progress('end','done','end','done');
if(file_exists($newtemplate_path . '/modules/Configurator/Configurator.php')){
set_upgrade_progress('configurator','in_progress');
require_once($newtemplate_path . '/include/utils/array_utils.php');
if(!class_exists('Configurator')){
require_once($newtemplate_path . '/modules/Configurator/Configurator.php');
}
$Configurator = new Configurator();
if(class_exists('Configurator')){
$Configurator->parseLoggerSettings();
}
set_upgrade_progress('configurator','done');
}
//unset the logger previously instantiated
if(file_exists($newtemplate_path . '/include/SugarLogger/LoggerManager.php')){
set_upgrade_progress('logger','in_progress');
if(!class_exists('LoggerManager')){
}
if(class_exists('LoggerManager')){
unset($GsLOBALS['log']);
$GLOBALS['log'] = LoggerManager::getLogger('SugarCRM');
}
set_upgrade_progress('logger','done');
}
///////////////////////////////////////////////////////////////////////////////
//// RECORD ERRORS
$phpErrors = ob_get_contents();
ob_end_clean();
if(count($errors) > 0) {
foreach($errors as $error) {
logThis("****** SilentUpgrade ERROR: {$error}", $path);
}
echo "FAILED\n";
} else {
logThis("***** SilentUpgrade completed successfully.", $path);
echo "********************************************************************\n";
echo "*************************** SUCCESS*********************************\n";
echo "********************************************************************\n";
echo "******** If your pre-upgrade Leads data is not showing ************\n";
echo "******** Or you see errors in detailview subpanels ****************\n";
echo "************* In order to resolve them ****************************\n";
echo "******** Log into application as Administrator ********************\n";
echo "******** Go to Admin panel ****************************************\n";
echo "******** Run Repair -> Rebuild Relationships **********************\n";
echo "********************************************************************\n";
}
?>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,490 @@
<?php
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
//////////////////////////////////////////////////////////////////////////////////////////
//// This is a stand alone file that can be run from the command prompt for upgrading a
//// Sugar Instance. Three parameters are required to be defined in order to execute this file.
//// php.exe -f silentUpgrade.php [Path to Upgrade Package zip] [Path to Log file] [Path to Instance]
//// See below the Usage for more details.
/////////////////////////////////////////////////////////////////////////////////////////
ini_set('memory_limit',-1);
///////////////////////////////////////////////////////////////////////////////
//// UTILITIES THAT MUST BE LOCAL :(
//Bug 24890, 24892. default_permissions not written to config.php. Following function checks and if
//no found then adds default_permissions to the config file.
function checkConfigForPermissions(){
if(file_exists(getcwd().'/config.php')){
require(getcwd().'/config.php');
}
global $sugar_config;
if(!isset($sugar_config['default_permissions'])){
$sugar_config['default_permissions'] = array (
'dir_mode' => 02770,
'file_mode' => 0660,
'user' => '',
'group' => '',
);
ksort($sugar_config);
if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
//writing to the file
}
}
}
function checkLoggerSettings(){
if(file_exists(getcwd().'/config.php')){
require(getcwd().'/config.php');
}
global $sugar_config;
if(!isset($sugar_config['logger'])){
$sugar_config['logger'] =array (
'level'=>'fatal',
'file' =>
array (
'ext' => '.log',
'name' => 'sugarcrm',
'dateFormat' => '%c',
'maxSize' => '10MB',
'maxLogs' => 10,
'suffix' => '%m_%Y',
),
);
ksort($sugar_config);
if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
//writing to the file
}
}
}
function checkResourceSettings(){
if(file_exists(getcwd().'/config.php')){
require(getcwd().'/config.php');
}
global $sugar_config;
if(!isset($sugar_config['resource_management'])){
$sugar_config['resource_management'] =
array (
'special_query_limit' => 50000,
'special_query_modules' =>
array (
0 => 'Reports',
1 => 'Export',
2 => 'Import',
3 => 'Administration',
4 => 'Sync',
),
'default_limit' => 1000,
);
ksort($sugar_config);
if(is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config,'config.php')) {
//writing to the file
}
}
}
function verifyArguments($argv,$usage_regular){
$upgradeType = '';
$cwd = getcwd(); // default to current, assumed to be in a valid SugarCRM root dir.
if(isset($argv[3])) {
if(is_dir($argv[3])) {
$cwd = $argv[3];
chdir($cwd);
} else {
echo "*******************************************************************************\n";
echo "*** ERROR: 3rd parameter must be a valid directory. Tried to cd to [ {$argv[3]} ].\n";
exit(1);
}
}
//check if this is an instance
if(is_file("{$cwd}/include/entryPoint.php")) {
//this should be a regular sugar install
$upgradeType = constant('SUGARCRM_INSTALL');
//check if this is a valid zip file
if(!is_file($argv[1])) { // valid zip?
echo "*******************************************************************************\n";
echo "*** ERROR: First argument must be a full path to the patch file. Got [ {$argv[1]} ].\n";
echo $usage_regular;
echo "FAILURE\n";
exit(1);
}
if(count($argv) < 5) {
echo "*******************************************************************************\n";
echo "*** ERROR: Missing required parameters. Received ".count($argv)." argument(s), require 5.\n";
echo $usage_regular;
echo "FAILURE\n";
exit(1);
}
}
else {
//this should be a regular sugar install
echo "*******************************************************************************\n";
echo "*** ERROR: Tried to execute in a non-SugarCRM root directory.\n";
exit(1);
}
if(isset($argv[7]) && file_exists($argv[7].'SugarTemplateUtilties.php')){
require_once($argv[7].'SugarTemplateUtilties.php');
}
return $upgradeType;
}
//// END UTILITIES THAT MUST BE LOCAL :(
///////////////////////////////////////////////////////////////////////////////
// only run from command line
if(isset($_SERVER['HTTP_USER_AGENT'])) {
fwrite(STDERR,'This utility may only be run from the command line or command prompt.');
exit(1);
}
//Clean_string cleans out any file passed in as a parameter
$_SERVER['PHP_SELF'] = 'silentUpgrade.php';
///////////////////////////////////////////////////////////////////////////////
//// USAGE
$usage_regular =<<<eoq2
Usage: php.exe -f silentUpgrade.php [upgradeZipFile] [logFile] [pathToSugarInstance] [admin-user]
On Command Prompt Change directory to where silentUpgrade.php resides. Then type path to
php.exe followed by -f silentUpgrade.php and the arguments.
Example:
[path-to-PHP/]php.exe -f silentUpgrade.php [path-to-upgrade-package/]SugarEnt-Upgrade-5.2.0-to-5.5.0.zip [path-to-log-file/]silentupgrade.log [path-to-sugar-instance/] admin
Arguments:
upgradeZipFile : Upgrade package file.
logFile : Silent Upgarde log file.
pathToSugarInstance : Sugar Instance instance being upgraded.
admin-user : admin user performing the upgrade
eoq2;
//// END USAGE
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//// STANDARD REQUIRED SUGAR INCLUDES AND PRESETS
if(!defined('sugarEntry')) define('sugarEntry', true);
$_SESSION = array();
$_SESSION['schema_change'] = 'sugar'; // we force-run all SQL
$_SESSION['silent_upgrade'] = true;
$_SESSION['step'] = 'silent'; // flag to NOT try redirect to 4.5.x upgrade wizard
$_REQUEST = array();
$_REQUEST['addTaskReminder'] = 'remind';
define('SUGARCRM_INSTALL', 'SugarCRM_Install');
define('DCE_INSTANCE', 'DCE_Instance');
global $cwd;
$cwd = getcwd(); // default to current, assumed to be in a valid SugarCRM root dir.
$upgradeType = verifyArguments($argv,$usage_regular);
$path = $argv[2]; // custom log file, if blank will use ./upgradeWizard.log
$subdirs = array('full', 'langpack', 'module', 'patch', 'theme', 'temp');
require_once('include/entryPoint.php');
require_once('modules/UpgradeWizard/uw_utils.php');
require_once('include/utils/zip_utils.php');
require_once('include/utils/sugar_file_utils.php');
require_once('include/SugarObjects/SugarConfig.php');
global $sugar_config;
$isDCEInstance = false;
$errors = array();
require('config.php');
if(isset($argv[3])) {
if(is_dir($argv[3])) {
$cwd = $argv[3];
chdir($cwd);
}
}
require_once("{$cwd}/sugar_version.php"); // provides $sugar_version & $sugar_flavor
global $sugar_config;
$configOptions = $sugar_config['dbconfig'];
$GLOBALS['log'] = LoggerManager::getLogger('SugarCRM');
$patchName = basename($argv[1]);
$zip_from_dir = substr($patchName, 0, strlen($patchName) - 4); // patch folder name (minus ".zip")
$path = $argv[2]; // custom log file, if blank will use ./upgradeWizard.log
if($sugar_version < '5.1.0'){
$db = &DBManager :: getInstance();
} else{
$db = &DBManagerFactory::getInstance();
}
$UWstrings = return_module_language('en_us', 'UpgradeWizard');
$adminStrings = return_module_language('en_us', 'Administration');
$mod_strings = array_merge($adminStrings, $UWstrings);
$subdirs = array('full', 'langpack', 'module', 'patch', 'theme', 'temp');
global $unzip_dir;
$license_accepted = false;
if(isset($argv[5]) && (strtolower($argv[5])=='yes' || strtolower($argv[5])=='y')){
$license_accepted = true;
}
//////////////////////////////////////////////////////////////////////////////
//Adding admin user to the silent upgrade
$current_user = new User();
if(isset($argv[4])) {
//if being used for internal upgrades avoid admin user verification
$user_name = $argv[4];
$q = "select id from users where user_name = '" . $user_name . "' and is_admin=1";
$result = $GLOBALS['db']->query($q, false);
$logged_user = $GLOBALS['db']->fetchByAssoc($result);
if(isset($logged_user['id']) && $logged_user['id'] != null){
//do nothing
$current_user->retrieve($logged_user['id']);
}
else{
echo "Not an admin user in users table. Please provide an admin user\n";
exit(1);
}
}
else {
echo "*******************************************************************************\n";
echo "*** ERROR: 4th parameter must be a valid admin user.\n";
echo $usage;
echo "FAILURE\n";
exit(1);
}
/////retrieve admin user
$unzip_dir = clean_path("{$cwd}/{$sugar_config['upload_dir']}upgrades/temp");
$install_file = clean_path("{$cwd}/{$sugar_config['upload_dir']}upgrades/patch/".basename($argv[1]));
$_SESSION['unzip_dir'] = $unzip_dir;
$_SESSION['install_file'] = $install_file;
$_SESSION['zip_from_dir'] = $zip_from_dir;
mkdir_recursive($unzip_dir);
if(!is_dir($unzip_dir)) {
fwrite(STDERR,"\n{$unzip_dir} is not an available directory\nFAILURE\n");
exit(1);
}
unzip($argv[1], $unzip_dir);
// mimic standard UW by copy patch zip to appropriate dir
copy($argv[1], $install_file);
//// END UPGRADE PREP
///////////////////////////////////////////////////////////////////////////////
if(function_exists('set_upgrade_vars')){
set_upgrade_vars();
}
/*
if($configOptions['db_type'] == 'mysql'){
//Change the db wait_timeout for this session
$que ="select @@wait_timeout";
$result = $db->query($que);
$tb = $db->fetchByAssoc($result);
logThis('Wait Timeout before change ***** '.$tb['@@wait_timeout'] , $path);
$query ="set wait_timeout=28800";
$db->query($query);
$result = $db->query($que);
$ta = $db->fetchByAssoc($result);
logThis('Wait Timeout after change ***** '.$ta['@@wait_timeout'] , $path);
}
*/
///////////////////////////////////////////////////////////////////////////////
//// RUN SILENT UPGRADE
ob_start();
set_time_limit(0);
/// RELOAD NEW DEFINITIONS
global $ACLActions, $beanList, $beanFiles;
include('modules/ACLActions/actiondefs.php');
include('include/modules.php');
// clear out the theme cache
if(is_dir($GLOBALS['sugar_config']['cache_dir'].'themes')){
$allModFiles = array();
$allModFiles = findAllFiles($GLOBALS['sugar_config']['cache_dir'].'themes',$allModFiles);
foreach($allModFiles as $file){
//$file_md5_ref = str_replace(clean_path(getcwd()),'',$file);
if(file_exists($file)){
unlink($file);
}
}
}
// re-minify the JS source files
$_REQUEST['root_directory'] = getcwd();
$_REQUEST['js_rebuild_concat'] = 'rebuild';
require_once('jssource/minify.php');
//First repair the databse to ensure it is up to date with the new vardefs/tabledefs
logThis('About to repair the database.', $path);
//Use Repair and rebuild to update the database.
global $dictionary;
require_once("modules/Administration/QuickRepairAndRebuild.php");
$rac = new RepairAndClear();
$rac->clearVardefs();
$rac->rebuildExtensions();
$repairedTables = array();
foreach ($beanFiles as $bean => $file) {
if(file_exists($file)){
unset($GLOBALS['dictionary'][$bean]);
require_once($file);
$focus = new $bean ();
if(empty($focus->table_name) || isset($repairedTables[$focus->table_name])) {
continue;
}
if (($focus instanceOf SugarBean)) {
$sql = $db->repairTable($focus, true);
if(!empty($sql)) {
logThis($sql, $path);
$repairedTables[$focus->table_name] = true;
}
}
}
}
unset ($dictionary);
include ("{$argv[3]}/modules/TableDictionary.php");
foreach ($dictionary as $meta) {
$tablename = $meta['table'];
if(isset($repairedTables[$tablename])) {
continue;
}
$fielddefs = $meta['fields'];
$indices = $meta['indices'];
$sql = $GLOBALS['db']->repairTableParams($tablename, $fielddefs, $indices, true);
if(!empty($sql)) {
logThis($sql, $path);
$repairedTables[$tablename] = true;
}
}
logThis('database repaired', $path);
include("{$cwd}/{$sugar_config['upload_dir']}upgrades/temp/manifest.php");
$ce_to_pro_ent = isset($manifest['name']) && ($manifest['name'] == 'SugarCE to SugarPro' || $manifest['name'] == 'SugarCE to SugarEnt');
$origVersion = substr(preg_replace("/[^0-9]/", "", $sugar_version),0,3);
if($origVersion < '550' || $ce_to_pro_ent) {
//add the global team if it does not exist
$globalteam = new Team();
$globalteam->retrieve('1');
require_once('modules/Administration/language/en_us.lang.php');
if(isset($globalteam->name)){
echo 'Global '.$mod_strings['LBL_UPGRADE_TEAM_EXISTS'].'<br>';
logThis(" Finish Building Global Team", $path);
}else{
$globalteam->create_team("Global", $mod_strings['LBL_GLOBAL_TEAM_DESC'], $globalteam->global_team);
}
logThis(" Start Building private teams", $path);
upgradeModulesForTeam();
logThis(" Finish Building private teams", $path);
logThis(" Start Building the team_set and team_sets_teams", $path);
upgradeModulesForTeamsets();
logThis(" Finish Building the team_set and team_sets_teams", $path);
logThis(" Start modules/Administration/upgradeTeams.php", $path);
include('modules/Administration/upgradeTeams.php');
logThis(" Finish modules/Administration/upgradeTeams.php", $path);
if($sugar_config['dbconfig']['db_type'] == 'mssql') {
if(check_FTS()){
$GLOBALS['db']->wakeupFTS();
}
}
}
///////////////////////////////////////////////////////////////////////////////
//// TAKE OUT TRASH
if(empty($errors)) {
set_upgrade_progress('end','in_progress','unlinkingfiles','in_progress');
logThis('Taking out the trash, unlinking temp files.', $path);
unlinkTempFiles(true);
logThis('Taking out the trash, done.', $path);
}
///////////////////////////////////////////////////////////////////////////////
//// RECORD ERRORS
$phpErrors = ob_get_contents();
ob_end_clean();
logThis("**** Potential PHP generated error messages: {$phpErrors}", $path);
if(count($errors) > 0) {
foreach($errors as $error) {
logThis("****** SilentUpgrade ERROR: {$error}", $path);
}
echo "FAILED\n";
} else {
logThis("***** SilentUpgrade completed successfully.", $path);
echo "********************************************************************\n";
echo "*************************** SUCCESS*********************************\n";
echo "********************************************************************\n";
echo "******** If your pre-upgrade Leads data is not showing ************\n";
echo "******** Or you see errors in detailview subpanels ****************\n";
echo "************* In order to resolve them ****************************\n";
echo "******** Log into application as Administrator ********************\n";
echo "******** Go to Admin panel ****************************************\n";
echo "******** Run Repair -> Rebuild Relationships **********************\n";
echo "********************************************************************\n";
}
?>

114
modules/UpgradeWizard/start.php Executable file
View File

@@ -0,0 +1,114 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*********************************************************************************
* Description:
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights
* Reserved. Contributor(s): ______________________________________..
* *******************************************************************************/
logThis('-----------------------------------------------------------------------------');
logThis('Upgrade started. At start.php');
//set the upgrade progress status.
set_upgrade_progress('start','in_progress');
unlinkTempFiles();
unlinkUploadFiles();
resetUwSession();
if(isset($_REQUEST['showUpdateWizardMessage']) && $_REQUEST['showUpdateWizardMessage'] == true) {
// set a flag to skip the upload screen
$_SESSION['skip_zip_upload'] = true;
$newUWMsg =<<<eoq
<table cellspacing="0" cellpadding="3" border="0">
<tr>
<th>
{$mod_strings['LBL_UW_START_UPGRADED_UW_TITLE']}
</th>
</tr>
<tr>
<td>
{$mod_strings['LBL_UW_START_UPGRADED_UW_DESC']}
</td>
</tr>
</table>
eoq;
echo $newUWMsg;
}
$uwMain =<<<eoq
<table cellpadding="3" cellspacing="0" border="0">
<tr>
<th align="left">
{$mod_strings['LBL_UW_TITLE_START']}
</th>
</tr>
<tr>
<td align="left">
<p>
{$mod_strings['LBL_UW_START_DESC']}
</p>
<p>
<span class="error">
{$mod_strings['LBL_UW_START_DESC2']}
</span>
</p>
</td>
</tr>
</table>
<div id="upgradeDiv" style="display:none">
<table cellspacing="0" cellpadding="0" border="0">
<tr><td>
<p><img src='modules/UpgradeWizard/processing.gif'> <br>{$mod_strings['LBL_UPGRADE_TAKES_TIME_HAVE_PATIENCE']}</p>
</td></tr>
</table>
</div>
eoq;
$showBack = false;
$showCancel = false;
$showRecheck = false;
$showNext = true;
$stepBack = 0;
$stepNext = 1;
$stepCancel = 0;
$stepRecheck = 0;
?>

View File

@@ -0,0 +1,300 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*********************************************************************************
* Description:
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights
* Reserved. Contributor(s): ______________________________________..
* *******************************************************************************/
logThis('[At systemCheck.php]');
$stop = false; // flag to prevent going to next step
///////////////////////////////////////////////////////////////////////////////
//// FILE CHECKS
logThis('Starting file permission check...');
$filesNotWritable = array();
$filesNWPerms = array();
// add directories here that should be skipped when doing file permissions checks (cache/upload is the nasty one)
$skipDirs = array(
$sugar_config['upload_dir'],
'.svn',
);
$files = uwFindAllFiles(getcwd(), array(), true, $skipDirs);
$i=0;
$filesOut = "
<a href='javascript:void(0); toggleNwFiles(\"filesNw\");'>{$mod_strings['LBL_UW_SHOW_NW_FILES']}</a>
<div id='filesNw' style='display:none;'>
<table cellpadding='3' cellspacing='0' border='0'>
<tr>
<th align='left'>{$mod_strings['LBL_UW_FILE']}</th>
<th align='left'>{$mod_strings['LBL_UW_FILE_PERMS']}</th>
<th align='left'>{$mod_strings['LBL_UW_FILE_OWNER']}</th>
<th align='left'>{$mod_strings['LBL_UW_FILE_GROUP']}</th>
</tr>";
$isWindows = is_windows();
foreach($files as $file) {
if($isWindows) {
if(!is_writable_windows($file)) {
logThis('WINDOWS: File ['.$file.'] not readable - saving for display');
// don't warn yet - we're going to use this to check against replacement files
$filesNotWritable[$i] = $file;
$filesNWPerms[$i] = substr(sprintf('%o',fileperms($file)), -4);
$filesOut .= "<tr>".
"<td><span class='error'>{$file}</span></td>".
"<td>{$filesNWPerms[$i]}</td>".
"<td>".$mod_strings['ERR_UW_CANNOT_DETERMINE_USER']."</td>".
"<td>".$mod_strings['ERR_UW_CANNOT_DETERMINE_GROUP']."</td>".
"</tr>";
}
} else {
if(!is_writable($file)) {
logThis('File ['.$file.'] not writable - saving for display');
// don't warn yet - we're going to use this to check against replacement files
$filesNotWritable[$i] = $file;
$filesNWPerms[$i] = substr(sprintf('%o',fileperms($file)), -4);
$owner = posix_getpwuid(fileowner($file));
$group = posix_getgrgid(filegroup($file));
$filesOut .= "<tr>".
"<td><span class='error'>{$file}</span></td>".
"<td>{$filesNWPerms[$i]}</td>".
"<td>".$owner['name']."</td>".
"<td>".$group['name']."</td>".
"</tr>";
}
}
$i++;
}
$filesOut .= '</table></div>';
// not a stop error
$errors['files']['filesNotWritable'] = (count($filesNotWritable) > 0) ? true : false;
if(count($filesNotWritable) < 1) {
$filesOut = "<b>{$mod_strings['LBL_UW_FILE_NO_ERRORS']}</b>";
}
logThis('Finished file permission check.');
//// END FILE CHECKS
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//// DATABASE CHECKS
logThis('Starting database permissions check...');
$dbOut = "
<a href='javascript:void(0); toggleNwFiles(\"dbPerms\");'>{$mod_strings['LBL_UW_SHOW_DB_PERMS']}</a>
<div id='dbPerms' style='display:none;'>
<table cellpadding='3' cellspacing='0' border='0'>
<tr>
<th align='left'>{$mod_strings['LBL_UW_DB_PERMS']}</th>
</tr>";
$db =& DBManagerFactory::getInstance();
$outs = array();
$outs['skip'] = false;
$outs['db'] = array();
$outs['dbOut'] = $dbOut;
$outs = testPermsCreate($db->dbType, $outs);
$outs = testPermsInsert($db->dbType, $outs, $outs['skip']);
$outs = testPermsUpdate($db->dbType, $outs, $outs['skip']);
$outs = testPermsSelect($db->dbType, $outs, $outs['skip']);
$outs = testPermsDelete($db->dbType, $outs, $outs['skip']);
$outs = testPermsAlterTableAdd($db->dbType, $outs, $outs['skip']);
$outs = testPermsAlterTableChange($db->dbType, $outs, $outs['skip']);
$outs = testPermsAlterTableDrop($db->dbType, $outs, $outs['skip']);
$outs = testPermsDropTable($db->dbType, $outs, $outs['skip']);
$outs['dbOut'] .= '</table>';
if(count($outs['db']) < 1) {
logThis('No permissions errors found!');
$outs['dbOut'] = "<b>".$mod_strings['LBL_UW_DB_NO_ERRORS']."</b>";
}
logThis('Finished database permissions check.');
$dbOut = $outs['dbOut'];
//// END DATABASE CHECKS
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//// INSTALLER TYPE CHECKS
$result = checkSystemCompliance();
$checks = array(
'phpVersion' => $mod_strings['LBL_UW_COMPLIANCE_PHP_VERSION'],
'mysqlVersion' => $mod_strings['LBL_UW_COMPLIANCE_MYSQL'],
'mssqlStatus' => $mod_strings['LBL_UW_COMPLIANCE_MSSQL_MAGIC_QUOTES'],
'xmlStatus' => $mod_strings['LBL_UW_COMPLIANCE_XML'],
'curlStatus' => $mod_strings['LBL_UW_COMPLIANCE_CURL'],
'imapStatus' => $mod_strings['LBL_UW_COMPLIANCE_IMAP'],
'mbstringStatus' => $mod_strings['LBL_UW_COMPLIANCE_MBSTRING'],
'safeModeStatus' => $mod_strings['LBL_UW_COMPLIANCE_SAFEMODE'],
'callTimeStatus' => $mod_strings['LBL_UW_COMPLIANCE_CALLTIME'],
'memory_msg' => $mod_strings['LBL_UW_COMPLIANCE_MEMORY'],
//commenting mbstring overload.
//'mbstring.func_overload' => $mod_strings['LBL_UW_COMPLIANCE_MBSTRING_FUNC_OVERLOAD'],
);
if($result['error_found'] == true) {
$stop = true;
$phpIniLocation = get_cfg_var("cfg_file_path");
$sysCompliance = "<a href='javascript:void(0); toggleNwFiles(\"sysComp\");'>{$mod_strings['LBL_UW_SHOW_COMPLIANCE']}</a>";
$sysCompliance .= "<div id='sysComp' >";
$sysCompliance .= "<table cellpadding='0' cellspacing='0' border='0'>";
foreach($result as $k => $v) {
if($k == 'error_found')
continue;
$sysCompliance .= "<tr><td valign='top'>{$checks[$k]}</td>";
$sysCompliance .= "<td valign='top'>{$v}</td></tr>";
}
$sysCompliance .= "<tr><td valign='top'>{$mod_strings['LBL_UW_COMPLIANCE_PHP_INI']}</td>";
$sysCompliance .= "<td valign='top'><b>{$phpIniLocation}</b></td></tr>";
$sysCompliance .= "</table></div>";
} else {
$sysCompliance = "<b>{$mod_strings['LBL_UW_COMPLIANCE_ALL_OK']}</b>";
}
//// END INSTALLER CHECKS
///////////////////////////////////////////////////////////////////////////////
//// stop on all errors
foreach($errors as $k => $type) {
if(is_array($type) && count($type) > 0) {
foreach($type as $k => $subtype) {
if($subtype == true) {
$stop = true;
}
}
}
if($type === true) {
logThis('Found errors during system check - disabling forward movement.');
$stop = true;
}
}
$showBack = true;
$showCancel = true;
$showRecheck = true;
$showNext = ($stop) ? false : true;
$stepBack = $_REQUEST['step'] - 1;
$stepNext = $_REQUEST['step'] + 1;
$stepCancel = -1;
$stepRecheck = $_REQUEST['step'];
$_SESSION['step'][$steps['files'][$_REQUEST['step']]] = ($stop) ? 'failed' : 'success';
///////////////////////////////////////////////////////////////////////////////
//// OUTPUT
$uwMain =<<<eoq
<style>
.stop {
color: #cc0000;
}
.go {
color: #00cc00;
}
</style>
<table cellpadding="3" cellspacing="0" border="0">
<tr>
<th align="left" colspan="2">
{$mod_strings['LBL_UW_FILE_ISSUES']}:
<hr>
</th>
</tr>
<tr>
<td align="left" valign="top">
{$mod_strings['LBL_UW_FILE_ISSUES_PERMS']}
</td>
<td>
{$filesOut}
</td>
</tr>
<tr>
<td colspan="2">
<p>&nbsp;</p>
</td>
</tr>
<tr>
<th align="left" colspan="2">
{$mod_strings['LBL_UW_DB_ISSUES']}:
<hr>
</th>
</tr>
<tr>
<td align="left" valign="top">
{$mod_strings['LBL_UW_DB_ISSUES_PERMS']}
</td>
<td>
{$dbOut}
</td>
</tr>
<tr>
<td colspan="2">
<p>&nbsp;</p>
</td>
</tr>
<tr>
<th align="left" colspan="2">
{$mod_strings['LBL_UW_COMPLIANCE_TITLE']}:
<hr>
</th>
</tr>
<tr>
<td align="left" valign="top">
{$mod_strings['LBL_UW_COMPLIANCE_TITLE2']}
</td>
<td>
{$sysCompliance}
</td>
</tr>
</table>
<div id="upgradeDiv" style="display:none">
<table border="0" cellspacing="0" cellpadding="0">
<tr><td>
<p><img src='modules/UpgradeWizard/processing.gif'> <br>{$mod_strings['LBL_UPGRADE_TAKES_TIME_HAVE_PATIENCE']}</p>
</td></tr>
</table>
</div>
eoq;
?>

View File

@@ -0,0 +1,94 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*********************************************************************************
* Description:
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights
* Reserved. Contributor(s): ______________________________________..
* *******************************************************************************/
if(ob_get_level() < 1)
ob_start();
ob_implicit_flush(1);
// load the generated persistence file if found
$persistence = array();
if(file_exists(getcwd().'/modules/UpgradeWizard/_persistence.php')) {
require_once(getcwd().'/modules/UpgradeWizard/_persistence.php');
}
if(!function_exists('getFilesForPermsCheck')) {
require_once('modules/UpgradeWizard/uw_utils.php');
}
if(!isset($sugar_config) || empty($sugar_config)) {
}
switch($_REQUEST['systemCheckStep']) {
case 'find_all_files':
ob_end_flush();
$persistence['files_to_check'] = getFilesForPermsCheck();
break;
case 'check_found_files':
if(empty($persistence['files_to_check'])) {
logThis('*** ERROR: could not find persistent array of files to check');
echo $mod_strings['ERR_UW_NO_FILES'];
} else {
ob_end_flush();
$persistence = checkFiles($persistence['files_to_check'], true);
}
break;
case 'check_files_status':
$ret = ($persistence['filesNotWritable']) ? 'true' : 'false';
echo $ret;
break;
}
write_array_to_file('persistence', $persistence, 'modules/UpgradeWizard/_persistence.php');
?>

View File

@@ -0,0 +1,393 @@
<?php
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
class UpgradeMetaHelper{
var $upgrade_dir;
var $debug_mode;
var $upgrade_modules;
var $customized_modules;
var $source_dir;
var $dest_dir ;
var $evparser;
var $dvparser;
var $path_to_master_copy;
/**
* UpgradeMetaHelper
* This is the constructor for the UpgradeMetaHelper class
* @param $dir The root upgrade directory (where to copy working files)
* @param $masterCopyDirectory The root master directory (where SugarCRM 5.x files reside)
* @param $debugMode Debug mode, default is false
*
*/
function UpgradeMetaHelper($dir='upgrade', $masterCopyDirecotry='modules_50', $debugMode = false) {
$this->upgrade_dir = $dir;
$this->debug_mode = $debugMode;
$this->upgrade_modules = $this->getModifiedModules();
if(count($this->upgrade_modules) > 0) {
$_SESSION['Upgraded_Modules'] = $this->upgrade_modules;
$this->create_upgrade_directory();
$this->path_to_master_copy = $masterCopyDirecotry;
$this->runParser();
}
$this->customized_modules = $this->getAllCustomizedModulesBeyondStudio();
if(count($this->customized_modules) > 0) {
$_SESSION['Customized_Modules'] = $this->customized_modules;
}
}
/**
* getModifiedModules
* This method returns a two-dimensional Array of Studio enabled
* modules that have been modified. The second Array index is an
* Array of files that do not match the md5 checksum for the module
* @return $return_array Two-dimensional Array of [module][modified file(s) Array]
*/
function getModifiedModules() {
$md5_string = array();
if(file_exists(clean_path(getcwd().'/files.md5'))){
require(clean_path(getcwd().'/files.md5'));
}
$return_array = array();
$modules = $this->loadStudioModules();
foreach($modules as $mod) {
$editView = "modules/$mod/EditView.html";
$detailView = "modules/$mod/DetailView.html";
$searchForm = "modules/$mod/SearchForm.html";
if(file_exists($editView) && isset($md5_string['./' . $editView])) {
$fileContents = file_get_contents($editView);
if(md5($fileContents) != $md5_string['./' . $editView]) {
$return_array[$mod][] = $editView;
}
}
if(file_exists($detailView) && isset($md5_string['./' . $detailView])) {
$fileContents = file_get_contents($detailView);
if(md5($fileContents) != $md5_string['./' . $detailView]) {
$return_array[$mod][] = $detailView;
}
}
if(file_exists($searchForm) && isset($md5_string['./' . $searchForm])) {
$fileContents = file_get_contents($searchForm);
if(md5($fileContents) != $md5_string['./' . $searchForm]) {
$return_array[$mod][] = $searchForm;
}
}
} //foreach
return $return_array;
}
function saveMatchingFilesQueries($currStep,$value){
$upgrade_progress_dir = getcwd().'/'.$GLOBALS['sugar_config']['upload_dir'].'upgrades/temp';
if(!is_dir($upgrade_progress_dir)){
mkdir($upgrade_progress_dir);
}
$file_queries_file = $upgrade_progress_dir.'/files_queries.php';
if(file_exists($file_queries_file)){
include($file_queries_file);
}
else{
if(function_exists('sugar_fopen')){
sugar_fopen($file_queries_file, 'w+');
}
else{
fopen($file_queries_file, 'w+');
}
}
if(!isset($files_queries) || $files_queries == NULL){
$files_queries = array();
}
$files_queries[$currStep]=$value;
if(is_writable($file_queries_file) && write_array_to_file( "file_queries", $file_queries,
$file_queries_file)) {
//writing to the file
}
}
function getAllCustomizedModulesBeyondStudio() {
require_once('modules/UpgradeWizard/uw_utils.php');
$md5_string = array();
if(file_exists(clean_path(getcwd().'/files.md5'))){
require(clean_path(getcwd().'/files.md5'));
}
$return_array = array();
$modules = $this->loadStudioModules();
$modulesAll = getAllModules(); //keep all modules as well
$allOtherModules = array_diff($modulesAll,$modules);
foreach($modules as $mod) {
if(!is_dir('modules/'.$mod)) continue;
$editView = "modules/$mod/EditView.html";
$detailView ="modules/$mod/DetailView.html";
$exclude_files[]=$editView;
$exclude_files[]=$detailView;
$allModFiles = array();
$allModFiles = findAllFiles('modules/'.$mod,$allModFiles);
foreach($allModFiles as $file){
//$file_md5_ref = str_replace(clean_path(getcwd()),'',$file);
if(file_exists($file) && !in_array($file,$exclude_files)){
if(isset($md5_string['./'.$file])) {
$fileContents = file_get_contents($file);
if(md5($fileContents) != $md5_string['./'.$file]) {
$return_array[$mod][] = $file;
}
else{
//keep in the array to be deleted later
$_SESSION['removeMd5MatchingFiles'][] = $file;
}
}
}
}
} //foreach
//also check out other non-studio modules by taking the difference between
//allMOdules and
foreach($allOtherModules as $mod) {
if(!is_dir('modules/'.$mod)) continue;
$allModFiles = array();
$allModFiles = findAllFiles('modules/'.$mod,$allModFiles);
foreach($allModFiles as $file){
//$file_md5_ref = str_replace(clean_path(getcwd()),'',$file);
if(file_exists($file)){
if(isset($md5_string['./'.$file])) {
$fileContents = file_get_contents($file);
if(md5($fileContents) == $md5_string['./'.$file]) {
$_SESSION['removeMd5MatchingFiles'][] = $file;
}
}
}
}
}
//Also store in a file
//saveMatchingFilesQueries('removeMd5MatchingFiles',$_SESSION['removeMd5MatchingFiles']);
return $return_array;
}
/**
* Get all the customized modules. Compare the file md5s with the base md5s
* If a file has been modified then put the module in the list of customized
* modules. Show the list in the preflight check UI.
*/
function getAllCustomizedModules() {
require_once('files.md5');
$return_array = array();
$modules = getAllModules();
foreach($modules as $mod) {
//find all files in each module if the files have been modified
//as compared to the base version then add the module to the
//customized modules array
$modFiles = findAllFiles(clean_path(getcwd())."/modules/$mod", array());
foreach($modFiles as $file){
$fileContents = file_get_contents($file);
$file = str_replace(clean_path(getcwd()),'',$file);
if($md5_string['./' . $file]){
if(md5($fileContents) != $md5_string['./' . $file]) {
//A file has been customized in the module. Put the module into the
// customized modules array.
echo 'Changed File'.$file;
$return_array[$mod];
break;
}
}
else{
// This is a new file in user's version and indicates that module has been
//customized. Put the module in the customized array.
echo 'New File'.$file;
$return_array[$mod];
break;
}
}
} //foreach
return $return_array;
}
/**
* loadStudioModules
* This method returns an Array of all modules where a studio.php file is
* present in the metadata directory of the module
* @return $modules Array of modules that are studio enabled
*/
function loadStudioModules() {
$modules = array();
$d = dir('modules');
while($e = $d->read()){
if(substr($e, 0, 1) == '.' || !is_dir('modules/' . $e))continue;
if(file_exists('modules/' . $e . '/metadata/studio.php')){
$modules[] = $e;
}
}
return $modules;
}
/**
* runParser
* This method creates the EditView and DetailView parser intances
* and runs the parsing for the modules to upgrade
*
*/
function runParser() {
require_once('include/SugarFields/Parsers/EditViewMetaParser.php');
require_once('include/SugarFields/Parsers/DetailViewMetaParser.php');
require_once('include/SugarFields/Parsers/SearchFormMetaParser.php');
$this->evparser = new EditViewMetaParser();
$this->dvparser = new DetailViewMetaParser();
$this->svparser = new SearchFormMetaParser();
foreach($this->upgrade_modules as $module_name=>$files) {
$this->parseFile($module_name, $files);
} //foreach
}
/**
* parseFile
* Hanldes parsing the files for given module where Studio or manual
* changes have been detected.
* @param $module_name The module to parse
* @param $files Array of files found to parse
*
*/
function parseFile($module_name, $files) {
global $beanList, $dictionary;
foreach($files as $file) {
if(preg_match('/(EditView|DetailView|SearchForm|QuickCreate)(\.html|\.tpl)$/s', $file, $matches)) {
$view = $matches[1];
switch($view) {
case 'EditView' : $parser = $this->evparser; break;
case 'DetailView' : $parser = $this->dvparser; break;
case 'SearchForm' : $parser = $this->svparser; break;
}
$lowerCaseView = $view == 'SearchForm' ? 'search' : strtolower($view);
include('modules/'.$module_name.'/vardefs.php');
$bean_name = $beanList[$module_name];
$newFile = $this->upgrade_dir.'/modules/'.$module_name.'/metadata/'.$lowerCaseView.'defs.php';
$evfp = fopen($newFile,'w');
$bean_name = $bean_name == 'aCase' ? 'Case' : $bean_name;
fwrite($evfp, $parser->parse($file,
$dictionary[$bean_name]['fields'],
$module_name,
true,
$this->path_to_master_copy.'/modules/'.$module_name.'/metadata/'.$lowerCaseView.'defs.php'));
fclose($evfp);
} //if
} //foreach
}
/**
* create_upgrade_directory
* Creates a directory called upgrade to house all the modules that are studio enabled.
* Also creates subdirectories for all studio enabled modules.
*
*/
function create_upgrade_directory() {
$dir = $this->upgrade_dir.'/modules';
if(!file_exists($this->upgrade_dir)) {
mkdir($this->upgrade_dir, 0755);
}
if(!file_exists($dir)) {
mkdir($dir, 0755);
}
foreach($this->upgrade_modules as $module=>$files){
if(!file_exists($dir.'/'.$module)) {
mkdir($dir.'/'.$module, 0755);
}
if(!file_exists($dir.'/'.$module.'/metadata')) {
mkdir($dir.'/'.$module.'/metadata', 0755);
}
foreach($files as $file) {
if(file_exists($file) && is_file($file)) {
copy($file, $this->upgrade_dir.'/'.$file);
} //if
} //foreach
}
}
/**
* verifyMetaData
* This function does some quick checks to make sure the metadataFile at
* least has an Array panel
*
* @param $metadataFile The path to the metadata file to verify
* @param $module The module to verify
* @param $view The view (EditView or DetailView)
* @return boolean true if verification check is okay; false otherwise
*/
function verifyMetaData($metadataFile, $module, $view) {
if(!file_exists($metadataFile) || !is_file($metadataFile)) {
return false;
}
include($metadataFile);
if(isset($viewdefs) && isset($viewdefs[$module][$view]['panels']) && is_array($viewdefs[$module][$view]['panels'])) {
return true;
}
if(isset($searchdefs) && isset($searchdefs[$module]) && is_array($searchdefs[$module])) {
return true;
}
return false;
}
}
?>

View File

@@ -0,0 +1,87 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*********************************************************************************
* Description:
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights
* Reserved. Contributor(s): ______________________________________..
* *******************************************************************************/
session_start();
$GLOBALS['installing'] = true;
require_once('include/JSON.php');
require_once('include/utils/db_utils.php');
require_once('include/utils/zip_utils.php');
require_once('modules/UpgradeWizard/uw_utils.php');
$json = getJSONobj();
/*
$upgradeStepTime = $json->decode(html_entity_decode($_REQUEST['upgradeStepTime']));
if(isset($tagdata['jsonObject']) && $tagdata['jsonObject'] != null){
$upgradeStepTime = $upgradeStepTime['jsonObject'];
}
if(!isset($_SESSION['totalUpgradeTime'])){
$_SESSION['totalUpgradeTime'] = 0;
}
*/
$_SESSION['totalUpgradeTime'] = $_SESSION['totalUpgradeTime']+$_REQUEST['upgradeStepTime'];
$response = $_SESSION['totalUpgradeTime'];
$GLOBALS['log']->fatal('TOTAL TIME .....'.$_SESSION['totalUpgradeTime']);
//$uptime = $uptime+$_REQUEST['upgradeStepTime'];
$GLOBALS['log']->fatal($response);
if (!empty($response)) {
$json = getJSONobj();
print $json->encode($response);
}
sugar_cleanup();
exit();
?>

382
modules/UpgradeWizard/upload.php Executable file
View File

@@ -0,0 +1,382 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*********************************************************************************
* Description:
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights
* Reserved. Contributor(s): ______________________________________..
* *******************************************************************************/
logThis('At upload.php');
//set the upgrade progress status.
set_upgrade_progress('upload','in_progress');
$stop = true; // flag to show "next"
$run = isset($_REQUEST['run']) ? $_REQUEST['run'] : '';
$out = '';
if(file_exists('ModuleInstall/PackageManager/PackageManagerDisplay.php')) {
require_once('ModuleInstall/PackageManager/PackageManagerDisplay.php');
}
///////////////////////////////////////////////////////////////////////////////
//// UPLOAD FILE PROCESSING
switch($run) {
case 'upload':
logThis('running upload');
$perform = false;
$tempFile = '';
if(isset($_REQUEST['release_id']) && $_REQUEST['release_id'] != ""){
require_once('ModuleInstall/PackageManager/PackageManager.php');
$pm = new PackageManager();
$tempFile = '';
$perform = false;
if(!empty($_SESSION['ML_PATCHES'])){
$release_map = $_SESSION['ML_PATCHES'][$_REQUEST['release_id']];
if(!empty($release_map)){
$tempFile = $pm->download($release_map['category_id'], $release_map['package_id'], $_REQUEST['release_id'], getcwd().'/'.$sugar_config['upload_dir']);
$perform = true;
if($release_map['type'] != 'patch'){
$pm->performSetup($tempFile, $release_map['type'], false);
header('Location: index.php?module=Administration&action=UpgradeWizard&view=module');
}
}
}
$base_filename = urldecode($tempFile);
}
else if( empty( $_FILES['upgrade_zip']['tmp_name'] ) ) {
logThis('ERROR: no file uploaded!');
echo $mod_strings['ERR_UW_NO_FILE_UPLOADED'];
// add PHP error if isset
if(isset($_FILES['upgrade_zip']['error']) && !empty($_FILES['upgrade_zip']['error'])) {
$out = "<b><span class='error'>{$mod_strings['ERR_UW_PHP_FILE_ERRORS'][$_FILES['upgrade_zip']['error']]}</span></b><br />";
}
} else {
if(!move_uploaded_file($_FILES['upgrade_zip']['tmp_name'], getcwd().'/'.$sugar_config['upload_dir'].$_FILES['upgrade_zip']['name'])) {
logThis('ERROR: could not move temporary file to final destination!');
unlinkTempFiles();
$out = "<b><span class='error'>{$mod_strings['ERR_UW_NOT_VALID_UPLOAD']}</span></b><br />";
} else {
$tempFile = getcwd().'/'.$sugar_config['upload_dir'].$_FILES['upgrade_zip']['name'];
logThis('File uploaded to '.$tempFile);
$base_filename = urldecode( $_REQUEST['upgrade_zip_escaped'] );
$perform = true;
}
}
if($perform){
$manifest_file = extractManifest($tempFile);
if(is_file($manifest_file)) {
require_once( $manifest_file );
$error = validate_manifest( $manifest );
if(!empty($error)) {
$out = "<b><span class='error'>{$error}</span></b><br />";
break;
}
$upgrade_zip_type = $manifest['type'];
// exclude the bad permutations
if($upgrade_zip_type != "patch") {
logThis('ERROR: incorrect patch type found: '.$upgrade_zip_type);
unlinkTempFiles();
$out = "<b><span class='error'>{$mod_strings['ERR_UW_ONLY_PATCHES']}</span></b><br />";
break;
}
$base_filename = preg_replace( "#\\\\#", "/", $base_filename );
$base_filename = basename( $base_filename );
mkdir_recursive( "$base_upgrade_dir/$upgrade_zip_type" );
$target_path = "$base_upgrade_dir/$upgrade_zip_type/$base_filename";
$target_manifest = remove_file_extension( $target_path ) . "-manifest.php";
if(isset($manifest['icon']) && $manifest['icon'] != "" ) {
logThis('extracting icons.');
$icon_location = extractFile( $tempFile ,$manifest['icon'] );
$path_parts = pathinfo( $icon_location );
copy( $icon_location, remove_file_extension( $target_path ) . "-icon." . $path_parts['extension'] );
}
if(copy($tempFile , $target_path)){
logThis('copying manifest.php to final destination.');
copy($manifest_file, $target_manifest);
$out .= "{$base_filename} {$mod_strings['LBL_UW_FILE_UPLOADED']}.<br>\n";
} else {
logThis('ERROR: cannot copy manifest.php to final destination.');
$out .= "<b><span class='error'>{$mod_strings['ERR_UW_UPLOAD_ERR']}</span></b><br />";
break;
}
} else {
logThis('ERROR: no manifest.php file found!');
unlinkTempFiles();
$out = "<b><span class='error'>{$mod_strings['ERR_UW_NO_MANIFEST']}</span></b><br />";
break;
}
$_SESSION['install_file'] = clean_path($tempFile);
logThis('zip file moved to ['.$_SESSION['install_file'].']');
//rrs serialize manifest for saving in the db
$serial_manifest = array();
$serial_manifest['manifest'] = (isset($manifest) ? $manifest : '');
$serial_manifest['installdefs'] = (isset($installdefs) ? $installdefs : '');
$serial_manifest['upgrade_manifest'] = (isset($upgrade_manifest) ? $upgrade_manifest : '');
$_SESSION['install_manifest'] = base64_encode(serialize($serial_manifest));
}
if(!empty($tempFile)) {
upgradeUWFiles($tempFile);
//set the upgrade progress status. actually it should be set when a file is uploaded
set_upgrade_progress('upload','done');
}
break; // end 'upload'
case 'delete':
logThis('running delete');
if(!isset($_REQUEST['install_file']) || ($_REQUEST['install_file'] == "")) {
logThis('ERROR: trying to delete non-existent file: ['.$_REQUEST['install_file'].']');
$error = $mod_strings['ERR_UW_NO_FILE_UPLOADED'];
}
// delete file in upgrades/patch
$delete_me = urldecode( $_REQUEST['install_file'] );
if(@unlink($delete_me)) {
logThis('unlinking: '.$delete_me);
$out = basename($delete_me).$mod_strings['LBL_UW_FILE_DELETED'];
} else {
logThis('ERROR: could not delete ['.$delete_me.']');
$error = $mod_strings['ERR_UW_FILE_NOT_DELETED'].$delete_me;
}
// delete file in cache/upload
$fileS = explode('/', $delete_me);
$c = count($fileS);
$fileName = (isset($fileS[$c-1]) && !empty($fileS[$c-1])) ? $fileS[$c-1] : $fileS[$c-2];
$deleteUpload = getcwd().'/'.$sugar_config['upload_dir'].$fileName;
logThis('Trying to delete '.$deleteUpload);
if(!@unlink($deleteUpload)) {
logThis('ERROR: could not delete: ['.$deleteUpload.']');
$error = $mod_strings['ERR_UW_FILE_NOT_DELETED'].$sugar_config['upload_dir'].$fileName;
}
if(!empty($error)) {
$out = "<b><span class='error'>{$error}</span></b><br />";
}
unlinkTempFiles();
unlinkUploadFiles();
//set the upgrade progress status. actually it should be set when a file is uploaded
set_upgrade_progress('upload','in_progress');
break;
}
//// END UPLOAD FILE PROCESSING FORM
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//// READY TO INSTALL UPGRADES
$validReturn = getValidPatchName();
$ready = $validReturn['ready'];
$disabled = $validReturn['disabled'];
//// END READY TO INSTALL UPGRADES
///////////////////////////////////////////////////////////////////////////////
if(isset($_SESSION['install_file']) && !empty($_SESSION['install_file']) && is_file($_SESSION['install_file'])) {
$stop = false;
} else {
$stop = true;
}
if($stop == false) set_upgrade_progress('upload','done');
$frozen = $out;
///////////////////////////////////////////////////////////////////////////////
//// UPLOAD FORM
$form = '';
if(empty($GLOBALS['sugar_config']['disable_uw_upload'])){
$form =<<<eoq
<form name="the_form" id='the_form' enctype="multipart/form-data" action="index.php" method="post">
<input type="hidden" name="module" value="UpgradeWizard">
<input type="hidden" name="action" value="index">
<input type="hidden" name="step" value="{$_REQUEST['step']}">
<input type="hidden" name="run" value="upload">
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="edit view">
<tr><td>
<table width="450" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
{$mod_strings['LBL_UPLOAD_UPGRADE']}
<input type="file" onchange="uploadCheck();" name="upgrade_zip" id="upgrade_zip" size="40" />
</td>
<td valign="bottom">&nbsp;
<input id="upload_button" class='button' type=button
{$disabled}
disabled="disabled"
value="{$mod_strings['LBL_UW_TITLE_UPLOAD']}"
onClick="uploadCheck();upgradeP('uploadingUpgardePackage');document.the_form.upgrade_zip_escaped.value = escape( document.the_form.upgrade_zip.value );document.the_form.submit();" />
<input type=hidden name="upgrade_zip_escaped" value="" />
</td>
</tr>
</table>
</td></tr>
</table>
</form>
eoq;
}
$hidden_fields = "<input type=\"hidden\" name=\"module\" value=\"UpgradeWizard\">";
$hidden_fields .= "<input type=\"hidden\" name=\"action\" value=\"index\">";
$hidden_fields .= "<input type=\"hidden\" name=\"step\" value=\"{$_REQUEST['step']}\">";
$hidden_fields .= "<input type=\"hidden\" name=\"run\" value=\"upload\">";
$form2 = '';
/* Removing Install From Sugar tab from Upgradewizard.
if(class_exists("PackageManagerDisplay")) {
$form2 = PackageManagerDisplay::buildPatchDisplay($form, $hidden_fields, 'index.php', array('patch', 'module'));
}
*/
if($form2 == null){
$form2 = $form;
}
$form3 =<<<eoq2
<br>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="edit view">
<tr><td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
{$mod_strings['LBL_UW_FILES_QUEUED']}<br>
{$ready}
</td>
</tr>
</table>
</td></tr>
</table>
<script type="text/javascript" language="Javascript" src="include/JSON.js"></script>
<script>
function fileBrowseLoaded(){
//alert(document.the_form.upgrade_zip.value.length);
if(escape(document.the_form.upgrade_zip.value).length == 0 || escape(document.the_form.upgrade_zip.value) == 'undefined'){
document.the_form.upload_button.disabled= 'disabled';
}
else{
document.the_form.upload_button.disabled= '';
}
var len = escape(document.the_form.upgrade_zip.value).length;
}
function uploadCheck(){
var len = escape(document.the_form.upgrade_zip.value).length;
var file_extn = escape(document.the_form.upgrade_zip.value).substr(len-3,len);
if(file_extn.toLowerCase() !='zip'){
//document.the_form.upgrade_zip.value = '';
//document.getElementById("upgrade_zip").value = '';
alert('Not a zip file');
document.getElementById("upgrade_zip").value='';
document.getElementById("upload_button").disabled='disabled';
}
else{
//AJAX call for checking the file size and comparing with php.ini settings.
var callback = {
success:function(r) {
var file_size = r.responseText;
//alert(file_size.length);
if(file_size.length >0){
var msg = SUGAR.language.get('UpgradeWizard','LBL_UW_FILE_SIZE');
msg1 =SUGAR.language.get('UpgradeWizard','LBL_UW_FILE_BIGGER_MSG');
msg2 = SUGAR.language.get('UpgradeWizard','LBL_BYTES_WEBSERVER_MSG');
if(msg == 'undefined') msg = 'The file size, ';
if(msg1 == 'undefined') msg1 = ' Bytes, is greater than what is allowed by the upload_max_filesize and/or the post_max_size settings in php.ini. Change the settings so that they are greater than ';
if(msg2 == 'undefined') msg2 = ' Bytes and restart the webserver.';
msg = msg+file_size+msg1;
msg = msg+file_size+msg2;
alert(msg);
document.getElementById("upload_button").disabled='disabled';
}
else{
document.getElementById("upload_button").disabled='';
}
}
}
//var file_name = document.getElementById('upgrade_zip').value;
var file_name = document.the_form.upgrade_zip.value;
postData = 'file_name=' + JSON.stringify(file_name) + '&module=UpgradeWizard&action=UploadFileCheck&to_pdf=1';
YAHOO.util.Connect.asyncRequest('POST', 'index.php', callback, postData);
}
}
</script>
eoq2;
$form5 =<<<eoq5
<br>
<div id="upgradeDiv" style="display:none">
<table cellspacing="0" cellpadding="0" border="0">
<tr><td>
<p><img src='modules/UpgradeWizard/processing.gif'> <br>{$mod_strings['LBL_UPGRADE_TAKES_TIME_HAVE_PATIENCE']}</p>
</td></tr>
</table>
</div>
eoq5;
$uwMain = $form2.$form3.$form5;
//// END UPLOAD FORM
///////////////////////////////////////////////////////////////////////////////
//set the upgrade progress status. actually it should be set when a file is uploaded
//set_upgrade_progress('upload','done');
$showBack = true;
$showCancel = true;
$showRecheck = true;
$showNext = ($stop) ? false : true;
$stepBack = $_REQUEST['step'] - 1;
$stepNext = $_REQUEST['step'] + 1;
$stepCancel = -1;
$stepRecheck = $_REQUEST['step'];
$_SESSION['step'][$steps['files'][$_REQUEST['step']]] = ($stop) ? 'failed' : 'success';
?>

914
modules/UpgradeWizard/uw_ajax.php Executable file
View File

@@ -0,0 +1,914 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*********************************************************************************
* Description:
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights
* Reserved. Contributor(s): ______________________________________..
* *******************************************************************************/
//// COMMON
function ajaxSqlProgress($persistence, $sql, $type) {
global $mod_strings;
// $type is sql_to_check or sql_to_run
$whatsLeft = count($persistence[$type]);
ob_start();
$out = "<b>{$mod_strings['LBL_UW_PREFLIGHT_QUERY']}</b><br />";
$out .= round((($persistence['sql_total'] - $whatsLeft) / $persistence['sql_total']) * 100, 1)."%
{$mod_strings['LBL_UW_DONE']} - {$mod_strings['LBL_UW_PREFLIGHT_QUERIES_LEFT']}: {$whatsLeft}";
$out .= "<br /><textarea cols='60' rows='3' DISABLED>{$sql}</textarea>";
echo $out;
ob_flush();
if($whatsLeft < 1) {
$persistence['sql_check_done'] = true;
}
return $persistence;
}
///////////////////////////////////////////////////////////////////////////////
//// COMMIT AJAX
/**
* does post-post-install stuff
* @param array persistence
* @return array persistence
*/
function commitAjaxFinalTouches($persistence) {
global $current_user;
global $locale;
global $mod_strings;
global $sugar_version;
if(empty($sugar_version)) {
require('sugar_version.php');
}
// convert to UTF8 if needed
if(!empty($persistence['allTables']))
executeConvertTablesSql($db->dbType, $persistence['allTables']);
// rebuild
logThis('Performing UWrebuild()...');
UWrebuild();
logThis('UWrebuild() done.');
// upgrade history
registerUpgrade($persistence);
// flag to say upgrade has completed
$persistence['upgrade_complete'] = true;
// reminders if needed
///////////////////////////////////////////////////////////////////////////////
//// HANDLE REMINDERS
if(count($persistence['skipped_files']) > 0) {
$desc = $mod_strings['LBL_UW_COMMIT_ADD_TASK_OVERVIEW']."\n\n";
$desc .= $mod_strings['LBL_UW_COMMIT_ADD_TASK_DESC_1'];
$desc .= $persistence['uw_restore_dir']."\n\n";
$desc .= $mod_strings['LBL_UW_COMMIT_ADD_TASK_DESC_2']."\n\n";
foreach($persistence['skipped_files'] as $file) {
$desc .= $file."\n";
}
//MFH #13468
$nowDate = gmdate($timedate->dbDateFormat);
$nowTime = gmdate($timedate->dbTimeFormat);
$nowDateTime = $nowDate.' '.$nowTime;
if($_REQUEST['addTaskReminder'] == 'remind') {
logThis('Adding Task for admin for manual merge.');
$task = new Task();
$task->name = $mod_strings['LBL_UW_COMMIT_ADD_TASK_NAME'];
$task->description = $desc;
$task->date_due = $nowDate;
$task->time_due = $nowTime;
$task->priority = 'High';
$task->status = 'Not Started';
$task->assigned_user_id = $current_user->id;
$task->created_by = $current_user->id;
$task->date_entered = $nowDateTime;
$task->date_modified = $nowDateTime;
$task->save();
}
if($_REQUEST['addEmailReminder'] == 'remind') {
logThis('Sending Reminder for admin for manual merge.');
$email = new Email();
$email->assigned_user_id = $current_user->id;
$email->name = $mod_strings['LBL_UW_COMMIT_ADD_TASK_NAME'];
$email->description = $desc;
$email->description_html = nl2br($desc);
$email->from_name = $current_user->full_name;
$email->from_addr = $current_user->email1;
$email->to_addrs_arr = $email->parse_addrs($current_user->email1,'','','');
$email->cc_addrs_arr = array();
$email->bcc_addrs_arr = array();
$email->date_entered = $nowDateTime;
$email->date_modified = $nowDateTime;
$email->send();
$email->save();
}
}
//// HANDLE REMINDERS
///////////////////////////////////////////////////////////////////////////////
// clean up
unlinkTempFiles();
ob_start();
echo 'done';
ob_flush();
return $persistence;
}
/**
* runs one line of sql
* @param array $persistence
* @return array $persistence
*/
function commitAjaxRunSql($persistence) {
global $db;
if(!isset($persistence['commit_sql_errors'])) {
$persistence['commit_sql_errors'] = array();
}
// This flag is determined by the preflight check in the installer
if($persistence['schema_change'] == 'sugar') {
if(isset($persistence['sql_to_run'])
&& count($persistence['sql_to_run']) > 0
&& !empty($persistence['sql_to_run'])) {
$sql = array_shift($persistence['sql_to_run']);
$sql = trim($sql);
if(!empty($sql)) {
logThis("[RUNNING SQL QUERY] {$sql}");
$db->query($sql);
$error = '';
switch($db->dbType) {
case 'mysql':
$error = mysql_error();
break;
case 'oci8':
break;
case 'mssql':
break;
}
if(!empty($error)) {
logThis('************************************************************');
logThis('*** ERROR: SQL Commit Error!');
logThis('*** Query: [ '.$sql.' ]');
logThis('************************************************************');
$persistence['commit_sql_errors'][] = getFormattedError($error, $sql);
}
$persistence = ajaxSqlProgress($persistence, $sql, 'sql_to_run');
}
} else {
ob_start();
echo 'done';
ob_flush();
}
} else {
ob_start();
echo 'done';
ob_flush();
}
return $persistence;
}
/**
* returns errors found during SQL operations
* @param array persistence
* @return string Error message or empty string on success
*/
function commitAjaxGetSqlErrors($persistence) {
global $mod_strings;
$out = '';
if(isset($persistence['commit_sql_errors']) && !empty($persistence['commit_sql_errors'])) {
$out = "<div class='error'>";
foreach($persistence['commit_sql_errors'] as $error) {
$out .= $error;
}
$out .= "</div>";
}
if(empty($out)) {
$out = $mod_strings['LBL_UW_COMMIT_ALL_SQL_SUCCESSFULLY_RUN'];
}
ob_start();
echo $out;
ob_flush();
}
/**
* parses the sql upgrade file for sequential querying
* @param array persistence
* @return array persistence
*/
function commitAjaxPrepSql($persistence) {
return preflightCheckJsonPrepSchemaCheck($persistence, false);
}
/**
* handles post-install tasks
*/
function commitAjaxPostInstall($persistence) {
global $mod_strings;
global $sugar_config;
global $sugar_version;
if(empty($sugar_version)) {
require('sugar_version.php');
}
// update versions info
if(!updateVersions($sugar_version)) {
echo $mod_strings['ERR_UW_COMMIT_UPDATE_VERSIONS'];
}
logThis('Starting post_install()...');
$postInstallResults = "<b>{$mod_strings['LBL_UW_COMMIT_POSTINSTALL_RESULTS']}</b><br />
<a href='javascript:toggleNwFiles(\"postInstallResults\");'>{$mod_strings['LBL_UW_SHOW']}</a><br />
<div id='postInstallResults' style='display:none'>";
$file = $persistence['unzip_dir']. "/" . constant('SUGARCRM_POST_INSTALL_FILE');
if(is_file($file)) {
include($file);
ob_start();
post_install();
}
require( "sugar_version.php" );
if (!rebuildConfigFile($sugar_config, $sugar_version)) {
logThis('*** ERROR: could not write config.php! - upgrade will fail!');
$errors[] = $mod_strings['ERR_UW_CONFIG_WRITE'];
}
$res = ob_get_contents();
$postInstallResults .= (empty($res)) ? $mod_strings['LBL_UW_SUCCESS'] : $res;
$postInstallResults .= "</div>";
ob_start();
echo $postInstallResults;
ob_flush();
logThis('post_install() done.');
}
//// END COMMIT AJAX
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//// PREFLIGHT JSON STYLE
function preflightCheckJsonFindUpgradeFiles($persistence) {
global $sugar_config;
global $mod_strings;
unset($persistence['rebuild_relationships']);
unset($persistence['rebuild_extensions']);
// don't bother if are rechecking
$manualDiff = array();
if(!isset($persistence['unzip_dir']) || empty($persistence['unzip_dir'])) {
logThis('unzipping files in upgrade archive...');
$errors = array();
$base_upgrade_dir = $sugar_config['upload_dir'] . "/upgrades";
$base_tmp_upgrade_dir = "$base_upgrade_dir/temp";
$install_file = urldecode( $persistence['install_file'] );
$show_files = true;
$unzip_dir = clean_path(mk_temp_dir( $base_tmp_upgrade_dir ));
$zip_from_dir = ".";
$zip_to_dir = ".";
$zip_force_copy = array();
unzip( $install_file, $unzip_dir );
// assumption -- already validated manifest.php at time of upload
include( "$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( !is_writable( "config.php" ) ){
logThis('BAD error');
return $mod_strings['ERR_UW_CONFIG'];
}
logThis('setting "unzip_dir" to '.$unzip_dir);
$persistence['unzip_dir'] = clean_path($unzip_dir);
$persistence['zip_from_dir'] = clean_path($zip_from_dir);
logThis('unzip done.');
} else {
$unzip_dir = $persistence['unzip_dir'];
$zip_from_dir = $persistence['zip_from_dir'];
}
$persistence['upgrade_files'] = uwFindAllFiles(clean_path("$unzip_dir/$zip_from_dir"), array(), true, array(), true);
return $persistence;
}
function preflightCheckJsonDiffFiles($persistence) {
global $sugar_version;
global $mod_strings;
if(!isset($sugar_version) || empty($sugar_version)) {
}
// get md5 sums
$md5_string = array();
$finalZipDir = $persistence['unzip_dir'].'/'.$persistence['zip_from_dir'];
if(is_file(getcwd().'/files.md5'))
require(getcwd().'/files.md5');
// initialize pass array
$manualDiff = array();
// file preflight checks
logThis('verifying md5 checksums for files...');
$cache_html_files = findAllFilesRelative( "{$GLOBALS['sugar_config']['cache_dir']}layout", array());
foreach($persistence['upgrade_files'] as $file) {
if(strpos($file, '.md5'))
continue; // skip md5 file
// normalize file paths
$file = clean_path($file);
// check that we can move/delete the upgraded file
if(!is_writable($file)) {
$errors[] = $mod_strings['ERR_UW_FILE_NOT_WRITABLE'].": ".$file;
}
// check that destination files are writable
$destFile = getcwd().str_replace($finalZipDir, '', $file);
if(is_file($destFile)) { // of course it needs to exist first...
if(!is_writable($destFile)) {
$errors[] = $mod_strings['ERR_UW_FILE_NOT_WRITABLE'].": ".$destFile;
}
}
///////////////////////////////////////////////////////////////////////
//// DIFFS
// compare md5s and build up a manual merge list
$targetFile = clean_path(".".str_replace(getcwd(),'',$destFile));
$targetMd5 = '0';
if(is_file($destFile)) {
if(strpos($targetFile, '.php')) {
// handle PHP files that were hit with the security regex
$fp = sugar_fopen($destFile, 'r');
$filesize = filesize($destFile);
if($filesize > 0) {
$fileContents = fread($fp, $filesize);
$targetMd5 = md5($fileContents);
}
} else {
$targetMd5 = md5_file($destFile);
}
}
if(isset($md5_string[$targetFile]) && $md5_string[$targetFile] != $targetMd5) {
logThis('found a file with a differing md5: ['.$targetFile.']');
$manualDiff[] = $destFile;
}
//// END DIFFS
///////////////////////////////////////////////////////////////////////
echo ".";
}
logThis('md5 verification done.');
$persistence['manual'] = $manualDiff;
$persistence['diff_errors'] = $errors;
return $persistence;
}
function preflightCheckJsonGetDiff($persistence) {
global $mod_strings;
global $current_user;
$out = $mod_strings['LBL_UW_PREFLIGHT_TESTS_PASSED'];
$stop = false;
$disableEmail = (empty($current_user->email1)) ? 'DISABLED' : 'CHECKED';
if(count($persistence['manual']) > 0) {
$preserveFiles = array();
$diffs =<<<eoq
<script type="text/javascript" language="Javascript">
function preflightToggleAll(cb) {
var checkAll = false;
var form = document.getElementById('diffs');
if(cb.checked == true) {
checkAll = true;
}
for(i=0; i<form.elements.length; i++) {
if(form.elements[i].type == 'checkbox') {
form.elements[i].checked = checkAll;
}
}
return;
}
</script>
<table cellpadding='0' cellspacing='0' border='0'>
<tr>
<td valign='top'>
<input type='checkbox' name='addTask' id='addTask' CHECKED>
</td>
<td valign='top'>
{$mod_strings['LBL_UW_PREFLIGHT_ADD_TASK']}
</td>
</tr>
<tr>
<td valign='top'>
<input type='checkbox' name='addEmail' id='addEmail' $disableEmail>
</td>
<td valign='top'>
{$mod_strings['LBL_UW_PREFLIGHT_EMAIL_REMINDER']}
</td>
</tr>
</table>
<form name='diffs' id='diffs'>
<p><a href='javascript:void(0); toggleNwFiles("diffsHide");'>{$mod_strings['LBL_UW_SHOW_DIFFS']}</a></p>
<div id='diffsHide' style='display:none'>
<table cellpadding='0' cellspacing='0' border='0'>
<tr>
<td valign='top' colspan='2'>
{$mod_strings['LBL_UW_PREFLIGHT_FILES_DESC']}
<br />&nbsp;
</td>
</tr>
<tr>
<td valign='top' colspan='2'>
<input type='checkbox' onchange='preflightToggleAll(this);'>&nbsp;<i><b>{$mod_strings['LBL_UW_PREFLIGHT_TOGGLE_ALL']}</b></i>
<br />&nbsp;
</td>
</tr>
eoq;
foreach($persistence['manual'] as $diff) {
$diff = clean_path($diff);
$persistence['files']['manual'][] = $diff;
$checked = (isAutoOverwriteFile($diff)) ? 'CHECKED' : '';
if(empty($checked)) {
$preserveFiles[] = $diff;
}
$diffs .= "<tr><td valign='top'>";
$diffs .= "<input type='checkbox' name='diff_files[]' value='{$diff}' $checked>";
$diffs .= "</td><td valign='top'>";
$diffs .= str_replace(getcwd(), '.', $diff);
$diffs .= "</td></tr>";
}
$diffs .= "</table>";
$diffs .= "</div></p>";
$diffs .= "</form>";
// list preserved files (templates, etc.)
$preserve = '';
foreach($preserveFiles as $pf) {
if(empty($preserve)) {
$preserve .= "<table cellpadding='0' cellspacing='0' border='0'><tr><td><b>";
$preserve .= $mod_strings['LBL_UW_PREFLIGHT_PRESERVE_FILES'];
$preserve .= "</b></td></tr>";
}
$preserve .= "<tr><td valign='top'><i>".str_replace(getcwd(), '.', $pf)."</i></td></tr>";
}
if(!empty($preserve)) {
$preserve .= '</table><br>';
}
$diffs = $preserve.$diffs;
} else { // NO FILE DIFFS REQUIRED
$diffs = $mod_strings['LBL_UW_PREFLIGHT_NO_DIFFS'];
}
echo $diffs;
return $persistence;
}
/**
* loads the sql file into an array
* @param array persistence
* @param bool preflight Flag to load for Preflight or Commit
* @return array persistence
*/
function preflightCheckJsonPrepSchemaCheck($persistence, $preflight=true) {
global $mod_strings;
global $db;
global $sugar_db_version;
global $manifest;
unset($persistence['sql_to_run']);
$persistence['sql_to_check'] = array();
$persistence['sql_to_check_backup'] = array();
if(isset($persistence['sql_check_done'])) {
// reset flag to not check (on Recheck)
unset($persistence['sql_check_done']);
unset($persistence['sql_errors']);
}
// get schema script if not loaded
if($preflight)
logThis('starting schema preflight check...');
else
logThis('Preparing SQL statements for sequential execution...');
if(!isset($sugar_db_version) || empty($sugar_db_version)) {
include('./sugar_version.php');
}
if(!isset($manifest['version']) || empty($manifest['version'])) {
include($persistence['unzip_dir'].'/manifest.php');
}
$current_version = substr(preg_replace("#[^0-9]#", "", $sugar_db_version),0,3);
$targetVersion = substr(preg_replace("#[^0-9]#", "", $manifest['version']),0,3);
$sqlScript = $persistence['unzip_dir'].'/scripts/'.$current_version.'_to_'.$targetVersion.'_'.$db->dbType.'.sql';
$newTables = array();
logThis('looking for schema script at: '.$sqlScript);
if(is_file($sqlScript)) {
logThis('found schema upgrade script: '.$sqlScript);
$fp = sugar_fopen($sqlScript, 'r');
$contents = fread($fp, filesize($sqlScript));
if(rewind($fp)) {
$completeLine = '';
while($line = fgets($fp)) {
if(strpos($line, '--') === false) {
$completeLine .= " ".trim($line);
if(strpos($line, ';') !== false) {
$completeLine = str_replace(';','',$completeLine);
$persistence['sql_to_check'][] = $completeLine;
$completeLine = ''; //reset for next loop
}
}
}
$persistence['sql_total'] = count($persistence['sql_to_check']);
} else {
logThis('*** ERROR: could not read schema script: '.$sqlScript);
$persistence['sql_errors'][] = $mod_strings['ERR_UW_FILE_NOT_READABLE'].'::'.$sqlScript;
}
}
// load a new array if for commit
if($preflight) {
$persistence['sql_to_check_backup'] = $persistence['sql_to_check'];
$persistence['sql_to_run'] = $persistence['sql_to_check'];
echo "1% ".$mod_strings['LBL_UW_DONE'];
} else {
$persistence['sql_to_run'] = $persistence['sql_to_check'];
unset($persistence['sql_to_check']);
}
return $persistence;
}
function preflightCheckJsonSchemaCheck($persistence) {
global $mod_strings;
global $db;
if(!isset($persistence['sql_check_done']) || $persistence['sql_check_done'] != true) {
// must keep sql in order
$completeLine = array_shift($persistence['sql_to_check']);
$whatsLeft = count($persistence['sql_to_check']);
// populate newTables array to prevent "getting sample data" from non-existent tables
$newTables = array();
if(strtoupper(substr($completeLine,1,5)) == 'CREAT')
$newTables[] = getTableFromQuery($completeLine);
$bad = verifySqlStatement(trim($completeLine), $db->dbType, $newTables);
if(!empty($bad)) {
logThis('*** ERROR: schema change script has errors: '.$completeLine);
$persistence['sql_errors'][] = $bad;
}
$persistence = ajaxSqlProgress($persistence, $completeLine, 'sql_to_check');
} else {
$persistence['sql_to_check'] = $persistence['sql_to_check_backup'];
echo 'done';
}
return $persistence;
}
function preflightCheckJsonGetSchemaErrors($persistence) {
global $mod_strings;
if(isset($persistence['sql_errors']) && count($persistence['sql_errors'] > 0)) {
$out = "<b class='error'>{$mod_strings['ERR_UW_PREFLIGHT_ERRORS']}:</b> ";
$out .= "<a href='javascript:void(0);toggleNwFiles(\"sqlErrors\");'>{$mod_strings['LBL_UW_SHOW_SQL_ERRORS']}</a><div id='sqlErrors' style='display:none'>";
foreach($persistence['sql_errors'] as $sqlError) {
$out .= "<br><span class='error'>{$sqlError}</span>";
}
$out .= "</div><hr />";
} else {
$out = '';
}
// reset errors if Rechecking
if(isset($persistence['sql_errors']))
//unset($persistence['sql_errors']);
echo $out;
return $persistence;
}
function preflightCheckJsonFillSchema() {
global $mod_strings;
global $persistence;
global $sugar_db_version;
global $manifest;
global $db;
if(empty($sugar_db_version)) {
include('sugar_version');
}
if(empty($manifest)) {
include($persistence['unzip_dir'].'/manifest.php');
}
///////////////////////////////////////////////////////////////////////////////
//// SCHEMA SCRIPT HANDLING
$schema = '';
$alterTableSchemaOut = '';
$current_version = substr(preg_replace("#[^0-9]#", "", $sugar_db_version),0,3);
$targetVersion = substr(preg_replace("#[^0-9]#", "", $manifest['version']),0,3);
$sqlScript = $persistence['unzip_dir'].'/scripts/'.$current_version.'_to_'.$targetVersion.'_'.$db->dbType.'.sql';
$newTables = array();
logThis('looking for SQL script for DISPLAY at '.$sqlScript);
if(file_exists($sqlScript)) {
$fp = sugar_fopen($sqlScript, 'r');
$contents = fread($fp, filesize($sqlScript));
$schema = "<p><a href='javascript:void(0); toggleNwFiles(\"schemashow\");'>{$mod_strings['LBL_UW_SHOW_SCHEMA']}</a>";
$schema .= "<div id='schemashow' style='display:none;'>";
$schema .= "<textarea readonly cols='80' rows='10'>{$contents}</textarea>";
$schema .= "</div></p>";
}
//// END SCHEMA SCRIPT HANDLING
///////////////////////////////////////////////////////////////////////////////
ob_start();
echo $schema;
ob_flush();
}
function preflightCheckJsonAlterTableCharset() {
global $mod_strings;
global $sugar_db_version;
global $persistence;
if(empty($sugar_db_version))
include('sugar_version.php');
$current_version = substr(preg_replace("#[^0-9]#", "", $sugar_db_version),0,3);
if(version_compare($current_version, '450', "<")) {
if(isset($persistence['allTables']) && !empty($persistence['allTables'])) {
$alterTableContents = printAlterTableSql($persistence['allTables']);
$alterTableSchema = "<p><a href='javascript:void(0); toggleNwFiles(\"alterTableSchemashow\");'>{$mod_strings['LBL_UW_CHARSET_SCHEMA_CHANGE']}</a>";
$alterTableSchema .= "<div id='alterTableSchemashow' style='display:none;'>";
$alterTableSchema .= "<textarea readonly cols='80' rows='10'>{$alterTableContents}</textarea>";
$alterTableSchema .= "</div></p>";
}
} else {
$alterTableSchema = '<i>'.$mod_strings['LBL_UW_PREFLIGHT_NOT_NEEDED'].'</i>';
}
ob_start();
echo $alterTableSchema;
ob_flush();
}
///////////////////////////////////////////////////////////////////////////////
//// SYSTEMCHECK AJAX FUNCTIONS
function systemCheckJsonGetFiles($persistence) {
global $sugar_config;
global $mod_strings;
// add directories here that should be skipped when doing file permissions checks (cache/upload is the nasty one)
$skipDirs = array(
$sugar_config['upload_dir'],
getcwd().'/themes',
);
if(!isset($persistence['dirs_checked'])) {
$the_array = array();
$files = array();
$dir = getcwd();
$d = dir($dir);
while($f = $d->read()) {
if($f == "." || $f == "..") // skip *nix self/parent
continue;
if(is_dir("$dir/$f"))
$the_array[] = clean_path("$dir/$f");
else {
$files[] = clean_path("$dir/$f");
}
}
$persistence['files_to_check'] = $files;
$persistence['dirs_to_check'] = $the_array;
$persistence['dirs_total'] = count($the_array);
$persistence['dirs_checked'] = false;
$out = "1% {$mod_strings['LBL_UW_DONE']}";
return $persistence;
} elseif($persistence['dirs_checked'] == false) {
$dir = array_pop($persistence['dirs_to_check']);
$files = uwFindAllFiles($dir, array(), true, $skipDirs);
$persistence['files_to_check'] = array_merge($persistence['files_to_check'], $files);
$whatsLeft = count($persistence['dirs_to_check']);
if(!isset($persistence['dirs_to_check']) || $whatsLeft < 1) {
$whatsLeft = 0;
$persistence['dirs_checked'] = true;
}
$out = round((($persistence['dirs_total'] - $whatsLeft) / 21) * 100, 1)."% {$mod_strings['LBL_UW_DONE']}";
$out .= " [{$mod_strings['LBL_UW_SYSTEM_CHECK_CHECKING_JSON']} {$dir}]";
} else {
$out = "Done";
}
echo trim($out);
return $persistence;
}
/**
* checks files for permissions
* @param array files Array of files with absolute paths
* @return string result of check
*/
function systemCheckJsonCheckFiles($persistence) {
global $mod_strings;
global $persistence;
$filesNotWritable = array();
$i=0;
$filesOut = "
<a href='javascript:void(0); toggleNwFiles(\"filesNw\");'>{$mod_strings['LBL_UW_SHOW_NW_FILES']}</a>
<div id='filesNw' style='display:none;'>
<table cellpadding='3' cellspacing='0' border='0'>
<tr>
<th align='left'>{$mod_strings['LBL_UW_FILE']}</th>
<th align='left'>{$mod_strings['LBL_UW_FILE_PERMS']}</th>
<th align='left'>{$mod_strings['LBL_UW_FILE_OWNER']}</th>
<th align='left'>{$mod_strings['LBL_UW_FILE_GROUP']}</th>
</tr>";
$isWindows = is_windows();
foreach($persistence['files_to_check'] as $file) {
// while($file = array_pop($persistence['files_to_check'])) {
// admin deletes a bad file mid-check:
if(!file_exists($file))
continue;
if($isWindows) {
if(!is_writable_windows($file)) {
logThis('WINDOWS: File ['.$file.'] not readable - saving for display');
// don't warn yet - we're going to use this to check against replacement files
$filesNotWritable[$i] = $file;
$filesNWPerms[$i] = substr(sprintf('%o',fileperms($file)), -4);
$filesOut .= "<tr>".
"<td valign='top'><span class='error'>{$file}</span></td>".
"<td valign='top'>{$filesNWPerms[$i]}</td>".
"<td valign='top'>".$mod_strings['ERR_UW_CANNOT_DETERMINE_USER']."</td>".
"<td valign='top'>".$mod_strings['ERR_UW_CANNOT_DETERMINE_GROUP']."</td>".
"</tr>";
}
} else {
if(!is_writable($file)) {
logThis('File ['.$file.'] not writable - saving for display');
// don't warn yet - we're going to use this to check against replacement files
$filesNotWritable[$i] = $file;
$filesNWPerms[$i] = substr(sprintf('%o',fileperms($file)), -4);
$owner = posix_getpwuid(fileowner($file));
$group = posix_getgrgid(filegroup($file));
$filesOut .= "<tr>".
"<td valign='top'><span class='error'>{$file}</span></td>".
"<td valign='top'>{$filesNWPerms[$i]}</td>".
"<td valign='top'>".$owner['name']."</td>".
"<td valign='top'>".$group['name']."</td>".
"</tr>";
}
}
$i++;
}
$filesOut .= '</table></div>';
// not a stop error
$persistence['filesNotWritable'] = (count($filesNotWritable) > 0) ? true : false;
if(count($filesNotWritable) < 1) {
$filesOut = "{$mod_strings['LBL_UW_FILE_NO_ERRORS']}";
$persistence['step']['systemCheck'] = 'success';
}
echo $filesOut;
return $persistence;
}
?>

View File

@@ -0,0 +1,46 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
//empty function getJSPath().. there is some dependency in meta upgrade
function getJSPath($file=''){
//nothing here fake function
}
?>

View File

@@ -0,0 +1,110 @@
<?php
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
global $sugar_version;
if(!defined('sugarEntry') || !sugarEntry) {
die('Not A Valid Entry Point');
}
///////////////////////////////////////////////////////////////////////////////
//// DYNAMICALLY GENERATE UPGRADEWIZARD MODULE FILE LIST
$uwFilesCurrent = findAllFiles('modules/UpgradeWizard/', array());
// handle 4.x to 4.5.x+ (no UpgradeWizard module)
if(count($uwFilesCurrent) < 5) {
$uwFiles = array(
'modules/UpgradeWizard/language/en_us.lang.php',
'modules/UpgradeWizard/cancel.php',
'modules/UpgradeWizard/commit.php',
'modules/UpgradeWizard/commitJson.php',
'modules/UpgradeWizard/end.php',
'modules/UpgradeWizard/Forms.php',
'modules/UpgradeWizard/index.php',
'modules/UpgradeWizard/Menu.php',
'modules/UpgradeWizard/preflight.php',
'modules/UpgradeWizard/preflightJson.php',
'modules/UpgradeWizard/start.php',
'modules/UpgradeWizard/su_utils.php',
'modules/UpgradeWizard/su.php',
'modules/UpgradeWizard/systemCheck.php',
'modules/UpgradeWizard/systemCheckJson.php',
'modules/UpgradeWizard/upgradeWizard.js',
'modules/UpgradeWizard/upload.php',
'modules/UpgradeWizard/uw_ajax.php',
'modules/UpgradeWizard/uw_files.php',
'modules/UpgradeWizard/uw_main.tpl',
'modules/UpgradeWizard/uw_utils.php',
);
} else {
$uwFilesCurrent = findAllFiles('ModuleInstall', $uwFilesCurrent);
$uwFilesCurrent = findAllFiles('include/javascript/yui', $uwFilesCurrent);
$uwFilesCurrent[] = 'HandleAjaxCall.php';
$uwFiles = array();
foreach($uwFilesCurrent as $file) {
$uwFiles[] = str_replace("./", "", clean_path($file));
}
}
//// END DYNAMICALLY GENERATE UPGRADEWIZARD MODULE FILE LIST
///////////////////////////////////////////////////////////////////////////////
$uw_files = array(
// standard files we steamroll with no warning
'log4php.properties',
'include/utils/encryption_utils.php',
'include/Pear/Crypt_Blowfish/Blowfish.php',
'include/Pear/Crypt_Blowfish/Blowfish/DefaultKey.php',
'include/utils.php',
'include/utils/external_cache.php',
'include/language/en_us.lang.php',
'include/modules.php',
'include/Localization/Localization.php',
'install/language/en_us.lang.php',
'XTemplate/xtpl.php',
'include/database/DBHelper.php',
'include/database/DBManager.php',
'include/database/DBManagerFactory.php',
'include/database/MssqlHelper.php',
'include/database/MssqlManager.php',
'include/database/MysqlHelper.php',
'include/database/MysqlManager.php',
'include/database/DBManagerFactory.php',
);
$uw_files = array_merge($uw_files, $uwFiles);

4526
modules/UpgradeWizard/uw_utils.php Executable file

File diff suppressed because it is too large Load Diff